diff --git a/dbt_project.yml b/dbt_project.yml index 09ab15b8..328fd70c 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'the_tuva_project' -version: '0.12.1' +version: '0.12.2' config-version: 2 require-dbt-version: ">=1.5.0" @@ -57,196 +57,196 @@ seeds: the_tuva_project: clinical_concept_library: clinical_concept_library__clinical_concepts: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_clinical_concepts.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_clinical_concepts.csv',compression=true,null_marker=true) }}" clinical_concept_library__coding_systems: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_coding_systems.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_coding_systems.csv',compression=true,null_marker=true) }}" clinical_concept_library__value_set_members: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_value_set_members.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_value_set_members.csv',compression=true,null_marker=true) }}" reference_data: reference_data__code_type: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','code_type.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','code_type.csv',compression=true,null_marker=true) }}" reference_data__ansi_fips_state: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ansi_fips_state.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ansi_fips_state.csv',compression=true,null_marker=true) }}" reference_data__calendar: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','calendar.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','calendar.csv',compression=true,null_marker=true) }}" reference_data__fips_county: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','fips_county.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','fips_county.csv',compression=true,null_marker=true) }}" reference_data__ssa_fips_state: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ssa_fips_state.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ssa_fips_state.csv',compression=true,null_marker=true) }}" terminology: terminology__admit_source: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','admit_source.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','admit_source.csv',compression=true,null_marker=true) }}" terminology__admit_type: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','admit_type.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','admit_type.csv',compression=true,null_marker=true) }}" terminology__apr_drg: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','apr_drg.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','apr_drg.csv',compression=true,null_marker=true) }}" terminology__bill_type: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','bill_type.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','bill_type.csv',compression=true,null_marker=true) }}" terminology__claim_type: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','claim_type.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','claim_type.csv',compression=true,null_marker=true) }}" terminology__ccs_services_procedures: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ccs_services_procedures.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ccs_services_procedures.csv',compression=true,null_marker=true) }}" terminology__discharge_disposition: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','discharge_disposition.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','discharge_disposition.csv',compression=true,null_marker=true) }}" terminology__encounter_type: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','encounter_type.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','encounter_type.csv',compression=true,null_marker=true) }}" terminology__ethnicity: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ethnicity.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ethnicity.csv',compression=true,null_marker=true) }}" terminology__gender: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','gender.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','gender.csv',compression=true,null_marker=true) }}" terminology__hcpcs_level_2: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','hcpcs_level_2.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','hcpcs_level_2.csv',compression=true,null_marker=true) }}" terminology__hcpcs_to_rbcs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','hcpcs_to_rbcs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','hcpcs_to_rbcs.csv',compression=true,null_marker=true) }}" terminology__icd_10_cm: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_10_cm.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_10_cm.csv',compression=true,null_marker=true) }}" terminology__icd_10_pcs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_10_pcs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_10_pcs.csv',compression=true,null_marker=true) }}" terminology__icd_9_cm: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_9_cm.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_9_cm.csv',compression=true,null_marker=true) }}" terminology__icd_9_pcs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_9_pcs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_9_pcs.csv',compression=true,null_marker=true) }}" terminology__loinc: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','loinc.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','loinc.csv',compression=true,null_marker=true) }}" terminology__loinc_deprecated_mapping: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','loinc_deprecated_mapping.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','loinc_deprecated_mapping.csv',compression=true,null_marker=true) }}" terminology__mdc: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','mdc.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','mdc.csv',compression=true,null_marker=true) }}" terminology__medicare_dual_eligibility: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_dual_eligibility.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_dual_eligibility.csv',compression=true,null_marker=true) }}" terminology__medicare_orec: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_orec.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_orec.csv',compression=true,null_marker=true) }}" terminology__medicare_status: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_status.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_status.csv',compression=true,null_marker=true) }}" terminology__ms_drg_weights_los: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ms_drg_weights_los.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ms_drg_weights_los.csv',compression=true,null_marker=true) }}" terminology__ms_drg: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ms_drg.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ms_drg.csv',compression=true,null_marker=true) }}" terminology__ndc: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ndc.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ndc.csv',compression=true,null_marker=true) }}" terminology__nitos: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','nitos.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','nitos.csv',compression=true,null_marker=true) }}" terminology__other_provider_taxonomy: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.1','other_provider_taxonomy.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.2','other_provider_taxonomy.csv',compression=true,null_marker=true) }}" terminology__payer_type: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','payer_type.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','payer_type.csv',compression=true,null_marker=true) }}" terminology__place_of_service: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','place_of_service.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','place_of_service.csv',compression=true,null_marker=true) }}" terminology__present_on_admission: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','present_on_admission.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','present_on_admission.csv',compression=true,null_marker=true) }}" terminology__provider: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.1','provider.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.2','provider.csv',compression=true,null_marker=true) }}" terminology__race: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','race.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','race.csv',compression=true,null_marker=true) }}" terminology__revenue_center: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','revenue_center.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','revenue_center.csv',compression=true,null_marker=true) }}" terminology__rxnorm_to_atc: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','rxnorm_to_atc.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','rxnorm_to_atc.csv',compression=true,null_marker=true) }}" terminology__rxnorm_brand_generic: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','rxnorm_brand_generic.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','rxnorm_brand_generic.csv',compression=true,null_marker=true) }}" terminology__snomed_ct: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_ct.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_ct.csv',compression=true,null_marker=true) }}" terminology__snomed_ct_transitive_closures: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_ct_transitive_closures.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_ct_transitive_closures.csv',compression=true,null_marker=true) }}" terminology__snomed_icd_10_map: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_icd_10_map.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_icd_10_map.csv',compression=true,null_marker=true) }}" value_sets: ccsr: ccsr__dxccsr_v2023_1_body_systems: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','dxccsr_v2023_1_body_systems.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','dxccsr_v2023_1_body_systems.csv',compression=true,null_marker=true) }}" ccsr__dxccsr_v2023_1_cleaned_map: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','dxccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','dxccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}" ccsr__prccsr_v2023_1_cleaned_map: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','prccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','prccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}" chronic_conditions: chronic_conditions__cms_chronic_conditions_hierarchy: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}" chronic_conditions__tuva_chronic_conditions_hierarchy: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}" cms_hcc: cms_hcc__adjustment_rates: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_adjustment_rates.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_adjustment_rates.csv',compression=true,null_marker=true) }}" cms_hcc__cpt_hcpcs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_cpt_hcpcs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_cpt_hcpcs.csv',compression=true,null_marker=true) }}" cms_hcc__demographic_factors: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_demographic_factors.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_demographic_factors.csv',compression=true,null_marker=true) }}" cms_hcc__disabled_interaction_factors: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disabled_interaction_factors.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disabled_interaction_factors.csv',compression=true,null_marker=true) }}" cms_hcc__disease_factors: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_factors.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_factors.csv',compression=true,null_marker=true) }}" cms_hcc__disease_hierarchy: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_hierarchy.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_hierarchy.csv',compression=true,null_marker=true) }}" cms_hcc__disease_interaction_factors: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_interaction_factors.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_interaction_factors.csv',compression=true,null_marker=true) }}" cms_hcc__enrollment_interaction_factors: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_enrollment_interaction_factors.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_enrollment_interaction_factors.csv',compression=true,null_marker=true) }}" cms_hcc__icd_10_cm_mappings: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}" cms_hcc__payment_hcc_count_factors: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_payment_hcc_count_factors.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_payment_hcc_count_factors.csv',compression=true,null_marker=true) }}" data_quality: data_quality__crosswalk_field_info: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_field_info.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_field_info.csv',compression=true,null_marker=true) }}" data_quality__crosswalk_field_to_mart: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_field_to_mart.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_field_to_mart.csv',compression=true,null_marker=true) }}" data_quality__crosswalk_mart_to_outcome_measure: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_mart_to_outcome_measure.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_mart_to_outcome_measure.csv',compression=true,null_marker=true) }}" data_quality__crosswalk_measure_reasonable_ranges: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_measure_reasonable_ranges.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_measure_reasonable_ranges.csv',compression=true,null_marker=true) }}" data_quality__reference_mart_analytics: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_reference_mart_analytics.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_reference_mart_analytics.csv',compression=true,null_marker=true) }}" ed_classification: ed_classification__categories: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','ed_classification_categories.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','ed_classification_categories.csv',compression=true,null_marker=true) }}" ed_classification__icd_10_cm_to_ccs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}" ed_classification__johnston_icd10: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','johnston_icd10.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','johnston_icd10.csv',compression=true,null_marker=true) }}" ed_classification__johnston_icd9: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','johnston_icd9.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','johnston_icd9.csv',compression=true,null_marker=true) }}" hcc_suspecting: hcc_suspecting__clinical_concepts: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_clinical_concepts.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_clinical_concepts.csv',compression=true,null_marker=true) }}" hcc_suspecting__hcc_descriptions: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_descriptions.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_descriptions.csv',compression=true,null_marker=true) }}" hcc_suspecting__icd_10_cm_mappings: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}" pharmacy: pharmacy__rxnorm_generic_available: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','rxnorm_generic_available.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','rxnorm_generic_available.csv',compression=true,null_marker=true) }}" quality_measures: quality_measures__concepts: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_concepts.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_concepts.csv',compression=true,null_marker=true) }}" quality_measures__measures: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_measures.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_measures.csv',compression=true,null_marker=true) }}" quality_measures__value_sets: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_value_set_codes.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_value_set_codes.csv',compression=true,null_marker=true) }}" readmissions: readmissions__acute_diagnosis_ccs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','acute_diagnosis_ccs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','acute_diagnosis_ccs.csv',compression=true,null_marker=true) }}" readmissions__acute_diagnosis_icd_10_cm: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','acute_diagnosis_icd_10_cm.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','acute_diagnosis_icd_10_cm.csv',compression=true,null_marker=true) }}" readmissions__always_planned_ccs_diagnosis_category: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','always_planned_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','always_planned_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}" readmissions__always_planned_ccs_procedure_category: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','always_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','always_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}" readmissions__exclusion_ccs_diagnosis_category: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','exclusion_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','exclusion_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}" readmissions__icd_10_cm_to_ccs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}" readmissions__icd_10_pcs_to_ccs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_pcs_to_ccs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_pcs_to_ccs.csv',compression=true,null_marker=true) }}" readmissions__potentially_planned_ccs_procedure_category: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','potentially_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','potentially_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}" readmissions__potentially_planned_icd_10_pcs: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','potentially_planned_icd_10_pcs.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','potentially_planned_icd_10_pcs.csv',compression=true,null_marker=true) }}" readmissions__specialty_cohort: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','specialty_cohort.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','specialty_cohort.csv',compression=true,null_marker=true) }}" readmissions__surgery_gynecology_cohort: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','surgery_gynecology_cohort.csv',compression=true,null_marker=true) }}" + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','surgery_gynecology_cohort.csv',compression=true,null_marker=true) }}" service_categories: service_category__service_categories: - +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','service_category__service_categories.csv',compression=true,null_marker=true) }}" \ No newline at end of file + +post-hook: "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','service_category__service_categories.csv',compression=true,null_marker=true) }}" \ No newline at end of file diff --git a/docs/catalog.json b/docs/catalog.json index 4f193a31..278bca31 100644 --- a/docs/catalog.json +++ b/docs/catalog.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.8.7", "generated_at": "2024-10-22T19:20:57.481172Z", "invocation_id": "20286335-30e3-42ae-bde1-c852d2c2ff63", "env": {}}, "nodes": {"model.input_layer.medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "MEDICAL_CLAIM", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 15, "name": "ADMIT_TYPE_CODE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 16, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 17, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 18, "name": "BILL_TYPE_CODE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 20, "name": "APR_DRG_CODE", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 21, "name": "REVENUE_CENTER_CODE", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 22, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 23, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 27, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 28, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 29, "name": "RENDERING_NPI", "comment": null}, "RENDERING_TIN": {"type": "NUMBER", "index": 30, "name": "RENDERING_TIN", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 31, "name": "BILLING_NPI", "comment": null}, "BILLING_TIN": {"type": "NUMBER", "index": 32, "name": "BILLING_TIN", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 33, "name": "FACILITY_NPI", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 34, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 35, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 36, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 37, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 38, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 39, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 40, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 41, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 42, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 43, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 44, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 45, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 46, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 47, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 48, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 49, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 50, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 93, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 94, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 95, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 96, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 97, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 98, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 99, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 100, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 101, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 119, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 120, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 121, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 122, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 123, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 124, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 125, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 126, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 127, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_25", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 144, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 145, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 146, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 147, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.medical_claim"}, "model.input_layer.pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PHARMACY_CLAIM", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 4, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_NPI": {"type": "TEXT", "index": 7, "name": "PRESCRIBING_PROVIDER_NPI", "comment": null}, "DISPENSING_PROVIDER_NPI": {"type": "TEXT", "index": 8, "name": "DISPENSING_PROVIDER_NPI", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 9, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 10, "name": "NDC_CODE", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 11, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 12, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 13, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 14, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 15, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 16, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 17, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 18, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 19, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 20, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 21, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 22, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 23, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 24, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.pharmacy_claim"}, "model.input_layer.location": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "LOCATION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 13, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 14, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.location"}, "model.input_layer.observation": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "OBSERVATION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "RESULT": {"type": "TEXT", "index": 13, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 14, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 15, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 16, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 18, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 21, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.observation"}, "model.input_layer.patient": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PATIENT", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 18, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 19, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.patient"}, "model.input_layer.lab_result": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "LAB_RESULT", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 12, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 13, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 15, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 16, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 17, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 18, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 21, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "NUMBER", "index": 23, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "NUMBER", "index": 24, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 25, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 26, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 28, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.lab_result"}, "model.input_layer.condition": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "CONDITION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 16, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 17, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 20, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.condition"}, "model.input_layer.encounter": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "ENCOUNTER", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 6, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 9, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 11, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 13, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 15, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 16, "name": "FACILITY_NAME", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 17, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 18, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 20, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 22, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 24, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 25, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 26, "name": "CHARGE_AMOUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 28, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.encounter"}, "model.input_layer.provider_attribution": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PROVIDER_ATTRIBUTION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 6, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 10, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.provider_attribution"}, "model.input_layer.medication": {"metadata": {"type": "VIEW", "schema": "INPUT_LAYER", "name": "MEDICATION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICATION_ID": {"type": "TEXT", "index": 1, "name": "MEDICATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 4, "name": "DISPENSING_DATE", "comment": null}, "PRESCRIBING_DATE": {"type": "DATE", "index": 5, "name": "PRESCRIBING_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "RXNORM_CODE": {"type": "TEXT", "index": 11, "name": "RXNORM_CODE", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "RXNORM_DESCRIPTION", "comment": null}, "ATC_CODE": {"type": "TEXT", "index": 13, "name": "ATC_CODE", "comment": null}, "ATC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "ATC_DESCRIPTION", "comment": null}, "ROUTE": {"type": "TEXT", "index": 15, "name": "ROUTE", "comment": null}, "STRENGTH": {"type": "TEXT", "index": 16, "name": "STRENGTH", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 17, "name": "QUANTITY", "comment": null}, "QUANTITY_UNIT": {"type": "TEXT", "index": 18, "name": "QUANTITY_UNIT", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 19, "name": "DAYS_SUPPLY", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 20, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 21, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 22, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 23, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.medication"}, "model.input_layer.practitioner": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PRACTITIONER", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 3, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 4, "name": "LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 9, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 10, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.practitioner"}, "model.input_layer.procedure": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PROCEDURE", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 12, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 13, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 14, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 15, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 16, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 17, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 18, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 19, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.procedure"}, "model.input_layer.eligibility": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "ELIGIBILITY", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 2, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 3, "name": "SUBSCRIBER_ID", "comment": null}, "GENDER": {"type": "TEXT", "index": 4, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 9, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 10, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 11, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 12, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 13, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 14, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 15, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 16, "name": "MEDICARE_STATUS_CODE", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 17, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 18, "name": "LAST_NAME", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 19, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 20, "name": "SUBSCRIBER_RELATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 21, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 22, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 23, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 24, "name": "ZIP_CODE", "comment": null}, "PHONE": {"type": "TEXT", "index": 25, "name": "PHONE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 27, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 28, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.eligibility"}, "model.the_tuva_project.data_quality__procedure_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_encounter_id"}, "model.the_tuva_project.service_category__stg_office_based": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "SERVICE_CATEGORY__STG_OFFICE_BASED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 4, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_office_based"}, "model.the_tuva_project.quality_measures__int_cbe0101_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_long"}, "model.the_tuva_project.data_quality__eligibility_missing_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MISSING_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_patient_id"}, "model.the_tuva_project.core__stg_claims_pharmacy_claim": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_PHARMACY_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PHARMACY_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "PHARMACY_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 9, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 12, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 13, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 15, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 16, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 17, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 18, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 23, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 25, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_pharmacy_claim"}, "model.the_tuva_project.data_quality__encounter_encounter_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_type"}, "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ALWAYS_PLANNED_CCS_DIAGNOSIS_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category"}, "seed.the_tuva_project.readmissions__specialty_cohort": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_SPECIALTY_COHORT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS": {"type": "TEXT", "index": 1, "name": "CCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 3, "name": "SPECIALTY_COHORT", "comment": null}, "PROCEDURE_OR_DIAGNOSIS": {"type": "TEXT", "index": 4, "name": "PROCEDURE_OR_DIAGNOSIS", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 276, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8192, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__specialty_cohort"}, "seed.input_layer.lab_result_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "LAB_RESULT_SEED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 12, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 13, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 15, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 16, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 17, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 18, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 21, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "NUMBER", "index": 23, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "NUMBER", "index": 24, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 25, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 26, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 28, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.lab_result_seed"}, "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "PMPM_PAYER_PLAN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 2, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 3, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 5, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 6, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 7, "name": "MEDICAL_PAID", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 8, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 9, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 10, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 11, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 12, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 13, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 14, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 15, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 16, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 17, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 18, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 19, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 20, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 21, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 22, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 23, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 24, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 25, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 26, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 27, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 28, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 29, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 30, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 31, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 32, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 33, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 34, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 35, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 36, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 37, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 38, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 39, "name": "URGENT_CARE_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 40, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 41, "name": "MEDICAL_ALLOWED", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 42, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 43, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 44, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 45, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 46, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 47, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 48, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 49, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 50, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 51, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 52, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 53, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 54, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 55, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 56, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 57, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 58, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 59, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 60, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 61, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 62, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 63, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 64, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 65, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 70, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 71, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 72, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 73, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 74, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer_plan"}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PRIMARY_DIAGNOSIS_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_UNION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"}, "model.the_tuva_project.data_quality__condition_status": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_STATUS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_status"}, "seed.the_tuva_project.reference_data__ssa_fips_state": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "SSA_FIPS_STATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SSA_FIPS_STATE_CODE": {"type": "TEXT", "index": 1, "name": "SSA_FIPS_STATE_CODE", "comment": null}, "SSA_FIPS_STATE_NAME": {"type": "TEXT", "index": 2, "name": "SSA_FIPS_STATE_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 78, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__ssa_fips_state"}, "seed.the_tuva_project.terminology__rxnorm_to_atc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "RXNORM_TO_ATC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"RXCUI": {"type": "TEXT", "index": 1, "name": "RXCUI", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "RXNORM_DESCRIPTION", "comment": null}, "ATC_1_CODE": {"type": "TEXT", "index": 3, "name": "ATC_1_CODE", "comment": null}, "ATC_1_NAME": {"type": "TEXT", "index": 4, "name": "ATC_1_NAME", "comment": null}, "ATC_2_CODE": {"type": "TEXT", "index": 5, "name": "ATC_2_CODE", "comment": null}, "ATC_2_NAME": {"type": "TEXT", "index": 6, "name": "ATC_2_NAME", "comment": null}, "ATC_3_CODE": {"type": "TEXT", "index": 7, "name": "ATC_3_CODE", "comment": null}, "ATC_3_NAME": {"type": "TEXT", "index": 8, "name": "ATC_3_NAME", "comment": null}, "ATC_4_CODE": {"type": "TEXT", "index": 9, "name": "ATC_4_CODE", "comment": null}, "ATC_4_NAME": {"type": "TEXT", "index": 10, "name": "ATC_4_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 24497, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1103360, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__rxnorm_to_atc"}, "model.the_tuva_project.cms_hcc__int_eligible_conditions": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_ELIGIBLE_CONDITIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CONDITION_CODE": {"type": "TEXT", "index": 2, "name": "CONDITION_CODE", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 3, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_eligible_conditions"}, "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__pharmacy_claim_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 6, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_npi"}, "seed.the_tuva_project.terminology__ethnicity": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ETHNICITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ethnicity"}, "model.the_tuva_project.data_quality__pharmacy_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_data_source"}, "model.the_tuva_project.data_quality__medication_quantity_unit": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_QUANTITY_UNIT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_quantity_unit"}, "model.the_tuva_project.data_quality__practitioner_specialty": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_SPECIALTY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_specialty"}, "model.the_tuva_project.service_category__stg_outpatient_institutional": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "SERVICE_CATEGORY__STG_OUTPATIENT_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_outpatient_institutional"}, "model.the_tuva_project.readmissions__encounter_with_ccs": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_WITH_CCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "VALID_PRIMARY_DIAGNOSIS_CODE_FLAG": {"type": "NUMBER", "index": 10, "name": "VALID_PRIMARY_DIAGNOSIS_CODE_FLAG", "comment": null}, "CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 11, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_with_ccs"}, "model.the_tuva_project.core__medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "MEDICAL_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICAL_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "MEDICAL_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 8, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 9, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 10, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 16, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 17, "name": "DISCHARGE_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 19, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 20, "name": "SERVICE_CATEGORY_3", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 21, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 23, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 25, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 27, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 31, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 33, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 37, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 38, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 39, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 40, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 41, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 42, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 43, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 44, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 45, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 46, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 47, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 48, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 49, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 50, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 51, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 52, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 53, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 54, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 55, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 56, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 57, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 58, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 59, "name": "TOTAL_COST_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 60, "name": "IN_NETWORK_FLAG", "comment": null}, "ENROLLMENT_FLAG": {"type": "NUMBER", "index": 61, "name": "ENROLLMENT_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 62, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 63, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__medical_claim"}, "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ICD_10_CM_TO_CCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "CCS_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CCS_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 72776, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1313792, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs"}, "model.the_tuva_project.quality_measures__int_cqm130_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_numerator"}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_REFERENCE_RANGE_LOW", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low"}, "model.the_tuva_project.data_quality__readmissions_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_READMISSIONS_REFERENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__readmissions_reference"}, "model.the_tuva_project.service_category__inpatient_hospice_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_HOSPICE_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_institutional"}, "model.the_tuva_project.data_quality__institutional_apr_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_APR_DRG_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_apr_drg_code"}, "model.the_tuva_project.data_quality__data_quality_detail": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_DETAIL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 11, "name": "SUMMARY_SK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_detail"}, "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "SNOMED_CT_TRANSITIVE_CLOSURES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PARENT_SNOMED_CODE": {"type": "TEXT", "index": 1, "name": "PARENT_SNOMED_CODE", "comment": null}, "PARENT_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "PARENT_DESCRIPTION", "comment": null}, "CHILD_SNOMED_CODE": {"type": "TEXT", "index": 3, "name": "CHILD_SNOMED_CODE", "comment": null}, "CHILD_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CHILD_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7336247, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 112937984, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__snomed_ct_transitive_closures"}, "model.the_tuva_project.data_quality__patient_county": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_COUNTY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_county"}, "model.the_tuva_project.data_quality__lab_result_lab_result_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_LAB_RESULT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_lab_result_id"}, "model.the_tuva_project.core__location": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "LOCATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__location"}, "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_PREP_EGFR_LABS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "CODE_TYPE": {"type": "TEXT", "index": 3, "name": "CODE_TYPE", "comment": null}, "CODE": {"type": "TEXT", "index": 4, "name": "CODE", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 5, "name": "RESULT_DATE", "comment": null}, "RESULT": {"type": "NUMBER", "index": 6, "name": "RESULT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs"}, "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097__performance_period"}, "model.the_tuva_project.readmissions__encounter_augmented": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "ENCOUNTER_AUGMENTED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 9, "name": "LENGTH_OF_STAY", "comment": null}, "INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 10, "name": "INDEX_ADMISSION_FLAG", "comment": null}, "PLANNED_FLAG": {"type": "NUMBER", "index": 11, "name": "PLANNED_FLAG", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 12, "name": "SPECIALTY_COHORT", "comment": null}, "DIED_FLAG": {"type": "NUMBER", "index": 13, "name": "DIED_FLAG", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CCS", "comment": null}, "DISQUALIFIED_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 15, "name": "DISQUALIFIED_ENCOUNTER_FLAG", "comment": null}, "MISSING_ADMIT_DATE_FLAG": {"type": "NUMBER", "index": 16, "name": "MISSING_ADMIT_DATE_FLAG", "comment": null}, "MISSING_DISCHARGE_DATE_FLAG": {"type": "NUMBER", "index": 17, "name": "MISSING_DISCHARGE_DATE_FLAG", "comment": null}, "ADMIT_AFTER_DISCHARGE_FLAG": {"type": "NUMBER", "index": 18, "name": "ADMIT_AFTER_DISCHARGE_FLAG", "comment": null}, "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 19, "name": "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 20, "name": "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "MISSING_PRIMARY_DIAGNOSIS_FLAG": {"type": "NUMBER", "index": 21, "name": "MISSING_PRIMARY_DIAGNOSIS_FLAG", "comment": null}, "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG": {"type": "NUMBER", "index": 22, "name": "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG", "comment": null}, "NO_DIAGNOSIS_CCS_FLAG": {"type": "NUMBER", "index": 23, "name": "NO_DIAGNOSIS_CCS_FLAG", "comment": null}, "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 24, "name": "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG", "comment": null}, "MISSING_MS_DRG_FLAG": {"type": "NUMBER", "index": 25, "name": "MISSING_MS_DRG_FLAG", "comment": null}, "INVALID_MS_DRG_FLAG": {"type": "NUMBER", "index": 26, "name": "INVALID_MS_DRG_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_augmented"}, "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_14_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions"}, "model.the_tuva_project.core__stg_clinical_medication": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_MEDICATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICATION_ID": {"type": "TEXT", "index": 1, "name": "MEDICATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 4, "name": "DISPENSING_DATE", "comment": null}, "PRESCRIBING_DATE": {"type": "DATE", "index": 5, "name": "PRESCRIBING_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "RXNORM_CODE": {"type": "TEXT", "index": 11, "name": "RXNORM_CODE", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "RXNORM_DESCRIPTION", "comment": null}, "ATC_CODE": {"type": "TEXT", "index": 13, "name": "ATC_CODE", "comment": null}, "ATC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "ATC_DESCRIPTION", "comment": null}, "ROUTE": {"type": "TEXT", "index": 15, "name": "ROUTE", "comment": null}, "STRENGTH": {"type": "TEXT", "index": 16, "name": "STRENGTH", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 17, "name": "QUANTITY", "comment": null}, "QUANTITY_UNIT": {"type": "TEXT", "index": 18, "name": "QUANTITY_UNIT", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 19, "name": "DAYS_SUPPLY", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 20, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 21, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_medication"}, "model.the_tuva_project.hcc_suspecting__int_lab_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_LAB_SUSPECTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 3, "name": "RESULT_DATE", "comment": null}, "RESULT": {"type": "NUMBER", "index": 4, "name": "RESULT", "comment": null}, "LAB_CODE": {"type": "TEXT", "index": 5, "name": "LAB_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 6, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "HCC_DESCRIPTION", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 8, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 9, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 10, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 11, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_lab_suspects"}, "model.the_tuva_project.data_quality__pharmacy_refills": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_REFILLS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_refills"}, "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLINICAL_FOR_PBI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SUMMARY_SK": {"type": "NUMBER", "index": 1, "name": "SUMMARY_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 4, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 5, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 6, "name": "INVALID_REASON", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 7, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 8, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "FREQUENCY": {"type": "NUMBER", "index": 10, "name": "FREQUENCY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi"}, "model.the_tuva_project.urgent_care__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__anchor_events"}, "model.the_tuva_project.data_quality__lab_result_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_description"}, "model.the_tuva_project.normalized_input__int_admit_source_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_SOURCE_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_final"}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_DISCHARGE_DISPOSITION_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_description"}, "model.the_tuva_project.normalized_input__int_ms_drg_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MS_DRG_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_voting"}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_COST_AND_UTILIZATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_GROUP", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 3, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 4, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 5, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization"}, "model.the_tuva_project.mart_review__stg_pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__STG_PHARMACY_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PHARMACY_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "PHARMACY_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 9, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 12, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 13, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 15, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 16, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 17, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 18, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 23, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 25, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 28, "name": "YEAR_MONTH", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__stg_pharmacy_claim"}, "model.the_tuva_project.normalized_input__int_present_on_admit_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PRESENT_ON_ADMIT_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 4, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 5, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 6, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 7, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 8, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 9, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 10, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 11, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 12, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 13, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 15, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 16, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 17, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 18, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 19, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 20, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 21, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 22, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 23, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 24, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 25, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 26, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 27, "name": "DIAGNOSIS_POA_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_final"}, "seed.the_tuva_project.service_category__service_categories": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__SERVICE_CATEGORIES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SERVICE_CATEGORY_1": {"type": "TEXT", "index": 1, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_3", "comment": null}, "PRIORITY": {"type": "NUMBER", "index": 4, "name": "PRIORITY", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 44, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.service_category__service_categories"}, "model.the_tuva_project.mart_review__inpatient": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__INPATIENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}, "ENCOUNTER_SOURCE_TYPE": {"type": "TEXT", "index": 45, "name": "ENCOUNTER_SOURCE_TYPE", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 46, "name": "PATIENT_SOURCE_KEY", "comment": null}, "ENCOUNTER_SOURCE_KEY": {"type": "TEXT", "index": 47, "name": "ENCOUNTER_SOURCE_KEY", "comment": null}, "DRGWITHDESCRIPTION": {"type": "TEXT", "index": 48, "name": "DRGWITHDESCRIPTION", "comment": null}, "PRIMARY_DIAGNOSIS_AND_DESCRIPTION": {"type": "TEXT", "index": 49, "name": "PRIMARY_DIAGNOSIS_AND_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 50, "name": "ADMIT_SOURCE_CODE_AND_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 51, "name": "ADMIT_TYPE_CODE_AND_DESCRIPTION", "comment": null}, "DISCHARGE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 52, "name": "DISCHARGE_CODE_AND_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 53, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 54, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 55, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_AND_DESCRIPTION": {"type": "TEXT", "index": 56, "name": "CCSR_CATEGORY_AND_DESCRIPTION", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 57, "name": "BODY_SYSTEM", "comment": null}, "LOS_GROUPS": {"type": "TEXT", "index": 58, "name": "LOS_GROUPS", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__inpatient"}, "seed.the_tuva_project.terminology__nitos": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "NITOS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS_CODE": {"type": "TEXT", "index": 1, "name": "HCPCS_CODE", "comment": null}, "NITOS_CODE": {"type": "TEXT", "index": 2, "name": "NITOS_CODE", "comment": null}, "NITOS_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "NITOS_DESCRIPTION", "comment": null}, "INVASIVE_NON_INVASIVE_FLAG": {"type": "TEXT", "index": 4, "name": "INVASIVE_NON_INVASIVE_FLAG", "comment": null}, "MODALITY": {"type": "TEXT", "index": 5, "name": "MODALITY", "comment": null}, "BODY_REGION": {"type": "TEXT", "index": 6, "name": "BODY_REGION", "comment": null}, "FOCUS_AREA": {"type": "TEXT", "index": 7, "name": "FOCUS_AREA", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 958, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 26624, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__nitos"}, "model.the_tuva_project.quality_measures__int_nqf2372_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "PERFORMANCE_PERIOD_LOOKBACK": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_LOOKBACK", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_denominator"}, "model.the_tuva_project.data_quality__acute_inpatient_prevelence": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ACUTE_INPATIENT_PREVELENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 5, "name": "VALUE_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_prevelence"}, "model.the_tuva_project.core__stg_clinical_patient": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_PATIENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_patient"}, "model.the_tuva_project.service_category__outpatient_radiology_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_RADIOLOGY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_professional"}, "model.the_tuva_project.ambulance__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 19, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__encounter_grain"}, "model.the_tuva_project.quality_measures__summary_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "SUMMARY_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "PERFORMANCE_FLAG": {"type": "NUMBER", "index": 5, "name": "PERFORMANCE_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 6, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 7, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 8, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 9, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 11, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 12, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 13, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 14, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__summary_long"}, "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_patient_id"}, "model.the_tuva_project.quality_measures__int_nqf0041_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_long"}, "model.the_tuva_project.data_quality__observation_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_patient_id"}, "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__claim_claim_line_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_LINE_END_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_end_date"}, "model.the_tuva_project.cms_hcc__int_disease_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DISEASE_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 2, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "HCC_DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 4, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 5, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 6, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 7, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_factors"}, "model.the_tuva_project.service_category__urgent_care_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_URGENT_CARE_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__urgent_care_institutional"}, "model.the_tuva_project.data_quality__procedure_procedure_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PROCEDURE_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_date"}, "model.the_tuva_project.readmissions__encounter_overlap": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_OVERLAP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID_A": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_ID_A", "comment": null}, "ENCOUNTER_ID_B": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID_B", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_overlap"}, "model.the_tuva_project.data_quality__practitioner_first_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_FIRST_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_first_name"}, "model.the_tuva_project.data_quality__observation_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_data_source"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_UNGROUPABLE_DRG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg"}, "seed.the_tuva_project.terminology__hcpcs_level_2": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "HCPCS_LEVEL_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS": {"type": "TEXT", "index": 1, "name": "HCPCS", "comment": null}, "SEQNUM": {"type": "TEXT", "index": 2, "name": "SEQNUM", "comment": null}, "RECID": {"type": "TEXT", "index": 3, "name": "RECID", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "LONG_DESCRIPTION", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "SHORT_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7500, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 368640, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__hcpcs_level_2"}, "model.the_tuva_project.data_quality__institutional_present_on_admission_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PRESENT_ON_ADMISSION_3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_3"}, "model.the_tuva_project.data_quality__professional_diagnosis_code_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_DIAGNOSIS_CODE_3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_3"}, "model.the_tuva_project.mart_review__quality_measures_value_set": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__QUALITY_MEASURES_VALUE_SET", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 3, "name": "DESCRIPTION", "comment": null}, "VERSION": {"type": "TEXT", "index": 4, "name": "VERSION", "comment": null}, "STEWARD": {"type": "TEXT", "index": 5, "name": "STEWARD", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 17, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__quality_measures_value_set"}, "seed.the_tuva_project.terminology__loinc_deprecated_mapping": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "LOINC_DEPRECATED_MAPPING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOINC": {"type": "TEXT", "index": 1, "name": "LOINC", "comment": null}, "MAP_TO": {"type": "TEXT", "index": 2, "name": "MAP_TO", "comment": null}, "COMMENT": {"type": "TEXT", "index": 3, "name": "COMMENT", "comment": null}, "FINAL_MAP_TO": {"type": "TEXT", "index": 4, "name": "FINAL_MAP_TO", "comment": null}, "ALL_COMMENTS": {"type": "TEXT", "index": 5, "name": "ALL_COMMENTS", "comment": null}, "DEPTH": {"type": "TEXT", "index": 6, "name": "DEPTH", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4613, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 97280, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__loinc_deprecated_mapping"}, "model.the_tuva_project.data_quality__claim_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PAYER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_payer"}, "model.the_tuva_project.quality_measures__int_cbe0055_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_denominator"}, "model.the_tuva_project.data_quality__institutional_procedure_code_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_CODE_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_1"}, "model.the_tuva_project.data_quality__condition_onset_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_ONSET_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_onset_date"}, "model.the_tuva_project.data_quality__eligibility_dual_status_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DUAL_STATUS_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_dual_status_code"}, "model.the_tuva_project.data_quality__medication_strength": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_STRENGTH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_strength"}, "model.the_tuva_project.data_quality__institutional_present_on_admission_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PRESENT_ON_ADMISSION_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_1"}, "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_SURGERY_GYNECOLOGY_COHORT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "CCS_CODE_AND_DESCRIPTION", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 4, "name": "SPECIALTY_COHORT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1676, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 28672, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__surgery_gynecology_cohort"}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_COST_AND_UTILIZATION_TREND", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "PKPY": {"type": "NUMBER", "index": 4, "name": "PKPY", "comment": null}, "PAID_PER": {"type": "NUMBER", "index": 5, "name": "PAID_PER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend"}, "model.the_tuva_project.data_quality__institutional_discharge_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DISCHARGE_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_date"}, "model.the_tuva_project.outpatient_rehab__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__anchor_events"}, "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ICD_10_PCS_TO_CCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "CCS_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CCS_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 80493, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1416192, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs"}, "model.the_tuva_project.data_quality__practitioner_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_data_source"}, "model.the_tuva_project.data_quality__eligibility_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_TREND", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 2, "name": "MEMBER_MONTHS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_trend"}, "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_07_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_denom"}, "model.the_tuva_project.data_quality__patient_last_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_LAST_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_last_name"}, "model.the_tuva_project.encounters__patient_data_source_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__PATIENT_DATA_SOURCE_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__patient_data_source_id"}, "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_VALUE_SET_ICD_10_CM_MAPPINGS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DIAGNOSIS_CODE": {"type": "TEXT", "index": 1, "name": "DIAGNOSIS_CODE", "comment": null}, "CMS_HCC_ESRD_V21": {"type": "TEXT", "index": 2, "name": "CMS_HCC_ESRD_V21", "comment": null}, "CMS_HCC_ESRD_V24": {"type": "TEXT", "index": 3, "name": "CMS_HCC_ESRD_V24", "comment": null}, "CMS_HCC_V22": {"type": "TEXT", "index": 4, "name": "CMS_HCC_V22", "comment": null}, "CMS_HCC_V24": {"type": "TEXT", "index": 5, "name": "CMS_HCC_V24", "comment": null}, "CMS_HCC_V28": {"type": "TEXT", "index": 6, "name": "CMS_HCC_V28", "comment": null}, "RX_HCC_V05": {"type": "TEXT", "index": 7, "name": "RX_HCC_V05", "comment": null}, "RX_HCC_V08": {"type": "TEXT", "index": 8, "name": "RX_HCC_V08", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 11687, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 89088, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings"}, "model.the_tuva_project.data_quality__location_parent_organization": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_PARENT_ORGANIZATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_parent_organization"}, "model.the_tuva_project.data_quality__lab_result_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_encounter_id"}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_REFERENCE_RANGE_HIGH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high"}, "model.the_tuva_project.asc__start_end_dates": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 2, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__start_end_dates"}, "seed.the_tuva_project.reference_data__calendar": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "CALENDAR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"FULL_DATE": {"type": "DATE", "index": 1, "name": "FULL_DATE", "comment": null}, "YEAR": {"type": "NUMBER", "index": 2, "name": "YEAR", "comment": null}, "MONTH": {"type": "NUMBER", "index": 3, "name": "MONTH", "comment": null}, "DAY": {"type": "NUMBER", "index": 4, "name": "DAY", "comment": null}, "MONTH_NAME": {"type": "TEXT", "index": 5, "name": "MONTH_NAME", "comment": null}, "DAY_OF_WEEK_NUMBER": {"type": "NUMBER", "index": 6, "name": "DAY_OF_WEEK_NUMBER", "comment": null}, "DAY_OF_WEEK_NAME": {"type": "TEXT", "index": 7, "name": "DAY_OF_WEEK_NAME", "comment": null}, "WEEK_OF_YEAR": {"type": "NUMBER", "index": 8, "name": "WEEK_OF_YEAR", "comment": null}, "DAY_OF_YEAR": {"type": "NUMBER", "index": 9, "name": "DAY_OF_YEAR", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 10, "name": "YEAR_MONTH", "comment": null}, "FIRST_DAY_OF_MONTH": {"type": "DATE", "index": 11, "name": "FIRST_DAY_OF_MONTH", "comment": null}, "LAST_DAY_OF_MONTH": {"type": "DATE", "index": 12, "name": "LAST_DAY_OF_MONTH", "comment": null}, "YEAR_MONTH_INT": {"type": "NUMBER", "index": 13, "name": "YEAR_MONTH_INT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 80000, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1007616, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__calendar"}, "model.the_tuva_project.service_category__stg_inpatient_institutional": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "SERVICE_CATEGORY__STG_INPATIENT_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_inpatient_institutional"}, "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DISPENSING_PROVIDER_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi"}, "model.the_tuva_project.data_quality__lab_result_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code_type"}, "model.the_tuva_project.dialysis__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__anchor_events"}, "model.the_tuva_project.hcc_suspecting__int_medication_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_MEDICATION_SUSPECTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "HCC_DESCRIPTION", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 5, "name": "DISPENSING_DATE", "comment": null}, "DRUG_CODE": {"type": "TEXT", "index": 6, "name": "DRUG_CODE", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 7, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 8, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 9, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 10, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_medication_suspects"}, "model.the_tuva_project.data_quality__institutional_rendering_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_RENDERING_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_rendering_npi"}, "seed.the_tuva_project.terminology__other_provider_taxonomy": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "OTHER_PROVIDER_TAXONOMY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NPI": {"type": "TEXT", "index": 1, "name": "NPI", "comment": null}, "TAXONOMY_CODE": {"type": "TEXT", "index": 2, "name": "TAXONOMY_CODE", "comment": null}, "MEDICARE_SPECIALTY_CODE": {"type": "TEXT", "index": 3, "name": "MEDICARE_SPECIALTY_CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 4, "name": "DESCRIPTION", "comment": null}, "PRIMARY_FLAG": {"type": "NUMBER", "index": 5, "name": "PRIMARY_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 10043050, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 73041920, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__other_provider_taxonomy"}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PRIMARY_DIAGNOSIS_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description"}, "seed.the_tuva_project.terminology__ms_drg": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MS_DRG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MS_DRG_CODE": {"type": "TEXT", "index": 1, "name": "MS_DRG_CODE", "comment": null}, "MDC_CODE": {"type": "TEXT", "index": 2, "name": "MDC_CODE", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 3, "name": "MEDICAL_SURGICAL", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "MS_DRG_DESCRIPTION", "comment": null}, "DEPRECATED": {"type": "NUMBER", "index": 5, "name": "DEPRECATED", "comment": null}, "DEPRECATED_DATE": {"type": "DATE", "index": 6, "name": "DEPRECATED_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 812, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 16896, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ms_drg"}, "model.the_tuva_project.data_quality__encounter_encounter_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_END_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_end_date"}, "model.the_tuva_project.outpatient_surgery__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__anchor_events"}, "model.the_tuva_project.data_quality__institutional_procedure_date_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_DATE_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_1"}, "model.the_tuva_project.data_quality__eligibility_gender": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_GENDER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_gender"}, "model.the_tuva_project.ahrq_measures__int_pqi_03_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_03_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_num"}, "model.the_tuva_project.data_quality__eligibility_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_patient_id"}, "model.the_tuva_project.service_category__outpatient_hospice_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPICE_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_institutional"}, "model.the_tuva_project.data_quality__condition_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_NORMALIZED_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_description"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_INT_CMS_CHRONIC_CONDITION_HIV_AIDS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"}, "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclusions"}, "model.the_tuva_project.service_category__office_based_radiology": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_RADIOLOGY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_radiology"}, "model.the_tuva_project.data_quality__eligibility_phone": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PHONE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_phone"}, "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_GENERIC_COST_BY_NDC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BRAND_RXCUI": {"type": "TEXT", "index": 1, "name": "BRAND_RXCUI", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "GENERIC_NDC_CODE": {"type": "TEXT", "index": 3, "name": "GENERIC_NDC_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 4, "name": "PAID_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 5, "name": "CLAIM_COUNT", "comment": null}, "TOTAL_UNITS": {"type": "NUMBER", "index": 6, "name": "TOTAL_UNITS", "comment": null}, "COST_PER_UNIT": {"type": "NUMBER", "index": 7, "name": "COST_PER_UNIT", "comment": null}, "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY": {"type": "NUMBER", "index": 8, "name": "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc"}, "model.the_tuva_project.data_quality__claim_hcpcs_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_HCPCS_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_hcpcs_code"}, "model.the_tuva_project.ambulance__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__anchor_events"}, "model.the_tuva_project.core__patient": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PATIENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__patient"}, "model.the_tuva_project.data_quality__observation_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_description"}, "model.the_tuva_project.service_category__ambulance_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULANCE_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulance_institutional"}, "model.the_tuva_project.normalized_input__int_admit_type_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_TYPE_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_final"}, "seed.the_tuva_project.terminology__icd_10_cm": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_10_CM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "HEADER_FLAG": {"type": "TEXT", "index": 2, "name": "HEADER_FLAG", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "SHORT_DESCRIPTION", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "LONG_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 97296, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2130944, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_10_cm"}, "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_LOOKBACK": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_LOOKBACK", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372__performance_period"}, "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__generate_encounter_id"}, "model.the_tuva_project.core__pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PHARMACY_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PHARMACY_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "PHARMACY_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 9, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 12, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 13, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 15, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 16, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 17, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 18, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 23, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 25, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__pharmacy_claim"}, "model.the_tuva_project.service_category__inpatient_rehab_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_REHAB_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_professional"}, "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__claim_plan": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PLAN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_plan"}, "seed.the_tuva_project.cms_hcc__demographic_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DEMOGRAPHIC_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "PLAN_SEGMENT": {"type": "TEXT", "index": 4, "name": "PLAN_SEGMENT", "comment": null}, "GENDER": {"type": "TEXT", "index": 5, "name": "GENDER", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 6, "name": "AGE_GROUP", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 7, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 8, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 9, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 10, "name": "INSTITUTIONAL_STATUS", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 11, "name": "COEFFICIENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 848, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 13312, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__demographic_factors"}, "model.the_tuva_project.ahrq_measures__pqi_denom_long": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_DENOM_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 4, "name": "PQI_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_denom_long"}, "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_ORDERING_PRACTITIONER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id"}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_EXCLUSIONS_STAGE_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"}, "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_MEASURE_REASONABLE_RANGES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_NAME": {"type": "TEXT", "index": 1, "name": "MEASURE_NAME", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 2, "name": "PAYER_TYPE", "comment": null}, "LOWER_BOUND": {"type": "FLOAT", "index": 3, "name": "LOWER_BOUND", "comment": null}, "UPPER_BOUND": {"type": "FLOAT", "index": 4, "name": "UPPER_BOUND", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 48, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges"}, "model.the_tuva_project.outpatient_hospice__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__encounter_grain"}, "model.the_tuva_project.inpatient_snf__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__start_end_dates"}, "model.the_tuva_project.service_category__stg_professional": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "SERVICE_CATEGORY__STG_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 4, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_professional"}, "model.the_tuva_project.data_quality__medication_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_SOURCE_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_source_code_type"}, "model.the_tuva_project.data_quality__patient_longitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_LONGITUDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_longitude"}, "model.the_tuva_project.acute_inpatient__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__start_end_dates"}, "model.the_tuva_project.normalized_input__int_procedure_code_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_CODE_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_voting"}, "seed.the_tuva_project.reference_data__ansi_fips_state": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "ANSI_FIPS_STATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANSI_FIPS_STATE_CODE": {"type": "TEXT", "index": 1, "name": "ANSI_FIPS_STATE_CODE", "comment": null}, "ANSI_FIPS_STATE_ABBREVIATION": {"type": "TEXT", "index": 2, "name": "ANSI_FIPS_STATE_ABBREVIATION", "comment": null}, "ANSI_FIPS_STATE_NAME": {"type": "TEXT", "index": 3, "name": "ANSI_FIPS_STATE_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 55, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__ansi_fips_state"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_ADVANCED_ILLNESS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 5, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 6, "name": "CLAIM_END_DATE", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 7, "name": "PROCEDURE_DATE", "comment": null}, "PATIENT_TYPE": {"type": "TEXT", "index": 8, "name": "PATIENT_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness"}, "model.the_tuva_project.ed_classification__int_map_primary_dx": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_INT_BY_PROVIDER_PARENT_ORGANIZATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_END_DATE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 5, "name": "FACILITY_ID", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 10, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 11, "name": "CHARGE_AMOUNT", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 12, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 13, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 14, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 15, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 16, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 17, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 18, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 19, "name": "DRUG", "comment": null}, "ED_CLASSIFICATION_CAPTURE": {"type": "NUMBER", "index": 20, "name": "ED_CLASSIFICATION_CAPTURE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ed_classification__int_map_primary_dx"}, "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "VALUE_SET_MEMBER_RELEVANT_FIELDS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_ID": {"type": "TEXT", "index": 1, "name": "CONCEPT_ID", "comment": null}, "CONCEPT_NAME": {"type": "TEXT", "index": 2, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_TYPE": {"type": "TEXT", "index": 3, "name": "CONCEPT_TYPE", "comment": null}, "VALUE_SET_MEMBER_ID": {"type": "TEXT", "index": 4, "name": "VALUE_SET_MEMBER_ID", "comment": null}, "CODE": {"type": "TEXT", "index": 5, "name": "CODE", "comment": null}, "CODING_SYSTEM_ID": {"type": "TEXT", "index": 6, "name": "CODING_SYSTEM_ID", "comment": null}, "INCLUDE_DESCENDANTS": {"type": "TEXT", "index": 7, "name": "INCLUDE_DESCENDANTS", "comment": null}, "CODING_SYSTEM_NAME": {"type": "TEXT", "index": 8, "name": "CODING_SYSTEM_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12164, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 164864, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"}, "model.the_tuva_project.inpatient_hospice__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__generate_encounter_id"}, "model.the_tuva_project.normalized_input__int_bill_type_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_BILL_TYPE_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_voting"}, "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_INT_FILTER_ENCOUNTER_WITH_CLASSIFICATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_END_DATE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 5, "name": "FACILITY_ID", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 10, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 11, "name": "CHARGE_AMOUNT", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 12, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 13, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 14, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 15, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 16, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 17, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 18, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 19, "name": "DRUG", "comment": null}, "ED_CLASSIFICATION_CAPTURE": {"type": "NUMBER", "index": 20, "name": "ED_CLASSIFICATION_CAPTURE", "comment": null}, "CLASSIFICATION": {"type": "TEXT", "index": 21, "name": "CLASSIFICATION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification"}, "model.the_tuva_project.data_quality__medication_atc_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ATC_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_atc_description"}, "model.the_tuva_project.quality_measures__int_adhras_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_exclusions"}, "model.the_tuva_project.encounters__stg_medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_MEDICAL_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"APR_DRG_CODE": {"type": "TEXT", "index": 1, "name": "APR_DRG_CODE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 6, "name": "CLAIM_LINE_ID", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "START_DATE": {"type": "DATE", "index": 8, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 9, "name": "END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 10, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 11, "name": "DISCHARGE_DATE", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 16, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 17, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_3", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 19, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 21, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 22, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 23, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_5", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 27, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 29, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "MS_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 31, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 32, "name": "ADMIT_TYPE_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 33, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 37, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 38, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 39, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 40, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 41, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 42, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 43, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 44, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "MODALITY": {"type": "TEXT", "index": 45, "name": "MODALITY", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 46, "name": "BILLING_ID", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 47, "name": "RENDERING_ID", "comment": null}, "REND_PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 48, "name": "REND_PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 49, "name": "FACILITY_ID", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 50, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 51, "name": "PAID_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 52, "name": "CHARGE_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 53, "name": "ALLOWED_AMOUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 54, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 55, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_medical_claim"}, "model.the_tuva_project.service_category__urgent_care_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_URGENT_CARE_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__urgent_care_professional"}, "model.the_tuva_project.data_quality__pharmacy_days_supply": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DAYS_SUPPLY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_days_supply"}, "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_ABNORMAL_FLAG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag"}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPITAL_OR_CLINIC_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional"}, "model.the_tuva_project.readmissions__index_time_requirement": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_INDEX_TIME_REQUIREMENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__index_time_requirement"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_HOSPICE_PALLIATIVE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"}, "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DISEASE_INTERACTION_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "HCC_CODE_1": {"type": "TEXT", "index": 2, "name": "HCC_CODE_1", "comment": null}, "HCC_CODE_2": {"type": "TEXT", "index": 3, "name": "HCC_CODE_2", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 4, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 5, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 6, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 7, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 8, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_interaction_factors"}, "model.the_tuva_project.quality_measures__int_cqm48_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_numerator"}, "model.the_tuva_project.data_quality__claim_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_data_source"}, "model.the_tuva_project.office_visit__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISIT__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 14, "name": "BILLING_ID", "comment": null}, "PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "PROVIDER_NAME", "comment": null}, "PROVIDER_SPECIALTY": {"type": "TEXT", "index": 16, "name": "PROVIDER_SPECIALTY", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 17, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 18, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 19, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 20, "name": "PHARMACY_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 21, "name": "HCPCS_CODE", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 22, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 24, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 25, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 26, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 27, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 28, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 29, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 30, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 31, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visit__encounter_grain"}, "model.the_tuva_project.service_category__dialysis_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_DIALYSIS_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__dialysis_professional"}, "model.the_tuva_project.data_quality__pharmacy_paid_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PAID_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_date"}, "model.the_tuva_project.data_quality__patient_race": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_RACE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_race"}, "model.the_tuva_project.data_quality__cms_hcc": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CMS_HCC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__cms_hcc"}, "model.the_tuva_project.data_quality__lab_result_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_data_source"}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "_VALUE_SET_DXCCSR_V2023_1_BODY_SYSTEMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BODY_SYSTEM": {"type": "TEXT", "index": 1, "name": "BODY_SYSTEM", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 2, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "PARENT_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "PARENT_CATEGORY_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 22, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"}, "model.the_tuva_project.service_category__acute_inpatient_institutional_other": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_INSTITUTIONAL_OTHER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_other"}, "model.the_tuva_project.quality_measures__int_nqf0420_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_numerator"}, "model.the_tuva_project.ccsr__dx_vertical_pivot": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "DX_VERTICAL_PIVOT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "CODE_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_RANK": {"type": "NUMBER", "index": 6, "name": "CCSR_CATEGORY_RANK", "comment": null}, "IS_IP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 7, "name": "IS_IP_DEFAULT_CATEGORY", "comment": null}, "IS_OP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 8, "name": "IS_OP_DEFAULT_CATEGORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 86288, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2392064, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__dx_vertical_pivot"}, "model.the_tuva_project.readmissions__readmission_summary": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "READMISSION_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 9, "name": "LENGTH_OF_STAY", "comment": null}, "INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 10, "name": "INDEX_ADMISSION_FLAG", "comment": null}, "PLANNED_FLAG": {"type": "NUMBER", "index": 11, "name": "PLANNED_FLAG", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 12, "name": "SPECIALTY_COHORT", "comment": null}, "DIED_FLAG": {"type": "NUMBER", "index": 13, "name": "DIED_FLAG", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CCS", "comment": null}, "HAD_READMISSION_FLAG": {"type": "NUMBER", "index": 15, "name": "HAD_READMISSION_FLAG", "comment": null}, "DAYS_TO_READMIT": {"type": "NUMBER", "index": 16, "name": "DAYS_TO_READMIT", "comment": null}, "READMIT_30_FLAG": {"type": "NUMBER", "index": 17, "name": "READMIT_30_FLAG", "comment": null}, "UNPLANNED_READMIT_30_FLAG": {"type": "NUMBER", "index": 18, "name": "UNPLANNED_READMIT_30_FLAG", "comment": null}, "READMISSION_ENCOUNTER_ID": {"type": "TEXT", "index": 19, "name": "READMISSION_ENCOUNTER_ID", "comment": null}, "READMISSION_ADMIT_DATE": {"type": "DATE", "index": 20, "name": "READMISSION_ADMIT_DATE", "comment": null}, "READMISSION_DISCHARGE_DATE": {"type": "DATE", "index": 21, "name": "READMISSION_DISCHARGE_DATE", "comment": null}, "READMISSION_DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 22, "name": "READMISSION_DISCHARGE_DISPOSITION_CODE", "comment": null}, "READMISSION_FACILITY": {"type": "TEXT", "index": 23, "name": "READMISSION_FACILITY", "comment": null}, "READMISSION_MS_DRG": {"type": "TEXT", "index": 24, "name": "READMISSION_MS_DRG", "comment": null}, "READMISSION_LENGTH_OF_STAY": {"type": "NUMBER", "index": 25, "name": "READMISSION_LENGTH_OF_STAY", "comment": null}, "READMISSION_INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 26, "name": "READMISSION_INDEX_ADMISSION_FLAG", "comment": null}, "READMISSION_PLANNED_FLAG": {"type": "NUMBER", "index": 27, "name": "READMISSION_PLANNED_FLAG", "comment": null}, "READMISSION_SPECIALTY_COHORT": {"type": "TEXT", "index": 28, "name": "READMISSION_SPECIALTY_COHORT", "comment": null}, "READMISSION_DIED_FLAG": {"type": "NUMBER", "index": 29, "name": "READMISSION_DIED_FLAG", "comment": null}, "READMISSION_DIAGNOSIS_CCS": {"type": "TEXT", "index": 30, "name": "READMISSION_DIAGNOSIS_CCS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 31, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__readmission_summary"}, "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_exclusions"}, "model.the_tuva_project.quality_measures__int_cqm438_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_numerator"}, "model.the_tuva_project.financial_pmpm__pmpm_payer": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "PMPM_PAYER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 2, "name": "PAYER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 4, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 5, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 6, "name": "MEDICAL_PAID", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 7, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 8, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 9, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 10, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 11, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 12, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 13, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 14, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 15, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 16, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 17, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 18, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 19, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 20, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 21, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 22, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 23, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 24, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 25, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 26, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 27, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 28, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 29, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 31, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 32, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 33, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 34, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 35, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 36, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 37, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 38, "name": "URGENT_CARE_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 39, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 40, "name": "MEDICAL_ALLOWED", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 41, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 42, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 43, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 44, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 45, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 46, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 47, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 48, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 49, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 50, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 51, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 52, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 53, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 54, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 55, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 56, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 57, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 58, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 59, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 60, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 61, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 62, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 63, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 64, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 65, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 70, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 71, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 72, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 73, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer"}, "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "_VALUE_SET_PRCCSR_V2023_1_CLEANED_MAP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "ICD_10_PCS_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ICD_10_PCS_DESCRIPTION", "comment": null}, "PRCCSR": {"type": "TEXT", "index": 3, "name": "PRCCSR", "comment": null}, "PRCCSR_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "PRCCSR_DESCRIPTION", "comment": null}, "CLINICAL_DOMAIN": {"type": "TEXT", "index": 5, "name": "CLINICAL_DOMAIN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 81597, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1539584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map"}, "model.the_tuva_project.data_quality__medication_route": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ROUTE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_route"}, "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_STG_PQI_MEMBER_MONTHS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "FIRST_DAY_OF_MONTH": {"type": "DATE", "index": 3, "name": "FIRST_DAY_OF_MONTH", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 4, "name": "YEAR_MONTH", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_member_months"}, "seed.the_tuva_project.quality_measures__concepts": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_VALUE_SET_CONCEPTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_NAME": {"type": "TEXT", "index": 1, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 2, "name": "CONCEPT_OID", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 3, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 4, "name": "MEASURE_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 372, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 9216, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.quality_measures__concepts"}, "model.the_tuva_project.data_quality__location_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_data_source"}, "model.the_tuva_project.dme__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DME__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__match_claims_to_anchor"}, "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events"}, "model.the_tuva_project.outpatient_radiology__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 20, "name": "HCPCS_CODE", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__encounter_grain"}, "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_POTENTIALLY_PLANNED_CCS_PROCEDURE_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 65, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category"}, "model.the_tuva_project.quality_measures__int_cqm236_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_long"}, "seed.the_tuva_project.data_quality__crosswalk_field_info": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_FIELD_INFO", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"INPUT_LAYER_TABLE_NAME": {"type": "TEXT", "index": 1, "name": "INPUT_LAYER_TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 3, "name": "FIELD_NAME", "comment": null}, "RED": {"type": "NUMBER", "index": 4, "name": "RED", "comment": null}, "GREEN": {"type": "NUMBER", "index": 5, "name": "GREEN", "comment": null}, "UNIQUE_VALUES_EXPECTED_FLAG": {"type": "NUMBER", "index": 6, "name": "UNIQUE_VALUES_EXPECTED_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 305, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5632, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_info"}, "model.the_tuva_project.data_quality__procedure_modifier_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_2"}, "model.the_tuva_project.data_quality__institutional_present_on_admission_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PRESENT_ON_ADMISSION_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_2"}, "model.the_tuva_project.data_quality__encounter_paid_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PAID_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_paid_amount"}, "seed.the_tuva_project.terminology__discharge_disposition": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "DISCHARGE_DISPOSITION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 1, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 41, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__discharge_disposition"}, "model.the_tuva_project.readmissions__index_discharge_requirement": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_INDEX_DISCHARGE_REQUIREMENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__index_discharge_requirement"}, "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor"}, "model.the_tuva_project.core__stg_claims_medical_claim": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_MEDICAL_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICAL_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "MEDICAL_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 8, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 9, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 10, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 16, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 17, "name": "DISCHARGE_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 19, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 20, "name": "SERVICE_CATEGORY_3", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 21, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 23, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 25, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 27, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 31, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 33, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 37, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 38, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 39, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 40, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 41, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 42, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 43, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 44, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 45, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 46, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 47, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 48, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 49, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 50, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 51, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 52, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 53, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 54, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 55, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 56, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 57, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 58, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 59, "name": "TOTAL_COST_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 60, "name": "IN_NETWORK_FLAG", "comment": null}, "ENROLLMENT_FLAG": {"type": "NUMBER", "index": 61, "name": "ENROLLMENT_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 62, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 63, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_medical_claim"}, "model.the_tuva_project.data_quality__eligibility_last_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_LAST_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_last_name"}, "model.the_tuva_project.data_quality__claim_charge_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CHARGE_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_charge_amount"}, "model.the_tuva_project.quality_measures__int_nqf2372_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_long"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR_CRITERIA1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1"}, "model.the_tuva_project.normalized_input__int_procedure_code_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_CODE_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 3, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 4, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 5, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 6, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 7, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 8, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 9, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 10, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 11, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 12, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 13, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 14, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 15, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 16, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 17, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 18, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 19, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 20, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 21, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 22, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 23, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 24, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 25, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 26, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 27, "name": "PROCEDURE_CODE_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_final"}, "model.the_tuva_project.service_category__stg_medical_claim": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "SERVICE_CATEGORY__STG_MEDICAL_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"APR_DRG_CODE": {"type": "TEXT", "index": 1, "name": "APR_DRG_CODE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_LINE_ID", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 5, "name": "CLAIM_TYPE", "comment": null}, "START_DATE": {"type": "DATE", "index": 6, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 7, "name": "END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 8, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 9, "name": "DISCHARGE_DATE", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_LINE_END_DATE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 14, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 16, "name": "HCPCS_CODE", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 17, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "MS_DRG_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 23, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 25, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 26, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 27, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 28, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 29, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "REND_PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "REND_PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "MODALITY": {"type": "TEXT", "index": 33, "name": "MODALITY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 34, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_medical_claim"}, "seed.the_tuva_project.reference_data__code_type": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE_TYPE": {"type": "TEXT", "index": 1, "name": "CODE_TYPE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 6, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__code_type"}, "model.the_tuva_project.data_quality__pharmacy_paid_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PAID_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_amount"}, "model.the_tuva_project.core__stg_clinical_practitioner": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_PRACTITIONER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 3, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 4, "name": "LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_practitioner"}, "model.the_tuva_project.data_quality__location_longitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_LONGITUDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_longitude"}, "model.the_tuva_project.data_quality__ed_classification_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ED_CLASSIFICATION_REFERENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 5, "name": "VALUE_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 9, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__ed_classification_reference"}, "seed.the_tuva_project.terminology__admit_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ADMIT_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ADMIT_TYPE_CODE": {"type": "TEXT", "index": 1, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 5, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__admit_type"}, "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_12_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_denom"}, "seed.the_tuva_project.terminology__snomed_icd_10_map": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "SNOMED_ICD_10_MAP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "EFFECTIVE_TIME": {"type": "TEXT", "index": 2, "name": "EFFECTIVE_TIME", "comment": null}, "ACTIVE": {"type": "TEXT", "index": 3, "name": "ACTIVE", "comment": null}, "MODULE_ID": {"type": "TEXT", "index": 4, "name": "MODULE_ID", "comment": null}, "REF_SET_ID": {"type": "TEXT", "index": 5, "name": "REF_SET_ID", "comment": null}, "REFERENCED_COMPONENT_ID": {"type": "TEXT", "index": 6, "name": "REFERENCED_COMPONENT_ID", "comment": null}, "REFERENCED_COMPONENT_NAME": {"type": "TEXT", "index": 7, "name": "REFERENCED_COMPONENT_NAME", "comment": null}, "MAP_GROUP": {"type": "TEXT", "index": 8, "name": "MAP_GROUP", "comment": null}, "MAP_PRIORITY": {"type": "TEXT", "index": 9, "name": "MAP_PRIORITY", "comment": null}, "MAP_RULE": {"type": "TEXT", "index": 10, "name": "MAP_RULE", "comment": null}, "MAP_ADVICE": {"type": "TEXT", "index": 11, "name": "MAP_ADVICE", "comment": null}, "MAP_TARGET": {"type": "TEXT", "index": 12, "name": "MAP_TARGET", "comment": null}, "MAP_TARGET_NAME": {"type": "TEXT", "index": 13, "name": "MAP_TARGET_NAME", "comment": null}, "CORRELATION_ID": {"type": "TEXT", "index": 14, "name": "CORRELATION_ID", "comment": null}, "MAP_CATEGORY_ID": {"type": "TEXT", "index": 15, "name": "MAP_CATEGORY_ID", "comment": null}, "MAP_CATEGORY_NAME": {"type": "TEXT", "index": 16, "name": "MAP_CATEGORY_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 256479, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 11658240, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__snomed_icd_10_map"}, "model.the_tuva_project.data_quality__eligibility_medicare_status_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MEDICARE_STATUS_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_medicare_status_code"}, "model.the_tuva_project.mart_review__number_of_conditions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__NUMBER_OF_CONDITIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 3, "name": "PATIENT_SOURCE_KEY", "comment": null}, "NUMOFCONDITIONS": {"type": "NUMBER", "index": 4, "name": "NUMOFCONDITIONS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__number_of_conditions"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions"}, "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_08_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_denom"}, "model.the_tuva_project.data_quality__condition_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_NORMALIZED_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code"}, "model.the_tuva_project.service_category__home_health_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_HOME_HEALTH_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__home_health_institutional"}, "model.the_tuva_project.data_quality__observation_normalized_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_UNITS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_units"}, "model.the_tuva_project.data_quality__eligibility_first_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_FIRST_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_first_name"}, "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_PHYSICAL_THERAPY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_professional"}, "model.the_tuva_project.data_quality__medication_rxnorm_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_RXNORM_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_code"}, "seed.the_tuva_project.terminology__icd_9_cm": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_9_CM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_9_CM": {"type": "TEXT", "index": 1, "name": "ICD_9_CM", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "LONG_DESCRIPTION", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "SHORT_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 14567, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 390144, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_9_cm"}, "model.the_tuva_project.core__stg_claims_procedure": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_PROCEDURE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 12, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 13, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 14, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 15, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 16, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 17, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 18, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 19, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_procedure"}, "seed.the_tuva_project.terminology__present_on_admission": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PRESENT_ON_ADMISSION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 1, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__present_on_admission"}, "model.the_tuva_project.quality_measures__int_cqm236__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236__performance_period"}, "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLAIMS_FOR_PBI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SUMMARY_SK": {"type": "NUMBER", "index": 1, "name": "SUMMARY_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 4, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 5, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 6, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 7, "name": "INVALID_REASON", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 8, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 9, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "FREQUENCY": {"type": "NUMBER", "index": 11, "name": "FREQUENCY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_for_pbi"}, "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DISCHARGE_DISPOSITION_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_voting"}, "model.the_tuva_project.normalized_input__int_procedure_date_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_DATE_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_COLUMN": {"type": "TEXT", "index": 3, "name": "PROCEDURE_COLUMN", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 4, "name": "PROCEDURE_DATE", "comment": null}, "PROCEDURE_DATE_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "PROCEDURE_DATE_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_normalize"}, "seed.the_tuva_project.terminology__mdc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MDC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MDC_CODE": {"type": "TEXT", "index": 1, "name": "MDC_CODE", "comment": null}, "MDC_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "MDC_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 25, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__mdc"}, "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_VALUE_SET_HCC_DESCRIPTIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCC_CODE": {"type": "TEXT", "index": 1, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "HCC_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 115, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4608, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"}, "model.the_tuva_project.office_visits__int_office_visits_ptotst": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_PTOTST", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_ptotst"}, "seed.the_tuva_project.cms_hcc__cpt_hcpcs": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_CPT_HCPCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PAYMENT_YEAR": {"type": "NUMBER", "index": 1, "name": "PAYMENT_YEAR", "comment": null}, "HCPCS_CPT_CODE": {"type": "TEXT", "index": 2, "name": "HCPCS_CPT_CODE", "comment": null}, "INCLUDED_FLAG": {"type": "TEXT", "index": 3, "name": "INCLUDED_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 39364, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 94208, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__cpt_hcpcs"}, "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_15_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions"}, "model.the_tuva_project.data_quality__claim_coinsurance_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CONINSURANCE_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_coinsurance_amount"}, "model.the_tuva_project.core__stg_claims_practitioner": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_PRACTITIONER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "PROVIDER_FIRST_NAME": {"type": "TEXT", "index": 3, "name": "PROVIDER_FIRST_NAME", "comment": null}, "PROVIDER_LAST_NAME": {"type": "TEXT", "index": 4, "name": "PROVIDER_LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_practitioner"}, "model.the_tuva_project.data_quality__observation_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_code"}, "model.the_tuva_project.data_quality__pharmacy_ndc_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_NDC_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_ndc_code"}, "model.the_tuva_project.service_category__observation_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OBSERVATION_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__observation_institutional"}, "model.the_tuva_project.cms_hcc__patient_risk_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "PATIENT_RISK_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 2, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 3, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 4, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 5, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 6, "name": "FACTOR_TYPE", "comment": null}, "RISK_FACTOR_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "RISK_FACTOR_DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 8, "name": "COEFFICIENT", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 9, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 10, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_factors"}, "model.the_tuva_project.inpatient_substance_use__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__prof_claims"}, "model.the_tuva_project.data_quality__patient_address": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_ADDRESS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_address"}, "model.the_tuva_project.service_category__combined_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_COMBINED_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 8, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__combined_professional"}, "model.the_tuva_project.asc__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 8, "name": "LENGTH_OF_STAY", "comment": null}, "GENDER": {"type": "TEXT", "index": 9, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 10, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 14, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 15, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 16, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 17, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 18, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 19, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 20, "name": "PHARMACY_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 21, "name": "HCPCS_CODE", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 27, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 28, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 29, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__encounter_grain"}, "model.the_tuva_project.data_quality__observation_observation_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_OBSERVATION_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_observation_date"}, "seed.input_layer.pharmacy_claim_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "PHARMACY_CLAIM_SEED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 4, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_NPI": {"type": "TEXT", "index": 7, "name": "PRESCRIBING_PROVIDER_NPI", "comment": null}, "DISPENSING_PROVIDER_NPI": {"type": "TEXT", "index": 8, "name": "DISPENSING_PROVIDER_NPI", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 9, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 10, "name": "NDC_CODE", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 11, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 12, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 13, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 14, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 15, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 16, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 17, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 18, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 19, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 20, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 21, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 22, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 23, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 24, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.pharmacy_claim_seed"}, "model.the_tuva_project.mart_review__patient_risk_scores": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT_RISK_SCORES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "V24_RISK_SCORE": {"type": "NUMBER", "index": 2, "name": "V24_RISK_SCORE", "comment": null}, "V28_RISK_SCORE": {"type": "NUMBER", "index": 3, "name": "V28_RISK_SCORE", "comment": null}, "BLENDED_RISK_SCORE": {"type": "NUMBER", "index": 4, "name": "BLENDED_RISK_SCORE", "comment": null}, "NORMALIZED_RISK_SCORE": {"type": "NUMBER", "index": 5, "name": "NORMALIZED_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE": {"type": "NUMBER", "index": 6, "name": "PAYMENT_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS": {"type": "NUMBER", "index": 7, "name": "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 8, "name": "MEMBER_MONTHS", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 9, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient_risk_scores"}, "model.the_tuva_project.service_category__emergency_department_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_EMERGENCY_DEPARTMENT_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__emergency_department_institutional"}, "model.the_tuva_project.inpatient_snf__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__prof_claims"}, "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period"}, "model.the_tuva_project.data_quality__observation_observation_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_OBSERVATION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_observation_id"}, "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_05_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions"}, "model.the_tuva_project.data_quality__acute_inpatient_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ACUTE_INPATIENT_REFERENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_reference"}, "model.the_tuva_project.data_quality__location_state": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_STATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_state"}, "model.the_tuva_project.data_quality__eligibility_address": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_ADDRESS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_address"}, "model.the_tuva_project.quality_measures__int_nqf0097_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_numerator"}, "model.the_tuva_project.core__stg_clinical_procedure": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_PROCEDURE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 12, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 13, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 14, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 15, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 16, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 17, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 18, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 19, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_procedure"}, "model.the_tuva_project.normalized_input__pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "NORMALIZED_INPUT_PHARMACY_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 4, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 7, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 9, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 11, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 12, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 14, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 15, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 16, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 17, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 18, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 19, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 20, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 24, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 25, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 26, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__pharmacy_claim"}, "model.the_tuva_project.service_category__inpatient_substance_use_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_SUBSTANCE_USE_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_substance_use_institutional"}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DIAGNOSIS_CODE_3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_3"}, "model.the_tuva_project.data_quality__encounter_admit_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_SOURCE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_description"}, "model.the_tuva_project.emergency_department__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__start_end_dates"}, "model.the_tuva_project.data_quality__location_location_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_LOCATION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_location_id"}, "model.the_tuva_project.readmissions__encounter_specialty_cohort": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_SPECIALTY_COHORT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 2, "name": "SPECIALTY_COHORT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_specialty_cohort"}, "seed.the_tuva_project.pharmacy__rxnorm_generic_available": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "RXNORM_GENERIC_AVAILABLE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRODUCT_TTY": {"type": "TEXT", "index": 1, "name": "PRODUCT_TTY", "comment": null}, "PRODUCT_RXCUI": {"type": "TEXT", "index": 2, "name": "PRODUCT_RXCUI", "comment": null}, "PRODUCT_NAME": {"type": "TEXT", "index": 3, "name": "PRODUCT_NAME", "comment": null}, "NDC_PRODUCT_TTY": {"type": "TEXT", "index": 4, "name": "NDC_PRODUCT_TTY", "comment": null}, "NDC_PRODUCT_RXCUI": {"type": "TEXT", "index": 5, "name": "NDC_PRODUCT_RXCUI", "comment": null}, "NDC_PRODUCT_NAME": {"type": "TEXT", "index": 6, "name": "NDC_PRODUCT_NAME", "comment": null}, "NDC": {"type": "TEXT", "index": 7, "name": "NDC", "comment": null}, "PRODUCT_STARTMARKETINGDATE": {"type": "DATE", "index": 8, "name": "PRODUCT_STARTMARKETINGDATE", "comment": null}, "PACKAGE_STARTMARKETINGDATE": {"type": "DATE", "index": 9, "name": "PACKAGE_STARTMARKETINGDATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 820285, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 7484416, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.pharmacy__rxnorm_generic_available"}, "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_COMORBIDITY_SUSPECTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "HCC_DESCRIPTION", "comment": null}, "CONDITION_1_CONCEPT_NAME": {"type": "TEXT", "index": 5, "name": "CONDITION_1_CONCEPT_NAME", "comment": null}, "CONDITION_1_CODE": {"type": "TEXT", "index": 6, "name": "CONDITION_1_CODE", "comment": null}, "CONDITION_1_RECORDED_DATE": {"type": "DATE", "index": 7, "name": "CONDITION_1_RECORDED_DATE", "comment": null}, "CONDITION_2_CONCEPT_NAME": {"type": "TEXT", "index": 8, "name": "CONDITION_2_CONCEPT_NAME", "comment": null}, "CONDITION_2_CODE": {"type": "TEXT", "index": 9, "name": "CONDITION_2_CODE", "comment": null}, "CONDITION_2_RECORDED_DATE": {"type": "DATE", "index": 10, "name": "CONDITION_2_RECORDED_DATE", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 11, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 12, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 13, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 14, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects"}, "model.the_tuva_project.data_quality__patient_city": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_CITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_city"}, "seed.the_tuva_project.terminology__claim_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "CLAIM_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_TYPE": {"type": "TEXT", "index": 1, "name": "CLAIM_TYPE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__claim_type"}, "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_exclusions"}, "model.the_tuva_project.inpatient_rehab__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__generate_encounter_id"}, "model.the_tuva_project.data_quality__practitioner_last_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_LAST_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_last_name"}, "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_11_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_denom"}, "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_01_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_denom"}, "model.the_tuva_project.data_quality__condition_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_NORMALIZED_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code_type"}, "model.the_tuva_project.quality_measures__int_cbe0101_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_numerator"}, "model.the_tuva_project.quality_measures__int_nqf0034_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 2, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE": {"type": "TEXT", "index": 3, "name": "EVIDENCE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_numerator"}, "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "DATA_QUALITY__CROSSWALK_FIELD_TO_MART_SK", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"INPUT_LAYER_TABLE_NAME": {"type": "TEXT", "index": 1, "name": "INPUT_LAYER_TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 3, "name": "FIELD_NAME", "comment": null}, "MART_NAME": {"type": "TEXT", "index": 4, "name": "MART_NAME", "comment": null}, "TABLE_CLAIM_TYPE_FIELD_SK": {"type": "NUMBER", "index": 5, "name": "TABLE_CLAIM_TYPE_FIELD_SK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk"}, "model.the_tuva_project.data_quality__pharmacy_quantity": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_QUANTITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_quantity"}, "model.the_tuva_project.data_quality__medication_medication_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_MEDICATION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_medication_id"}, "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_PATIENT_HCC_HISTORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 3, "name": "RECORDED_DATE", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CONDITION_TYPE", "comment": null}, "ICD_10_CM_CODE": {"type": "TEXT", "index": 5, "name": "ICD_10_CM_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 6, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "HCC_DESCRIPTION", "comment": null}, "FIRST_RECORDED": {"type": "DATE", "index": 8, "name": "FIRST_RECORDED", "comment": null}, "LAST_RECORDED": {"type": "DATE", "index": 9, "name": "LAST_RECORDED", "comment": null}, "LAST_BILLED": {"type": "DATE", "index": 10, "name": "LAST_BILLED", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 11, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 12, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 13, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 14, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"}, "model.the_tuva_project.cms_hcc__int_demographic_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DEMOGRAPHIC_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 2, "name": "ENROLLMENT_STATUS", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 4, "name": "AGE_GROUP", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 5, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 6, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 7, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 8, "name": "INSTITUTIONAL_STATUS", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 9, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 10, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 11, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 12, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 13, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 14, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 15, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 16, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_demographic_factors"}, "model.the_tuva_project.data_quality__chronic_conditions_prevalence": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CHRONIC_CONDITIONS_PREVALENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "PATIENTS": {"type": "NUMBER", "index": 3, "name": "PATIENTS", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 4, "name": "VALUE_RANK", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 5, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 6, "name": "ANALYTICS_VALUE", "comment": null}, "MEDICARE_LDS_CONDITION_RANK": {"type": "NUMBER", "index": 7, "name": "MEDICARE_LDS_CONDITION_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 10, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_prevalence"}, "model.the_tuva_project.data_quality__observation_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_code_type"}, "model.the_tuva_project.quality_measures__int_cqm48_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "ENCOUNTER_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_DATE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_denominator"}, "model.the_tuva_project.quality_measures__int_cqm236_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_denominator"}, "model.the_tuva_project.service_category__inpatient_psychiatric_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_PSYCHIATRIC_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_professional"}, "model.the_tuva_project.pharmacy__int_brand_with_generic_available": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_BRAND_WITH_GENERIC_AVAILABLE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BRAND_WITH_GENERIC_AVAILABLE": {"type": "TEXT", "index": 1, "name": "BRAND_WITH_GENERIC_AVAILABLE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_brand_with_generic_available"}, "model.the_tuva_project.ambulance__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__generate_encounter_id"}, "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_ORIGINAL_REASON_ENTITLEMENT_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code"}, "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_EXCLUSION_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_ID", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "PQI_NUMBER": {"type": "NUMBER", "index": 5, "name": "PQI_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"}, "model.the_tuva_project.hcc_suspecting__int_prep_conditions": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_PREP_CONDITIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 2, "name": "RECORDED_DATE", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 3, "name": "CONDITION_TYPE", "comment": null}, "CODE_TYPE": {"type": "TEXT", "index": 4, "name": "CODE_TYPE", "comment": null}, "CODE": {"type": "TEXT", "index": 5, "name": "CODE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 6, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_conditions"}, "model.the_tuva_project.cms_hcc__int_hcc_count_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_HCC_COUNT_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 3, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 4, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 5, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 6, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_count_factors"}, "model.the_tuva_project.ahrq_measures__pqi_summary": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PQI_NUMBER": {"type": "TEXT", "index": 1, "name": "PQI_NUMBER", "comment": null}, "PQI_NAME": {"type": "TEXT", "index": 2, "name": "PQI_NAME", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 6, "name": "PATIENT_ID", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 7, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 8, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "MS_DRG_DESCRIPTION", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 10, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 11, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 12, "name": "LENGTH_OF_STAY", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 13, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_summary"}, "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_exclusions"}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "_VALUE_SET_DXCCSR_V2023_1_CLEANED_MAP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM_CODE": {"type": "TEXT", "index": 1, "name": "ICD_10_CM_CODE", "comment": null}, "ICD_10_CM_CODE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ICD_10_CM_CODE_DESCRIPTION", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 3, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 4, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 5, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 6, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "CCSR_CATEGORY_1": {"type": "TEXT", "index": 7, "name": "CCSR_CATEGORY_1", "comment": null}, "CCSR_CATEGORY_1_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "CCSR_CATEGORY_1_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_2": {"type": "TEXT", "index": 9, "name": "CCSR_CATEGORY_2", "comment": null}, "CCSR_CATEGORY_2_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "CCSR_CATEGORY_2_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_3": {"type": "TEXT", "index": 11, "name": "CCSR_CATEGORY_3", "comment": null}, "CCSR_CATEGORY_3_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "CCSR_CATEGORY_3_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_4": {"type": "TEXT", "index": 13, "name": "CCSR_CATEGORY_4", "comment": null}, "CCSR_CATEGORY_4_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "CCSR_CATEGORY_4_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_5": {"type": "TEXT", "index": 15, "name": "CCSR_CATEGORY_5", "comment": null}, "CCSR_CATEGORY_5_DESCRIPTION": {"type": "TEXT", "index": 16, "name": "CCSR_CATEGORY_5_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_6": {"type": "TEXT", "index": 17, "name": "CCSR_CATEGORY_6", "comment": null}, "CCSR_CATEGORY_6_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "CCSR_CATEGORY_6_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 74549, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1899008, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map"}, "model.the_tuva_project.outpatient_psych__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__encounter_grain"}, "model.the_tuva_project.data_quality__location_latitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_LATITUDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_latitude"}, "model.the_tuva_project.mart_review__tuva_chronic_conditions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__TUVA_CHRONIC_CONDITIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "CONDITION": {"type": "TEXT", "index": 3, "name": "CONDITION", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 4, "name": "PATIENT_SOURCE_KEY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__tuva_chronic_conditions"}, "model.the_tuva_project.orphaned_claim__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ORPHANED_CLAIM__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 27, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 28, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 29, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.orphaned_claim__encounter_grain"}, "model.the_tuva_project.quality_measures__int_nqf0420_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_denominator"}, "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DISCHARGE_DISPOSITION_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_disposition_code"}, "model.the_tuva_project.outpatient_psych__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__anchor_events"}, "model.the_tuva_project.data_quality__encounter_encounter_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_START_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_start_date"}, "model.the_tuva_project.data_quality__claim_claim_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_type"}, "seed.the_tuva_project.terminology__apr_drg": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "APR_DRG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"APR_DRG_CODE": {"type": "TEXT", "index": 1, "name": "APR_DRG_CODE", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 2, "name": "MEDICAL_SURGICAL", "comment": null}, "MDC_CODE": {"type": "TEXT", "index": 3, "name": "MDC_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "APR_DRG_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 316, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8704, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__apr_drg"}, "model.the_tuva_project.data_quality__location_facility_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_FACILITY_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_facility_type"}, "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_15_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_denom"}, "model.the_tuva_project.data_quality__data_quality_claims_detail": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLAIMS_DETAIL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 12, "name": "SUMMARY_SK", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_detail"}, "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_MART_TO_OUTCOME_MEASURE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MART_NAME": {"type": "TEXT", "index": 1, "name": "MART_NAME", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure"}, "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DIAGNOSIS_CODE_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_COLUMN": {"type": "TEXT", "index": 4, "name": "DIAGNOSIS_COLUMN", "comment": null}, "NORMALIZED_DIAGNOSIS_CODE": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DIAGNOSIS_CODE", "comment": null}, "DIAGNOSIS_CODE_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "DIAGNOSIS_CODE_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize"}, "model.the_tuva_project.service_category__office_based_visit_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OFFICE_BASED_VISIT_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_visit_professional"}, "model.the_tuva_project.service_category__combined_institutional_line_level": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_COMBINED_INSTITUTIONAL_LINE_LEVEL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__combined_institutional_line_level"}, "model.the_tuva_project.data_quality__condition_present_on_admit_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_PRESENT_ON_ADMIT_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_code"}, "model.the_tuva_project.quality_measures__int_cbe0055_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_numerator"}, "model.the_tuva_project.data_quality__eligibility_plan": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PLAN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_plan"}, "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_11_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions"}, "model.the_tuva_project.data_quality__institutional_admission_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_ADMISSION_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_admission_date"}, "seed.the_tuva_project.ed_classification__johnston_icd10": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_JOHNSTON_ICD10", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD10": {"type": "TEXT", "index": 1, "name": "ICD10", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 2, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 3, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 4, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 5, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 6, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 7, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 8, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 9, "name": "DRUG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 47132, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 304128, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd10"}, "model.the_tuva_project.data_quality__procedure_modifier_4": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_4", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_4"}, "model.the_tuva_project.data_quality__service_category_pmpm_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "SERVICE_CATEGORY_PMPM_TREND", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 4, "name": "TOTAL_PAID", "comment": null}, "PMPM": {"type": "NUMBER", "index": 5, "name": "PMPM", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__service_category_pmpm_trend"}, "model.the_tuva_project.data_quality__procedure_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_CLAIM_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_claim_id"}, "model.the_tuva_project.data_quality__patient_birth_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_BIRTH_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_birth_date"}, "model.the_tuva_project.outpatient_substance_use__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__encounter_grain"}, "model.the_tuva_project.normalized_input__int_place_of_service_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PLACE_OF_SERVICE_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_place_of_service_normalize"}, "model.the_tuva_project.quality_measures__summary_wide": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "SUMMARY_WIDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "NQF_2372": {"type": "NUMBER", "index": 2, "name": "NQF_2372", "comment": null}, "NQF_0034": {"type": "NUMBER", "index": 3, "name": "NQF_0034", "comment": null}, "NQF_0059": {"type": "NUMBER", "index": 4, "name": "NQF_0059", "comment": null}, "CQM_236": {"type": "NUMBER", "index": 5, "name": "CQM_236", "comment": null}, "NQF_0053": {"type": "NUMBER", "index": 6, "name": "NQF_0053", "comment": null}, "CBE_0055": {"type": "NUMBER", "index": 7, "name": "CBE_0055", "comment": null}, "NQF_0097": {"type": "NUMBER", "index": 8, "name": "NQF_0097", "comment": null}, "CQM_438": {"type": "NUMBER", "index": 9, "name": "CQM_438", "comment": null}, "NQF_0041": {"type": "NUMBER", "index": 10, "name": "NQF_0041", "comment": null}, "CBE_0101": {"type": "NUMBER", "index": 11, "name": "CBE_0101", "comment": null}, "CQM_48": {"type": "NUMBER", "index": 12, "name": "CQM_48", "comment": null}, "CQM_130": {"type": "NUMBER", "index": 13, "name": "CQM_130", "comment": null}, "NQF_0420": {"type": "NUMBER", "index": 14, "name": "NQF_0420", "comment": null}, "ADH_DIABETES": {"type": "NUMBER", "index": 15, "name": "ADH_DIABETES", "comment": null}, "ADH_RAS": {"type": "NUMBER", "index": 16, "name": "ADH_RAS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__summary_wide"}, "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_16_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"}, "model.the_tuva_project.data_quality__encounters_missing_groups_union": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_MISSING_GROUPS_UNION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups_union"}, "model.the_tuva_project.outpatient_radiology__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 3, "name": "HCPCS_CODE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__generate_encounter_id"}, "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_03_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_denom"}, "model.the_tuva_project.data_quality__encounter_attending_provider_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ATTENDING_PROVIDER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_attending_provider_id"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_INSTITUTIONAL_SNP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"}, "model.the_tuva_project.ahrq_measures__int_pqi_16_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_16_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_num"}, "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_PHYSICAL_THERAPY_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional"}, "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_ICD_10_CM_MAPPINGS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PAYMENT_YEAR": {"type": "NUMBER", "index": 1, "name": "PAYMENT_YEAR", "comment": null}, "DIAGNOSIS_CODE": {"type": "TEXT", "index": 2, "name": "DIAGNOSIS_CODE", "comment": null}, "CMS_HCC_V24": {"type": "TEXT", "index": 3, "name": "CMS_HCC_V24", "comment": null}, "CMS_HCC_V24_FLAG": {"type": "TEXT", "index": 4, "name": "CMS_HCC_V24_FLAG", "comment": null}, "CMS_HCC_V28": {"type": "TEXT", "index": 5, "name": "CMS_HCC_V28", "comment": null}, "CMS_HCC_V28_FLAG": {"type": "TEXT", "index": 6, "name": "CMS_HCC_V28_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 78932, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 459776, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings"}, "model.the_tuva_project.data_quality__eligibility_payer_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PAYER_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer_type"}, "seed.the_tuva_project.terminology__place_of_service": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PLACE_OF_SERVICE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 1, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 50, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__place_of_service"}, "model.the_tuva_project.quality_measures__int_adhras__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras__performance_period"}, "model.the_tuva_project.readmissions__readmission_crude": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_READMISSION_CRUDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "HAD_READMISSION_FLAG": {"type": "NUMBER", "index": 5, "name": "HAD_READMISSION_FLAG", "comment": null}, "DAYS_TO_READMIT": {"type": "NUMBER", "index": 6, "name": "DAYS_TO_READMIT", "comment": null}, "READMIT_30_FLAG": {"type": "NUMBER", "index": 7, "name": "READMIT_30_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__readmission_crude"}, "model.the_tuva_project.data_quality__medication_prescribing_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_PRESCRIBING_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_prescribing_date"}, "model.the_tuva_project.outpatient_ptotst__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__anchor_events"}, "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_exclusions"}, "model.the_tuva_project.outpatient_injections__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__generate_encounter_id"}, "model.the_tuva_project.data_quality__medication_ndc_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_NDC_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_description"}, "model.the_tuva_project.pharmacy__brand_generic_opportunity": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "BRAND_GENERIC_OPPORTUNITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 4, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NDC_DESCRIPTION", "comment": null}, "BRAND_RXCUI": {"type": "TEXT", "index": 6, "name": "BRAND_RXCUI", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 7, "name": "BRAND_VS_GENERIC", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 8, "name": "GENERIC_AVAILABLE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "TOTAL_UNITS": {"type": "NUMBER", "index": 10, "name": "TOTAL_UNITS", "comment": null}, "BRAND_COST_PER_UNIT": {"type": "NUMBER", "index": 11, "name": "BRAND_COST_PER_UNIT", "comment": null}, "GENERIC_AVERAGE_COST_PER_UNIT": {"type": "NUMBER", "index": 12, "name": "GENERIC_AVERAGE_COST_PER_UNIT", "comment": null}, "BRAND_LESS_GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 13, "name": "BRAND_LESS_GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY": {"type": "NUMBER", "index": 14, "name": "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__brand_generic_opportunity"}, "model.the_tuva_project.data_quality__eligibility_death_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DEATH_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_date"}, "model.the_tuva_project.data_quality__eligibility_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_START_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_start_date"}, "model.the_tuva_project.service_category__pharmacy_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__PHARMACY_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__pharmacy_institutional"}, "seed.the_tuva_project.terminology__bill_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "BILL_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BILL_TYPE_CODE": {"type": "TEXT", "index": 1, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "DEPRECATED": {"type": "NUMBER", "index": 3, "name": "DEPRECATED", "comment": null}, "DEPRECATED_DATE": {"type": "DATE", "index": 4, "name": "DEPRECATED_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1701, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 22016, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__bill_type"}, "model.the_tuva_project.data_quality__procedure_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_NORMALIZED_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_description"}, "model.the_tuva_project.data_quality__lab_result_normalized_component": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_COMPONENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_component"}, "model.the_tuva_project.data_quality__institutional_procedure_date_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_DATE_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_2"}, "model.the_tuva_project.normalized_input__int_medical_npi_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MEDICAL_NPI_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_RENDERING_NPI": {"type": "TEXT", "index": 5, "name": "NORMALIZED_RENDERING_NPI", "comment": null}, "NORMALIZED_RENDERING_NAME": {"type": "TEXT", "index": 6, "name": "NORMALIZED_RENDERING_NAME", "comment": null}, "NORMALIZED_BILLING_NPI": {"type": "TEXT", "index": 7, "name": "NORMALIZED_BILLING_NPI", "comment": null}, "NORMALIZED_BILLING_NAME": {"type": "TEXT", "index": 8, "name": "NORMALIZED_BILLING_NAME", "comment": null}, "NORMALIZED_FACILITY_NPI": {"type": "TEXT", "index": 9, "name": "NORMALIZED_FACILITY_NPI", "comment": null}, "NORMALIZED_FACILITY_NAME": {"type": "TEXT", "index": 10, "name": "NORMALIZED_FACILITY_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_medical_npi_normalize"}, "model.the_tuva_project.office_visits__int_office_visits_claim_line": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_CLAIM_LINE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_claim_line"}, "model.the_tuva_project.inpatient_psych__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__start_end_dates"}, "model.the_tuva_project.quality_measures__int_adhras_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 2, "name": "DISPENSING_DATE", "comment": null}, "FIRST_DISPENSING_DATE": {"type": "DATE", "index": 3, "name": "FIRST_DISPENSING_DATE", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 4, "name": "DAYS_SUPPLY", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 5, "name": "NDC_CODE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 7, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 8, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 9, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 10, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 11, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_denominator"}, "seed.the_tuva_project.ed_classification__categories": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_CATEGORIES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLASSIFICATION": {"type": "TEXT", "index": 1, "name": "CLASSIFICATION", "comment": null}, "CLASSIFICATION_NAME": {"type": "TEXT", "index": 2, "name": "CLASSIFICATION_NAME", "comment": null}, "CLASSIFICATION_ORDER": {"type": "TEXT", "index": 3, "name": "CLASSIFICATION_ORDER", "comment": null}, "CLASSIFICATION_COLUMN": {"type": "TEXT", "index": 4, "name": "CLASSIFICATION_COLUMN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 9, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__categories"}, "model.the_tuva_project.data_quality__eligibility_birth_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_BIRTH_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_birth_date"}, "model.the_tuva_project.ahrq_measures__int_pqi_15_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_15_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_num"}, "model.the_tuva_project.ahrq_measures__pqi_num_long": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_NUM_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 5, "name": "PQI_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_num_long"}, "model.the_tuva_project.quality_measures__int_nqf0059_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_denominator"}, "model.the_tuva_project.mart_review__member_months": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__MEMBER_MONTHS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 10, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 14, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 15, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 16, "name": "MEDICAL_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 17, "name": "PHARMACY_PAID", "comment": null}, "PATIENT_DATA_SOURCE_KEY": {"type": "TEXT", "index": 18, "name": "PATIENT_DATA_SOURCE_KEY", "comment": null}, "MEMBER_MONTH_KEY": {"type": "TEXT", "index": 19, "name": "MEMBER_MONTH_KEY", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__member_months"}, "seed.the_tuva_project.cms_hcc__disease_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISEASE_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 4, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 5, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 6, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 8, "name": "HCC_CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 9, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 10, "name": "COEFFICIENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1369, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 24576, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disease_factors"}, "model.the_tuva_project.cms_hcc__patient_risk_scores": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "PATIENT_RISK_SCORES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "V24_RISK_SCORE": {"type": "NUMBER", "index": 2, "name": "V24_RISK_SCORE", "comment": null}, "V28_RISK_SCORE": {"type": "NUMBER", "index": 3, "name": "V28_RISK_SCORE", "comment": null}, "BLENDED_RISK_SCORE": {"type": "NUMBER", "index": 4, "name": "BLENDED_RISK_SCORE", "comment": null}, "NORMALIZED_RISK_SCORE": {"type": "NUMBER", "index": 5, "name": "NORMALIZED_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE": {"type": "NUMBER", "index": 6, "name": "PAYMENT_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS": {"type": "NUMBER", "index": 7, "name": "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 8, "name": "MEMBER_MONTHS", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 9, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_scores"}, "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__generate_encounter_id"}, "model.the_tuva_project.data_quality__medication_dispensing_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_DISPENSING_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_dispensing_date"}, "model.the_tuva_project.data_quality__eligibility_demographics": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DEMOGRAPHICS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_demographics"}, "model.the_tuva_project.data_quality__eligibility_death_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DEATH_FLAG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_flag"}, "model.the_tuva_project.mart_review__calendar_month": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__CALENDAR_MONTH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "FULL_DATE": {"type": "DATE", "index": 2, "name": "FULL_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2629, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 16384, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__calendar_month"}, "model.the_tuva_project.data_quality__claim_percent": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLAIM_PERCENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_TYPE": {"type": "TEXT", "index": 1, "name": "CLAIM_TYPE", "comment": null}, "PERCENT_OF_TOTAL_PAID": {"type": "FLOAT", "index": 2, "name": "PERCENT_OF_TOTAL_PAID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_percent"}, "model.the_tuva_project.home_health__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__match_claims_to_anchor"}, "model.the_tuva_project.service_category__ambulatory_surgery_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULATORY_SURGERY_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_institutional"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_INT_CMS_CHRONIC_CONDITION_ALL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"}, "model.the_tuva_project.outpatient_hospice__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__anchor_events"}, "model.the_tuva_project.normalized_input__int_revenue_center_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_REVENUE_CENTER_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_revenue_center_normalize"}, "model.the_tuva_project.data_quality__pharmacy_dispensing_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DISPENSING_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_date"}, "model.the_tuva_project.data_quality__observation_result": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_RESULT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_result"}, "model.the_tuva_project.core__stg_claims_encounter": {"metadata": {"type": "BASE TABLE", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_ENCOUNTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_encounter"}, "model.the_tuva_project.service_category__pharmacy_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__PHARMACY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__pharmacy_professional"}, "model.the_tuva_project.data_quality__pharmacy_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_patient_id"}, "model.the_tuva_project.data_quality__lab_result_accession_number": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_ACCESSION_NUMBER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_accession_number"}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_REFERENCE_RANGE_HIGH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_high"}, "model.the_tuva_project.service_category__outpatient_substance_use_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SUBSTANCE_USE_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_professional"}, "model.the_tuva_project.data_quality__encounter_charge_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_CHARGE_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_charge_amount"}, "model.the_tuva_project.hcc_suspecting__summary": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PATIENT_SEX": {"type": "TEXT", "index": 2, "name": "PATIENT_SEX", "comment": null}, "PATIENT_BIRTH_DATE": {"type": "DATE", "index": 3, "name": "PATIENT_BIRTH_DATE", "comment": null}, "PATIENT_AGE": {"type": "NUMBER", "index": 4, "name": "PATIENT_AGE", "comment": null}, "SUSPECTING_GAPS": {"type": "NUMBER", "index": 5, "name": "SUSPECTING_GAPS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__summary"}, "model.the_tuva_project.normalized_input__int_discharge_disposition_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DISCHARGE_DISPOSITION_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_final"}, "model.the_tuva_project.emergency_department__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__generate_encounter_id"}, "model.the_tuva_project.normalized_input__int_medical_date_aggregation": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MEDICAL_DATE_AGGREGATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "MINIMUM_CLAIM_START_DATE": {"type": "DATE", "index": 3, "name": "MINIMUM_CLAIM_START_DATE", "comment": null}, "MAXIMUM_CLAIM_END_DATE": {"type": "DATE", "index": 4, "name": "MAXIMUM_CLAIM_END_DATE", "comment": null}, "MINIMUM_ADMISSION_DATE": {"type": "DATE", "index": 5, "name": "MINIMUM_ADMISSION_DATE", "comment": null}, "MAXIMUM_DISCHARGE_DATE": {"type": "DATE", "index": 6, "name": "MAXIMUM_DISCHARGE_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_medical_date_aggregation"}, "model.the_tuva_project.data_quality__claim_paid_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PAID_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_paid_date"}, "model.the_tuva_project.quality_measures__int_nqf0041_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_numerator"}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DIAGNOSIS_CODE_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_2"}, "model.the_tuva_project.data_quality__encounter_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_data_source"}, "model.the_tuva_project.financial_pmpm__pmpm_prep": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "PMPM_PREP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 6, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 10, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 14, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 15, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 16, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 17, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 18, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 19, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 20, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 21, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 22, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 23, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 24, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 25, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 26, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 27, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 28, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 29, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 30, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 31, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 32, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 33, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 34, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 35, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 36, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OTHER_PAID_2": {"type": "NUMBER", "index": 37, "name": "OTHER_PAID_2", "comment": null}, "OUTPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 38, "name": "OUTPATIENT_HOSPICE_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 39, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 40, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 41, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 42, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 43, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 44, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "PHARMACY_PAID_2": {"type": "NUMBER", "index": 45, "name": "PHARMACY_PAID_2", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 46, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 47, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 48, "name": "URGENT_CARE_PAID", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 49, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 50, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 51, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 52, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 53, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 54, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 55, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 56, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 57, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 58, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 59, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 60, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 61, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 62, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 63, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 64, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 65, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 70, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 71, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OTHER_ALLOWED_2": {"type": "NUMBER", "index": 72, "name": "OTHER_ALLOWED_2", "comment": null}, "OUTPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 73, "name": "OUTPATIENT_HOSPICE_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 74, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 75, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 76, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 77, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 78, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 79, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "PHARMACY_ALLOWED_2": {"type": "NUMBER", "index": 80, "name": "PHARMACY_ALLOWED_2", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 81, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 82, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 83, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 84, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 85, "name": "MEDICAL_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 86, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 87, "name": "MEDICAL_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 88, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_prep"}, "model.the_tuva_project.quality_measures__int_nqf0041_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_denominator"}, "model.the_tuva_project.data_quality__institutional_service_unit_quantity": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_SERVICE_UNIT_QUANTITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_service_unit_quantity"}, "model.the_tuva_project.service_category__combined_institutional_header_level": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_COMBINED_INSTITUTIONAL_HEADER_LEVEL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__combined_institutional_header_level"}, "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_exclusions"}, "model.the_tuva_project.core__stg_clinical_condition": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_CONDITION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 16, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 17, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_condition"}, "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_PATIENT_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_patient_patient_id"}, "model.the_tuva_project.data_quality__quality_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "QUALITY_TREND", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"FIRST_DAY_OF_MONTH": {"type": "DATE", "index": 1, "name": "FIRST_DAY_OF_MONTH", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 2, "name": "SUMMARY_SK", "comment": null}, "VALID_NUM": {"type": "NUMBER", "index": 3, "name": "VALID_NUM", "comment": null}, "FILL_NUM": {"type": "NUMBER", "index": 4, "name": "FILL_NUM", "comment": null}, "DENOM": {"type": "NUMBER", "index": 5, "name": "DENOM", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__quality_trend"}, "model.the_tuva_project.data_quality__observation_panel_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_PANEL_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_panel_id"}, "model.the_tuva_project.data_quality__institutional_bill_type_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_BILL_TYPE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_bill_type_code"}, "model.the_tuva_project.service_category__emergency_department_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_EMERGENCY_DEPARTMENT_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__emergency_department_professional"}, "model.the_tuva_project.data_quality__encounter_apr_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_APR_DRG_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_code"}, "model.the_tuva_project.core__eligibility": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "ELIGIBILITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ELIGIBILITY_ID": {"type": "TEXT", "index": 1, "name": "ELIGIBILITY_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 3, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 4, "name": "SUBSCRIBER_ID", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 5, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 6, "name": "DEATH_DATE", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 7, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 8, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 9, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 10, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 12, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 13, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 14, "name": "MEDICARE_STATUS_CODE", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 15, "name": "SUBSCRIBER_RELATION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 16, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__eligibility"}, "model.the_tuva_project.data_quality__claim_type_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_TYPE_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 3, "name": "CLAIM_COUNT", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 4, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_type_summary"}, "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_03_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions"}, "model.the_tuva_project.inpatient_psych__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__prof_claims"}, "model.the_tuva_project.ccsr__long_condition_category": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "LONG_CONDITION_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CODE_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 6, "name": "CONDITION_RANK", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 7, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 8, "name": "BODY_SYSTEM", "comment": null}, "PARENT_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "PARENT_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 10, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_RANK": {"type": "NUMBER", "index": 12, "name": "CCSR_CATEGORY_RANK", "comment": null}, "IS_IP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 13, "name": "IS_IP_DEFAULT_CATEGORY", "comment": null}, "IS_OP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 14, "name": "IS_OP_DEFAULT_CATEGORY", "comment": null}, "DXCCSR_VERSION": {"type": "TEXT", "index": 15, "name": "DXCCSR_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 16, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__long_condition_category"}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPITAL_OR_CLINIC_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional"}, "model.the_tuva_project.data_quality__data_loss": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_LOSS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"TABLE_NAME": {"type": "TEXT", "index": 1, "name": "TABLE_NAME", "comment": null}, "METRIC": {"type": "TEXT", "index": 2, "name": "METRIC", "comment": null}, "INPUT_LAYER_VALUE": {"type": "FLOAT", "index": 3, "name": "INPUT_LAYER_VALUE", "comment": null}, "CORE_VALUE": {"type": "NUMBER", "index": 4, "name": "CORE_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_loss"}, "model.the_tuva_project.data_quality__procedure_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_SOURCE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_source_description"}, "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_EXCLUSION_CCS_DIAGNOSIS_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "EXCLUSION_CATEGORY": {"type": "TEXT", "index": 3, "name": "EXCLUSION_CATEGORY", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 47, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category"}, "model.the_tuva_project.normalized_input__int_undetermined_claim_type": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_UNDETERMINED_CLAIM_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 16, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 17, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 18, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 22, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 24, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 25, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 26, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 28, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 29, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 30, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 31, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 32, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 33, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 34, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 35, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 36, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 37, "name": "RENDERING_NPI", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 38, "name": "RENDERING_NAME", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 39, "name": "BILLING_NPI", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 40, "name": "BILLING_NAME", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 41, "name": "FACILITY_NPI", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 42, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 43, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 44, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 45, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 46, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 47, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 48, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 49, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 50, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 93, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 94, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 95, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 96, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 97, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 98, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 99, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 100, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 101, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 119, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 120, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 121, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 122, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 123, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 124, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 125, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 126, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 127, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 144, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 145, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 146, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 147, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 148, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 149, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 150, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 151, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 152, "name": "PROCEDURE_DATE_25", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 153, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 154, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_undetermined_claim_type"}, "model.the_tuva_project.data_quality__condition_present_on_admit_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_PRESENT_ON_ADMIT_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_description"}, "model.the_tuva_project.data_quality__location_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_npi"}, "model.the_tuva_project.mart_review__patient": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}, "PATIENT_DATA_SOURCE_KEY": {"type": "TEXT", "index": 21, "name": "PATIENT_DATA_SOURCE_KEY", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient"}, "model.the_tuva_project.data_quality__encounter_allowed_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ALLOWED_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_allowed_amount"}, "seed.the_tuva_project.clinical_concept_library__clinical_concepts": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "CLINICAL_CONCEPTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_ID": {"type": "TEXT", "index": 1, "name": "CONCEPT_ID", "comment": null}, "CONCEPT_NAME": {"type": "TEXT", "index": 2, "name": "CONCEPT_NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 3, "name": "STATUS", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 4, "name": "CONCEPT_OID", "comment": null}, "LAST_UPDATE_DATE": {"type": "DATE", "index": 5, "name": "LAST_UPDATE_DATE", "comment": null}, "LAST_UPDATE_NOTE": {"type": "TEXT", "index": 6, "name": "LAST_UPDATE_NOTE", "comment": null}, "CONCEPT_TYPE": {"type": "TEXT", "index": 7, "name": "CONCEPT_TYPE", "comment": null}, "CONTENT_SOURCE": {"type": "TEXT", "index": 8, "name": "CONTENT_SOURCE", "comment": null}, "EXTERNAL_SOURCE_DETAIL": {"type": "TEXT", "index": 9, "name": "EXTERNAL_SOURCE_DETAIL", "comment": null}, "CONCEPT_SCOPE": {"type": "TEXT", "index": 10, "name": "CONCEPT_SCOPE", "comment": null}, "VALUE_SET_SEARCH_NOTES": {"type": "TEXT", "index": 11, "name": "VALUE_SET_SEARCH_NOTES", "comment": null}, "CODE": {"type": "TEXT", "index": 12, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "CODE_DESCRIPTION", "comment": null}, "CODING_SYSTEM_ID": {"type": "TEXT", "index": 14, "name": "CODING_SYSTEM_ID", "comment": null}, "CODING_SYSTEM_VERSION": {"type": "TEXT", "index": 15, "name": "CODING_SYSTEM_VERSION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 197, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 56320, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.clinical_concept_library__clinical_concepts"}, "seed.the_tuva_project.terminology__medicare_status": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MEDICARE_STATUS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 1, "name": "MEDICARE_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "MEDICARE_STATUS_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 5, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__medicare_status"}, "model.the_tuva_project.office_visits__int_office_visits_telehealth": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_TELEHEALTH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_telehealth"}, "model.the_tuva_project.inpatient_substance_use__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__encounter_grain"}, "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_PRACTITIONER_PRACTITIONER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_INT_CMS_CHRONIC_CONDITION_OUD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"}, "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"}, "model.the_tuva_project.acute_inpatient__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 14, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 15, "name": "ED_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 20, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 21, "name": "FACILITY_TYPE", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 22, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 23, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 24, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 25, "name": "NICU_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 26, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 28, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 29, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 31, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 33, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 35, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 37, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 38, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 39, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 42, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 43, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 44, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 45, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 46, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__encounter_grain"}, "model.the_tuva_project.data_quality__observation_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code"}, "model.the_tuva_project.data_quality__summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SUMMARY_SK": {"type": "NUMBER", "index": 1, "name": "SUMMARY_SK", "comment": null}, "TABLE_CLAIM_TYPE_FIELD_SK": {"type": "NUMBER", "index": 2, "name": "TABLE_CLAIM_TYPE_FIELD_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 4, "name": "TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 5, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "RED": {"type": "NUMBER", "index": 7, "name": "RED", "comment": null}, "GREEN": {"type": "NUMBER", "index": 8, "name": "GREEN", "comment": null}, "VALID_NUM": {"type": "NUMBER", "index": 9, "name": "VALID_NUM", "comment": null}, "FILL_NUM": {"type": "NUMBER", "index": 10, "name": "FILL_NUM", "comment": null}, "DENOM": {"type": "NUMBER", "index": 11, "name": "DENOM", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__summary"}, "model.the_tuva_project.data_quality__practitioner_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_PRACTITIONER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_practitioner_id"}, "model.the_tuva_project.data_quality__institutional_billing_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_BILLING_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_billing_npi"}, "model.the_tuva_project.data_quality__eligibility_state": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_STATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_state"}, "seed.the_tuva_project.ed_classification__johnston_icd9": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_JOHNSTON_ICD9", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD9": {"type": "TEXT", "index": 1, "name": "ICD9", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 2, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 3, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 4, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 5, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 6, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 7, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 8, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 9, "name": "DRUG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7443, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 53248, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd9"}, "model.the_tuva_project.data_quality__medication_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_patient_id"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_DEMENTIA", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 5, "name": "DISPENSING_DATE", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 6, "name": "PAID_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia"}, "model.the_tuva_project.data_quality__raw_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "RAW_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SOURCE": {"type": "TEXT", "index": 1, "name": "SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 2, "name": "TABLE_NAME", "comment": null}, "ROW_COUNT": {"type": "NUMBER", "index": 3, "name": "ROW_COUNT", "comment": null}, "UNIQUE_CHECK": {"type": "NUMBER", "index": 4, "name": "UNIQUE_CHECK", "comment": null}, "UNIQUE_CHECK_DESC": {"type": "TEXT", "index": 5, "name": "UNIQUE_CHECK_DESC", "comment": null}, "TABLE_ORDER": {"type": "NUMBER", "index": 6, "name": "TABLE_ORDER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__raw_summary"}, "model.the_tuva_project.core__stg_claims_location": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_LOCATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_location"}, "model.the_tuva_project.outpatient_injections__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__anchor_events"}, "model.the_tuva_project.inpatient_hospice__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__prof_claims"}, "model.the_tuva_project.data_quality__lab_result_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code_type"}, "model.the_tuva_project.data_quality__procedure_modifier_5": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_5", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_5"}, "model.the_tuva_project.data_quality__medical_claim_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_patient_id"}, "model.the_tuva_project.data_quality__quality_measures_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_QUALITY_MEASURES_REFERENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__quality_measures_reference"}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_SKILLED_NURSING_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional"}, "model.the_tuva_project.outpatient_ptotst__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__encounter_grain"}, "model.the_tuva_project.ahrq_measures__pqi_rate": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_RATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 2, "name": "YEAR_NUMBER", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 3, "name": "PQI_NUMBER", "comment": null}, "DENOM_COUNT": {"type": "NUMBER", "index": 4, "name": "DENOM_COUNT", "comment": null}, "NUM_COUNT": {"type": "NUMBER", "index": 5, "name": "NUM_COUNT", "comment": null}, "RATE_PER_100_THOUSAND": {"type": "NUMBER", "index": 6, "name": "RATE_PER_100_THOUSAND", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_rate"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 2, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 3, "name": "EVIDENCE_VALUE", "comment": null}, "ADHERENCE": {"type": "NUMBER", "index": 4, "name": "ADHERENCE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 5, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"}, "model.the_tuva_project.data_quality__medical_claim_provider_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_PROVIDER_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_provider_npi"}, "model.the_tuva_project.quality_measures__int_nqf0059_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_numerator"}, "model.the_tuva_project.core__stg_claims_patient": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_PATIENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_patient"}, "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "LOOKBACK_PERIOD_AUGUST": {"type": "DATE", "index": 6, "name": "LOOKBACK_PERIOD_AUGUST", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041__performance_period"}, "model.the_tuva_project.data_quality__acute_inpatient": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ACUTE_INPATIENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient"}, "model.the_tuva_project.data_quality__inpatient_dq_stage": {"metadata": {"type": "VIEW", "schema": "DATA_QUALITY", "name": "DATA_QUALITY__INPATIENT_DQ_STAGE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__inpatient_dq_stage"}, "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DISABLED_INTERACTION_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 3, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 4, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 5, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 6, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors"}, "model.the_tuva_project.data_quality__lab_result_source_component": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_COMPONENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_component"}, "model.the_tuva_project.data_quality__lab_result_result": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_RESULT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_result"}, "model.the_tuva_project.quality_measures__int_cqm130_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_long"}, "model.the_tuva_project.core__procedure": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PROCEDURE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 12, "name": "MAPPING_METHOD", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 13, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 14, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 15, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 16, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 17, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 18, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__procedure"}, "model.the_tuva_project.data_quality__eligibility_city": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_CITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_city"}, "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ALWAYS_PLANNED_CCS_PROCEDURE_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category"}, "model.the_tuva_project.data_quality__procedure_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PRACTITIONER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_practitioner_id"}, "model.the_tuva_project.service_category__office_based_surgery_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_SURGERY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_surgery_professional"}, "seed.the_tuva_project.terminology__snomed_ct": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "SNOMED_CT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SNOMED_CT": {"type": "TEXT", "index": 1, "name": "SNOMED_CT", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "IS_ACTIVE": {"type": "TEXT", "index": 3, "name": "IS_ACTIVE", "comment": null}, "CREATED": {"type": "DATE", "index": 4, "name": "CREATED", "comment": null}, "LAST_UPDATED": {"type": "DATE", "index": 5, "name": "LAST_UPDATED", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 517628, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 17523712, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__snomed_ct"}, "model.the_tuva_project.lab__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__generate_encounter_id"}, "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor"}, "model.the_tuva_project.mart_review__readmissions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__READMISSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 9, "name": "LENGTH_OF_STAY", "comment": null}, "INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 10, "name": "INDEX_ADMISSION_FLAG", "comment": null}, "PLANNED_FLAG": {"type": "NUMBER", "index": 11, "name": "PLANNED_FLAG", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 12, "name": "SPECIALTY_COHORT", "comment": null}, "DIED_FLAG": {"type": "NUMBER", "index": 13, "name": "DIED_FLAG", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CCS", "comment": null}, "HAD_READMISSION_FLAG": {"type": "NUMBER", "index": 15, "name": "HAD_READMISSION_FLAG", "comment": null}, "DAYS_TO_READMIT": {"type": "NUMBER", "index": 16, "name": "DAYS_TO_READMIT", "comment": null}, "READMIT_30_FLAG": {"type": "NUMBER", "index": 17, "name": "READMIT_30_FLAG", "comment": null}, "UNPLANNED_READMIT_30_FLAG": {"type": "NUMBER", "index": 18, "name": "UNPLANNED_READMIT_30_FLAG", "comment": null}, "READMISSION_ENCOUNTER_ID": {"type": "TEXT", "index": 19, "name": "READMISSION_ENCOUNTER_ID", "comment": null}, "READMISSION_ADMIT_DATE": {"type": "DATE", "index": 20, "name": "READMISSION_ADMIT_DATE", "comment": null}, "READMISSION_DISCHARGE_DATE": {"type": "DATE", "index": 21, "name": "READMISSION_DISCHARGE_DATE", "comment": null}, "READMISSION_DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 22, "name": "READMISSION_DISCHARGE_DISPOSITION_CODE", "comment": null}, "READMISSION_FACILITY": {"type": "TEXT", "index": 23, "name": "READMISSION_FACILITY", "comment": null}, "READMISSION_MS_DRG": {"type": "TEXT", "index": 24, "name": "READMISSION_MS_DRG", "comment": null}, "READMISSION_LENGTH_OF_STAY": {"type": "NUMBER", "index": 25, "name": "READMISSION_LENGTH_OF_STAY", "comment": null}, "READMISSION_INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 26, "name": "READMISSION_INDEX_ADMISSION_FLAG", "comment": null}, "READMISSION_PLANNED_FLAG": {"type": "NUMBER", "index": 27, "name": "READMISSION_PLANNED_FLAG", "comment": null}, "READMISSION_SPECIALTY_COHORT": {"type": "TEXT", "index": 28, "name": "READMISSION_SPECIALTY_COHORT", "comment": null}, "READMISSION_DIED_FLAG": {"type": "NUMBER", "index": 29, "name": "READMISSION_DIED_FLAG", "comment": null}, "READMISSION_DIAGNOSIS_CCS": {"type": "TEXT", "index": 30, "name": "READMISSION_DIAGNOSIS_CCS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 31, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__readmissions"}, "model.the_tuva_project.urgent_care__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__encounter_grain"}, "model.the_tuva_project.lab__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__anchor_events"}, "model.the_tuva_project.acute_inpatient__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__prof_claims"}, "model.the_tuva_project.data_quality__patient_first_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_FIRST_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_first_name"}, "model.the_tuva_project.inpatient_substance_use__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__start_end_dates"}, "model.the_tuva_project.service_category__office_based_other_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_OTHER_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_other_professional"}, "model.the_tuva_project.data_quality__lab_result_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_patient_id"}, "model.the_tuva_project.service_category__outpatient_rehab_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_REHAB_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_professional"}, "seed.the_tuva_project.pqi__value_sets": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "_VALUE_SET_PQI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "VALUE_SET_NAME": {"type": "TEXT", "index": 2, "name": "VALUE_SET_NAME", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 3, "name": "PQI_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 6059, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 46592, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.pqi__value_sets"}, "model.the_tuva_project.data_quality__professional_place_of_service_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_PLACE_OF_SERVICE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_place_of_service_code"}, "model.the_tuva_project.data_quality__claim_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_id"}, "model.the_tuva_project.data_quality__encounter_facility_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_FACILITY_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_facility_id"}, "model.the_tuva_project.cms_hcc__int_hcc_mapping": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_HCC_MAPPING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CONDITION_CODE": {"type": "TEXT", "index": 2, "name": "CONDITION_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 4, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 5, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_mapping"}, "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor"}, "model.the_tuva_project.service_category__outpatient_rehab_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_REHAB_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_institutional"}, "seed.the_tuva_project.terminology__icd_10_pcs": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_10_PCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 78638, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1001472, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_10_pcs"}, "model.the_tuva_project.urgent_care__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__match_claims_to_anchor"}, "model.the_tuva_project.emergency_department__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__prof_claims"}, "model.the_tuva_project.outpatient_rehab__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__generate_encounter_id"}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_REFERENCE_RANGE_HIGH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_high"}, "model.the_tuva_project.data_quality__encounter_admit_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_code"}, "model.the_tuva_project.data_quality__procedure_modifier_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_1"}, "model.the_tuva_project.pharmacy__int_generic_cost": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_GENERIC_COST", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BRAND_RXCUI": {"type": "TEXT", "index": 1, "name": "BRAND_RXCUI", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY": {"type": "NUMBER", "index": 3, "name": "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY", "comment": null}, "GENERIC_AVERAGE_COST_PER_UNIT": {"type": "NUMBER", "index": 4, "name": "GENERIC_AVERAGE_COST_PER_UNIT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost"}, "model.the_tuva_project.service_category__inpatient_hospice_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_HOSPICE_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_professional"}, "seed.the_tuva_project.terminology__loinc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "LOINC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOINC": {"type": "TEXT", "index": 1, "name": "LOINC", "comment": null}, "SHORT_NAME": {"type": "TEXT", "index": 2, "name": "SHORT_NAME", "comment": null}, "LONG_COMMON_NAME": {"type": "TEXT", "index": 3, "name": "LONG_COMMON_NAME", "comment": null}, "COMPONENT": {"type": "TEXT", "index": 4, "name": "COMPONENT", "comment": null}, "PROPERTY": {"type": "TEXT", "index": 5, "name": "PROPERTY", "comment": null}, "TIME_ASPECT": {"type": "TEXT", "index": 6, "name": "TIME_ASPECT", "comment": null}, "SYSTEM": {"type": "TEXT", "index": 7, "name": "SYSTEM", "comment": null}, "SCALE_TYPE": {"type": "TEXT", "index": 8, "name": "SCALE_TYPE", "comment": null}, "METHOD_TYPE": {"type": "TEXT", "index": 9, "name": "METHOD_TYPE", "comment": null}, "CLASS_CODE": {"type": "TEXT", "index": 10, "name": "CLASS_CODE", "comment": null}, "CLASS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CLASS_DESCRIPTION", "comment": null}, "CLASS_TYPE_CODE": {"type": "TEXT", "index": 12, "name": "CLASS_TYPE_CODE", "comment": null}, "CLASS_TYPE_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "CLASS_TYPE_DESCRIPTION", "comment": null}, "EXTERNAL_COPYRIGHT_NOTICE": {"type": "TEXT", "index": 14, "name": "EXTERNAL_COPYRIGHT_NOTICE", "comment": null}, "STATUS": {"type": "TEXT", "index": 15, "name": "STATUS", "comment": null}, "VERSION_FIRST_RELEASED": {"type": "TEXT", "index": 16, "name": "VERSION_FIRST_RELEASED", "comment": null}, "VERSION_LAST_CHANGED": {"type": "TEXT", "index": 17, "name": "VERSION_LAST_CHANGED", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 101632, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4118528, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__loinc"}, "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_DATE_CHECKS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_date_checks"}, "model.the_tuva_project.data_quality__condition_recorded_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_RECORDED_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_recorded_date"}, "model.the_tuva_project.data_quality__cms_hcc_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CMS_HCC_REFERENCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__cms_hcc_reference"}, "model.the_tuva_project.data_quality__institutional_admit_type_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_ADMIT_TYPE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_type_code"}, "model.the_tuva_project.data_quality__professional_diagnosis_code_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_DIAGNOSIS_CODE_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_2"}, "model.the_tuva_project.data_quality__condition_condition_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CONDITION_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_condition_type"}, "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_HCC_HIERARCHY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 2, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 3, "name": "PAYMENT_YEAR", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 4, "name": "HCC_CODE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_hierarchy"}, "model.the_tuva_project.data_quality__procedure_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code"}, "model.the_tuva_project.data_quality__condition_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_encounter_id"}, "model.the_tuva_project.data_quality__medical_claim_date_checks": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_DATE_CHECKS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_date_checks"}, "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain"}, "model.the_tuva_project.outpatient_rehab__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__encounter_grain"}, "model.the_tuva_project.data_quality__practitioner_practice_affiliation": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_PRACTICE_AFFILIATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_practice_affiliation"}, "model.the_tuva_project.data_quality__medication_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_PRACTITIONER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_practitioner_id"}, "model.the_tuva_project.dme__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DME__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__anchor_events"}, "model.the_tuva_project.service_category__outpatient_radiology_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_RADIOLOGY_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_institutional"}, "model.the_tuva_project.encounters__stg_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 4, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_professional"}, "model.the_tuva_project.data_quality__pharmacy_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_id"}, "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 1, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_1YP": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN_1YP", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_2YP": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN_2YP", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_4YP": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_BEGIN_4YP", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_9YP": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_BEGIN_9YP", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034__performance_period"}, "seed.the_tuva_project.hcc_suspecting__clinical_concepts": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_VALUE_SET_CLINICAL_CONCEPTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_NAME": {"type": "TEXT", "index": 1, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 2, "name": "CONCEPT_OID", "comment": null}, "CODE": {"type": "TEXT", "index": 3, "name": "CODE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 4, "name": "CODE_SYSTEM", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 25472, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 188928, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.hcc_suspecting__clinical_concepts"}, "model.the_tuva_project.data_quality__institutional_procedure_code_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_CODE_3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_3"}, "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_PRESCRIPTION_DETAILS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details"}, "model.the_tuva_project.service_category__outpatient_surgery_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SURGERY_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_institutional"}, "model.the_tuva_project.data_quality__patient_death_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_DEATH_FLAG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_death_flag"}, "model.the_tuva_project.readmissions__planned_encounter": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_PLANNED_ENCOUNTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__planned_encounter"}, "model.the_tuva_project.data_quality__patient_zip_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_ZIP_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_zip_code"}, "model.the_tuva_project.data_quality__claim_paid_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PAID_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_paid_amount"}, "model.the_tuva_project.quality_measures__int_nqf0053_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 2, "name": "RECORDED_DATE", "comment": null}, "AGE": {"type": "NUMBER", "index": 3, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_denominator"}, "seed.the_tuva_project.terminology__ms_drg_weights_los": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MS_DRG_WEIGHTS_LOS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MS_DRG": {"type": "TEXT", "index": 1, "name": "MS_DRG", "comment": null}, "FY_2024_FINAL_POST_ACUTE_DRG": {"type": "TEXT", "index": 2, "name": "FY_2024_FINAL_POST_ACUTE_DRG", "comment": null}, "FY_2024_FINAL_SPECIAL_PAY_DRG": {"type": "TEXT", "index": 3, "name": "FY_2024_FINAL_SPECIAL_PAY_DRG", "comment": null}, "MDC": {"type": "TEXT", "index": 4, "name": "MDC", "comment": null}, "TYPE": {"type": "TEXT", "index": 5, "name": "TYPE", "comment": null}, "MS_DRG_TITLE": {"type": "TEXT", "index": 6, "name": "MS_DRG_TITLE", "comment": null}, "DRG_WEIGHT_RAW": {"type": "NUMBER", "index": 7, "name": "DRG_WEIGHT_RAW", "comment": null}, "DRG_WEIGHT": {"type": "NUMBER", "index": 8, "name": "DRG_WEIGHT", "comment": null}, "GEOMETRIC_MEAN_LOS": {"type": "NUMBER", "index": 9, "name": "GEOMETRIC_MEAN_LOS", "comment": null}, "ARITHMETIC_MEAN_LOS": {"type": "NUMBER", "index": 10, "name": "ARITHMETIC_MEAN_LOS", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 766, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 24064, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ms_drg_weights_los"}, "model.the_tuva_project.data_quality__analytics_populated": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ANALYTICS_POPULATED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"TABLE_NAME": {"type": "TEXT", "index": 1, "name": "TABLE_NAME", "comment": null}, "RECORD_COUNT": {"type": "NUMBER", "index": 2, "name": "RECORD_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 8, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__analytics_populated"}, "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_12_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions"}, "model.the_tuva_project.ccsr__long_procedure_category": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "LONG_PROCEDURE_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CODE_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 6, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 7, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CLINICAL_DOMAIN": {"type": "TEXT", "index": 9, "name": "CLINICAL_DOMAIN", "comment": null}, "PRCCSR_VERSION": {"type": "TEXT", "index": 10, "name": "PRCCSR_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__long_procedure_category"}, "model.the_tuva_project.data_quality__professional_claim_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_CLAIM_START_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_claim_start_date"}, "model.the_tuva_project.data_quality__medication_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_source_code"}, "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PRESENT_ON_ADMIT_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_COLUMN": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_COLUMN", "comment": null}, "NORMALIZED_PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "PRESENT_ON_ADMIT_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_normalize"}, "seed.the_tuva_project.terminology__provider": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PROVIDER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NPI": {"type": "TEXT", "index": 1, "name": "NPI", "comment": null}, "ENTITY_TYPE_CODE": {"type": "TEXT", "index": 2, "name": "ENTITY_TYPE_CODE", "comment": null}, "ENTITY_TYPE_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "ENTITY_TYPE_DESCRIPTION", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 4, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "PROVIDER_FIRST_NAME": {"type": "TEXT", "index": 6, "name": "PROVIDER_FIRST_NAME", "comment": null}, "PROVIDER_LAST_NAME": {"type": "TEXT", "index": 7, "name": "PROVIDER_LAST_NAME", "comment": null}, "PROVIDER_ORGANIZATION_NAME": {"type": "TEXT", "index": 8, "name": "PROVIDER_ORGANIZATION_NAME", "comment": null}, "PARENT_ORGANIZATION_NAME": {"type": "TEXT", "index": 9, "name": "PARENT_ORGANIZATION_NAME", "comment": null}, "PRACTICE_ADDRESS_LINE_1": {"type": "TEXT", "index": 10, "name": "PRACTICE_ADDRESS_LINE_1", "comment": null}, "PRACTICE_ADDRESS_LINE_2": {"type": "TEXT", "index": 11, "name": "PRACTICE_ADDRESS_LINE_2", "comment": null}, "PRACTICE_CITY": {"type": "TEXT", "index": 12, "name": "PRACTICE_CITY", "comment": null}, "PRACTICE_STATE": {"type": "TEXT", "index": 13, "name": "PRACTICE_STATE", "comment": null}, "PRACTICE_ZIP_CODE": {"type": "TEXT", "index": 14, "name": "PRACTICE_ZIP_CODE", "comment": null}, "LAST_UPDATED": {"type": "DATE", "index": 15, "name": "LAST_UPDATED", "comment": null}, "DEACTIVATION_DATE": {"type": "DATE", "index": 16, "name": "DEACTIVATION_DATE", "comment": null}, "DEACTIVATION_FLAG": {"type": "TEXT", "index": 17, "name": "DEACTIVATION_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 8576349, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 264443904, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__provider"}, "model.the_tuva_project.data_quality__medication_quantity": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_QUANTITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_quantity"}, "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101__performance_period"}, "model.the_tuva_project.data_quality__procedure_modifier_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_3"}, "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PRESCRIBING_PROVIDER_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi"}, "model.the_tuva_project.data_quality__primary_keys_location_location_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_LOCATION_LOCATION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_location_location_id"}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions"}, "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_EXCLUDE_PROCEDURES_MEDICATIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications"}, "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_CLAIM_LINE_FIELDS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 6, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_claim_line_fields"}, "model.the_tuva_project.acute_inpatient__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__generate_encounter_id"}, "model.the_tuva_project.data_quality__procedure_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_NORMALIZED_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code"}, "model.the_tuva_project.core__stg_clinical_location": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_LOCATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_location"}, "model.the_tuva_project.data_quality__practitioner_sub_specialty": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_SUB_SPECIALTY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_sub_specialty"}, "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_VALUE_SET_TUVA_CHRONIC_CONDITIONS_HIERARCHY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_FAMILY": {"type": "TEXT", "index": 1, "name": "CONDITION_FAMILY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 2, "name": "CONDITION", "comment": null}, "ICD_10_CM_CODE": {"type": "TEXT", "index": 3, "name": "ICD_10_CM_CODE", "comment": null}, "ICD_10_CM_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "ICD_10_CM_DESCRIPTION", "comment": null}, "CONDITION_COLUMN_NAME": {"type": "TEXT", "index": 5, "name": "CONDITION_COLUMN_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1583, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 35840, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy"}, "model.the_tuva_project.inpatient_rehab__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__start_end_dates"}, "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_INSTITUTIONAL_MED_SURG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg"}, "model.the_tuva_project.core__stg_claims_eligibility": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_ELIGIBILITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ELIGIBILITY_ID": {"type": "TEXT", "index": 1, "name": "ELIGIBILITY_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 3, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 4, "name": "SUBSCRIBER_ID", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 5, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 6, "name": "DEATH_DATE", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 7, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 8, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 9, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 10, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 12, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 13, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 14, "name": "MEDICARE_STATUS_CODE", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 15, "name": "SUBSCRIBER_RELATION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 16, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_eligibility"}, "model.the_tuva_project.hcc_suspecting__int_all_conditions": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_ALL_CONDITIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 2, "name": "RECORDED_DATE", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 3, "name": "CONDITION_TYPE", "comment": null}, "ICD_10_CM_CODE": {"type": "TEXT", "index": 4, "name": "ICD_10_CM_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 5, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 6, "name": "HCC_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_conditions"}, "model.the_tuva_project.mart_review__ed_classification": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__ED_CLASSIFICATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ED_CLASSIFICATION_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ED_CLASSIFICATION_DESCRIPTION", "comment": null}, "AVOIDABLE_CATEGORY": {"type": "TEXT", "index": 3, "name": "AVOIDABLE_CATEGORY", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 4, "name": "PAID_AMOUNT", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 5, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 6, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PRIMARY_DIAGNOSIS_AND_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_AND_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 8, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 9, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY_AND_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CCSR_PARENT_CATEGORY_AND_DESCRIPTION", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 12, "name": "BODY_SYSTEM", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 14, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 15, "name": "CHARGE_AMOUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 16, "name": "DATA_SOURCE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 17, "name": "LENGTH_OF_STAY", "comment": null}, "DISCHARGE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "DISCHARGE_CODE_AND_DESCRIPTION", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 19, "name": "PATIENT_SOURCE_KEY", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 20, "name": "FACILITY_NAME", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 21, "name": "ENCOUNTER_START_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 22, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__ed_classification"}, "seed.the_tuva_project.terminology__gender": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "GENDER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"GENDER": {"type": "TEXT", "index": 1, "name": "GENDER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__gender"}, "model.the_tuva_project.data_quality__claim_deductible_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DEDUCTIBLE_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_deductible_amount"}, "model.the_tuva_project.ahrq_measures__int_pqi_05_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_05_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_num"}, "seed.the_tuva_project.pqi__measures": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "_VALUE_SET_PQI_MEASURES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PQI_NUMBER": {"type": "TEXT", "index": 1, "name": "PQI_NUMBER", "comment": null}, "PQI_NAME": {"type": "TEXT", "index": 2, "name": "PQI_NAME", "comment": null}, "PQI_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "PQI_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 10, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.pqi__measures"}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PRIMARY_DIAGNOSIS_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type"}, "model.the_tuva_project.data_quality__lab_result_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_description"}, "model.the_tuva_project.service_category__dialysis_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_DIALYSIS_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__dialysis_institutional"}, "model.the_tuva_project.data_quality__patient_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_data_source"}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_SKILLED_NURSING_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional"}, "model.the_tuva_project.quality_measures__int_nqf0059_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_long"}, "model.the_tuva_project.data_quality__claim_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_patient_id"}, "model.the_tuva_project.data_quality__readmissions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_READMISSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__readmissions"}, "model.the_tuva_project.ccsr__procedure_category_map": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "PROCEDURE_CATEGORY_MAP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "CODE_DESCRIPTION", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CLINICAL_DOMAIN": {"type": "TEXT", "index": 6, "name": "CLINICAL_DOMAIN", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 81597, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1553408, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__procedure_category_map"}, "model.the_tuva_project.mart_review__pharmacy": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PHARMACY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 5, "name": "PATIENT_SOURCE_KEY", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 6, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "NDC_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 9, "name": "ALLOWED_AMOUNT", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "PRESCRIBING_SPECIALTY": {"type": "TEXT", "index": 12, "name": "PRESCRIBING_SPECIALTY", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 13, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 14, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 15, "name": "PAID_DATE", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 16, "name": "DISPENSING_DATE", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 17, "name": "DAYS_SUPPLY", "comment": null}, "RXCUI": {"type": "TEXT", "index": 18, "name": "RXCUI", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "RXNORM_DESCRIPTION", "comment": null}, "BRAND_NAME": {"type": "TEXT", "index": 20, "name": "BRAND_NAME", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 21, "name": "BRAND_VS_GENERIC", "comment": null}, "INGREDIENT_NAME": {"type": "TEXT", "index": 22, "name": "INGREDIENT_NAME", "comment": null}, "ATC_1_NAME": {"type": "TEXT", "index": 23, "name": "ATC_1_NAME", "comment": null}, "ATC_2_NAME": {"type": "TEXT", "index": 24, "name": "ATC_2_NAME", "comment": null}, "ATC_3_NAME": {"type": "TEXT", "index": 25, "name": "ATC_3_NAME", "comment": null}, "ATC_4_NAME": {"type": "TEXT", "index": 26, "name": "ATC_4_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__pharmacy"}, "model.the_tuva_project.service_category__dme_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_DME_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__dme_professional"}, "model.the_tuva_project.inpatient_hospice__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__START_END_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__start_end_dates"}, "model.the_tuva_project.medical_claim_expanded": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_EXPANDED", "name": "MEDICAL_CLAIM_EXPANDED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 15, "name": "ADMIT_TYPE_CODE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 16, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 17, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 18, "name": "BILL_TYPE_CODE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 20, "name": "APR_DRG_CODE", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 21, "name": "REVENUE_CENTER_CODE", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 22, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 23, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 27, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 28, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 29, "name": "RENDERING_NPI", "comment": null}, "RENDERING_TIN": {"type": "NUMBER", "index": 30, "name": "RENDERING_TIN", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 31, "name": "BILLING_NPI", "comment": null}, "BILLING_TIN": {"type": "NUMBER", "index": 32, "name": "BILLING_TIN", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 33, "name": "FACILITY_NPI", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 34, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 35, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 36, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 37, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 38, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 39, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 40, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 41, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 42, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 43, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 44, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 45, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 46, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 47, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 48, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 49, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 50, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 93, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 94, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 95, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 96, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 97, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 98, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 99, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 100, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 101, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 119, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 120, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 121, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 122, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 123, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 124, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 125, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 126, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 127, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_25", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 144, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 145, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 146, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 147, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.medical_claim_expanded"}, "model.the_tuva_project.data_quality__eligibility_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PAYER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer"}, "model.the_tuva_project.inpatient_rehab__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__encounter_grain"}, "model.the_tuva_project.data_quality__condition_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_patient_id"}, "model.the_tuva_project.core__medication": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "MEDICATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICATION_ID": {"type": "TEXT", "index": 1, "name": "MEDICATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 4, "name": "DISPENSING_DATE", "comment": null}, "PRESCRIBING_DATE": {"type": "DATE", "index": 5, "name": "PRESCRIBING_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "NDC_MAPPING_METHOD": {"type": "TEXT", "index": 11, "name": "NDC_MAPPING_METHOD", "comment": null}, "RXNORM_CODE": {"type": "TEXT", "index": 12, "name": "RXNORM_CODE", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "RXNORM_DESCRIPTION", "comment": null}, "RXNORM_MAPPING_METHOD": {"type": "TEXT", "index": 14, "name": "RXNORM_MAPPING_METHOD", "comment": null}, "ATC_CODE": {"type": "TEXT", "index": 15, "name": "ATC_CODE", "comment": null}, "ATC_DESCRIPTION": {"type": "TEXT", "index": 16, "name": "ATC_DESCRIPTION", "comment": null}, "ATC_MAPPING_METHOD": {"type": "TEXT", "index": 17, "name": "ATC_MAPPING_METHOD", "comment": null}, "ROUTE": {"type": "TEXT", "index": 18, "name": "ROUTE", "comment": null}, "STRENGTH": {"type": "TEXT", "index": 19, "name": "STRENGTH", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 20, "name": "QUANTITY", "comment": null}, "QUANTITY_UNIT": {"type": "TEXT", "index": 21, "name": "QUANTITY_UNIT", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 22, "name": "DAYS_SUPPLY", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 23, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 24, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 25, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__medication"}, "model.the_tuva_project.quality_measures__int_cbe0055_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_long"}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DIAGNOSIS_CODE_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_1"}, "model.the_tuva_project.data_quality__professional_rendering_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_RENDERING_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_rendering_npi"}, "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_STG_PQI_INPATIENT_ENCOUNTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 3, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "MS_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 5, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 7, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 8, "name": "LENGTH_OF_STAY", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 10, "name": "PATIENT_ID", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 11, "name": "FACILITY_ID", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 12, "name": "PAID_AMOUNT", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 13, "name": "YEAR_NUMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"}, "model.the_tuva_project.data_quality__encounter_ms_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_MS_DRG_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_code"}, "model.the_tuva_project.quality_measures__int_cqm130_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PROCEDURE_ENCOUNTER_DATE": {"type": "DATE", "index": 3, "name": "PROCEDURE_ENCOUNTER_DATE", "comment": null}, "CLAIMS_ENCOUNTER_DATE": {"type": "DATE", "index": 4, "name": "CLAIMS_ENCOUNTER_DATE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 7, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 8, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 9, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 10, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_denominator"}, "seed.the_tuva_project.cms_hcc__disease_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISEASE_INTERACTION_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 4, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 5, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 6, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "SHORT_NAME": {"type": "TEXT", "index": 8, "name": "SHORT_NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 9, "name": "DESCRIPTION", "comment": null}, "HCC_CODE_1": {"type": "TEXT", "index": 10, "name": "HCC_CODE_1", "comment": null}, "HCC_CODE_2": {"type": "TEXT", "index": 11, "name": "HCC_CODE_2", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 12, "name": "COEFFICIENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 961, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 16384, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disease_interaction_factors"}, "model.the_tuva_project.core__condition": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "CONDITION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 16, "name": "MAPPING_METHOD", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 17, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__condition"}, "model.the_tuva_project.dme__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "DME__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 19, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__encounter_grain"}, "model.the_tuva_project.data_quality__patient_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_patient_id"}, "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "FLAG_CLAIMS_WITH_ENROLLMENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 4, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 5, "name": "PLAN", "comment": null}, "INFERRED_CLAIM_START_YEAR_MONTH": {"type": "TEXT", "index": 6, "name": "INFERRED_CLAIM_START_YEAR_MONTH", "comment": null}, "INFERRED_CLAIM_END_YEAR_MONTH": {"type": "TEXT", "index": 7, "name": "INFERRED_CLAIM_END_YEAR_MONTH", "comment": null}, "INFERRED_CLAIM_START_COLUMN_USED": {"type": "TEXT", "index": 8, "name": "INFERRED_CLAIM_START_COLUMN_USED", "comment": null}, "INFERRED_CLAIM_END_COLUMN_USED": {"type": "TEXT", "index": 9, "name": "INFERRED_CLAIM_END_COLUMN_USED", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment"}, "model.the_tuva_project.ahrq_measures__int_pqi_01_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_01_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_num"}, "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__match_claims_to_anchor"}, "model.the_tuva_project.quality_measures__int_nqf0097_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_long"}, "model.the_tuva_project.data_quality__pharmacy_deductible_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DEDUCTIBLE_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_deductible_amount"}, "model.the_tuva_project.ahrq_measures__int_pqi_07_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_07_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_num"}, "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_OBSERVATION_OBSERVATION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_observation_observation_id"}, "model.the_tuva_project.data_quality__claim_member_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_MEMBER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_member_id"}, "model.the_tuva_project.office_visits__int_office_visits": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 7, "name": "SERVICE_CATEGORY_3", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 8, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits"}, "model.the_tuva_project.data_quality__claim_allowed_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_ALLOWED_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_allowed_amount"}, "model.the_tuva_project.service_category__outpatient_psychiatric_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_PSYCHIATRIC_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_professional"}, "model.the_tuva_project.data_quality__professional_diagnosis_code_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_DIAGNOSIS_CODE_1", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_1"}, "model.the_tuva_project.data_quality__claim_claim_line_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_LINE_START_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_start_date"}, "model.the_tuva_project.data_quality__data_quality_test_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_TEST_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 80, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_test_summary"}, "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_ENCOUNTER_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_FRAILTY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty"}, "model.the_tuva_project.data_quality__lab_result_result_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_RESULT_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_result_date"}, "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420__performance_period"}, "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_05_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_denom"}, "model.the_tuva_project.data_quality__encounter_ms_drg_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_MS_DRG_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_description"}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_DISCHARGE_DISPOSITION_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_code"}, "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_16_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"}, "model.the_tuva_project.asc__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__match_claims_to_anchor"}, "model.the_tuva_project.normalized_input__int_procedure_date_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_DATE_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 3, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 4, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 6, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 7, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 8, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 9, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 10, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 11, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 12, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 13, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 14, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 15, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 16, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 17, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 18, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 19, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 20, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 21, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 22, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 23, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 24, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 25, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 26, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 27, "name": "PROCEDURE_DATE_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_final"}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "TUVA_CHRONIC_CONDITIONS_WIDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "OBESITY": {"type": "NUMBER", "index": 2, "name": "OBESITY", "comment": null}, "OSTEOARTHRITIS": {"type": "NUMBER", "index": 3, "name": "OSTEOARTHRITIS", "comment": null}, "COPD": {"type": "NUMBER", "index": 4, "name": "COPD", "comment": null}, "ANXIETY_DISORDERS": {"type": "NUMBER", "index": 5, "name": "ANXIETY_DISORDERS", "comment": null}, "CKD": {"type": "NUMBER", "index": 6, "name": "CKD", "comment": null}, "T2D": {"type": "NUMBER", "index": 7, "name": "T2D", "comment": null}, "CLL": {"type": "NUMBER", "index": 8, "name": "CLL", "comment": null}, "DYSPLIPIDEMIAS": {"type": "NUMBER", "index": 9, "name": "DYSPLIPIDEMIAS", "comment": null}, "HYPERTENSION": {"type": "NUMBER", "index": 10, "name": "HYPERTENSION", "comment": null}, "ATHEROSCLEROSIS": {"type": "NUMBER", "index": 11, "name": "ATHEROSCLEROSIS", "comment": null}, "DEMENTIA": {"type": "NUMBER", "index": 12, "name": "DEMENTIA", "comment": null}, "RHEUMATOID_ARTHRITIS": {"type": "NUMBER", "index": 13, "name": "RHEUMATOID_ARTHRITIS", "comment": null}, "CELIAC": {"type": "NUMBER", "index": 14, "name": "CELIAC", "comment": null}, "HIP_FRACTURE": {"type": "NUMBER", "index": 15, "name": "HIP_FRACTURE", "comment": null}, "IMMUNODEFICIENCIES_AND_WHITE_BLOOD_CELL_DISORDERS": {"type": "NUMBER", "index": 16, "name": "IMMUNODEFICIENCIES_AND_WHITE_BLOOD_CELL_DISORDERS", "comment": null}, "ASTHMA": {"type": "NUMBER", "index": 17, "name": "ASTHMA", "comment": null}, "T1D": {"type": "NUMBER", "index": 18, "name": "T1D", "comment": null}, "ULCERATIVE_COLITIS": {"type": "NUMBER", "index": 19, "name": "ULCERATIVE_COLITIS", "comment": null}, "CHROHNS": {"type": "NUMBER", "index": 20, "name": "CHROHNS", "comment": null}, "HOLICOBACTER": {"type": "NUMBER", "index": 21, "name": "HOLICOBACTER", "comment": null}, "BIPOLAR": {"type": "NUMBER", "index": 22, "name": "BIPOLAR", "comment": null}, "HEART_FAILURE": {"type": "NUMBER", "index": 23, "name": "HEART_FAILURE", "comment": null}, "TABACCO": {"type": "NUMBER", "index": 24, "name": "TABACCO", "comment": null}, "LYME": {"type": "NUMBER", "index": 25, "name": "LYME", "comment": null}, "BREAST_CANCER": {"type": "NUMBER", "index": 26, "name": "BREAST_CANCER", "comment": null}, "OSTEOPOROSIS": {"type": "NUMBER", "index": 27, "name": "OSTEOPOROSIS", "comment": null}, "PULMONARY_EMBOLISM": {"type": "NUMBER", "index": 28, "name": "PULMONARY_EMBOLISM", "comment": null}, "SCHIZOPHRENIA": {"type": "NUMBER", "index": 29, "name": "SCHIZOPHRENIA", "comment": null}, "ATRIAL_FIBRILLATION": {"type": "NUMBER", "index": 30, "name": "ATRIAL_FIBRILLATION", "comment": null}, "COLORECTAL_CANCER": {"type": "NUMBER", "index": 31, "name": "COLORECTAL_CANCER", "comment": null}, "DEPRESSION": {"type": "NUMBER", "index": 32, "name": "DEPRESSION", "comment": null}, "DEEP_VEIN_THROMBOSIS": {"type": "NUMBER", "index": 33, "name": "DEEP_VEIN_THROMBOSIS", "comment": null}, "ALZHEIMER": {"type": "NUMBER", "index": 34, "name": "ALZHEIMER", "comment": null}, "STROKE": {"type": "NUMBER", "index": 35, "name": "STROKE", "comment": null}, "MYOCARDIAL_INFRACTION": {"type": "NUMBER", "index": 36, "name": "MYOCARDIAL_INFRACTION", "comment": null}, "OPIOD_USE_DISORDER": {"type": "NUMBER", "index": 37, "name": "OPIOD_USE_DISORDER", "comment": null}, "LUNG_CANCER": {"type": "NUMBER", "index": 38, "name": "LUNG_CANCER", "comment": null}, "HERPES": {"type": "NUMBER", "index": 39, "name": "HERPES", "comment": null}, "RICKETTSIOSIS": {"type": "NUMBER", "index": 40, "name": "RICKETTSIOSIS", "comment": null}, "MS": {"type": "NUMBER", "index": 41, "name": "MS", "comment": null}, "ALCHOHOL": {"type": "NUMBER", "index": 42, "name": "ALCHOHOL", "comment": null}, "ADHD": {"type": "NUMBER", "index": 43, "name": "ADHD", "comment": null}, "HIV": {"type": "NUMBER", "index": 44, "name": "HIV", "comment": null}, "PTSD": {"type": "NUMBER", "index": 45, "name": "PTSD", "comment": null}, "LUPUS": {"type": "NUMBER", "index": 46, "name": "LUPUS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 47, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"}, "model.the_tuva_project.data_quality__medication_rxnorm_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_RXNORM_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_description"}, "model.the_tuva_project.readmissions__exclusion": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_EXCLUSION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__exclusion"}, "model.the_tuva_project.quality_measures__int_cqm48_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_exclusions"}, "model.the_tuva_project.data_quality__pharmacy_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PAYER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_payer"}, "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_08_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions"}, "model.the_tuva_project.data_quality__condition_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_data_source"}, "model.the_tuva_project.data_quality__pharmacy_allowed_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_ALLOWED_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_allowed_amount"}, "model.the_tuva_project.quality_measures__int_cqm48_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_long"}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_REFERENCE_RANGE_LOW", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_low"}, "seed.the_tuva_project.quality_measures__measures": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_VALUE_SET_MEASURES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 3, "name": "DESCRIPTION", "comment": null}, "VERSION": {"type": "TEXT", "index": 4, "name": "VERSION", "comment": null}, "STEWARD": {"type": "TEXT", "index": 5, "name": "STEWARD", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 17, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4608, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.quality_measures__measures"}, "model.the_tuva_project.data_quality__patient_death_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_DEATH_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_death_date"}, "model.the_tuva_project.data_quality__location_city": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_CITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_city"}, "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_2_ALLOWED_PIVOT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 6, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 7, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 8, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 9, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 10, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 11, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 12, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 13, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 14, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 15, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 16, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 17, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 18, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PTOTST_ALLOWED": {"type": "NUMBER", "index": 19, "name": "OFFICE_BASED_PTOTST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 20, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 21, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 22, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 23, "name": "OTHER_ALLOWED", "comment": null}, "OUTPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 24, "name": "OUTPATIENT_HOSPICE_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 25, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PTOTST_ALLOWED": {"type": "NUMBER", "index": 26, "name": "OUTPATIENT_PTOTST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 27, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 28, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 29, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 31, "name": "PHARMACY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 32, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 33, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 34, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot"}, "model.the_tuva_project.inpatient_snf__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__encounter_grain"}, "model.the_tuva_project.mart_review__members_with_claims": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__MEMBERS_WITH_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "MEMBERS_WITH_MEDICAL_CLAIMS": {"type": "NUMBER", "index": 3, "name": "MEMBERS_WITH_MEDICAL_CLAIMS", "comment": null}, "MEMBERS_WITH_PHARMACY_CLAIMS": {"type": "NUMBER", "index": 4, "name": "MEMBERS_WITH_PHARMACY_CLAIMS", "comment": null}, "MEMBERS_WITH_CLAIMS": {"type": "NUMBER", "index": 5, "name": "MEMBERS_WITH_CLAIMS", "comment": null}, "TOTAL_MEMBER_MONTHS": {"type": "NUMBER", "index": 6, "name": "TOTAL_MEMBER_MONTHS", "comment": null}, "PERCENT_MEMBERS_WITH_CLAIMS": {"type": "NUMBER", "index": 7, "name": "PERCENT_MEMBERS_WITH_CLAIMS", "comment": null}, "PERCENT_MEMBERS_WITH_MEDICAL_CLAIMS": {"type": "NUMBER", "index": 8, "name": "PERCENT_MEMBERS_WITH_MEDICAL_CLAIMS", "comment": null}, "PERCENT_MEMBERS_WITH_PHARMACY_CLAIMS": {"type": "NUMBER", "index": 9, "name": "PERCENT_MEMBERS_WITH_PHARMACY_CLAIMS", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__members_with_claims"}, "model.the_tuva_project.quality_measures__int_cqm48__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48__performance_period"}, "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_2_PAID_PIVOT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 6, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 7, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 8, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 9, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 10, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 11, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 12, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 13, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 14, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 15, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 16, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 17, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 18, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PTOTST_PAID": {"type": "NUMBER", "index": 19, "name": "OFFICE_BASED_PTOTST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 20, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 21, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 22, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 23, "name": "OTHER_PAID", "comment": null}, "OUTPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 24, "name": "OUTPATIENT_HOSPICE_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 25, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PTOTST_PAID": {"type": "NUMBER", "index": 26, "name": "OUTPATIENT_PTOTST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 27, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 28, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 29, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 31, "name": "PHARMACY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 32, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 33, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 34, "name": "URGENT_CARE_PAID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot"}, "seed.the_tuva_project.terminology__race": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "RACE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 8, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__race"}, "model.the_tuva_project.quality_measures__int_cqm130__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130__performance_period"}, "model.the_tuva_project.data_quality__medication_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_encounter_id"}, "model.the_tuva_project.quality_measures__int_nqf0053_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_numerator"}, "model.the_tuva_project.data_quality__institutional_claim_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_CLAIM_START_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_start_date"}, "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ELIGIBILITY_DATES_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PATIENT_ID_KEY": {"type": "TEXT", "index": 2, "name": "PATIENT_ID_KEY", "comment": null}, "NORMALIZED_BIRTH_DATE": {"type": "DATE", "index": 3, "name": "NORMALIZED_BIRTH_DATE", "comment": null}, "NORMALIZED_DEATH_DATE": {"type": "DATE", "index": 4, "name": "NORMALIZED_DEATH_DATE", "comment": null}, "NORMALIZED_ENROLLMENT_START_DATE": {"type": "DATE", "index": 5, "name": "NORMALIZED_ENROLLMENT_START_DATE", "comment": null}, "NORMALIZED_ENROLLMENT_END_DATE": {"type": "DATE", "index": 6, "name": "NORMALIZED_ENROLLMENT_END_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize"}, "model.the_tuva_project.encounters__stg_outpatient_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_OUTPATIENT_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_outpatient_institutional"}, "model.the_tuva_project.data_quality__procedure_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_patient_id"}, "model.the_tuva_project.data_quality__observation_source_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_REFERENCE_RANGE_LOW", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_low"}, "model.the_tuva_project.service_category__lab_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_LAB_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__lab_institutional"}, "model.the_tuva_project.data_quality__institutional_revenue_center_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_REVENUE_CENTER_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_revenue_center_code"}, "model.the_tuva_project.mart_review__stg_medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__STG_MEDICAL_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICAL_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "MEDICAL_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 8, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 9, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 10, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 16, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 17, "name": "DISCHARGE_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 19, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 20, "name": "SERVICE_CATEGORY_3", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 21, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 23, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 25, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 27, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 31, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 33, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 37, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 38, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 39, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 40, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 41, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 42, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 43, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 44, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 45, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 46, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 47, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 48, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 49, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 50, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 51, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 52, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 53, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 54, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 55, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 56, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 57, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 58, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 59, "name": "TOTAL_COST_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 60, "name": "IN_NETWORK_FLAG", "comment": null}, "ENROLLMENT_FLAG": {"type": "NUMBER", "index": 61, "name": "ENROLLMENT_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 62, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 63, "name": "TUVA_LAST_RUN", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 64, "name": "YEAR_MONTH", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__stg_medical_claim"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR_CRITERIA3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3"}, "model.the_tuva_project.hcc_suspecting__int_all_medications": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_ALL_MEDICATIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 2, "name": "DISPENSING_DATE", "comment": null}, "DRUG_CODE": {"type": "TEXT", "index": 3, "name": "DRUG_CODE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 4, "name": "CODE_SYSTEM", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_medications"}, "model.the_tuva_project.dialysis__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__match_claims_to_anchor"}, "seed.the_tuva_project.terminology__medicare_orec": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MEDICARE_OREC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 1, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ORIGINAL_REASON_ENTITLEMENT_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__medicare_orec"}, "model.the_tuva_project.quality_measures__int_nqf0097_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 8, "name": "DISCHARGE_DATE", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_denominator"}, "model.the_tuva_project.data_quality__location_zip_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_ZIP_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_zip_code"}, "model.the_tuva_project.readmissions__encounter": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter"}, "model.the_tuva_project.data_quality__institutional_ms_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_MS_DRG_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_ms_drg_code"}, "model.the_tuva_project.encounters__stg_eligibility": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_ELIGIBILITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 2, "name": "BIRTH_DATE", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 4, "name": "RACE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 5, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "PATIENT_ROW_NUM": {"type": "NUMBER", "index": 6, "name": "PATIENT_ROW_NUM", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_eligibility"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSIONS_MISSING_AGE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age"}, "model.the_tuva_project.service_category__home_health_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_HOME_HEALTH_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__home_health_professional"}, "model.the_tuva_project.normalized_input__int_apr_drg_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_APR_DRG_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_voting"}, "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_LAB_RESULT_LAB_RESULT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id"}, "model.the_tuva_project.data_quality__data_quality_clinical_detail": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLINICAL_DETAIL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 11, "name": "SUMMARY_SK", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_detail"}, "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_ENCOUNTER_RANKING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_TYPE", "comment": null}, "PRIORITY_NUMBER": {"type": "NUMBER", "index": 3, "name": "PRIORITY_NUMBER", "comment": null}, "RELATIVE_RANK": {"type": "NUMBER", "index": 4, "name": "RELATIVE_RANK", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking"}, "model.the_tuva_project.data_quality__condition_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_source_code"}, "model.the_tuva_project.readmissions__encounter_data_quality": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_DATA_QUALITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 2, "name": "DIAGNOSIS_CCS", "comment": null}, "DISQUALIFIED_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 3, "name": "DISQUALIFIED_ENCOUNTER_FLAG", "comment": null}, "MISSING_ADMIT_DATE_FLAG": {"type": "NUMBER", "index": 4, "name": "MISSING_ADMIT_DATE_FLAG", "comment": null}, "MISSING_DISCHARGE_DATE_FLAG": {"type": "NUMBER", "index": 5, "name": "MISSING_DISCHARGE_DATE_FLAG", "comment": null}, "ADMIT_AFTER_DISCHARGE_FLAG": {"type": "NUMBER", "index": 6, "name": "ADMIT_AFTER_DISCHARGE_FLAG", "comment": null}, "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 7, "name": "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 8, "name": "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "MISSING_PRIMARY_DIAGNOSIS_FLAG": {"type": "NUMBER", "index": 9, "name": "MISSING_PRIMARY_DIAGNOSIS_FLAG", "comment": null}, "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG": {"type": "NUMBER", "index": 10, "name": "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG", "comment": null}, "NO_DIAGNOSIS_CCS_FLAG": {"type": "NUMBER", "index": 11, "name": "NO_DIAGNOSIS_CCS_FLAG", "comment": null}, "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 12, "name": "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG", "comment": null}, "MISSING_MS_DRG_FLAG": {"type": "NUMBER", "index": 13, "name": "MISSING_MS_DRG_FLAG", "comment": null}, "INVALID_MS_DRG_FLAG": {"type": "NUMBER", "index": 14, "name": "INVALID_MS_DRG_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_data_quality"}, "model.the_tuva_project.mart_review__stg_member_month": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__STG_MEMBER_MONTH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 10, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 14, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "YEAR_MONTH_INT": {"type": "NUMBER", "index": 15, "name": "YEAR_MONTH_INT", "comment": null}, "YEAR_MONTH_DATE": {"type": "DATE", "index": 16, "name": "YEAR_MONTH_DATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__stg_member_month"}, "model.the_tuva_project.quality_measures__int_cqm236_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 7, "name": "OBSERVATION_DATE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_numerator"}, "model.the_tuva_project.data_quality__medication_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_data_source"}, "model.the_tuva_project.data_quality__practitioner_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_npi"}, "model.the_tuva_project.cms_hcc__int_members": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_MEMBERS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 2, "name": "ENROLLMENT_STATUS", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 4, "name": "AGE_GROUP", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 5, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 6, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 7, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 8, "name": "INSTITUTIONAL_STATUS", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 9, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 10, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 11, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 12, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 13, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_members"}, "model.the_tuva_project.quality_measures__int_cqm438__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438__performance_period"}, "model.the_tuva_project.data_quality__pharmacy_plan": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PLAN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_plan"}, "model.the_tuva_project.data_quality__encounter_admit_type_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_TYPE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_code"}, "model.the_tuva_project.asc__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__anchor_events"}, "model.the_tuva_project.data_quality__professional_claim_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_CLAIM_END_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_claim_end_date"}, "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_VOLUME_AND_DOLLARS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "NUMBER", "index": 1, "name": "YEAR_MONTH", "comment": null}, "CLAIM_VOLUME": {"type": "NUMBER", "index": 2, "name": "CLAIM_VOLUME", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 3, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars"}, "model.the_tuva_project.data_quality__medication_ndc_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_NDC_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_code"}, "model.the_tuva_project.data_quality__condition_condition_rank": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CONDITION_RANK", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_condition_rank"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 3, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 4, "name": "NDC_CODE", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 5, "name": "DAYS_SUPPLY", "comment": null}, "DAYS_IN_TREATMENT_PERIOD": {"type": "NUMBER", "index": 6, "name": "DAYS_IN_TREATMENT_PERIOD", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 7, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 8, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 9, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 10, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 11, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 12, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator"}, "model.the_tuva_project.normalized_input__int_procedure_date_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_DATE_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "DATE", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_voting"}, "model.the_tuva_project.ahrq_measures__int_pqi_12_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_12_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_num"}, "model.the_tuva_project.core__stg_clinical_encounter": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_ENCOUNTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_encounter"}, "model.the_tuva_project.data_quality__eligibility_missing_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MISSING_PAYER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_payer"}, "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_PAYMENT_HCC_COUNT_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 4, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 5, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 6, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "PAYMENT_HCC_COUNT": {"type": "TEXT", "index": 8, "name": "PAYMENT_HCC_COUNT", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 9, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 10, "name": "COEFFICIENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 73, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors"}, "model.the_tuva_project.data_quality__observation_observation_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_OBSERVATION_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_observation_type"}, "model.the_tuva_project.encounters__orphaned_claims": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__ORPHANED_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__orphaned_claims"}, "seed.the_tuva_project.reference_data__fips_county": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "FIPS_COUNTY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"FIPS_CODE": {"type": "TEXT", "index": 1, "name": "FIPS_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 2, "name": "COUNTY", "comment": null}, "STATE": {"type": "TEXT", "index": 3, "name": "STATE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3232, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 31232, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__fips_county"}, "model.the_tuva_project.data_quality__core_populated": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CORE_POPULATED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"TABLE_NAME": {"type": "TEXT", "index": 1, "name": "TABLE_NAME", "comment": null}, "RECORD_COUNT": {"type": "NUMBER", "index": 2, "name": "RECORD_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 8, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__core_populated"}, "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ACUTE_DIAGNOSIS_CCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 80, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_ccs"}, "model.the_tuva_project.data_quality__eligibility_race": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_RACE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_race"}, "model.the_tuva_project.data_quality__primary_key_check": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEY_CHECK", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_key_check"}, "model.the_tuva_project.data_quality__encounter_admit_type_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_TYPE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_description"}, "model.the_tuva_project.service_category__inpatient_rehab_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_REHAB_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_institutional"}, "model.the_tuva_project.office_visits__int_office_visits_surgery": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_SURGERY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_surgery"}, "model.the_tuva_project.normalized_input__int_admit_type_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_TYPE_NORMALIZE_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_voting"}, "model.the_tuva_project.data_quality__eligibility_member_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MEMBER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_member_id"}, "model.the_tuva_project.mart_review__patient_risk_factors": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT_RISK_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 2, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 3, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 4, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 5, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 6, "name": "FACTOR_TYPE", "comment": null}, "RISK_FACTOR_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "RISK_FACTOR_DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 8, "name": "COEFFICIENT", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 9, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 10, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}, "PATIENT_RISK_SK": {"type": "NUMBER", "index": 12, "name": "PATIENT_RISK_SK", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient_risk_factors"}, "model.the_tuva_project.readmissions__procedure_ccs": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_PROCEDURE_CCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PROCEDURE_CODE": {"type": "TEXT", "index": 2, "name": "PROCEDURE_CODE", "comment": null}, "VALID_ICD_10_PCS_FLAG": {"type": "NUMBER", "index": 3, "name": "VALID_ICD_10_PCS_FLAG", "comment": null}, "CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__procedure_ccs"}, "model.the_tuva_project.data_quality__location_address": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_ADDRESS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_address"}, "model.the_tuva_project.quality_measures__int_cqm236_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclusions"}, "model.the_tuva_project.data_quality__encounter_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PATIENT_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_patient_id"}, "model.the_tuva_project.normalized_input__int_admit_source_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_SOURCE_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_voting"}, "model.the_tuva_project.data_quality__ed_classification": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ED_CLASSIFICATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__ed_classification"}, "model.the_tuva_project.data_quality__professional_billing_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_BILLING_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_billing_npi"}, "seed.the_tuva_project.terminology__encounter_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ENCOUNTER_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_TYPE": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_TYPE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 18, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__encounter_type"}, "model.the_tuva_project.data_quality__claim_diagnosis_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DIAGNOSIS_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_diagnosis_code_type"}, "model.the_tuva_project.asc__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 3, "name": "END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__generate_encounter_id"}, "seed.the_tuva_project.terminology__icd_9_pcs": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_9_PCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_9_PCS": {"type": "TEXT", "index": 1, "name": "ICD_9_PCS", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "LONG_DESCRIPTION", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "SHORT_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 3882, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 105984, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_9_pcs"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator"}, "model.the_tuva_project.core__encounter": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "ENCOUNTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}, "ENCOUNTER_SOURCE_TYPE": {"type": "TEXT", "index": 45, "name": "ENCOUNTER_SOURCE_TYPE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__encounter"}, "model.the_tuva_project.lab__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__match_claims_to_anchor"}, "model.the_tuva_project.inpatient_rehab__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__PROF_CLAIMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__prof_claims"}, "model.the_tuva_project.urgent_care__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__generate_encounter_id"}, "model.the_tuva_project.inpatient_snf__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__generate_encounter_id"}, "seed.the_tuva_project.terminology__payer_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PAYER_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PAYER_TYPE": {"type": "TEXT", "index": 1, "name": "PAYER_TYPE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__payer_type"}, "model.the_tuva_project.office_visits__int_office_visits_em": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_EM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_em"}, "seed.the_tuva_project.terminology__ndc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "NDC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NDC": {"type": "TEXT", "index": 1, "name": "NDC", "comment": null}, "RXCUI": {"type": "TEXT", "index": 2, "name": "RXCUI", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "RXNORM_DESCRIPTION", "comment": null}, "FDA_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "FDA_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 878867, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8559104, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ndc"}, "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_07_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions"}, "model.the_tuva_project.data_quality__lab_result_collection_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_COLLECTION_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_collection_date"}, "model.the_tuva_project.data_quality__observation_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_encounter_id"}, "model.the_tuva_project.office_visits__int_office_visits_injections": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_INJECTIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_injections"}, "model.the_tuva_project.home_health__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__generate_encounter_id"}, "model.the_tuva_project.pharmacy__int_claims_current_cost": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_CLAIMS_CURRENT_COST", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NDC_CODE": {"type": "TEXT", "index": 1, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "NDC_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "RXCUI": {"type": "TEXT", "index": 4, "name": "RXCUI", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 5, "name": "BRAND_VS_GENERIC", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 6, "name": "GENERIC_AVAILABLE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 7, "name": "PAID_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 8, "name": "CLAIM_COUNT", "comment": null}, "COST_PER_CLAIM": {"type": "NUMBER", "index": 9, "name": "COST_PER_CLAIM", "comment": null}, "TOTAL_UNITS": {"type": "NUMBER", "index": 10, "name": "TOTAL_UNITS", "comment": null}, "COST_PER_UNIT": {"type": "NUMBER", "index": 11, "name": "COST_PER_UNIT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_claims_current_cost"}, "model.the_tuva_project.readmissions__index_admission": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_INDEX_ADMISSION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__index_admission"}, "model.the_tuva_project.ccsr__singular_condition_category": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "SINGULAR_CONDITION_CATEGORY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 6, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "PARENT_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "PARENT_CATEGORY_DESCRIPTION", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 8, "name": "BODY_SYSTEM", "comment": null}, "DXCCSR_VERSION": {"type": "TEXT", "index": 9, "name": "DXCCSR_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__singular_condition_category"}, "model.the_tuva_project.quality_measures__int_nqf0034_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_long"}, "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_VOLUME_AND_DOLLARS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "NUMBER", "index": 1, "name": "YEAR_MONTH", "comment": null}, "CLAIM_VOLUME": {"type": "NUMBER", "index": 2, "name": "CLAIM_VOLUME", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 3, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars"}, "seed.input_layer.provider_attribution_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "PROVIDER_ATTRIBUTION_SEED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 6, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 10, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.provider_attribution_seed"}, "model.the_tuva_project.ahrq_measures__int_pqi_08_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_08_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_num"}, "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_MEDICATION_MEDICATION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_medication_medication_id"}, "model.the_tuva_project.data_quality__pharmacy_member_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_MEMBER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_member_id"}, "model.the_tuva_project.data_quality__claim_copayment_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_COPAYMENT_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_copayment_amount"}, "model.the_tuva_project.data_quality__procedure_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_SOURCE_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code_type"}, "model.the_tuva_project.service_category__acute_inpatient_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_professional"}, "model.the_tuva_project.data_quality__analytics_reference_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ANALYTICS_REFERENCE_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 5, "name": "VALUE_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 35, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__analytics_reference_summary"}, "model.the_tuva_project.data_quality__location_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_NAME", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_name"}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_REFERENCE_RANGE_LOW", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_low"}, "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "LOOKBACK_PERIOD_JUNE": {"type": "DATE", "index": 6, "name": "LOOKBACK_PERIOD_JUNE", "comment": null}, "LOOKBACK_PERIOD_DECEMBER": {"type": "DATE", "index": 7, "name": "LOOKBACK_PERIOD_DECEMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053__performance_period"}, "model.the_tuva_project.home_health__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__anchor_events"}, "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_1_ALLOWED_PIVOT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 6, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 7, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 8, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 9, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 10, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 11, "name": "PHARMACY_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot"}, "model.the_tuva_project.service_category__ambulance_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULANCE_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulance_professional"}, "model.the_tuva_project.quality_measures__int_cqm438_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_exclusions"}, "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_ABNORMAL_FLAG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag"}, "model.the_tuva_project.data_quality__encounter_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_id"}, "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_EXCLUDE_PROCEDURES_OBSERVATIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 5, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "CMS_CHRONIC_CONDITIONS_WIDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ACUTE_MYOCARDIAL_INFARCTION": {"type": "NUMBER", "index": 2, "name": "ACUTE_MYOCARDIAL_INFARCTION", "comment": null}, "ADHD_CONDUCT_DISORDERS_AND_HYPERKINETIC_SYNDROME": {"type": "NUMBER", "index": 3, "name": "ADHD_CONDUCT_DISORDERS_AND_HYPERKINETIC_SYNDROME", "comment": null}, "ALCOHOL_USE_DISORDERS": {"type": "NUMBER", "index": 4, "name": "ALCOHOL_USE_DISORDERS", "comment": null}, "ALZHEIMERS_DISEASE": {"type": "NUMBER", "index": 5, "name": "ALZHEIMERS_DISEASE", "comment": null}, "ANEMIA": {"type": "NUMBER", "index": 6, "name": "ANEMIA", "comment": null}, "ANXIETY_DISORDERS": {"type": "NUMBER", "index": 7, "name": "ANXIETY_DISORDERS", "comment": null}, "ASTHMA": {"type": "NUMBER", "index": 8, "name": "ASTHMA", "comment": null}, "ATRIAL_FIBRILLATION_AND_FLUTTER": {"type": "NUMBER", "index": 9, "name": "ATRIAL_FIBRILLATION_AND_FLUTTER", "comment": null}, "AUTISM_SPECTRUM_DISORDERS": {"type": "NUMBER", "index": 10, "name": "AUTISM_SPECTRUM_DISORDERS", "comment": null}, "BENIGN_PROSTATIC_HYPERPLASIA": {"type": "NUMBER", "index": 11, "name": "BENIGN_PROSTATIC_HYPERPLASIA", "comment": null}, "BIPOLAR_DISORDER": {"type": "NUMBER", "index": 12, "name": "BIPOLAR_DISORDER", "comment": null}, "CANCER_BREAST": {"type": "NUMBER", "index": 13, "name": "CANCER_BREAST", "comment": null}, "CANCER_COLORECTAL": {"type": "NUMBER", "index": 14, "name": "CANCER_COLORECTAL", "comment": null}, "CANCER_ENDOMETRIAL": {"type": "NUMBER", "index": 15, "name": "CANCER_ENDOMETRIAL", "comment": null}, "CANCER_LUNG": {"type": "NUMBER", "index": 16, "name": "CANCER_LUNG", "comment": null}, "CANCER_PROSTATE": {"type": "NUMBER", "index": 17, "name": "CANCER_PROSTATE", "comment": null}, "CANCER_UROLOGIC_KIDNEY_RENAL_PELVIS_AND_URETER": {"type": "NUMBER", "index": 18, "name": "CANCER_UROLOGIC_KIDNEY_RENAL_PELVIS_AND_URETER", "comment": null}, "CATARACT": {"type": "NUMBER", "index": 19, "name": "CATARACT", "comment": null}, "CEREBRAL_PALSY": {"type": "NUMBER", "index": 20, "name": "CEREBRAL_PALSY", "comment": null}, "CHRONIC_KIDNEY_DISEASE": {"type": "NUMBER", "index": 21, "name": "CHRONIC_KIDNEY_DISEASE", "comment": null}, "CHRONIC_OBSTRUCTIVE_PULMONARY_DISEASE": {"type": "NUMBER", "index": 22, "name": "CHRONIC_OBSTRUCTIVE_PULMONARY_DISEASE", "comment": null}, "CYSTIC_FIBROSIS_AND_OTHER_METABOLIC_DEVELOPMENTAL_DISORDERS": {"type": "NUMBER", "index": 23, "name": "CYSTIC_FIBROSIS_AND_OTHER_METABOLIC_DEVELOPMENTAL_DISORDERS", "comment": null}, "DEPRESSION_BIPOLAR_OR_OTHER_DEPRESSIVE_MOOD_DISORDERS": {"type": "NUMBER", "index": 24, "name": "DEPRESSION_BIPOLAR_OR_OTHER_DEPRESSIVE_MOOD_DISORDERS", "comment": null}, "DEPRESSIVE_DISORDERS": {"type": "NUMBER", "index": 25, "name": "DEPRESSIVE_DISORDERS", "comment": null}, "DIABETES": {"type": "NUMBER", "index": 26, "name": "DIABETES", "comment": null}, "DRUG_USE_DISORDERS": {"type": "NUMBER", "index": 27, "name": "DRUG_USE_DISORDERS", "comment": null}, "EPILEPSY": {"type": "NUMBER", "index": 28, "name": "EPILEPSY", "comment": null}, "FIBROMYALGIA_AND_CHRONIC_PAIN_AND_FATIGUE": {"type": "NUMBER", "index": 29, "name": "FIBROMYALGIA_AND_CHRONIC_PAIN_AND_FATIGUE", "comment": null}, "GLAUCOMA": {"type": "NUMBER", "index": 30, "name": "GLAUCOMA", "comment": null}, "HEART_FAILURE_AND_NON_ISCHEMIC_HEART_DISEASE": {"type": "NUMBER", "index": 31, "name": "HEART_FAILURE_AND_NON_ISCHEMIC_HEART_DISEASE", "comment": null}, "HEPATITIS_A": {"type": "NUMBER", "index": 32, "name": "HEPATITIS_A", "comment": null}, "HEPATITIS_B_ACUTE_OR_UNSPECIFIED": {"type": "NUMBER", "index": 33, "name": "HEPATITIS_B_ACUTE_OR_UNSPECIFIED", "comment": null}, "HEPATITIS_B_CHRONIC": {"type": "NUMBER", "index": 34, "name": "HEPATITIS_B_CHRONIC", "comment": null}, "HEPATITIS_C_ACUTE": {"type": "NUMBER", "index": 35, "name": "HEPATITIS_C_ACUTE", "comment": null}, "HEPATITIS_C_CHRONIC": {"type": "NUMBER", "index": 36, "name": "HEPATITIS_C_CHRONIC", "comment": null}, "HEPATITIS_C_UNSPECIFIED": {"type": "NUMBER", "index": 37, "name": "HEPATITIS_C_UNSPECIFIED", "comment": null}, "HEPATITIS_D": {"type": "NUMBER", "index": 38, "name": "HEPATITIS_D", "comment": null}, "HEPATITIS_E": {"type": "NUMBER", "index": 39, "name": "HEPATITIS_E", "comment": null}, "HIP_PELVIC_FRACTURE": {"type": "NUMBER", "index": 40, "name": "HIP_PELVIC_FRACTURE", "comment": null}, "HUMAN_IMMUNODEFICIENCY_VIRUS_AND_OR_ACQUIRED_IMMUNODEFICIENCY_SYNDROME_HIV_AIDS": {"type": "NUMBER", "index": 41, "name": "HUMAN_IMMUNODEFICIENCY_VIRUS_AND_OR_ACQUIRED_IMMUNODEFICIENCY_SYNDROME_HIV_AIDS", "comment": null}, "HYPERLIPIDEMIA": {"type": "NUMBER", "index": 42, "name": "HYPERLIPIDEMIA", "comment": null}, "HYPERTENSION": {"type": "NUMBER", "index": 43, "name": "HYPERTENSION", "comment": null}, "HYPOTHYROIDISM": {"type": "NUMBER", "index": 44, "name": "HYPOTHYROIDISM", "comment": null}, "INTELLECTUAL_DISABILITIES_AND_RELATED_CONDITIONS": {"type": "NUMBER", "index": 45, "name": "INTELLECTUAL_DISABILITIES_AND_RELATED_CONDITIONS", "comment": null}, "ISCHEMIC_HEART_DISEASE": {"type": "NUMBER", "index": 46, "name": "ISCHEMIC_HEART_DISEASE", "comment": null}, "LEARNING_DISABILITIES": {"type": "NUMBER", "index": 47, "name": "LEARNING_DISABILITIES", "comment": null}, "LEUKEMIAS_AND_LYMPHOMAS": {"type": "NUMBER", "index": 48, "name": "LEUKEMIAS_AND_LYMPHOMAS", "comment": null}, "LIVER_DISEASE_CIRRHOSIS_AND_OTHER_LIVER_CONDITIONS_EXCEPT_VIRAL_HEPATITIS": {"type": "NUMBER", "index": 49, "name": "LIVER_DISEASE_CIRRHOSIS_AND_OTHER_LIVER_CONDITIONS_EXCEPT_VIRAL_HEPATITIS", "comment": null}, "MIGRAINE_AND_CHRONIC_HEADACHE": {"type": "NUMBER", "index": 50, "name": "MIGRAINE_AND_CHRONIC_HEADACHE", "comment": null}, "MOBILITY_IMPAIRMENTS": {"type": "NUMBER", "index": 51, "name": "MOBILITY_IMPAIRMENTS", "comment": null}, "MULTIPLE_SCLEROSIS_AND_TRANSVERSE_MYELITIS": {"type": "NUMBER", "index": 52, "name": "MULTIPLE_SCLEROSIS_AND_TRANSVERSE_MYELITIS", "comment": null}, "MUSCULAR_DYSTROPHY": {"type": "NUMBER", "index": 53, "name": "MUSCULAR_DYSTROPHY", "comment": null}, "NON_ALZHEIMERS_DEMENTIA": {"type": "NUMBER", "index": 54, "name": "NON_ALZHEIMERS_DEMENTIA", "comment": null}, "OBESITY": {"type": "NUMBER", "index": 55, "name": "OBESITY", "comment": null}, "OPIOID_USE_DISORDER_OUD": {"type": "NUMBER", "index": 56, "name": "OPIOID_USE_DISORDER_OUD", "comment": null}, "OSTEOPOROSIS_WITH_OR_WITHOUT_PATHOLOGICAL_FRACTURE": {"type": "NUMBER", "index": 57, "name": "OSTEOPOROSIS_WITH_OR_WITHOUT_PATHOLOGICAL_FRACTURE", "comment": null}, "OTHER_DEVELOPMENTAL_DELAYS": {"type": "NUMBER", "index": 58, "name": "OTHER_DEVELOPMENTAL_DELAYS", "comment": null}, "PARKINSONS_DISEASE_AND_SECONDARY_PARKINSONISM": {"type": "NUMBER", "index": 59, "name": "PARKINSONS_DISEASE_AND_SECONDARY_PARKINSONISM", "comment": null}, "PERIPHERAL_VASCULAR_DISEASE_PVD": {"type": "NUMBER", "index": 60, "name": "PERIPHERAL_VASCULAR_DISEASE_PVD", "comment": null}, "PERSONALITY_DISORDERS": {"type": "NUMBER", "index": 61, "name": "PERSONALITY_DISORDERS", "comment": null}, "PNEUMONIA_ALL_CAUSE": {"type": "NUMBER", "index": 62, "name": "PNEUMONIA_ALL_CAUSE", "comment": null}, "POST_TRAUMATIC_STRESS_DISORDER_PTSD": {"type": "NUMBER", "index": 63, "name": "POST_TRAUMATIC_STRESS_DISORDER_PTSD", "comment": null}, "PRESSURE_AND_CHRONIC_ULCERS": {"type": "NUMBER", "index": 64, "name": "PRESSURE_AND_CHRONIC_ULCERS", "comment": null}, "RHEUMATOID_ARTHRITIS_OSTEOARTHRITIS": {"type": "NUMBER", "index": 65, "name": "RHEUMATOID_ARTHRITIS_OSTEOARTHRITIS", "comment": null}, "SCHIZOPHRENIA": {"type": "NUMBER", "index": 66, "name": "SCHIZOPHRENIA", "comment": null}, "SCHIZOPHRENIA_AND_OTHER_PSYCHOTIC_DISORDERS": {"type": "NUMBER", "index": 67, "name": "SCHIZOPHRENIA_AND_OTHER_PSYCHOTIC_DISORDERS", "comment": null}, "SENSORY_BLINDNESS_AND_VISUAL_IMPAIRMENT": {"type": "NUMBER", "index": 68, "name": "SENSORY_BLINDNESS_AND_VISUAL_IMPAIRMENT", "comment": null}, "SENSORY_DEAFNESS_AND_HEARING_IMPAIRMENT": {"type": "NUMBER", "index": 69, "name": "SENSORY_DEAFNESS_AND_HEARING_IMPAIRMENT", "comment": null}, "SICKLE_CELL_DISEASE": {"type": "NUMBER", "index": 70, "name": "SICKLE_CELL_DISEASE", "comment": null}, "SPINA_BIFIDA_AND_OTHER_CONGENITAL_ANOMALIES_OF_THE_NERVOUS_SYSTEM": {"type": "NUMBER", "index": 71, "name": "SPINA_BIFIDA_AND_OTHER_CONGENITAL_ANOMALIES_OF_THE_NERVOUS_SYSTEM", "comment": null}, "SPINAL_CORD_INJURY": {"type": "NUMBER", "index": 72, "name": "SPINAL_CORD_INJURY", "comment": null}, "STROKE_TRANSIENT_ISCHEMIC_ATTACK": {"type": "NUMBER", "index": 73, "name": "STROKE_TRANSIENT_ISCHEMIC_ATTACK", "comment": null}, "TOBACCO_USE": {"type": "NUMBER", "index": 74, "name": "TOBACCO_USE", "comment": null}, "TRAUMATIC_BRAIN_INJURY_AND_NONPSYCHOTIC_MENTAL_DISORDERS_DUE_TO_BRAIN_DAMAGE": {"type": "NUMBER", "index": 75, "name": "TRAUMATIC_BRAIN_INJURY_AND_NONPSYCHOTIC_MENTAL_DISORDERS_DUE_TO_BRAIN_DAMAGE", "comment": null}, "VIRAL_HEPATITIS_GENERAL": {"type": "NUMBER", "index": 76, "name": "VIRAL_HEPATITIS_GENERAL", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 77, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"}, "seed.input_layer.eligibility_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "ELIGIBILITY_SEED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 2, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 3, "name": "SUBSCRIBER_ID", "comment": null}, "GENDER": {"type": "TEXT", "index": 4, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 9, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 10, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 11, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 12, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 13, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 14, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 15, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 16, "name": "MEDICARE_STATUS_CODE", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 17, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 18, "name": "LAST_NAME", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 19, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 20, "name": "SUBSCRIBER_RELATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 21, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 22, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 23, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 24, "name": "ZIP_CODE", "comment": null}, "PHONE": {"type": "TEXT", "index": 25, "name": "PHONE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 27, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 28, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.eligibility_seed"}, "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_EXCLUDE_COLECTOMY_CANCER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer"}, "model.the_tuva_project.quality_measures__int_cbe0101_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "ENCOUNTER_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_DATE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_denominator"}, "model.the_tuva_project.ahrq_measures__int_pqi_14_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_14_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_num"}, "model.the_tuva_project.data_quality__lab_result_specimen": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SPECIMEN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_specimen"}, "seed.the_tuva_project.clinical_concept_library__value_set_members": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "VALUE_SET_MEMBERS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"VALUE_SET_MEMBER_ID": {"type": "TEXT", "index": 1, "name": "VALUE_SET_MEMBER_ID", "comment": null}, "CONCEPT_ID": {"type": "TEXT", "index": 2, "name": "CONCEPT_ID", "comment": null}, "STATUS": {"type": "TEXT", "index": 3, "name": "STATUS", "comment": null}, "LAST_UPDATE_DATE": {"type": "DATE", "index": 4, "name": "LAST_UPDATE_DATE", "comment": null}, "LAST_UPDATE_NOTE": {"type": "TEXT", "index": 5, "name": "LAST_UPDATE_NOTE", "comment": null}, "CODE": {"type": "TEXT", "index": 6, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "CODE_DESCRIPTION", "comment": null}, "CODING_SYSTEM_ID": {"type": "TEXT", "index": 8, "name": "CODING_SYSTEM_ID", "comment": null}, "CODING_SYSTEM_VERSION": {"type": "TEXT", "index": 9, "name": "CODING_SYSTEM_VERSION", "comment": null}, "INCLUDE_DESCENDANTS": {"type": "TEXT", "index": 10, "name": "INCLUDE_DESCENDANTS", "comment": null}, "COMMENT": {"type": "TEXT", "index": 11, "name": "COMMENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12164, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 274944, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.clinical_concept_library__value_set_members"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_TRANSFER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer"}, "model.the_tuva_project.data_quality__medication_atc_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ATC_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_atc_code"}, "model.the_tuva_project.service_category__outpatient_surgery_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SURGERY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_professional"}, "model.the_tuva_project.data_quality__data_quality_for_pbi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_FOR_PBI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 2, "name": "FIELD_NAME", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 4, "name": "CLAIM_TYPE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 5, "name": "BUCKET_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 6, "name": "FIELD_VALUE", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 7, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 8, "name": "DRILL_DOWN_VALUE", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 10, "name": "SUMMARY_SK", "comment": null}, "FREQUENCY": {"type": "NUMBER", "index": 11, "name": "FREQUENCY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_for_pbi"}, "model.the_tuva_project.core__stg_clinical_lab_result": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_LAB_RESULT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 12, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 13, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 15, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 16, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 17, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 18, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 21, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "TEXT", "index": 23, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "TEXT", "index": 24, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 25, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 26, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_lab_result"}, "model.the_tuva_project.inpatient_psych__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__encounter_grain"}, "model.the_tuva_project.data_quality__institutional_admit_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_ADMIT_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_source_code"}, "model.the_tuva_project.data_quality__claim_total_cost_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_TOTAL_COST_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_total_cost_amount"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_MISSING_GENDER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender"}, "seed.the_tuva_project.terminology__hcpcs_to_rbcs": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "HCPCS_TO_RBCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS_CD": {"type": "TEXT", "index": 1, "name": "HCPCS_CD", "comment": null}, "RBCS_ID": {"type": "TEXT", "index": 2, "name": "RBCS_ID", "comment": null}, "RBCS_CAT": {"type": "TEXT", "index": 3, "name": "RBCS_CAT", "comment": null}, "RBCS_CAT_DESC": {"type": "TEXT", "index": 4, "name": "RBCS_CAT_DESC", "comment": null}, "RBCS_CAT_SUBCAT": {"type": "TEXT", "index": 5, "name": "RBCS_CAT_SUBCAT", "comment": null}, "RBCS_SUBCAT_DESC": {"type": "TEXT", "index": 6, "name": "RBCS_SUBCAT_DESC", "comment": null}, "RBCS_FAMNUMB": {"type": "NUMBER", "index": 7, "name": "RBCS_FAMNUMB", "comment": null}, "RBCS_FAMILY_DESC": {"type": "TEXT", "index": 8, "name": "RBCS_FAMILY_DESC", "comment": null}, "RBCS_MAJOR_IND": {"type": "TEXT", "index": 9, "name": "RBCS_MAJOR_IND", "comment": null}, "HCPCS_CD_ADD_DT": {"type": "DATE", "index": 10, "name": "HCPCS_CD_ADD_DT", "comment": null}, "HCPCS_CD_END_DT": {"type": "DATE", "index": 11, "name": "HCPCS_CD_END_DT", "comment": null}, "RBCS_ASSIGNMENT_EFF_DT": {"type": "DATE", "index": 12, "name": "RBCS_ASSIGNMENT_EFF_DT", "comment": null}, "CURRENT_FLAG": {"type": "NUMBER", "index": 13, "name": "CURRENT_FLAG", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 17033, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 235520, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__hcpcs_to_rbcs"}, "model.the_tuva_project.normalized_input__int_bill_type_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_BILL_TYPE_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_final"}, "model.the_tuva_project.quality_measures__int_nqf0034_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_DENOMINATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MIN_AGE": {"type": "NUMBER", "index": 2, "name": "MIN_AGE", "comment": null}, "MAX_AGE": {"type": "NUMBER", "index": 3, "name": "MAX_AGE", "comment": null}, "QUALIFYING_TYPES": {"type": "TEXT", "index": 4, "name": "QUALIFYING_TYPES", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_denominator"}, "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_PSYCHIATRIC_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_institutional"}, "model.the_tuva_project.normalized_input__eligibility": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "NORMALIZED_INPUT_ELIGIBILITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 2, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 3, "name": "SUBSCRIBER_ID", "comment": null}, "GENDER": {"type": "TEXT", "index": 4, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 9, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 10, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 11, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 12, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 13, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 14, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 15, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 16, "name": "MEDICARE_STATUS_CODE", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 17, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 18, "name": "LAST_NAME", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 19, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 20, "name": "SUBSCRIBER_RELATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 21, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 22, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 23, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 24, "name": "ZIP_CODE", "comment": null}, "PHONE": {"type": "TEXT", "index": 25, "name": "PHONE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__eligibility"}, "model.the_tuva_project.mart_review__quality_measures_summary_long": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__QUALITY_MEASURES_SUMMARY_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "PERFORMANCE_FLAG": {"type": "NUMBER", "index": 5, "name": "PERFORMANCE_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 6, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 7, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 8, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 9, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 11, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 12, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 13, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 14, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__quality_measures_summary_long"}, "model.the_tuva_project.data_quality__professional_facility_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_FACILITY_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_facility_npi"}, "model.the_tuva_project.home_health__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 22, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 25, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 26, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__encounter_grain"}, "model.the_tuva_project.dialysis__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 22, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 25, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 26, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__encounter_grain"}, "model.the_tuva_project.data_quality__eligibility_dq_stage": {"metadata": {"type": "VIEW", "schema": "DATA_QUALITY", "name": "DATA_QUALITY__ELIGIBILITY_DQ_STAGE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "NUMBER", "index": 2, "name": "YEAR_MONTH", "comment": null}, "MONTH_START_DATE": {"type": "DATE", "index": 3, "name": "MONTH_START_DATE", "comment": null}, "MONTH_END_DATE": {"type": "DATE", "index": 4, "name": "MONTH_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_dq_stage"}, "seed.the_tuva_project.terminology__ccs_services_procedures": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "CCS_SERVICES_PROCEDURES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS_CODE": {"type": "TEXT", "index": 1, "name": "HCPCS_CODE", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 2, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 17477, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 131584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ccs_services_procedures"}, "model.the_tuva_project.core__practitioner": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PRACTITIONER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "PROVIDER_FIRST_NAME": {"type": "TEXT", "index": 3, "name": "PROVIDER_FIRST_NAME", "comment": null}, "PROVIDER_LAST_NAME": {"type": "TEXT", "index": 4, "name": "PROVIDER_LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__practitioner"}, "model.the_tuva_project.core__member_months": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "MEMBER_MONTHS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 10, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 14, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__member_months"}, "model.the_tuva_project.outpatient_substance_use__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__anchor_events"}, "model.the_tuva_project.quality_measures__int_cqm130_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_exclusions"}, "model.the_tuva_project.data_quality__institutional_facility_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_FACILITY_NPI", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_facility_npi"}, "model.the_tuva_project.normalized_input__int_present_on_admit_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PRESENT_ON_ADMIT_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_voting"}, "model.the_tuva_project.data_quality__lab_result_normalized_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_UNITS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_units"}, "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_CONDITION_CONDITION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_condition_condition_id"}, "model.the_tuva_project.inpatient_psych__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__generate_encounter_id"}, "model.the_tuva_project.outpatient_surgery__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__generate_encounter_id"}, "model.the_tuva_project.data_quality__patient_sex": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_SEX", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_sex"}, "model.the_tuva_project.data_quality__lab_result_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code"}, "model.the_tuva_project.data_quality__pharmacy_copayment_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_COPAYMENT_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_copayment_amount"}, "model.the_tuva_project.ed_classification__summary": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ED_CLASSIFICATION_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ED_CLASSIFICATION_DESCRIPTION", "comment": null}, "ED_CLASSIFICATION_ORDER": {"type": "TEXT", "index": 3, "name": "ED_CLASSIFICATION_ORDER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_END_DATE", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 6, "name": "YEAR_MONTH", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 10, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 11, "name": "CHARGE_AMOUNT", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_STATE": {"type": "TEXT", "index": 14, "name": "FACILITY_STATE", "comment": null}, "FACILITY_CITY": {"type": "TEXT", "index": 15, "name": "FACILITY_CITY", "comment": null}, "FACILITY_ZIP_CODE": {"type": "TEXT", "index": 16, "name": "FACILITY_ZIP_CODE", "comment": null}, "PATIENT_SEX": {"type": "TEXT", "index": 17, "name": "PATIENT_SEX", "comment": null}, "PATIENT_AGE": {"type": "NUMBER", "index": 18, "name": "PATIENT_AGE", "comment": null}, "PATIENT_ZIP_CODE": {"type": "TEXT", "index": 19, "name": "PATIENT_ZIP_CODE", "comment": null}, "PATIENT_LATITUDE": {"type": "FLOAT", "index": 20, "name": "PATIENT_LATITUDE", "comment": null}, "PATIENT_LONGITUDE": {"type": "FLOAT", "index": 21, "name": "PATIENT_LONGITUDE", "comment": null}, "PATIENT_RACE": {"type": "TEXT", "index": 22, "name": "PATIENT_RACE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ed_classification__summary"}, "model.the_tuva_project.dme__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DME__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__generate_encounter_id"}, "model.the_tuva_project.pharmacy__generic_available_list": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "GENERIC_AVAILABLE_LIST", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"GENERIC_AVAILABLE_SK": {"type": "NUMBER", "index": 1, "name": "GENERIC_AVAILABLE_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "BRAND_NDC_CODE": {"type": "TEXT", "index": 3, "name": "BRAND_NDC_CODE", "comment": null}, "BRAND_NDC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "BRAND_NDC_DESCRIPTION", "comment": null}, "BRAND_RXCUI": {"type": "TEXT", "index": 5, "name": "BRAND_RXCUI", "comment": null}, "BRAND_PAID_AMOUNT": {"type": "NUMBER", "index": 6, "name": "BRAND_PAID_AMOUNT", "comment": null}, "BRAND_UNITS": {"type": "NUMBER", "index": 7, "name": "BRAND_UNITS", "comment": null}, "BRAND_PAID_PER_UNIT": {"type": "NUMBER", "index": 8, "name": "BRAND_PAID_PER_UNIT", "comment": null}, "GENERIC_NDC": {"type": "TEXT", "index": 9, "name": "GENERIC_NDC", "comment": null}, "GENERIC_NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "GENERIC_NDC_DESCRIPTION", "comment": null}, "GENERIC_PRESCRIBED_HISTORY": {"type": "NUMBER", "index": 11, "name": "GENERIC_PRESCRIBED_HISTORY", "comment": null}, "GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 12, "name": "GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_COST_AT_UNITS": {"type": "NUMBER", "index": 13, "name": "GENERIC_COST_AT_UNITS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__generic_available_list"}, "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_PATIENT_SPEND_WITH_SERVICE_CATEGORIES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_2", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 7, "name": "TOTAL_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 8, "name": "TOTAL_ALLOWED", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 9, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"}, "model.the_tuva_project.inpatient_hospice__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__encounter_grain"}, "model.the_tuva_project.office_visits__int_office_visits_union": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_UNION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "PRIORITY_NUMBER": {"type": "NUMBER", "index": 5, "name": "PRIORITY_NUMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_union"}, "model.the_tuva_project.normalized_input__int_ms_drg_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MS_DRG_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_final"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_MISSING_PRIMARY_DX", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx"}, "model.the_tuva_project.data_quality__observation_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code_type"}, "model.the_tuva_project.data_quality__chronic_conditions_none": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CHRONIC_CONDITIONS_NONE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "MEDICARE_LDS_REFERENCE": {"type": "TEXT", "index": 3, "name": "MEDICARE_LDS_REFERENCE", "comment": null}, "NORMALLY_ZERO": {"type": "NUMBER", "index": 4, "name": "NORMALLY_ZERO", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_none"}, "model.the_tuva_project.outpatient_injections__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 20, "name": "HCPCS_CODE", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__encounter_grain"}, "model.the_tuva_project.data_quality__eligibility_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_data_source"}, "seed.input_layer.observation_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "OBSERVATION_SEED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "RESULT": {"type": "TEXT", "index": 13, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 14, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 15, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 16, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 18, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 21, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.observation_seed"}, "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_POTENTIALLY_PLANNED_ICD_10_PCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2521, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 34304, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs"}, "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_EXCLUDE_MASTECTOMY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_long"}, "model.the_tuva_project.data_quality__eligibility_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_END_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_end_date"}, "model.the_tuva_project.core__observation": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "OBSERVATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 13, "name": "MAPPING_METHOD", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 15, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 16, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 18, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 21, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__observation"}, "model.the_tuva_project.service_category__observation_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OBSERVATION_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__observation_professional"}, "model.the_tuva_project.mart_review__patient_risk": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT_RISK", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"RISK_SCORE_BUCKET": {"type": "TEXT", "index": 1, "name": "RISK_SCORE_BUCKET", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 2, "name": "PAYMENT_YEAR", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 4, "name": "MODEL_VERSION", "comment": null}, "PATIENT_RISK_SK": {"type": "NUMBER", "index": 5, "name": "PATIENT_RISK_SK", "comment": null}, "RISK_SCORE": {"type": "NUMBER", "index": 6, "name": "RISK_SCORE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient_risk"}, "model.the_tuva_project.service_category__lab_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_LAB_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__lab_professional"}, "model.the_tuva_project.mart_review__pmpm": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PMPM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 2, "name": "PAYER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 4, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 5, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 6, "name": "MEDICAL_PAID", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 7, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 8, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 9, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 10, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 11, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 12, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 13, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 14, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 15, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 16, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 17, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 18, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 19, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 20, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 21, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 22, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 23, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 24, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 25, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 26, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 27, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 28, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 29, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 31, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 32, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 33, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 34, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 35, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 36, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 37, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 38, "name": "URGENT_CARE_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 39, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 40, "name": "MEDICAL_ALLOWED", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 41, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 42, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 43, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 44, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 45, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 46, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 47, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 48, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 49, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 50, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 51, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 52, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 53, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 54, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 55, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 56, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 57, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 58, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 59, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 60, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 61, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 62, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 63, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 64, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 65, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 70, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 71, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 72, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 73, "name": "TUVA_LAST_RUN", "comment": null}, "TOTAL_PAID_ABSOLUTE": {"type": "NUMBER", "index": 74, "name": "TOTAL_PAID_ABSOLUTE", "comment": null}, "MEDICAL_PAID_ABSOLUTE": {"type": "NUMBER", "index": 75, "name": "MEDICAL_PAID_ABSOLUTE", "comment": null}, "PHARMACY_PAID_ABSOLUTE": {"type": "NUMBER", "index": 76, "name": "PHARMACY_PAID_ABSOLUTE", "comment": null}, "INPATIENT_PAID_ABSOLUTE": {"type": "NUMBER", "index": 77, "name": "INPATIENT_PAID_ABSOLUTE", "comment": null}, "OUTPATIENT_PAID_ABSOLUTE": {"type": "NUMBER", "index": 78, "name": "OUTPATIENT_PAID_ABSOLUTE", "comment": null}, "OFFICE_BASED_PAID_ABSOLUTE": {"type": "NUMBER", "index": 79, "name": "OFFICE_BASED_PAID_ABSOLUTE", "comment": null}, "ANCILLARY_PAID_ABSOLUTE": {"type": "NUMBER", "index": 80, "name": "ANCILLARY_PAID_ABSOLUTE", "comment": null}, "OTHER_PAID_ABSOLUTE": {"type": "NUMBER", "index": 81, "name": "OTHER_PAID_ABSOLUTE", "comment": null}, "DATA_SOURCE_MONTH_KEY": {"type": "TEXT", "index": 82, "name": "DATA_SOURCE_MONTH_KEY", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__pmpm"}, "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__generate_encounter_id"}, "model.the_tuva_project.service_category__outpatient_hospice_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPICE_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_professional"}, "model.the_tuva_project.data_quality__institutional_claim_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_CLAIM_END_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_end_date"}, "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_PROCEDURE_PROCEDURE_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"}, "model.the_tuva_project.data_quality__encounter_length_of_stay": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_LENGTH_OF_STAY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_length_of_stay"}, "model.the_tuva_project.service_category__service_category_grouper": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY_GROUPER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "ORIGINAL_SERVICE_CAT_2": {"type": "TEXT", "index": 7, "name": "ORIGINAL_SERVICE_CAT_2", "comment": null}, "ORIGINAL_SERVICE_CAT_3": {"type": "TEXT", "index": 8, "name": "ORIGINAL_SERVICE_CAT_3", "comment": null}, "DUPLICATE_ROW_NUMBER": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_ROW_NUMBER", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 10, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 12, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "MS_DRG_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 14, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 16, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 17, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 18, "name": "HCPCS_CODE", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 19, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 20, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 21, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 22, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 23, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "MODALITY": {"type": "TEXT", "index": 25, "name": "MODALITY", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 26, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 28, "name": "SOURCE_MODEL_NAME", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 29, "name": "DATA_SOURCE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__service_category_grouper"}, "model.the_tuva_project.core__stg_clinical_observation": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLINICAL_OBSERVATION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "RESULT": {"type": "TEXT", "index": 13, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 14, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 15, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 16, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 18, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_observation"}, "model.the_tuva_project.outpatient_hospice__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__generate_encounter_id"}, "seed.the_tuva_project.cms_hcc__disease_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISEASE_HIERARCHY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 2, "name": "HCC_CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 3, "name": "DESCRIPTION", "comment": null}, "HCCS_TO_EXCLUDE": {"type": "TEXT", "index": 4, "name": "HCCS_TO_EXCLUDE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 221, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disease_hierarchy"}, "model.the_tuva_project.normalized_input__int_procedure_code_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_CODE_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 3, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_COLUMN": {"type": "TEXT", "index": 4, "name": "PROCEDURE_COLUMN", "comment": null}, "NORMALIZED_PROCEDURE_CODE": {"type": "TEXT", "index": 5, "name": "NORMALIZED_PROCEDURE_CODE", "comment": null}, "PROCEDURE_CODE_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "PROCEDURE_CODE_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_normalize"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_MISSING_DATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates"}, "model.the_tuva_project.quality_measures__int_nqf2372_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_numerator"}, "model.the_tuva_project.data_quality__observation_source_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_REFERENCE_RANGE_HIGH", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_high"}, "model.the_tuva_project.quality_measures__int_adhras_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_NUMERATOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 2, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 3, "name": "EVIDENCE_VALUE", "comment": null}, "ADHERENCE": {"type": "NUMBER", "index": 4, "name": "ADHERENCE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 5, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_numerator"}, "model.the_tuva_project.encounters__combined_claim_line_crosswalk": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__COMBINED_CLAIM_LINE_CROSSWALK", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "PRIORITY_NUMBER": {"type": "NUMBER", "index": 7, "name": "PRIORITY_NUMBER", "comment": null}, "CLAIM_LINE_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 8, "name": "CLAIM_LINE_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__combined_claim_line_crosswalk"}, "model.the_tuva_project.data_quality__eligibility_zip_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_ZIP_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_zip_code"}, "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_COINSURANCE_AMOUNT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount"}, "model.the_tuva_project.data_quality__condition_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_SOURCE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_source_description"}, "model.the_tuva_project.data_quality__analytics_checks_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ANALYTICS_CHECKS_SUMMARY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "NORMALLY_ZERO": {"type": "NUMBER", "index": 3, "name": "NORMALLY_ZERO", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__analytics_checks_summary"}, "model.the_tuva_project.data_quality__procedure_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_NORMALIZED_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code_type"}, "model.the_tuva_project.data_quality__quality_measures": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_QUALITY_MEASURES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__quality_measures"}, "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_14_DENOM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_denom"}, "model.the_tuva_project.data_quality__institutional_procedure_code_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_CODE_2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_2"}, "model.the_tuva_project.lab__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 19, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__encounter_grain"}, "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_PSYCHIATRIC_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_institutional"}, "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_VALUE_SET_CMS_CHRONIC_CONDITIONS_HIERARCHY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "CONDITION": {"type": "TEXT", "index": 2, "name": "CONDITION", "comment": null}, "CONDITION_COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "CONDITION_COLUMN_NAME", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "ADDITIONAL_LOGIC": {"type": "TEXT", "index": 6, "name": "ADDITIONAL_LOGIC", "comment": null}, "CLAIMS_QUALIFICATION": {"type": "TEXT", "index": 7, "name": "CLAIMS_QUALIFICATION", "comment": null}, "INCLUSION_TYPE": {"type": "TEXT", "index": 8, "name": "INCLUSION_TYPE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 9, "name": "CODE_SYSTEM", "comment": null}, "CODE": {"type": "TEXT", "index": 10, "name": "CODE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 6532, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 143360, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"}, "model.the_tuva_project.data_quality__claim_date_trends": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DATE_TRENDS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "NUMBER", "index": 1, "name": "YEAR_MONTH", "comment": null}, "CLAIM_START_DATE": {"type": "NUMBER", "index": 2, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "NUMBER", "index": 3, "name": "CLAIM_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "NUMBER", "index": 4, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "NUMBER", "index": 5, "name": "DISCHARGE_DATE", "comment": null}, "MEDICAL_PAID_DATE": {"type": "NUMBER", "index": 6, "name": "MEDICAL_PAID_DATE", "comment": null}, "DISPENSING_DATE": {"type": "NUMBER", "index": 7, "name": "DISPENSING_DATE", "comment": null}, "PHARMACY_PAID_DATE": {"type": "NUMBER", "index": 8, "name": "PHARMACY_PAID_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_date_trends"}, "model.the_tuva_project.data_quality__encounters_missing_groups": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_MISSING_GROUPS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MISSING_ENCOUNTER_GROUP": {"type": "TEXT", "index": 1, "name": "MISSING_ENCOUNTER_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups"}, "model.the_tuva_project.service_category__office_based_physical_therapy_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_PHYSICAL_THERAPY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_physical_therapy_professional"}, "model.the_tuva_project.core__lab_result": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "LAB_RESULT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 12, "name": "MAPPING_METHOD", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 13, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 14, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 15, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 16, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 17, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 18, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 19, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 21, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 23, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "TEXT", "index": 24, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "TEXT", "index": 25, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 26, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 27, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 28, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__lab_result"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "CMS_CHRONIC_CONDITIONS_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"}, "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055__performance_period"}, "model.the_tuva_project.normalized_input__medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "NORMALIZED_INPUT_MEDICAL_CLAIM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 16, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 17, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 18, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 22, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 24, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 25, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 26, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 28, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 29, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "TEXT", "index": 30, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 31, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 32, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 33, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 34, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 35, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 36, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 37, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 38, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 39, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 40, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 41, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 42, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 43, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 44, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 45, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 46, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 47, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 48, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 49, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 50, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 51, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 52, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 93, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 94, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 95, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 96, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 97, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 98, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 99, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 100, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 101, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 102, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 103, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 119, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 120, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 121, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 122, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 123, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 124, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 125, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 126, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 127, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 128, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 129, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 144, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 145, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 146, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 147, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 148, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 149, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 150, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 151, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 152, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 153, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 154, "name": "PROCEDURE_DATE_25", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 155, "name": "DATA_SOURCE", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 156, "name": "IN_NETWORK_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 157, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__medical_claim"}, "model.the_tuva_project.data_quality__lab_result_source_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_UNITS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_units"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR_CRITERIA2", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2"}, "model.the_tuva_project.data_quality__medication_days_supply": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_DAYS_SUPPLY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_days_supply"}, "model.the_tuva_project.ambulance__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__match_claims_to_anchor"}, "model.the_tuva_project.hcc_suspecting__int_observation_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_OBSERVATION_SUSPECTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 3, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_RESULT": {"type": "TEXT", "index": 4, "name": "OBSERVATION_RESULT", "comment": null}, "CONDITION_CODE": {"type": "TEXT", "index": 5, "name": "CONDITION_CODE", "comment": null}, "CONDITION_DATE": {"type": "DATE", "index": 6, "name": "CONDITION_DATE", "comment": null}, "CONDITION_CONCEPT_NAME": {"type": "TEXT", "index": 7, "name": "CONDITION_CONCEPT_NAME", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 8, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "HCC_DESCRIPTION", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 10, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 11, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 12, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 13, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_observation_suspects"}, "seed.the_tuva_project.quality_measures__value_sets": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_VALUE_SET_CODES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_NAME": {"type": "TEXT", "index": 1, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 2, "name": "CONCEPT_OID", "comment": null}, "CODE": {"type": "TEXT", "index": 3, "name": "CODE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 4, "name": "CODE_SYSTEM", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 52101, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 494592, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.quality_measures__value_sets"}, "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_ENROLLMENT_INTERACTION_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 3, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 4, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 5, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 6, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors"}, "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_ENROLLMENT_INTERACTION_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 4, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 5, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 6, "name": "DUAL_STATUS", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 8, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 9, "name": "COEFFICIENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 14, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4096, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors"}, "model.the_tuva_project.data_quality__procedure_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_data_source"}, "model.the_tuva_project.quality_measures__summary_counts": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "SUMMARY_COUNTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "DENOMINATOR_SUM": {"type": "NUMBER", "index": 6, "name": "DENOMINATOR_SUM", "comment": null}, "NUMERATOR_SUM": {"type": "NUMBER", "index": 7, "name": "NUMERATOR_SUM", "comment": null}, "EXCLUSION_SUM": {"type": "NUMBER", "index": 8, "name": "EXCLUSION_SUM", "comment": null}, "PERFORMANCE_RATE": {"type": "NUMBER", "index": 9, "name": "PERFORMANCE_RATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:20UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__summary_counts"}, "seed.the_tuva_project.cms_hcc__adjustment_rates": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_ADJUSTMENT_RATES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 2, "name": "PAYMENT_YEAR", "comment": null}, "NORMALIZATION_FACTOR": {"type": "FLOAT", "index": 3, "name": "NORMALIZATION_FACTOR", "comment": null}, "MA_CODING_PATTERN_ADJUSTMENT": {"type": "FLOAT", "index": 4, "name": "MA_CODING_PATTERN_ADJUSTMENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__adjustment_rates"}, "model.the_tuva_project.data_quality__procedure_procedure_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PROCEDURE_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_id"}, "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 5, "name": "HCPCS_CODE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 6, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor"}, "model.the_tuva_project.office_visits__int_office_visits_radiology": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_RADIOLOGY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 5, "name": "HCPCS_CODE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 6, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_radiology"}, "model.the_tuva_project.data_quality__dx_and_px": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DX_AND_PX", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__dx_and_px"}, "model.the_tuva_project.data_quality__pharmacy_claim_line_number": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_LINE_NUMBER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_line_number"}, "model.the_tuva_project.data_quality__condition_resolved_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_RESOLVED_DATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_resolved_date"}, "model.the_tuva_project.outpatient_psych__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__generate_encounter_id"}, "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISABLED_INTERACTION_FACTORS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 4, "name": "INSTITUTIONAL_STATUS", "comment": null}, "SHORT_NAME": {"type": "TEXT", "index": 5, "name": "SHORT_NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 6, "name": "DESCRIPTION", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 7, "name": "HCC_CODE", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 8, "name": "COEFFICIENT", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 40, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4096, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disabled_interaction_factors"}, "seed.the_tuva_project.terminology__admit_source": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ADMIT_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 1, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "NEWBORN_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "NEWBORN_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 16, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__admit_source"}, "model.the_tuva_project.data_quality__service_categories_pmpm": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "SERVICE_CATEGORIES_PMPM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 3, "name": "TOTAL_PAID", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 4, "name": "MEMBER_MONTHS", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 5, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 6, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__service_categories_pmpm"}, "model.the_tuva_project.data_quality__condition_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_SOURCE_CODE_TYPE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_source_code_type"}, "model.the_tuva_project.data_quality__condition_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CLAIM_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_claim_id"}, "model.the_tuva_project.normalized_input__int_diagnosis_code_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DIAGNOSIS_CODE_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 4, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 5, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 6, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 7, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 8, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 9, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 10, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 11, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 12, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 13, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 15, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 16, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 17, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 18, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 19, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 20, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 21, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 22, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 23, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 24, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 25, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 26, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 27, "name": "DIAGNOSIS_CODE_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_final"}, "seed.input_layer.medical_claim_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "MEDICAL_CLAIM_SEED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 15, "name": "ADMIT_TYPE_CODE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 16, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 17, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 18, "name": "BILL_TYPE_CODE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 20, "name": "APR_DRG_CODE", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 21, "name": "REVENUE_CENTER_CODE", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 22, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 23, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 27, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 28, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 29, "name": "RENDERING_NPI", "comment": null}, "RENDERING_TIN": {"type": "NUMBER", "index": 30, "name": "RENDERING_TIN", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 31, "name": "BILLING_NPI", "comment": null}, "BILLING_TIN": {"type": "NUMBER", "index": 32, "name": "BILLING_TIN", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 33, "name": "FACILITY_NPI", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 34, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 35, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 36, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 37, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 38, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 39, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 40, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 41, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 42, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 43, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 44, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 45, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 46, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 47, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 48, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 49, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 50, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 93, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 94, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 95, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 96, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 97, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 98, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 99, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 100, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 101, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 119, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 120, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 121, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 122, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 123, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 124, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 125, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 126, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 127, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_25", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 144, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 145, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 146, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 147, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.medical_claim_seed"}, "model.the_tuva_project.data_quality__pharmacy_claim_ndc": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_NDC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_ndc"}, "model.the_tuva_project.data_quality__encounter_apr_drg_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_APR_DRG_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_description"}, "model.the_tuva_project.mart_review__enrollment_change": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__ENROLLMENT_CHANGE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CHANGE_MONTH": {"type": "DATE", "index": 2, "name": "CHANGE_MONTH", "comment": null}, "CHANGE_TYPE": {"type": "TEXT", "index": 3, "name": "CHANGE_TYPE", "comment": null}, "MEMBER_COUNT": {"type": "NUMBER", "index": 4, "name": "MEMBER_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__enrollment_change"}, "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_01_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions"}, "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_EXCLUSIONS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_exclusions"}, "model.the_tuva_project.mart_review__data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__DATA_SOURCE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__data_source"}, "model.the_tuva_project.data_quality__institutional_procedure_date_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_DATE_3", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_3"}, "model.the_tuva_project.data_quality__condition_condition_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CONDITION_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_condition_id"}, "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"}, "model.the_tuva_project.service_category__outpatient_substance_use_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SUBSTANCE_USE_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_institutional"}, "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MEDICAL_CLAIM_DATE_NORMALIZE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_CLAIM_START_DATE": {"type": "DATE", "index": 5, "name": "NORMALIZED_CLAIM_START_DATE", "comment": null}, "NORMALIZED_CLAIM_END_DATE": {"type": "DATE", "index": 6, "name": "NORMALIZED_CLAIM_END_DATE", "comment": null}, "NORMALIZED_CLAIM_LINE_START_DATE": {"type": "DATE", "index": 7, "name": "NORMALIZED_CLAIM_LINE_START_DATE", "comment": null}, "NORMALIZED_CLAIM_LINE_END_DATE": {"type": "DATE", "index": 8, "name": "NORMALIZED_CLAIM_LINE_END_DATE", "comment": null}, "NORMALIZED_ADMISSION_DATE": {"type": "DATE", "index": 9, "name": "NORMALIZED_ADMISSION_DATE", "comment": null}, "NORMALIZED_DISCHARGE_DATE": {"type": "DATE", "index": 10, "name": "NORMALIZED_DISCHARGE_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize"}, "model.the_tuva_project.normalized_input__int_apr_drg_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_APR_DRG_FINAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_final"}, "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "PHARMACY_CLAIM_EXPANDED", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 6, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 7, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 8, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 11, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 12, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 13, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 14, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 15, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 16, "name": "ALLOWED_AMOUNT", "comment": null}, "RXCUI": {"type": "TEXT", "index": 17, "name": "RXCUI", "comment": null}, "PRODUCT_NAME": {"type": "TEXT", "index": 18, "name": "PRODUCT_NAME", "comment": null}, "PRODUCT_TTY": {"type": "TEXT", "index": 19, "name": "PRODUCT_TTY", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 20, "name": "BRAND_VS_GENERIC", "comment": null}, "BRAND_NAME": {"type": "TEXT", "index": 21, "name": "BRAND_NAME", "comment": null}, "GENERIC_RXCUI": {"type": "TEXT", "index": 22, "name": "GENERIC_RXCUI", "comment": null}, "GENERIC_RXCUI_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "GENERIC_RXCUI_DESCRIPTION", "comment": null}, "GENERIC_TTY": {"type": "TEXT", "index": 24, "name": "GENERIC_TTY", "comment": null}, "INGREDIENT_NAME": {"type": "TEXT", "index": 25, "name": "INGREDIENT_NAME", "comment": null}, "DOSE_FORM_NAME": {"type": "TEXT", "index": 26, "name": "DOSE_FORM_NAME", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 27, "name": "GENERIC_AVAILABLE", "comment": null}, "BRAND_COST_PER_UNIT": {"type": "NUMBER", "index": 28, "name": "BRAND_COST_PER_UNIT", "comment": null}, "GENERIC_AVERAGE_COST_PER_UNIT": {"type": "NUMBER", "index": 29, "name": "GENERIC_AVERAGE_COST_PER_UNIT", "comment": null}, "BRAND_LESS_GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 30, "name": "BRAND_LESS_GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY": {"type": "NUMBER", "index": 31, "name": "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY", "comment": null}, "GENERIC_AVAILABLE_SK": {"type": "NUMBER", "index": 32, "name": "GENERIC_AVAILABLE_SK", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"}, "seed.the_tuva_project.terminology__revenue_center": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "REVENUE_CENTER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"REVENUE_CENTER_CODE": {"type": "TEXT", "index": 1, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 526, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8704, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__revenue_center"}, "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059__PERFORMANCE_PERIOD", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059__performance_period"}, "seed.the_tuva_project.terminology__medicare_dual_eligibility": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MEDICARE_DUAL_ELIGIBILITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DUAL_STATUS_CODE": {"type": "TEXT", "index": 1, "name": "DUAL_STATUS_CODE", "comment": null}, "DUAL_STATUS_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DUAL_STATUS_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__medicare_dual_eligibility"}, "seed.the_tuva_project.clinical_concept_library__coding_systems": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "CODING_SYSTEMS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODING_SYSTEM_ID": {"type": "TEXT", "index": 1, "name": "CODING_SYSTEM_ID", "comment": null}, "CODING_SYSTEM_NAME": {"type": "TEXT", "index": 2, "name": "CODING_SYSTEM_NAME", "comment": null}, "CODING_SYSTEM_URI": {"type": "TEXT", "index": 3, "name": "CODING_SYSTEM_URI", "comment": null}, "CODING_SYSTEM_OID": {"type": "TEXT", "index": 4, "name": "CODING_SYSTEM_OID", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:14UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.clinical_concept_library__coding_systems"}, "model.the_tuva_project.dialysis__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__GENERATE_ENCOUNTER_ID", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__generate_encounter_id"}, "model.the_tuva_project.quality_measures__int_adhras_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_long"}, "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_INSTITUTIONAL_MATERNITY", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity"}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "TUVA_CHRONIC_CONDITIONS_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CONDITION": {"type": "TEXT", "index": 2, "name": "CONDITION", "comment": null}, "FIRST_DIAGNOSIS_DATE": {"type": "DATE", "index": 3, "name": "FIRST_DIAGNOSIS_DATE", "comment": null}, "LAST_DIAGNOSIS_DATE": {"type": "DATE", "index": 4, "name": "LAST_DIAGNOSIS_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"}, "seed.the_tuva_project.terminology__rxnorm_brand_generic": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "RXNORM_BRAND_GENERIC", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRODUCT_RXCUI": {"type": "TEXT", "index": 1, "name": "PRODUCT_RXCUI", "comment": null}, "PRODUCT_NAME": {"type": "TEXT", "index": 2, "name": "PRODUCT_NAME", "comment": null}, "PRODUCT_TTY": {"type": "TEXT", "index": 3, "name": "PRODUCT_TTY", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 4, "name": "BRAND_VS_GENERIC", "comment": null}, "BRAND_NAME": {"type": "TEXT", "index": 5, "name": "BRAND_NAME", "comment": null}, "CLINICAL_PRODUCT_RXCUI": {"type": "TEXT", "index": 6, "name": "CLINICAL_PRODUCT_RXCUI", "comment": null}, "CLINICAL_PRODUCT_NAME": {"type": "TEXT", "index": 7, "name": "CLINICAL_PRODUCT_NAME", "comment": null}, "CLINICAL_PRODUCT_TTY": {"type": "TEXT", "index": 8, "name": "CLINICAL_PRODUCT_TTY", "comment": null}, "INGREDIENT_NAME": {"type": "TEXT", "index": 9, "name": "INGREDIENT_NAME", "comment": null}, "DOSE_FORM_NAME": {"type": "TEXT", "index": 10, "name": "DOSE_FORM_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 63956, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3440640, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__rxnorm_brand_generic"}, "model.the_tuva_project.quality_measures__int_cqm438_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_long"}, "model.the_tuva_project.data_quality__lab_result_status": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_STATUS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_status"}, "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_INST_HEADER_FIELDS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_inst_header_fields"}, "model.the_tuva_project.data_quality__unique_value_examples": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "UNIQUE_VALUE_EXAMPLES", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__unique_value_examples"}, "model.the_tuva_project.data_quality__observation_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_description"}, "model.the_tuva_project.quality_measures__int_nqf0420_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_long"}, "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ACUTE_DIAGNOSIS_ICD_10_CM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 12333, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 183808, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm"}, "model.the_tuva_project.data_quality__observation_source_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_UNITS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_units"}, "model.the_tuva_project.quality_measures__int_nqf0053_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_LONG", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_long"}, "seed.the_tuva_project.data_quality__reference_mart_analytics": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_REFERENCE_MART_ANALYTICS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 3, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 4, "name": "VALUE_RANK", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 5, "name": "PAYER_TYPE", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 134, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 6144, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__reference_mart_analytics"}, "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DIAGNOSIS_CODE_VOTING", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_voting"}, "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_FIELD_TO_MART", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"INPUT_LAYER_TABLE_NAME": {"type": "TEXT", "index": 1, "name": "INPUT_LAYER_TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 3, "name": "FIELD_NAME", "comment": null}, "MART_NAME": {"type": "TEXT", "index": 4, "name": "MART_NAME", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 307, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_to_mart"}, "model.the_tuva_project.data_quality__financial_pmpm": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_FINANCIAL_PMPM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEMBER_MONTHS": {"type": "NUMBER", "index": 1, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PMPM": {"type": "NUMBER", "index": 2, "name": "TOTAL_PMPM", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__financial_pmpm"}, "model.the_tuva_project.service_category__ambulatory_surgery_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULATORY_SURGERY_PROFESSIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_professional"}, "model.the_tuva_project.outpatient_radiology__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__ANCHOR_EVENTS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 3, "name": "HCPCS_CODE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__anchor_events"}, "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__MATCH_CLAIMS_TO_ANCHOR", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__claim_claim_line_number": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_LINE_NUMBER", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:17UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_number"}, "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_ICD_10_CM_TO_CCS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "CCS_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CCS_DESCRIPTION", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 72776, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1313792, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:15UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs"}, "model.the_tuva_project.data_quality__medication_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_SOURCE_DESCRIPTION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_source_description"}, "model.the_tuva_project.mart_review__claims_with_enrollment": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__CLAIMS_WITH_ENROLLMENT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "CLAIMS_WITH_ENROLLMENT": {"type": "NUMBER", "index": 3, "name": "CLAIMS_WITH_ENROLLMENT", "comment": null}, "CLAIMS": {"type": "NUMBER", "index": 4, "name": "CLAIMS", "comment": null}, "PERCENTAGE_CLAIMS_WITH_ENROLLMENT": {"type": "NUMBER", "index": 5, "name": "PERCENTAGE_CLAIMS_WITH_ENROLLMENT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__claims_with_enrollment"}, "model.the_tuva_project.hcc_suspecting__list": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "LIST", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "HCC_DESCRIPTION", "comment": null}, "REASON": {"type": "TEXT", "index": 5, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 6, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 7, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__list"}, "model.the_tuva_project.data_quality__patient_state": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_STATE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_state"}, "model.the_tuva_project.data_quality__patient_latitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_LATITUDE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_latitude"}, "model.the_tuva_project.data_quality__lab_result_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_CODE", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code"}, "model.the_tuva_project.core__stg_claims_condition": {"metadata": {"type": "VIEW", "schema": "DBT_TOM", "name": "CORE__STG_CLAIMS_CONDITION", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 16, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 17, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_condition"}, "model.the_tuva_project.encounters__stg_inpatient_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_INPATIENT_INSTITUTIONAL", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_inpatient_institutional"}, "model.the_tuva_project.hcc_suspecting__list_rollup": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "LIST_ROLLUP", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 2, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "HCC_DESCRIPTION", "comment": null}, "REASON": {"type": "TEXT", "index": 4, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 5, "name": "CONTRIBUTING_FACTOR", "comment": null}, "LATEST_SUSPECT_DATE": {"type": "DATE", "index": 6, "name": "LATEST_SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__list_rollup"}, "model.the_tuva_project.emergency_department__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 13, "name": "OBSERVATION_FLAG", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 14, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 15, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 16, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 17, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 18, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 19, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 20, "name": "PHARMACY_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 21, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 23, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 24, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 25, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 26, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 28, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 30, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 32, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 35, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 38, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 39, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 40, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 41, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__encounter_grain"}, "model.the_tuva_project.outpatient_surgery__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__ENCOUNTER_GRAIN", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:18UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__encounter_grain"}, "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_1_PAID_PIVOT", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 6, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 7, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 8, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 9, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 10, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 11, "name": "PHARMACY_PAID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:19UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot"}, "model.the_tuva_project.data_quality__eligibility_date_checks": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DATE_CHECKS", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-22 19:16UTC", "include": true, "description": "The timestamp for last update/change"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_date_checks"}, "model.the_tuva_project.ahrq_measures__int_pqi_11_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_11_NUM", "database": "CMS_SYNTHETIC", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_num"}}, "sources": {}, "errors": null} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.8.6", "generated_at": "2024-10-25T14:35:06.121909Z", "invocation_id": "7a3fb5b6-66c4-4d4a-b7ed-a46ac2f1bdcb", "env": {}}, "nodes": {"model.the_tuva_project.data_quality__observation_observation_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_OBSERVATION_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_observation_type"}, "model.the_tuva_project.data_quality__claim_allowed_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_ALLOWED_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_allowed_amount"}, "model.the_tuva_project.data_quality__institutional_present_on_admission_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PRESENT_ON_ADMISSION_3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_3"}, "model.the_tuva_project.data_quality__location_city": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_CITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_city"}, "seed.the_tuva_project.terminology__race": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "RACE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 8, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__race"}, "model.the_tuva_project.data_quality__claim_copayment_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_COPAYMENT_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_copayment_amount"}, "model.the_tuva_project.data_quality__medication_strength": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_STRENGTH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_strength"}, "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclusions"}, "model.the_tuva_project.mart_review__stg_pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__STG_PHARMACY_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PHARMACY_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "PHARMACY_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 9, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 12, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 13, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 15, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 16, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 17, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 18, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 23, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 25, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 28, "name": "YEAR_MONTH", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__stg_pharmacy_claim"}, "model.the_tuva_project.service_category__pharmacy_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__PHARMACY_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__pharmacy_institutional"}, "model.the_tuva_project.normalized_input__int_revenue_center_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_REVENUE_CENTER_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_revenue_center_normalize"}, "model.the_tuva_project.inpatient_hospice__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__encounter_grain"}, "model.the_tuva_project.data_quality__procedure_modifier_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_2"}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PRIMARY_DIAGNOSIS_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description"}, "model.the_tuva_project.office_visits__int_office_visits_em": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_EM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_em"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_TRANSFER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer"}, "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_PHYSICAL_THERAPY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_professional"}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPITAL_OR_CLINIC_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional"}, "model.the_tuva_project.data_quality__condition_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_source_code"}, "seed.the_tuva_project.cms_hcc__cpt_hcpcs": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_CPT_HCPCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PAYMENT_YEAR": {"type": "NUMBER", "index": 1, "name": "PAYMENT_YEAR", "comment": null}, "HCPCS_CPT_CODE": {"type": "TEXT", "index": 2, "name": "HCPCS_CPT_CODE", "comment": null}, "INCLUDED_FLAG": {"type": "TEXT", "index": 3, "name": "INCLUDED_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 94208, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 39364, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__cpt_hcpcs"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "CMS_CHRONIC_CONDITIONS_WIDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ACUTE_MYOCARDIAL_INFARCTION": {"type": "NUMBER", "index": 2, "name": "ACUTE_MYOCARDIAL_INFARCTION", "comment": null}, "ADHD_CONDUCT_DISORDERS_AND_HYPERKINETIC_SYNDROME": {"type": "NUMBER", "index": 3, "name": "ADHD_CONDUCT_DISORDERS_AND_HYPERKINETIC_SYNDROME", "comment": null}, "ALCOHOL_USE_DISORDERS": {"type": "NUMBER", "index": 4, "name": "ALCOHOL_USE_DISORDERS", "comment": null}, "ALZHEIMERS_DISEASE": {"type": "NUMBER", "index": 5, "name": "ALZHEIMERS_DISEASE", "comment": null}, "ANEMIA": {"type": "NUMBER", "index": 6, "name": "ANEMIA", "comment": null}, "ANXIETY_DISORDERS": {"type": "NUMBER", "index": 7, "name": "ANXIETY_DISORDERS", "comment": null}, "ASTHMA": {"type": "NUMBER", "index": 8, "name": "ASTHMA", "comment": null}, "ATRIAL_FIBRILLATION_AND_FLUTTER": {"type": "NUMBER", "index": 9, "name": "ATRIAL_FIBRILLATION_AND_FLUTTER", "comment": null}, "AUTISM_SPECTRUM_DISORDERS": {"type": "NUMBER", "index": 10, "name": "AUTISM_SPECTRUM_DISORDERS", "comment": null}, "BENIGN_PROSTATIC_HYPERPLASIA": {"type": "NUMBER", "index": 11, "name": "BENIGN_PROSTATIC_HYPERPLASIA", "comment": null}, "BIPOLAR_DISORDER": {"type": "NUMBER", "index": 12, "name": "BIPOLAR_DISORDER", "comment": null}, "CANCER_BREAST": {"type": "NUMBER", "index": 13, "name": "CANCER_BREAST", "comment": null}, "CANCER_COLORECTAL": {"type": "NUMBER", "index": 14, "name": "CANCER_COLORECTAL", "comment": null}, "CANCER_ENDOMETRIAL": {"type": "NUMBER", "index": 15, "name": "CANCER_ENDOMETRIAL", "comment": null}, "CANCER_LUNG": {"type": "NUMBER", "index": 16, "name": "CANCER_LUNG", "comment": null}, "CANCER_PROSTATE": {"type": "NUMBER", "index": 17, "name": "CANCER_PROSTATE", "comment": null}, "CANCER_UROLOGIC_KIDNEY_RENAL_PELVIS_AND_URETER": {"type": "NUMBER", "index": 18, "name": "CANCER_UROLOGIC_KIDNEY_RENAL_PELVIS_AND_URETER", "comment": null}, "CATARACT": {"type": "NUMBER", "index": 19, "name": "CATARACT", "comment": null}, "CEREBRAL_PALSY": {"type": "NUMBER", "index": 20, "name": "CEREBRAL_PALSY", "comment": null}, "CHRONIC_KIDNEY_DISEASE": {"type": "NUMBER", "index": 21, "name": "CHRONIC_KIDNEY_DISEASE", "comment": null}, "CHRONIC_OBSTRUCTIVE_PULMONARY_DISEASE": {"type": "NUMBER", "index": 22, "name": "CHRONIC_OBSTRUCTIVE_PULMONARY_DISEASE", "comment": null}, "CYSTIC_FIBROSIS_AND_OTHER_METABOLIC_DEVELOPMENTAL_DISORDERS": {"type": "NUMBER", "index": 23, "name": "CYSTIC_FIBROSIS_AND_OTHER_METABOLIC_DEVELOPMENTAL_DISORDERS", "comment": null}, "DEPRESSION_BIPOLAR_OR_OTHER_DEPRESSIVE_MOOD_DISORDERS": {"type": "NUMBER", "index": 24, "name": "DEPRESSION_BIPOLAR_OR_OTHER_DEPRESSIVE_MOOD_DISORDERS", "comment": null}, "DEPRESSIVE_DISORDERS": {"type": "NUMBER", "index": 25, "name": "DEPRESSIVE_DISORDERS", "comment": null}, "DIABETES": {"type": "NUMBER", "index": 26, "name": "DIABETES", "comment": null}, "DRUG_USE_DISORDERS": {"type": "NUMBER", "index": 27, "name": "DRUG_USE_DISORDERS", "comment": null}, "EPILEPSY": {"type": "NUMBER", "index": 28, "name": "EPILEPSY", "comment": null}, "FIBROMYALGIA_AND_CHRONIC_PAIN_AND_FATIGUE": {"type": "NUMBER", "index": 29, "name": "FIBROMYALGIA_AND_CHRONIC_PAIN_AND_FATIGUE", "comment": null}, "GLAUCOMA": {"type": "NUMBER", "index": 30, "name": "GLAUCOMA", "comment": null}, "HEART_FAILURE_AND_NON_ISCHEMIC_HEART_DISEASE": {"type": "NUMBER", "index": 31, "name": "HEART_FAILURE_AND_NON_ISCHEMIC_HEART_DISEASE", "comment": null}, "HEPATITIS_A": {"type": "NUMBER", "index": 32, "name": "HEPATITIS_A", "comment": null}, "HEPATITIS_B_ACUTE_OR_UNSPECIFIED": {"type": "NUMBER", "index": 33, "name": "HEPATITIS_B_ACUTE_OR_UNSPECIFIED", "comment": null}, "HEPATITIS_B_CHRONIC": {"type": "NUMBER", "index": 34, "name": "HEPATITIS_B_CHRONIC", "comment": null}, "HEPATITIS_C_ACUTE": {"type": "NUMBER", "index": 35, "name": "HEPATITIS_C_ACUTE", "comment": null}, "HEPATITIS_C_CHRONIC": {"type": "NUMBER", "index": 36, "name": "HEPATITIS_C_CHRONIC", "comment": null}, "HEPATITIS_C_UNSPECIFIED": {"type": "NUMBER", "index": 37, "name": "HEPATITIS_C_UNSPECIFIED", "comment": null}, "HEPATITIS_D": {"type": "NUMBER", "index": 38, "name": "HEPATITIS_D", "comment": null}, "HEPATITIS_E": {"type": "NUMBER", "index": 39, "name": "HEPATITIS_E", "comment": null}, "HIP_PELVIC_FRACTURE": {"type": "NUMBER", "index": 40, "name": "HIP_PELVIC_FRACTURE", "comment": null}, "HUMAN_IMMUNODEFICIENCY_VIRUS_AND_OR_ACQUIRED_IMMUNODEFICIENCY_SYNDROME_HIV_AIDS": {"type": "NUMBER", "index": 41, "name": "HUMAN_IMMUNODEFICIENCY_VIRUS_AND_OR_ACQUIRED_IMMUNODEFICIENCY_SYNDROME_HIV_AIDS", "comment": null}, "HYPERLIPIDEMIA": {"type": "NUMBER", "index": 42, "name": "HYPERLIPIDEMIA", "comment": null}, "HYPERTENSION": {"type": "NUMBER", "index": 43, "name": "HYPERTENSION", "comment": null}, "HYPOTHYROIDISM": {"type": "NUMBER", "index": 44, "name": "HYPOTHYROIDISM", "comment": null}, "INTELLECTUAL_DISABILITIES_AND_RELATED_CONDITIONS": {"type": "NUMBER", "index": 45, "name": "INTELLECTUAL_DISABILITIES_AND_RELATED_CONDITIONS", "comment": null}, "ISCHEMIC_HEART_DISEASE": {"type": "NUMBER", "index": 46, "name": "ISCHEMIC_HEART_DISEASE", "comment": null}, "LEARNING_DISABILITIES": {"type": "NUMBER", "index": 47, "name": "LEARNING_DISABILITIES", "comment": null}, "LEUKEMIAS_AND_LYMPHOMAS": {"type": "NUMBER", "index": 48, "name": "LEUKEMIAS_AND_LYMPHOMAS", "comment": null}, "LIVER_DISEASE_CIRRHOSIS_AND_OTHER_LIVER_CONDITIONS_EXCEPT_VIRAL_HEPATITIS": {"type": "NUMBER", "index": 49, "name": "LIVER_DISEASE_CIRRHOSIS_AND_OTHER_LIVER_CONDITIONS_EXCEPT_VIRAL_HEPATITIS", "comment": null}, "MIGRAINE_AND_CHRONIC_HEADACHE": {"type": "NUMBER", "index": 50, "name": "MIGRAINE_AND_CHRONIC_HEADACHE", "comment": null}, "MOBILITY_IMPAIRMENTS": {"type": "NUMBER", "index": 51, "name": "MOBILITY_IMPAIRMENTS", "comment": null}, "MULTIPLE_SCLEROSIS_AND_TRANSVERSE_MYELITIS": {"type": "NUMBER", "index": 52, "name": "MULTIPLE_SCLEROSIS_AND_TRANSVERSE_MYELITIS", "comment": null}, "MUSCULAR_DYSTROPHY": {"type": "NUMBER", "index": 53, "name": "MUSCULAR_DYSTROPHY", "comment": null}, "NON_ALZHEIMERS_DEMENTIA": {"type": "NUMBER", "index": 54, "name": "NON_ALZHEIMERS_DEMENTIA", "comment": null}, "OBESITY": {"type": "NUMBER", "index": 55, "name": "OBESITY", "comment": null}, "OPIOID_USE_DISORDER_OUD": {"type": "NUMBER", "index": 56, "name": "OPIOID_USE_DISORDER_OUD", "comment": null}, "OSTEOPOROSIS_WITH_OR_WITHOUT_PATHOLOGICAL_FRACTURE": {"type": "NUMBER", "index": 57, "name": "OSTEOPOROSIS_WITH_OR_WITHOUT_PATHOLOGICAL_FRACTURE", "comment": null}, "OTHER_DEVELOPMENTAL_DELAYS": {"type": "NUMBER", "index": 58, "name": "OTHER_DEVELOPMENTAL_DELAYS", "comment": null}, "PARKINSONS_DISEASE_AND_SECONDARY_PARKINSONISM": {"type": "NUMBER", "index": 59, "name": "PARKINSONS_DISEASE_AND_SECONDARY_PARKINSONISM", "comment": null}, "PERIPHERAL_VASCULAR_DISEASE_PVD": {"type": "NUMBER", "index": 60, "name": "PERIPHERAL_VASCULAR_DISEASE_PVD", "comment": null}, "PERSONALITY_DISORDERS": {"type": "NUMBER", "index": 61, "name": "PERSONALITY_DISORDERS", "comment": null}, "PNEUMONIA_ALL_CAUSE": {"type": "NUMBER", "index": 62, "name": "PNEUMONIA_ALL_CAUSE", "comment": null}, "POST_TRAUMATIC_STRESS_DISORDER_PTSD": {"type": "NUMBER", "index": 63, "name": "POST_TRAUMATIC_STRESS_DISORDER_PTSD", "comment": null}, "PRESSURE_AND_CHRONIC_ULCERS": {"type": "NUMBER", "index": 64, "name": "PRESSURE_AND_CHRONIC_ULCERS", "comment": null}, "RHEUMATOID_ARTHRITIS_OSTEOARTHRITIS": {"type": "NUMBER", "index": 65, "name": "RHEUMATOID_ARTHRITIS_OSTEOARTHRITIS", "comment": null}, "SCHIZOPHRENIA": {"type": "NUMBER", "index": 66, "name": "SCHIZOPHRENIA", "comment": null}, "SCHIZOPHRENIA_AND_OTHER_PSYCHOTIC_DISORDERS": {"type": "NUMBER", "index": 67, "name": "SCHIZOPHRENIA_AND_OTHER_PSYCHOTIC_DISORDERS", "comment": null}, "SENSORY_BLINDNESS_AND_VISUAL_IMPAIRMENT": {"type": "NUMBER", "index": 68, "name": "SENSORY_BLINDNESS_AND_VISUAL_IMPAIRMENT", "comment": null}, "SENSORY_DEAFNESS_AND_HEARING_IMPAIRMENT": {"type": "NUMBER", "index": 69, "name": "SENSORY_DEAFNESS_AND_HEARING_IMPAIRMENT", "comment": null}, "SICKLE_CELL_DISEASE": {"type": "NUMBER", "index": 70, "name": "SICKLE_CELL_DISEASE", "comment": null}, "SPINA_BIFIDA_AND_OTHER_CONGENITAL_ANOMALIES_OF_THE_NERVOUS_SYSTEM": {"type": "NUMBER", "index": 71, "name": "SPINA_BIFIDA_AND_OTHER_CONGENITAL_ANOMALIES_OF_THE_NERVOUS_SYSTEM", "comment": null}, "SPINAL_CORD_INJURY": {"type": "NUMBER", "index": 72, "name": "SPINAL_CORD_INJURY", "comment": null}, "STROKE_TRANSIENT_ISCHEMIC_ATTACK": {"type": "NUMBER", "index": 73, "name": "STROKE_TRANSIENT_ISCHEMIC_ATTACK", "comment": null}, "TOBACCO_USE": {"type": "NUMBER", "index": 74, "name": "TOBACCO_USE", "comment": null}, "TRAUMATIC_BRAIN_INJURY_AND_NONPSYCHOTIC_MENTAL_DISORDERS_DUE_TO_BRAIN_DAMAGE": {"type": "NUMBER", "index": 75, "name": "TRAUMATIC_BRAIN_INJURY_AND_NONPSYCHOTIC_MENTAL_DISORDERS_DUE_TO_BRAIN_DAMAGE", "comment": null}, "VIRAL_HEPATITIS_GENERAL": {"type": "NUMBER", "index": 76, "name": "VIRAL_HEPATITIS_GENERAL", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 77, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"}, "model.the_tuva_project.ahrq_measures__int_pqi_05_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_05_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_num"}, "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "LOOKBACK_PERIOD_AUGUST": {"type": "DATE", "index": 6, "name": "LOOKBACK_PERIOD_AUGUST", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041__performance_period"}, "model.the_tuva_project.data_quality__claim_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PAYER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_payer"}, "seed.the_tuva_project.terminology__gender": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "GENDER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"GENDER": {"type": "TEXT", "index": 1, "name": "GENDER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__gender"}, "model.the_tuva_project.data_quality__pharmacy_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PAYER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_payer"}, "model.the_tuva_project.outpatient_surgery__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__generate_encounter_id"}, "model.the_tuva_project.outpatient_rehab__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__anchor_events"}, "model.the_tuva_project.data_quality__patient_longitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_LONGITUDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_longitude"}, "model.the_tuva_project.data_quality__lab_result_status": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_STATUS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_status"}, "model.the_tuva_project.data_quality__dx_and_px": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DX_AND_PX", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__dx_and_px"}, "model.the_tuva_project.data_quality__encounter_admit_type_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_TYPE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_description"}, "model.the_tuva_project.normalized_input__int_procedure_date_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_DATE_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 3, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 4, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 6, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 7, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 8, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 9, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 10, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 11, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 12, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 13, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 14, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 15, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 16, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 17, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 18, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 19, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 20, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 21, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 22, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 23, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 24, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 25, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 26, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 27, "name": "PROCEDURE_DATE_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_final"}, "model.the_tuva_project.data_quality__eligibility_race": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_RACE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_race"}, "model.the_tuva_project.service_category__outpatient_psychiatric_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_PSYCHIATRIC_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_professional"}, "model.the_tuva_project.data_quality__data_quality_for_pbi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_FOR_PBI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 2, "name": "FIELD_NAME", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 4, "name": "CLAIM_TYPE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 5, "name": "BUCKET_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 6, "name": "FIELD_VALUE", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 7, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 8, "name": "DRILL_DOWN_VALUE", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 10, "name": "SUMMARY_SK", "comment": null}, "FREQUENCY": {"type": "NUMBER", "index": 11, "name": "FREQUENCY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_for_pbi"}, "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 5, "name": "HCPCS_CODE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 6, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__quality_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "QUALITY_TREND", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"FIRST_DAY_OF_MONTH": {"type": "DATE", "index": 1, "name": "FIRST_DAY_OF_MONTH", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 2, "name": "SUMMARY_SK", "comment": null}, "VALID_NUM": {"type": "NUMBER", "index": 3, "name": "VALID_NUM", "comment": null}, "FILL_NUM": {"type": "NUMBER", "index": 4, "name": "FILL_NUM", "comment": null}, "DENOM": {"type": "NUMBER", "index": 5, "name": "DENOM", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__quality_trend"}, "model.the_tuva_project.office_visits__int_office_visits_union": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_UNION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "PRIORITY_NUMBER": {"type": "NUMBER", "index": 5, "name": "PRIORITY_NUMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_union"}, "model.the_tuva_project.encounters__stg_outpatient_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_OUTPATIENT_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_outpatient_institutional"}, "model.the_tuva_project.core__stg_claims_eligibility": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_ELIGIBILITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ELIGIBILITY_ID": {"type": "TEXT", "index": 1, "name": "ELIGIBILITY_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 3, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 4, "name": "SUBSCRIBER_ID", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 5, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 6, "name": "DEATH_DATE", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 7, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 8, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 9, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 10, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 12, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 13, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 14, "name": "MEDICARE_STATUS_CODE", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 15, "name": "SUBSCRIBER_RELATION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 16, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_eligibility"}, "model.the_tuva_project.data_quality__claim_claim_line_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_LINE_START_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_start_date"}, "model.the_tuva_project.mart_review__quality_measures_value_set": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__QUALITY_MEASURES_VALUE_SET", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 3, "name": "DESCRIPTION", "comment": null}, "VERSION": {"type": "TEXT", "index": 4, "name": "VERSION", "comment": null}, "STEWARD": {"type": "TEXT", "index": 5, "name": "STEWARD", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 17, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__quality_measures_value_set"}, "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ICD_10_PCS_TO_CCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "CCS_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CCS_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1416192, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 80493, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs"}, "model.the_tuva_project.data_quality__claim_claim_line_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_LINE_END_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_end_date"}, "model.the_tuva_project.service_category__outpatient_hospice_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPICE_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_professional"}, "model.the_tuva_project.data_quality__institutional_procedure_code_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_CODE_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_1"}, "model.the_tuva_project.mart_review__members_with_claims": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__MEMBERS_WITH_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "MEMBERS_WITH_MEDICAL_CLAIMS": {"type": "NUMBER", "index": 3, "name": "MEMBERS_WITH_MEDICAL_CLAIMS", "comment": null}, "MEMBERS_WITH_PHARMACY_CLAIMS": {"type": "NUMBER", "index": 4, "name": "MEMBERS_WITH_PHARMACY_CLAIMS", "comment": null}, "MEMBERS_WITH_CLAIMS": {"type": "NUMBER", "index": 5, "name": "MEMBERS_WITH_CLAIMS", "comment": null}, "TOTAL_MEMBER_MONTHS": {"type": "NUMBER", "index": 6, "name": "TOTAL_MEMBER_MONTHS", "comment": null}, "PERCENT_MEMBERS_WITH_CLAIMS": {"type": "NUMBER", "index": 7, "name": "PERCENT_MEMBERS_WITH_CLAIMS", "comment": null}, "PERCENT_MEMBERS_WITH_MEDICAL_CLAIMS": {"type": "NUMBER", "index": 8, "name": "PERCENT_MEMBERS_WITH_MEDICAL_CLAIMS", "comment": null}, "PERCENT_MEMBERS_WITH_PHARMACY_CLAIMS": {"type": "NUMBER", "index": 9, "name": "PERCENT_MEMBERS_WITH_PHARMACY_CLAIMS", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__members_with_claims"}, "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_2_ALLOWED_PIVOT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 6, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 7, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 8, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 9, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 10, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 11, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 12, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 13, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 14, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 15, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 16, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 17, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 18, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PTOTST_ALLOWED": {"type": "NUMBER", "index": 19, "name": "OFFICE_BASED_PTOTST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 20, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 21, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 22, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 23, "name": "OTHER_ALLOWED", "comment": null}, "OUTPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 24, "name": "OUTPATIENT_HOSPICE_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 25, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PTOTST_ALLOWED": {"type": "NUMBER", "index": 26, "name": "OUTPATIENT_PTOTST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 27, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 28, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 29, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 31, "name": "PHARMACY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 32, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 33, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 34, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot"}, "model.the_tuva_project.data_quality__lab_result_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_data_source"}, "model.the_tuva_project.pharmacy__brand_generic_opportunity": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "BRAND_GENERIC_OPPORTUNITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 4, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NDC_DESCRIPTION", "comment": null}, "BRAND_RXCUI": {"type": "TEXT", "index": 6, "name": "BRAND_RXCUI", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 7, "name": "BRAND_VS_GENERIC", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 8, "name": "GENERIC_AVAILABLE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "TOTAL_UNITS": {"type": "NUMBER", "index": 10, "name": "TOTAL_UNITS", "comment": null}, "BRAND_COST_PER_UNIT": {"type": "NUMBER", "index": 11, "name": "BRAND_COST_PER_UNIT", "comment": null}, "GENERIC_AVERAGE_COST_PER_UNIT": {"type": "NUMBER", "index": 12, "name": "GENERIC_AVERAGE_COST_PER_UNIT", "comment": null}, "BRAND_LESS_GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 13, "name": "BRAND_LESS_GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY": {"type": "NUMBER", "index": 14, "name": "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__brand_generic_opportunity"}, "model.the_tuva_project.data_quality__practitioner_specialty": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_SPECIALTY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_specialty"}, "model.the_tuva_project.urgent_care__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__anchor_events"}, "model.the_tuva_project.data_quality__eligibility_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_data_source"}, "model.the_tuva_project.quality_measures__int_cqm236_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_long"}, "model.the_tuva_project.data_quality__lab_result_lab_result_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_LAB_RESULT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_lab_result_id"}, "model.the_tuva_project.core__stg_claims_practitioner": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_PRACTITIONER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "PROVIDER_FIRST_NAME": {"type": "TEXT", "index": 3, "name": "PROVIDER_FIRST_NAME", "comment": null}, "PROVIDER_LAST_NAME": {"type": "TEXT", "index": 4, "name": "PROVIDER_LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_practitioner"}, "model.the_tuva_project.data_quality__data_quality_test_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_TEST_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 80, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_test_summary"}, "model.the_tuva_project.data_quality__observation_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_patient_id"}, "model.the_tuva_project.data_quality__observation_panel_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_PANEL_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_panel_id"}, "model.the_tuva_project.core__stg_clinical_condition": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_CONDITION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 16, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 17, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_condition"}, "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_VOLUME_AND_DOLLARS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "NUMBER", "index": 1, "name": "YEAR_MONTH", "comment": null}, "CLAIM_VOLUME": {"type": "NUMBER", "index": 2, "name": "CLAIM_VOLUME", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 3, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars"}, "model.the_tuva_project.data_quality__observation_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_data_source"}, "model.the_tuva_project.quality_measures__int_cqm130__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130__performance_period"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions"}, "model.the_tuva_project.mart_review__ed_classification": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__ED_CLASSIFICATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ED_CLASSIFICATION_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ED_CLASSIFICATION_DESCRIPTION", "comment": null}, "AVOIDABLE_CATEGORY": {"type": "TEXT", "index": 3, "name": "AVOIDABLE_CATEGORY", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 4, "name": "PAID_AMOUNT", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 5, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 6, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PRIMARY_DIAGNOSIS_AND_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_AND_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 8, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 9, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY_AND_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CCSR_PARENT_CATEGORY_AND_DESCRIPTION", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 12, "name": "BODY_SYSTEM", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 14, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 15, "name": "CHARGE_AMOUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 16, "name": "DATA_SOURCE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 17, "name": "LENGTH_OF_STAY", "comment": null}, "DISCHARGE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "DISCHARGE_CODE_AND_DESCRIPTION", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 19, "name": "PATIENT_SOURCE_KEY", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 20, "name": "FACILITY_NAME", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 21, "name": "ENCOUNTER_START_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 22, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__ed_classification"}, "model.the_tuva_project.data_quality__patient_death_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_DEATH_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_death_date"}, "model.the_tuva_project.data_quality__patient_latitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_LATITUDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_latitude"}, "model.the_tuva_project.data_quality__institutional_revenue_center_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_REVENUE_CENTER_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_revenue_center_code"}, "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_EXCLUDE_MASTECTOMY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy"}, "model.the_tuva_project.data_quality__lab_result_specimen": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SPECIMEN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_specimen"}, "model.the_tuva_project.mart_review__number_of_conditions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__NUMBER_OF_CONDITIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 3, "name": "PATIENT_SOURCE_KEY", "comment": null}, "NUMOFCONDITIONS": {"type": "NUMBER", "index": 4, "name": "NUMOFCONDITIONS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__number_of_conditions"}, "model.the_tuva_project.readmissions__encounter": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter"}, "seed.the_tuva_project.terminology__icd_9_cm": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_9_CM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_9_CM": {"type": "TEXT", "index": 1, "name": "ICD_9_CM", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "LONG_DESCRIPTION", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "SHORT_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 390144, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 14567, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_9_cm"}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "_VALUE_SET_DXCCSR_V2023_1_BODY_SYSTEMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BODY_SYSTEM": {"type": "TEXT", "index": 1, "name": "BODY_SYSTEM", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 2, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "PARENT_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "PARENT_CATEGORY_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 22, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"}, "model.the_tuva_project.core__patient": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PATIENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__patient"}, "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_05_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_denom"}, "model.the_tuva_project.data_quality__pharmacy_deductible_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DEDUCTIBLE_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_deductible_amount"}, "model.the_tuva_project.data_quality__encounter_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_patient_id"}, "model.the_tuva_project.emergency_department__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__prof_claims"}, "model.the_tuva_project.data_quality__institutional_admit_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_ADMIT_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_source_code"}, "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_FIELD_TO_MART", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"INPUT_LAYER_TABLE_NAME": {"type": "TEXT", "index": 1, "name": "INPUT_LAYER_TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 3, "name": "FIELD_NAME", "comment": null}, "MART_NAME": {"type": "TEXT", "index": 4, "name": "MART_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 307, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_to_mart"}, "model.the_tuva_project.data_quality__patient_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_patient_id"}, "model.the_tuva_project.data_quality__professional_claim_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_CLAIM_START_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_claim_start_date"}, "model.the_tuva_project.dialysis__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__generate_encounter_id"}, "model.the_tuva_project.urgent_care__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__match_claims_to_anchor"}, "model.the_tuva_project.normalized_input__eligibility": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "NORMALIZED_INPUT_ELIGIBILITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 2, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 3, "name": "SUBSCRIBER_ID", "comment": null}, "GENDER": {"type": "TEXT", "index": 4, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 9, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 10, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 11, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 12, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 13, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 14, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 15, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 16, "name": "MEDICARE_STATUS_CODE", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 17, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 18, "name": "LAST_NAME", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 19, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 20, "name": "SUBSCRIBER_RELATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 21, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 22, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 23, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 24, "name": "ZIP_CODE", "comment": null}, "PHONE": {"type": "TEXT", "index": 25, "name": "PHONE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__eligibility"}, "model.the_tuva_project.normalized_input__int_bill_type_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_BILL_TYPE_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_voting"}, "model.the_tuva_project.urgent_care__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__encounter_grain"}, "model.the_tuva_project.data_quality__procedure_procedure_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PROCEDURE_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_id"}, "model.the_tuva_project.inpatient_hospice__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__start_end_dates"}, "model.the_tuva_project.inpatient_psych__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__encounter_grain"}, "model.the_tuva_project.quality_measures__int_nqf0059_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_long"}, "model.the_tuva_project.outpatient_hospice__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__generate_encounter_id"}, "model.the_tuva_project.mart_review__quality_measures_summary_long": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__QUALITY_MEASURES_SUMMARY_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "PERFORMANCE_FLAG": {"type": "NUMBER", "index": 5, "name": "PERFORMANCE_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 6, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 7, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 8, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 9, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 11, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 12, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 13, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 14, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__quality_measures_summary_long"}, "model.the_tuva_project.data_quality__claim_coinsurance_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CONINSURANCE_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_coinsurance_amount"}, "seed.the_tuva_project.quality_measures__concepts": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_VALUE_SET_CONCEPTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_NAME": {"type": "TEXT", "index": 1, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 2, "name": "CONCEPT_OID", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 3, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 4, "name": "MEASURE_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 9216, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 372, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.quality_measures__concepts"}, "model.the_tuva_project.normalized_input__int_procedure_date_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_DATE_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_COLUMN": {"type": "TEXT", "index": 3, "name": "PROCEDURE_COLUMN", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 4, "name": "PROCEDURE_DATE", "comment": null}, "PROCEDURE_DATE_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "PROCEDURE_DATE_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_normalize"}, "model.the_tuva_project.data_quality__institutional_claim_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_CLAIM_START_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_start_date"}, "model.the_tuva_project.quality_measures__int_cbe0101_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "ENCOUNTER_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_DATE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_denominator"}, "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "VALUE_SET_MEMBER_RELEVANT_FIELDS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_ID": {"type": "TEXT", "index": 1, "name": "CONCEPT_ID", "comment": null}, "CONCEPT_NAME": {"type": "TEXT", "index": 2, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_TYPE": {"type": "TEXT", "index": 3, "name": "CONCEPT_TYPE", "comment": null}, "VALUE_SET_MEMBER_ID": {"type": "TEXT", "index": 4, "name": "VALUE_SET_MEMBER_ID", "comment": null}, "CODE": {"type": "TEXT", "index": 5, "name": "CODE", "comment": null}, "CODING_SYSTEM_ID": {"type": "TEXT", "index": 6, "name": "CODING_SYSTEM_ID", "comment": null}, "INCLUDE_DESCENDANTS": {"type": "TEXT", "index": 7, "name": "INCLUDE_DESCENDANTS", "comment": null}, "CODING_SYSTEM_NAME": {"type": "TEXT", "index": 8, "name": "CODING_SYSTEM_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 164864, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12164, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"}, "model.the_tuva_project.data_quality__lab_result_normalized_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_UNITS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_units"}, "model.the_tuva_project.data_quality__eligibility_missing_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MISSING_PAYER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_payer"}, "model.the_tuva_project.quality_measures__int_cqm130_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PROCEDURE_ENCOUNTER_DATE": {"type": "DATE", "index": 3, "name": "PROCEDURE_ENCOUNTER_DATE", "comment": null}, "CLAIMS_ENCOUNTER_DATE": {"type": "DATE", "index": 4, "name": "CLAIMS_ENCOUNTER_DATE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 7, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 8, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 9, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 10, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_denominator"}, "seed.the_tuva_project.terminology__mdc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MDC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MDC_CODE": {"type": "TEXT", "index": 1, "name": "MDC_CODE", "comment": null}, "MDC_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "MDC_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 25, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__mdc"}, "seed.input_layer.medical_claim_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "MEDICAL_CLAIM_SEED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 15, "name": "ADMIT_TYPE_CODE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 16, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 17, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 18, "name": "BILL_TYPE_CODE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 20, "name": "APR_DRG_CODE", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 21, "name": "REVENUE_CENTER_CODE", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 22, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 23, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 27, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 28, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 29, "name": "RENDERING_NPI", "comment": null}, "RENDERING_TIN": {"type": "NUMBER", "index": 30, "name": "RENDERING_TIN", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 31, "name": "BILLING_NPI", "comment": null}, "BILLING_TIN": {"type": "NUMBER", "index": 32, "name": "BILLING_TIN", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 33, "name": "FACILITY_NPI", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 34, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 35, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 36, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 37, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 38, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 39, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 40, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 41, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 42, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 43, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 44, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 45, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 46, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 47, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 48, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 49, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 50, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 93, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 94, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 95, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 96, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 97, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 98, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 99, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 100, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 101, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 119, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 120, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 121, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 122, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 123, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 124, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 125, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 126, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 127, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_25", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 144, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 145, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 146, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 147, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.medical_claim_seed"}, "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_exclusions"}, "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DISCHARGE_DISPOSITION_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_voting"}, "model.the_tuva_project.data_quality__medication_rxnorm_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_RXNORM_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_code"}, "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_ENCOUNTER_RANKING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_TYPE", "comment": null}, "PRIORITY_NUMBER": {"type": "NUMBER", "index": 3, "name": "PRIORITY_NUMBER", "comment": null}, "RELATIVE_RANK": {"type": "NUMBER", "index": 4, "name": "RELATIVE_RANK", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking"}, "seed.input_layer.eligibility_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "ELIGIBILITY_SEED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 2, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 3, "name": "SUBSCRIBER_ID", "comment": null}, "GENDER": {"type": "TEXT", "index": 4, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 9, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 10, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 11, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 12, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 13, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 14, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 15, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 16, "name": "MEDICARE_STATUS_CODE", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 17, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 18, "name": "LAST_NAME", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 19, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 20, "name": "SUBSCRIBER_RELATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 21, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 22, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 23, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 24, "name": "ZIP_CODE", "comment": null}, "PHONE": {"type": "TEXT", "index": 25, "name": "PHONE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 27, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 28, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.eligibility_seed"}, "model.the_tuva_project.ambulance__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__anchor_events"}, "model.the_tuva_project.data_quality__core_populated": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CORE_POPULATED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"TABLE_NAME": {"type": "TEXT", "index": 1, "name": "TABLE_NAME", "comment": null}, "RECORD_COUNT": {"type": "NUMBER", "index": 2, "name": "RECORD_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 8, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__core_populated"}, "model.the_tuva_project.data_quality__medical_claim_date_checks": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_DATE_CHECKS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_date_checks"}, "model.the_tuva_project.data_quality__medication_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_source_code"}, "model.the_tuva_project.core__condition": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "CONDITION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 16, "name": "MAPPING_METHOD", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 17, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__condition"}, "seed.the_tuva_project.terminology__encounter_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ENCOUNTER_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_TYPE": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_TYPE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 18, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__encounter_type"}, "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_16_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"}, "model.the_tuva_project.encounters__stg_medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_MEDICAL_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"APR_DRG_CODE": {"type": "TEXT", "index": 1, "name": "APR_DRG_CODE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 6, "name": "CLAIM_LINE_ID", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "START_DATE": {"type": "DATE", "index": 8, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 9, "name": "END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 10, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 11, "name": "DISCHARGE_DATE", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 16, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 17, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_3", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 19, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 21, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 22, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 23, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_5", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 27, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 29, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "MS_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 31, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 32, "name": "ADMIT_TYPE_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 33, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 37, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 38, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 39, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 40, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 41, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 42, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 43, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 44, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "MODALITY": {"type": "TEXT", "index": 45, "name": "MODALITY", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 46, "name": "BILLING_ID", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 47, "name": "RENDERING_ID", "comment": null}, "REND_PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 48, "name": "REND_PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 49, "name": "FACILITY_ID", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 50, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 51, "name": "PAID_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 52, "name": "CHARGE_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 53, "name": "ALLOWED_AMOUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 54, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 55, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_medical_claim"}, "model.the_tuva_project.data_quality__lab_result_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code"}, "model.the_tuva_project.quality_measures__int_cqm48_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_long"}, "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_ABNORMAL_FLAG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag"}, "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_08_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_denom"}, "model.the_tuva_project.core__encounter": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "ENCOUNTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}, "ENCOUNTER_SOURCE_TYPE": {"type": "TEXT", "index": 45, "name": "ENCOUNTER_SOURCE_TYPE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__encounter"}, "model.the_tuva_project.data_quality__eligibility_medicare_status_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MEDICARE_STATUS_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_medicare_status_code"}, "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_VALUE_SET_TUVA_CHRONIC_CONDITIONS_HIERARCHY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_FAMILY": {"type": "TEXT", "index": 1, "name": "CONDITION_FAMILY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 2, "name": "CONDITION", "comment": null}, "ICD_10_CM_CODE": {"type": "TEXT", "index": 3, "name": "ICD_10_CM_CODE", "comment": null}, "ICD_10_CM_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "ICD_10_CM_DESCRIPTION", "comment": null}, "CONDITION_COLUMN_NAME": {"type": "TEXT", "index": 5, "name": "CONDITION_COLUMN_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 35840, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1583, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy"}, "model.the_tuva_project.data_quality__patient_state": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_STATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_state"}, "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DISEASE_INTERACTION_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "HCC_CODE_1": {"type": "TEXT", "index": 2, "name": "HCC_CODE_1", "comment": null}, "HCC_CODE_2": {"type": "TEXT", "index": 3, "name": "HCC_CODE_2", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 4, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 5, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 6, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 7, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 8, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_interaction_factors"}, "model.the_tuva_project.quality_measures__int_nqf0097_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 8, "name": "DISCHARGE_DATE", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_denominator"}, "model.the_tuva_project.quality_measures__int_cbe0055_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_denominator"}, "model.the_tuva_project.data_quality__professional_diagnosis_code_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_DIAGNOSIS_CODE_3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_3"}, "model.the_tuva_project.data_quality__institutional_discharge_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DISCHARGE_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_date"}, "model.the_tuva_project.pharmacy__generic_available_list": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "GENERIC_AVAILABLE_LIST", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"GENERIC_AVAILABLE_SK": {"type": "NUMBER", "index": 1, "name": "GENERIC_AVAILABLE_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "BRAND_NDC_CODE": {"type": "TEXT", "index": 3, "name": "BRAND_NDC_CODE", "comment": null}, "BRAND_NDC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "BRAND_NDC_DESCRIPTION", "comment": null}, "BRAND_RXCUI": {"type": "TEXT", "index": 5, "name": "BRAND_RXCUI", "comment": null}, "BRAND_PAID_AMOUNT": {"type": "NUMBER", "index": 6, "name": "BRAND_PAID_AMOUNT", "comment": null}, "BRAND_UNITS": {"type": "NUMBER", "index": 7, "name": "BRAND_UNITS", "comment": null}, "BRAND_PAID_PER_UNIT": {"type": "NUMBER", "index": 8, "name": "BRAND_PAID_PER_UNIT", "comment": null}, "GENERIC_NDC": {"type": "TEXT", "index": 9, "name": "GENERIC_NDC", "comment": null}, "GENERIC_NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "GENERIC_NDC_DESCRIPTION", "comment": null}, "GENERIC_PRESCRIBED_HISTORY": {"type": "NUMBER", "index": 11, "name": "GENERIC_PRESCRIBED_HISTORY", "comment": null}, "GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 12, "name": "GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_COST_AT_UNITS": {"type": "NUMBER", "index": 13, "name": "GENERIC_COST_AT_UNITS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__generic_available_list"}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_DISCHARGE_DISPOSITION_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_code"}, "model.the_tuva_project.encounters__orphaned_claims": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__ORPHANED_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__orphaned_claims"}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_REFERENCE_RANGE_LOW", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_low"}, "model.the_tuva_project.data_quality__condition_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_NORMALIZED_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_description"}, "model.the_tuva_project.quality_measures__int_nqf0041_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_long"}, "model.the_tuva_project.service_category__stg_medical_claim": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "SERVICE_CATEGORY__STG_MEDICAL_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"APR_DRG_CODE": {"type": "TEXT", "index": 1, "name": "APR_DRG_CODE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_LINE_ID", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 5, "name": "CLAIM_TYPE", "comment": null}, "START_DATE": {"type": "DATE", "index": 6, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 7, "name": "END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 8, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 9, "name": "DISCHARGE_DATE", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_LINE_END_DATE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 14, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 16, "name": "HCPCS_CODE", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 17, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "MS_DRG_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 23, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 25, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 26, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 27, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 28, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 29, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "REND_PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "REND_PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "MODALITY": {"type": "TEXT", "index": 33, "name": "MODALITY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 34, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_medical_claim"}, "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_GENERIC_COST_BY_NDC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BRAND_RXCUI": {"type": "TEXT", "index": 1, "name": "BRAND_RXCUI", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "GENERIC_NDC_CODE": {"type": "TEXT", "index": 3, "name": "GENERIC_NDC_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 4, "name": "PAID_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 5, "name": "CLAIM_COUNT", "comment": null}, "TOTAL_UNITS": {"type": "NUMBER", "index": 6, "name": "TOTAL_UNITS", "comment": null}, "COST_PER_UNIT": {"type": "NUMBER", "index": 7, "name": "COST_PER_UNIT", "comment": null}, "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY": {"type": "NUMBER", "index": 8, "name": "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc"}, "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ACUTE_DIAGNOSIS_CCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 80, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_ccs"}, "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_SURGERY_GYNECOLOGY_COHORT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "CCS_CODE_AND_DESCRIPTION", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 4, "name": "SPECIALTY_COHORT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 28672, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1676, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__surgery_gynecology_cohort"}, "model.the_tuva_project.data_quality__professional_facility_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_FACILITY_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_facility_npi"}, "model.the_tuva_project.service_category__dialysis_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_DIALYSIS_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__dialysis_professional"}, "model.the_tuva_project.data_quality__eligibility_dual_status_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DUAL_STATUS_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_dual_status_code"}, "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_INST_HEADER_FIELDS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_inst_header_fields"}, "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_ENCOUNTER_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id"}, "model.the_tuva_project.data_quality__medication_rxnorm_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_RXNORM_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_description"}, "model.the_tuva_project.data_quality__institutional_present_on_admission_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PRESENT_ON_ADMISSION_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_1"}, "model.the_tuva_project.data_quality__condition_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_data_source"}, "model.the_tuva_project.data_quality__practitioner_first_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_FIRST_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_first_name"}, "model.the_tuva_project.quality_measures__int_nqf0420_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_long"}, "model.the_tuva_project.quality_measures__int_nqf0053_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_numerator"}, "model.the_tuva_project.data_quality__encounter_ms_drg_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_MS_DRG_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_description"}, "model.the_tuva_project.quality_measures__int_cqm48__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48__performance_period"}, "model.the_tuva_project.service_category__emergency_department_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_EMERGENCY_DEPARTMENT_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__emergency_department_professional"}, "model.the_tuva_project.core__stg_clinical_practitioner": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_PRACTITIONER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 3, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 4, "name": "LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_practitioner"}, "model.the_tuva_project.data_quality__financial_pmpm": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_FINANCIAL_PMPM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEMBER_MONTHS": {"type": "NUMBER", "index": 1, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PMPM": {"type": "NUMBER", "index": 2, "name": "TOTAL_PMPM", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__financial_pmpm"}, "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__patient_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_data_source"}, "model.the_tuva_project.service_category__stg_outpatient_institutional": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "SERVICE_CATEGORY__STG_OUTPATIENT_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_outpatient_institutional"}, "model.the_tuva_project.inpatient_rehab__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__prof_claims"}, "model.the_tuva_project.service_category__inpatient_rehab_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_REHAB_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_institutional"}, "model.the_tuva_project.urgent_care__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "URGENT_CARE__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.urgent_care__generate_encounter_id"}, "model.the_tuva_project.inpatient_snf__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__encounter_grain"}, "model.the_tuva_project.data_quality__claim_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_patient_id"}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "TUVA_CHRONIC_CONDITIONS_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CONDITION": {"type": "TEXT", "index": 2, "name": "CONDITION", "comment": null}, "FIRST_DIAGNOSIS_DATE": {"type": "DATE", "index": 3, "name": "FIRST_DIAGNOSIS_DATE", "comment": null}, "LAST_DIAGNOSIS_DATE": {"type": "DATE", "index": 4, "name": "LAST_DIAGNOSIS_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"}, "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__procedure_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_NORMALIZED_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code_type"}, "model.the_tuva_project.data_quality__claim_total_cost_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_TOTAL_COST_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_total_cost_amount"}, "model.the_tuva_project.service_category__ambulatory_surgery_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULATORY_SURGERY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_professional"}, "model.the_tuva_project.data_quality__claim_paid_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PAID_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_paid_amount"}, "model.the_tuva_project.quality_measures__int_cqm438_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_long"}, "model.the_tuva_project.data_quality__patient_first_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_FIRST_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_first_name"}, "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_COINSURANCE_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount"}, "model.the_tuva_project.hcc_suspecting__int_observation_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_OBSERVATION_SUSPECTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 3, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_RESULT": {"type": "TEXT", "index": 4, "name": "OBSERVATION_RESULT", "comment": null}, "CONDITION_CODE": {"type": "TEXT", "index": 5, "name": "CONDITION_CODE", "comment": null}, "CONDITION_DATE": {"type": "DATE", "index": 6, "name": "CONDITION_DATE", "comment": null}, "CONDITION_CONCEPT_NAME": {"type": "TEXT", "index": 7, "name": "CONDITION_CONCEPT_NAME", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 8, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "HCC_DESCRIPTION", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 10, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 11, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 12, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 13, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_observation_suspects"}, "model.the_tuva_project.asc__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__match_claims_to_anchor"}, "model.the_tuva_project.dme__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DME__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__anchor_events"}, "model.the_tuva_project.service_category__outpatient_surgery_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SURGERY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_professional"}, "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_PATIENT_SPEND_WITH_SERVICE_CATEGORIES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_2", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 7, "name": "TOTAL_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 8, "name": "TOTAL_ALLOWED", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 9, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"}, "seed.the_tuva_project.quality_measures__measures": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_VALUE_SET_MEASURES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 3, "name": "DESCRIPTION", "comment": null}, "VERSION": {"type": "TEXT", "index": 4, "name": "VERSION", "comment": null}, "STEWARD": {"type": "TEXT", "index": 5, "name": "STEWARD", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4608, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 17, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.quality_measures__measures"}, "model.the_tuva_project.service_category__urgent_care_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_URGENT_CARE_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__urgent_care_institutional"}, "model.the_tuva_project.data_quality__practitioner_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_data_source"}, "model.the_tuva_project.data_quality__pharmacy_paid_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PAID_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_date"}, "model.the_tuva_project.data_quality__lab_result_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_description"}, "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_EXCLUDE_COLECTOMY_CANCER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer"}, "model.the_tuva_project.data_quality__professional_diagnosis_code_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_DIAGNOSIS_CODE_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_1"}, "model.the_tuva_project.mart_review__pmpm": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PMPM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 2, "name": "PAYER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 4, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 5, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 6, "name": "MEDICAL_PAID", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 7, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 8, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 9, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 10, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 11, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 12, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 13, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 14, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 15, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 16, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 17, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 18, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 19, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 20, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 21, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 22, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 23, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 24, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 25, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 26, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 27, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 28, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 29, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 31, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 32, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 33, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 34, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 35, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 36, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 37, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 38, "name": "URGENT_CARE_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 39, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 40, "name": "MEDICAL_ALLOWED", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 41, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 42, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 43, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 44, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 45, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 46, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 47, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 48, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 49, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 50, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 51, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 52, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 53, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 54, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 55, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 56, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 57, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 58, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 59, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 60, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 61, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 62, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 63, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 64, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 65, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 70, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 71, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 72, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 73, "name": "TUVA_LAST_RUN", "comment": null}, "TOTAL_PAID_ABSOLUTE": {"type": "NUMBER", "index": 74, "name": "TOTAL_PAID_ABSOLUTE", "comment": null}, "MEDICAL_PAID_ABSOLUTE": {"type": "NUMBER", "index": 75, "name": "MEDICAL_PAID_ABSOLUTE", "comment": null}, "PHARMACY_PAID_ABSOLUTE": {"type": "NUMBER", "index": 76, "name": "PHARMACY_PAID_ABSOLUTE", "comment": null}, "INPATIENT_PAID_ABSOLUTE": {"type": "NUMBER", "index": 77, "name": "INPATIENT_PAID_ABSOLUTE", "comment": null}, "OUTPATIENT_PAID_ABSOLUTE": {"type": "NUMBER", "index": 78, "name": "OUTPATIENT_PAID_ABSOLUTE", "comment": null}, "OFFICE_BASED_PAID_ABSOLUTE": {"type": "NUMBER", "index": 79, "name": "OFFICE_BASED_PAID_ABSOLUTE", "comment": null}, "ANCILLARY_PAID_ABSOLUTE": {"type": "NUMBER", "index": 80, "name": "ANCILLARY_PAID_ABSOLUTE", "comment": null}, "OTHER_PAID_ABSOLUTE": {"type": "NUMBER", "index": 81, "name": "OTHER_PAID_ABSOLUTE", "comment": null}, "DATA_SOURCE_MONTH_KEY": {"type": "TEXT", "index": 82, "name": "DATA_SOURCE_MONTH_KEY", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__pmpm"}, "model.the_tuva_project.readmissions__exclusion": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_EXCLUSION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__exclusion"}, "model.the_tuva_project.normalized_input__int_present_on_admit_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PRESENT_ON_ADMIT_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_voting"}, "model.the_tuva_project.quality_measures__int_cqm48_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_exclusions"}, "seed.the_tuva_project.reference_data__fips_county": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "FIPS_COUNTY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"FIPS_CODE": {"type": "TEXT", "index": 1, "name": "FIPS_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 2, "name": "COUNTY", "comment": null}, "STATE": {"type": "TEXT", "index": 3, "name": "STATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 31232, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3232, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__fips_county"}, "model.the_tuva_project.data_quality__pharmacy_claim_line_number": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_LINE_NUMBER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_line_number"}, "model.the_tuva_project.inpatient_snf__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__prof_claims"}, "model.the_tuva_project.service_category__acute_inpatient_institutional_other": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_INSTITUTIONAL_OTHER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_other"}, "model.the_tuva_project.mart_review__claims_with_enrollment": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__CLAIMS_WITH_ENROLLMENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "CLAIMS_WITH_ENROLLMENT": {"type": "NUMBER", "index": 3, "name": "CLAIMS_WITH_ENROLLMENT", "comment": null}, "CLAIMS": {"type": "NUMBER", "index": 4, "name": "CLAIMS", "comment": null}, "PERCENTAGE_CLAIMS_WITH_ENROLLMENT": {"type": "NUMBER", "index": 5, "name": "PERCENTAGE_CLAIMS_WITH_ENROLLMENT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__claims_with_enrollment"}, "model.the_tuva_project.data_quality__location_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_npi"}, "model.the_tuva_project.quality_measures__int_nqf0053_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_long"}, "model.the_tuva_project.data_quality__lab_result_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_patient_id"}, "model.the_tuva_project.data_quality__patient_death_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_DEATH_FLAG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_death_flag"}, "model.the_tuva_project.data_quality__procedure_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_NORMALIZED_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code"}, "seed.the_tuva_project.terminology__present_on_admission": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PRESENT_ON_ADMISSION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 1, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__present_on_admission"}, "seed.the_tuva_project.pqi__value_sets": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "_VALUE_SET_PQI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "VALUE_SET_NAME": {"type": "TEXT", "index": 2, "name": "VALUE_SET_NAME", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 3, "name": "PQI_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 46592, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 6059, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.pqi__value_sets"}, "model.the_tuva_project.encounters__stg_inpatient_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_INPATIENT_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_inpatient_institutional"}, "model.the_tuva_project.data_quality__observation_source_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_UNITS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_units"}, "seed.the_tuva_project.terminology__bill_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "BILL_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BILL_TYPE_CODE": {"type": "TEXT", "index": 1, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "DEPRECATED": {"type": "NUMBER", "index": 3, "name": "DEPRECATED", "comment": null}, "DEPRECATED_DATE": {"type": "DATE", "index": 4, "name": "DEPRECATED_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 22016, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1701, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__bill_type"}, "model.the_tuva_project.data_quality__institutional_rendering_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_RENDERING_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_rendering_npi"}, "seed.the_tuva_project.readmissions__specialty_cohort": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_SPECIALTY_COHORT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS": {"type": "TEXT", "index": 1, "name": "CCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 3, "name": "SPECIALTY_COHORT", "comment": null}, "PROCEDURE_OR_DIAGNOSIS": {"type": "TEXT", "index": 4, "name": "PROCEDURE_OR_DIAGNOSIS", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8192, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 276, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__specialty_cohort"}, "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_patient_id"}, "model.the_tuva_project.office_visits__int_office_visits": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 7, "name": "SERVICE_CATEGORY_3", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 8, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits"}, "model.the_tuva_project.data_quality__pharmacy_allowed_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_ALLOWED_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_allowed_amount"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_FRAILTY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty"}, "model.the_tuva_project.mart_review__service_categories_long": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__SERVICE_CATEGORIES_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "PAID_AMT": {"type": "NUMBER", "index": 5, "name": "PAID_AMT", "comment": null}, "VISITS": {"type": "NUMBER", "index": 6, "name": "VISITS", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__service_categories_long"}, "model.the_tuva_project.outpatient_injections__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__generate_encounter_id"}, "model.the_tuva_project.data_quality__procedure_procedure_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PROCEDURE_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_date"}, "seed.the_tuva_project.data_quality__crosswalk_field_info": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_FIELD_INFO", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"INPUT_LAYER_TABLE_NAME": {"type": "TEXT", "index": 1, "name": "INPUT_LAYER_TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 3, "name": "FIELD_NAME", "comment": null}, "RED": {"type": "NUMBER", "index": 4, "name": "RED", "comment": null}, "GREEN": {"type": "NUMBER", "index": 5, "name": "GREEN", "comment": null}, "UNIQUE_VALUES_EXPECTED_FLAG": {"type": "NUMBER", "index": 6, "name": "UNIQUE_VALUES_EXPECTED_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5632, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 305, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_info"}, "model.the_tuva_project.acute_inpatient__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 14, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 15, "name": "ED_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 20, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 21, "name": "FACILITY_TYPE", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 22, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 23, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 24, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 25, "name": "NICU_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 26, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 28, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 29, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 31, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 33, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 35, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 37, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 38, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 39, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 42, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 43, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 44, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 45, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 46, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__encounter_grain"}, "model.the_tuva_project.data_quality__ed_classification_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ED_CLASSIFICATION_REFERENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 5, "name": "VALUE_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 9, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__ed_classification_reference"}, "model.the_tuva_project.normalized_input__int_discharge_disposition_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DISCHARGE_DISPOSITION_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_final"}, "model.the_tuva_project.data_quality__lab_result_accession_number": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_ACCESSION_NUMBER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_accession_number"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_HOSPICE_PALLIATIVE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"}, "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097__performance_period"}, "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_14_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions"}, "model.the_tuva_project.outpatient_hospice__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__encounter_grain"}, "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_PREP_EGFR_LABS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "CODE_TYPE": {"type": "TEXT", "index": 3, "name": "CODE_TYPE", "comment": null}, "CODE": {"type": "TEXT", "index": 4, "name": "CODE", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 5, "name": "RESULT_DATE", "comment": null}, "RESULT": {"type": "NUMBER", "index": 6, "name": "RESULT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs"}, "model.the_tuva_project.data_quality__eligibility_demographics": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DEMOGRAPHICS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_demographics"}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_COST_AND_UTILIZATION_TREND", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "PKPY": {"type": "NUMBER", "index": 4, "name": "PKPY", "comment": null}, "PAID_PER": {"type": "NUMBER", "index": 5, "name": "PAID_PER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend"}, "model.the_tuva_project.office_visit__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISIT__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 14, "name": "BILLING_ID", "comment": null}, "PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "PROVIDER_NAME", "comment": null}, "PROVIDER_SPECIALTY": {"type": "TEXT", "index": 16, "name": "PROVIDER_SPECIALTY", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 17, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 18, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 19, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 20, "name": "PHARMACY_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 21, "name": "HCPCS_CODE", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 22, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 24, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 25, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 26, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 27, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 28, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 29, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 30, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 31, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visit__encounter_grain"}, "model.the_tuva_project.data_quality__patient_county": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_COUNTY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_county"}, "model.the_tuva_project.data_quality__institutional_present_on_admission_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PRESENT_ON_ADMISSION_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_2"}, "model.the_tuva_project.quality_measures__int_nqf0053_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 2, "name": "RECORDED_DATE", "comment": null}, "AGE": {"type": "NUMBER", "index": 3, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_denominator"}, "model.the_tuva_project.data_quality__claim_deductible_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DEDUCTIBLE_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_deductible_amount"}, "model.the_tuva_project.data_quality__institutional_bill_type_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_BILL_TYPE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_bill_type_code"}, "model.the_tuva_project.data_quality__observation_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_description"}, "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_PATIENT_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_patient_patient_id"}, "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_1_PAID_PIVOT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 6, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 7, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 8, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 9, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 10, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 11, "name": "PHARMACY_PAID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot"}, "model.the_tuva_project.data_quality__lab_result_source_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_UNITS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_units"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_UNGROUPABLE_DRG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg"}, "seed.the_tuva_project.terminology__medicare_status": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MEDICARE_STATUS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 1, "name": "MEDICARE_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "MEDICARE_STATUS_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 5, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__medicare_status"}, "model.the_tuva_project.data_quality__medication_ndc_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_NDC_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_description"}, "model.the_tuva_project.ahrq_measures__pqi_summary": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PQI_NUMBER": {"type": "TEXT", "index": 1, "name": "PQI_NUMBER", "comment": null}, "PQI_NAME": {"type": "TEXT", "index": 2, "name": "PQI_NAME", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 6, "name": "PATIENT_ID", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 7, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 8, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "MS_DRG_DESCRIPTION", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 10, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 11, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 12, "name": "LENGTH_OF_STAY", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 13, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_summary"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR_CRITERIA1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1"}, "model.the_tuva_project.service_category__inpatient_substance_use_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_SUBSTANCE_USE_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_substance_use_institutional"}, "model.the_tuva_project.normalized_input__int_ms_drg_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MS_DRG_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_final"}, "model.the_tuva_project.data_quality__eligibility_address": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_ADDRESS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_address"}, "model.the_tuva_project.data_quality__lab_result_normalized_component": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_COMPONENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_component"}, "model.the_tuva_project.data_quality__pharmacy_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_patient_id"}, "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_DATE_CHECKS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_date_checks"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_MISSING_PRIMARY_DX", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx"}, "model.the_tuva_project.core__eligibility": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "ELIGIBILITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ELIGIBILITY_ID": {"type": "TEXT", "index": 1, "name": "ELIGIBILITY_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 3, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 4, "name": "SUBSCRIBER_ID", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 5, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 6, "name": "DEATH_DATE", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 7, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 8, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 9, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 10, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 12, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 13, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 14, "name": "MEDICARE_STATUS_CODE", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 15, "name": "SUBSCRIBER_RELATION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 16, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__eligibility"}, "model.the_tuva_project.data_quality__eligibility_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_START_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_start_date"}, "model.the_tuva_project.data_quality__encounter_encounter_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_type"}, "model.the_tuva_project.data_quality__claim_charge_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CHARGE_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_charge_amount"}, "model.the_tuva_project.ccsr__dx_vertical_pivot": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "DX_VERTICAL_PIVOT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "CODE_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_RANK": {"type": "NUMBER", "index": 6, "name": "CCSR_CATEGORY_RANK", "comment": null}, "IS_IP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 7, "name": "IS_IP_DEFAULT_CATEGORY", "comment": null}, "IS_OP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 8, "name": "IS_OP_DEFAULT_CATEGORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2390528, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 86288, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__dx_vertical_pivot"}, "model.the_tuva_project.data_quality__lab_result_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code_type"}, "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_EXCLUSION_CCS_DIAGNOSIS_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "EXCLUSION_CATEGORY": {"type": "TEXT", "index": 3, "name": "EXCLUSION_CATEGORY", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 47, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category"}, "model.the_tuva_project.inpatient_snf__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__start_end_dates"}, "model.the_tuva_project.data_quality__medication_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_SOURCE_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_source_code_type"}, "model.the_tuva_project.data_quality__medication_dispensing_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_DISPENSING_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_dispensing_date"}, "model.the_tuva_project.data_quality__data_loss": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_LOSS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"TABLE_NAME": {"type": "TEXT", "index": 1, "name": "TABLE_NAME", "comment": null}, "METRIC": {"type": "TEXT", "index": 2, "name": "METRIC", "comment": null}, "INPUT_LAYER_VALUE": {"type": "FLOAT", "index": 3, "name": "INPUT_LAYER_VALUE", "comment": null}, "CORE_VALUE": {"type": "NUMBER", "index": 4, "name": "CORE_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_loss"}, "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_INT_FILTER_ENCOUNTER_WITH_CLASSIFICATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_END_DATE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 5, "name": "FACILITY_ID", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 10, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 11, "name": "CHARGE_AMOUNT", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 12, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 13, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 14, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 15, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 16, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 17, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 18, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 19, "name": "DRUG", "comment": null}, "ED_CLASSIFICATION_CAPTURE": {"type": "NUMBER", "index": 20, "name": "ED_CLASSIFICATION_CAPTURE", "comment": null}, "CLASSIFICATION": {"type": "TEXT", "index": 21, "name": "CLASSIFICATION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification"}, "model.the_tuva_project.normalized_input__int_medical_npi_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MEDICAL_NPI_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_RENDERING_NPI": {"type": "TEXT", "index": 5, "name": "NORMALIZED_RENDERING_NPI", "comment": null}, "NORMALIZED_RENDERING_NAME": {"type": "TEXT", "index": 6, "name": "NORMALIZED_RENDERING_NAME", "comment": null}, "NORMALIZED_BILLING_NPI": {"type": "TEXT", "index": 7, "name": "NORMALIZED_BILLING_NPI", "comment": null}, "NORMALIZED_BILLING_NAME": {"type": "TEXT", "index": 8, "name": "NORMALIZED_BILLING_NAME", "comment": null}, "NORMALIZED_FACILITY_NPI": {"type": "TEXT", "index": 9, "name": "NORMALIZED_FACILITY_NPI", "comment": null}, "NORMALIZED_FACILITY_NAME": {"type": "TEXT", "index": 10, "name": "NORMALIZED_FACILITY_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_medical_npi_normalize"}, "model.the_tuva_project.outpatient_injections__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 20, "name": "HCPCS_CODE", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__encounter_grain"}, "seed.input_layer.observation_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "OBSERVATION_SEED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "RESULT": {"type": "TEXT", "index": 13, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 14, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 15, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 16, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 18, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 21, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.observation_seed"}, "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_MEASURE_REASONABLE_RANGES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_NAME": {"type": "TEXT", "index": 1, "name": "MEASURE_NAME", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 2, "name": "PAYER_TYPE", "comment": null}, "LOWER_BOUND": {"type": "FLOAT", "index": 3, "name": "LOWER_BOUND", "comment": null}, "UPPER_BOUND": {"type": "FLOAT", "index": 4, "name": "UPPER_BOUND", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 48, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges"}, "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "_VALUE_SET_PRCCSR_V2023_1_CLEANED_MAP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "ICD_10_PCS_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ICD_10_PCS_DESCRIPTION", "comment": null}, "PRCCSR": {"type": "TEXT", "index": 3, "name": "PRCCSR", "comment": null}, "PRCCSR_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "PRCCSR_DESCRIPTION", "comment": null}, "CLINICAL_DOMAIN": {"type": "TEXT", "index": 5, "name": "CLINICAL_DOMAIN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1539584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 81597, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map"}, "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__generate_encounter_id"}, "model.the_tuva_project.outpatient_injections__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_INJECTIONS__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_injections__anchor_events"}, "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ELIGIBILITY_DATES_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PATIENT_ID_KEY": {"type": "TEXT", "index": 2, "name": "PATIENT_ID_KEY", "comment": null}, "NORMALIZED_BIRTH_DATE": {"type": "DATE", "index": 3, "name": "NORMALIZED_BIRTH_DATE", "comment": null}, "NORMALIZED_DEATH_DATE": {"type": "DATE", "index": 4, "name": "NORMALIZED_DEATH_DATE", "comment": null}, "NORMALIZED_ENROLLMENT_START_DATE": {"type": "DATE", "index": 5, "name": "NORMALIZED_ENROLLMENT_START_DATE", "comment": null}, "NORMALIZED_ENROLLMENT_END_DATE": {"type": "DATE", "index": 6, "name": "NORMALIZED_ENROLLMENT_END_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize"}, "model.the_tuva_project.cms_hcc__int_disease_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DISEASE_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 2, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "HCC_DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 4, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 5, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 6, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 7, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_factors"}, "seed.the_tuva_project.terminology__hcpcs_level_2": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "HCPCS_LEVEL_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS": {"type": "TEXT", "index": 1, "name": "HCPCS", "comment": null}, "SEQNUM": {"type": "TEXT", "index": 2, "name": "SEQNUM", "comment": null}, "RECID": {"type": "TEXT", "index": 3, "name": "RECID", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "LONG_DESCRIPTION", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "SHORT_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 368640, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7500, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__hcpcs_level_2"}, "model.the_tuva_project.service_category__office_based_radiology": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_RADIOLOGY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_radiology"}, "model.the_tuva_project.data_quality__medication_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_encounter_id"}, "model.the_tuva_project.data_quality__eligibility_zip_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_ZIP_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_zip_code"}, "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_exclusions"}, "model.the_tuva_project.data_quality__quality_measures": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_QUALITY_MEASURES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__quality_measures"}, "model.the_tuva_project.data_quality__eligibility_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_TREND", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 2, "name": "MEMBER_MONTHS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_trend"}, "model.the_tuva_project.data_quality__primary_key_check": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEY_CHECK", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_key_check"}, "model.the_tuva_project.service_category__inpatient_rehab_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_REHAB_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_professional"}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_EXCLUSIONS_STAGE_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"}, "model.the_tuva_project.data_quality__claim_hcpcs_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_HCPCS_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_hcpcs_code"}, "model.the_tuva_project.ahrq_measures__int_pqi_08_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_08_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_num"}, "model.the_tuva_project.service_category__service_category_grouper": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY_GROUPER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "ORIGINAL_SERVICE_CAT_2": {"type": "TEXT", "index": 7, "name": "ORIGINAL_SERVICE_CAT_2", "comment": null}, "ORIGINAL_SERVICE_CAT_3": {"type": "TEXT", "index": 8, "name": "ORIGINAL_SERVICE_CAT_3", "comment": null}, "DUPLICATE_ROW_NUMBER": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_ROW_NUMBER", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 10, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 12, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "MS_DRG_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 14, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 16, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 17, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 18, "name": "HCPCS_CODE", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 19, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 20, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 21, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 22, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 23, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "MODALITY": {"type": "TEXT", "index": 25, "name": "MODALITY", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 26, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 28, "name": "SOURCE_MODEL_NAME", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 29, "name": "DATA_SOURCE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__service_category_grouper"}, "model.the_tuva_project.data_quality__chronic_conditions_prevalence": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CHRONIC_CONDITIONS_PREVALENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "PATIENTS": {"type": "NUMBER", "index": 3, "name": "PATIENTS", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 4, "name": "VALUE_RANK", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 5, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 6, "name": "ANALYTICS_VALUE", "comment": null}, "MEDICARE_LDS_CONDITION_RANK": {"type": "NUMBER", "index": 7, "name": "MEDICARE_LDS_CONDITION_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 10, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_prevalence"}, "model.the_tuva_project.encounters__combined_claim_line_crosswalk": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__COMBINED_CLAIM_LINE_CROSSWALK", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "PRIORITY_NUMBER": {"type": "NUMBER", "index": 7, "name": "PRIORITY_NUMBER", "comment": null}, "CLAIM_LINE_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 8, "name": "CLAIM_LINE_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__combined_claim_line_crosswalk"}, "model.the_tuva_project.data_quality__practitioner_last_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_LAST_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_last_name"}, "model.the_tuva_project.service_category__acute_inpatient_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_professional"}, "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_VALUE_SET_ICD_10_CM_MAPPINGS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DIAGNOSIS_CODE": {"type": "TEXT", "index": 1, "name": "DIAGNOSIS_CODE", "comment": null}, "CMS_HCC_ESRD_V21": {"type": "TEXT", "index": 2, "name": "CMS_HCC_ESRD_V21", "comment": null}, "CMS_HCC_ESRD_V24": {"type": "TEXT", "index": 3, "name": "CMS_HCC_ESRD_V24", "comment": null}, "CMS_HCC_V22": {"type": "TEXT", "index": 4, "name": "CMS_HCC_V22", "comment": null}, "CMS_HCC_V24": {"type": "TEXT", "index": 5, "name": "CMS_HCC_V24", "comment": null}, "CMS_HCC_V28": {"type": "TEXT", "index": 6, "name": "CMS_HCC_V28", "comment": null}, "RX_HCC_V05": {"type": "TEXT", "index": 7, "name": "RX_HCC_V05", "comment": null}, "RX_HCC_V08": {"type": "TEXT", "index": 8, "name": "RX_HCC_V08", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 89088, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 11687, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings"}, "model.the_tuva_project.core__stg_clinical_lab_result": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_LAB_RESULT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 12, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 13, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 15, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 16, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 17, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 18, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 21, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "TEXT", "index": 23, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "TEXT", "index": 24, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 25, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 26, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_lab_result"}, "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_COMORBIDITY_SUSPECTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "HCC_DESCRIPTION", "comment": null}, "CONDITION_1_CONCEPT_NAME": {"type": "TEXT", "index": 5, "name": "CONDITION_1_CONCEPT_NAME", "comment": null}, "CONDITION_1_CODE": {"type": "TEXT", "index": 6, "name": "CONDITION_1_CODE", "comment": null}, "CONDITION_1_RECORDED_DATE": {"type": "DATE", "index": 7, "name": "CONDITION_1_RECORDED_DATE", "comment": null}, "CONDITION_2_CONCEPT_NAME": {"type": "TEXT", "index": 8, "name": "CONDITION_2_CONCEPT_NAME", "comment": null}, "CONDITION_2_CODE": {"type": "TEXT", "index": 9, "name": "CONDITION_2_CODE", "comment": null}, "CONDITION_2_RECORDED_DATE": {"type": "DATE", "index": 10, "name": "CONDITION_2_RECORDED_DATE", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 11, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 12, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 13, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 14, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects"}, "model.the_tuva_project.quality_measures__int_nqf0097_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_numerator"}, "model.the_tuva_project.inpatient_psych__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__generate_encounter_id"}, "model.the_tuva_project.data_quality__institutional_billing_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_BILLING_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_billing_npi"}, "model.the_tuva_project.data_quality__lab_result_collection_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_COLLECTION_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_collection_date"}, "seed.the_tuva_project.pharmacy__rxnorm_generic_available": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "RXNORM_GENERIC_AVAILABLE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRODUCT_TTY": {"type": "TEXT", "index": 1, "name": "PRODUCT_TTY", "comment": null}, "PRODUCT_RXCUI": {"type": "TEXT", "index": 2, "name": "PRODUCT_RXCUI", "comment": null}, "PRODUCT_NAME": {"type": "TEXT", "index": 3, "name": "PRODUCT_NAME", "comment": null}, "NDC_PRODUCT_TTY": {"type": "TEXT", "index": 4, "name": "NDC_PRODUCT_TTY", "comment": null}, "NDC_PRODUCT_RXCUI": {"type": "TEXT", "index": 5, "name": "NDC_PRODUCT_RXCUI", "comment": null}, "NDC_PRODUCT_NAME": {"type": "TEXT", "index": 6, "name": "NDC_PRODUCT_NAME", "comment": null}, "NDC": {"type": "TEXT", "index": 7, "name": "NDC", "comment": null}, "PRODUCT_STARTMARKETINGDATE": {"type": "DATE", "index": 8, "name": "PRODUCT_STARTMARKETINGDATE", "comment": null}, "PACKAGE_STARTMARKETINGDATE": {"type": "DATE", "index": 9, "name": "PACKAGE_STARTMARKETINGDATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 7484416, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 820285, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.pharmacy__rxnorm_generic_available"}, "model.the_tuva_project.quality_measures__int_cqm236_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_denominator"}, "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ICD_10_CM_TO_CCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "CCS_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CCS_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1313792, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 72776, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs"}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_DISCHARGE_DISPOSITION_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_description"}, "model.the_tuva_project.normalized_input__int_procedure_code_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_CODE_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 3, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_COLUMN": {"type": "TEXT", "index": 4, "name": "PROCEDURE_COLUMN", "comment": null}, "NORMALIZED_PROCEDURE_CODE": {"type": "TEXT", "index": 5, "name": "NORMALIZED_PROCEDURE_CODE", "comment": null}, "PROCEDURE_CODE_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "PROCEDURE_CODE_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_normalize"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_INT_CMS_CHRONIC_CONDITION_ALL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"}, "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_ORDERING_PRACTITIONER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id"}, "model.the_tuva_project.ahrq_measures__pqi_denom_long": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_DENOM_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 4, "name": "PQI_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_denom_long"}, "model.the_tuva_project.ahrq_measures__int_pqi_15_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_15_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_num"}, "model.the_tuva_project.ed_classification__int_map_primary_dx": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_INT_BY_PROVIDER_PARENT_ORGANIZATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_END_DATE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 5, "name": "FACILITY_ID", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 10, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 11, "name": "CHARGE_AMOUNT", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 12, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 13, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 14, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 15, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 16, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 17, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 18, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 19, "name": "DRUG", "comment": null}, "ED_CLASSIFICATION_CAPTURE": {"type": "NUMBER", "index": 20, "name": "ED_CLASSIFICATION_CAPTURE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ed_classification__int_map_primary_dx"}, "model.the_tuva_project.data_quality__eligibility_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_END_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_end_date"}, "model.the_tuva_project.readmissions__index_admission": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_INDEX_ADMISSION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__index_admission"}, "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420__performance_period"}, "model.the_tuva_project.service_category__lab_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_LAB_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__lab_professional"}, "model.the_tuva_project.service_category__observation_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OBSERVATION_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__observation_institutional"}, "model.the_tuva_project.ed_classification__summary": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ED_CLASSIFICATION_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ED_CLASSIFICATION_DESCRIPTION", "comment": null}, "ED_CLASSIFICATION_ORDER": {"type": "TEXT", "index": 3, "name": "ED_CLASSIFICATION_ORDER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_END_DATE", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 6, "name": "YEAR_MONTH", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 7, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 9, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 10, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 11, "name": "CHARGE_AMOUNT", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_STATE": {"type": "TEXT", "index": 14, "name": "FACILITY_STATE", "comment": null}, "FACILITY_CITY": {"type": "TEXT", "index": 15, "name": "FACILITY_CITY", "comment": null}, "FACILITY_ZIP_CODE": {"type": "TEXT", "index": 16, "name": "FACILITY_ZIP_CODE", "comment": null}, "PATIENT_SEX": {"type": "TEXT", "index": 17, "name": "PATIENT_SEX", "comment": null}, "PATIENT_AGE": {"type": "NUMBER", "index": 18, "name": "PATIENT_AGE", "comment": null}, "PATIENT_ZIP_CODE": {"type": "TEXT", "index": 19, "name": "PATIENT_ZIP_CODE", "comment": null}, "PATIENT_LATITUDE": {"type": "FLOAT", "index": 20, "name": "PATIENT_LATITUDE", "comment": null}, "PATIENT_LONGITUDE": {"type": "FLOAT", "index": 21, "name": "PATIENT_LONGITUDE", "comment": null}, "PATIENT_RACE": {"type": "TEXT", "index": 22, "name": "PATIENT_RACE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ed_classification__summary"}, "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "LOOKBACK_PERIOD_JUNE": {"type": "DATE", "index": 6, "name": "LOOKBACK_PERIOD_JUNE", "comment": null}, "LOOKBACK_PERIOD_DECEMBER": {"type": "DATE", "index": 7, "name": "LOOKBACK_PERIOD_DECEMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053__performance_period"}, "model.the_tuva_project.data_quality__data_quality_claims_detail": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLAIMS_DETAIL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 12, "name": "SUMMARY_SK", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_detail"}, "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_exclusions"}, "model.the_tuva_project.outpatient_substance_use__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__anchor_events"}, "model.the_tuva_project.data_quality__acute_inpatient": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ACUTE_INPATIENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient"}, "model.the_tuva_project.outpatient_hospice__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__anchor_events"}, "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_PRACTITIONER_PRACTITIONER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id"}, "model.the_tuva_project.core__stg_clinical_procedure": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_PROCEDURE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 12, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 13, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 14, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 15, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 16, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 17, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 18, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 19, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_procedure"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSIONS_MISSING_AGE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age"}, "model.the_tuva_project.data_quality__medical_claim_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_patient_id"}, "model.the_tuva_project.outpatient_ptotst__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__encounter_grain"}, "seed.the_tuva_project.cms_hcc__demographic_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DEMOGRAPHIC_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "PLAN_SEGMENT": {"type": "TEXT", "index": 4, "name": "PLAN_SEGMENT", "comment": null}, "GENDER": {"type": "TEXT", "index": 5, "name": "GENDER", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 6, "name": "AGE_GROUP", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 7, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 8, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 9, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 10, "name": "INSTITUTIONAL_STATUS", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 11, "name": "COEFFICIENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 13312, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 848, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__demographic_factors"}, "model.the_tuva_project.data_quality__patient_address": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_ADDRESS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_address"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_ADVANCED_ILLNESS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 5, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 6, "name": "CLAIM_END_DATE", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 7, "name": "PROCEDURE_DATE", "comment": null}, "PATIENT_TYPE": {"type": "TEXT", "index": 8, "name": "PATIENT_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness"}, "model.the_tuva_project.service_category__emergency_department_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_EMERGENCY_DEPARTMENT_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__emergency_department_institutional"}, "model.the_tuva_project.data_quality__claim_member_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_MEMBER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_member_id"}, "model.the_tuva_project.data_quality__condition_condition_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CONDITION_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_condition_type"}, "model.the_tuva_project.mart_review__tuva_chronic_conditions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__TUVA_CHRONIC_CONDITIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "CONDITION": {"type": "TEXT", "index": 3, "name": "CONDITION", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 4, "name": "PATIENT_SOURCE_KEY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__tuva_chronic_conditions"}, "seed.the_tuva_project.terminology__medicare_orec": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MEDICARE_OREC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 1, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ORIGINAL_REASON_ENTITLEMENT_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__medicare_orec"}, "seed.the_tuva_project.ed_classification__johnston_icd10": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_JOHNSTON_ICD10", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD10": {"type": "TEXT", "index": 1, "name": "ICD10", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 2, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 3, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 4, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 5, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 6, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 7, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 8, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 9, "name": "DRUG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 304128, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 47132, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd10"}, "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_PRESCRIPTION_DETAILS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details"}, "model.the_tuva_project.quality_measures__int_nqf0059_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_numerator"}, "model.the_tuva_project.data_quality__inpatient_dq_stage": {"metadata": {"type": "VIEW", "schema": "DATA_QUALITY", "name": "DATA_QUALITY__INPATIENT_DQ_STAGE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__inpatient_dq_stage"}, "model.the_tuva_project.data_quality__encounter_allowed_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ALLOWED_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_allowed_amount"}, "model.the_tuva_project.mart_review__member_months": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__MEMBER_MONTHS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 10, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 14, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 15, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 16, "name": "MEDICAL_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 17, "name": "PHARMACY_PAID", "comment": null}, "PATIENT_DATA_SOURCE_KEY": {"type": "TEXT", "index": 18, "name": "PATIENT_DATA_SOURCE_KEY", "comment": null}, "MEMBER_MONTH_KEY": {"type": "TEXT", "index": 19, "name": "MEMBER_MONTH_KEY", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__member_months"}, "model.the_tuva_project.quality_measures__int_adhras_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_exclusions"}, "seed.the_tuva_project.clinical_concept_library__clinical_concepts": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "CLINICAL_CONCEPTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_ID": {"type": "TEXT", "index": 1, "name": "CONCEPT_ID", "comment": null}, "CONCEPT_NAME": {"type": "TEXT", "index": 2, "name": "CONCEPT_NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 3, "name": "STATUS", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 4, "name": "CONCEPT_OID", "comment": null}, "LAST_UPDATE_DATE": {"type": "DATE", "index": 5, "name": "LAST_UPDATE_DATE", "comment": null}, "LAST_UPDATE_NOTE": {"type": "TEXT", "index": 6, "name": "LAST_UPDATE_NOTE", "comment": null}, "CONCEPT_TYPE": {"type": "TEXT", "index": 7, "name": "CONCEPT_TYPE", "comment": null}, "CONTENT_SOURCE": {"type": "TEXT", "index": 8, "name": "CONTENT_SOURCE", "comment": null}, "EXTERNAL_SOURCE_DETAIL": {"type": "TEXT", "index": 9, "name": "EXTERNAL_SOURCE_DETAIL", "comment": null}, "CONCEPT_SCOPE": {"type": "TEXT", "index": 10, "name": "CONCEPT_SCOPE", "comment": null}, "VALUE_SET_SEARCH_NOTES": {"type": "TEXT", "index": 11, "name": "VALUE_SET_SEARCH_NOTES", "comment": null}, "CODE": {"type": "TEXT", "index": 12, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "CODE_DESCRIPTION", "comment": null}, "CODING_SYSTEM_ID": {"type": "TEXT", "index": 14, "name": "CODING_SYSTEM_ID", "comment": null}, "CODING_SYSTEM_VERSION": {"type": "TEXT", "index": 15, "name": "CODING_SYSTEM_VERSION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 56320, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 197, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.clinical_concept_library__clinical_concepts"}, "model.the_tuva_project.service_category__home_health_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_HOME_HEALTH_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__home_health_institutional"}, "model.the_tuva_project.data_quality__procedure_modifier_5": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_5", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_5"}, "model.the_tuva_project.service_category__dialysis_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_DIALYSIS_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__dialysis_institutional"}, "model.the_tuva_project.data_quality__observation_source_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_REFERENCE_RANGE_LOW", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_low"}, "model.the_tuva_project.orphaned_claim__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ORPHANED_CLAIM__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 27, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 28, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 29, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.orphaned_claim__encounter_grain"}, "model.the_tuva_project.data_quality__lab_result_source_component": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_COMPONENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_component"}, "model.the_tuva_project.home_health__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__match_claims_to_anchor"}, "model.the_tuva_project.core__procedure": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PROCEDURE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 12, "name": "MAPPING_METHOD", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 13, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 14, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 15, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 16, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 17, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 18, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__procedure"}, "model.the_tuva_project.mart_review__patient_risk_scores": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT_RISK_SCORES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "V24_RISK_SCORE": {"type": "NUMBER", "index": 2, "name": "V24_RISK_SCORE", "comment": null}, "V28_RISK_SCORE": {"type": "NUMBER", "index": 3, "name": "V28_RISK_SCORE", "comment": null}, "BLENDED_RISK_SCORE": {"type": "NUMBER", "index": 4, "name": "BLENDED_RISK_SCORE", "comment": null}, "NORMALIZED_RISK_SCORE": {"type": "NUMBER", "index": 5, "name": "NORMALIZED_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE": {"type": "NUMBER", "index": 6, "name": "PAYMENT_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS": {"type": "NUMBER", "index": 7, "name": "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 8, "name": "MEMBER_MONTHS", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 9, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient_risk_scores"}, "model.the_tuva_project.service_category__combined_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_COMBINED_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 8, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__combined_professional"}, "model.the_tuva_project.data_quality__eligibility_city": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_CITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_city"}, "seed.the_tuva_project.terminology__snomed_ct": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "SNOMED_CT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SNOMED_CT": {"type": "TEXT", "index": 1, "name": "SNOMED_CT", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "IS_ACTIVE": {"type": "TEXT", "index": 3, "name": "IS_ACTIVE", "comment": null}, "CREATED": {"type": "DATE", "index": 4, "name": "CREATED", "comment": null}, "LAST_UPDATED": {"type": "DATE", "index": 5, "name": "LAST_UPDATED", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 17523712, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 517628, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__snomed_ct"}, "model.the_tuva_project.data_quality__eligibility_member_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MEMBER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_member_id"}, "model.the_tuva_project.ahrq_measures__int_pqi_07_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_07_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_num"}, "model.the_tuva_project.data_quality__institutional_admit_type_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_ADMIT_TYPE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_type_code"}, "model.the_tuva_project.ahrq_measures__int_pqi_14_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_14_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_num"}, "model.the_tuva_project.data_quality__condition_onset_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_ONSET_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_onset_date"}, "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_2_PAID_PIVOT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 6, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 7, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 8, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 9, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 10, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 11, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 12, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 13, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 14, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 15, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 16, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 17, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 18, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PTOTST_PAID": {"type": "NUMBER", "index": 19, "name": "OFFICE_BASED_PTOTST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 20, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 21, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 22, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 23, "name": "OTHER_PAID", "comment": null}, "OUTPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 24, "name": "OUTPATIENT_HOSPICE_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 25, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PTOTST_PAID": {"type": "NUMBER", "index": 26, "name": "OUTPATIENT_PTOTST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 27, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 28, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 29, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 31, "name": "PHARMACY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 32, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 33, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 34, "name": "URGENT_CARE_PAID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot"}, "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__generate_encounter_id"}, "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_15_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_denom"}, "model.the_tuva_project.data_quality__procedure_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_SOURCE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_source_description"}, "model.the_tuva_project.data_quality__observation_observation_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_OBSERVATION_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_observation_date"}, "model.the_tuva_project.data_quality__observation_result": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_RESULT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_result"}, "model.the_tuva_project.office_visits__int_office_visits_telehealth": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_TELEHEALTH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_telehealth"}, "model.the_tuva_project.data_quality__eligibility_death_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DEATH_FLAG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_flag"}, "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_PSYCHIATRIC_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_institutional"}, "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CROSSWALK_FIELD_TO_MART_SK", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"INPUT_LAYER_TABLE_NAME": {"type": "TEXT", "index": 1, "name": "INPUT_LAYER_TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 3, "name": "FIELD_NAME", "comment": null}, "MART_NAME": {"type": "TEXT", "index": 4, "name": "MART_NAME", "comment": null}, "TABLE_CLAIM_TYPE_FIELD_SK": {"type": "NUMBER", "index": 5, "name": "TABLE_CLAIM_TYPE_FIELD_SK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5632, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 306, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_INSTITUTIONAL_SNP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"}, "model.the_tuva_project.mart_review__stg_member_month": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__STG_MEMBER_MONTH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 10, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 14, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "YEAR_MONTH_INT": {"type": "NUMBER", "index": 15, "name": "YEAR_MONTH_INT", "comment": null}, "YEAR_MONTH_DATE": {"type": "DATE", "index": 16, "name": "YEAR_MONTH_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__stg_member_month"}, "model.the_tuva_project.quality_measures__int_cqm236_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclusions"}, "model.the_tuva_project.readmissions__encounter_data_quality": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_DATA_QUALITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 2, "name": "DIAGNOSIS_CCS", "comment": null}, "DISQUALIFIED_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 3, "name": "DISQUALIFIED_ENCOUNTER_FLAG", "comment": null}, "MISSING_ADMIT_DATE_FLAG": {"type": "NUMBER", "index": 4, "name": "MISSING_ADMIT_DATE_FLAG", "comment": null}, "MISSING_DISCHARGE_DATE_FLAG": {"type": "NUMBER", "index": 5, "name": "MISSING_DISCHARGE_DATE_FLAG", "comment": null}, "ADMIT_AFTER_DISCHARGE_FLAG": {"type": "NUMBER", "index": 6, "name": "ADMIT_AFTER_DISCHARGE_FLAG", "comment": null}, "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 7, "name": "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 8, "name": "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "MISSING_PRIMARY_DIAGNOSIS_FLAG": {"type": "NUMBER", "index": 9, "name": "MISSING_PRIMARY_DIAGNOSIS_FLAG", "comment": null}, "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG": {"type": "NUMBER", "index": 10, "name": "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG", "comment": null}, "NO_DIAGNOSIS_CCS_FLAG": {"type": "NUMBER", "index": 11, "name": "NO_DIAGNOSIS_CCS_FLAG", "comment": null}, "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 12, "name": "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG", "comment": null}, "MISSING_MS_DRG_FLAG": {"type": "NUMBER", "index": 13, "name": "MISSING_MS_DRG_FLAG", "comment": null}, "INVALID_MS_DRG_FLAG": {"type": "NUMBER", "index": 14, "name": "INVALID_MS_DRG_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_data_quality"}, "model.the_tuva_project.data_quality__condition_condition_rank": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CONDITION_RANK", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_condition_rank"}, "model.the_tuva_project.data_quality__pharmacy_plan": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PLAN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_plan"}, "model.the_tuva_project.service_category__outpatient_surgery_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SURGERY_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_institutional"}, "model.the_tuva_project.asc__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__anchor_events"}, "model.the_tuva_project.data_quality__location_state": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_STATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_state"}, "model.the_tuva_project.data_quality__condition_present_on_admit_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_PRESENT_ON_ADMIT_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_code"}, "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_CROSSWALK_MART_TO_OUTCOME_MEASURE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MART_NAME": {"type": "TEXT", "index": 1, "name": "MART_NAME", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure"}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_SKILLED_NURSING_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional"}, "model.the_tuva_project.inpatient_substance_use__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__start_end_dates"}, "model.the_tuva_project.hcc_suspecting__int_lab_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_LAB_SUSPECTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 3, "name": "RESULT_DATE", "comment": null}, "RESULT": {"type": "NUMBER", "index": 4, "name": "RESULT", "comment": null}, "LAB_CODE": {"type": "TEXT", "index": 5, "name": "LAB_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 6, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "HCC_DESCRIPTION", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 8, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 9, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 10, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 11, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_lab_suspects"}, "model.the_tuva_project.dialysis__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__match_claims_to_anchor"}, "model.the_tuva_project.quality_measures__int_adhras_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 2, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 3, "name": "EVIDENCE_VALUE", "comment": null}, "ADHERENCE": {"type": "NUMBER", "index": 4, "name": "ADHERENCE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 5, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_numerator"}, "model.the_tuva_project.encounters__patient_data_source_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__PATIENT_DATA_SOURCE_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__patient_data_source_id"}, "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_PATIENT_HCC_HISTORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 3, "name": "RECORDED_DATE", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CONDITION_TYPE", "comment": null}, "ICD_10_CM_CODE": {"type": "TEXT", "index": 5, "name": "ICD_10_CM_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 6, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "HCC_DESCRIPTION", "comment": null}, "FIRST_RECORDED": {"type": "DATE", "index": 8, "name": "FIRST_RECORDED", "comment": null}, "LAST_RECORDED": {"type": "DATE", "index": 9, "name": "LAST_RECORDED", "comment": null}, "LAST_BILLED": {"type": "DATE", "index": 10, "name": "LAST_BILLED", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 11, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 12, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 13, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 14, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"}, "model.the_tuva_project.service_category__ambulance_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULANCE_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulance_professional"}, "seed.the_tuva_project.cms_hcc__disease_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISEASE_HIERARCHY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 2, "name": "HCC_CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 3, "name": "DESCRIPTION", "comment": null}, "HCCS_TO_EXCLUDE": {"type": "TEXT", "index": 4, "name": "HCCS_TO_EXCLUDE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 221, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disease_hierarchy"}, "model.the_tuva_project.office_visits__int_office_visits_injections": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_INJECTIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_injections"}, "model.the_tuva_project.data_quality__location_location_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_LOCATION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_location_id"}, "model.the_tuva_project.data_quality__observation_source_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_REFERENCE_RANGE_HIGH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_high"}, "model.the_tuva_project.data_quality__summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SUMMARY_SK": {"type": "NUMBER", "index": 1, "name": "SUMMARY_SK", "comment": null}, "TABLE_CLAIM_TYPE_FIELD_SK": {"type": "NUMBER", "index": 2, "name": "TABLE_CLAIM_TYPE_FIELD_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 4, "name": "TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 5, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "RED": {"type": "NUMBER", "index": 7, "name": "RED", "comment": null}, "GREEN": {"type": "NUMBER", "index": 8, "name": "GREEN", "comment": null}, "VALID_NUM": {"type": "NUMBER", "index": 9, "name": "VALID_NUM", "comment": null}, "FILL_NUM": {"type": "NUMBER", "index": 10, "name": "FILL_NUM", "comment": null}, "DENOM": {"type": "NUMBER", "index": 11, "name": "DENOM", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__summary"}, "model.the_tuva_project.data_quality__analytics_reference_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ANALYTICS_REFERENCE_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 5, "name": "VALUE_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 35, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__analytics_reference_summary"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_long"}, "model.the_tuva_project.quality_measures__int_adhras__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras__performance_period"}, "model.the_tuva_project.data_quality__unique_value_examples": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "UNIQUE_VALUE_EXAMPLES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__unique_value_examples"}, "model.the_tuva_project.normalized_input__int_bill_type_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_BILL_TYPE_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_final"}, "model.the_tuva_project.data_quality__procedure_modifier_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_1"}, "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ACUTE_DIAGNOSIS_ICD_10_CM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 183808, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12333, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm"}, "model.the_tuva_project.data_quality__medication_quantity_unit": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_QUANTITY_UNIT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_quantity_unit"}, "model.the_tuva_project.core__stg_claims_condition": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_CONDITION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 16, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 17, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_condition"}, "model.the_tuva_project.data_quality__location_parent_organization": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_PARENT_ORGANIZATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_parent_organization"}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_REFERENCE_RANGE_LOW", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_low"}, "model.the_tuva_project.hcc_suspecting__int_prep_conditions": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_PREP_CONDITIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 2, "name": "RECORDED_DATE", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 3, "name": "CONDITION_TYPE", "comment": null}, "CODE_TYPE": {"type": "TEXT", "index": 4, "name": "CODE_TYPE", "comment": null}, "CODE": {"type": "TEXT", "index": 5, "name": "CODE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 6, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_conditions"}, "model.the_tuva_project.data_quality__encounter_length_of_stay": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_LENGTH_OF_STAY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_length_of_stay"}, "model.the_tuva_project.data_quality__practitioner_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_PRACTITIONER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_practitioner_id"}, "model.the_tuva_project.core__observation": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "OBSERVATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 13, "name": "MAPPING_METHOD", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 15, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 16, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 18, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 21, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__observation"}, "model.the_tuva_project.data_quality__pharmacy_ndc_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_NDC_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_ndc_code"}, "model.the_tuva_project.core__stg_claims_encounter": {"metadata": {"type": "BASE TABLE", "schema": "TEST", "name": "CORE__STG_CLAIMS_ENCOUNTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_encounter"}, "model.the_tuva_project.quality_measures__int_cqm130_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_numerator"}, "seed.the_tuva_project.terminology__loinc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "LOINC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOINC": {"type": "TEXT", "index": 1, "name": "LOINC", "comment": null}, "SHORT_NAME": {"type": "TEXT", "index": 2, "name": "SHORT_NAME", "comment": null}, "LONG_COMMON_NAME": {"type": "TEXT", "index": 3, "name": "LONG_COMMON_NAME", "comment": null}, "COMPONENT": {"type": "TEXT", "index": 4, "name": "COMPONENT", "comment": null}, "PROPERTY": {"type": "TEXT", "index": 5, "name": "PROPERTY", "comment": null}, "TIME_ASPECT": {"type": "TEXT", "index": 6, "name": "TIME_ASPECT", "comment": null}, "SYSTEM": {"type": "TEXT", "index": 7, "name": "SYSTEM", "comment": null}, "SCALE_TYPE": {"type": "TEXT", "index": 8, "name": "SCALE_TYPE", "comment": null}, "METHOD_TYPE": {"type": "TEXT", "index": 9, "name": "METHOD_TYPE", "comment": null}, "CLASS_CODE": {"type": "TEXT", "index": 10, "name": "CLASS_CODE", "comment": null}, "CLASS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CLASS_DESCRIPTION", "comment": null}, "CLASS_TYPE_CODE": {"type": "TEXT", "index": 12, "name": "CLASS_TYPE_CODE", "comment": null}, "CLASS_TYPE_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "CLASS_TYPE_DESCRIPTION", "comment": null}, "EXTERNAL_COPYRIGHT_NOTICE": {"type": "TEXT", "index": 14, "name": "EXTERNAL_COPYRIGHT_NOTICE", "comment": null}, "STATUS": {"type": "TEXT", "index": 15, "name": "STATUS", "comment": null}, "VERSION_FIRST_RELEASED": {"type": "TEXT", "index": 16, "name": "VERSION_FIRST_RELEASED", "comment": null}, "VERSION_LAST_CHANGED": {"type": "TEXT", "index": 17, "name": "VERSION_LAST_CHANGED", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4118528, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 101632, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__loinc"}, "model.the_tuva_project.normalized_input__int_procedure_date_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_DATE_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "DATE", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_voting"}, "model.the_tuva_project.data_quality__encounter_admit_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_code"}, "model.the_tuva_project.ahrq_measures__int_pqi_03_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_03_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_num"}, "model.the_tuva_project.data_quality__eligibility_dq_stage": {"metadata": {"type": "VIEW", "schema": "DATA_QUALITY", "name": "DATA_QUALITY__ELIGIBILITY_DQ_STAGE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "NUMBER", "index": 2, "name": "YEAR_MONTH", "comment": null}, "MONTH_START_DATE": {"type": "DATE", "index": 3, "name": "MONTH_START_DATE", "comment": null}, "MONTH_END_DATE": {"type": "DATE", "index": 4, "name": "MONTH_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_dq_stage"}, "model.the_tuva_project.pharmacy__int_brand_with_generic_available": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_BRAND_WITH_GENERIC_AVAILABLE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BRAND_WITH_GENERIC_AVAILABLE": {"type": "TEXT", "index": 1, "name": "BRAND_WITH_GENERIC_AVAILABLE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_brand_with_generic_available"}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "_VALUE_SET_DXCCSR_V2023_1_CLEANED_MAP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM_CODE": {"type": "TEXT", "index": 1, "name": "ICD_10_CM_CODE", "comment": null}, "ICD_10_CM_CODE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ICD_10_CM_CODE_DESCRIPTION", "comment": null}, "DEFAULT_CCSR_CATEGORY_IP": {"type": "TEXT", "index": 3, "name": "DEFAULT_CCSR_CATEGORY_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP": {"type": "TEXT", "index": 4, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_IP", "comment": null}, "DEFAULT_CCSR_CATEGORY_OP": {"type": "TEXT", "index": 5, "name": "DEFAULT_CCSR_CATEGORY_OP", "comment": null}, "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP": {"type": "TEXT", "index": 6, "name": "DEFAULT_CCSR_CATEGORY_DESCRIPTION_OP", "comment": null}, "CCSR_CATEGORY_1": {"type": "TEXT", "index": 7, "name": "CCSR_CATEGORY_1", "comment": null}, "CCSR_CATEGORY_1_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "CCSR_CATEGORY_1_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_2": {"type": "TEXT", "index": 9, "name": "CCSR_CATEGORY_2", "comment": null}, "CCSR_CATEGORY_2_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "CCSR_CATEGORY_2_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_3": {"type": "TEXT", "index": 11, "name": "CCSR_CATEGORY_3", "comment": null}, "CCSR_CATEGORY_3_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "CCSR_CATEGORY_3_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_4": {"type": "TEXT", "index": 13, "name": "CCSR_CATEGORY_4", "comment": null}, "CCSR_CATEGORY_4_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "CCSR_CATEGORY_4_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_5": {"type": "TEXT", "index": 15, "name": "CCSR_CATEGORY_5", "comment": null}, "CCSR_CATEGORY_5_DESCRIPTION": {"type": "TEXT", "index": 16, "name": "CCSR_CATEGORY_5_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_6": {"type": "TEXT", "index": 17, "name": "CCSR_CATEGORY_6", "comment": null}, "CCSR_CATEGORY_6_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "CCSR_CATEGORY_6_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1899008, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 74549, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map"}, "model.the_tuva_project.service_category__outpatient_rehab_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_REHAB_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_professional"}, "seed.the_tuva_project.clinical_concept_library__coding_systems": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "CODING_SYSTEMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODING_SYSTEM_ID": {"type": "TEXT", "index": 1, "name": "CODING_SYSTEM_ID", "comment": null}, "CODING_SYSTEM_NAME": {"type": "TEXT", "index": 2, "name": "CODING_SYSTEM_NAME", "comment": null}, "CODING_SYSTEM_URI": {"type": "TEXT", "index": 3, "name": "CODING_SYSTEM_URI", "comment": null}, "CODING_SYSTEM_OID": {"type": "TEXT", "index": 4, "name": "CODING_SYSTEM_OID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.clinical_concept_library__coding_systems"}, "model.the_tuva_project.data_quality__medication_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_SOURCE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_source_description"}, "model.the_tuva_project.data_quality__patient_zip_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_ZIP_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_zip_code"}, "model.the_tuva_project.quality_measures__int_nqf0034_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MIN_AGE": {"type": "NUMBER", "index": 2, "name": "MIN_AGE", "comment": null}, "MAX_AGE": {"type": "NUMBER", "index": 3, "name": "MAX_AGE", "comment": null}, "QUALIFYING_TYPES": {"type": "TEXT", "index": 4, "name": "QUALIFYING_TYPES", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_denominator"}, "model.the_tuva_project.encounters__stg_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 4, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_professional"}, "model.the_tuva_project.outpatient_radiology__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 3, "name": "HCPCS_CODE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__anchor_events"}, "model.the_tuva_project.data_quality__claim_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_id"}, "model.the_tuva_project.data_quality__lab_result_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_description"}, "model.the_tuva_project.quality_measures__int_adhras_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_long"}, "model.the_tuva_project.data_quality__condition_recorded_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_RECORDED_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_recorded_date"}, "model.the_tuva_project.medical_claim_expanded": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_EXPANDED", "name": "MEDICAL_CLAIM_EXPANDED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 15, "name": "ADMIT_TYPE_CODE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 16, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 17, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 18, "name": "BILL_TYPE_CODE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 20, "name": "APR_DRG_CODE", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 21, "name": "REVENUE_CENTER_CODE", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 22, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 23, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 27, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 28, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 29, "name": "RENDERING_NPI", "comment": null}, "RENDERING_TIN": {"type": "NUMBER", "index": 30, "name": "RENDERING_TIN", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 31, "name": "BILLING_NPI", "comment": null}, "BILLING_TIN": {"type": "NUMBER", "index": 32, "name": "BILLING_TIN", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 33, "name": "FACILITY_NPI", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 34, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 35, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 36, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 37, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 38, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 39, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 40, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 41, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 42, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 43, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 44, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 45, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 46, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 47, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 48, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 49, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 50, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 93, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 94, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 95, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 96, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 97, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 98, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 99, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 100, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 101, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 119, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 120, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 121, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 122, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 123, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 124, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 125, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 126, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 127, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_25", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 144, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 145, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 146, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 147, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.medical_claim_expanded"}, "model.the_tuva_project.hcc_suspecting__list": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "LIST", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "HCC_DESCRIPTION", "comment": null}, "REASON": {"type": "TEXT", "index": 5, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 6, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 7, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__list"}, "model.the_tuva_project.data_quality__encounter_ms_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_MS_DRG_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_code"}, "model.the_tuva_project.office_visits__int_office_visits_radiology": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_RADIOLOGY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 5, "name": "HCPCS_CODE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 6, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_radiology"}, "model.the_tuva_project.service_category__inpatient_hospice_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_HOSPICE_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_professional"}, "model.the_tuva_project.service_category__office_based_physical_therapy_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_PHYSICAL_THERAPY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_physical_therapy_professional"}, "model.the_tuva_project.mart_review__readmissions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__READMISSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 9, "name": "LENGTH_OF_STAY", "comment": null}, "INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 10, "name": "INDEX_ADMISSION_FLAG", "comment": null}, "PLANNED_FLAG": {"type": "NUMBER", "index": 11, "name": "PLANNED_FLAG", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 12, "name": "SPECIALTY_COHORT", "comment": null}, "DIED_FLAG": {"type": "NUMBER", "index": 13, "name": "DIED_FLAG", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CCS", "comment": null}, "HAD_READMISSION_FLAG": {"type": "NUMBER", "index": 15, "name": "HAD_READMISSION_FLAG", "comment": null}, "DAYS_TO_READMIT": {"type": "NUMBER", "index": 16, "name": "DAYS_TO_READMIT", "comment": null}, "READMIT_30_FLAG": {"type": "NUMBER", "index": 17, "name": "READMIT_30_FLAG", "comment": null}, "UNPLANNED_READMIT_30_FLAG": {"type": "NUMBER", "index": 18, "name": "UNPLANNED_READMIT_30_FLAG", "comment": null}, "READMISSION_ENCOUNTER_ID": {"type": "TEXT", "index": 19, "name": "READMISSION_ENCOUNTER_ID", "comment": null}, "READMISSION_ADMIT_DATE": {"type": "DATE", "index": 20, "name": "READMISSION_ADMIT_DATE", "comment": null}, "READMISSION_DISCHARGE_DATE": {"type": "DATE", "index": 21, "name": "READMISSION_DISCHARGE_DATE", "comment": null}, "READMISSION_DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 22, "name": "READMISSION_DISCHARGE_DISPOSITION_CODE", "comment": null}, "READMISSION_FACILITY": {"type": "TEXT", "index": 23, "name": "READMISSION_FACILITY", "comment": null}, "READMISSION_MS_DRG": {"type": "TEXT", "index": 24, "name": "READMISSION_MS_DRG", "comment": null}, "READMISSION_LENGTH_OF_STAY": {"type": "NUMBER", "index": 25, "name": "READMISSION_LENGTH_OF_STAY", "comment": null}, "READMISSION_INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 26, "name": "READMISSION_INDEX_ADMISSION_FLAG", "comment": null}, "READMISSION_PLANNED_FLAG": {"type": "NUMBER", "index": 27, "name": "READMISSION_PLANNED_FLAG", "comment": null}, "READMISSION_SPECIALTY_COHORT": {"type": "TEXT", "index": 28, "name": "READMISSION_SPECIALTY_COHORT", "comment": null}, "READMISSION_DIED_FLAG": {"type": "NUMBER", "index": 29, "name": "READMISSION_DIED_FLAG", "comment": null}, "READMISSION_DIAGNOSIS_CCS": {"type": "TEXT", "index": 30, "name": "READMISSION_DIAGNOSIS_CCS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 31, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__readmissions"}, "model.the_tuva_project.data_quality__eligibility_phone": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PHONE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_phone"}, "model.the_tuva_project.dme__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "DME__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 19, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__encounter_grain"}, "model.the_tuva_project.lab__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__anchor_events"}, "model.the_tuva_project.data_quality__encounter_facility_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_FACILITY_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_facility_id"}, "seed.the_tuva_project.data_quality__reference_mart_analytics": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "_VALUE_SET_REFERENCE_MART_ANALYTICS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 3, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 4, "name": "VALUE_RANK", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 5, "name": "PAYER_TYPE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 6144, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 134, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.data_quality__reference_mart_analytics"}, "model.the_tuva_project.ahrq_measures__int_pqi_11_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_11_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_num"}, "model.the_tuva_project.mart_review__generics": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__GENERICS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"GENERIC_AVAILABLE_SK": {"type": "NUMBER", "index": 1, "name": "GENERIC_AVAILABLE_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "BRAND_NDC_CODE": {"type": "TEXT", "index": 3, "name": "BRAND_NDC_CODE", "comment": null}, "BRAND_NDC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "BRAND_NDC_DESCRIPTION", "comment": null}, "BRAND_RXCUI": {"type": "TEXT", "index": 5, "name": "BRAND_RXCUI", "comment": null}, "BRAND_PAID_AMOUNT": {"type": "NUMBER", "index": 6, "name": "BRAND_PAID_AMOUNT", "comment": null}, "BRAND_UNITS": {"type": "NUMBER", "index": 7, "name": "BRAND_UNITS", "comment": null}, "BRAND_PAID_PER_UNIT": {"type": "NUMBER", "index": 8, "name": "BRAND_PAID_PER_UNIT", "comment": null}, "GENERIC_NDC": {"type": "TEXT", "index": 9, "name": "GENERIC_NDC", "comment": null}, "GENERIC_NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "GENERIC_NDC_DESCRIPTION", "comment": null}, "GENERIC_PRESCRIBED_HISTORY": {"type": "NUMBER", "index": 11, "name": "GENERIC_PRESCRIBED_HISTORY", "comment": null}, "GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 12, "name": "GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_COST_AT_UNITS": {"type": "NUMBER", "index": 13, "name": "GENERIC_COST_AT_UNITS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__generics"}, "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events"}, "model.the_tuva_project.ccsr__long_procedure_category": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "LONG_PROCEDURE_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CODE_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 6, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 7, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CLINICAL_DOMAIN": {"type": "TEXT", "index": 9, "name": "CLINICAL_DOMAIN", "comment": null}, "PRCCSR_VERSION": {"type": "TEXT", "index": 10, "name": "PRCCSR_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__long_procedure_category"}, "model.the_tuva_project.inpatient_rehab__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__encounter_grain"}, "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_INSTITUTIONAL_MATERNITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity"}, "seed.the_tuva_project.cms_hcc__adjustment_rates": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_ADJUSTMENT_RATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 2, "name": "PAYMENT_YEAR", "comment": null}, "NORMALIZATION_FACTOR": {"type": "FLOAT", "index": 3, "name": "NORMALIZATION_FACTOR", "comment": null}, "MA_CODING_PATTERN_ADJUSTMENT": {"type": "FLOAT", "index": 4, "name": "MA_CODING_PATTERN_ADJUSTMENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__adjustment_rates"}, "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPICE__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__eligibility_payer": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PAYER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer"}, "model.the_tuva_project.ccsr__procedure_category_map": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "PROCEDURE_CATEGORY_MAP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "CODE_DESCRIPTION", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CLINICAL_DOMAIN": {"type": "TEXT", "index": 6, "name": "CLINICAL_DOMAIN", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1553408, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 81597, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__procedure_category_map"}, "model.the_tuva_project.dme__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DME__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__generate_encounter_id"}, "model.the_tuva_project.data_quality__eligibility_gender": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_GENDER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_gender"}, "model.the_tuva_project.data_quality__eligibility_missing_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_MISSING_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_patient_id"}, "model.the_tuva_project.service_category__observation_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OBSERVATION_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__observation_professional"}, "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_11_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_denom"}, "model.the_tuva_project.quality_measures__int_nqf0034_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 2, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE": {"type": "TEXT", "index": 3, "name": "EVIDENCE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_numerator"}, "model.the_tuva_project.data_quality__pharmacy_copayment_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_COPAYMENT_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_copayment_amount"}, "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_07_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions"}, "seed.the_tuva_project.quality_measures__value_sets": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_VALUE_SET_CODES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_NAME": {"type": "TEXT", "index": 1, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 2, "name": "CONCEPT_OID", "comment": null}, "CODE": {"type": "TEXT", "index": 3, "name": "CODE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 4, "name": "CODE_SYSTEM", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 494592, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 52101, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.quality_measures__value_sets"}, "model.the_tuva_project.core__stg_clinical_patient": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_PATIENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_patient"}, "model.the_tuva_project.data_quality__institutional_claim_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_CLAIM_END_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_end_date"}, "model.the_tuva_project.normalized_input__medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "NORMALIZED_INPUT_MEDICAL_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 16, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 17, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 18, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 22, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 24, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 25, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 26, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 28, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 29, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "TEXT", "index": 30, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 31, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 32, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 33, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 34, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 35, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 36, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 37, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 38, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 39, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 40, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 41, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 42, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 43, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 44, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 45, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 46, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 47, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 48, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 49, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 50, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 51, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 52, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 93, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 94, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 95, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 96, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 97, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 98, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 99, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 100, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 101, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 102, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 103, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 119, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 120, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 121, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 122, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 123, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 124, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 125, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 126, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 127, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 128, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 129, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 144, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 145, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 146, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 147, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 148, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 149, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 150, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 151, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 152, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 153, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 154, "name": "PROCEDURE_DATE_25", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 155, "name": "DATA_SOURCE", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 156, "name": "IN_NETWORK_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 157, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__medical_claim"}, "model.the_tuva_project.data_quality__medication_days_supply": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_DAYS_SUPPLY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_days_supply"}, "model.the_tuva_project.quality_measures__int_nqf0041_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_numerator"}, "model.the_tuva_project.data_quality__encounter_charge_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_CHARGE_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_charge_amount"}, "model.the_tuva_project.data_quality__institutional_procedure_code_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_CODE_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_2"}, "model.the_tuva_project.core__member_months": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "MEMBER_MONTHS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 10, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 14, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__member_months"}, "model.the_tuva_project.data_quality__acute_inpatient_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ACUTE_INPATIENT_REFERENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_reference"}, "model.the_tuva_project.inpatient_substance_use__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__prof_claims"}, "model.the_tuva_project.core__stg_claims_pharmacy_claim": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_PHARMACY_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PHARMACY_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "PHARMACY_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 9, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 12, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 13, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 15, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 16, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 17, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 18, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 23, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 25, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_pharmacy_claim"}, "model.the_tuva_project.emergency_department__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__generate_encounter_id"}, "model.the_tuva_project.mart_review__data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__data_source"}, "model.the_tuva_project.data_quality__encounter_apr_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_APR_DRG_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_code"}, "model.the_tuva_project.core__stg_clinical_medication": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_MEDICATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICATION_ID": {"type": "TEXT", "index": 1, "name": "MEDICATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 4, "name": "DISPENSING_DATE", "comment": null}, "PRESCRIBING_DATE": {"type": "DATE", "index": 5, "name": "PRESCRIBING_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "RXNORM_CODE": {"type": "TEXT", "index": 11, "name": "RXNORM_CODE", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "RXNORM_DESCRIPTION", "comment": null}, "ATC_CODE": {"type": "TEXT", "index": 13, "name": "ATC_CODE", "comment": null}, "ATC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "ATC_DESCRIPTION", "comment": null}, "ROUTE": {"type": "TEXT", "index": 15, "name": "ROUTE", "comment": null}, "STRENGTH": {"type": "TEXT", "index": 16, "name": "STRENGTH", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 17, "name": "QUANTITY", "comment": null}, "QUANTITY_UNIT": {"type": "TEXT", "index": 18, "name": "QUANTITY_UNIT", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 19, "name": "DAYS_SUPPLY", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 20, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 21, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_medication"}, "model.the_tuva_project.normalized_input__int_admit_source_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_SOURCE_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_final"}, "model.the_tuva_project.hcc_suspecting__summary": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PATIENT_SEX": {"type": "TEXT", "index": 2, "name": "PATIENT_SEX", "comment": null}, "PATIENT_BIRTH_DATE": {"type": "DATE", "index": 3, "name": "PATIENT_BIRTH_DATE", "comment": null}, "PATIENT_AGE": {"type": "NUMBER", "index": 4, "name": "PATIENT_AGE", "comment": null}, "SUSPECTING_GAPS": {"type": "NUMBER", "index": 5, "name": "SUSPECTING_GAPS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__summary"}, "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_03_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions"}, "model.the_tuva_project.data_quality__procedure_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_SOURCE_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code_type"}, "model.the_tuva_project.data_quality__procedure_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_encounter_id"}, "model.the_tuva_project.data_quality__acute_inpatient_prevelence": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ACUTE_INPATIENT_PREVELENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "VALUE_RANK": {"type": "NUMBER", "index": 5, "name": "VALUE_RANK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_prevelence"}, "model.the_tuva_project.data_quality__lab_result_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code_type"}, "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DISPENSING_PROVIDER_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi"}, "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_PHYSICAL_THERAPY_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional"}, "seed.the_tuva_project.terminology__icd_9_pcs": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_9_PCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_9_PCS": {"type": "TEXT", "index": 1, "name": "ICD_9_PCS", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "LONG_DESCRIPTION", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "SHORT_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 105984, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3882, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_9_pcs"}, "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_PSYCHIATRIC_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_institutional"}, "model.the_tuva_project.data_quality__encounter_encounter_start_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_START_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_start_date"}, "model.the_tuva_project.mart_review__stg_medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__STG_MEDICAL_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICAL_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "MEDICAL_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 8, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 9, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 10, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 16, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 17, "name": "DISCHARGE_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 19, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 20, "name": "SERVICE_CATEGORY_3", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 21, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 23, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 25, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 27, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 31, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 33, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 37, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 38, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 39, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 40, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 41, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 42, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 43, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 44, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 45, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 46, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 47, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 48, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 49, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 50, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 51, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 52, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 53, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 54, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 55, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 56, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 57, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 58, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 59, "name": "TOTAL_COST_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 60, "name": "IN_NETWORK_FLAG", "comment": null}, "ENROLLMENT_FLAG": {"type": "NUMBER", "index": 61, "name": "ENROLLMENT_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 62, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 63, "name": "TUVA_LAST_RUN", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 64, "name": "YEAR_MONTH", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__stg_medical_claim"}, "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_PAYMENT_HCC_COUNT_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 4, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 5, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 6, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "PAYMENT_HCC_COUNT": {"type": "TEXT", "index": 8, "name": "PAYMENT_HCC_COUNT", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 9, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 10, "name": "COEFFICIENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 5120, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 73, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors"}, "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_OBSERVATION_OBSERVATION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_observation_observation_id"}, "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_exclusions"}, "model.the_tuva_project.data_quality__medication_prescribing_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_PRESCRIBING_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_prescribing_date"}, "seed.the_tuva_project.terminology__place_of_service": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PLACE_OF_SERVICE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 1, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 50, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__place_of_service"}, "model.the_tuva_project.data_quality__medication_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_PRACTITIONER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_practitioner_id"}, "model.the_tuva_project.data_quality__patient_city": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_CITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_city"}, "seed.the_tuva_project.terminology__ethnicity": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ETHNICITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE": {"type": "TEXT", "index": 1, "name": "CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ethnicity"}, "model.the_tuva_project.ccsr__singular_condition_category": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "SINGULAR_CONDITION_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 6, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "PARENT_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "PARENT_CATEGORY_DESCRIPTION", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 8, "name": "BODY_SYSTEM", "comment": null}, "DXCCSR_VERSION": {"type": "TEXT", "index": 9, "name": "DXCCSR_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__singular_condition_category"}, "model.the_tuva_project.core__practitioner": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PRACTITIONER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "PROVIDER_FIRST_NAME": {"type": "TEXT", "index": 3, "name": "PROVIDER_FIRST_NAME", "comment": null}, "PROVIDER_LAST_NAME": {"type": "TEXT", "index": 4, "name": "PROVIDER_LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__practitioner"}, "model.the_tuva_project.ambulance__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__generate_encounter_id"}, "seed.the_tuva_project.terminology__ccs_services_procedures": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "CCS_SERVICES_PROCEDURES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS_CODE": {"type": "TEXT", "index": 1, "name": "HCPCS_CODE", "comment": null}, "CCS_CATEGORY": {"type": "TEXT", "index": 2, "name": "CCS_CATEGORY", "comment": null}, "CCS_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "CCS_CATEGORY_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 131584, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 17477, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ccs_services_procedures"}, "model.the_tuva_project.data_quality__lab_result_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_encounter_id"}, "model.the_tuva_project.data_quality__encounter_apr_drg_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_APR_DRG_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_description"}, "model.the_tuva_project.data_quality__claim_diagnosis_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DIAGNOSIS_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_diagnosis_code_type"}, "model.the_tuva_project.data_quality__lab_result_result_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_RESULT_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_result_date"}, "model.the_tuva_project.readmissions__readmission_crude": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_READMISSION_CRUDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "HAD_READMISSION_FLAG": {"type": "NUMBER", "index": 5, "name": "HAD_READMISSION_FLAG", "comment": null}, "DAYS_TO_READMIT": {"type": "NUMBER", "index": 6, "name": "DAYS_TO_READMIT", "comment": null}, "READMIT_30_FLAG": {"type": "NUMBER", "index": 7, "name": "READMIT_30_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__readmission_crude"}, "seed.the_tuva_project.terminology__apr_drg": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "APR_DRG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"APR_DRG_CODE": {"type": "TEXT", "index": 1, "name": "APR_DRG_CODE", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 2, "name": "MEDICAL_SURGICAL", "comment": null}, "MDC_CODE": {"type": "TEXT", "index": 3, "name": "MDC_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "APR_DRG_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8704, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 316, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__apr_drg"}, "model.the_tuva_project.data_quality__institutional_procedure_code_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_CODE_3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_3"}, "model.the_tuva_project.hcc_suspecting__int_all_medications": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_ALL_MEDICATIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 2, "name": "DISPENSING_DATE", "comment": null}, "DRUG_CODE": {"type": "TEXT", "index": 3, "name": "DRUG_CODE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 4, "name": "CODE_SYSTEM", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_medications"}, "model.the_tuva_project.normalized_input__int_procedure_code_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_CODE_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_voting"}, "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": {"metadata": {"type": "BASE TABLE", "schema": "PHARMACY", "name": "PHARMACY_CLAIM_EXPANDED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 6, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 7, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 8, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 11, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 12, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 13, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 14, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 15, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 16, "name": "ALLOWED_AMOUNT", "comment": null}, "RXCUI": {"type": "TEXT", "index": 17, "name": "RXCUI", "comment": null}, "PRODUCT_NAME": {"type": "TEXT", "index": 18, "name": "PRODUCT_NAME", "comment": null}, "PRODUCT_TTY": {"type": "TEXT", "index": 19, "name": "PRODUCT_TTY", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 20, "name": "BRAND_VS_GENERIC", "comment": null}, "BRAND_NAME": {"type": "TEXT", "index": 21, "name": "BRAND_NAME", "comment": null}, "GENERIC_RXCUI": {"type": "TEXT", "index": 22, "name": "GENERIC_RXCUI", "comment": null}, "GENERIC_RXCUI_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "GENERIC_RXCUI_DESCRIPTION", "comment": null}, "GENERIC_TTY": {"type": "TEXT", "index": 24, "name": "GENERIC_TTY", "comment": null}, "INGREDIENT_NAME": {"type": "TEXT", "index": 25, "name": "INGREDIENT_NAME", "comment": null}, "DOSE_FORM_NAME": {"type": "TEXT", "index": 26, "name": "DOSE_FORM_NAME", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 27, "name": "GENERIC_AVAILABLE", "comment": null}, "BRAND_COST_PER_UNIT": {"type": "NUMBER", "index": 28, "name": "BRAND_COST_PER_UNIT", "comment": null}, "GENERIC_AVERAGE_COST_PER_UNIT": {"type": "NUMBER", "index": 29, "name": "GENERIC_AVERAGE_COST_PER_UNIT", "comment": null}, "BRAND_LESS_GENERIC_COST_PER_UNIT": {"type": "NUMBER", "index": 30, "name": "BRAND_LESS_GENERIC_COST_PER_UNIT", "comment": null}, "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY": {"type": "NUMBER", "index": 31, "name": "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY", "comment": null}, "GENERIC_AVAILABLE_SK": {"type": "NUMBER", "index": 32, "name": "GENERIC_AVAILABLE_SK", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"}, "model.the_tuva_project.service_category__outpatient_radiology_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_RADIOLOGY_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_institutional"}, "model.the_tuva_project.data_quality__analytics_populated": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ANALYTICS_POPULATED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"TABLE_NAME": {"type": "TEXT", "index": 1, "name": "TABLE_NAME", "comment": null}, "RECORD_COUNT": {"type": "NUMBER", "index": 2, "name": "RECORD_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 8, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__analytics_populated"}, "model.the_tuva_project.data_quality__encounter_admit_type_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_TYPE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_code"}, "seed.the_tuva_project.hcc_suspecting__clinical_concepts": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_VALUE_SET_CLINICAL_CONCEPTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONCEPT_NAME": {"type": "TEXT", "index": 1, "name": "CONCEPT_NAME", "comment": null}, "CONCEPT_OID": {"type": "TEXT", "index": 2, "name": "CONCEPT_OID", "comment": null}, "CODE": {"type": "TEXT", "index": 3, "name": "CODE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 4, "name": "CODE_SYSTEM", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 188928, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 25472, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.hcc_suspecting__clinical_concepts"}, "model.the_tuva_project.data_quality__institutional_procedure_date_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_DATE_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_2"}, "model.the_tuva_project.data_quality__practitioner_practice_affiliation": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_PRACTICE_AFFILIATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_practice_affiliation"}, "model.the_tuva_project.mart_review__enrollment_change": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__ENROLLMENT_CHANGE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CHANGE_MONTH": {"type": "DATE", "index": 2, "name": "CHANGE_MONTH", "comment": null}, "CHANGE_TYPE": {"type": "TEXT", "index": 3, "name": "CHANGE_TYPE", "comment": null}, "MEMBER_COUNT": {"type": "NUMBER", "index": 4, "name": "MEMBER_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__enrollment_change"}, "model.the_tuva_project.outpatient_psych__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__generate_encounter_id"}, "model.the_tuva_project.normalized_input__int_present_on_admit_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PRESENT_ON_ADMIT_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 4, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 5, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 6, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 7, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 8, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 9, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 10, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 11, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 12, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 13, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 15, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 16, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 17, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 18, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 19, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 20, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 21, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 22, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 23, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 24, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 25, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 26, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 27, "name": "DIAGNOSIS_POA_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_final"}, "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLINICAL_FOR_PBI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SUMMARY_SK": {"type": "NUMBER", "index": 1, "name": "SUMMARY_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 4, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 5, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 6, "name": "INVALID_REASON", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 7, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 8, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "FREQUENCY": {"type": "NUMBER", "index": 10, "name": "FREQUENCY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi"}, "model.the_tuva_project.service_category__outpatient_substance_use_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SUBSTANCE_USE_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_professional"}, "model.the_tuva_project.core__stg_clinical_observation": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_OBSERVATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "RESULT": {"type": "TEXT", "index": 13, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 14, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 15, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 16, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 18, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_observation"}, "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "PMPM_PAYER_PLAN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 2, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 3, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 5, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 6, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 7, "name": "MEDICAL_PAID", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 8, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 9, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 10, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 11, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 12, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 13, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 14, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 15, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 16, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 17, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 18, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 19, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 20, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 21, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 22, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 23, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 24, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 25, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 26, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 27, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 28, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 29, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 30, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 31, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 32, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 33, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 34, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 35, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 36, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 37, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 38, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 39, "name": "URGENT_CARE_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 40, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 41, "name": "MEDICAL_ALLOWED", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 42, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 43, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 44, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 45, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 46, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 47, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 48, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 49, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 50, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 51, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 52, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 53, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 54, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 55, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 56, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 57, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 58, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 59, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 60, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 61, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 62, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 63, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 64, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 65, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 70, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 71, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 72, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 73, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 74, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer_plan"}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_COST_AND_UTILIZATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_GROUP", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 3, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 4, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 5, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization"}, "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"}, "model.the_tuva_project.data_quality__condition_condition_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CONDITION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_condition_id"}, "model.the_tuva_project.inpatient_psych__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__prof_claims"}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_REFERENCE_RANGE_HIGH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_high"}, "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_01_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions"}, "model.the_tuva_project.ambulance__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__encounter_encounter_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_END_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_end_date"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR_CRITERIA3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3"}, "model.the_tuva_project.quality_measures__int_cqm130_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_long"}, "model.the_tuva_project.data_quality__observation_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_description"}, "model.the_tuva_project.emergency_department__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 13, "name": "OBSERVATION_FLAG", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 14, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 15, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 16, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 17, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 18, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 19, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 20, "name": "PHARMACY_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 21, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 23, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 24, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 25, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 26, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 28, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 30, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 32, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 35, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 38, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 39, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 40, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 41, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__encounter_grain"}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "TUVA_CHRONIC_CONDITIONS_WIDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "OBESITY": {"type": "NUMBER", "index": 2, "name": "OBESITY", "comment": null}, "OSTEOARTHRITIS": {"type": "NUMBER", "index": 3, "name": "OSTEOARTHRITIS", "comment": null}, "COPD": {"type": "NUMBER", "index": 4, "name": "COPD", "comment": null}, "ANXIETY_DISORDERS": {"type": "NUMBER", "index": 5, "name": "ANXIETY_DISORDERS", "comment": null}, "CKD": {"type": "NUMBER", "index": 6, "name": "CKD", "comment": null}, "T2D": {"type": "NUMBER", "index": 7, "name": "T2D", "comment": null}, "CLL": {"type": "NUMBER", "index": 8, "name": "CLL", "comment": null}, "DYSPLIPIDEMIAS": {"type": "NUMBER", "index": 9, "name": "DYSPLIPIDEMIAS", "comment": null}, "HYPERTENSION": {"type": "NUMBER", "index": 10, "name": "HYPERTENSION", "comment": null}, "ATHEROSCLEROSIS": {"type": "NUMBER", "index": 11, "name": "ATHEROSCLEROSIS", "comment": null}, "DEMENTIA": {"type": "NUMBER", "index": 12, "name": "DEMENTIA", "comment": null}, "RHEUMATOID_ARTHRITIS": {"type": "NUMBER", "index": 13, "name": "RHEUMATOID_ARTHRITIS", "comment": null}, "CELIAC": {"type": "NUMBER", "index": 14, "name": "CELIAC", "comment": null}, "HIP_FRACTURE": {"type": "NUMBER", "index": 15, "name": "HIP_FRACTURE", "comment": null}, "IMMUNODEFICIENCIES_AND_WHITE_BLOOD_CELL_DISORDERS": {"type": "NUMBER", "index": 16, "name": "IMMUNODEFICIENCIES_AND_WHITE_BLOOD_CELL_DISORDERS", "comment": null}, "ASTHMA": {"type": "NUMBER", "index": 17, "name": "ASTHMA", "comment": null}, "T1D": {"type": "NUMBER", "index": 18, "name": "T1D", "comment": null}, "ULCERATIVE_COLITIS": {"type": "NUMBER", "index": 19, "name": "ULCERATIVE_COLITIS", "comment": null}, "CHROHNS": {"type": "NUMBER", "index": 20, "name": "CHROHNS", "comment": null}, "HOLICOBACTER": {"type": "NUMBER", "index": 21, "name": "HOLICOBACTER", "comment": null}, "BIPOLAR": {"type": "NUMBER", "index": 22, "name": "BIPOLAR", "comment": null}, "HEART_FAILURE": {"type": "NUMBER", "index": 23, "name": "HEART_FAILURE", "comment": null}, "TABACCO": {"type": "NUMBER", "index": 24, "name": "TABACCO", "comment": null}, "LYME": {"type": "NUMBER", "index": 25, "name": "LYME", "comment": null}, "BREAST_CANCER": {"type": "NUMBER", "index": 26, "name": "BREAST_CANCER", "comment": null}, "OSTEOPOROSIS": {"type": "NUMBER", "index": 27, "name": "OSTEOPOROSIS", "comment": null}, "PULMONARY_EMBOLISM": {"type": "NUMBER", "index": 28, "name": "PULMONARY_EMBOLISM", "comment": null}, "SCHIZOPHRENIA": {"type": "NUMBER", "index": 29, "name": "SCHIZOPHRENIA", "comment": null}, "ATRIAL_FIBRILLATION": {"type": "NUMBER", "index": 30, "name": "ATRIAL_FIBRILLATION", "comment": null}, "COLORECTAL_CANCER": {"type": "NUMBER", "index": 31, "name": "COLORECTAL_CANCER", "comment": null}, "DEPRESSION": {"type": "NUMBER", "index": 32, "name": "DEPRESSION", "comment": null}, "DEEP_VEIN_THROMBOSIS": {"type": "NUMBER", "index": 33, "name": "DEEP_VEIN_THROMBOSIS", "comment": null}, "ALZHEIMER": {"type": "NUMBER", "index": 34, "name": "ALZHEIMER", "comment": null}, "STROKE": {"type": "NUMBER", "index": 35, "name": "STROKE", "comment": null}, "MYOCARDIAL_INFRACTION": {"type": "NUMBER", "index": 36, "name": "MYOCARDIAL_INFRACTION", "comment": null}, "OPIOD_USE_DISORDER": {"type": "NUMBER", "index": 37, "name": "OPIOD_USE_DISORDER", "comment": null}, "LUNG_CANCER": {"type": "NUMBER", "index": 38, "name": "LUNG_CANCER", "comment": null}, "HERPES": {"type": "NUMBER", "index": 39, "name": "HERPES", "comment": null}, "RICKETTSIOSIS": {"type": "NUMBER", "index": 40, "name": "RICKETTSIOSIS", "comment": null}, "MS": {"type": "NUMBER", "index": 41, "name": "MS", "comment": null}, "ALCHOHOL": {"type": "NUMBER", "index": 42, "name": "ALCHOHOL", "comment": null}, "ADHD": {"type": "NUMBER", "index": 43, "name": "ADHD", "comment": null}, "HIV": {"type": "NUMBER", "index": 44, "name": "HIV", "comment": null}, "PTSD": {"type": "NUMBER", "index": 45, "name": "PTSD", "comment": null}, "LUPUS": {"type": "NUMBER", "index": 46, "name": "LUPUS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 47, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"}, "model.the_tuva_project.data_quality__claim_claim_line_number": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_LINE_NUMBER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_number"}, "model.the_tuva_project.data_quality__location_zip_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_ZIP_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_zip_code"}, "model.the_tuva_project.data_quality__institutional_procedure_date_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_DATE_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_1"}, "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__match_claims_to_anchor"}, "seed.the_tuva_project.terminology__admit_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ADMIT_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ADMIT_TYPE_CODE": {"type": "TEXT", "index": 1, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 5, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__admit_type"}, "model.the_tuva_project.service_category__home_health_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_HOME_HEALTH_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__home_health_professional"}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DIAGNOSIS_CODE_1", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_1"}, "model.the_tuva_project.dialysis__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__anchor_events"}, "seed.the_tuva_project.service_category__service_categories": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__SERVICE_CATEGORIES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SERVICE_CATEGORY_1": {"type": "TEXT", "index": 1, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_3", "comment": null}, "PRIORITY": {"type": "NUMBER", "index": 4, "name": "PRIORITY", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 44, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.service_category__service_categories"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_INT_CMS_CHRONIC_CONDITION_OUD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"}, "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_POTENTIALLY_PLANNED_ICD_10_PCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 34304, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2521, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs"}, "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MEDICAL_CLAIM_DATE_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_CLAIM_START_DATE": {"type": "DATE", "index": 5, "name": "NORMALIZED_CLAIM_START_DATE", "comment": null}, "NORMALIZED_CLAIM_END_DATE": {"type": "DATE", "index": 6, "name": "NORMALIZED_CLAIM_END_DATE", "comment": null}, "NORMALIZED_CLAIM_LINE_START_DATE": {"type": "DATE", "index": 7, "name": "NORMALIZED_CLAIM_LINE_START_DATE", "comment": null}, "NORMALIZED_CLAIM_LINE_END_DATE": {"type": "DATE", "index": 8, "name": "NORMALIZED_CLAIM_LINE_END_DATE", "comment": null}, "NORMALIZED_ADMISSION_DATE": {"type": "DATE", "index": 9, "name": "NORMALIZED_ADMISSION_DATE", "comment": null}, "NORMALIZED_DISCHARGE_DATE": {"type": "DATE", "index": 10, "name": "NORMALIZED_DISCHARGE_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize"}, "seed.input_layer.pharmacy_claim_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "PHARMACY_CLAIM_SEED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 4, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_NPI": {"type": "TEXT", "index": 7, "name": "PRESCRIBING_PROVIDER_NPI", "comment": null}, "DISPENSING_PROVIDER_NPI": {"type": "TEXT", "index": 8, "name": "DISPENSING_PROVIDER_NPI", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 9, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 10, "name": "NDC_CODE", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 11, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 12, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 13, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 14, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 15, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 16, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 17, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 18, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 19, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 20, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 21, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 22, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 23, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 24, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.pharmacy_claim_seed"}, "seed.the_tuva_project.cms_hcc__disease_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISEASE_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 4, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 5, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 6, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 8, "name": "HCC_CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 9, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 10, "name": "COEFFICIENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 24576, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1369, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disease_factors"}, "model.the_tuva_project.readmissions__readmission_summary": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "READMISSION_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 9, "name": "LENGTH_OF_STAY", "comment": null}, "INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 10, "name": "INDEX_ADMISSION_FLAG", "comment": null}, "PLANNED_FLAG": {"type": "NUMBER", "index": 11, "name": "PLANNED_FLAG", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 12, "name": "SPECIALTY_COHORT", "comment": null}, "DIED_FLAG": {"type": "NUMBER", "index": 13, "name": "DIED_FLAG", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CCS", "comment": null}, "HAD_READMISSION_FLAG": {"type": "NUMBER", "index": 15, "name": "HAD_READMISSION_FLAG", "comment": null}, "DAYS_TO_READMIT": {"type": "NUMBER", "index": 16, "name": "DAYS_TO_READMIT", "comment": null}, "READMIT_30_FLAG": {"type": "NUMBER", "index": 17, "name": "READMIT_30_FLAG", "comment": null}, "UNPLANNED_READMIT_30_FLAG": {"type": "NUMBER", "index": 18, "name": "UNPLANNED_READMIT_30_FLAG", "comment": null}, "READMISSION_ENCOUNTER_ID": {"type": "TEXT", "index": 19, "name": "READMISSION_ENCOUNTER_ID", "comment": null}, "READMISSION_ADMIT_DATE": {"type": "DATE", "index": 20, "name": "READMISSION_ADMIT_DATE", "comment": null}, "READMISSION_DISCHARGE_DATE": {"type": "DATE", "index": 21, "name": "READMISSION_DISCHARGE_DATE", "comment": null}, "READMISSION_DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 22, "name": "READMISSION_DISCHARGE_DISPOSITION_CODE", "comment": null}, "READMISSION_FACILITY": {"type": "TEXT", "index": 23, "name": "READMISSION_FACILITY", "comment": null}, "READMISSION_MS_DRG": {"type": "TEXT", "index": 24, "name": "READMISSION_MS_DRG", "comment": null}, "READMISSION_LENGTH_OF_STAY": {"type": "NUMBER", "index": 25, "name": "READMISSION_LENGTH_OF_STAY", "comment": null}, "READMISSION_INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 26, "name": "READMISSION_INDEX_ADMISSION_FLAG", "comment": null}, "READMISSION_PLANNED_FLAG": {"type": "NUMBER", "index": 27, "name": "READMISSION_PLANNED_FLAG", "comment": null}, "READMISSION_SPECIALTY_COHORT": {"type": "TEXT", "index": 28, "name": "READMISSION_SPECIALTY_COHORT", "comment": null}, "READMISSION_DIED_FLAG": {"type": "NUMBER", "index": 29, "name": "READMISSION_DIED_FLAG", "comment": null}, "READMISSION_DIAGNOSIS_CCS": {"type": "TEXT", "index": 30, "name": "READMISSION_DIAGNOSIS_CCS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 31, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__readmission_summary"}, "model.the_tuva_project.ahrq_measures__pqi_rate": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_RATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 2, "name": "YEAR_NUMBER", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 3, "name": "PQI_NUMBER", "comment": null}, "DENOM_COUNT": {"type": "NUMBER", "index": 4, "name": "DENOM_COUNT", "comment": null}, "NUM_COUNT": {"type": "NUMBER", "index": 5, "name": "NUM_COUNT", "comment": null}, "RATE_PER_100_THOUSAND": {"type": "NUMBER", "index": 6, "name": "RATE_PER_100_THOUSAND", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_rate"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 2, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 3, "name": "EVIDENCE_VALUE", "comment": null}, "ADHERENCE": {"type": "NUMBER", "index": 4, "name": "ADHERENCE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 5, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"}, "model.the_tuva_project.data_quality__data_quality_clinical_detail": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLINICAL_DETAIL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 11, "name": "SUMMARY_SK", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_detail"}, "model.the_tuva_project.service_category__ambulatory_surgery_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULATORY_SURGERY_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_institutional"}, "model.the_tuva_project.lab__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__condition_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_CLAIM_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_claim_id"}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_REFERENCE_RANGE_HIGH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high"}, "seed.the_tuva_project.terminology__rxnorm_to_atc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "RXNORM_TO_ATC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"RXCUI": {"type": "TEXT", "index": 1, "name": "RXCUI", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "RXNORM_DESCRIPTION", "comment": null}, "ATC_1_CODE": {"type": "TEXT", "index": 3, "name": "ATC_1_CODE", "comment": null}, "ATC_1_NAME": {"type": "TEXT", "index": 4, "name": "ATC_1_NAME", "comment": null}, "ATC_2_CODE": {"type": "TEXT", "index": 5, "name": "ATC_2_CODE", "comment": null}, "ATC_2_NAME": {"type": "TEXT", "index": 6, "name": "ATC_2_NAME", "comment": null}, "ATC_3_CODE": {"type": "TEXT", "index": 7, "name": "ATC_3_CODE", "comment": null}, "ATC_3_NAME": {"type": "TEXT", "index": 8, "name": "ATC_3_NAME", "comment": null}, "ATC_4_CODE": {"type": "TEXT", "index": 9, "name": "ATC_4_CODE", "comment": null}, "ATC_4_NAME": {"type": "TEXT", "index": 10, "name": "ATC_4_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1103360, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 24497, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__rxnorm_to_atc"}, "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_VALUE_SET_CMS_CHRONIC_CONDITIONS_HIERARCHY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "CONDITION": {"type": "TEXT", "index": 2, "name": "CONDITION", "comment": null}, "CONDITION_COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "CONDITION_COLUMN_NAME", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "ADDITIONAL_LOGIC": {"type": "TEXT", "index": 6, "name": "ADDITIONAL_LOGIC", "comment": null}, "CLAIMS_QUALIFICATION": {"type": "TEXT", "index": 7, "name": "CLAIMS_QUALIFICATION", "comment": null}, "INCLUSION_TYPE": {"type": "TEXT", "index": 8, "name": "INCLUSION_TYPE", "comment": null}, "CODE_SYSTEM": {"type": "TEXT", "index": 9, "name": "CODE_SYSTEM", "comment": null}, "CODE": {"type": "TEXT", "index": 10, "name": "CODE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 143360, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 6532, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PRIMARY_DIAGNOSIS_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type"}, "model.the_tuva_project.lab__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 19, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__encounter_grain"}, "model.the_tuva_project.quality_measures__int_nqf2372_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "PERFORMANCE_PERIOD_LOOKBACK": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_LOOKBACK", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_denominator"}, "model.the_tuva_project.data_quality__primary_keys_location_location_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_LOCATION_LOCATION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_location_location_id"}, "seed.the_tuva_project.terminology__provider": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PROVIDER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NPI": {"type": "TEXT", "index": 1, "name": "NPI", "comment": null}, "ENTITY_TYPE_CODE": {"type": "TEXT", "index": 2, "name": "ENTITY_TYPE_CODE", "comment": null}, "ENTITY_TYPE_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "ENTITY_TYPE_DESCRIPTION", "comment": null}, "PRIMARY_TAXONOMY_CODE": {"type": "TEXT", "index": 4, "name": "PRIMARY_TAXONOMY_CODE", "comment": null}, "PRIMARY_SPECIALTY_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "PRIMARY_SPECIALTY_DESCRIPTION", "comment": null}, "PROVIDER_FIRST_NAME": {"type": "TEXT", "index": 6, "name": "PROVIDER_FIRST_NAME", "comment": null}, "PROVIDER_LAST_NAME": {"type": "TEXT", "index": 7, "name": "PROVIDER_LAST_NAME", "comment": null}, "PROVIDER_ORGANIZATION_NAME": {"type": "TEXT", "index": 8, "name": "PROVIDER_ORGANIZATION_NAME", "comment": null}, "PARENT_ORGANIZATION_NAME": {"type": "TEXT", "index": 9, "name": "PARENT_ORGANIZATION_NAME", "comment": null}, "PRACTICE_ADDRESS_LINE_1": {"type": "TEXT", "index": 10, "name": "PRACTICE_ADDRESS_LINE_1", "comment": null}, "PRACTICE_ADDRESS_LINE_2": {"type": "TEXT", "index": 11, "name": "PRACTICE_ADDRESS_LINE_2", "comment": null}, "PRACTICE_CITY": {"type": "TEXT", "index": 12, "name": "PRACTICE_CITY", "comment": null}, "PRACTICE_STATE": {"type": "TEXT", "index": 13, "name": "PRACTICE_STATE", "comment": null}, "PRACTICE_ZIP_CODE": {"type": "TEXT", "index": 14, "name": "PRACTICE_ZIP_CODE", "comment": null}, "LAST_UPDATED": {"type": "DATE", "index": 15, "name": "LAST_UPDATED", "comment": null}, "DEACTIVATION_DATE": {"type": "DATE", "index": 16, "name": "DEACTIVATION_DATE", "comment": null}, "DEACTIVATION_FLAG": {"type": "TEXT", "index": 17, "name": "DEACTIVATION_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 264403968, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 8576349, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__provider"}, "model.the_tuva_project.lab__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "LAB__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.lab__generate_encounter_id"}, "model.the_tuva_project.office_visits__int_office_visits_claim_line": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_CLAIM_LINE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 3, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_claim_line"}, "model.the_tuva_project.data_quality__medication_quantity": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_QUANTITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_quantity"}, "model.the_tuva_project.core__stg_clinical_encounter": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_ENCOUNTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_encounter"}, "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"}, "model.the_tuva_project.service_category__office_based_surgery_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_SURGERY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_surgery_professional"}, "model.the_tuva_project.encounters__stg_eligibility": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ENCOUNTERS__STG_ELIGIBILITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 2, "name": "BIRTH_DATE", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 4, "name": "RACE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 5, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "PATIENT_ROW_NUM": {"type": "NUMBER", "index": 6, "name": "PATIENT_ROW_NUM", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.encounters__stg_eligibility"}, "model.the_tuva_project.data_quality__quality_measures_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_QUALITY_MEASURES_REFERENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__quality_measures_reference"}, "model.the_tuva_project.data_quality__medication_atc_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ATC_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_atc_description"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_MISSING_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates"}, "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_LAB_RESULT_LAB_RESULT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id"}, "model.the_tuva_project.service_category__ambulance_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_AMBULANCE_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__ambulance_institutional"}, "model.the_tuva_project.data_quality__procedure_practitioner_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PRACTITIONER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_practitioner_id"}, "model.the_tuva_project.inpatient_hospice__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__prof_claims"}, "model.the_tuva_project.data_quality__claim_percent": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLAIM_PERCENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_TYPE": {"type": "TEXT", "index": 1, "name": "CLAIM_TYPE", "comment": null}, "PERCENT_OF_TOTAL_PAID": {"type": "FLOAT", "index": 2, "name": "PERCENT_OF_TOTAL_PAID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_percent"}, "model.the_tuva_project.ahrq_measures__pqi_num_long": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_NUM_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "PQI_NUMBER": {"type": "TEXT", "index": 5, "name": "PQI_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_num_long"}, "model.the_tuva_project.readmissions__encounter_augmented": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "ENCOUNTER_AUGMENTED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 9, "name": "LENGTH_OF_STAY", "comment": null}, "INDEX_ADMISSION_FLAG": {"type": "NUMBER", "index": 10, "name": "INDEX_ADMISSION_FLAG", "comment": null}, "PLANNED_FLAG": {"type": "NUMBER", "index": 11, "name": "PLANNED_FLAG", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 12, "name": "SPECIALTY_COHORT", "comment": null}, "DIED_FLAG": {"type": "NUMBER", "index": 13, "name": "DIED_FLAG", "comment": null}, "DIAGNOSIS_CCS": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CCS", "comment": null}, "DISQUALIFIED_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 15, "name": "DISQUALIFIED_ENCOUNTER_FLAG", "comment": null}, "MISSING_ADMIT_DATE_FLAG": {"type": "NUMBER", "index": 16, "name": "MISSING_ADMIT_DATE_FLAG", "comment": null}, "MISSING_DISCHARGE_DATE_FLAG": {"type": "NUMBER", "index": 17, "name": "MISSING_DISCHARGE_DATE_FLAG", "comment": null}, "ADMIT_AFTER_DISCHARGE_FLAG": {"type": "NUMBER", "index": 18, "name": "ADMIT_AFTER_DISCHARGE_FLAG", "comment": null}, "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 19, "name": "MISSING_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG": {"type": "NUMBER", "index": 20, "name": "INVALID_DISCHARGE_DISPOSITION_CODE_FLAG", "comment": null}, "MISSING_PRIMARY_DIAGNOSIS_FLAG": {"type": "NUMBER", "index": 21, "name": "MISSING_PRIMARY_DIAGNOSIS_FLAG", "comment": null}, "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG": {"type": "NUMBER", "index": 22, "name": "INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG", "comment": null}, "NO_DIAGNOSIS_CCS_FLAG": {"type": "NUMBER", "index": 23, "name": "NO_DIAGNOSIS_CCS_FLAG", "comment": null}, "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG": {"type": "NUMBER", "index": 24, "name": "OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG", "comment": null}, "MISSING_MS_DRG_FLAG": {"type": "NUMBER", "index": 25, "name": "MISSING_MS_DRG_FLAG", "comment": null}, "INVALID_MS_DRG_FLAG": {"type": "NUMBER", "index": 26, "name": "INVALID_MS_DRG_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_augmented"}, "model.the_tuva_project.quality_measures__int_nqf0097_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0097_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_long"}, "model.the_tuva_project.data_quality__medical_claim_provider_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_PROVIDER_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_provider_npi"}, "model.the_tuva_project.service_category__pharmacy_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__PHARMACY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__pharmacy_professional"}, "model.the_tuva_project.data_quality__chronic_conditions_none": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CHRONIC_CONDITIONS_NONE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "MEDICARE_LDS_REFERENCE": {"type": "TEXT", "index": 3, "name": "MEDICARE_LDS_REFERENCE", "comment": null}, "NORMALLY_ZERO": {"type": "NUMBER", "index": 4, "name": "NORMALLY_ZERO", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_none"}, "seed.the_tuva_project.terminology__icd_10_cm": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_10_CM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "HEADER_FLAG": {"type": "TEXT", "index": 2, "name": "HEADER_FLAG", "comment": null}, "SHORT_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "SHORT_DESCRIPTION", "comment": null}, "LONG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "LONG_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2130944, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 97296, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_10_cm"}, "model.the_tuva_project.data_quality__observation_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_code"}, "model.the_tuva_project.data_quality__claim_type_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_TYPE_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 2, "name": "CLAIM_TYPE", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 3, "name": "CLAIM_COUNT", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 4, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_type_summary"}, "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_CONDITION_CONDITION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_condition_condition_id"}, "model.the_tuva_project.data_quality__readmissions_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_READMISSIONS_REFERENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__readmissions_reference"}, "model.the_tuva_project.cms_hcc__patient_risk_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "PATIENT_RISK_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 2, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 3, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 4, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 5, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 6, "name": "FACTOR_TYPE", "comment": null}, "RISK_FACTOR_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "RISK_FACTOR_DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 8, "name": "COEFFICIENT", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 9, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 10, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_factors"}, "model.the_tuva_project.inpatient_rehab__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__generate_encounter_id"}, "model.the_tuva_project.service_category__outpatient_hospice_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPICE_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_institutional"}, "model.the_tuva_project.data_quality__observation_observation_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_OBSERVATION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_observation_id"}, "model.the_tuva_project.data_quality__medication_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_patient_id"}, "model.the_tuva_project.service_category__stg_inpatient_institutional": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "SERVICE_CATEGORY__STG_INPATIENT_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 2, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_inpatient_institutional"}, "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_PROCEDURE_PROCEDURE_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DIAGNOSIS_CODE_3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_3"}, "model.the_tuva_project.quality_measures__int_cbe0101_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_numerator"}, "model.the_tuva_project.data_quality__pharmacy_quantity": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_QUANTITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_quantity"}, "model.the_tuva_project.inpatient_snf__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SNF__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_snf__generate_encounter_id"}, "model.the_tuva_project.data_quality__medication_medication_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_MEDICATION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_medication_id"}, "model.the_tuva_project.office_visits__int_office_visits_ptotst": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_PTOTST", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_ptotst"}, "model.the_tuva_project.readmissions__index_time_requirement": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_INDEX_TIME_REQUIREMENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__index_time_requirement"}, "model.the_tuva_project.data_quality__condition_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_NORMALIZED_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code"}, "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_STG_PQI_MEMBER_MONTHS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "FIRST_DAY_OF_MONTH": {"type": "DATE", "index": 3, "name": "FIRST_DAY_OF_MONTH", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 4, "name": "YEAR_MONTH", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_member_months"}, "model.the_tuva_project.data_quality__encounter_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_id"}, "seed.the_tuva_project.terminology__snomed_icd_10_map": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "SNOMED_ICD_10_MAP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "EFFECTIVE_TIME": {"type": "TEXT", "index": 2, "name": "EFFECTIVE_TIME", "comment": null}, "ACTIVE": {"type": "TEXT", "index": 3, "name": "ACTIVE", "comment": null}, "MODULE_ID": {"type": "TEXT", "index": 4, "name": "MODULE_ID", "comment": null}, "REF_SET_ID": {"type": "TEXT", "index": 5, "name": "REF_SET_ID", "comment": null}, "REFERENCED_COMPONENT_ID": {"type": "TEXT", "index": 6, "name": "REFERENCED_COMPONENT_ID", "comment": null}, "REFERENCED_COMPONENT_NAME": {"type": "TEXT", "index": 7, "name": "REFERENCED_COMPONENT_NAME", "comment": null}, "MAP_GROUP": {"type": "TEXT", "index": 8, "name": "MAP_GROUP", "comment": null}, "MAP_PRIORITY": {"type": "TEXT", "index": 9, "name": "MAP_PRIORITY", "comment": null}, "MAP_RULE": {"type": "TEXT", "index": 10, "name": "MAP_RULE", "comment": null}, "MAP_ADVICE": {"type": "TEXT", "index": 11, "name": "MAP_ADVICE", "comment": null}, "MAP_TARGET": {"type": "TEXT", "index": 12, "name": "MAP_TARGET", "comment": null}, "MAP_TARGET_NAME": {"type": "TEXT", "index": 13, "name": "MAP_TARGET_NAME", "comment": null}, "CORRELATION_ID": {"type": "TEXT", "index": 14, "name": "CORRELATION_ID", "comment": null}, "MAP_CATEGORY_ID": {"type": "TEXT", "index": 15, "name": "MAP_CATEGORY_ID", "comment": null}, "MAP_CATEGORY_NAME": {"type": "TEXT", "index": 16, "name": "MAP_CATEGORY_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 11658240, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 256479, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__snomed_icd_10_map"}, "model.the_tuva_project.dme__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "DME__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dme__match_claims_to_anchor"}, "model.the_tuva_project.outpatient_rehab__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__encounter_grain"}, "model.the_tuva_project.inpatient_hospice__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_HOSPICE__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_hospice__generate_encounter_id"}, "seed.the_tuva_project.clinical_concept_library__value_set_members": {"metadata": {"type": "BASE TABLE", "schema": "CLINICAL_CONCEPT_LIBRARY", "name": "VALUE_SET_MEMBERS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"VALUE_SET_MEMBER_ID": {"type": "TEXT", "index": 1, "name": "VALUE_SET_MEMBER_ID", "comment": null}, "CONCEPT_ID": {"type": "TEXT", "index": 2, "name": "CONCEPT_ID", "comment": null}, "STATUS": {"type": "TEXT", "index": 3, "name": "STATUS", "comment": null}, "LAST_UPDATE_DATE": {"type": "DATE", "index": 4, "name": "LAST_UPDATE_DATE", "comment": null}, "LAST_UPDATE_NOTE": {"type": "TEXT", "index": 5, "name": "LAST_UPDATE_NOTE", "comment": null}, "CODE": {"type": "TEXT", "index": 6, "name": "CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "CODE_DESCRIPTION", "comment": null}, "CODING_SYSTEM_ID": {"type": "TEXT", "index": 8, "name": "CODING_SYSTEM_ID", "comment": null}, "CODING_SYSTEM_VERSION": {"type": "TEXT", "index": 9, "name": "CODING_SYSTEM_VERSION", "comment": null}, "INCLUDE_DESCENDANTS": {"type": "TEXT", "index": 10, "name": "INCLUDE_DESCENDANTS", "comment": null}, "COMMENT": {"type": "TEXT", "index": 11, "name": "COMMENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 274944, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 12164, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.clinical_concept_library__value_set_members"}, "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_15_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions"}, "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_12_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_denom"}, "model.the_tuva_project.service_category__stg_professional": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "SERVICE_CATEGORY__STG_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 4, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_professional"}, "model.the_tuva_project.data_quality__claim_plan": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PLAN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_plan"}, "model.the_tuva_project.acute_inpatient__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__start_end_dates"}, "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DISABLED_INTERACTION_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 3, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 4, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 5, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 6, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors"}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_SKILLED_NURSING_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional"}, "model.the_tuva_project.normalized_input__int_undetermined_claim_type": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_UNDETERMINED_CLAIM_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 16, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 17, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 18, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 22, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 24, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 25, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 26, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 27, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 28, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 29, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 30, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 31, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 32, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 33, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 34, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 35, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 36, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 37, "name": "RENDERING_NPI", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 38, "name": "RENDERING_NAME", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 39, "name": "BILLING_NPI", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 40, "name": "BILLING_NAME", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 41, "name": "FACILITY_NPI", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 42, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 43, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 44, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 45, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 46, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 47, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 48, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 49, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 50, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 93, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 94, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 95, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 96, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 97, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 98, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 99, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 100, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 101, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 119, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 120, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 121, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 122, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 123, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 124, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 125, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 126, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 127, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 144, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 145, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 146, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 147, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 148, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 149, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 150, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 151, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 152, "name": "PROCEDURE_DATE_25", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 153, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 154, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_undetermined_claim_type"}, "model.the_tuva_project.mart_review__patient": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}, "PATIENT_DATA_SOURCE_KEY": {"type": "TEXT", "index": 21, "name": "PATIENT_DATA_SOURCE_KEY", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient"}, "model.the_tuva_project.financial_pmpm__pmpm_payer": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "PMPM_PAYER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 2, "name": "PAYER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 4, "name": "MEMBER_MONTHS", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 5, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 6, "name": "MEDICAL_PAID", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 7, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 8, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 9, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 10, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 11, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 12, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 13, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 14, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 15, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 16, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 17, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 18, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 19, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 20, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 21, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 22, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 23, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 24, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 25, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 26, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 27, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 28, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 29, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 30, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 31, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 32, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 33, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 34, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 35, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 36, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 37, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 38, "name": "URGENT_CARE_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 39, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 40, "name": "MEDICAL_ALLOWED", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 41, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 42, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 43, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 44, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 45, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 46, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 47, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 48, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 49, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 50, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 51, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 52, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 53, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 54, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 55, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 56, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 57, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 58, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 59, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 60, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 61, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 62, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 63, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 64, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 65, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 70, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 71, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 72, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 73, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer"}, "seed.the_tuva_project.reference_data__ansi_fips_state": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "ANSI_FIPS_STATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANSI_FIPS_STATE_CODE": {"type": "TEXT", "index": 1, "name": "ANSI_FIPS_STATE_CODE", "comment": null}, "ANSI_FIPS_STATE_ABBREVIATION": {"type": "TEXT", "index": 2, "name": "ANSI_FIPS_STATE_ABBREVIATION", "comment": null}, "ANSI_FIPS_STATE_NAME": {"type": "TEXT", "index": 3, "name": "ANSI_FIPS_STATE_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 55, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__ansi_fips_state"}, "model.the_tuva_project.core__pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "PHARMACY_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PHARMACY_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "PHARMACY_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 9, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 12, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 13, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 15, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 16, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 17, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 18, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 23, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 25, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__pharmacy_claim"}, "model.the_tuva_project.mart_review__inpatient": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__INPATIENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_GROUP", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 7, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 15, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 16, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 17, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 18, "name": "FACILITY_TYPE", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 20, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 21, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 22, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 23, "name": "PHARMACY_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 24, "name": "ED_FLAG", "comment": null}, "DELIVERY_FLAG": {"type": "NUMBER", "index": 25, "name": "DELIVERY_FLAG", "comment": null}, "DELIVERY_TYPE": {"type": "TEXT", "index": 26, "name": "DELIVERY_TYPE", "comment": null}, "NEWBORN_FLAG": {"type": "NUMBER", "index": 27, "name": "NEWBORN_FLAG", "comment": null}, "NICU_FLAG": {"type": "NUMBER", "index": 28, "name": "NICU_FLAG", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 29, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 30, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 31, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 32, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 33, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 34, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 35, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 36, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 37, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 38, "name": "CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 39, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 40, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 41, "name": "PROF_CLAIM_COUNT", "comment": null}, "SOURCE_MODEL": {"type": "TEXT", "index": 42, "name": "SOURCE_MODEL", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 43, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 44, "name": "TUVA_LAST_RUN", "comment": null}, "ENCOUNTER_SOURCE_TYPE": {"type": "TEXT", "index": 45, "name": "ENCOUNTER_SOURCE_TYPE", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 46, "name": "PATIENT_SOURCE_KEY", "comment": null}, "ENCOUNTER_SOURCE_KEY": {"type": "TEXT", "index": 47, "name": "ENCOUNTER_SOURCE_KEY", "comment": null}, "DRGWITHDESCRIPTION": {"type": "TEXT", "index": 48, "name": "DRGWITHDESCRIPTION", "comment": null}, "PRIMARY_DIAGNOSIS_AND_DESCRIPTION": {"type": "TEXT", "index": 49, "name": "PRIMARY_DIAGNOSIS_AND_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 50, "name": "ADMIT_SOURCE_CODE_AND_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 51, "name": "ADMIT_TYPE_CODE_AND_DESCRIPTION", "comment": null}, "DISCHARGE_CODE_AND_DESCRIPTION": {"type": "TEXT", "index": 52, "name": "DISCHARGE_CODE_AND_DESCRIPTION", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 53, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 54, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 55, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_AND_DESCRIPTION": {"type": "TEXT", "index": 56, "name": "CCSR_CATEGORY_AND_DESCRIPTION", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 57, "name": "BODY_SYSTEM", "comment": null}, "LOS_GROUPS": {"type": "TEXT", "index": 58, "name": "LOS_GROUPS", "comment": null}, "DRG_WEIGHT": {"type": "NUMBER", "index": 59, "name": "DRG_WEIGHT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__inpatient"}, "model.the_tuva_project.data_quality__practitioner_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_npi"}, "model.the_tuva_project.data_quality__observation_normalized_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code"}, "model.the_tuva_project.quality_measures__int_nqf0059_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_denominator"}, "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_LOOKBACK": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_LOOKBACK", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372__performance_period"}, "model.the_tuva_project.asc__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 8, "name": "LENGTH_OF_STAY", "comment": null}, "GENDER": {"type": "TEXT", "index": 9, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 10, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 14, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 15, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 16, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 17, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 18, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 19, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 20, "name": "PHARMACY_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 21, "name": "HCPCS_CODE", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 24, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 27, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 28, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 29, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__encounter_grain"}, "model.the_tuva_project.data_quality__observation_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code_type"}, "model.the_tuva_project.cms_hcc__int_hcc_count_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_HCC_COUNT_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 3, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 4, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 5, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 6, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_count_factors"}, "model.the_tuva_project.data_quality__medication_route": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ROUTE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_route"}, "model.the_tuva_project.data_quality__eligibility_first_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_FIRST_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_first_name"}, "model.the_tuva_project.data_quality__institutional_ms_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_MS_DRG_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_ms_drg_code"}, "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CLAIMS_FOR_PBI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SUMMARY_SK": {"type": "NUMBER", "index": 1, "name": "SUMMARY_SK", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 4, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 5, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 6, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 7, "name": "INVALID_REASON", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 8, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 9, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "FREQUENCY": {"type": "NUMBER", "index": 11, "name": "FREQUENCY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_for_pbi"}, "model.the_tuva_project.data_quality__location_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_data_source"}, "model.the_tuva_project.core__stg_claims_patient": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_PATIENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 18, "name": "AGE", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 19, "name": "AGE_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_patient"}, "model.the_tuva_project.mart_review__patient_risk_factors": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT_RISK_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 2, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 3, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 4, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 5, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 6, "name": "FACTOR_TYPE", "comment": null}, "RISK_FACTOR_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "RISK_FACTOR_DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 8, "name": "COEFFICIENT", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 9, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 10, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}, "PATIENT_RISK_SK": {"type": "NUMBER", "index": 12, "name": "PATIENT_RISK_SK", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient_risk_factors"}, "model.the_tuva_project.data_quality__observation_normalized_units": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_UNITS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_units"}, "model.the_tuva_project.outpatient_radiology__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 20, "name": "HCPCS_CODE", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__encounter_grain"}, "model.the_tuva_project.inpatient_rehab__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_REHAB__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_rehab__start_end_dates"}, "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_VALUE_SET_HCC_DESCRIPTIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCC_CODE": {"type": "TEXT", "index": 1, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "HCC_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4608, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 115, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"}, "model.the_tuva_project.normalized_input__int_admit_type_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_TYPE_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_final"}, "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor"}, "model.the_tuva_project.quality_measures__int_cqm236__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236__performance_period"}, "model.the_tuva_project.data_quality__location_facility_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_FACILITY_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_facility_type"}, "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_03_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_denom"}, "model.the_tuva_project.ahrq_measures__int_pqi_16_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_16_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_num"}, "model.the_tuva_project.data_quality__procedure_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_patient_id"}, "model.the_tuva_project.data_quality__eligibility_plan": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PLAN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_plan"}, "model.the_tuva_project.quality_measures__int_nqf0420_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_numerator"}, "model.the_tuva_project.quality_measures__int_nqf2372_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_long"}, "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_16_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"}, "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DISCHARGE_DISPOSITION_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_disposition_code"}, "model.the_tuva_project.asc__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 3, "name": "END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__generate_encounter_id"}, "model.the_tuva_project.data_quality__condition_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_encounter_id"}, "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 3, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 4, "name": "NDC_CODE", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 5, "name": "DAYS_SUPPLY", "comment": null}, "DAYS_IN_TREATMENT_PERIOD": {"type": "NUMBER", "index": 6, "name": "DAYS_IN_TREATMENT_PERIOD", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 7, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 8, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 9, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 10, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 11, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 12, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator"}, "model.the_tuva_project.quality_measures__int_nqf0420_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_denominator"}, "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_11_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions"}, "model.the_tuva_project.ahrq_measures__int_pqi_12_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_12_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_num"}, "model.the_tuva_project.outpatient_radiology__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_RADIOLOGY__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 3, "name": "HCPCS_CODE", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_radiology__generate_encounter_id"}, "model.the_tuva_project.outpatient_ptotst__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__anchor_events"}, "model.the_tuva_project.data_quality__location_address": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_ADDRESS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_address"}, "model.the_tuva_project.quality_measures__int_cqm236_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 7, "name": "OBSERVATION_DATE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_numerator"}, "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_HCC_HIERARCHY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 2, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 3, "name": "PAYMENT_YEAR", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 4, "name": "HCC_CODE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_hierarchy"}, "model.the_tuva_project.cms_hcc__int_members": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_MEMBERS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 2, "name": "ENROLLMENT_STATUS", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 4, "name": "AGE_GROUP", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 5, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 6, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 7, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 8, "name": "INSTITUTIONAL_STATUS", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 9, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 10, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 11, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 12, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 13, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_members"}, "model.the_tuva_project.data_quality__encounters_missing_groups_union": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_MISSING_GROUPS_UNION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups_union"}, "model.the_tuva_project.office_visits__int_office_visits_surgery": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OFFICE_VISITS__INT_OFFICE_VISITS_SURGERY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_surgery"}, "model.the_tuva_project.normalized_input__int_apr_drg_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_APR_DRG_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_voting"}, "model.the_tuva_project.data_quality__ed_classification": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_ED_CLASSIFICATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__ed_classification"}, "model.the_tuva_project.service_category__office_based_visit_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OFFICE_BASED_VISIT_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_visit_professional"}, "model.the_tuva_project.data_quality__eligibility_payer_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PAYER_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer_type"}, "model.the_tuva_project.data_quality__procedure_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_CLAIM_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_claim_id"}, "model.the_tuva_project.data_quality__patient_birth_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_BIRTH_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_birth_date"}, "seed.the_tuva_project.terminology__medicare_dual_eligibility": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MEDICARE_DUAL_ELIGIBILITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DUAL_STATUS_CODE": {"type": "TEXT", "index": 1, "name": "DUAL_STATUS_CODE", "comment": null}, "DUAL_STATUS_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DUAL_STATUS_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__medicare_dual_eligibility"}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_NORMALIZED_REFERENCE_RANGE_HIGH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_high"}, "model.the_tuva_project.data_quality__professional_billing_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_BILLING_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_billing_npi"}, "model.the_tuva_project.quality_measures__int_cqm438__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438__performance_period"}, "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DIAGNOSIS_CODE_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_COLUMN": {"type": "TEXT", "index": 4, "name": "DIAGNOSIS_COLUMN", "comment": null}, "NORMALIZED_DIAGNOSIS_CODE": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DIAGNOSIS_CODE", "comment": null}, "DIAGNOSIS_CODE_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "DIAGNOSIS_CODE_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize"}, "model.the_tuva_project.normalized_input__int_apr_drg_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_APR_DRG_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_final"}, "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 1, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_1YP": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN_1YP", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_2YP": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN_2YP", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_4YP": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_BEGIN_4YP", "comment": null}, "PERFORMANCE_PERIOD_BEGIN_9YP": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_BEGIN_9YP", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034__performance_period"}, "model.the_tuva_project.data_quality__institutional_admission_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_ADMISSION_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_admission_date"}, "model.the_tuva_project.readmissions__procedure_ccs": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_PROCEDURE_CCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PROCEDURE_CODE": {"type": "TEXT", "index": 2, "name": "PROCEDURE_CODE", "comment": null}, "VALID_ICD_10_PCS_FLAG": {"type": "NUMBER", "index": 3, "name": "VALID_ICD_10_PCS_FLAG", "comment": null}, "CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 4, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__procedure_ccs"}, "model.the_tuva_project.data_quality__encounter_attending_provider_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ATTENDING_PROVIDER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_attending_provider_id"}, "model.the_tuva_project.data_quality__location_latitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_LATITUDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_latitude"}, "model.the_tuva_project.normalized_input__int_admit_source_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_SOURCE_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_voting"}, "model.the_tuva_project.data_quality__medication_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_data_source"}, "model.the_tuva_project.data_quality__pharmacy_paid_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PAID_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_amount"}, "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_ICD_10_CM_MAPPINGS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PAYMENT_YEAR": {"type": "NUMBER", "index": 1, "name": "PAYMENT_YEAR", "comment": null}, "DIAGNOSIS_CODE": {"type": "TEXT", "index": 2, "name": "DIAGNOSIS_CODE", "comment": null}, "CMS_HCC_V24": {"type": "TEXT", "index": 3, "name": "CMS_HCC_V24", "comment": null}, "CMS_HCC_V24_FLAG": {"type": "TEXT", "index": 4, "name": "CMS_HCC_V24_FLAG", "comment": null}, "CMS_HCC_V28": {"type": "TEXT", "index": 5, "name": "CMS_HCC_V28", "comment": null}, "CMS_HCC_V28_FLAG": {"type": "TEXT", "index": 6, "name": "CMS_HCC_V28_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 459776, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 78932, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings"}, "model.the_tuva_project.data_quality__condition_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_patient_id"}, "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_VOLUME_AND_DOLLARS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "NUMBER", "index": 1, "name": "YEAR_MONTH", "comment": null}, "CLAIM_VOLUME": {"type": "NUMBER", "index": 2, "name": "CLAIM_VOLUME", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 3, "name": "PAID_AMOUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars"}, "model.the_tuva_project.pharmacy__int_generic_cost": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_GENERIC_COST", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"BRAND_RXCUI": {"type": "TEXT", "index": 1, "name": "BRAND_RXCUI", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY": {"type": "NUMBER", "index": 3, "name": "PRESCRIBED_ATLEAST_ONE_GENERIC_HISTORY", "comment": null}, "GENERIC_AVERAGE_COST_PER_UNIT": {"type": "NUMBER", "index": 4, "name": "GENERIC_AVERAGE_COST_PER_UNIT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost"}, "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_ACUTE_INPATIENT_INSTITUTIONAL_MED_SURG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg"}, "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__generate_encounter_id"}, "model.the_tuva_project.data_quality__service_category_pmpm_trend": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "SERVICE_CATEGORY_PMPM_TREND", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 4, "name": "TOTAL_PAID", "comment": null}, "PMPM": {"type": "NUMBER", "index": 5, "name": "PMPM", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__service_category_pmpm_trend"}, "model.the_tuva_project.data_quality__pharmacy_claim_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_id"}, "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_08_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions"}, "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_07_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_denom"}, "model.the_tuva_project.data_quality__location_longitude": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_LONGITUDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_longitude"}, "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_exclusions"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "_INT_CMS_CHRONIC_CONDITION_HIV_AIDS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"}, "model.the_tuva_project.outpatient_psych__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__encounter_grain"}, "model.the_tuva_project.service_category__combined_institutional_line_level": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_COMBINED_INSTITUTIONAL_LINE_LEVEL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__combined_institutional_line_level"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_UNION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"}, "model.the_tuva_project.quality_measures__summary_wide": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "SUMMARY_WIDE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "NQF_2372": {"type": "NUMBER", "index": 2, "name": "NQF_2372", "comment": null}, "NQF_0034": {"type": "NUMBER", "index": 3, "name": "NQF_0034", "comment": null}, "NQF_0059": {"type": "NUMBER", "index": 4, "name": "NQF_0059", "comment": null}, "CQM_236": {"type": "NUMBER", "index": 5, "name": "CQM_236", "comment": null}, "NQF_0053": {"type": "NUMBER", "index": 6, "name": "NQF_0053", "comment": null}, "CBE_0055": {"type": "NUMBER", "index": 7, "name": "CBE_0055", "comment": null}, "NQF_0097": {"type": "NUMBER", "index": 8, "name": "NQF_0097", "comment": null}, "CQM_438": {"type": "NUMBER", "index": 9, "name": "CQM_438", "comment": null}, "NQF_0041": {"type": "NUMBER", "index": 10, "name": "NQF_0041", "comment": null}, "CBE_0101": {"type": "NUMBER", "index": 11, "name": "CBE_0101", "comment": null}, "CQM_48": {"type": "NUMBER", "index": 12, "name": "CQM_48", "comment": null}, "CQM_130": {"type": "NUMBER", "index": 13, "name": "CQM_130", "comment": null}, "NQF_0420": {"type": "NUMBER", "index": 14, "name": "NQF_0420", "comment": null}, "ADH_DIABETES": {"type": "NUMBER", "index": 15, "name": "ADH_DIABETES", "comment": null}, "ADH_RAS": {"type": "NUMBER", "index": 16, "name": "ADH_RAS", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__summary_wide"}, "model.the_tuva_project.data_quality__claim_claim_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_CLAIM_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_claim_type"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator"}, "model.the_tuva_project.outpatient_psych__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PSYCH__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_psych__anchor_events"}, "model.the_tuva_project.data_quality__practitioner_sub_specialty": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRACTITIONER_SUB_SPECIALTY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__practitioner_sub_specialty"}, "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICAL_CLAIM_CLAIM_LINE_FIELDS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 6, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medical_claim_claim_line_fields"}, "model.the_tuva_project.data_quality__pharmacy_claim_ndc": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_NDC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_ndc"}, "model.the_tuva_project.core__stg_clinical_location": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLINICAL_LOCATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_clinical_location"}, "model.the_tuva_project.quality_measures__int_cqm438_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_numerator"}, "model.the_tuva_project.outpatient_surgery__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__anchor_events"}, "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISABLED_INTERACTION_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 4, "name": "INSTITUTIONAL_STATUS", "comment": null}, "SHORT_NAME": {"type": "TEXT", "index": 5, "name": "SHORT_NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 6, "name": "DESCRIPTION", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 7, "name": "HCC_CODE", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 8, "name": "COEFFICIENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4096, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 40, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disabled_interaction_factors"}, "seed.the_tuva_project.terminology__admit_source": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ADMIT_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 1, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "NEWBORN_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "NEWBORN_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 16, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__admit_source"}, "model.the_tuva_project.acute_inpatient__generate_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "END_DATE": {"type": "DATE", "index": 4, "name": "END_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "ENCOUNTER_CLAIM_NUMBER": {"type": "NUMBER", "index": 7, "name": "ENCOUNTER_CLAIM_NUMBER", "comment": null}, "ENCOUNTER_CLAIM_NUMBER_DESC": {"type": "NUMBER", "index": 8, "name": "ENCOUNTER_CLAIM_NUMBER_DESC", "comment": null}, "CLOSE_FLAG": {"type": "NUMBER", "index": 9, "name": "CLOSE_FLAG", "comment": null}, "MIN_CLOSING_ROW": {"type": "NUMBER", "index": 10, "name": "MIN_CLOSING_ROW", "comment": null}, "ENCOUNTER_ID": {"type": "NUMBER", "index": 11, "name": "ENCOUNTER_ID", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__generate_encounter_id"}, "model.the_tuva_project.data_quality__medication_ndc_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_NDC_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_code"}, "model.the_tuva_project.hcc_suspecting__int_medication_suspects": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_MEDICATION_SUSPECTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "HCC_DESCRIPTION", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 5, "name": "DISPENSING_DATE", "comment": null}, "DRUG_CODE": {"type": "TEXT", "index": 6, "name": "DRUG_CODE", "comment": null}, "CURRENT_YEAR_BILLED": {"type": "BOOLEAN", "index": 7, "name": "CURRENT_YEAR_BILLED", "comment": null}, "REASON": {"type": "TEXT", "index": 8, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 9, "name": "CONTRIBUTING_FACTOR", "comment": null}, "SUSPECT_DATE": {"type": "DATE", "index": 10, "name": "SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_medication_suspects"}, "model.the_tuva_project.data_quality__lab_result_result": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_RESULT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_result"}, "model.the_tuva_project.quality_measures__int_cbe0055_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_numerator"}, "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain"}, "model.the_tuva_project.inpatient_substance_use__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_SUBSTANCE_USE__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 4, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 7, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 8, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 9, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 13, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 14, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 15, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 16, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 17, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 18, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 19, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 20, "name": "OBSERVATION_FLAG", "comment": null}, "ED_FLAG": {"type": "NUMBER", "index": 21, "name": "ED_FLAG", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 22, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "MS_DRG_DESCRIPTION", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 24, "name": "MEDICAL_SURGICAL", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 25, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "APR_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 27, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 31, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 33, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 34, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 35, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 36, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 37, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 38, "name": "PROF_CLAIM_COUNT", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 39, "name": "LENGTH_OF_STAY", "comment": null}, "MORTALITY_FLAG": {"type": "NUMBER", "index": 40, "name": "MORTALITY_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 41, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 42, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_substance_use__encounter_grain"}, "model.the_tuva_project.data_quality__pharmacy_dispensing_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DISPENSING_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_date"}, "model.the_tuva_project.data_quality__pharmacy_days_supply": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DAYS_SUPPLY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_days_supply"}, "model.the_tuva_project.data_quality__procedure_normalized_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_NORMALIZED_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_description"}, "model.the_tuva_project.quality_measures__int_nqf0041_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0041_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 5, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 6, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 7, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_denominator"}, "model.the_tuva_project.data_quality__eligibility_last_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_LAST_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_last_name"}, "model.the_tuva_project.readmissions__index_discharge_requirement": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_INDEX_DISCHARGE_REQUIREMENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__index_discharge_requirement"}, "model.the_tuva_project.data_quality__eligibility_death_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DEATH_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_date"}, "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "SNOMED_CT_TRANSITIVE_CLOSURES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PARENT_SNOMED_CODE": {"type": "TEXT", "index": 1, "name": "PARENT_SNOMED_CODE", "comment": null}, "PARENT_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "PARENT_DESCRIPTION", "comment": null}, "CHILD_SNOMED_CODE": {"type": "TEXT", "index": 3, "name": "CHILD_SNOMED_CODE", "comment": null}, "CHILD_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CHILD_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 112937984, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7336247, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__snomed_ct_transitive_closures"}, "model.the_tuva_project.service_category__combined_institutional_header_level": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_COMBINED_INSTITUTIONAL_HEADER_LEVEL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__combined_institutional_header_level"}, "model.the_tuva_project.data_quality__patient_race": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_RACE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_race"}, "model.the_tuva_project.data_quality__encounter_paid_amount": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PAID_AMOUNT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_paid_amount"}, "model.the_tuva_project.quality_measures__int_cqm48_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 8, "name": "EVIDENCE_VALUE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_numerator"}, "seed.input_layer.lab_result_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "LAB_RESULT_SEED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 12, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 13, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 15, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 16, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 17, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 18, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 21, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "NUMBER", "index": 23, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "NUMBER", "index": 24, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 25, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 26, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 28, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.lab_result_seed"}, "model.the_tuva_project.data_quality__condition_present_on_admit_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_PRESENT_ON_ADMIT_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_description"}, "model.the_tuva_project.normalized_input__int_procedure_code_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PROCEDURE_CODE_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 3, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 4, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 5, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 6, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 7, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 8, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 9, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 10, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 11, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 12, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 13, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 14, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 15, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 16, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 17, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 18, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 19, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 20, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 21, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 22, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 23, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 24, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 25, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 26, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 27, "name": "PROCEDURE_CODE_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_final"}, "model.the_tuva_project.data_quality__readmissions": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_READMISSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__readmissions"}, "model.the_tuva_project.data_quality__procedure_modifier_4": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_4", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_4"}, "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_12_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions"}, "model.the_tuva_project.data_quality__professional_claim_end_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_CLAIM_END_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_claim_end_date"}, "model.the_tuva_project.normalized_input__int_admit_type_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_ADMIT_TYPE_NORMALIZE_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_voting"}, "model.the_tuva_project.service_category__lab_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_LAB_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 6, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__lab_institutional"}, "model.the_tuva_project.data_quality__procedure_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code"}, "model.the_tuva_project.data_quality__professional_diagnosis_code_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_DIAGNOSIS_CODE_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_2"}, "model.the_tuva_project.data_quality__condition_normalized_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_NORMALIZED_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code_type"}, "seed.the_tuva_project.reference_data__code_type": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CODE_TYPE": {"type": "TEXT", "index": 1, "name": "CODE_TYPE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 6, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__code_type"}, "model.the_tuva_project.readmissions__encounter_overlap": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_OVERLAP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID_A": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_ID_A", "comment": null}, "ENCOUNTER_ID_B": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID_B", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_overlap"}, "seed.the_tuva_project.ed_classification__johnston_icd9": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_JOHNSTON_ICD9", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD9": {"type": "TEXT", "index": 1, "name": "ICD9", "comment": null}, "EDCNNPA": {"type": "TEXT", "index": 2, "name": "EDCNNPA", "comment": null}, "EDCNPA": {"type": "TEXT", "index": 3, "name": "EDCNPA", "comment": null}, "EPCT": {"type": "TEXT", "index": 4, "name": "EPCT", "comment": null}, "NONER": {"type": "TEXT", "index": 5, "name": "NONER", "comment": null}, "INJURY": {"type": "TEXT", "index": 6, "name": "INJURY", "comment": null}, "PSYCH": {"type": "TEXT", "index": 7, "name": "PSYCH", "comment": null}, "ALCOHOL": {"type": "TEXT", "index": 8, "name": "ALCOHOL", "comment": null}, "DRUG": {"type": "TEXT", "index": 9, "name": "DRUG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 53248, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7443, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd9"}, "model.the_tuva_project.core__location": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "LOCATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__location"}, "model.the_tuva_project.data_quality__eligibility_birth_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_BIRTH_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_birth_date"}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_OUTPATIENT_HOSPITAL_OR_CLINIC_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional"}, "model.the_tuva_project.data_quality__condition_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_SOURCE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_source_description"}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_DIAGNOSIS_CODE_2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_2"}, "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__pharmacy_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_data_source"}, "model.the_tuva_project.service_category__inpatient_hospice_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_HOSPICE_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_institutional"}, "seed.the_tuva_project.terminology__revenue_center": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "REVENUE_CENTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"REVENUE_CENTER_CODE": {"type": "TEXT", "index": 1, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8704, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 526, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__revenue_center"}, "model.the_tuva_project.data_quality__condition_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_SOURCE_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_source_code_type"}, "model.the_tuva_project.outpatient_rehab__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_REHAB__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_rehab__generate_encounter_id"}, "model.the_tuva_project.quality_measures__int_cqm438_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_exclusions"}, "model.the_tuva_project.financial_pmpm__pmpm_prep": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "PMPM_PREP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 6, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 10, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "INPATIENT_PAID": {"type": "NUMBER", "index": 14, "name": "INPATIENT_PAID", "comment": null}, "OUTPATIENT_PAID": {"type": "NUMBER", "index": 15, "name": "OUTPATIENT_PAID", "comment": null}, "OFFICE_BASED_PAID": {"type": "NUMBER", "index": 16, "name": "OFFICE_BASED_PAID", "comment": null}, "ANCILLARY_PAID": {"type": "NUMBER", "index": 17, "name": "ANCILLARY_PAID", "comment": null}, "OTHER_PAID": {"type": "NUMBER", "index": 18, "name": "OTHER_PAID", "comment": null}, "PHARMACY_PAID": {"type": "NUMBER", "index": 19, "name": "PHARMACY_PAID", "comment": null}, "ACUTE_INPATIENT_PAID": {"type": "NUMBER", "index": 20, "name": "ACUTE_INPATIENT_PAID", "comment": null}, "AMBULANCE_PAID": {"type": "NUMBER", "index": 21, "name": "AMBULANCE_PAID", "comment": null}, "AMBULATORY_SURGERY_CENTER_PAID": {"type": "NUMBER", "index": 22, "name": "AMBULATORY_SURGERY_CENTER_PAID", "comment": null}, "DIALYSIS_PAID": {"type": "NUMBER", "index": 23, "name": "DIALYSIS_PAID", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_PAID": {"type": "NUMBER", "index": 24, "name": "DURABLE_MEDICAL_EQUIPMENT_PAID", "comment": null}, "EMERGENCY_DEPARTMENT_PAID": {"type": "NUMBER", "index": 25, "name": "EMERGENCY_DEPARTMENT_PAID", "comment": null}, "HOME_HEALTH_PAID": {"type": "NUMBER", "index": 26, "name": "HOME_HEALTH_PAID", "comment": null}, "INPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 27, "name": "INPATIENT_HOSPICE_PAID", "comment": null}, "INPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 28, "name": "INPATIENT_PSYCHIATRIC_PAID", "comment": null}, "INPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 29, "name": "INPATIENT_REHABILITATION_PAID", "comment": null}, "LAB_PAID": {"type": "NUMBER", "index": 30, "name": "LAB_PAID", "comment": null}, "OBSERVATION_PAID": {"type": "NUMBER", "index": 31, "name": "OBSERVATION_PAID", "comment": null}, "OFFICE_BASED_OTHER_PAID": {"type": "NUMBER", "index": 32, "name": "OFFICE_BASED_OTHER_PAID", "comment": null}, "OFFICE_BASED_PT_OT_ST_PAID": {"type": "NUMBER", "index": 33, "name": "OFFICE_BASED_PT_OT_ST_PAID", "comment": null}, "OFFICE_BASED_RADIOLOGY_PAID": {"type": "NUMBER", "index": 34, "name": "OFFICE_BASED_RADIOLOGY_PAID", "comment": null}, "OFFICE_BASED_SURGERY_PAID": {"type": "NUMBER", "index": 35, "name": "OFFICE_BASED_SURGERY_PAID", "comment": null}, "OFFICE_BASED_VISIT_PAID": {"type": "NUMBER", "index": 36, "name": "OFFICE_BASED_VISIT_PAID", "comment": null}, "OTHER_PAID_2": {"type": "NUMBER", "index": 37, "name": "OTHER_PAID_2", "comment": null}, "OUTPATIENT_HOSPICE_PAID": {"type": "NUMBER", "index": 38, "name": "OUTPATIENT_HOSPICE_PAID", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID": {"type": "NUMBER", "index": 39, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_PAID", "comment": null}, "OUTPATIENT_PT_OT_ST_PAID": {"type": "NUMBER", "index": 40, "name": "OUTPATIENT_PT_OT_ST_PAID", "comment": null}, "OUTPATIENT_PSYCHIATRIC_PAID": {"type": "NUMBER", "index": 41, "name": "OUTPATIENT_PSYCHIATRIC_PAID", "comment": null}, "OUTPATIENT_RADIOLOGY_PAID": {"type": "NUMBER", "index": 42, "name": "OUTPATIENT_RADIOLOGY_PAID", "comment": null}, "OUTPATIENT_REHABILITATION_PAID": {"type": "NUMBER", "index": 43, "name": "OUTPATIENT_REHABILITATION_PAID", "comment": null}, "OUTPATIENT_SURGERY_PAID": {"type": "NUMBER", "index": 44, "name": "OUTPATIENT_SURGERY_PAID", "comment": null}, "PHARMACY_PAID_2": {"type": "NUMBER", "index": 45, "name": "PHARMACY_PAID_2", "comment": null}, "SKILLED_NURSING_PAID": {"type": "NUMBER", "index": 46, "name": "SKILLED_NURSING_PAID", "comment": null}, "TELEHEALTH_VISIT_PAID": {"type": "NUMBER", "index": 47, "name": "TELEHEALTH_VISIT_PAID", "comment": null}, "URGENT_CARE_PAID": {"type": "NUMBER", "index": 48, "name": "URGENT_CARE_PAID", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 49, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 50, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 51, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 52, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 53, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 54, "name": "PHARMACY_ALLOWED", "comment": null}, "ACUTE_INPATIENT_ALLOWED": {"type": "NUMBER", "index": 55, "name": "ACUTE_INPATIENT_ALLOWED", "comment": null}, "AMBULANCE_ALLOWED": {"type": "NUMBER", "index": 56, "name": "AMBULANCE_ALLOWED", "comment": null}, "AMBULATORY_SURGERY_CENTER_ALLOWED": {"type": "NUMBER", "index": 57, "name": "AMBULATORY_SURGERY_CENTER_ALLOWED", "comment": null}, "DIALYSIS_ALLOWED": {"type": "NUMBER", "index": 58, "name": "DIALYSIS_ALLOWED", "comment": null}, "DURABLE_MEDICAL_EQUIPMENT_ALLOWED": {"type": "NUMBER", "index": 59, "name": "DURABLE_MEDICAL_EQUIPMENT_ALLOWED", "comment": null}, "EMERGENCY_DEPARTMENT_ALLOWED": {"type": "NUMBER", "index": 60, "name": "EMERGENCY_DEPARTMENT_ALLOWED", "comment": null}, "HOME_HEALTH_ALLOWED": {"type": "NUMBER", "index": 61, "name": "HOME_HEALTH_ALLOWED", "comment": null}, "INPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 62, "name": "INPATIENT_HOSPICE_ALLOWED", "comment": null}, "INPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 63, "name": "INPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "INPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 64, "name": "INPATIENT_REHABILITATION_ALLOWED", "comment": null}, "LAB_ALLOWED": {"type": "NUMBER", "index": 65, "name": "LAB_ALLOWED", "comment": null}, "OBSERVATION_ALLOWED": {"type": "NUMBER", "index": 66, "name": "OBSERVATION_ALLOWED", "comment": null}, "OFFICE_BASED_OTHER_ALLOWED": {"type": "NUMBER", "index": 67, "name": "OFFICE_BASED_OTHER_ALLOWED", "comment": null}, "OFFICE_BASED_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 68, "name": "OFFICE_BASED_PT_OT_ST_ALLOWED", "comment": null}, "OFFICE_BASED_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 69, "name": "OFFICE_BASED_RADIOLOGY_ALLOWED", "comment": null}, "OFFICE_BASED_SURGERY_ALLOWED": {"type": "NUMBER", "index": 70, "name": "OFFICE_BASED_SURGERY_ALLOWED", "comment": null}, "OFFICE_BASED_VISIT_ALLOWED": {"type": "NUMBER", "index": 71, "name": "OFFICE_BASED_VISIT_ALLOWED", "comment": null}, "OTHER_ALLOWED_2": {"type": "NUMBER", "index": 72, "name": "OTHER_ALLOWED_2", "comment": null}, "OUTPATIENT_HOSPICE_ALLOWED": {"type": "NUMBER", "index": 73, "name": "OUTPATIENT_HOSPICE_ALLOWED", "comment": null}, "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED": {"type": "NUMBER", "index": 74, "name": "OUTPATIENT_HOSPITAL_OR_CLINIC_ALLOWED", "comment": null}, "OUTPATIENT_PT_OT_ST_ALLOWED": {"type": "NUMBER", "index": 75, "name": "OUTPATIENT_PT_OT_ST_ALLOWED", "comment": null}, "OUTPATIENT_PSYCHIATRIC_ALLOWED": {"type": "NUMBER", "index": 76, "name": "OUTPATIENT_PSYCHIATRIC_ALLOWED", "comment": null}, "OUTPATIENT_RADIOLOGY_ALLOWED": {"type": "NUMBER", "index": 77, "name": "OUTPATIENT_RADIOLOGY_ALLOWED", "comment": null}, "OUTPATIENT_REHABILITATION_ALLOWED": {"type": "NUMBER", "index": 78, "name": "OUTPATIENT_REHABILITATION_ALLOWED", "comment": null}, "OUTPATIENT_SURGERY_ALLOWED": {"type": "NUMBER", "index": 79, "name": "OUTPATIENT_SURGERY_ALLOWED", "comment": null}, "PHARMACY_ALLOWED_2": {"type": "NUMBER", "index": 80, "name": "PHARMACY_ALLOWED_2", "comment": null}, "SKILLED_NURSING_ALLOWED": {"type": "NUMBER", "index": 81, "name": "SKILLED_NURSING_ALLOWED", "comment": null}, "TELEHEALTH_VISIT_ALLOWED": {"type": "NUMBER", "index": 82, "name": "TELEHEALTH_VISIT_ALLOWED", "comment": null}, "URGENT_CARE_ALLOWED": {"type": "NUMBER", "index": 83, "name": "URGENT_CARE_ALLOWED", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 84, "name": "TOTAL_PAID", "comment": null}, "MEDICAL_PAID": {"type": "NUMBER", "index": 85, "name": "MEDICAL_PAID", "comment": null}, "TOTAL_ALLOWED": {"type": "NUMBER", "index": 86, "name": "TOTAL_ALLOWED", "comment": null}, "MEDICAL_ALLOWED": {"type": "NUMBER", "index": 87, "name": "MEDICAL_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 88, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_prep"}, "seed.the_tuva_project.reference_data__ssa_fips_state": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "SSA_FIPS_STATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SSA_FIPS_STATE_CODE": {"type": "TEXT", "index": 1, "name": "SSA_FIPS_STATE_CODE", "comment": null}, "SSA_FIPS_STATE_NAME": {"type": "TEXT", "index": 2, "name": "SSA_FIPS_STATE_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 78, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__ssa_fips_state"}, "model.the_tuva_project.dialysis__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "DIALYSIS__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 22, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 25, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 26, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.dialysis__encounter_grain"}, "model.the_tuva_project.data_quality__professional_rendering_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_RENDERING_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_rendering_npi"}, "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101__performance_period"}, "model.the_tuva_project.service_category__outpatient_substance_use_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_SUBSTANCE_USE_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_institutional"}, "model.the_tuva_project.quality_measures__int_cbe0101_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0101_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_long"}, "model.the_tuva_project.quality_measures__int_adhras_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_ADHRAS_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 2, "name": "DISPENSING_DATE", "comment": null}, "FIRST_DISPENSING_DATE": {"type": "DATE", "index": 3, "name": "FIRST_DISPENSING_DATE", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 4, "name": "DAYS_SUPPLY", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 5, "name": "NDC_CODE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 6, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 7, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 8, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 9, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 10, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 11, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_denominator"}, "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "FLAG_CLAIMS_WITH_ENROLLMENT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 4, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 5, "name": "PLAN", "comment": null}, "INFERRED_CLAIM_START_YEAR_MONTH": {"type": "TEXT", "index": 6, "name": "INFERRED_CLAIM_START_YEAR_MONTH", "comment": null}, "INFERRED_CLAIM_END_YEAR_MONTH": {"type": "TEXT", "index": 7, "name": "INFERRED_CLAIM_END_YEAR_MONTH", "comment": null}, "INFERRED_CLAIM_START_COLUMN_USED": {"type": "TEXT", "index": 8, "name": "INFERRED_CLAIM_START_COLUMN_USED", "comment": null}, "INFERRED_CLAIM_END_COLUMN_USED": {"type": "TEXT", "index": 9, "name": "INFERRED_CLAIM_END_COLUMN_USED", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment"}, "model.the_tuva_project.quality_measures__int_nqf0034_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0034_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_long"}, "model.the_tuva_project.data_quality__eligibility_date_checks": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_DATE_CHECKS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_date_checks"}, "model.the_tuva_project.data_quality__raw_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "RAW_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"SOURCE": {"type": "TEXT", "index": 1, "name": "SOURCE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 2, "name": "TABLE_NAME", "comment": null}, "ROW_COUNT": {"type": "NUMBER", "index": 3, "name": "ROW_COUNT", "comment": null}, "UNIQUE_CHECK": {"type": "NUMBER", "index": 4, "name": "UNIQUE_CHECK", "comment": null}, "UNIQUE_CHECK_DESC": {"type": "TEXT", "index": 5, "name": "UNIQUE_CHECK_DESC", "comment": null}, "TABLE_ORDER": {"type": "NUMBER", "index": 6, "name": "TABLE_ORDER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__raw_summary"}, "model.the_tuva_project.hcc_suspecting__list_rollup": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "LIST_ROLLUP", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 2, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "HCC_DESCRIPTION", "comment": null}, "REASON": {"type": "TEXT", "index": 4, "name": "REASON", "comment": null}, "CONTRIBUTING_FACTOR": {"type": "TEXT", "index": 5, "name": "CONTRIBUTING_FACTOR", "comment": null}, "LATEST_SUSPECT_DATE": {"type": "DATE", "index": 6, "name": "LATEST_SUSPECT_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__list_rollup"}, "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_ENROLLMENT_INTERACTION_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 3, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 4, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 5, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 6, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors"}, "model.the_tuva_project.mart_review__pharmacy": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PHARMACY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 4, "name": "DATA_SOURCE", "comment": null}, "PATIENT_SOURCE_KEY": {"type": "TEXT", "index": 5, "name": "PATIENT_SOURCE_KEY", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 6, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "NDC_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 9, "name": "ALLOWED_AMOUNT", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 10, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 11, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "PRESCRIBING_SPECIALTY": {"type": "TEXT", "index": 12, "name": "PRESCRIBING_SPECIALTY", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 13, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 14, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 15, "name": "PAID_DATE", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 16, "name": "DISPENSING_DATE", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 17, "name": "DAYS_SUPPLY", "comment": null}, "COST_PER_DAY": {"type": "NUMBER", "index": 18, "name": "COST_PER_DAY", "comment": null}, "THIRTY_DAY_EQUIVALENT_COST": {"type": "NUMBER", "index": 19, "name": "THIRTY_DAY_EQUIVALENT_COST", "comment": null}, "SPECIALTY_TIER": {"type": "NUMBER", "index": 20, "name": "SPECIALTY_TIER", "comment": null}, "RXCUI": {"type": "TEXT", "index": 21, "name": "RXCUI", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "RXNORM_DESCRIPTION", "comment": null}, "BRAND_NAME": {"type": "TEXT", "index": 23, "name": "BRAND_NAME", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 24, "name": "BRAND_VS_GENERIC", "comment": null}, "INGREDIENT_NAME": {"type": "TEXT", "index": 25, "name": "INGREDIENT_NAME", "comment": null}, "ATC_1_NAME": {"type": "TEXT", "index": 26, "name": "ATC_1_NAME", "comment": null}, "ATC_2_NAME": {"type": "TEXT", "index": 27, "name": "ATC_2_NAME", "comment": null}, "ATC_3_NAME": {"type": "TEXT", "index": 28, "name": "ATC_3_NAME", "comment": null}, "ATC_4_NAME": {"type": "TEXT", "index": 29, "name": "ATC_4_NAME", "comment": null}, "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY": {"type": "NUMBER", "index": 30, "name": "GENERIC_AVAILABLE_TOTAL_OPPORTUNITY", "comment": null}, "GENERIC_COST_AT_UNITS": {"type": "NUMBER", "index": 31, "name": "GENERIC_COST_AT_UNITS", "comment": null}, "BRAND_PAID_AMOUNT": {"type": "NUMBER", "index": 32, "name": "BRAND_PAID_AMOUNT", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 33, "name": "GENERIC_AVAILABLE", "comment": null}, "GENERIC_AVAILABLE_SK": {"type": "NUMBER", "index": 34, "name": "GENERIC_AVAILABLE_SK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 35, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__pharmacy"}, "model.the_tuva_project.normalized_input__int_ms_drg_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MS_DRG_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 7, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 8, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_voting"}, "model.the_tuva_project.home_health__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 19, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 22, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 25, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 26, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__encounter_grain"}, "model.the_tuva_project.data_quality__encounter_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_data_source"}, "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_05_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions"}, "model.the_tuva_project.service_category__dme_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_DME_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__dme_professional"}, "model.the_tuva_project.normalized_input__int_medical_date_aggregation": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_MEDICAL_DATE_AGGREGATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "MINIMUM_CLAIM_START_DATE": {"type": "DATE", "index": 3, "name": "MINIMUM_CLAIM_START_DATE", "comment": null}, "MAXIMUM_CLAIM_END_DATE": {"type": "DATE", "index": 4, "name": "MAXIMUM_CLAIM_END_DATE", "comment": null}, "MINIMUM_ADMISSION_DATE": {"type": "DATE", "index": 5, "name": "MINIMUM_ADMISSION_DATE", "comment": null}, "MAXIMUM_DISCHARGE_DATE": {"type": "DATE", "index": 6, "name": "MAXIMUM_DISCHARGE_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_medical_date_aggregation"}, "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_SHARED_EXCLUSIONS_DEMENTIA", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 5, "name": "DISPENSING_DATE", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 6, "name": "PAID_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia"}, "model.the_tuva_project.data_quality__observation_source_code_type": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_SOURCE_CODE_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_source_code_type"}, "seed.the_tuva_project.terminology__payer_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "PAYER_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PAYER_TYPE": {"type": "TEXT", "index": 1, "name": "PAYER_TYPE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__payer_type"}, "model.the_tuva_project.data_quality__service_categories_pmpm": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "SERVICE_CATEGORIES_PMPM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "TOTAL_PAID": {"type": "NUMBER", "index": 3, "name": "TOTAL_PAID", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 4, "name": "MEMBER_MONTHS", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 5, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 6, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__service_categories_pmpm"}, "model.the_tuva_project.readmissions__encounter_specialty_cohort": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_SPECIALTY_COHORT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "SPECIALTY_COHORT": {"type": "TEXT", "index": 2, "name": "SPECIALTY_COHORT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_specialty_cohort"}, "seed.the_tuva_project.terminology__nitos": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "NITOS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS_CODE": {"type": "TEXT", "index": 1, "name": "HCPCS_CODE", "comment": null}, "NITOS_CODE": {"type": "TEXT", "index": 2, "name": "NITOS_CODE", "comment": null}, "NITOS_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "NITOS_DESCRIPTION", "comment": null}, "INVASIVE_NON_INVASIVE_FLAG": {"type": "TEXT", "index": 4, "name": "INVASIVE_NON_INVASIVE_FLAG", "comment": null}, "MODALITY": {"type": "TEXT", "index": 5, "name": "MODALITY", "comment": null}, "BODY_REGION": {"type": "TEXT", "index": 6, "name": "BODY_REGION", "comment": null}, "FOCUS_AREA": {"type": "TEXT", "index": 7, "name": "FOCUS_AREA", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 26624, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 958, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__nitos"}, "model.the_tuva_project.quality_measures__int_nqf2372_numerator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF2372_NUMERATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 7, "name": "EVIDENCE_DATE", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 8, "name": "NUMERATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_numerator"}, "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_PTOTST__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor"}, "model.the_tuva_project.data_quality__pharmacy_claim_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_CLAIM_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 6, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_npi"}, "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_PRESCRIBING_PROVIDER_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi"}, "model.the_tuva_project.data_quality__professional_place_of_service_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROFESSIONAL_PLACE_OF_SERVICE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__professional_place_of_service_code"}, "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_ENROLLMENT_INTERACTION_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 4, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 5, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 6, "name": "DUAL_STATUS", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 8, "name": "DESCRIPTION", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 9, "name": "COEFFICIENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 4096, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 14, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors"}, "model.the_tuva_project.cms_hcc__int_hcc_mapping": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_HCC_MAPPING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CONDITION_CODE": {"type": "TEXT", "index": 2, "name": "CONDITION_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 3, "name": "HCC_CODE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 4, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 5, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_mapping"}, "model.the_tuva_project.data_quality__claim_paid_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_PAID_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_paid_date"}, "model.the_tuva_project.normalized_input__int_diagnosis_code_final": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DIAGNOSIS_CODE_FINAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 4, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 5, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 6, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 7, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 8, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 9, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 10, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 11, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 12, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 13, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 14, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 15, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 16, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 17, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 18, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 19, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 20, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 21, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 22, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 23, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 24, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 25, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 26, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 27, "name": "DIAGNOSIS_CODE_25", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_final"}, "seed.the_tuva_project.terminology__rxnorm_brand_generic": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "RXNORM_BRAND_GENERIC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRODUCT_RXCUI": {"type": "TEXT", "index": 1, "name": "PRODUCT_RXCUI", "comment": null}, "PRODUCT_NAME": {"type": "TEXT", "index": 2, "name": "PRODUCT_NAME", "comment": null}, "PRODUCT_TTY": {"type": "TEXT", "index": 3, "name": "PRODUCT_TTY", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 4, "name": "BRAND_VS_GENERIC", "comment": null}, "BRAND_NAME": {"type": "TEXT", "index": 5, "name": "BRAND_NAME", "comment": null}, "CLINICAL_PRODUCT_RXCUI": {"type": "TEXT", "index": 6, "name": "CLINICAL_PRODUCT_RXCUI", "comment": null}, "CLINICAL_PRODUCT_NAME": {"type": "TEXT", "index": 7, "name": "CLINICAL_PRODUCT_NAME", "comment": null}, "CLINICAL_PRODUCT_TTY": {"type": "TEXT", "index": 8, "name": "CLINICAL_PRODUCT_TTY", "comment": null}, "INGREDIENT_NAME": {"type": "TEXT", "index": 9, "name": "INGREDIENT_NAME", "comment": null}, "DOSE_FORM_NAME": {"type": "TEXT", "index": 10, "name": "DOSE_FORM_NAME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3440640, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 63956, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__rxnorm_brand_generic"}, "model.the_tuva_project.hcc_suspecting__int_all_conditions": {"metadata": {"type": "BASE TABLE", "schema": "HCC_SUSPECTING", "name": "_INT_ALL_CONDITIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 2, "name": "RECORDED_DATE", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 3, "name": "CONDITION_TYPE", "comment": null}, "ICD_10_CM_CODE": {"type": "TEXT", "index": 4, "name": "ICD_10_CM_CODE", "comment": null}, "HCC_CODE": {"type": "TEXT", "index": 5, "name": "HCC_CODE", "comment": null}, "HCC_DESCRIPTION": {"type": "TEXT", "index": 6, "name": "HCC_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_conditions"}, "model.the_tuva_project.core__stg_claims_medical_claim": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_MEDICAL_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICAL_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "MEDICAL_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 8, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 9, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 10, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 16, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 17, "name": "DISCHARGE_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 19, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 20, "name": "SERVICE_CATEGORY_3", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 21, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 23, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 25, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 27, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 31, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 33, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 37, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 38, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 39, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 40, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 41, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 42, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 43, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 44, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 45, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 46, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 47, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 48, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 49, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 50, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 51, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 52, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 53, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 54, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 55, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 56, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 57, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 58, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 59, "name": "TOTAL_COST_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 60, "name": "IN_NETWORK_FLAG", "comment": null}, "ENROLLMENT_FLAG": {"type": "NUMBER", "index": 61, "name": "ENROLLMENT_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 62, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 63, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_medical_claim"}, "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ALWAYS_PLANNED_CCS_DIAGNOSIS_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category"}, "model.the_tuva_project.data_quality__condition_status": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_STATUS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_status"}, "seed.the_tuva_project.terminology__ms_drg": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MS_DRG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MS_DRG_CODE": {"type": "TEXT", "index": 1, "name": "MS_DRG_CODE", "comment": null}, "MDC_CODE": {"type": "TEXT", "index": 2, "name": "MDC_CODE", "comment": null}, "MEDICAL_SURGICAL": {"type": "TEXT", "index": 3, "name": "MEDICAL_SURGICAL", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "MS_DRG_DESCRIPTION", "comment": null}, "DEPRECATED": {"type": "NUMBER", "index": 5, "name": "DEPRECATED", "comment": null}, "DEPRECATED_DATE": {"type": "DATE", "index": 6, "name": "DEPRECATED_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 16896, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 812, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ms_drg"}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM438_DENOMINATOR_CRITERIA2", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 2, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 3, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 4, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 5, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 6, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2"}, "seed.the_tuva_project.terminology__hcpcs_to_rbcs": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "HCPCS_TO_RBCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"HCPCS_CD": {"type": "TEXT", "index": 1, "name": "HCPCS_CD", "comment": null}, "RBCS_ID": {"type": "TEXT", "index": 2, "name": "RBCS_ID", "comment": null}, "RBCS_CAT": {"type": "TEXT", "index": 3, "name": "RBCS_CAT", "comment": null}, "RBCS_CAT_DESC": {"type": "TEXT", "index": 4, "name": "RBCS_CAT_DESC", "comment": null}, "RBCS_CAT_SUBCAT": {"type": "TEXT", "index": 5, "name": "RBCS_CAT_SUBCAT", "comment": null}, "RBCS_SUBCAT_DESC": {"type": "TEXT", "index": 6, "name": "RBCS_SUBCAT_DESC", "comment": null}, "RBCS_FAMNUMB": {"type": "NUMBER", "index": 7, "name": "RBCS_FAMNUMB", "comment": null}, "RBCS_FAMILY_DESC": {"type": "TEXT", "index": 8, "name": "RBCS_FAMILY_DESC", "comment": null}, "RBCS_MAJOR_IND": {"type": "TEXT", "index": 9, "name": "RBCS_MAJOR_IND", "comment": null}, "HCPCS_CD_ADD_DT": {"type": "DATE", "index": 10, "name": "HCPCS_CD_ADD_DT", "comment": null}, "HCPCS_CD_END_DT": {"type": "DATE", "index": 11, "name": "HCPCS_CD_END_DT", "comment": null}, "RBCS_ASSIGNMENT_EFF_DT": {"type": "DATE", "index": 12, "name": "RBCS_ASSIGNMENT_EFF_DT", "comment": null}, "CURRENT_FLAG": {"type": "NUMBER", "index": 13, "name": "CURRENT_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 235520, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 17033, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__hcpcs_to_rbcs"}, "model.the_tuva_project.data_quality__pharmacy_refills": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_REFILLS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_refills"}, "model.the_tuva_project.quality_measures__summary_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "SUMMARY_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "PERFORMANCE_FLAG": {"type": "NUMBER", "index": 5, "name": "PERFORMANCE_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 6, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 7, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 8, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 9, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 11, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 12, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 13, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 14, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 15, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__summary_long"}, "seed.the_tuva_project.cms_hcc__disease_interaction_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_VALUE_SET_DISEASE_INTERACTION_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MODEL_VERSION": {"type": "TEXT", "index": 1, "name": "MODEL_VERSION", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 2, "name": "FACTOR_TYPE", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 3, "name": "ENROLLMENT_STATUS", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 4, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 5, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 6, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 7, "name": "INSTITUTIONAL_STATUS", "comment": null}, "SHORT_NAME": {"type": "TEXT", "index": 8, "name": "SHORT_NAME", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 9, "name": "DESCRIPTION", "comment": null}, "HCC_CODE_1": {"type": "TEXT", "index": 10, "name": "HCC_CODE_1", "comment": null}, "HCC_CODE_2": {"type": "TEXT", "index": 11, "name": "HCC_CODE_2", "comment": null}, "COEFFICIENT": {"type": "FLOAT", "index": 12, "name": "COEFFICIENT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 16384, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 961, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.cms_hcc__disease_interaction_factors"}, "model.the_tuva_project.service_category__outpatient_rehab_institutional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_REHAB_INSTITUTIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 2, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 3, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 5, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_institutional"}, "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_EXCLUDE_PROCEDURES_MEDICATIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 4, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications"}, "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PRESENT_ON_ADMIT_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "DIAGNOSIS_COLUMN": {"type": "TEXT", "index": 3, "name": "DIAGNOSIS_COLUMN", "comment": null}, "NORMALIZED_PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "PRESENT_ON_ADMIT_OCCURRENCE_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_normalize"}, "model.the_tuva_project.data_quality__patient_last_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_LAST_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_last_name"}, "model.the_tuva_project.home_health__anchor_events": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__ANCHOR_EVENTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__anchor_events"}, "seed.the_tuva_project.terminology__ms_drg_weights_los": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "MS_DRG_WEIGHTS_LOS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MS_DRG": {"type": "TEXT", "index": 1, "name": "MS_DRG", "comment": null}, "FY_2024_FINAL_POST_ACUTE_DRG": {"type": "TEXT", "index": 2, "name": "FY_2024_FINAL_POST_ACUTE_DRG", "comment": null}, "FY_2024_FINAL_SPECIAL_PAY_DRG": {"type": "TEXT", "index": 3, "name": "FY_2024_FINAL_SPECIAL_PAY_DRG", "comment": null}, "MDC": {"type": "TEXT", "index": 4, "name": "MDC", "comment": null}, "TYPE": {"type": "TEXT", "index": 5, "name": "TYPE", "comment": null}, "MS_DRG_TITLE": {"type": "TEXT", "index": 6, "name": "MS_DRG_TITLE", "comment": null}, "DRG_WEIGHT_RAW": {"type": "NUMBER", "index": 7, "name": "DRG_WEIGHT_RAW", "comment": null}, "DRG_WEIGHT": {"type": "NUMBER", "index": 8, "name": "DRG_WEIGHT", "comment": null}, "GEOMETRIC_MEAN_LOS": {"type": "NUMBER", "index": 9, "name": "GEOMETRIC_MEAN_LOS", "comment": null}, "ARITHMETIC_MEAN_LOS": {"type": "NUMBER", "index": 10, "name": "ARITHMETIC_MEAN_LOS", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 24064, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 766, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ms_drg_weights_los"}, "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_DIAGNOSIS_CODE_VOTING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "COLUMN_NAME": {"type": "TEXT", "index": 3, "name": "COLUMN_NAME", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "OCCURRENCE_COUNT": {"type": "NUMBER", "index": 5, "name": "OCCURRENCE_COUNT", "comment": null}, "NEXT_OCCURRENCE_COUNT": {"type": "NUMBER", "index": 6, "name": "NEXT_OCCURRENCE_COUNT", "comment": null}, "OCCURRENCE_ROW_COUNT": {"type": "NUMBER", "index": 7, "name": "OCCURRENCE_ROW_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_voting"}, "model.the_tuva_project.data_quality__analytics_checks_summary": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ANALYTICS_CHECKS_SUMMARY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "NORMALLY_ZERO": {"type": "NUMBER", "index": 3, "name": "NORMALLY_ZERO", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 11, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__analytics_checks_summary"}, "seed.the_tuva_project.terminology__other_provider_taxonomy": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "OTHER_PROVIDER_TAXONOMY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NPI": {"type": "TEXT", "index": 1, "name": "NPI", "comment": null}, "TAXONOMY_CODE": {"type": "TEXT", "index": 2, "name": "TAXONOMY_CODE", "comment": null}, "MEDICARE_SPECIALTY_CODE": {"type": "TEXT", "index": 3, "name": "MEDICARE_SPECIALTY_CODE", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 4, "name": "DESCRIPTION", "comment": null}, "PRIMARY_FLAG": {"type": "NUMBER", "index": 5, "name": "PRIMARY_FLAG", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 73041920, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 10043050, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__other_provider_taxonomy"}, "model.the_tuva_project.data_quality__condition_resolved_date": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CONDITION_RESOLVED_DATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__condition_resolved_date"}, "model.the_tuva_project.core__lab_result": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "LAB_RESULT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MAPPING_METHOD": {"type": "TEXT", "index": 12, "name": "MAPPING_METHOD", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 13, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 14, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 15, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 16, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 17, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 18, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 19, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 21, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 23, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "TEXT", "index": 24, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "TEXT", "index": 25, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 26, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 27, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 28, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__lab_result"}, "seed.the_tuva_project.reference_data__calendar": {"metadata": {"type": "BASE TABLE", "schema": "REFERENCE_DATA", "name": "CALENDAR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"FULL_DATE": {"type": "DATE", "index": 1, "name": "FULL_DATE", "comment": null}, "YEAR": {"type": "NUMBER", "index": 2, "name": "YEAR", "comment": null}, "MONTH": {"type": "NUMBER", "index": 3, "name": "MONTH", "comment": null}, "DAY": {"type": "NUMBER", "index": 4, "name": "DAY", "comment": null}, "MONTH_NAME": {"type": "TEXT", "index": 5, "name": "MONTH_NAME", "comment": null}, "DAY_OF_WEEK_NUMBER": {"type": "NUMBER", "index": 6, "name": "DAY_OF_WEEK_NUMBER", "comment": null}, "DAY_OF_WEEK_NAME": {"type": "TEXT", "index": 7, "name": "DAY_OF_WEEK_NAME", "comment": null}, "WEEK_OF_YEAR": {"type": "NUMBER", "index": 8, "name": "WEEK_OF_YEAR", "comment": null}, "DAY_OF_YEAR": {"type": "NUMBER", "index": 9, "name": "DAY_OF_YEAR", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 10, "name": "YEAR_MONTH", "comment": null}, "FIRST_DAY_OF_MONTH": {"type": "DATE", "index": 11, "name": "FIRST_DAY_OF_MONTH", "comment": null}, "LAST_DAY_OF_MONTH": {"type": "DATE", "index": 12, "name": "LAST_DAY_OF_MONTH", "comment": null}, "YEAR_MONTH_INT": {"type": "NUMBER", "index": 13, "name": "YEAR_MONTH_INT", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1007616, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 80000, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.reference_data__calendar"}, "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0059__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059__performance_period"}, "model.the_tuva_project.data_quality__encounters_missing_groups": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTERS_MISSING_GROUPS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MISSING_ENCOUNTER_GROUP": {"type": "TEXT", "index": 1, "name": "MISSING_ENCOUNTER_GROUP", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups"}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_PRIMARY_DIAGNOSIS_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code"}, "model.the_tuva_project.data_quality__procedure_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_data_source"}, "model.the_tuva_project.service_category__stg_office_based": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "SERVICE_CATEGORY__STG_OFFICE_BASED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_TYPE": {"type": "TEXT", "index": 4, "name": "SERVICE_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__stg_office_based"}, "seed.input_layer.provider_attribution_seed": {"metadata": {"type": "BASE TABLE", "schema": "_TUVA_SYNTHETIC", "name": "PROVIDER_ATTRIBUTION_SEED", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 6, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 10, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.input_layer.provider_attribution_seed"}, "model.the_tuva_project.data_quality__claim_date_trends": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DATE_TRENDS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "NUMBER", "index": 1, "name": "YEAR_MONTH", "comment": null}, "CLAIM_START_DATE": {"type": "NUMBER", "index": 2, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "NUMBER", "index": 3, "name": "CLAIM_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "NUMBER", "index": 4, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "NUMBER", "index": 5, "name": "DISCHARGE_DATE", "comment": null}, "MEDICAL_PAID_DATE": {"type": "NUMBER", "index": 6, "name": "MEDICAL_PAID_DATE", "comment": null}, "DISPENSING_DATE": {"type": "NUMBER", "index": 7, "name": "DISPENSING_DATE", "comment": null}, "PHARMACY_PAID_DATE": {"type": "NUMBER", "index": 8, "name": "PHARMACY_PAID_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 9, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_date_trends"}, "model.the_tuva_project.service_category__outpatient_radiology_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OUTPATIENT_RADIOLOGY_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_professional"}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0053_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions"}, "model.the_tuva_project.service_category__inpatient_psychiatric_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_INPATIENT_PSYCHIATRIC_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_professional"}, "model.the_tuva_project.pharmacy__int_claims_current_cost": {"metadata": {"type": "VIEW", "schema": "PHARMACY", "name": "_INT_CLAIMS_CURRENT_COST", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NDC_CODE": {"type": "TEXT", "index": 1, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "NDC_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "RXCUI": {"type": "TEXT", "index": 4, "name": "RXCUI", "comment": null}, "BRAND_VS_GENERIC": {"type": "TEXT", "index": 5, "name": "BRAND_VS_GENERIC", "comment": null}, "GENERIC_AVAILABLE": {"type": "TEXT", "index": 6, "name": "GENERIC_AVAILABLE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 7, "name": "PAID_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 8, "name": "CLAIM_COUNT", "comment": null}, "COST_PER_CLAIM": {"type": "NUMBER", "index": 9, "name": "COST_PER_CLAIM", "comment": null}, "TOTAL_UNITS": {"type": "NUMBER", "index": 10, "name": "TOTAL_UNITS", "comment": null}, "COST_PER_UNIT": {"type": "NUMBER", "index": 11, "name": "COST_PER_UNIT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.pharmacy__int_claims_current_cost"}, "model.the_tuva_project.core__stg_claims_procedure": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_PROCEDURE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 12, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 13, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 14, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 15, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 16, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 17, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 18, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 19, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_procedure"}, "model.the_tuva_project.data_quality__procedure_modifier_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PROCEDURE_MODIFIER_3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_3"}, "model.the_tuva_project.quality_measures__int_cqm130_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM130_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_exclusions"}, "model.the_tuva_project.data_quality__claim_data_source": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "CLAIM_DATA_SOURCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__claim_data_source"}, "model.the_tuva_project.data_quality__cms_hcc": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CMS_HCC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_QUALITY_CHECK": {"type": "TEXT", "index": 1, "name": "DATA_QUALITY_CHECK", "comment": null}, "RESULT_COUNT": {"type": "NUMBER", "index": 2, "name": "RESULT_COUNT", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__cms_hcc"}, "model.the_tuva_project.data_quality__location_name": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LOCATION_NAME", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__location_name"}, "model.the_tuva_project.data_quality__institutional_service_unit_quantity": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_SERVICE_UNIT_QUANTITY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_service_unit_quantity"}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_REFERENCE_RANGE_LOW", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low"}, "model.the_tuva_project.core__stg_claims_location": {"metadata": {"type": "VIEW", "schema": "TEST", "name": "CORE__STG_CLAIMS_LOCATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 13, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__stg_claims_location"}, "model.the_tuva_project.mart_review__calendar_month": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__CALENDAR_MONTH", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_MONTH": {"type": "TEXT", "index": 1, "name": "YEAR_MONTH", "comment": null}, "FULL_DATE": {"type": "DATE", "index": 2, "name": "FULL_DATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 16384, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 2629, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__calendar_month"}, "model.the_tuva_project.outpatient_substance_use__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SUBSTANCE_USE__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_substance_use__encounter_grain"}, "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_NORMALIZED_ABNORMAL_FLAG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag"}, "model.the_tuva_project.data_quality__data_quality_detail": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_DETAIL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "SUMMARY_SK": {"type": "NUMBER", "index": 11, "name": "SUMMARY_SK", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__data_quality_detail"}, "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "PQI_EXCLUSION_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 2, "name": "ENCOUNTER_ID", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_NUMBER": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_NUMBER", "comment": null}, "PQI_NUMBER": {"type": "NUMBER", "index": 5, "name": "PQI_NUMBER", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"}, "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": {"metadata": {"type": "BASE TABLE", "schema": "FINANCIAL_PMPM", "name": "_INT_SERVICE_CATEGORY_1_ALLOWED_PIVOT", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "INPATIENT_ALLOWED": {"type": "NUMBER", "index": 6, "name": "INPATIENT_ALLOWED", "comment": null}, "OUTPATIENT_ALLOWED": {"type": "NUMBER", "index": 7, "name": "OUTPATIENT_ALLOWED", "comment": null}, "OFFICE_BASED_ALLOWED": {"type": "NUMBER", "index": 8, "name": "OFFICE_BASED_ALLOWED", "comment": null}, "ANCILLARY_ALLOWED": {"type": "NUMBER", "index": 9, "name": "ANCILLARY_ALLOWED", "comment": null}, "OTHER_ALLOWED": {"type": "NUMBER", "index": 10, "name": "OTHER_ALLOWED", "comment": null}, "PHARMACY_ALLOWED": {"type": "NUMBER", "index": 11, "name": "PHARMACY_ALLOWED", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot"}, "seed.the_tuva_project.terminology__loinc_deprecated_mapping": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "LOINC_DEPRECATED_MAPPING", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOINC": {"type": "TEXT", "index": 1, "name": "LOINC", "comment": null}, "MAP_TO": {"type": "TEXT", "index": 2, "name": "MAP_TO", "comment": null}, "COMMENT": {"type": "TEXT", "index": 3, "name": "COMMENT", "comment": null}, "FINAL_MAP_TO": {"type": "TEXT", "index": 4, "name": "FINAL_MAP_TO", "comment": null}, "ALL_COMMENTS": {"type": "TEXT", "index": 5, "name": "ALL_COMMENTS", "comment": null}, "DEPTH": {"type": "TEXT", "index": 6, "name": "DEPTH", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 97280, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4613, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__loinc_deprecated_mapping"}, "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_ICD_10_CM_TO_CCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_CM": {"type": "TEXT", "index": 1, "name": "ICD_10_CM", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}, "CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 3, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "CCS_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "CCS_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1313792, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 72776, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs"}, "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM236_EXCLUDE_PROCEDURES_OBSERVATIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "EXCLUSION_TYPE": {"type": "TEXT", "index": 5, "name": "EXCLUSION_TYPE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations"}, "model.the_tuva_project.data_quality__medication_atc_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MEDICATION_ATC_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__medication_atc_code"}, "model.the_tuva_project.data_quality__cms_hcc_reference": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "DATA_QUALITY_CMS_HCC_REFERENCE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ANALYTICS_CONCEPT": {"type": "TEXT", "index": 1, "name": "ANALYTICS_CONCEPT", "comment": null}, "ANALYTICS_MEASURE": {"type": "TEXT", "index": 2, "name": "ANALYTICS_MEASURE", "comment": null}, "DATA_SOURCE_VALUE": {"type": "NUMBER", "index": 3, "name": "DATA_SOURCE_VALUE", "comment": null}, "ANALYTICS_VALUE": {"type": "TEXT", "index": 4, "name": "ANALYTICS_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 1, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__cms_hcc_reference"}, "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_ORIGINAL_REASON_ENTITLEMENT_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code"}, "model.the_tuva_project.quality_measures__int_cqm48_denominator": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CQM48_DENOMINATOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "AGE": {"type": "NUMBER", "index": 2, "name": "AGE", "comment": null}, "ENCOUNTER_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_DATE", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 6, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 7, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 8, "name": "MEASURE_VERSION", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 9, "name": "DENOMINATOR_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_denominator"}, "model.the_tuva_project.ahrq_measures__int_pqi_01_num": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_01_NUM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 3, "name": "YEAR_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_num"}, "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055__performance_period"}, "seed.the_tuva_project.terminology__icd_10_pcs": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "ICD_10_PCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ICD_10_PCS": {"type": "TEXT", "index": 1, "name": "ICD_10_PCS", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1001472, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 78638, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__icd_10_pcs"}, "model.the_tuva_project.acute_inpatient__prof_claims": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "ACUTE_INPATIENT__PROF_CLAIMS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 5, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_ATTRIBUTION_NUMBER": {"type": "NUMBER", "index": 6, "name": "CLAIM_ATTRIBUTION_NUMBER", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.acute_inpatient__prof_claims"}, "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_HOSPITAL_OR_CLINIC__MATCH_CLAIMS_TO_ANCHOR", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 4, "name": "CLAIM_LINE_NUMBER", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 5, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor"}, "model.the_tuva_project.inpatient_psych__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "INPATIENT_PSYCH__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.inpatient_psych__start_end_dates"}, "model.the_tuva_project.service_category__office_based_other_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "SERVICE_CATEGORY__OFFICE_BASED_OTHER_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__office_based_other_professional"}, "model.the_tuva_project.data_quality__institutional_procedure_date_3": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_PROCEDURE_DATE_3", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_3"}, "model.the_tuva_project.core__medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "MEDICAL_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICAL_CLAIM_ID": {"type": "TEXT", "index": 1, "name": "MEDICAL_CLAIM_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 3, "name": "CLAIM_LINE_NUMBER", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 6, "name": "ENCOUNTER_GROUP", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 7, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 8, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 9, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 10, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 11, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 12, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 13, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 14, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 15, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 16, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 17, "name": "DISCHARGE_DATE", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 18, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 19, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 20, "name": "SERVICE_CATEGORY_3", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 21, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 22, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 23, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 24, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 25, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 26, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 27, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 28, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 29, "name": "BILL_TYPE_CODE", "comment": null}, "BILL_TYPE_DESCRIPTION": {"type": "TEXT", "index": 30, "name": "BILL_TYPE_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 31, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 32, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 33, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 34, "name": "APR_DRG_DESCRIPTION", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 35, "name": "REVENUE_CENTER_CODE", "comment": null}, "REVENUE_CENTER_DESCRIPTION": {"type": "TEXT", "index": 36, "name": "REVENUE_CENTER_DESCRIPTION", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 37, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 38, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 39, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 40, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 41, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 42, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 43, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_ID": {"type": "TEXT", "index": 44, "name": "RENDERING_ID", "comment": null}, "RENDERING_TIN": {"type": "TEXT", "index": 45, "name": "RENDERING_TIN", "comment": null}, "RENDERING_NAME": {"type": "TEXT", "index": 46, "name": "RENDERING_NAME", "comment": null}, "BILLING_ID": {"type": "TEXT", "index": 47, "name": "BILLING_ID", "comment": null}, "BILLING_TIN": {"type": "TEXT", "index": 48, "name": "BILLING_TIN", "comment": null}, "BILLING_NAME": {"type": "TEXT", "index": 49, "name": "BILLING_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 50, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 51, "name": "FACILITY_NAME", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 52, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 53, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 54, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 55, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 56, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 57, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 58, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "NUMBER", "index": 59, "name": "TOTAL_COST_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 60, "name": "IN_NETWORK_FLAG", "comment": null}, "ENROLLMENT_FLAG": {"type": "NUMBER", "index": 61, "name": "ENROLLMENT_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 62, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 63, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__medical_claim"}, "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_01_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_denom"}, "model.the_tuva_project.core__medication": {"metadata": {"type": "BASE TABLE", "schema": "CORE", "name": "MEDICATION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICATION_ID": {"type": "TEXT", "index": 1, "name": "MEDICATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 4, "name": "DISPENSING_DATE", "comment": null}, "PRESCRIBING_DATE": {"type": "DATE", "index": 5, "name": "PRESCRIBING_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "NDC_MAPPING_METHOD": {"type": "TEXT", "index": 11, "name": "NDC_MAPPING_METHOD", "comment": null}, "RXNORM_CODE": {"type": "TEXT", "index": 12, "name": "RXNORM_CODE", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "RXNORM_DESCRIPTION", "comment": null}, "RXNORM_MAPPING_METHOD": {"type": "TEXT", "index": 14, "name": "RXNORM_MAPPING_METHOD", "comment": null}, "ATC_CODE": {"type": "TEXT", "index": 15, "name": "ATC_CODE", "comment": null}, "ATC_DESCRIPTION": {"type": "TEXT", "index": 16, "name": "ATC_DESCRIPTION", "comment": null}, "ATC_MAPPING_METHOD": {"type": "TEXT", "index": 17, "name": "ATC_MAPPING_METHOD", "comment": null}, "ROUTE": {"type": "TEXT", "index": 18, "name": "ROUTE", "comment": null}, "STRENGTH": {"type": "TEXT", "index": 19, "name": "STRENGTH", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 20, "name": "QUANTITY", "comment": null}, "QUANTITY_UNIT": {"type": "TEXT", "index": 21, "name": "QUANTITY_UNIT", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 22, "name": "DAYS_SUPPLY", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 23, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 24, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TIMESTAMP_NTZ", "index": 25, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.core__medication"}, "model.the_tuva_project.asc__start_end_dates": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "ASC__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 2, "name": "OLD_ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.asc__start_end_dates"}, "model.the_tuva_project.outpatient_surgery__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "OUTPATIENT_SURGERY__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "OBSERVATION_FLAG": {"type": "NUMBER", "index": 19, "name": "OBSERVATION_FLAG", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 20, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 23, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 27, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.outpatient_surgery__encounter_grain"}, "model.the_tuva_project.service_category__urgent_care_professional": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_URGENT_CARE_PROFESSIONAL", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_LINE_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_LINE_ID", "comment": null}, "SERVICE_CATEGORY_1": {"type": "TEXT", "index": 4, "name": "SERVICE_CATEGORY_1", "comment": null}, "SERVICE_CATEGORY_2": {"type": "TEXT", "index": 5, "name": "SERVICE_CATEGORY_2", "comment": null}, "SERVICE_CATEGORY_3": {"type": "TEXT", "index": 6, "name": "SERVICE_CATEGORY_3", "comment": null}, "SOURCE_MODEL_NAME": {"type": "TEXT", "index": 7, "name": "SOURCE_MODEL_NAME", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.service_category__urgent_care_professional"}, "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": {"metadata": {"type": "VIEW", "schema": "QUALITY_MEASURES", "name": "_INT_ADH_DIABETES__PERFORMANCE_PERIOD", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period"}, "model.the_tuva_project.data_quality__patient_sex": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PATIENT_SEX", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__patient_sex"}, "model.the_tuva_project.cms_hcc__patient_risk_scores": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "PATIENT_RISK_SCORES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "V24_RISK_SCORE": {"type": "NUMBER", "index": 2, "name": "V24_RISK_SCORE", "comment": null}, "V28_RISK_SCORE": {"type": "NUMBER", "index": 3, "name": "V28_RISK_SCORE", "comment": null}, "BLENDED_RISK_SCORE": {"type": "NUMBER", "index": 4, "name": "BLENDED_RISK_SCORE", "comment": null}, "NORMALIZED_RISK_SCORE": {"type": "NUMBER", "index": 5, "name": "NORMALIZED_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE": {"type": "NUMBER", "index": 6, "name": "PAYMENT_RISK_SCORE", "comment": null}, "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS": {"type": "NUMBER", "index": 7, "name": "PAYMENT_RISK_SCORE_WEIGHTED_BY_MONTHS", "comment": null}, "MEMBER_MONTHS": {"type": "NUMBER", "index": 8, "name": "MEMBER_MONTHS", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 9, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_scores"}, "model.the_tuva_project.cms_hcc__int_demographic_factors": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_DEMOGRAPHIC_FACTORS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "ENROLLMENT_STATUS": {"type": "TEXT", "index": 2, "name": "ENROLLMENT_STATUS", "comment": null}, "GENDER": {"type": "TEXT", "index": 3, "name": "GENDER", "comment": null}, "AGE_GROUP": {"type": "TEXT", "index": 4, "name": "AGE_GROUP", "comment": null}, "MEDICAID_STATUS": {"type": "TEXT", "index": 5, "name": "MEDICAID_STATUS", "comment": null}, "DUAL_STATUS": {"type": "TEXT", "index": 6, "name": "DUAL_STATUS", "comment": null}, "OREC": {"type": "TEXT", "index": 7, "name": "OREC", "comment": null}, "INSTITUTIONAL_STATUS": {"type": "TEXT", "index": 8, "name": "INSTITUTIONAL_STATUS", "comment": null}, "ENROLLMENT_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 9, "name": "ENROLLMENT_STATUS_DEFAULT", "comment": null}, "MEDICAID_DUAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 10, "name": "MEDICAID_DUAL_STATUS_DEFAULT", "comment": null}, "OREC_DEFAULT": {"type": "BOOLEAN", "index": 11, "name": "OREC_DEFAULT", "comment": null}, "INSTITUTIONAL_STATUS_DEFAULT": {"type": "BOOLEAN", "index": 12, "name": "INSTITUTIONAL_STATUS_DEFAULT", "comment": null}, "COEFFICIENT": {"type": "NUMBER", "index": 13, "name": "COEFFICIENT", "comment": null}, "FACTOR_TYPE": {"type": "TEXT", "index": 14, "name": "FACTOR_TYPE", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 15, "name": "MODEL_VERSION", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 16, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 17, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_demographic_factors"}, "model.the_tuva_project.readmissions__encounter_with_ccs": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_ENCOUNTER_WITH_CCS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ADMIT_DATE": {"type": "DATE", "index": 3, "name": "ADMIT_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 4, "name": "DISCHARGE_DATE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 5, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 6, "name": "FACILITY_ID", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 7, "name": "MS_DRG_CODE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 8, "name": "PAID_AMOUNT", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "VALID_PRIMARY_DIAGNOSIS_CODE_FLAG": {"type": "NUMBER", "index": 10, "name": "VALID_PRIMARY_DIAGNOSIS_CODE_FLAG", "comment": null}, "CCS_DIAGNOSIS_CATEGORY": {"type": "TEXT", "index": 11, "name": "CCS_DIAGNOSIS_CATEGORY", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 12, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__encounter_with_ccs"}, "model.the_tuva_project.quality_measures__summary_counts": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "SUMMARY_COUNTS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEASURE_ID": {"type": "TEXT", "index": 1, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 2, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 3, "name": "MEASURE_VERSION", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 4, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 5, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "DENOMINATOR_SUM": {"type": "NUMBER", "index": 6, "name": "DENOMINATOR_SUM", "comment": null}, "NUMERATOR_SUM": {"type": "NUMBER", "index": 7, "name": "NUMERATOR_SUM", "comment": null}, "EXCLUSION_SUM": {"type": "NUMBER", "index": 8, "name": "EXCLUSION_SUM", "comment": null}, "PERFORMANCE_RATE": {"type": "NUMBER", "index": 9, "name": "PERFORMANCE_RATE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__summary_counts"}, "model.the_tuva_project.cms_hcc__int_eligible_conditions": {"metadata": {"type": "BASE TABLE", "schema": "CMS_HCC", "name": "_INT_ELIGIBLE_CONDITIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CONDITION_CODE": {"type": "TEXT", "index": 2, "name": "CONDITION_CODE", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 3, "name": "PAYMENT_YEAR", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 4, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.cms_hcc__int_eligible_conditions"}, "seed.the_tuva_project.pqi__measures": {"metadata": {"type": "BASE TABLE", "schema": "AHRQ_MEASURES", "name": "_VALUE_SET_PQI_MEASURES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PQI_NUMBER": {"type": "TEXT", "index": 1, "name": "PQI_NUMBER", "comment": null}, "PQI_NAME": {"type": "TEXT", "index": 2, "name": "PQI_NAME", "comment": null}, "PQI_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "PQI_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 10, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.pqi__measures"}, "model.the_tuva_project.mart_review__patient_risk": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "MART_REVIEW__PATIENT_RISK", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"RISK_SCORE_BUCKET": {"type": "TEXT", "index": 1, "name": "RISK_SCORE_BUCKET", "comment": null}, "PAYMENT_YEAR": {"type": "NUMBER", "index": 2, "name": "PAYMENT_YEAR", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MODEL_VERSION": {"type": "TEXT", "index": 4, "name": "MODEL_VERSION", "comment": null}, "PATIENT_RISK_SK": {"type": "NUMBER", "index": 5, "name": "PATIENT_RISK_SK", "comment": null}, "RISK_SCORE": {"type": "NUMBER", "index": 6, "name": "RISK_SCORE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 7, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.mart_review__patient_risk"}, "model.the_tuva_project.emergency_department__start_end_dates": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "EMERGENCY_DEPARTMENT__START_END_DATES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 3, "name": "ENCOUNTER_END_DATE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.emergency_department__start_end_dates"}, "model.the_tuva_project.data_quality__encounter_admit_source_description": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ENCOUNTER_ADMIT_SOURCE_DESCRIPTION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_description"}, "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_POTENTIALLY_PLANNED_CCS_PROCEDURE_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 65, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category"}, "seed.the_tuva_project.terminology__ndc": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "NDC", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"NDC": {"type": "TEXT", "index": 1, "name": "NDC", "comment": null}, "RXCUI": {"type": "TEXT", "index": 2, "name": "RXCUI", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 3, "name": "RXNORM_DESCRIPTION", "comment": null}, "FDA_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "FDA_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 8559104, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 878867, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__ndc"}, "model.the_tuva_project.quality_measures__int_cbe0055_long": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_CBE0055_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "DENOMINATOR_FLAG": {"type": "NUMBER", "index": 2, "name": "DENOMINATOR_FLAG", "comment": null}, "NUMERATOR_FLAG": {"type": "NUMBER", "index": 3, "name": "NUMERATOR_FLAG", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "EVIDENCE_DATE": {"type": "DATE", "index": 5, "name": "EVIDENCE_DATE", "comment": null}, "EVIDENCE_VALUE": {"type": "TEXT", "index": 6, "name": "EVIDENCE_VALUE", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 7, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 8, "name": "EXCLUSION_REASON", "comment": null}, "PERFORMANCE_PERIOD_BEGIN": {"type": "DATE", "index": 9, "name": "PERFORMANCE_PERIOD_BEGIN", "comment": null}, "PERFORMANCE_PERIOD_END": {"type": "DATE", "index": 10, "name": "PERFORMANCE_PERIOD_END", "comment": null}, "MEASURE_ID": {"type": "TEXT", "index": 11, "name": "MEASURE_ID", "comment": null}, "MEASURE_NAME": {"type": "TEXT", "index": 12, "name": "MEASURE_NAME", "comment": null}, "MEASURE_VERSION": {"type": "TEXT", "index": 13, "name": "MEASURE_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 14, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:31UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_long"}, "model.the_tuva_project.home_health__generate_encounter_id": {"metadata": {"type": "VIEW", "schema": "CLAIMS_PREPROCESSING", "name": "HOME_HEALTH__GENERATE_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 1, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 2, "name": "START_DATE", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 3, "name": "CLAIM_ID", "comment": null}, "OLD_ENCOUNTER_ID": {"type": "NUMBER", "index": 4, "name": "OLD_ENCOUNTER_ID", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.home_health__generate_encounter_id"}, "model.the_tuva_project.ccsr__long_condition_category": {"metadata": {"type": "BASE TABLE", "schema": "CCSR", "name": "LONG_CONDITION_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "CODE_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "CODE_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 6, "name": "CONDITION_RANK", "comment": null}, "CCSR_PARENT_CATEGORY": {"type": "TEXT", "index": 7, "name": "CCSR_PARENT_CATEGORY", "comment": null}, "BODY_SYSTEM": {"type": "TEXT", "index": 8, "name": "BODY_SYSTEM", "comment": null}, "PARENT_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "PARENT_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY": {"type": "TEXT", "index": 10, "name": "CCSR_CATEGORY", "comment": null}, "CCSR_CATEGORY_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "CCSR_CATEGORY_DESCRIPTION", "comment": null}, "CCSR_CATEGORY_RANK": {"type": "NUMBER", "index": 12, "name": "CCSR_CATEGORY_RANK", "comment": null}, "IS_IP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 13, "name": "IS_IP_DEFAULT_CATEGORY", "comment": null}, "IS_OP_DEFAULT_CATEGORY": {"type": "NUMBER", "index": 14, "name": "IS_OP_DEFAULT_CATEGORY", "comment": null}, "DXCCSR_VERSION": {"type": "TEXT", "index": 15, "name": "DXCCSR_VERSION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 16, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ccsr__long_condition_category"}, "model.the_tuva_project.readmissions__planned_encounter": {"metadata": {"type": "VIEW", "schema": "READMISSIONS", "name": "_INT_PLANNED_ENCOUNTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 2, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.readmissions__planned_encounter"}, "model.the_tuva_project.data_quality__eligibility_state": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_STATE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_state"}, "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": {"metadata": {"type": "BASE TABLE", "schema": "READMISSIONS", "name": "_VALUE_SET_ALWAYS_PLANNED_CCS_PROCEDURE_CATEGORY", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CCS_PROCEDURE_CATEGORY": {"type": "TEXT", "index": 1, "name": "CCS_PROCEDURE_CATEGORY", "comment": null}, "DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 3, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category"}, "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_STG_PQI_INPATIENT_ENCOUNTER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 2, "name": "DATA_SOURCE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 3, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 4, "name": "MS_DRG_DESCRIPTION", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 5, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 6, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 7, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 8, "name": "LENGTH_OF_STAY", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 10, "name": "PATIENT_ID", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 11, "name": "FACILITY_ID", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 12, "name": "PAID_AMOUNT", "comment": null}, "YEAR_NUMBER": {"type": "NUMBER", "index": 13, "name": "YEAR_NUMBER", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"}, "model.the_tuva_project.normalized_input__pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "NORMALIZED_INPUT_PHARMACY_CLAIM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 4, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_ID": {"type": "TEXT", "index": 7, "name": "PRESCRIBING_PROVIDER_ID", "comment": null}, "PRESCRIBING_PROVIDER_NAME": {"type": "TEXT", "index": 8, "name": "PRESCRIBING_PROVIDER_NAME", "comment": null}, "DISPENSING_PROVIDER_ID": {"type": "TEXT", "index": 9, "name": "DISPENSING_PROVIDER_ID", "comment": null}, "DISPENSING_PROVIDER_NAME": {"type": "TEXT", "index": 10, "name": "DISPENSING_PROVIDER_NAME", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 11, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 12, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 13, "name": "NDC_DESCRIPTION", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 14, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 15, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 16, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 17, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 18, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 19, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 20, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 21, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 22, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 24, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 25, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 26, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__pharmacy_claim"}, "seed.the_tuva_project.terminology__discharge_disposition": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "DISCHARGE_DISPOSITION", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 1, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 2, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 3072, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 41, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__discharge_disposition"}, "seed.the_tuva_project.terminology__claim_type": {"metadata": {"type": "BASE TABLE", "schema": "TERMINOLOGY", "name": "CLAIM_TYPE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_TYPE": {"type": "TEXT", "index": 1, "name": "CLAIM_TYPE", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 1024, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 4, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.terminology__claim_type"}, "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PRIMARY_KEYS_MEDICATION_MEDICATION_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 7, "name": "FIELD_VALUE", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "DUPLICATE_COUNT": {"type": "NUMBER", "index": 9, "name": "DUPLICATE_COUNT", "comment": null}, "ROW_NUMBER_VALUE": {"type": "NUMBER", "index": 10, "name": "ROW_NUMBER_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__primary_keys_medication_medication_id"}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": {"metadata": {"type": "BASE TABLE", "schema": "CHRONIC_CONDITIONS", "name": "CMS_CHRONIC_CONDITIONS_LONG", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 2, "name": "CLAIM_ID", "comment": null}, "START_DATE": {"type": "DATE", "index": 3, "name": "START_DATE", "comment": null}, "CHRONIC_CONDITION_TYPE": {"type": "TEXT", "index": 4, "name": "CHRONIC_CONDITION_TYPE", "comment": null}, "CONDITION_CATEGORY": {"type": "TEXT", "index": 5, "name": "CONDITION_CATEGORY", "comment": null}, "CONDITION": {"type": "TEXT", "index": 6, "name": "CONDITION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 7, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 8, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"}, "model.the_tuva_project.data_quality__eligibility_patient_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "ELIGIBILITY_PATIENT_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__eligibility_patient_id"}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_SHARED_EXCLUSION_MISSING_GENDER", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 3, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender"}, "model.the_tuva_project.ambulance__encounter_grain": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "AMBULANCE__ENCOUNTER_GRAIN", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "NUMBER", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 2, "name": "ENCOUNTER_START_DATE", "comment": null}, "PATIENT_DATA_SOURCE_ID": {"type": "NUMBER", "index": 3, "name": "PATIENT_DATA_SOURCE_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 4, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_GROUP": {"type": "TEXT", "index": 5, "name": "ENCOUNTER_GROUP", "comment": null}, "ADMIT_AGE": {"type": "NUMBER", "index": 6, "name": "ADMIT_AGE", "comment": null}, "GENDER": {"type": "TEXT", "index": 7, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 8, "name": "RACE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 10, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 12, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 13, "name": "FACILITY_NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 14, "name": "FACILITY_TYPE", "comment": null}, "LAB_FLAG": {"type": "NUMBER", "index": 15, "name": "LAB_FLAG", "comment": null}, "DME_FLAG": {"type": "NUMBER", "index": 16, "name": "DME_FLAG", "comment": null}, "AMBULANCE_FLAG": {"type": "NUMBER", "index": 17, "name": "AMBULANCE_FLAG", "comment": null}, "PHARMACY_FLAG": {"type": "NUMBER", "index": 18, "name": "PHARMACY_FLAG", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 19, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "PLACE_OF_SERVICE_DESCRIPTION": {"type": "TEXT", "index": 20, "name": "PLACE_OF_SERVICE_DESCRIPTION", "comment": null}, "TOTAL_PAID_AMOUNT": {"type": "NUMBER", "index": 21, "name": "TOTAL_PAID_AMOUNT", "comment": null}, "TOTAL_ALLOWED_AMOUNT": {"type": "NUMBER", "index": 22, "name": "TOTAL_ALLOWED_AMOUNT", "comment": null}, "TOTAL_CHARGE_AMOUNT": {"type": "NUMBER", "index": 23, "name": "TOTAL_CHARGE_AMOUNT", "comment": null}, "CLAIM_COUNT": {"type": "NUMBER", "index": 24, "name": "CLAIM_COUNT", "comment": null}, "INST_CLAIM_COUNT": {"type": "NUMBER", "index": 25, "name": "INST_CLAIM_COUNT", "comment": null}, "PROF_CLAIM_COUNT": {"type": "NUMBER", "index": 26, "name": "PROF_CLAIM_COUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 28, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:29UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ambulance__encounter_grain"}, "model.the_tuva_project.normalized_input__int_place_of_service_normalize": {"metadata": {"type": "BASE TABLE", "schema": "CLAIMS_PREPROCESSING", "name": "_INT_NORMALIZED_INPUT_PLACE_OF_SERVICE_NORMALIZE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 4, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 5, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 6, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.normalized_input__int_place_of_service_normalize"}, "seed.the_tuva_project.ed_classification__categories": {"metadata": {"type": "BASE TABLE", "schema": "ED_CLASSIFICATION", "name": "_VALUE_SET_CATEGORIES", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLASSIFICATION": {"type": "TEXT", "index": 1, "name": "CLASSIFICATION", "comment": null}, "CLASSIFICATION_NAME": {"type": "TEXT", "index": 2, "name": "CLASSIFICATION_NAME", "comment": null}, "CLASSIFICATION_ORDER": {"type": "TEXT", "index": 3, "name": "CLASSIFICATION_ORDER", "comment": null}, "CLASSIFICATION_COLUMN": {"type": "TEXT", "index": 4, "name": "CLASSIFICATION_COLUMN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 2560, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 9, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "seed.the_tuva_project.ed_classification__categories"}, "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": {"metadata": {"type": "VIEW", "schema": "AHRQ_MEASURES", "name": "_INT_PQI_14_DENOM", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"YEAR_NUMBER": {"type": "NUMBER", "index": 1, "name": "YEAR_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 3, "name": "DATA_SOURCE", "comment": null}, "AGE": {"type": "NUMBER", "index": 4, "name": "AGE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_denom"}, "model.the_tuva_project.data_quality__observation_encounter_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "OBSERVATION_ENCOUNTER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__observation_encounter_id"}, "model.the_tuva_project.data_quality__institutional_apr_drg_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_APR_DRG_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_apr_drg_code"}, "model.the_tuva_project.data_quality__institutional_facility_npi": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "INSTITUTIONAL_FACILITY_NPI", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__institutional_facility_npi"}, "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": {"metadata": {"type": "BASE TABLE", "schema": "QUALITY_MEASURES", "name": "_INT_NQF0420_EXCLUSIONS", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "EXCLUSION_DATE": {"type": "DATE", "index": 2, "name": "EXCLUSION_DATE", "comment": null}, "EXCLUSION_REASON": {"type": "TEXT", "index": 3, "name": "EXCLUSION_REASON", "comment": null}, "EXCLUSION_FLAG": {"type": "NUMBER", "index": 4, "name": "EXCLUSION_FLAG", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 5, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:30UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_exclusions"}, "model.the_tuva_project.data_quality__pharmacy_member_id": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "PHARMACY_MEMBER_ID", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "TEXT", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 6, "name": "CLAIM_TYPE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 7, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 8, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 9, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 10, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 11, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:28UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__pharmacy_member_id"}, "model.the_tuva_project.data_quality__lab_result_source_code": {"metadata": {"type": "BASE TABLE", "schema": "DATA_QUALITY", "name": "LAB_RESULT_SOURCE_CODE", "database": "DEV_THUXUAN", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"DATA_SOURCE": {"type": "TEXT", "index": 1, "name": "DATA_SOURCE", "comment": null}, "SOURCE_DATE": {"type": "DATE", "index": 2, "name": "SOURCE_DATE", "comment": null}, "TABLE_NAME": {"type": "TEXT", "index": 3, "name": "TABLE_NAME", "comment": null}, "DRILL_DOWN_KEY": {"type": "TEXT", "index": 4, "name": "DRILL_DOWN_KEY", "comment": null}, "DRILL_DOWN_VALUE": {"type": "TEXT", "index": 5, "name": "DRILL_DOWN_VALUE", "comment": null}, "FIELD_NAME": {"type": "TEXT", "index": 6, "name": "FIELD_NAME", "comment": null}, "BUCKET_NAME": {"type": "TEXT", "index": 7, "name": "BUCKET_NAME", "comment": null}, "INVALID_REASON": {"type": "TEXT", "index": 8, "name": "INVALID_REASON", "comment": null}, "FIELD_VALUE": {"type": "TEXT", "index": 9, "name": "FIELD_VALUE", "comment": null}, "TUVA_LAST_RUN": {"type": "TEXT", "index": 10, "name": "TUVA_LAST_RUN", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:26UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code"}, "model.input_layer.patient": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PATIENT", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 2, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 3, "name": "LAST_NAME", "comment": null}, "SEX": {"type": "TEXT", "index": 4, "name": "SEX", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 9, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 10, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 11, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 12, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 13, "name": "ZIP_CODE", "comment": null}, "COUNTY": {"type": "TEXT", "index": 14, "name": "COUNTY", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 15, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 16, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 17, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 18, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 19, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.patient"}, "model.input_layer.location": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "LOCATION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LOCATION_ID": {"type": "TEXT", "index": 1, "name": "LOCATION_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "FACILITY_TYPE": {"type": "TEXT", "index": 4, "name": "FACILITY_TYPE", "comment": null}, "PARENT_ORGANIZATION": {"type": "TEXT", "index": 5, "name": "PARENT_ORGANIZATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 6, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 7, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 8, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 9, "name": "ZIP_CODE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 12, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 13, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 14, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.location"}, "model.input_layer.procedure": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PROCEDURE", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PROCEDURE_ID": {"type": "TEXT", "index": 1, "name": "PROCEDURE_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "PROCEDURE_DATE": {"type": "DATE", "index": 5, "name": "PROCEDURE_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "MODIFIER_1": {"type": "TEXT", "index": 12, "name": "MODIFIER_1", "comment": null}, "MODIFIER_2": {"type": "TEXT", "index": 13, "name": "MODIFIER_2", "comment": null}, "MODIFIER_3": {"type": "TEXT", "index": 14, "name": "MODIFIER_3", "comment": null}, "MODIFIER_4": {"type": "TEXT", "index": 15, "name": "MODIFIER_4", "comment": null}, "MODIFIER_5": {"type": "TEXT", "index": 16, "name": "MODIFIER_5", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 17, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 18, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 19, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.procedure"}, "model.input_layer.eligibility": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "ELIGIBILITY", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 2, "name": "MEMBER_ID", "comment": null}, "SUBSCRIBER_ID": {"type": "TEXT", "index": 3, "name": "SUBSCRIBER_ID", "comment": null}, "GENDER": {"type": "TEXT", "index": 4, "name": "GENDER", "comment": null}, "RACE": {"type": "TEXT", "index": 5, "name": "RACE", "comment": null}, "BIRTH_DATE": {"type": "DATE", "index": 6, "name": "BIRTH_DATE", "comment": null}, "DEATH_DATE": {"type": "DATE", "index": 7, "name": "DEATH_DATE", "comment": null}, "DEATH_FLAG": {"type": "NUMBER", "index": 8, "name": "DEATH_FLAG", "comment": null}, "ENROLLMENT_START_DATE": {"type": "DATE", "index": 9, "name": "ENROLLMENT_START_DATE", "comment": null}, "ENROLLMENT_END_DATE": {"type": "DATE", "index": 10, "name": "ENROLLMENT_END_DATE", "comment": null}, "PAYER": {"type": "TEXT", "index": 11, "name": "PAYER", "comment": null}, "PAYER_TYPE": {"type": "TEXT", "index": 12, "name": "PAYER_TYPE", "comment": null}, "PLAN": {"type": "TEXT", "index": 13, "name": "PLAN", "comment": null}, "ORIGINAL_REASON_ENTITLEMENT_CODE": {"type": "TEXT", "index": 14, "name": "ORIGINAL_REASON_ENTITLEMENT_CODE", "comment": null}, "DUAL_STATUS_CODE": {"type": "TEXT", "index": 15, "name": "DUAL_STATUS_CODE", "comment": null}, "MEDICARE_STATUS_CODE": {"type": "TEXT", "index": 16, "name": "MEDICARE_STATUS_CODE", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 17, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 18, "name": "LAST_NAME", "comment": null}, "SOCIAL_SECURITY_NUMBER": {"type": "TEXT", "index": 19, "name": "SOCIAL_SECURITY_NUMBER", "comment": null}, "SUBSCRIBER_RELATION": {"type": "TEXT", "index": 20, "name": "SUBSCRIBER_RELATION", "comment": null}, "ADDRESS": {"type": "TEXT", "index": 21, "name": "ADDRESS", "comment": null}, "CITY": {"type": "TEXT", "index": 22, "name": "CITY", "comment": null}, "STATE": {"type": "TEXT", "index": 23, "name": "STATE", "comment": null}, "ZIP_CODE": {"type": "TEXT", "index": 24, "name": "ZIP_CODE", "comment": null}, "PHONE": {"type": "TEXT", "index": 25, "name": "PHONE", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 26, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 27, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 28, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.eligibility"}, "model.input_layer.encounter": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "ENCOUNTER", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"ENCOUNTER_ID": {"type": "TEXT", "index": 1, "name": "ENCOUNTER_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_TYPE": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_TYPE", "comment": null}, "ENCOUNTER_START_DATE": {"type": "DATE", "index": 4, "name": "ENCOUNTER_START_DATE", "comment": null}, "ENCOUNTER_END_DATE": {"type": "DATE", "index": 5, "name": "ENCOUNTER_END_DATE", "comment": null}, "LENGTH_OF_STAY": {"type": "NUMBER", "index": 6, "name": "LENGTH_OF_STAY", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "ADMIT_SOURCE_DESCRIPTION", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 9, "name": "ADMIT_TYPE_CODE", "comment": null}, "ADMIT_TYPE_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "ADMIT_TYPE_DESCRIPTION", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 11, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "DISCHARGE_DISPOSITION_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "DISCHARGE_DISPOSITION_DESCRIPTION", "comment": null}, "ATTENDING_PROVIDER_ID": {"type": "TEXT", "index": 13, "name": "ATTENDING_PROVIDER_ID", "comment": null}, "ATTENDING_PROVIDER_NAME": {"type": "TEXT", "index": 14, "name": "ATTENDING_PROVIDER_NAME", "comment": null}, "FACILITY_ID": {"type": "TEXT", "index": 15, "name": "FACILITY_ID", "comment": null}, "FACILITY_NAME": {"type": "TEXT", "index": 16, "name": "FACILITY_NAME", "comment": null}, "PRIMARY_DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 17, "name": "PRIMARY_DIAGNOSIS_CODE_TYPE", "comment": null}, "PRIMARY_DIAGNOSIS_CODE": {"type": "TEXT", "index": 18, "name": "PRIMARY_DIAGNOSIS_CODE", "comment": null}, "PRIMARY_DIAGNOSIS_DESCRIPTION": {"type": "TEXT", "index": 19, "name": "PRIMARY_DIAGNOSIS_DESCRIPTION", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 20, "name": "MS_DRG_CODE", "comment": null}, "MS_DRG_DESCRIPTION": {"type": "TEXT", "index": 21, "name": "MS_DRG_DESCRIPTION", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 22, "name": "APR_DRG_CODE", "comment": null}, "APR_DRG_DESCRIPTION": {"type": "TEXT", "index": 23, "name": "APR_DRG_DESCRIPTION", "comment": null}, "PAID_AMOUNT": {"type": "NUMBER", "index": 24, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "NUMBER", "index": 25, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "NUMBER", "index": 26, "name": "CHARGE_AMOUNT", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 28, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.encounter"}, "model.input_layer.medical_claim": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "MEDICAL_CLAIM", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "CLAIM_TYPE": {"type": "TEXT", "index": 3, "name": "CLAIM_TYPE", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 4, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 5, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 6, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 7, "name": "PLAN", "comment": null}, "CLAIM_START_DATE": {"type": "DATE", "index": 8, "name": "CLAIM_START_DATE", "comment": null}, "CLAIM_END_DATE": {"type": "DATE", "index": 9, "name": "CLAIM_END_DATE", "comment": null}, "CLAIM_LINE_START_DATE": {"type": "DATE", "index": 10, "name": "CLAIM_LINE_START_DATE", "comment": null}, "CLAIM_LINE_END_DATE": {"type": "DATE", "index": 11, "name": "CLAIM_LINE_END_DATE", "comment": null}, "ADMISSION_DATE": {"type": "DATE", "index": 12, "name": "ADMISSION_DATE", "comment": null}, "DISCHARGE_DATE": {"type": "DATE", "index": 13, "name": "DISCHARGE_DATE", "comment": null}, "ADMIT_SOURCE_CODE": {"type": "TEXT", "index": 14, "name": "ADMIT_SOURCE_CODE", "comment": null}, "ADMIT_TYPE_CODE": {"type": "TEXT", "index": 15, "name": "ADMIT_TYPE_CODE", "comment": null}, "DISCHARGE_DISPOSITION_CODE": {"type": "TEXT", "index": 16, "name": "DISCHARGE_DISPOSITION_CODE", "comment": null}, "PLACE_OF_SERVICE_CODE": {"type": "TEXT", "index": 17, "name": "PLACE_OF_SERVICE_CODE", "comment": null}, "BILL_TYPE_CODE": {"type": "TEXT", "index": 18, "name": "BILL_TYPE_CODE", "comment": null}, "MS_DRG_CODE": {"type": "TEXT", "index": 19, "name": "MS_DRG_CODE", "comment": null}, "APR_DRG_CODE": {"type": "TEXT", "index": 20, "name": "APR_DRG_CODE", "comment": null}, "REVENUE_CENTER_CODE": {"type": "TEXT", "index": 21, "name": "REVENUE_CENTER_CODE", "comment": null}, "SERVICE_UNIT_QUANTITY": {"type": "NUMBER", "index": 22, "name": "SERVICE_UNIT_QUANTITY", "comment": null}, "HCPCS_CODE": {"type": "TEXT", "index": 23, "name": "HCPCS_CODE", "comment": null}, "HCPCS_MODIFIER_1": {"type": "TEXT", "index": 24, "name": "HCPCS_MODIFIER_1", "comment": null}, "HCPCS_MODIFIER_2": {"type": "TEXT", "index": 25, "name": "HCPCS_MODIFIER_2", "comment": null}, "HCPCS_MODIFIER_3": {"type": "TEXT", "index": 26, "name": "HCPCS_MODIFIER_3", "comment": null}, "HCPCS_MODIFIER_4": {"type": "TEXT", "index": 27, "name": "HCPCS_MODIFIER_4", "comment": null}, "HCPCS_MODIFIER_5": {"type": "TEXT", "index": 28, "name": "HCPCS_MODIFIER_5", "comment": null}, "RENDERING_NPI": {"type": "TEXT", "index": 29, "name": "RENDERING_NPI", "comment": null}, "RENDERING_TIN": {"type": "NUMBER", "index": 30, "name": "RENDERING_TIN", "comment": null}, "BILLING_NPI": {"type": "TEXT", "index": 31, "name": "BILLING_NPI", "comment": null}, "BILLING_TIN": {"type": "NUMBER", "index": 32, "name": "BILLING_TIN", "comment": null}, "FACILITY_NPI": {"type": "TEXT", "index": 33, "name": "FACILITY_NPI", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 34, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 35, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 36, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 37, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "FLOAT", "index": 38, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "FLOAT", "index": 39, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "FLOAT", "index": 40, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "TOTAL_COST_AMOUNT": {"type": "FLOAT", "index": 41, "name": "TOTAL_COST_AMOUNT", "comment": null}, "DIAGNOSIS_CODE_TYPE": {"type": "TEXT", "index": 42, "name": "DIAGNOSIS_CODE_TYPE", "comment": null}, "DIAGNOSIS_CODE_1": {"type": "TEXT", "index": 43, "name": "DIAGNOSIS_CODE_1", "comment": null}, "DIAGNOSIS_CODE_2": {"type": "TEXT", "index": 44, "name": "DIAGNOSIS_CODE_2", "comment": null}, "DIAGNOSIS_CODE_3": {"type": "TEXT", "index": 45, "name": "DIAGNOSIS_CODE_3", "comment": null}, "DIAGNOSIS_CODE_4": {"type": "TEXT", "index": 46, "name": "DIAGNOSIS_CODE_4", "comment": null}, "DIAGNOSIS_CODE_5": {"type": "TEXT", "index": 47, "name": "DIAGNOSIS_CODE_5", "comment": null}, "DIAGNOSIS_CODE_6": {"type": "TEXT", "index": 48, "name": "DIAGNOSIS_CODE_6", "comment": null}, "DIAGNOSIS_CODE_7": {"type": "TEXT", "index": 49, "name": "DIAGNOSIS_CODE_7", "comment": null}, "DIAGNOSIS_CODE_8": {"type": "TEXT", "index": 50, "name": "DIAGNOSIS_CODE_8", "comment": null}, "DIAGNOSIS_CODE_9": {"type": "TEXT", "index": 51, "name": "DIAGNOSIS_CODE_9", "comment": null}, "DIAGNOSIS_CODE_10": {"type": "TEXT", "index": 52, "name": "DIAGNOSIS_CODE_10", "comment": null}, "DIAGNOSIS_CODE_11": {"type": "TEXT", "index": 53, "name": "DIAGNOSIS_CODE_11", "comment": null}, "DIAGNOSIS_CODE_12": {"type": "TEXT", "index": 54, "name": "DIAGNOSIS_CODE_12", "comment": null}, "DIAGNOSIS_CODE_13": {"type": "TEXT", "index": 55, "name": "DIAGNOSIS_CODE_13", "comment": null}, "DIAGNOSIS_CODE_14": {"type": "TEXT", "index": 56, "name": "DIAGNOSIS_CODE_14", "comment": null}, "DIAGNOSIS_CODE_15": {"type": "TEXT", "index": 57, "name": "DIAGNOSIS_CODE_15", "comment": null}, "DIAGNOSIS_CODE_16": {"type": "TEXT", "index": 58, "name": "DIAGNOSIS_CODE_16", "comment": null}, "DIAGNOSIS_CODE_17": {"type": "TEXT", "index": 59, "name": "DIAGNOSIS_CODE_17", "comment": null}, "DIAGNOSIS_CODE_18": {"type": "TEXT", "index": 60, "name": "DIAGNOSIS_CODE_18", "comment": null}, "DIAGNOSIS_CODE_19": {"type": "TEXT", "index": 61, "name": "DIAGNOSIS_CODE_19", "comment": null}, "DIAGNOSIS_CODE_20": {"type": "TEXT", "index": 62, "name": "DIAGNOSIS_CODE_20", "comment": null}, "DIAGNOSIS_CODE_21": {"type": "TEXT", "index": 63, "name": "DIAGNOSIS_CODE_21", "comment": null}, "DIAGNOSIS_CODE_22": {"type": "TEXT", "index": 64, "name": "DIAGNOSIS_CODE_22", "comment": null}, "DIAGNOSIS_CODE_23": {"type": "TEXT", "index": 65, "name": "DIAGNOSIS_CODE_23", "comment": null}, "DIAGNOSIS_CODE_24": {"type": "TEXT", "index": 66, "name": "DIAGNOSIS_CODE_24", "comment": null}, "DIAGNOSIS_CODE_25": {"type": "TEXT", "index": 67, "name": "DIAGNOSIS_CODE_25", "comment": null}, "DIAGNOSIS_POA_1": {"type": "TEXT", "index": 68, "name": "DIAGNOSIS_POA_1", "comment": null}, "DIAGNOSIS_POA_2": {"type": "TEXT", "index": 69, "name": "DIAGNOSIS_POA_2", "comment": null}, "DIAGNOSIS_POA_3": {"type": "TEXT", "index": 70, "name": "DIAGNOSIS_POA_3", "comment": null}, "DIAGNOSIS_POA_4": {"type": "TEXT", "index": 71, "name": "DIAGNOSIS_POA_4", "comment": null}, "DIAGNOSIS_POA_5": {"type": "TEXT", "index": 72, "name": "DIAGNOSIS_POA_5", "comment": null}, "DIAGNOSIS_POA_6": {"type": "TEXT", "index": 73, "name": "DIAGNOSIS_POA_6", "comment": null}, "DIAGNOSIS_POA_7": {"type": "TEXT", "index": 74, "name": "DIAGNOSIS_POA_7", "comment": null}, "DIAGNOSIS_POA_8": {"type": "TEXT", "index": 75, "name": "DIAGNOSIS_POA_8", "comment": null}, "DIAGNOSIS_POA_9": {"type": "TEXT", "index": 76, "name": "DIAGNOSIS_POA_9", "comment": null}, "DIAGNOSIS_POA_10": {"type": "TEXT", "index": 77, "name": "DIAGNOSIS_POA_10", "comment": null}, "DIAGNOSIS_POA_11": {"type": "TEXT", "index": 78, "name": "DIAGNOSIS_POA_11", "comment": null}, "DIAGNOSIS_POA_12": {"type": "TEXT", "index": 79, "name": "DIAGNOSIS_POA_12", "comment": null}, "DIAGNOSIS_POA_13": {"type": "TEXT", "index": 80, "name": "DIAGNOSIS_POA_13", "comment": null}, "DIAGNOSIS_POA_14": {"type": "TEXT", "index": 81, "name": "DIAGNOSIS_POA_14", "comment": null}, "DIAGNOSIS_POA_15": {"type": "TEXT", "index": 82, "name": "DIAGNOSIS_POA_15", "comment": null}, "DIAGNOSIS_POA_16": {"type": "TEXT", "index": 83, "name": "DIAGNOSIS_POA_16", "comment": null}, "DIAGNOSIS_POA_17": {"type": "TEXT", "index": 84, "name": "DIAGNOSIS_POA_17", "comment": null}, "DIAGNOSIS_POA_18": {"type": "TEXT", "index": 85, "name": "DIAGNOSIS_POA_18", "comment": null}, "DIAGNOSIS_POA_19": {"type": "TEXT", "index": 86, "name": "DIAGNOSIS_POA_19", "comment": null}, "DIAGNOSIS_POA_20": {"type": "TEXT", "index": 87, "name": "DIAGNOSIS_POA_20", "comment": null}, "DIAGNOSIS_POA_21": {"type": "TEXT", "index": 88, "name": "DIAGNOSIS_POA_21", "comment": null}, "DIAGNOSIS_POA_22": {"type": "TEXT", "index": 89, "name": "DIAGNOSIS_POA_22", "comment": null}, "DIAGNOSIS_POA_23": {"type": "TEXT", "index": 90, "name": "DIAGNOSIS_POA_23", "comment": null}, "DIAGNOSIS_POA_24": {"type": "TEXT", "index": 91, "name": "DIAGNOSIS_POA_24", "comment": null}, "DIAGNOSIS_POA_25": {"type": "TEXT", "index": 92, "name": "DIAGNOSIS_POA_25", "comment": null}, "PROCEDURE_CODE_TYPE": {"type": "TEXT", "index": 93, "name": "PROCEDURE_CODE_TYPE", "comment": null}, "PROCEDURE_CODE_1": {"type": "TEXT", "index": 94, "name": "PROCEDURE_CODE_1", "comment": null}, "PROCEDURE_CODE_2": {"type": "TEXT", "index": 95, "name": "PROCEDURE_CODE_2", "comment": null}, "PROCEDURE_CODE_3": {"type": "TEXT", "index": 96, "name": "PROCEDURE_CODE_3", "comment": null}, "PROCEDURE_CODE_4": {"type": "TEXT", "index": 97, "name": "PROCEDURE_CODE_4", "comment": null}, "PROCEDURE_CODE_5": {"type": "TEXT", "index": 98, "name": "PROCEDURE_CODE_5", "comment": null}, "PROCEDURE_CODE_6": {"type": "TEXT", "index": 99, "name": "PROCEDURE_CODE_6", "comment": null}, "PROCEDURE_CODE_7": {"type": "TEXT", "index": 100, "name": "PROCEDURE_CODE_7", "comment": null}, "PROCEDURE_CODE_8": {"type": "TEXT", "index": 101, "name": "PROCEDURE_CODE_8", "comment": null}, "PROCEDURE_CODE_9": {"type": "TEXT", "index": 102, "name": "PROCEDURE_CODE_9", "comment": null}, "PROCEDURE_CODE_10": {"type": "TEXT", "index": 103, "name": "PROCEDURE_CODE_10", "comment": null}, "PROCEDURE_CODE_11": {"type": "TEXT", "index": 104, "name": "PROCEDURE_CODE_11", "comment": null}, "PROCEDURE_CODE_12": {"type": "TEXT", "index": 105, "name": "PROCEDURE_CODE_12", "comment": null}, "PROCEDURE_CODE_13": {"type": "TEXT", "index": 106, "name": "PROCEDURE_CODE_13", "comment": null}, "PROCEDURE_CODE_14": {"type": "TEXT", "index": 107, "name": "PROCEDURE_CODE_14", "comment": null}, "PROCEDURE_CODE_15": {"type": "TEXT", "index": 108, "name": "PROCEDURE_CODE_15", "comment": null}, "PROCEDURE_CODE_16": {"type": "TEXT", "index": 109, "name": "PROCEDURE_CODE_16", "comment": null}, "PROCEDURE_CODE_17": {"type": "TEXT", "index": 110, "name": "PROCEDURE_CODE_17", "comment": null}, "PROCEDURE_CODE_18": {"type": "TEXT", "index": 111, "name": "PROCEDURE_CODE_18", "comment": null}, "PROCEDURE_CODE_19": {"type": "TEXT", "index": 112, "name": "PROCEDURE_CODE_19", "comment": null}, "PROCEDURE_CODE_20": {"type": "TEXT", "index": 113, "name": "PROCEDURE_CODE_20", "comment": null}, "PROCEDURE_CODE_21": {"type": "TEXT", "index": 114, "name": "PROCEDURE_CODE_21", "comment": null}, "PROCEDURE_CODE_22": {"type": "TEXT", "index": 115, "name": "PROCEDURE_CODE_22", "comment": null}, "PROCEDURE_CODE_23": {"type": "TEXT", "index": 116, "name": "PROCEDURE_CODE_23", "comment": null}, "PROCEDURE_CODE_24": {"type": "TEXT", "index": 117, "name": "PROCEDURE_CODE_24", "comment": null}, "PROCEDURE_CODE_25": {"type": "TEXT", "index": 118, "name": "PROCEDURE_CODE_25", "comment": null}, "PROCEDURE_DATE_1": {"type": "DATE", "index": 119, "name": "PROCEDURE_DATE_1", "comment": null}, "PROCEDURE_DATE_2": {"type": "DATE", "index": 120, "name": "PROCEDURE_DATE_2", "comment": null}, "PROCEDURE_DATE_3": {"type": "DATE", "index": 121, "name": "PROCEDURE_DATE_3", "comment": null}, "PROCEDURE_DATE_4": {"type": "DATE", "index": 122, "name": "PROCEDURE_DATE_4", "comment": null}, "PROCEDURE_DATE_5": {"type": "DATE", "index": 123, "name": "PROCEDURE_DATE_5", "comment": null}, "PROCEDURE_DATE_6": {"type": "DATE", "index": 124, "name": "PROCEDURE_DATE_6", "comment": null}, "PROCEDURE_DATE_7": {"type": "DATE", "index": 125, "name": "PROCEDURE_DATE_7", "comment": null}, "PROCEDURE_DATE_8": {"type": "DATE", "index": 126, "name": "PROCEDURE_DATE_8", "comment": null}, "PROCEDURE_DATE_9": {"type": "DATE", "index": 127, "name": "PROCEDURE_DATE_9", "comment": null}, "PROCEDURE_DATE_10": {"type": "DATE", "index": 128, "name": "PROCEDURE_DATE_10", "comment": null}, "PROCEDURE_DATE_11": {"type": "DATE", "index": 129, "name": "PROCEDURE_DATE_11", "comment": null}, "PROCEDURE_DATE_12": {"type": "DATE", "index": 130, "name": "PROCEDURE_DATE_12", "comment": null}, "PROCEDURE_DATE_13": {"type": "DATE", "index": 131, "name": "PROCEDURE_DATE_13", "comment": null}, "PROCEDURE_DATE_14": {"type": "DATE", "index": 132, "name": "PROCEDURE_DATE_14", "comment": null}, "PROCEDURE_DATE_15": {"type": "DATE", "index": 133, "name": "PROCEDURE_DATE_15", "comment": null}, "PROCEDURE_DATE_16": {"type": "DATE", "index": 134, "name": "PROCEDURE_DATE_16", "comment": null}, "PROCEDURE_DATE_17": {"type": "DATE", "index": 135, "name": "PROCEDURE_DATE_17", "comment": null}, "PROCEDURE_DATE_18": {"type": "DATE", "index": 136, "name": "PROCEDURE_DATE_18", "comment": null}, "PROCEDURE_DATE_19": {"type": "DATE", "index": 137, "name": "PROCEDURE_DATE_19", "comment": null}, "PROCEDURE_DATE_20": {"type": "DATE", "index": 138, "name": "PROCEDURE_DATE_20", "comment": null}, "PROCEDURE_DATE_21": {"type": "DATE", "index": 139, "name": "PROCEDURE_DATE_21", "comment": null}, "PROCEDURE_DATE_22": {"type": "DATE", "index": 140, "name": "PROCEDURE_DATE_22", "comment": null}, "PROCEDURE_DATE_23": {"type": "DATE", "index": 141, "name": "PROCEDURE_DATE_23", "comment": null}, "PROCEDURE_DATE_24": {"type": "DATE", "index": 142, "name": "PROCEDURE_DATE_24", "comment": null}, "PROCEDURE_DATE_25": {"type": "DATE", "index": 143, "name": "PROCEDURE_DATE_25", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 144, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 145, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 146, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 147, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.medical_claim"}, "model.input_layer.lab_result": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "LAB_RESULT", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"LAB_RESULT_ID": {"type": "TEXT", "index": 1, "name": "LAB_RESULT_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "ACCESSION_NUMBER": {"type": "TEXT", "index": 4, "name": "ACCESSION_NUMBER", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 5, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 7, "name": "SOURCE_DESCRIPTION", "comment": null}, "SOURCE_COMPONENT": {"type": "TEXT", "index": 8, "name": "SOURCE_COMPONENT", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 9, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 11, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "NORMALIZED_COMPONENT": {"type": "TEXT", "index": 12, "name": "NORMALIZED_COMPONENT", "comment": null}, "STATUS": {"type": "TEXT", "index": 13, "name": "STATUS", "comment": null}, "RESULT": {"type": "TEXT", "index": 14, "name": "RESULT", "comment": null}, "RESULT_DATE": {"type": "DATE", "index": 15, "name": "RESULT_DATE", "comment": null}, "COLLECTION_DATE": {"type": "DATE", "index": 16, "name": "COLLECTION_DATE", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 17, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 18, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 19, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 20, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 21, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 22, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "SOURCE_ABNORMAL_FLAG": {"type": "NUMBER", "index": 23, "name": "SOURCE_ABNORMAL_FLAG", "comment": null}, "NORMALIZED_ABNORMAL_FLAG": {"type": "NUMBER", "index": 24, "name": "NORMALIZED_ABNORMAL_FLAG", "comment": null}, "SPECIMEN": {"type": "TEXT", "index": 25, "name": "SPECIMEN", "comment": null}, "ORDERING_PRACTITIONER_ID": {"type": "TEXT", "index": 26, "name": "ORDERING_PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 27, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 28, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 29, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.lab_result"}, "model.input_layer.practitioner": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PRACTITIONER", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PRACTITIONER_ID": {"type": "TEXT", "index": 1, "name": "PRACTITIONER_ID", "comment": null}, "NPI": {"type": "TEXT", "index": 2, "name": "NPI", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 3, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 4, "name": "LAST_NAME", "comment": null}, "PRACTICE_AFFILIATION": {"type": "TEXT", "index": 5, "name": "PRACTICE_AFFILIATION", "comment": null}, "SPECIALTY": {"type": "TEXT", "index": 6, "name": "SPECIALTY", "comment": null}, "SUB_SPECIALTY": {"type": "TEXT", "index": 7, "name": "SUB_SPECIALTY", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 8, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 9, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 10, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.practitioner"}, "model.input_layer.provider_attribution": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PROVIDER_ATTRIBUTION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"PATIENT_ID": {"type": "TEXT", "index": 1, "name": "PATIENT_ID", "comment": null}, "YEAR_MONTH": {"type": "TEXT", "index": 2, "name": "YEAR_MONTH", "comment": null}, "PAYER": {"type": "TEXT", "index": 3, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 4, "name": "PLAN", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 5, "name": "DATA_SOURCE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 6, "name": "PAYER_ATTRIBUTED_PROVIDER", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 7, "name": "PAYER_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 8, "name": "PAYER_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "PAYER_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 9, "name": "PAYER_ATTRIBUTED_PROVIDER_LOB", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER": {"type": "TEXT", "index": 10, "name": "CUSTOM_ATTRIBUTED_PROVIDER", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE": {"type": "TEXT", "index": 11, "name": "CUSTOM_ATTRIBUTED_PROVIDER_PRACTICE", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION": {"type": "TEXT", "index": 12, "name": "CUSTOM_ATTRIBUTED_PROVIDER_ORGANIZATION", "comment": null}, "CUSTOM_ATTRIBUTED_PROVIDER_LOB": {"type": "TEXT", "index": 13, "name": "CUSTOM_ATTRIBUTED_PROVIDER_LOB", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.provider_attribution"}, "model.input_layer.condition": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "CONDITION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CONDITION_ID": {"type": "TEXT", "index": 1, "name": "CONDITION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "CLAIM_ID": {"type": "TEXT", "index": 4, "name": "CLAIM_ID", "comment": null}, "RECORDED_DATE": {"type": "DATE", "index": 5, "name": "RECORDED_DATE", "comment": null}, "ONSET_DATE": {"type": "DATE", "index": 6, "name": "ONSET_DATE", "comment": null}, "RESOLVED_DATE": {"type": "DATE", "index": 7, "name": "RESOLVED_DATE", "comment": null}, "STATUS": {"type": "TEXT", "index": 8, "name": "STATUS", "comment": null}, "CONDITION_TYPE": {"type": "TEXT", "index": 9, "name": "CONDITION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 11, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 13, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 14, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 15, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "CONDITION_RANK": {"type": "NUMBER", "index": 16, "name": "CONDITION_RANK", "comment": null}, "PRESENT_ON_ADMIT_CODE": {"type": "TEXT", "index": 17, "name": "PRESENT_ON_ADMIT_CODE", "comment": null}, "PRESENT_ON_ADMIT_DESCRIPTION": {"type": "TEXT", "index": 18, "name": "PRESENT_ON_ADMIT_DESCRIPTION", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 19, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 20, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.condition"}, "model.input_layer.medication": {"metadata": {"type": "VIEW", "schema": "INPUT_LAYER", "name": "MEDICATION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"MEDICATION_ID": {"type": "TEXT", "index": 1, "name": "MEDICATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 4, "name": "DISPENSING_DATE", "comment": null}, "PRESCRIBING_DATE": {"type": "DATE", "index": 5, "name": "PRESCRIBING_DATE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 6, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 8, "name": "SOURCE_DESCRIPTION", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 9, "name": "NDC_CODE", "comment": null}, "NDC_DESCRIPTION": {"type": "TEXT", "index": 10, "name": "NDC_DESCRIPTION", "comment": null}, "RXNORM_CODE": {"type": "TEXT", "index": 11, "name": "RXNORM_CODE", "comment": null}, "RXNORM_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "RXNORM_DESCRIPTION", "comment": null}, "ATC_CODE": {"type": "TEXT", "index": 13, "name": "ATC_CODE", "comment": null}, "ATC_DESCRIPTION": {"type": "TEXT", "index": 14, "name": "ATC_DESCRIPTION", "comment": null}, "ROUTE": {"type": "TEXT", "index": 15, "name": "ROUTE", "comment": null}, "STRENGTH": {"type": "TEXT", "index": 16, "name": "STRENGTH", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 17, "name": "QUANTITY", "comment": null}, "QUANTITY_UNIT": {"type": "TEXT", "index": 18, "name": "QUANTITY_UNIT", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 19, "name": "DAYS_SUPPLY", "comment": null}, "PRACTITIONER_ID": {"type": "TEXT", "index": 20, "name": "PRACTITIONER_ID", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 21, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 22, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 23, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.medication"}, "model.input_layer.observation": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "OBSERVATION", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"OBSERVATION_ID": {"type": "TEXT", "index": 1, "name": "OBSERVATION_ID", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 2, "name": "PATIENT_ID", "comment": null}, "ENCOUNTER_ID": {"type": "TEXT", "index": 3, "name": "ENCOUNTER_ID", "comment": null}, "PANEL_ID": {"type": "TEXT", "index": 4, "name": "PANEL_ID", "comment": null}, "OBSERVATION_DATE": {"type": "DATE", "index": 5, "name": "OBSERVATION_DATE", "comment": null}, "OBSERVATION_TYPE": {"type": "TEXT", "index": 6, "name": "OBSERVATION_TYPE", "comment": null}, "SOURCE_CODE_TYPE": {"type": "TEXT", "index": 7, "name": "SOURCE_CODE_TYPE", "comment": null}, "SOURCE_CODE": {"type": "TEXT", "index": 8, "name": "SOURCE_CODE", "comment": null}, "SOURCE_DESCRIPTION": {"type": "TEXT", "index": 9, "name": "SOURCE_DESCRIPTION", "comment": null}, "NORMALIZED_CODE_TYPE": {"type": "TEXT", "index": 10, "name": "NORMALIZED_CODE_TYPE", "comment": null}, "NORMALIZED_CODE": {"type": "TEXT", "index": 11, "name": "NORMALIZED_CODE", "comment": null}, "NORMALIZED_DESCRIPTION": {"type": "TEXT", "index": 12, "name": "NORMALIZED_DESCRIPTION", "comment": null}, "RESULT": {"type": "TEXT", "index": 13, "name": "RESULT", "comment": null}, "SOURCE_UNITS": {"type": "TEXT", "index": 14, "name": "SOURCE_UNITS", "comment": null}, "NORMALIZED_UNITS": {"type": "TEXT", "index": 15, "name": "NORMALIZED_UNITS", "comment": null}, "SOURCE_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 16, "name": "SOURCE_REFERENCE_RANGE_LOW", "comment": null}, "SOURCE_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 17, "name": "SOURCE_REFERENCE_RANGE_HIGH", "comment": null}, "NORMALIZED_REFERENCE_RANGE_LOW": {"type": "TEXT", "index": 18, "name": "NORMALIZED_REFERENCE_RANGE_LOW", "comment": null}, "NORMALIZED_REFERENCE_RANGE_HIGH": {"type": "TEXT", "index": 19, "name": "NORMALIZED_REFERENCE_RANGE_HIGH", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 20, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 21, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:25UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.observation"}, "model.input_layer.pharmacy_claim": {"metadata": {"type": "BASE TABLE", "schema": "INPUT_LAYER", "name": "PHARMACY_CLAIM", "database": "TUVA", "comment": null, "owner": "ACCOUNTADMIN"}, "columns": {"CLAIM_ID": {"type": "TEXT", "index": 1, "name": "CLAIM_ID", "comment": null}, "CLAIM_LINE_NUMBER": {"type": "NUMBER", "index": 2, "name": "CLAIM_LINE_NUMBER", "comment": null}, "PATIENT_ID": {"type": "TEXT", "index": 3, "name": "PATIENT_ID", "comment": null}, "MEMBER_ID": {"type": "TEXT", "index": 4, "name": "MEMBER_ID", "comment": null}, "PAYER": {"type": "TEXT", "index": 5, "name": "PAYER", "comment": null}, "PLAN": {"type": "TEXT", "index": 6, "name": "PLAN", "comment": null}, "PRESCRIBING_PROVIDER_NPI": {"type": "TEXT", "index": 7, "name": "PRESCRIBING_PROVIDER_NPI", "comment": null}, "DISPENSING_PROVIDER_NPI": {"type": "TEXT", "index": 8, "name": "DISPENSING_PROVIDER_NPI", "comment": null}, "DISPENSING_DATE": {"type": "DATE", "index": 9, "name": "DISPENSING_DATE", "comment": null}, "NDC_CODE": {"type": "TEXT", "index": 10, "name": "NDC_CODE", "comment": null}, "QUANTITY": {"type": "NUMBER", "index": 11, "name": "QUANTITY", "comment": null}, "DAYS_SUPPLY": {"type": "NUMBER", "index": 12, "name": "DAYS_SUPPLY", "comment": null}, "REFILLS": {"type": "NUMBER", "index": 13, "name": "REFILLS", "comment": null}, "PAID_DATE": {"type": "DATE", "index": 14, "name": "PAID_DATE", "comment": null}, "PAID_AMOUNT": {"type": "FLOAT", "index": 15, "name": "PAID_AMOUNT", "comment": null}, "ALLOWED_AMOUNT": {"type": "FLOAT", "index": 16, "name": "ALLOWED_AMOUNT", "comment": null}, "CHARGE_AMOUNT": {"type": "FLOAT", "index": 17, "name": "CHARGE_AMOUNT", "comment": null}, "COINSURANCE_AMOUNT": {"type": "NUMBER", "index": 18, "name": "COINSURANCE_AMOUNT", "comment": null}, "COPAYMENT_AMOUNT": {"type": "NUMBER", "index": 19, "name": "COPAYMENT_AMOUNT", "comment": null}, "DEDUCTIBLE_AMOUNT": {"type": "NUMBER", "index": 20, "name": "DEDUCTIBLE_AMOUNT", "comment": null}, "IN_NETWORK_FLAG": {"type": "NUMBER", "index": 21, "name": "IN_NETWORK_FLAG", "comment": null}, "DATA_SOURCE": {"type": "TEXT", "index": 22, "name": "DATA_SOURCE", "comment": null}, "FILE_NAME": {"type": "TEXT", "index": 23, "name": "FILE_NAME", "comment": null}, "INGEST_DATETIME": {"type": "TIMESTAMP_NTZ", "index": 24, "name": "INGEST_DATETIME", "comment": null}}, "stats": {"last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2024-10-25 14:27UTC", "include": true, "description": "The timestamp for last update/change"}, "bytes": {"id": "bytes", "label": "Approximate Size", "value": 0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.input_layer.pharmacy_claim"}}, "sources": {}, "errors": null} \ No newline at end of file diff --git a/docs/manifest.json b/docs/manifest.json index 9b302b18..1acde1e5 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v12.json", "dbt_version": "1.8.7", "generated_at": "2024-10-22T19:20:27.265487Z", "invocation_id": "20286335-30e3-42ae-bde1-c852d2c2ff63", "env": {}, "project_name": "input_layer", "project_id": "c67fdb5d91230d67641e7c60c81d655e", "user_id": "f44fa49c-dcce-4172-9303-93dd3e638f0a", "send_anonymous_usage_stats": true, "adapter_type": "snowflake"}, "nodes": {"model.input_layer.provider_attribution": {"database": "tuva", "schema": "input_layer", "name": "provider_attribution", "resource_type": "model", "package_name": "input_layer", "path": "provider_attribution.sql", "original_file_path": "models/provider_attribution.sql", "unique_id": "model.input_layer.provider_attribution", "fqn": ["input_layer", "provider_attribution"], "alias": "provider_attribution", "checksum": {"name": "sha256", "checksum": "40bdb3a17999d3654fcae16df6458a58ecac54dd3bc830db3146e35d9eb9c349"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The provider_attribution table assigns a provider to each patient-member_month of eligibility. The user may assign both a payer attributed provider (as typically assigned by the payer in VBC contracts) as well as custom attributed provider (typically determined by the user). Fields related to each attributed provider (practice, organization, line of business)are also present.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset as a 6 character string (yyyymm, e.g. 202401).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider": {"name": "payer_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the payer.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "description": "Name of the practice for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "description": "Name of the organization for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "description": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider": {"name": "custom_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "description": "Name of the practice for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "description": "Name of the organization for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "description": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.1493208, "relation_name": "tuva.input_layer.provider_attribution", "raw_code": "select\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , payer_attributed_provider\n , payer_attributed_provider_practice\n , payer_attributed_provider_organization\n , payer_attributed_provider_lob\n , custom_attributed_provider\n , custom_attributed_provider_practice\n , custom_attributed_provider_organization\n , custom_attributed_provider_lob\nfrom {{ ref('provider_attribution_seed') }}", "language": "sql", "refs": [{"name": "provider_attribution_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.provider_attribution_seed"]}, "compiled_path": "../target/compiled/input_layer/models/provider_attribution.sql", "compiled": true, "compiled_code": "select\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , payer_attributed_provider\n , payer_attributed_provider_practice\n , payer_attributed_provider_organization\n , payer_attributed_provider_lob\n , custom_attributed_provider\n , custom_attributed_provider_practice\n , custom_attributed_provider_organization\n , custom_attributed_provider_lob\nfrom cms_synthetic._tuva_synthetic.provider_attribution_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.procedure": {"database": "tuva", "schema": "input_layer", "name": "procedure", "resource_type": "model", "package_name": "input_layer", "path": "procedure.sql", "original_file_path": "models/procedure.sql", "unique_id": "model.input_layer.procedure", "fqn": ["input_layer", "procedure"], "alias": "procedure", "checksum": {"name": "sha256", "checksum": "3e88fdc92568176776b136dbea132b5de7e0c7e9affd09192d8a3c5e9eb4920d"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The procedure table contains information on procedures that were performed on patients in the dataset.\n", "columns": {"procedure_id": {"name": "procedure_id", "description": "The unique identifier for the performed procedure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each person across all datasets.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "The encounter_id for the encounter where this procedure was performed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "The claim on which the procedure was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date": {"name": "procedure_date", "description": "Date when the procedure was performed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "Type of procedure code for the procedure in the source system.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The procedure code in the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the procedure code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "Normalized type of procedure code for the procedure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Description of the procedure code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_1": {"name": "modifier_1", "description": "First modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_2": {"name": "modifier_2", "description": "Second modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_3": {"name": "modifier_3", "description": "Third modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_4": {"name": "modifier_4", "description": "Fourth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_5": {"name": "modifier_5", "description": "Fifth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "ID of the provider who performed the procedure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.1732109, "relation_name": "tuva.input_layer.procedure", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as procedure_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as claim_id\n , cast(null as date) as procedure_date\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\n , cast(null as {{ dbt.type_string() }} ) as modifier_1\n , cast(null as {{ dbt.type_string() }} ) as modifier_2\n , cast(null as {{ dbt.type_string() }} ) as modifier_3\n , cast(null as {{ dbt.type_string() }} ) as modifier_4\n , cast(null as {{ dbt.type_string() }} ) as modifier_5\n , cast(null as {{ dbt.type_string() }} ) as practitioner_id\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/procedure.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as procedure_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as procedure_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as modifier_1\n , cast(null as TEXT ) as modifier_2\n , cast(null as TEXT ) as modifier_3\n , cast(null as TEXT ) as modifier_4\n , cast(null as TEXT ) as modifier_5\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.practitioner": {"database": "tuva", "schema": "input_layer", "name": "practitioner", "resource_type": "model", "package_name": "input_layer", "path": "practitioner.sql", "original_file_path": "models/practitioner.sql", "unique_id": "model.input_layer.practitioner", "fqn": ["input_layer", "practitioner"], "alias": "practitioner", "checksum": {"name": "sha256", "checksum": "e214e8b54ff10d7e29aca10447fbf16d8a5b33f1d700d417c149bad12a11b248"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The practitioner table contains information on the providers in the dataset e.g. physicians, physicians assistants, etc.\n", "columns": {"practitioner_id": {"name": "practitioner_id", "description": "Unique ID for the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "NPI for the provider.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "First name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Last name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_affiliation": {"name": "practice_affiliation", "description": "Practice affiliation of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty": {"name": "specialty", "description": "Specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sub_specialty": {"name": "sub_specialty", "description": "Sub specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.171146, "relation_name": "tuva.input_layer.practitioner", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as practitioner_id\n , cast(null as {{ dbt.type_string() }} ) as npi\n , cast(null as {{ dbt.type_string() }} ) as first_name\n , cast(null as {{ dbt.type_string() }} ) as last_name\n , cast(null as {{ dbt.type_string() }} ) as practice_affiliation\n , cast(null as {{ dbt.type_string() }} ) as specialty\n , cast(null as {{ dbt.type_string() }} ) as sub_specialty\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/practitioner.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as practice_affiliation\n , cast(null as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.encounter": {"database": "tuva", "schema": "input_layer", "name": "encounter", "resource_type": "model", "package_name": "input_layer", "path": "encounter.sql", "original_file_path": "models/encounter.sql", "unique_id": "model.input_layer.encounter", "fqn": ["input_layer", "encounter"], "alias": "encounter", "checksum": {"name": "sha256", "checksum": "014167d7b460273087d69c9c91d70203c829b134c06a136afaf5c98dfdf981d1"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The encounter table contains information about patients visits (i.e. encounters). This includes acute inpatient, emergency department, office visits, SNF stays, etc.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__encounter_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Admission source code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Admission type code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Discharge disposition code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_id": {"name": "attending_provider_id", "description": "Attending provider ID for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_name": {"name": "attending_provider_name", "description": "Attending provider name for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility identifier for the encounter (typically represents the facility where services were performed). Can be an NPI or source code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name for the encounter (typically represents the facility where services were performed).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid for the encounter by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient) on the encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the encounter by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.156946, "relation_name": "tuva.input_layer.encounter", "raw_code": "select \n cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_type\n , cast(null as date) as encounter_start_date\n , cast(null as date) as encounter_end_date\n , cast(null as {{ dbt.type_int() }} ) as length_of_stay\n , cast(null as {{ dbt.type_string() }} ) as admit_source_code\n , cast(null as {{ dbt.type_string() }} ) as admit_source_description\n , cast(null as {{ dbt.type_string() }} ) as admit_type_code\n , cast(null as {{ dbt.type_string() }} ) as admit_type_description\n , cast(null as {{ dbt.type_string() }} ) as discharge_disposition_code\n , cast(null as {{ dbt.type_string() }} ) as discharge_disposition_description\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_id\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_name\n , cast(null as {{ dbt.type_string() }} ) as facility_id\n , cast(null as {{ dbt.type_string() }} ) as facility_name\n , cast(null as {{ dbt.type_string() }} ) as primary_diagnosis_code_type\n , cast(null as {{ dbt.type_string() }} ) as primary_diagnosis_code\n , cast(null as {{ dbt.type_string() }} ) as primary_diagnosis_description\n , cast(null as {{ dbt.type_string() }} ) as ms_drg_code\n , cast(null as {{ dbt.type_string() }} ) as ms_drg_description\n , cast(null as {{ dbt.type_string() }} ) as apr_drg_code\n , cast(null as {{ dbt.type_string() }} ) as apr_drg_description\n , cast(null as {{ dbt.type_numeric() }} ) as paid_amount\n , cast(null as {{ dbt.type_numeric() }} ) as allowed_amount\n , cast(null as {{ dbt.type_numeric() }} ) as charge_amount\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/encounter.sql", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_type\n , cast(null as date) as encounter_start_date\n , cast(null as date) as encounter_end_date\n , cast(null as integer ) as length_of_stay\n , cast(null as TEXT ) as admit_source_code\n , cast(null as TEXT ) as admit_source_description\n , cast(null as TEXT ) as admit_type_code\n , cast(null as TEXT ) as admit_type_description\n , cast(null as TEXT ) as discharge_disposition_code\n , cast(null as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(null as TEXT ) as facility_id\n , cast(null as TEXT ) as facility_name\n , cast(null as TEXT ) as primary_diagnosis_code_type\n , cast(null as TEXT ) as primary_diagnosis_code\n , cast(null as TEXT ) as primary_diagnosis_description\n , cast(null as TEXT ) as ms_drg_code\n , cast(null as TEXT ) as ms_drg_description\n , cast(null as TEXT ) as apr_drg_code\n , cast(null as TEXT ) as apr_drg_description\n , cast(null as numeric(28,6) ) as paid_amount\n , cast(null as numeric(28,6) ) as allowed_amount\n , cast(null as numeric(28,6) ) as charge_amount\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.eligibility": {"database": "tuva", "schema": "input_layer", "name": "eligibility", "resource_type": "model", "package_name": "input_layer", "path": "eligibility.sql", "original_file_path": "models/eligibility.sql", "unique_id": "model.input_layer.eligibility", "fqn": ["input_layer", "eligibility"], "alias": "eligibility", "checksum": {"name": "sha256", "checksum": "3a680d198abd6a690e272e2aa463bcc5623b6674d92b09ec37771aaea19fce45"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The eligibility table includes information about a patient's health insurance coverage and demographics (note: we use the word patient as a synonym for member). Every claims dataset should include some sort of eligibility data, otherwise it's impossible to calculate member months, which are needed to calculate measures like PMPM.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_id": {"name": "subscriber_id", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Biological sex of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "Race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "Date the patient was born.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "Indicates whether the patient has died.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_type": {"name": "payer_type", "description": "Type of payer (e.g. commercial, medicare, medicaid, etc.).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__payer_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "Original reason for Medicare entitlement code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "Patient's first name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Patient's last name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "Patient's social security number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_relation": {"name": "subscriber_relation", "description": "Relationship to the policy holder (self, spouse, dependent, etc)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "Patient's street address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "Patient's city of address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "State the patient lives in (most recent known address)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "Zip code the patient lives in (most recent known address).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "phone": {"name": "phone", "description": "Patient's phone number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.1157482, "relation_name": "tuva.input_layer.eligibility", "raw_code": "select\n patient_id\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , subscriber_relation\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom {{ ref('eligibility_seed') }}", "language": "sql", "refs": [{"name": "eligibility_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.eligibility_seed"]}, "compiled_path": "../target/compiled/input_layer/models/eligibility.sql", "compiled": true, "compiled_code": "select\n patient_id\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , subscriber_relation\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom cms_synthetic._tuva_synthetic.eligibility_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.medical_claim": {"database": "tuva", "schema": "input_layer", "name": "medical_claim", "resource_type": "model", "package_name": "input_layer", "path": "medical_claim.sql", "original_file_path": "models/medical_claim.sql", "unique_id": "model.input_layer.medical_claim", "fqn": ["input_layer", "medical_claim"], "alias": "medical_claim", "checksum": {"name": "sha256", "checksum": "eed0bcdf3d1c5ae30316df2a2bf7b67c1710ee7594cd305d1bd420dcd18dd8f5"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The medical_claim table contains information on healthcare services and supplies provided to patients, billed by providers, and paid for by health insurers. It includes information on the provider who rendered the service, the amount paid for the service by the health insurer, and the underlying reason for the service (i.e. diagnosis).\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__claim_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "Start date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_start_date": {"name": "claim_line_start_date", "description": "Start date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_end_date": {"name": "claim_line_end_date", "description": "End date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "Admission date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Discharge date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Place of service for the claim (professional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__place_of_service.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__bill_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code for the claim line (institutional only and typically multiple codes per claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__revenue_center.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_unit_quantity": {"name": "service_unit_quantity", "description": "The number of units for the particular revenue center code.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "HCPCS level 1 or level 2 code for the claim line.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "1st modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "2nd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "3rd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "4th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "5th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_npi": {"name": "rendering_npi", "description": "Rendering NPI for the claim (typically represents the physician or entity providing services).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_tin": {"name": "rendering_tin", "description": "Rendering provider tax identification number (TIN).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_npi": {"name": "billing_npi", "description": "Billing NPI for the claim (typically represents organization billing the claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_tin": {"name": "billing_tin", "description": "Billing provider tax identification number (TIN).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid on the claim by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient) on the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount paid by the patient that applies towards their deductible.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_cost_amount": {"name": "total_cost_amount", "description": "The total amount paid on the claim by different parties.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_type": {"name": "diagnosis_code_type", "description": "Indicates the type of diagnosis code (e.g. ICD-10-CM).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_1": {"name": "diagnosis_code_1", "description": "1st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_2": {"name": "diagnosis_code_2", "description": "2nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_3": {"name": "diagnosis_code_3", "description": "3rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_4": {"name": "diagnosis_code_4", "description": "4th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_5": {"name": "diagnosis_code_5", "description": "5th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_6": {"name": "diagnosis_code_6", "description": "6th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_7": {"name": "diagnosis_code_7", "description": "7th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_8": {"name": "diagnosis_code_8", "description": "8th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_9": {"name": "diagnosis_code_9", "description": "9th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_10": {"name": "diagnosis_code_10", "description": "10th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_11": {"name": "diagnosis_code_11", "description": "11th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_12": {"name": "diagnosis_code_12", "description": "12th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_13": {"name": "diagnosis_code_13", "description": "13th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_14": {"name": "diagnosis_code_14", "description": "14th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_15": {"name": "diagnosis_code_15", "description": "15th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_16": {"name": "diagnosis_code_16", "description": "16th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_17": {"name": "diagnosis_code_17", "description": "17th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_18": {"name": "diagnosis_code_18", "description": "18th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_19": {"name": "diagnosis_code_19", "description": "19th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_20": {"name": "diagnosis_code_20", "description": "20th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_21": {"name": "diagnosis_code_21", "description": "21st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_22": {"name": "diagnosis_code_22", "description": "22nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_23": {"name": "diagnosis_code_23", "description": "23rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_24": {"name": "diagnosis_code_24", "description": "24th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_25": {"name": "diagnosis_code_25", "description": "25th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_1": {"name": "diagnosis_poa_1", "description": "Present on admission code for the 1st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_2": {"name": "diagnosis_poa_2", "description": "Present on admission code for the 2nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_3": {"name": "diagnosis_poa_3", "description": "Present on admission code for the 3rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_4": {"name": "diagnosis_poa_4", "description": "Present on admission code for the 4th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_5": {"name": "diagnosis_poa_5", "description": "Present on admission code for the 5th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_6": {"name": "diagnosis_poa_6", "description": "Present on admission code for the 6th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_7": {"name": "diagnosis_poa_7", "description": "Present on admission code for the 7th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_8": {"name": "diagnosis_poa_8", "description": "Present on admission code for the 8th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_9": {"name": "diagnosis_poa_9", "description": "Present on admission code for the 9th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_10": {"name": "diagnosis_poa_10", "description": "Present on admission code for the 10th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_11": {"name": "diagnosis_poa_11", "description": "Present on admission code for the 11th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_12": {"name": "diagnosis_poa_12", "description": "Present on admission code for the 12th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_13": {"name": "diagnosis_poa_13", "description": "Present on admission code for the 13th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_14": {"name": "diagnosis_poa_14", "description": "Present on admission code for the 14th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_15": {"name": "diagnosis_poa_15", "description": "Present on admission code for the 15th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_16": {"name": "diagnosis_poa_16", "description": "Present on admission code for the 16th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_17": {"name": "diagnosis_poa_17", "description": "Present on admission code for the 17th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_18": {"name": "diagnosis_poa_18", "description": "Present on admission code for the 18th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_19": {"name": "diagnosis_poa_19", "description": "Present on admission code for the 19th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_20": {"name": "diagnosis_poa_20", "description": "Present on admission code for the 20th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_21": {"name": "diagnosis_poa_21", "description": "Present on admission code for the 21st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_22": {"name": "diagnosis_poa_22", "description": "Present on admission code for the 22nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_23": {"name": "diagnosis_poa_23", "description": "Present on admission code for the 23rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_24": {"name": "diagnosis_poa_24", "description": "Present on admission code for the 24th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_25": {"name": "diagnosis_poa_25", "description": "Present on admission code for the 25th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_type": {"name": "procedure_code_type", "description": "Indicates the type of procedure code (e.g. ICD-10-PCS).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_1": {"name": "procedure_code_1", "description": "1st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_2": {"name": "procedure_code_2", "description": "2nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_3": {"name": "procedure_code_3", "description": "3rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_4": {"name": "procedure_code_4", "description": "4th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_5": {"name": "procedure_code_5", "description": "5th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_6": {"name": "procedure_code_6", "description": "6th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_7": {"name": "procedure_code_7", "description": "7th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_8": {"name": "procedure_code_8", "description": "8th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_9": {"name": "procedure_code_9", "description": "9th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_10": {"name": "procedure_code_10", "description": "10th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_11": {"name": "procedure_code_11", "description": "11th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_12": {"name": "procedure_code_12", "description": "12th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_13": {"name": "procedure_code_13", "description": "13th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_14": {"name": "procedure_code_14", "description": "14th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_15": {"name": "procedure_code_15", "description": "15th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_16": {"name": "procedure_code_16", "description": "16th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_17": {"name": "procedure_code_17", "description": "17th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_18": {"name": "procedure_code_18", "description": "18th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_19": {"name": "procedure_code_19", "description": "19th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_20": {"name": "procedure_code_20", "description": "20th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_21": {"name": "procedure_code_21", "description": "21st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_22": {"name": "procedure_code_22", "description": "22nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_23": {"name": "procedure_code_23", "description": "23rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_24": {"name": "procedure_code_24", "description": "24th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_25": {"name": "procedure_code_25", "description": "25th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_1": {"name": "procedure_date_1", "description": "Date of the 1st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_2": {"name": "procedure_date_2", "description": "Date of the 2nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_3": {"name": "procedure_date_3", "description": "Date of the 3rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_4": {"name": "procedure_date_4", "description": "Date of the 4th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_5": {"name": "procedure_date_5", "description": "Date of the 5th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_6": {"name": "procedure_date_6", "description": "Date of the 6th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_7": {"name": "procedure_date_7", "description": "Date of the 7th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_8": {"name": "procedure_date_8", "description": "Date of the 8th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_9": {"name": "procedure_date_9", "description": "Date of the 9th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_10": {"name": "procedure_date_10", "description": "Date of the 10th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_11": {"name": "procedure_date_11", "description": "Date of the 11th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_12": {"name": "procedure_date_12", "description": "Date of the 12th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_13": {"name": "procedure_date_13", "description": "Date of the 13th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_14": {"name": "procedure_date_14", "description": "Date of the 14th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_15": {"name": "procedure_date_15", "description": "Date of the 15th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_16": {"name": "procedure_date_16", "description": "Date of the 16th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_17": {"name": "procedure_date_17", "description": "Date of the 17th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_18": {"name": "procedure_date_18", "description": "Date of the 18th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_19": {"name": "procedure_date_19", "description": "Date of the 19th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_20": {"name": "procedure_date_20", "description": "Date of the 20th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_21": {"name": "procedure_date_21", "description": "Date of the 21st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_22": {"name": "procedure_date_22", "description": "Date of the 22nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_23": {"name": "procedure_date_23", "description": "Date of the 23rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_24": {"name": "procedure_date_24", "description": "Date of the 24th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_25": {"name": "procedure_date_25", "description": "Date of the 25th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.142435, "relation_name": "tuva.input_layer.medical_claim", "raw_code": "select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom {{ ref('medical_claim_seed') }}", "language": "sql", "refs": [{"name": "medical_claim_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.medical_claim_seed"]}, "compiled_path": "../target/compiled/input_layer/models/medical_claim.sql", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom cms_synthetic._tuva_synthetic.medical_claim_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.pharmacy_claim": {"database": "tuva", "schema": "input_layer", "name": "pharmacy_claim", "resource_type": "model", "package_name": "input_layer", "path": "pharmacy_claim.sql", "original_file_path": "models/pharmacy_claim.sql", "unique_id": "model.input_layer.pharmacy_claim", "fqn": ["input_layer", "pharmacy_claim"], "alias": "pharmacy_claim", "checksum": {"name": "sha256", "checksum": "09117829aa51c57d9bd0d6524b08b5433b8a74481fc832fe10272ce1aa33512d"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The pharmacy_claim table includes information about retail and specialty drug prescriptions that have been filled by a patient, billed by a pharmacy, and paid by an insurer.\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_npi": {"name": "prescribing_provider_npi", "description": "NPI for the provider that wrote the prescription (e.g. priamry care physician).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_npi": {"name": "dispensing_provider_npi", "description": "NPI for the provider that dispensed the prescription (e.g. pharmacy).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "Number of doses.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days supply.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the prescription.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "Date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid by the health insurer for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "Contractual amount allowed to be paid by the payer + patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the claim by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.1450932, "relation_name": "tuva.input_layer.pharmacy_claim", "raw_code": "select\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom {{ ref('pharmacy_claim_seed') }}", "language": "sql", "refs": [{"name": "pharmacy_claim_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.pharmacy_claim_seed"]}, "compiled_path": "../target/compiled/input_layer/models/pharmacy_claim.sql", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom cms_synthetic._tuva_synthetic.pharmacy_claim_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.location": {"database": "tuva", "schema": "input_layer", "name": "location", "resource_type": "model", "package_name": "input_layer", "path": "location.sql", "original_file_path": "models/location.sql", "unique_id": "model.input_layer.location", "fqn": ["input_layer", "location"], "alias": "location", "checksum": {"name": "sha256", "checksum": "01f44a45e8baed679a64b680ac3d5088fc337a3ace99b0026cb7c197fc3a8a50"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The location table contains information on practice and facility locations where patients receive medical care.\n", "columns": {"location_id": {"name": "location_id", "description": "Unique identifier for each location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "The national provider identifier associated with the location e.g. facility_npi.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "name": {"name": "name", "description": "The name of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_organization": {"name": "parent_organization", "description": "The parent organization associated with the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The street address of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.163383, "relation_name": "tuva.input_layer.location", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as location_id\n , cast(null as {{ dbt.type_string() }} ) as npi\n , cast(null as {{ dbt.type_string() }} ) as name\n , cast(null as {{ dbt.type_string() }} ) as facility_type\n , cast(null as {{ dbt.type_string() }} ) as parent_organization\n , cast(null as {{ dbt.type_string() }} ) as address\n , cast(null as {{ dbt.type_string() }} ) as city\n , cast(null as {{ dbt.type_string() }} ) as state\n , cast(null as {{ dbt.type_string() }} ) as zip_code\n , cast(null as {{ dbt.type_float() }} ) as latitude\n , cast(null as {{ dbt.type_float() }} ) as longitude\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/location.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as location_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(null as TEXT ) as parent_organization\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.patient": {"database": "tuva", "schema": "input_layer", "name": "patient", "resource_type": "model", "package_name": "input_layer", "path": "patient.sql", "original_file_path": "models/patient.sql", "unique_id": "model.input_layer.patient", "fqn": ["input_layer", "patient"], "alias": "patient", "checksum": {"name": "sha256", "checksum": "b81f3eda96abdf0a48064185544be663f98c5a428de46e7ef9e6cbf5ea7badc2"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The patient table contains demographic and geographic information on patients.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each person across all datasets.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "The first name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "The last name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "The death date of the patient if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "A flag indicating if the patient has died.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "Patient's social security number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The address of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city where the patient lives.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state where the patient lives.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "county": {"name": "county", "description": "The county for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.169825, "relation_name": "tuva.input_layer.patient", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as first_name\n , cast(null as {{ dbt.type_string() }} ) as last_name\n , cast(null as {{ dbt.type_string() }} ) as sex\n , cast(null as {{ dbt.type_string() }} ) as race\n , cast(null as date) as birth_date\n , cast(null as date) as death_date\n , cast(null as {{ dbt.type_int() }} ) as death_flag\n , cast(null as {{ dbt.type_string() }} ) as social_security_number\n , cast(null as {{ dbt.type_string() }} ) as address\n , cast(null as {{ dbt.type_string() }} ) as city\n , cast(null as {{ dbt.type_string() }} ) as state\n , cast(null as {{ dbt.type_string() }} ) as zip_code\n , cast(null as {{ dbt.type_string() }} ) as county\n , cast(null as {{ dbt.type_float() }} ) as latitude\n , cast(null as {{ dbt.type_float() }} ) as longitude\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/patient.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as sex\n , cast(null as TEXT ) as race\n , cast(null as date) as birth_date\n , cast(null as date) as death_date\n , cast(null as integer ) as death_flag\n , cast(null as TEXT ) as social_security_number\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as TEXT ) as county\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.condition": {"database": "tuva", "schema": "input_layer", "name": "condition", "resource_type": "model", "package_name": "input_layer", "path": "condition.sql", "original_file_path": "models/condition.sql", "unique_id": "model.input_layer.condition", "fqn": ["input_layer", "condition"], "alias": "condition", "checksum": {"name": "sha256", "checksum": "ffe250f1283830a4b9c985b93aa12da0eaaad5257ce8697c6cb5923a0d36fb89"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The condition table contains information related to medical conditions patients have, including problems, admitting diagnosis codes, and billable diagnosis codes.\n", "columns": {"condition_id": {"name": "condition_id", "description": "Unique identifier for each condition in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date when the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "onset_date": {"name": "onset_date", "description": "Date when the condition first occurred.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "resolved_date": {"name": "resolved_date", "description": "Date when the condition was resolved.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of the condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition i.e. problem, admitting, or billing.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The condition code in the source system e.g. the ICD-10 code.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the condition code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of condition code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized condition code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "The numerical ranking of a diagnosis code in a claim. Principle diagnosis code is given a ranking of 1. Claims data typically has a strict ranking of conditions whereas medical records will often not have this information or the information won't be accurate.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "present_on_admit_code": {"name": "present_on_admit_code", "description": "The present_on_admit_code related to the condition.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "present_on_admit_description": {"name": "present_on_admit_description", "description": "The description of the present_on_admit_code for the condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.1532102, "relation_name": "tuva.input_layer.condition", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as condition_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as claim_id\n , cast(null as date) as recorded_date\n , cast(null as date) as onset_date\n , cast(null as date) as resolved_date\n , cast(null as {{ dbt.type_string() }} ) as status\n , cast(null as {{ dbt.type_string() }} ) as condition_type\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\n , cast(null as {{ dbt.type_int() }} ) as condition_rank\n , cast(null as {{ dbt.type_string() }} ) as present_on_admit_code\n , cast(null as {{ dbt.type_string() }} ) as present_on_admit_description\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/condition.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as condition_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as recorded_date\n , cast(null as date) as onset_date\n , cast(null as date) as resolved_date\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as condition_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as integer ) as condition_rank\n , cast(null as TEXT ) as present_on_admit_code\n , cast(null as TEXT ) as present_on_admit_description\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.medication": {"database": "tuva", "schema": "input_layer", "name": "medication", "resource_type": "model", "package_name": "input_layer", "path": "medication.sql", "original_file_path": "models/medication.sql", "unique_id": "model.input_layer.medication", "fqn": ["input_layer", "medication"], "alias": "medication", "checksum": {"name": "sha256", "checksum": "a266e27a6cdbcfb6ab4a48a0a9d1b47c07d691b67d1555839ee622da4b6408aa"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The medication table contains information on medications ordered and/or administered during a patient encounter.\n", "columns": {"medication_id": {"name": "medication_id", "description": "Unique identifier for each medication in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_date": {"name": "prescribing_date", "description": "Date the medication was prescribed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The source code type of the medication.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The source code for the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "The source description of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code associated with the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description for the NDC.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "RxNorm code associated with the medication.", "meta": {"terminology": "https://www.nlm.nih.gov/research/umls/rxnorm/index.html"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "Description for the RxNorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_code": {"name": "atc_code", "description": "ATC code for the medication.", "meta": {"terminology": "https://www.who.int/tools/atc-ddd-toolkit/atc-classification"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_description": {"name": "atc_description", "description": "Description for the ATC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "route": {"name": "route", "description": "The route used to administer the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "strength": {"name": "strength", "description": "The strength of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "The quantity of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity_unit": {"name": "quantity_unit", "description": "The units for the quantity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "The number of days supply included.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner who ordered the medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer"}, "created_at": 1729623957.16664, "relation_name": "tuva.input_layer.medication", "raw_code": "select \n cast(null as {{ dbt.type_string() }} ) as medication_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as date) as dispensing_date\n , cast(null as date) as prescribing_date\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_string() }} ) as ndc_description\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_description\n , cast(null as {{ dbt.type_string() }} ) as atc_code\n , cast(null as {{ dbt.type_string() }} ) as atc_description\n , cast(null as {{ dbt.type_string() }} ) as route\n , cast(null as {{ dbt.type_string() }} ) as strength\n , cast(null as {{ dbt.type_int() }} ) as quantity\n , cast(null as {{ dbt.type_string() }} ) as quantity_unit\n , cast(null as {{ dbt.type_int() }} ) as days_supply\n , cast(null as {{ dbt.type_string() }} ) as practitioner_id\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/medication.sql", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as medication_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as date) as dispensing_date\n , cast(null as date) as prescribing_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as ndc_code\n , cast(null as TEXT ) as ndc_description\n , cast(null as TEXT ) as rxnorm_code\n , cast(null as TEXT ) as rxnorm_description\n , cast(null as TEXT ) as atc_code\n , cast(null as TEXT ) as atc_description\n , cast(null as TEXT ) as route\n , cast(null as TEXT ) as strength\n , cast(null as integer ) as quantity\n , cast(null as TEXT ) as quantity_unit\n , cast(null as integer ) as days_supply\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.observation": {"database": "tuva", "schema": "input_layer", "name": "observation", "resource_type": "model", "package_name": "input_layer", "path": "observation.sql", "original_file_path": "models/observation.sql", "unique_id": "model.input_layer.observation", "fqn": ["input_layer", "observation"], "alias": "observation", "checksum": {"name": "sha256", "checksum": "0716becd14292298a880637a162143292dfe4a5d197bfabf481c996a5443090a"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The observation table contains information on measurements other than lab tests e.g. blood pressure, height, and weight.\n", "columns": {"observation_id": {"name": "observation_id", "description": "Unique identifier for each observation in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "panel_id": {"name": "panel_id", "description": "Unique identifier for the panel.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "Date the observation was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_type": {"name": "observation_type", "description": "Type of observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "Source code type of the observation.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "Source code of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Source description of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "Normalized code type of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "Normalized code of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the observatino.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.168515, "relation_name": "tuva.input_layer.observation", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as observation_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as panel_id\n , cast(null as date) as observation_date\n , cast(null as {{ dbt.type_string() }} ) as observation_type\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\n , cast(null as {{ dbt.type_string() }} ) as result\n , cast(null as {{ dbt.type_string() }} ) as source_units\n , cast(null as {{ dbt.type_string() }} ) as normalized_units\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_low\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_high\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_low\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_high\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/observation.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as observation_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as panel_id\n , cast(null as date) as observation_date\n , cast(null as TEXT ) as observation_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as result\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.lab_result": {"database": "tuva", "schema": "input_layer", "name": "lab_result", "resource_type": "model", "package_name": "input_layer", "path": "lab_result.sql", "original_file_path": "models/lab_result.sql", "unique_id": "model.input_layer.lab_result", "fqn": ["input_layer", "lab_result"], "alias": "lab_result", "checksum": {"name": "sha256", "checksum": "393186514e3eeb0274df957ca9f0aedc157df399bf15ac00bbac35b4b608b66c"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The lab result table contains information about lab test results, including the LOINC code and description, units, reference range, and result.\n", "columns": {"lab_result_id": {"name": "lab_result_id", "description": "Unique identifier for the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter. Included in this table if the lab test can be linked to an encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "accession_number": {"name": "accession_number", "description": "The lab order number from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The code type from the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code for the lab from the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "The description for the lab test from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_component": {"name": "source_component", "description": "The description for the component of the test from the source system.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized code type.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code e.g. LOINC.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "The normalized description for the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_component": {"name": "normalized_component", "description": "The normalized component.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "The status of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "collection_date": {"name": "collection_date", "description": "Date the test was collected.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_abnormal_flag": {"name": "source_abnormal_flag", "description": "Indicates whether the result is abnormal or normal.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_abnormal_flag": {"name": "normalized_abnormal_flag", "description": "Normalized abnormal flag.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specimen": {"name": "specimen", "description": "The type of specimen e.g. blood, plasma, urine.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ordering_practitioner_id": {"name": "ordering_practitioner_id", "description": "Unique identifier for the practitioner who ordered the lab test.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models/_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729623957.161124, "relation_name": "tuva.input_layer.lab_result", "raw_code": "select\n cast(null as {{ dbt.type_string() }} ) as lab_result_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as accession_number\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(null as {{ dbt.type_string() }} ) as source_component\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\n , cast(null as {{ dbt.type_string() }} ) as normalized_component\n , cast(null as {{ dbt.type_string() }} ) as status\n , cast(null as {{ dbt.type_string() }} ) as result\n , cast(null as date) as result_date\n , cast(null as date) as collection_date\n , cast(null as {{ dbt.type_string() }} ) as source_units\n , cast(null as {{ dbt.type_string() }} ) as normalized_units\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_low\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_high\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_low\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_high\n , cast(null as {{ dbt.type_int() }} ) as source_abnormal_flag\n , cast(null as {{ dbt.type_int() }} ) as normalized_abnormal_flag\n , cast(null as {{ dbt.type_string() }} ) as specimen\n , cast(null as {{ dbt.type_string() }} ) as ordering_practitioner_id\n , cast(null as {{ dbt.type_string() }} ) as data_source\n , cast(null as {{ dbt.type_string() }} ) as file_name\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "../target/compiled/input_layer/models/lab_result.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as lab_result_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as accession_number\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as source_component\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as normalized_component\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as result\n , cast(null as date) as result_date\n , cast(null as date) as collection_date\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as integer ) as source_abnormal_flag\n , cast(null as integer ) as normalized_abnormal_flag\n , cast(null as TEXT ) as specimen\n , cast(null as TEXT ) as ordering_practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "seed.input_layer.eligibility_seed": {"database": "cms_synthetic", "schema": "_tuva_synthetic", "name": "eligibility_seed", "resource_type": "seed", "package_name": "input_layer", "path": "eligibility_seed.csv", "original_file_path": "../seeds/eligibility_seed.csv", "unique_id": "seed.input_layer.eligibility_seed", "fqn": ["input_layer", "eligibility_seed"], "alias": "eligibility_seed", "checksum": {"name": "sha256", "checksum": "6ed27e28eb51135fe699e911c94b3c014822bd68036fd2b0b039a36f22a569af"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"patient_id": "varchar(255)", "member_id": "varchar(255)", "subscriber_id": "varchar(255)", "gender": "varchar(255)", "race": "varchar(255)", "birth_date": "date", "death_date": "date", "death_flag": "integer", "enrollment_start_date": "date", "enrollment_end_date": "date", "payer": "varchar(255)", "payer_type": "varchar(255)", "plan": "varchar(255)", "original_reason_entitlement_code": "varchar(255)", "dual_status_code": "varchar(255)", "medicare_status_code": "varchar(255)", "first_name": "varchar(255)", "last_name": "varchar(255)", "social_security_number": "varchar(255)", "subscriber_relation": "varchar(255)", "address": "varchar(255)", "city": "varchar(255)", "state": "varchar(255)", "zip_code": "varchar(255)", "phone": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds/_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"patient_id": "varchar(255)", "member_id": "varchar(255)", "subscriber_id": "varchar(255)", "gender": "varchar(255)", "race": "varchar(255)", "birth_date": "date", "death_date": "date", "death_flag": "integer", "enrollment_start_date": "date", "enrollment_end_date": "date", "payer": "varchar(255)", "payer_type": "varchar(255)", "plan": "varchar(255)", "original_reason_entitlement_code": "varchar(255)", "dual_status_code": "varchar(255)", "medicare_status_code": "varchar(255)", "first_name": "varchar(255)", "last_name": "varchar(255)", "social_security_number": "varchar(255)", "subscriber_relation": "varchar(255)", "address": "varchar(255)", "city": "varchar(255)", "state": "varchar(255)", "zip_code": "varchar(255)", "phone": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729623957.0079648, "relation_name": "cms_synthetic._tuva_synthetic.eligibility_seed", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.medical_claim_seed": {"database": "cms_synthetic", "schema": "_tuva_synthetic", "name": "medical_claim_seed", "resource_type": "seed", "package_name": "input_layer", "path": "medical_claim_seed.csv", "original_file_path": "../seeds/medical_claim_seed.csv", "unique_id": "seed.input_layer.medical_claim_seed", "fqn": ["input_layer", "medical_claim_seed"], "alias": "medical_claim_seed", "checksum": {"name": "sha256", "checksum": "5327a9e9aec0c0d566781bce1dd560e4d58ee279e433b135aef1643011eba304"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "claim_type": "varchar(255)", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "claim_start_date": "date", "claim_end_date": "date", "claim_line_start_date": "date", "claim_line_end_date": "date", "admission_date": "date", "discharge_date": "date", "admit_source_code": "varchar(255)", "admit_type_code": "varchar(255)", "discharge_disposition_code": "varchar(255)", "place_of_service_code": "varchar(255)", "bill_type_code": "varchar(255)", "ms_drg_code": "varchar(255)", "apr_drg_code": "varchar(255)", "revenue_center_code": "varchar(255)", "service_unit_quantity": "integer", "hcpcs_code": "varchar(255)", "hcpcs_modifier_1": "varchar(255)", "hcpcs_modifier_2": "varchar(255)", "hcpcs_modifier_3": "varchar(255)", "hcpcs_modifier_4": "varchar(255)", "hcpcs_modifier_5": "varchar(255)", "rendering_npi": "varchar(255)", "billing_npi": "varchar(255)", "facility_npi": "varchar(255)", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "coinsurance_amount": "float", "copayment_amount": "float", "deductible_amount": "float", "total_cost_amount": "float", "diagnosis_code_type": "varchar(255)", "diagnosis_code_1": "varchar(255)", "diagnosis_code_2": "varchar(255)", "diagnosis_code_3": "varchar(255)", "diagnosis_code_4": "varchar(255)", "diagnosis_code_5": "varchar(255)", "diagnosis_code_6": "varchar(255)", "diagnosis_code_7": "varchar(255)", "diagnosis_code_8": "varchar(255)", "diagnosis_code_9": "varchar(255)", "diagnosis_code_10": "varchar(255)", "diagnosis_code_11": "varchar(255)", "diagnosis_code_12": "varchar(255)", "diagnosis_code_13": "varchar(255)", "diagnosis_code_14": "varchar(255)", "diagnosis_code_15": "varchar(255)", "diagnosis_code_16": "varchar(255)", "diagnosis_code_17": "varchar(255)", "diagnosis_code_18": "varchar(255)", "diagnosis_code_19": "varchar(255)", "diagnosis_code_20": "varchar(255)", "diagnosis_code_21": "varchar(255)", "diagnosis_code_22": "varchar(255)", "diagnosis_code_23": "varchar(255)", "diagnosis_code_24": "varchar(255)", "diagnosis_code_25": "varchar(255)", "diagnosis_poa_1": "varchar(255)", "diagnosis_poa_2": "varchar(255)", "diagnosis_poa_3": "varchar(255)", "diagnosis_poa_4": "varchar(255)", "diagnosis_poa_5": "varchar(255)", "diagnosis_poa_6": "varchar(255)", "diagnosis_poa_7": "varchar(255)", "diagnosis_poa_8": "varchar(255)", "diagnosis_poa_9": "varchar(255)", "diagnosis_poa_10": "varchar(255)", "diagnosis_poa_11": "varchar(255)", "diagnosis_poa_12": "varchar(255)", "diagnosis_poa_13": "varchar(255)", "diagnosis_poa_14": "varchar(255)", "diagnosis_poa_15": "varchar(255)", "diagnosis_poa_16": "varchar(255)", "diagnosis_poa_17": "varchar(255)", "diagnosis_poa_18": "varchar(255)", "diagnosis_poa_19": "varchar(255)", "diagnosis_poa_20": "varchar(255)", "diagnosis_poa_21": "varchar(255)", "diagnosis_poa_22": "varchar(255)", "diagnosis_poa_23": "varchar(255)", "diagnosis_poa_24": "varchar(255)", "diagnosis_poa_25": "varchar(255)", "procedure_code_type": "varchar(255)", "procedure_code_1": "varchar(255)", "procedure_code_2": "varchar(255)", "procedure_code_3": "varchar(255)", "procedure_code_4": "varchar(255)", "procedure_code_5": "varchar(255)", "procedure_code_6": "varchar(255)", "procedure_code_7": "varchar(255)", "procedure_code_8": "varchar(255)", "procedure_code_9": "varchar(255)", "procedure_code_10": "varchar(255)", "procedure_code_11": "varchar(255)", "procedure_code_12": "varchar(255)", "procedure_code_13": "varchar(255)", "procedure_code_14": "varchar(255)", "procedure_code_15": "varchar(255)", "procedure_code_16": "varchar(255)", "procedure_code_17": "varchar(255)", "procedure_code_18": "varchar(255)", "procedure_code_19": "varchar(255)", "procedure_code_20": "varchar(255)", "procedure_code_21": "varchar(255)", "procedure_code_22": "varchar(255)", "procedure_code_23": "varchar(255)", "procedure_code_24": "varchar(255)", "procedure_code_25": "varchar(255)", "procedure_date_1": "date", "procedure_date_2": "date", "procedure_date_3": "date", "procedure_date_4": "date", "procedure_date_5": "date", "procedure_date_6": "date", "procedure_date_7": "date", "procedure_date_8": "date", "procedure_date_9": "date", "procedure_date_10": "date", "procedure_date_11": "date", "procedure_date_12": "date", "procedure_date_13": "date", "procedure_date_14": "date", "procedure_date_15": "date", "procedure_date_16": "date", "procedure_date_17": "date", "procedure_date_18": "date", "procedure_date_19": "date", "procedure_date_20": "date", "procedure_date_21": "date", "procedure_date_22": "date", "procedure_date_23": "date", "procedure_date_24": "date", "procedure_date_25": "date", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds/_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "claim_type": "varchar(255)", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "claim_start_date": "date", "claim_end_date": "date", "claim_line_start_date": "date", "claim_line_end_date": "date", "admission_date": "date", "discharge_date": "date", "admit_source_code": "varchar(255)", "admit_type_code": "varchar(255)", "discharge_disposition_code": "varchar(255)", "place_of_service_code": "varchar(255)", "bill_type_code": "varchar(255)", "ms_drg_code": "varchar(255)", "apr_drg_code": "varchar(255)", "revenue_center_code": "varchar(255)", "service_unit_quantity": "integer", "hcpcs_code": "varchar(255)", "hcpcs_modifier_1": "varchar(255)", "hcpcs_modifier_2": "varchar(255)", "hcpcs_modifier_3": "varchar(255)", "hcpcs_modifier_4": "varchar(255)", "hcpcs_modifier_5": "varchar(255)", "rendering_npi": "varchar(255)", "billing_npi": "varchar(255)", "facility_npi": "varchar(255)", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "coinsurance_amount": "float", "copayment_amount": "float", "deductible_amount": "float", "total_cost_amount": "float", "diagnosis_code_type": "varchar(255)", "diagnosis_code_1": "varchar(255)", "diagnosis_code_2": "varchar(255)", "diagnosis_code_3": "varchar(255)", "diagnosis_code_4": "varchar(255)", "diagnosis_code_5": "varchar(255)", "diagnosis_code_6": "varchar(255)", "diagnosis_code_7": "varchar(255)", "diagnosis_code_8": "varchar(255)", "diagnosis_code_9": "varchar(255)", "diagnosis_code_10": "varchar(255)", "diagnosis_code_11": "varchar(255)", "diagnosis_code_12": "varchar(255)", "diagnosis_code_13": "varchar(255)", "diagnosis_code_14": "varchar(255)", "diagnosis_code_15": "varchar(255)", "diagnosis_code_16": "varchar(255)", "diagnosis_code_17": "varchar(255)", "diagnosis_code_18": "varchar(255)", "diagnosis_code_19": "varchar(255)", "diagnosis_code_20": "varchar(255)", "diagnosis_code_21": "varchar(255)", "diagnosis_code_22": "varchar(255)", "diagnosis_code_23": "varchar(255)", "diagnosis_code_24": "varchar(255)", "diagnosis_code_25": "varchar(255)", "diagnosis_poa_1": "varchar(255)", "diagnosis_poa_2": "varchar(255)", "diagnosis_poa_3": "varchar(255)", "diagnosis_poa_4": "varchar(255)", "diagnosis_poa_5": "varchar(255)", "diagnosis_poa_6": "varchar(255)", "diagnosis_poa_7": "varchar(255)", "diagnosis_poa_8": "varchar(255)", "diagnosis_poa_9": "varchar(255)", "diagnosis_poa_10": "varchar(255)", "diagnosis_poa_11": "varchar(255)", "diagnosis_poa_12": "varchar(255)", "diagnosis_poa_13": "varchar(255)", "diagnosis_poa_14": "varchar(255)", "diagnosis_poa_15": "varchar(255)", "diagnosis_poa_16": "varchar(255)", "diagnosis_poa_17": "varchar(255)", "diagnosis_poa_18": "varchar(255)", "diagnosis_poa_19": "varchar(255)", "diagnosis_poa_20": "varchar(255)", "diagnosis_poa_21": "varchar(255)", "diagnosis_poa_22": "varchar(255)", "diagnosis_poa_23": "varchar(255)", "diagnosis_poa_24": "varchar(255)", "diagnosis_poa_25": "varchar(255)", "procedure_code_type": "varchar(255)", "procedure_code_1": "varchar(255)", "procedure_code_2": "varchar(255)", "procedure_code_3": "varchar(255)", "procedure_code_4": "varchar(255)", "procedure_code_5": "varchar(255)", "procedure_code_6": "varchar(255)", "procedure_code_7": "varchar(255)", "procedure_code_8": "varchar(255)", "procedure_code_9": "varchar(255)", "procedure_code_10": "varchar(255)", "procedure_code_11": "varchar(255)", "procedure_code_12": "varchar(255)", "procedure_code_13": "varchar(255)", "procedure_code_14": "varchar(255)", "procedure_code_15": "varchar(255)", "procedure_code_16": "varchar(255)", "procedure_code_17": "varchar(255)", "procedure_code_18": "varchar(255)", "procedure_code_19": "varchar(255)", "procedure_code_20": "varchar(255)", "procedure_code_21": "varchar(255)", "procedure_code_22": "varchar(255)", "procedure_code_23": "varchar(255)", "procedure_code_24": "varchar(255)", "procedure_code_25": "varchar(255)", "procedure_date_1": "date", "procedure_date_2": "date", "procedure_date_3": "date", "procedure_date_4": "date", "procedure_date_5": "date", "procedure_date_6": "date", "procedure_date_7": "date", "procedure_date_8": "date", "procedure_date_9": "date", "procedure_date_10": "date", "procedure_date_11": "date", "procedure_date_12": "date", "procedure_date_13": "date", "procedure_date_14": "date", "procedure_date_15": "date", "procedure_date_16": "date", "procedure_date_17": "date", "procedure_date_18": "date", "procedure_date_19": "date", "procedure_date_20": "date", "procedure_date_21": "date", "procedure_date_22": "date", "procedure_date_23": "date", "procedure_date_24": "date", "procedure_date_25": "date", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729623957.061281, "relation_name": "cms_synthetic._tuva_synthetic.medical_claim_seed", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.provider_attribution_seed": {"database": "cms_synthetic", "schema": "_tuva_synthetic", "name": "provider_attribution_seed", "resource_type": "seed", "package_name": "input_layer", "path": "provider_attribution_seed.csv", "original_file_path": "../seeds/provider_attribution_seed.csv", "unique_id": "seed.input_layer.provider_attribution_seed", "fqn": ["input_layer", "provider_attribution_seed"], "alias": "provider_attribution_seed", "checksum": {"name": "sha256", "checksum": "9dd1af98dc7f19433c964a593f106ce03a9d54f926963c980241532ef8ff89ec"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"patient_id": "varchar(255)", "year_month": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "data_source": "varchar(255)", "payer_attributed_provider": "varchar(255)", "payer_attributed_provider_practice": "varchar(255)", "payer_attributed_provider_organization": "varchar(255)", "payer_attributed_provider_lob": "varchar(255)", "custom_attributed_provider": "varchar(255)", "custom_attributed_provider_practice": "varchar(255)", "custom_attributed_provider_organization": "varchar(255)", "custom_attributed_provider_lob": "varchar(255)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds/_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"patient_id": "varchar(255)", "year_month": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "data_source": "varchar(255)", "payer_attributed_provider": "varchar(255)", "payer_attributed_provider_practice": "varchar(255)", "payer_attributed_provider_organization": "varchar(255)", "payer_attributed_provider_lob": "varchar(255)", "custom_attributed_provider": "varchar(255)", "custom_attributed_provider_practice": "varchar(255)", "custom_attributed_provider_organization": "varchar(255)", "custom_attributed_provider_lob": "varchar(255)"}}, "created_at": 1729623957.083312, "relation_name": "cms_synthetic._tuva_synthetic.provider_attribution_seed", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.lab_result_seed": {"database": "cms_synthetic", "schema": "_tuva_synthetic", "name": "lab_result_seed", "resource_type": "seed", "package_name": "input_layer", "path": "lab_result_seed.csv", "original_file_path": "../seeds/lab_result_seed.csv", "unique_id": "seed.input_layer.lab_result_seed", "fqn": ["input_layer", "lab_result_seed"], "alias": "lab_result_seed", "checksum": {"name": "sha256", "checksum": "f4a5befc9f192ba40d00a04f01e3782a99032b555f548fa130650f5b4c528d45"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"lab_result_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "accession_number": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "source_component": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "normalized_component": "varchar(255)", "status": "varchar(255)", "result": "varchar(255)", "result_date": "date", "collection_date": "date", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "source_abnormal_flag": "integer", "normalized_abnormal_flag": "integer", "specimen": "varchar(255)", "ordering_practitioner_id": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime", "tuva_last_run": "varchar(255)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds/_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"lab_result_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "accession_number": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "source_component": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "normalized_component": "varchar(255)", "status": "varchar(255)", "result": "varchar(255)", "result_date": "date", "collection_date": "date", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "source_abnormal_flag": "integer", "normalized_abnormal_flag": "integer", "specimen": "varchar(255)", "ordering_practitioner_id": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime", "tuva_last_run": "varchar(255)"}}, "created_at": 1729623957.020511, "relation_name": "cms_synthetic._tuva_synthetic.lab_result_seed", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.observation_seed": {"database": "cms_synthetic", "schema": "_tuva_synthetic", "name": "observation_seed", "resource_type": "seed", "package_name": "input_layer", "path": "observation_seed.csv", "original_file_path": "../seeds/observation_seed.csv", "unique_id": "seed.input_layer.observation_seed", "fqn": ["input_layer", "observation_seed"], "alias": "observation_seed", "checksum": {"name": "sha256", "checksum": "1bf517a342bbe7bcda0a7bec43280155281bbf2e78f605663d0d6a2db730329b"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"observation_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "panel_id": "varchar(255)", "observation_date": "date", "observation_type": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "result": "varchar(255)", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds/_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"observation_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "panel_id": "varchar(255)", "observation_date": "date", "observation_type": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "result": "varchar(255)", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729623957.070716, "relation_name": "cms_synthetic._tuva_synthetic.observation_seed", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.pharmacy_claim_seed": {"database": "cms_synthetic", "schema": "_tuva_synthetic", "name": "pharmacy_claim_seed", "resource_type": "seed", "package_name": "input_layer", "path": "pharmacy_claim_seed.csv", "original_file_path": "../seeds/pharmacy_claim_seed.csv", "unique_id": "seed.input_layer.pharmacy_claim_seed", "fqn": ["input_layer", "pharmacy_claim_seed"], "alias": "pharmacy_claim_seed", "checksum": {"name": "sha256", "checksum": "f45fdfb7b829bb0f73635eddee09d49957d71b16d897a41d9e9ecb0e32e0b0d3"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "prescribing_provider_npi": "varchar(255)", "dispensing_provider_npi": "varchar(255)", "dispensing_date": "date", "ndc_code": "varchar(255)", "quantity": "integer", "days_supply": "integer", "refills": "integer", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds/_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "prescribing_provider_npi": "varchar(255)", "dispensing_provider_npi": "varchar(255)", "dispensing_date": "date", "ndc_code": "varchar(255)", "quantity": "integer", "days_supply": "integer", "refills": "integer", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729623957.0764558, "relation_name": "cms_synthetic._tuva_synthetic.pharmacy_claim_seed", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "depends_on": {"macros": []}}, "model.the_tuva_project.pharmacy__stg_pharmacy_claim": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/staging/pharmacy__stg_pharmacy_claim.sql", "original_file_path": "models/pharmacy/staging/pharmacy__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "fqn": ["the_tuva_project", "pharmacy", "staging", "pharmacy__stg_pharmacy_claim"], "alias": "stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "ca2939d24e585ed3f2fd3e633f25a0da9a65f644faa6ef874d6d408ae5b57bf7"}, "config": {"enabled": true, "alias": "stg_pharmacy_claim", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Staging table for pharmacy claims, serving as the basis for further calculations.", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "stg_pharmacy_claim", "tags": ["pharmacy"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.770984, "relation_name": null, "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom {{ ref('core__pharmacy_claim') }} as p\nleft join {{ ref('terminology__ndc') }} as n \n on p.ndc_code = n.ndc", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/staging/pharmacy__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__brand_generic_opportunity": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__brand_generic_opportunity", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/final/pharmacy__brand_generic_opportunity.sql", "original_file_path": "models/pharmacy/final/pharmacy__brand_generic_opportunity.sql", "unique_id": "model.the_tuva_project.pharmacy__brand_generic_opportunity", "fqn": ["the_tuva_project", "pharmacy", "final", "pharmacy__brand_generic_opportunity"], "alias": "brand_generic_opportunity", "checksum": {"name": "sha256", "checksum": "1a1078199452d43ef3a31d7eed471c581a0548cb7661066b8cabddafb14e3c9d"}, "config": {"enabled": true, "alias": "brand_generic_opportunity", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Table that identifies opportunities for generic substitution in pharmacy claims.\n", "columns": {"data_source": {"name": "data_source", "description": "Source of the data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Line number of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National Drug Code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description of the drug as per NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_rxcui": {"name": "brand_rxcui", "description": "RxNorm Concept Unique Identifier for the brand.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_vs_generic": {"name": "brand_vs_generic", "description": "Indicates whether the drug is a brand or generic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available": {"name": "generic_available", "description": "Indicates if a generic version is available.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid for the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_units": {"name": "total_units", "description": "Total units of the drug dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_cost_per_unit": {"name": "brand_cost_per_unit", "description": "Cost per unit for the branded drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_average_cost_per_unit": {"name": "generic_average_cost_per_unit", "description": "Average cost per unit of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_less_generic_cost_per_unit": {"name": "brand_less_generic_cost_per_unit", "description": "Difference between the cost per unit of the brand and the average cost per unit of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available_total_opportunity": {"name": "generic_available_total_opportunity", "description": "Total potential savings from substituting with generics, where applicable, based on units multiplied by cost difference per unit.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "brand_generic_opportunity", "tags": ["pharmacy"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.753058, "relation_name": "cms_synthetic.pharmacy.brand_generic_opportunity", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n/* claimid/line/source grain. calculates opportunity at line level*/\n\nwith cpu as (\nselect claim_id\n,claim_line_number\n,data_source\n,case when quantity > 0 then paid_amount/quantity else null end as brand_cost_per_unit\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }}\n)\n\n\nselect \n pc.data_source\n , pc.claim_id\n , pc.claim_line_number\n , cc.ndc_code\n , cc.ndc_description\n , cc.rxcui as brand_rxcui\n , cc.brand_vs_generic \n , cc.generic_available\n , pc.paid_amount\n , pc.quantity as total_units\n , cpu.brand_cost_per_unit\n , gc.generic_average_cost_per_unit \n , cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit as brand_less_generic_cost_per_unit\n , case \n when cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit > 0 \n then (cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit) * pc.quantity \n else 0 \n end as generic_available_total_opportunity\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }} as pc\ninner join cpu on pc.claim_id = cpu.claim_id\n and\n pc.claim_line_number = cpu.claim_line_number\n and\n pc.data_source = cpu.data_source\ninner join {{ ref('pharmacy__int_claims_current_cost') }} cc\n on cc.ndc_code = pc.ndc_code\n and\n cc.data_source = pc.data_source\ninner join {{ ref('pharmacy__int_generic_cost') }} as gc \n on cc.rxcui = gc.brand_rxcui\n and gc.data_source = cc.data_source\nwhere prescribed_atleast_one_generic_history = 1", "language": "sql", "refs": [{"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}, {"name": "pharmacy__int_generic_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__stg_pharmacy_claim", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__int_generic_cost"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/final/pharmacy__brand_generic_opportunity.sql", "compiled": true, "compiled_code": "\n\n/* claimid/line/source grain. calculates opportunity at line level*/\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n), cpu as (\nselect claim_id\n,claim_line_number\n,data_source\n,case when quantity > 0 then paid_amount/quantity else null end as brand_cost_per_unit\nfrom __dbt__cte__stg_pharmacy_claim\n)\n\n\nselect \n pc.data_source\n , pc.claim_id\n , pc.claim_line_number\n , cc.ndc_code\n , cc.ndc_description\n , cc.rxcui as brand_rxcui\n , cc.brand_vs_generic \n , cc.generic_available\n , pc.paid_amount\n , pc.quantity as total_units\n , cpu.brand_cost_per_unit\n , gc.generic_average_cost_per_unit \n , cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit as brand_less_generic_cost_per_unit\n , case \n when cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit > 0 \n then (cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit) * pc.quantity \n else 0 \n end as generic_available_total_opportunity\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as pc\ninner join cpu on pc.claim_id = cpu.claim_id\n and\n pc.claim_line_number = cpu.claim_line_number\n and\n pc.data_source = cpu.data_source\ninner join cms_synthetic.pharmacy._int_claims_current_cost cc\n on cc.ndc_code = pc.ndc_code\n and\n cc.data_source = pc.data_source\ninner join cms_synthetic.pharmacy._int_generic_cost as gc \n on cc.rxcui = gc.brand_rxcui\n and gc.data_source = cc.data_source\nwhere prescribed_atleast_one_generic_history = 1", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__generic_available_list": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__generic_available_list", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/final/pharmacy__generic_available_list.sql", "original_file_path": "models/pharmacy/final/pharmacy__generic_available_list.sql", "unique_id": "model.the_tuva_project.pharmacy__generic_available_list", "fqn": ["the_tuva_project", "pharmacy", "final", "pharmacy__generic_available_list"], "alias": "generic_available_list", "checksum": {"name": "sha256", "checksum": "cc04172295a98bc9adf414e323dec62be6ebb39de185e64e37224a62ec37da38"}, "config": {"enabled": true, "alias": "generic_available_list", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Provides a list of pharmacy claims where a generic alternative is available, detailing both brand and potential generic drug costs and descriptions.\n", "columns": {"generic_available_sk": {"name": "generic_available_sk", "description": "Surrogate key for generic availability.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Source of the data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_ndc_code": {"name": "brand_ndc_code", "description": "National Drug Code for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_ndc_description": {"name": "brand_ndc_description", "description": "Description of the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_rxcui": {"name": "brand_rxcui", "description": "RxNorm Concept Unique Identifier for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_paid_amount": {"name": "brand_paid_amount", "description": "Total amount paid for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_units": {"name": "brand_units", "description": "Units of the brand drug dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_paid_per_unit": {"name": "brand_paid_per_unit", "description": "Paid amount per unit for the brand drug, calculated as total paid divided by units, if units are not zero.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_ndc": {"name": "generic_ndc", "description": "National Drug Code for the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_ndc_description": {"name": "generic_ndc_description", "description": "FDA description of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_prescribed_history": {"name": "generic_prescribed_history", "description": "Indicates if a generic version has previously been prescribed, 1 for yes and 0 for no.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_cost_per_unit": {"name": "generic_cost_per_unit", "description": "Cost per unit for the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_cost_at_units": {"name": "generic_cost_at_units", "description": "Cost for the generic drug at the dispensed units of the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "generic_available_list", "tags": ["pharmacy"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.757869, "relation_name": "cms_synthetic.pharmacy.generic_available_list", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith generic_sk as (\n select \n generic_available_sk\n , claim_id\n , claim_line_number\n , data_source\n from {{ ref('pharmacy__pharmacy_claim_expanded') }} as e\n where generic_available_sk is not null\n)\n\nselect \n sk.generic_available_sk\n , p.data_source\n , p.ndc_code as brand_ndc_code\n , p.ndc_description as brand_ndc_description\n , p.rxcui as brand_rxcui\n , p.paid_amount as brand_paid_amount\n , p.quantity as brand_units\n , case \n when p.quantity = 0 \n then 0 \n else p.paid_amount / p.quantity \n end as brand_paid_per_unit\n , ga.ndc as generic_ndc\n , n.fda_description as generic_ndc_description\n , case \n when gc.ndc_code is not null \n then 1 \n else 0 \n end as generic_prescribed_history\n , gc.cost_per_unit as generic_cost_per_unit\n , gc.cost_per_unit * p.quantity as generic_cost_at_units\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }} as p\ninner join generic_sk as sk \n on p.claim_id = sk.claim_id\n and p.claim_line_number = sk.claim_line_number\n and p.data_source = sk.data_source\ninner join {{ ref('pharmacy__int_brand_with_generic_available') }} as b \n on p.rxcui = b.brand_with_generic_available\ninner join {{ ref('pharmacy__rxnorm_generic_available') }} as ga \n on p.rxcui = ga.product_rxcui\n and ga.ndc_product_tty in ('SCD','GPCK')\nleft join {{ ref('terminology__ndc') }} as n \n on ga.ndc = n.ndc\nleft join {{ ref('pharmacy__int_claims_current_cost') }} as gc \n on ga.ndc = gc.ndc_code\n and gc.brand_vs_generic = 'generic'\n and gc.data_source = p.data_source\nwhere \n ga.product_startmarketingdate is not null\n {% if target.type == 'fabric' %}\n and cast(ga.product_startmarketingdate as date) <= GETDATE()\n {% else %}\n and cast(ga.product_startmarketingdate as date) <= current_date\n{% endif %}", "language": "sql", "refs": [{"name": "pharmacy__pharmacy_claim_expanded", "package": null, "version": null}, {"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy__int_brand_with_generic_available", "package": null, "version": null}, {"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "seed.the_tuva_project.terminology__ndc", "model.the_tuva_project.pharmacy__int_claims_current_cost"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/final/pharmacy__generic_available_list.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n), generic_sk as (\n select \n generic_available_sk\n , claim_id\n , claim_line_number\n , data_source\n from cms_synthetic.pharmacy.pharmacy_claim_expanded as e\n where generic_available_sk is not null\n)\n\nselect \n sk.generic_available_sk\n , p.data_source\n , p.ndc_code as brand_ndc_code\n , p.ndc_description as brand_ndc_description\n , p.rxcui as brand_rxcui\n , p.paid_amount as brand_paid_amount\n , p.quantity as brand_units\n , case \n when p.quantity = 0 \n then 0 \n else p.paid_amount / p.quantity \n end as brand_paid_per_unit\n , ga.ndc as generic_ndc\n , n.fda_description as generic_ndc_description\n , case \n when gc.ndc_code is not null \n then 1 \n else 0 \n end as generic_prescribed_history\n , gc.cost_per_unit as generic_cost_per_unit\n , gc.cost_per_unit * p.quantity as generic_cost_at_units\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\ninner join generic_sk as sk \n on p.claim_id = sk.claim_id\n and p.claim_line_number = sk.claim_line_number\n and p.data_source = sk.data_source\ninner join cms_synthetic.pharmacy._int_brand_with_generic_available as b \n on p.rxcui = b.brand_with_generic_available\ninner join cms_synthetic.pharmacy.rxnorm_generic_available as ga \n on p.rxcui = ga.product_rxcui\n and ga.ndc_product_tty in ('SCD','GPCK')\nleft join cms_synthetic.terminology.ndc as n \n on ga.ndc = n.ndc\nleft join cms_synthetic.pharmacy._int_claims_current_cost as gc \n on ga.ndc = gc.ndc_code\n and gc.brand_vs_generic = 'generic'\n and gc.data_source = p.data_source\nwhere \n ga.product_startmarketingdate is not null\n \n and cast(ga.product_startmarketingdate as date) <= current_date\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__pharmacy_claim_expanded", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/final/pharmacy__pharmacy_claim_expanded.sql", "original_file_path": "models/pharmacy/final/pharmacy__pharmacy_claim_expanded.sql", "unique_id": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "fqn": ["the_tuva_project", "pharmacy", "final", "pharmacy__pharmacy_claim_expanded"], "alias": "pharmacy_claim_expanded", "checksum": {"name": "sha256", "checksum": "468debf554309c23e15675d2b2c2d7221425865100fe16b2de5d5d8b281fbeeb"}, "config": {"enabled": true, "alias": "pharmacy_claim_expanded", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Expanded view of pharmacy claims with additional details.\n", "columns": {"data_source": {"name": "data_source", "description": "Source of the data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each pharmacy claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Line number of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Unique identifier for each member.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_id": {"name": "prescribing_provider_id", "description": "ID of the prescribing provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_id": {"name": "dispensing_provider_id", "description": "ID of the dispensing provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date when the drug was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National Drug Code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description of the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "Quantity of the drug dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days the drug supply will last.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "Date when the drug was paid for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid for the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "Total allowed amount covered by insurance.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxcui": {"name": "rxcui", "description": "RxNorm Concept Unique Identifier.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "product_name": {"name": "product_name", "description": "Name of the product.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "product_tty": {"name": "product_tty", "description": "Term type of the product.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_vs_generic": {"name": "brand_vs_generic", "description": "Indicates whether the drug is a brand or generic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_name": {"name": "brand_name", "description": "Name of the brand.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_rxcui": {"name": "generic_rxcui", "description": "RxNorm Concept Unique Identifier for the generic version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_rxcui_description": {"name": "generic_rxcui_description", "description": "Description of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_tty": {"name": "generic_tty", "description": "Term type of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingredient_name": {"name": "ingredient_name", "description": "Active ingredient in the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dose_form_name": {"name": "dose_form_name", "description": "Form of the drug dose.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available": {"name": "generic_available", "description": "Indicates if a generic version is available.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_cost_per_unit": {"name": "brand_cost_per_unit", "description": "Cost per unit for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_average_cost_per_unit": {"name": "generic_average_cost_per_unit", "description": "Average cost per unit of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_less_generic_cost_per_unit": {"name": "brand_less_generic_cost_per_unit", "description": "Difference in cost per unit between the brand and generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available_total_opportunity": {"name": "generic_available_total_opportunity", "description": "Total potential savings from substituting with generics, where applicable, calculated per unit.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available_sk": {"name": "generic_available_sk", "description": "Surrogate key for generic availability data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "pharmacy_claim_expanded", "tags": ["pharmacy"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.763036, "relation_name": "cms_synthetic.pharmacy.pharmacy_claim_expanded", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith all_drugs as (\n select \n p.data_source\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.ndc_code\n , p.ndc_description\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\n , p.paid_amount\n , p.allowed_amount\n , p.rxcui\n , r.product_name\n , r.product_tty\n , r.brand_vs_generic\n , r.brand_name\n , r.clinical_product_rxcui as generic_rxcui\n , r.clinical_product_name as generic_rxcui_description\n , r.clinical_product_tty as generic_tty\n , r.ingredient_name\n , r.dose_form_name\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else r.brand_vs_generic \n end as generic_available\n , opp.brand_cost_per_unit\n , opp.generic_average_cost_per_unit\n , opp.brand_less_generic_cost_per_unit\n , opp.generic_available_total_opportunity\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ ref('pharmacy__stg_pharmacy_claim') }} as p\n left join {{ ref('terminology__rxnorm_brand_generic') }} as r \n on p.rxcui = r.product_rxcui\n left join {{ ref('pharmacy__int_brand_with_generic_available') }} as ga \n on p.rxcui = ga.brand_with_generic_available\n left join {{ ref('pharmacy__brand_generic_opportunity') }} as opp \n on p.claim_id = opp.claim_id\n and p.claim_line_number = opp.claim_line_number\n and p.data_source = opp.data_source\n)\n\n, generic_available as (\n select \n *\n , row_number() over (order by ndc_code, data_source) as generic_available_sk\n from all_drugs\n where generic_available = 'brand_with_generic_available'\n)\n\nselect \n a.data_source\n , a.claim_id\n , a.claim_line_number\n , a.patient_id\n , a.member_id\n , a.prescribing_provider_id\n , a.dispensing_provider_id\n , a.dispensing_date\n , a.ndc_code\n , a.ndc_description\n , a.quantity\n , a.days_supply\n , a.refills\n , a.paid_date\n , a.paid_amount\n , a.allowed_amount\n , a.rxcui\n , a.product_name\n , a.product_tty\n , a.brand_vs_generic\n , a.brand_name\n , a.generic_rxcui\n , a.generic_rxcui_description\n , a.generic_tty\n , a.ingredient_name\n , a.dose_form_name\n , a.generic_available\n , a.brand_cost_per_unit\n , a.generic_average_cost_per_unit\n , a.brand_less_generic_cost_per_unit\n , a.generic_available_total_opportunity\n , g.generic_available_sk\nfrom all_drugs as a\nleft join generic_available as g \n on a.claim_id = g.claim_id\n and a.claim_line_number = g.claim_line_number\n and a.data_source = g.data_source", "language": "sql", "refs": [{"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__rxnorm_brand_generic", "package": null, "version": null}, {"name": "pharmacy__int_brand_with_generic_available", "package": null, "version": null}, {"name": "pharmacy__brand_generic_opportunity", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__brand_generic_opportunity"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/final/pharmacy__pharmacy_claim_expanded.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n), all_drugs as (\n select \n p.data_source\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.ndc_code\n , p.ndc_description\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\n , p.paid_amount\n , p.allowed_amount\n , p.rxcui\n , r.product_name\n , r.product_tty\n , r.brand_vs_generic\n , r.brand_name\n , r.clinical_product_rxcui as generic_rxcui\n , r.clinical_product_name as generic_rxcui_description\n , r.clinical_product_tty as generic_tty\n , r.ingredient_name\n , r.dose_form_name\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else r.brand_vs_generic \n end as generic_available\n , opp.brand_cost_per_unit\n , opp.generic_average_cost_per_unit\n , opp.brand_less_generic_cost_per_unit\n , opp.generic_available_total_opportunity\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from __dbt__cte__stg_pharmacy_claim as p\n left join cms_synthetic.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\n left join cms_synthetic.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\n left join cms_synthetic.pharmacy.brand_generic_opportunity as opp \n on p.claim_id = opp.claim_id\n and p.claim_line_number = opp.claim_line_number\n and p.data_source = opp.data_source\n)\n\n, generic_available as (\n select \n *\n , row_number() over (order by ndc_code, data_source) as generic_available_sk\n from all_drugs\n where generic_available = 'brand_with_generic_available'\n)\n\nselect \n a.data_source\n , a.claim_id\n , a.claim_line_number\n , a.patient_id\n , a.member_id\n , a.prescribing_provider_id\n , a.dispensing_provider_id\n , a.dispensing_date\n , a.ndc_code\n , a.ndc_description\n , a.quantity\n , a.days_supply\n , a.refills\n , a.paid_date\n , a.paid_amount\n , a.allowed_amount\n , a.rxcui\n , a.product_name\n , a.product_tty\n , a.brand_vs_generic\n , a.brand_name\n , a.generic_rxcui\n , a.generic_rxcui_description\n , a.generic_tty\n , a.ingredient_name\n , a.dose_form_name\n , a.generic_available\n , a.brand_cost_per_unit\n , a.generic_average_cost_per_unit\n , a.brand_less_generic_cost_per_unit\n , a.generic_available_total_opportunity\n , g.generic_available_sk\nfrom all_drugs as a\nleft join generic_available as g \n on a.claim_id = g.claim_id\n and a.claim_line_number = g.claim_line_number\n and a.data_source = g.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_claims_current_cost": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__int_claims_current_cost", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/intermediate/pharmacy__int_claims_current_cost.sql", "original_file_path": "models/pharmacy/intermediate/pharmacy__int_claims_current_cost.sql", "unique_id": "model.the_tuva_project.pharmacy__int_claims_current_cost", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_claims_current_cost"], "alias": "_int_claims_current_cost", "checksum": {"name": "sha256", "checksum": "3c0f17d58f2b7c4f56f52d5d97f2af364a57b0d1862ec8eb7f7c8760989d6e8b"}, "config": {"enabled": true, "alias": "_int_claims_current_cost", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view calculating the current cost of claims.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_claims_current_cost", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.7662778, "relation_name": "cms_synthetic.pharmacy._int_claims_current_cost", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n/* All claims, current cost*/\n\nselect \n p.ndc_code\n , p.ndc_description\n , p.data_source\n , p.rxcui\n , r.brand_vs_generic\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end as generic_available\n , sum(paid_amount) as paid_amount\n , count(distinct claim_id) as claim_count\n , sum(paid_amount) / count(distinct claim_id) as cost_per_claim\n , sum(quantity) as total_units\n , case \n when sum(quantity) > 0 \n and sum(paid_amount) > 0 \n then sum(paid_amount) / sum(quantity) \n else null \n end as cost_per_unit\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }} as p\nleft join {{ ref('terminology__rxnorm_brand_generic') }} as r \n on p.rxcui = r.product_rxcui\nleft join {{ ref('pharmacy__int_brand_with_generic_available') }} as ga \n on p.rxcui = ga.brand_with_generic_available\nwhere p.ndc_code is not null\ngroup by \n case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end\n , r.brand_vs_generic\n , p.ndc_code\n , p.rxcui\n , p.ndc_description\n , p.data_source", "language": "sql", "refs": [{"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__rxnorm_brand_generic", "package": null, "version": null}, {"name": "pharmacy__int_brand_with_generic_available", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "model.the_tuva_project.pharmacy__int_brand_with_generic_available"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/intermediate/pharmacy__int_claims_current_cost.sql", "compiled": true, "compiled_code": "\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n) /* All claims, current cost*/\n\nselect \n p.ndc_code\n , p.ndc_description\n , p.data_source\n , p.rxcui\n , r.brand_vs_generic\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end as generic_available\n , sum(paid_amount) as paid_amount\n , count(distinct claim_id) as claim_count\n , sum(paid_amount) / count(distinct claim_id) as cost_per_claim\n , sum(quantity) as total_units\n , case \n when sum(quantity) > 0 \n and sum(paid_amount) > 0 \n then sum(paid_amount) / sum(quantity) \n else null \n end as cost_per_unit\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\nleft join cms_synthetic.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\nleft join cms_synthetic.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\nwhere p.ndc_code is not null\ngroup by \n case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end\n , r.brand_vs_generic\n , p.ndc_code\n , p.rxcui\n , p.ndc_description\n , p.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__int_generic_cost_by_ndc", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/intermediate/pharmacy__int_generic_cost_by_ndc.sql", "original_file_path": "models/pharmacy/intermediate/pharmacy__int_generic_cost_by_ndc.sql", "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_generic_cost_by_ndc"], "alias": "_int_generic_cost_by_ndc", "checksum": {"name": "sha256", "checksum": "e576514d52124b129d650590ffaea692f93cf4bc4d50e1c3397dca991016d16c"}, "config": {"enabled": true, "alias": "_int_generic_cost_by_ndc", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view calculating the cost of generic drugs at the ndc level for informational purposes.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_generic_cost_by_ndc", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.769469, "relation_name": "cms_synthetic.pharmacy._int_generic_cost_by_ndc", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n/* for each brand rxcui, what is the average cost/unit of all generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , cl.ndc_code as generic_ndc_code\n , cl.paid_amount\n , cl.claim_count\n , cl.total_units\n , cl.cost_per_unit\n , case when claim_count > 0 then 1 else 0 end as prescribed_atleast_one_generic_history\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy__rxnorm_generic_available') }} as g\nleft join {{ ref('pharmacy__int_claims_current_cost') }} as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'", "language": "sql", "refs": [{"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available", "model.the_tuva_project.pharmacy__int_claims_current_cost"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/intermediate/pharmacy__int_generic_cost_by_ndc.sql", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of all generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , cl.ndc_code as generic_ndc_code\n , cl.paid_amount\n , cl.claim_count\n , cl.total_units\n , cl.cost_per_unit\n , case when claim_count > 0 then 1 else 0 end as prescribed_atleast_one_generic_history\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.pharmacy.rxnorm_generic_available as g\nleft join cms_synthetic.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_brand_with_generic_available": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__int_brand_with_generic_available", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/intermediate/pharmacy__int_brand_with_generic_available.sql", "original_file_path": "models/pharmacy/intermediate/pharmacy__int_brand_with_generic_available.sql", "unique_id": "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_brand_with_generic_available"], "alias": "_int_brand_with_generic_available", "checksum": {"name": "sha256", "checksum": "beb3c05225bf296086f50f4d53288ec49c578ccfebf45b6e48d0153068f787b5"}, "config": {"enabled": true, "alias": "_int_brand_with_generic_available", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view identifying brand drugs that have generic equivalents available.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_brand_with_generic_available", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.764896, "relation_name": "cms_synthetic.pharmacy._int_brand_with_generic_available", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct \n product_rxcui as brand_with_generic_available\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy__rxnorm_generic_available') }}\nwhere \n ndc_product_tty in ('SCD', 'GPCK')\n {% if target.type == 'fabric' %}\n and cast(product_startmarketingdate as date) <= GETDATE()\n {% else %}\n and cast(product_startmarketingdate as date) <= current_date\n{% endif %}", "language": "sql", "refs": [{"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/intermediate/pharmacy__int_brand_with_generic_available.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n product_rxcui as brand_with_generic_available\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.pharmacy.rxnorm_generic_available\nwhere \n ndc_product_tty in ('SCD', 'GPCK')\n \n and cast(product_startmarketingdate as date) <= current_date\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_generic_cost": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__int_generic_cost", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy/intermediate/pharmacy__int_generic_cost.sql", "original_file_path": "models/pharmacy/intermediate/pharmacy__int_generic_cost.sql", "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_generic_cost"], "alias": "_int_generic_cost", "checksum": {"name": "sha256", "checksum": "f2149a10bcd87d90bf6ad68caca55fc7d5c924140bb1e9e6692a84606db79a1a"}, "config": {"enabled": true, "alias": "_int_generic_cost", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view calculating the cost of generic drugs.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/pharmacy/pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_generic_cost", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.767901, "relation_name": "cms_synthetic.pharmacy._int_generic_cost", "raw_code": "{{ config(\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n/* for each brand rxcui, what is the average cost/unit of generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , max(case when claim_count > 0 then 1 else 0 end) as prescribed_atleast_one_generic_history\n , sum(case when total_units > 0 and paid_amount > 0 then paid_amount else null end)/sum(case when total_units > 0 and paid_amount > 0 then total_units else null end) as generic_average_cost_per_unit\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy__rxnorm_generic_available') }} as g\nleft join {{ ref('pharmacy__int_claims_current_cost') }} as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'\ngroup by\n g.product_rxcui\n , cl.data_source", "language": "sql", "refs": [{"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available", "model.the_tuva_project.pharmacy__int_claims_current_cost"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/intermediate/pharmacy__int_generic_cost.sql", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , max(case when claim_count > 0 then 1 else 0 end) as prescribed_atleast_one_generic_history\n , sum(case when total_units > 0 and paid_amount > 0 then paid_amount else null end)/sum(case when total_units > 0 and paid_amount > 0 then total_units else null end) as generic_average_cost_per_unit\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.pharmacy.rxnorm_generic_available as g\nleft join cms_synthetic.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'\ngroup by\n g.product_rxcui\n , cl.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.medical_claim_expanded": {"database": "cms_synthetic", "schema": "claims_expanded", "name": "medical_claim_expanded", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_expanded/medical_claim_expanded.sql", "original_file_path": "models/claims_expanded/medical_claim_expanded.sql", "unique_id": "model.the_tuva_project.medical_claim_expanded", "fqn": ["the_tuva_project", "claims_expanded", "medical_claim_expanded"], "alias": "medical_claim_expanded", "checksum": {"name": "sha256", "checksum": "6b01544120d48e1468e9a45f322e947e438a625c935a03bb69a311e5449256bd"}, "config": {"enabled": true, "alias": null, "schema": "claims_expanded", "database": null, "tags": ["claims_expanded"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_expanded"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_expanded/_claims_expanded_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_expanded", "materialized": "table", "tags": "claims_expanded", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.787683, "relation_name": "cms_synthetic.claims_expanded.medical_claim_expanded", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n\nselect *\nfrom {{ ref('medical_claim') }}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_expanded/medical_claim_expanded.sql", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom tuva.input_layer.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_encounter": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_encounter.sql", "original_file_path": "models/core/staging/core__stg_claims_encounter.sql", "unique_id": "model.the_tuva_project.core__stg_claims_encounter", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_encounter"], "alias": "core__stg_claims_encounter", "checksum": {"name": "sha256", "checksum": "8cc80f6c086aa663ac06b37793a3c41f0275048b0340fa120fcd5fc3acf193c5"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "materialized": "table", "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.103009, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_encounter", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the encounter table in core using dbt_utils.union_relations.\n-- *************************************************\n\n{{ config(materialized='table') }}\n\nWITH base AS (\n {{ dbt_utils.union_relations(\n relations=[\n ref('acute_inpatient__encounter_grain')\n , ref('emergency_department__encounter_grain')\n , ref('inpatient_hospice__encounter_grain')\n , ref('inpatient_psych__encounter_grain')\n , ref('inpatient_rehab__encounter_grain')\n , ref('inpatient_snf__encounter_grain')\n , ref('inpatient_substance_use__encounter_grain')\n , ref('urgent_care__encounter_grain')\n , ref('office_visit__encounter_grain')\n , ref('outpatient_hospice__encounter_grain')\n , ref('outpatient_hospital_or_clinic__encounter_grain')\n , ref('outpatient_injections__encounter_grain')\n , ref('outpatient_psych__encounter_grain')\n , ref('outpatient_ptotst__encounter_grain')\n , ref('outpatient_surgery__encounter_grain')\n , ref('outpatient_radiology__encounter_grain')\n , ref('outpatient_rehab__encounter_grain')\n , ref('outpatient_substance_use__encounter_grain')\n , ref('home_health__encounter_grain')\n , ref('dialysis__encounter_grain')\n , ref('asc__encounter_grain')\n , ref('ambulance__encounter_grain')\n , ref('dme__encounter_grain')\n , ref('lab__encounter_grain')\n , ref('orphaned_claim__encounter_grain')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n)\n\nSELECT\n cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\n , cast(p.patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(encounter_type as {{ dbt.type_string() }} ) as encounter_type\n , cast(encounter_group as {{ dbt.type_string() }} ) as encounter_group\n , {{ try_to_cast_date('encounter_start_date', 'YYYY-MM-DD') }} as encounter_start_date\n , {{ try_to_cast_date('encounter_end_date', 'YYYY-MM-DD') }} as encounter_end_date\n , cast(length_of_stay as {{ dbt.type_int() }} ) as length_of_stay\n , cast(admit_source_code as {{ dbt.type_string() }} ) as admit_source_code\n , cast(admit_source_description as {{ dbt.type_string() }} ) as admit_source_description\n , cast(admit_type_code as {{ dbt.type_string() }} ) as admit_type_code\n , cast(admit_type_description as {{ dbt.type_string() }} ) as admit_type_description\n , cast(discharge_disposition_code as {{ dbt.type_string() }} ) as discharge_disposition_code\n , cast(discharge_disposition_description as {{ dbt.type_string() }} ) as discharge_disposition_description\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_id\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_name\n , cast(facility_id as {{ dbt.type_string() }} ) as facility_id\n , cast(facility_name as {{ dbt.type_string() }} ) as facility_name\n , cast(facility_type as {{ dbt.type_string() }} ) as facility_type\n , cast(observation_flag as {{ dbt.type_int() }} ) as observation_flag\n , cast(lab_flag as {{ dbt.type_int() }} ) as lab_flag\n , cast(dme_flag as {{ dbt.type_int() }} ) as dme_flag\n , cast(ambulance_flag as {{ dbt.type_int() }} ) as ambulance_flag\n , cast(pharmacy_flag as {{ dbt.type_int() }} ) as pharmacy_flag\n , cast(ed_flag as {{ dbt.type_int() }} ) as ed_flag\n , cast(delivery_flag as {{ dbt.type_int() }} ) as delivery_flag\n , cast(delivery_type as {{ dbt.type_string() }} ) as delivery_type\n , cast(newborn_flag as {{ dbt.type_int() }} ) as newborn_flag\n , cast(nicu_flag as {{ dbt.type_int() }} ) as nicu_flag\n , cast(primary_diagnosis_code_type as {{ dbt.type_string() }} ) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as {{ dbt.type_string() }} ) as primary_diagnosis_code\n , cast(primary_diagnosis_description as {{ dbt.type_string() }} ) as primary_diagnosis_description\n , cast(ms_drg_code as {{ dbt.type_string() }} ) as ms_drg_code\n , cast(ms_drg_description as {{ dbt.type_string() }} ) as ms_drg_description\n , cast(apr_drg_code as {{ dbt.type_string() }} ) as apr_drg_code\n , cast(apr_drg_description as {{ dbt.type_string() }} ) as apr_drg_description\n , cast(total_paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\n , cast(total_allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\n , cast(total_charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\n , cast(claim_count as {{ dbt.type_int() }}) as claim_count\n , cast(inst_claim_count as {{ dbt.type_int() }}) as inst_claim_count\n , cast(prof_claim_count as {{ dbt.type_int() }}) as prof_claim_count\n , cast(_dbt_source_relation as {{ dbt.type_string() }}) as source_model\n , cast(base.data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nFROM base\ninner join {{ ref('encounters__patient_data_source_id') }} p on base.patient_data_source_id = p.patient_data_source_id", "language": "sql", "refs": [{"name": "acute_inpatient__encounter_grain", "package": null, "version": null}, {"name": "emergency_department__encounter_grain", "package": null, "version": null}, {"name": "inpatient_hospice__encounter_grain", "package": null, "version": null}, {"name": "inpatient_psych__encounter_grain", "package": null, "version": null}, {"name": "inpatient_rehab__encounter_grain", "package": null, "version": null}, {"name": "inpatient_snf__encounter_grain", "package": null, "version": null}, {"name": "inpatient_substance_use__encounter_grain", "package": null, "version": null}, {"name": "urgent_care__encounter_grain", "package": null, "version": null}, {"name": "office_visit__encounter_grain", "package": null, "version": null}, {"name": "outpatient_hospice__encounter_grain", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__encounter_grain", "package": null, "version": null}, {"name": "outpatient_injections__encounter_grain", "package": null, "version": null}, {"name": "outpatient_psych__encounter_grain", "package": null, "version": null}, {"name": "outpatient_ptotst__encounter_grain", "package": null, "version": null}, {"name": "outpatient_surgery__encounter_grain", "package": null, "version": null}, {"name": "outpatient_radiology__encounter_grain", "package": null, "version": null}, {"name": "outpatient_rehab__encounter_grain", "package": null, "version": null}, {"name": "outpatient_substance_use__encounter_grain", "package": null, "version": null}, {"name": "home_health__encounter_grain", "package": null, "version": null}, {"name": "dialysis__encounter_grain", "package": null, "version": null}, {"name": "asc__encounter_grain", "package": null, "version": null}, {"name": "ambulance__encounter_grain", "package": null, "version": null}, {"name": "dme__encounter_grain", "package": null, "version": null}, {"name": "lab__encounter_grain", "package": null, "version": null}, {"name": "orphaned_claim__encounter_grain", "package": null, "version": null}, {"name": "encounters__patient_data_source_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations", "macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.encounters__patient_data_source_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_encounter.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the encounter table in core using dbt_utils.union_relations.\n-- *************************************************\n\n\n\nWITH base AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.acute_inpatient__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(\"DELIVERY_FLAG\" as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(\"DELIVERY_TYPE\" as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(\"NEWBORN_FLAG\" as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(\"NICU_FLAG\" as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.acute_inpatient__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.emergency_department__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.emergency_department__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_snf__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_snf__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.urgent_care__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.urgent_care__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.office_visit__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(null as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"BILLING_ID\" as character varying(16777216)) as \"BILLING_ID\" ,\n cast(\"PROVIDER_NAME\" as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(\"PROVIDER_SPECIALTY\" as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(\"CCS_CATEGORY\" as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(\"CCS_CATEGORY_DESCRIPTION\" as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.office_visit__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_injections__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_injections__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_ptotst__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_ptotst__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_surgery__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_surgery__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_radiology__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_radiology__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.home_health__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.home_health__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.dialysis__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.dialysis__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.asc__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.asc__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.ambulance__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.ambulance__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.dme__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.dme__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.lab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.lab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.orphaned_claim__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.orphaned_claim__encounter_grain\n\n \n )\n\n \n)\n\nSELECT\n cast(encounter_id as TEXT ) as encounter_id\n , cast(p.patient_id as TEXT ) as patient_id\n , cast(encounter_type as TEXT ) as encounter_type\n , cast(encounter_group as TEXT ) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer ) as length_of_stay\n , cast(admit_source_code as TEXT ) as admit_source_code\n , cast(admit_source_description as TEXT ) as admit_source_description\n , cast(admit_type_code as TEXT ) as admit_type_code\n , cast(admit_type_description as TEXT ) as admit_type_description\n , cast(discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(facility_id as TEXT ) as facility_id\n , cast(facility_name as TEXT ) as facility_name\n , cast(facility_type as TEXT ) as facility_type\n , cast(observation_flag as integer ) as observation_flag\n , cast(lab_flag as integer ) as lab_flag\n , cast(dme_flag as integer ) as dme_flag\n , cast(ambulance_flag as integer ) as ambulance_flag\n , cast(pharmacy_flag as integer ) as pharmacy_flag\n , cast(ed_flag as integer ) as ed_flag\n , cast(delivery_flag as integer ) as delivery_flag\n , cast(delivery_type as TEXT ) as delivery_type\n , cast(newborn_flag as integer ) as newborn_flag\n , cast(nicu_flag as integer ) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT ) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT ) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT ) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT ) as ms_drg_code\n , cast(ms_drg_description as TEXT ) as ms_drg_description\n , cast(apr_drg_code as TEXT ) as apr_drg_code\n , cast(apr_drg_description as TEXT ) as apr_drg_description\n , cast(total_paid_amount as numeric(28,6) ) as paid_amount\n , cast(total_allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(total_charge_amount as numeric(28,6) ) as charge_amount\n , cast(claim_count as integer) as claim_count\n , cast(inst_claim_count as integer) as inst_claim_count\n , cast(prof_claim_count as integer) as prof_claim_count\n , cast(_dbt_source_relation as TEXT) as source_model\n , cast(base.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nFROM base\ninner join cms_synthetic.claims_preprocessing.encounters__patient_data_source_id p on base.patient_data_source_id = p.patient_data_source_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_condition": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_condition.sql", "original_file_path": "models/core/staging/core__stg_clinical_condition.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_condition", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_condition"], "alias": "core__stg_clinical_condition", "checksum": {"name": "sha256", "checksum": "7444f8d1668c6c451f1be57759d4b60aafc796f64ce7cef259a41df17e161056"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.1257868, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_condition", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nselect\n cast(condition_id as {{ dbt.type_string() }} ) as condition_id\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\n , cast(claim_id as {{ dbt.type_string() }} ) as claim_id\n , {{ try_to_cast_date('recorded_date', 'YYYY-MM-DD') }} as recorded_date\n , {{ try_to_cast_date('onset_date', 'YYYY-MM-DD') }} as onset_date\n , {{ try_to_cast_date('resolved_date', 'YYYY-MM-DD') }} as resolved_date\n , cast(status as {{ dbt.type_string() }} ) as status\n , cast(condition_type as {{ dbt.type_string() }} ) as condition_type\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\n , cast(condition_rank as {{ dbt.type_int() }} ) as condition_rank\n , cast(present_on_admit_code as {{ dbt.type_string() }} ) as present_on_admit_code\n , cast(present_on_admit_description as {{ dbt.type_string() }} ) as present_on_admit_description\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('condition') }}", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_condition.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(condition_id as TEXT ) as condition_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( recorded_date as date ) as recorded_date\n , try_cast( onset_date as date ) as onset_date\n , try_cast( resolved_date as date ) as resolved_date\n , cast(status as TEXT ) as status\n , cast(condition_type as TEXT ) as condition_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(condition_rank as integer ) as condition_rank\n , cast(present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_location": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_location", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_location.sql", "original_file_path": "models/core/staging/core__stg_claims_location.sql", "unique_id": "model.the_tuva_project.core__stg_claims_location", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_location"], "alias": "core__stg_claims_location", "checksum": {"name": "sha256", "checksum": "f75433d40e575e60c364677aed388fee145eba842eaeac4b34545c423fc63414"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.132763, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_location", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom {{ ref('core__stg_claims_medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct rendering_id as npi, data_source\nfrom {{ ref('core__stg_claims_medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct billing_id as npi, data_source\nfrom {{ ref('core__stg_claims_medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom {{ ref('terminology__provider') }} aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'organization'\n)\n\n\n\nselect \n cast(npi as {{ dbt.type_string() }} ) as location_id\n , cast(npi as {{ dbt.type_string() }} ) as npi\n , cast(provider_organization_name as {{ dbt.type_string() }} ) as name\n , cast(null as {{ dbt.type_string() }} ) as facility_type\n , cast(parent_organization_name as {{ dbt.type_string() }} ) as parent_organization\n , cast(practice_address_line_1 as {{ dbt.type_string() }} ) as address\n , cast(practice_city as {{ dbt.type_string() }} ) as city\n , cast(practice_state as {{ dbt.type_string() }} ) as state\n , cast(practice_zip_code as {{ dbt.type_string() }} ) as zip_code\n , cast(null as {{ dbt.type_float() }} ) as latitude\n , cast(null as {{ dbt.type_float() }} ) as longitude\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast( '{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom provider", "language": "sql", "refs": [{"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_location.sql", "compiled": true, "compiled_code": "\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom cms_synthetic.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'organization'\n)\n\n\n\nselect \n cast(npi as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(provider_organization_name as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(parent_organization_name as TEXT ) as parent_organization\n , cast(practice_address_line_1 as TEXT ) as address\n , cast(practice_city as TEXT ) as city\n , cast(practice_state as TEXT ) as state\n , cast(practice_zip_code as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast( '2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom provider", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_practitioner": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_practitioner", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_practitioner.sql", "original_file_path": "models/core/staging/core__stg_claims_practitioner.sql", "unique_id": "model.the_tuva_project.core__stg_claims_practitioner", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_practitioner"], "alias": "core__stg_claims_practitioner", "checksum": {"name": "sha256", "checksum": "6c89330677f93c72051640bf9395699ea182e45d2e2c59c2350c138a07925322"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.139262, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_practitioner", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the provider table \n-- in core. It includes data about all providers\n-- present in the raw claims dataset.\n-- *************************************************\n\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom {{ ref('core__stg_claims_medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct rendering_id as npi, data_source\nfrom {{ ref('core__stg_claims_medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct billing_id as npi, data_source\nfrom {{ ref('core__stg_claims_medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom {{ ref('terminology__provider') }} aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'individual'\n)\n\n\n\nselect \n cast(npi as {{ dbt.type_string() }} ) as practitioner_id\n , cast(npi as {{ dbt.type_string() }} ) as npi\n , cast(provider_first_name as {{ dbt.type_string() }} ) as provider_first_name\n , cast(provider_last_name as {{ dbt.type_string() }} ) as provider_last_name\n , cast(parent_organization_name as {{ dbt.type_string() }} ) as practice_affiliation\n , cast(primary_specialty_description as {{ dbt.type_string() }} ) as specialty\n , cast(null as {{ dbt.type_string() }} ) as sub_specialty\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom provider", "language": "sql", "refs": [{"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_practitioner.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the provider table \n-- in core. It includes data about all providers\n-- present in the raw claims dataset.\n-- *************************************************\n\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom cms_synthetic.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'individual'\n)\n\n\n\nselect \n cast(npi as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(provider_first_name as TEXT ) as provider_first_name\n , cast(provider_last_name as TEXT ) as provider_last_name\n , cast(parent_organization_name as TEXT ) as practice_affiliation\n , cast(primary_specialty_description as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom provider", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_eligibility": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_eligibility.sql", "original_file_path": "models/core/staging/core__stg_claims_eligibility.sql", "unique_id": "model.the_tuva_project.core__stg_claims_eligibility", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_eligibility"], "alias": "core__stg_claims_eligibility", "checksum": {"name": "sha256", "checksum": "d5b1b051a81d86363fe5e46f4c583d21b45eab1aa849db7834462ddc934bdef9"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.145226, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_eligibility", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the eligibility table in core.\n-- *************************************************\n\n\n\n\nselect\n {{ dbt.concat([\n \"member_id\",\n \"'-'\",\n \"enrollment_start_date\",\n \"'-'\",\n \"enrollment_end_date\",\n \"'-'\",\n \"payer\",\n \"'-'\",\n quote_column('plan'),\n ]) }} as eligibility_id\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(member_id as {{ dbt.type_string() }} ) as member_id\n , cast(subscriber_id as {{ dbt.type_string() }} ) as subscriber_id\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(enrollment_start_date as date ) as enrollment_start_date\n , cast(enrollment_end_date as date ) as enrollment_end_date\n , cast(payer as {{ dbt.type_string() }} ) as payer\n , cast(payer_type as {{ dbt.type_string() }} ) as payer_type\n , {{ quote_column('plan') }}\n , cast(original_reason_entitlement_code as {{ dbt.type_string() }} ) as original_reason_entitlement_code\n , cast(dual_status_code as {{ dbt.type_string() }} ) as dual_status_code\n , cast(medicare_status_code as {{ dbt.type_string() }} ) as medicare_status_code\n , cast(subscriber_relation as {{ dbt.type_string() }} ) as subscriber_relation\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__eligibility') }}", "language": "sql", "refs": [{"name": "normalized_input__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.normalized_input__eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_eligibility.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the eligibility table in core.\n-- *************************************************\n\n\n\n\nselect\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(subscriber_id as TEXT ) as subscriber_id\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(enrollment_start_date as date ) as enrollment_start_date\n , cast(enrollment_end_date as date ) as enrollment_end_date\n , cast(payer as TEXT ) as payer\n , cast(payer_type as TEXT ) as payer_type\n , plan\n , cast(original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(dual_status_code as TEXT ) as dual_status_code\n , cast(medicare_status_code as TEXT ) as medicare_status_code\n , cast(subscriber_relation as TEXT ) as subscriber_relation\n , cast(data_source as TEXT ) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_medical_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_medical_claim.sql", "original_file_path": "models/core/staging/core__stg_claims_medical_claim.sql", "unique_id": "model.the_tuva_project.core__stg_claims_medical_claim", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_medical_claim"], "alias": "core__stg_claims_medical_claim", "checksum": {"name": "sha256", "checksum": "bee73256f99b23444f97db9b7fdb2f9409e47b89e971417d1f056e1dbba3d606"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.152114, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_medical_claim", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the medical_claim table\n-- in core. It adds these 4 fields to the input layer\n-- medical claim table:\n-- encounter_id\n-- service_category_1\n-- service_category_2\n-- *************************************************\n\nwith all_encounters as (\n select claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from {{ ref('encounters__combined_claim_line_crosswalk') }}\n where claim_line_attribution_number = 1\n \n union all \n\n select \n claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from {{ ref('encounters__orphaned_claims') }}\n)\n\n\nselect\n {{ dbt.concat([\n \"med.claim_id\",\n \"'-'\",\n \"med.claim_line_number\"\n ]) }} as medical_claim_id\n , cast(med.claim_id as {{ dbt.type_string() }} ) as claim_id\n , cast(med.claim_line_number as {{ dbt.type_int() }} ) as claim_line_number\n , cast(x.encounter_id as int ) as encounter_id\n , cast(x.encounter_type as {{ dbt.type_string() }} ) as encounter_type\n , cast(x.encounter_group as {{ dbt.type_string() }} ) as encounter_group\n , cast(med.claim_type as {{ dbt.type_string() }} ) as claim_type\n , cast(med.patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(med.member_id as {{ dbt.type_string() }} ) as member_id\n , cast(med.payer as {{ dbt.type_string() }} ) as payer\n , med.{{ quote_column('plan') }}\n , {{ try_to_cast_date('med.claim_start_date', 'YYYY-MM-DD') }} as claim_start_date\n , {{ try_to_cast_date('med.claim_end_date', 'YYYY-MM-DD') }} as claim_end_date\n , {{ try_to_cast_date('med.claim_line_start_date', 'YYYY-MM-DD') }} as claim_line_start_date\n , {{ try_to_cast_date('med.claim_line_end_date', 'YYYY-MM-DD') }} as claim_line_end_date\n , {{ try_to_cast_date('med.admission_date', 'YYYY-MM-DD') }} as admission_date\n , {{ try_to_cast_date('med.discharge_date', 'YYYY-MM-DD') }} as discharge_date\n , cast(srv_group.service_category_1 as {{ dbt.type_string() }} ) as service_category_1\n , cast(srv_group.service_category_2 as {{ dbt.type_string() }} ) as service_category_2\n , cast(srv_group.service_category_3 as {{ dbt.type_string() }} ) as service_category_3\n , cast(med.admit_source_code as {{ dbt.type_string() }} ) as admit_source_code\n , cast(med.admit_source_description as {{ dbt.type_string() }} ) as admit_source_description\n , cast(med.admit_type_code as {{ dbt.type_string() }} ) as admit_type_code\n , cast(med.admit_type_description as {{ dbt.type_string() }} ) as admit_type_description\n , cast(med.discharge_disposition_code as {{ dbt.type_string() }} ) as discharge_disposition_code\n , cast(med.discharge_disposition_description as {{ dbt.type_string() }} ) as discharge_disposition_description\n , cast(med.place_of_service_code as {{ dbt.type_string() }} ) as place_of_service_code\n , cast(med.place_of_service_description as {{ dbt.type_string() }} ) as place_of_service_description\n , cast(med.bill_type_code as {{ dbt.type_string() }} ) as bill_type_code\n , cast(med.bill_type_description as {{ dbt.type_string() }} ) as bill_type_description\n , cast(med.ms_drg_code as {{ dbt.type_string() }} ) as ms_drg_code\n , cast(med.ms_drg_description as {{ dbt.type_string() }} ) as ms_drg_description\n , cast(med.apr_drg_code as {{ dbt.type_string() }} ) as apr_drg_code\n , cast(med.apr_drg_description as {{ dbt.type_string() }} ) as apr_drg_description\n , cast(med.revenue_center_code as {{ dbt.type_string() }} ) as revenue_center_code\n , cast(med.revenue_center_description as {{ dbt.type_string() }} ) as revenue_center_description\n , cast(med.service_unit_quantity as {{ dbt.type_numeric() }} ) as service_unit_quantity\n , cast(med.hcpcs_code as {{ dbt.type_string() }} ) as hcpcs_code\n , cast(med.hcpcs_modifier_1 as {{ dbt.type_string() }} ) as hcpcs_modifier_1\n , cast(med.hcpcs_modifier_2 as {{ dbt.type_string() }} ) as hcpcs_modifier_2\n , cast(med.hcpcs_modifier_3 as {{ dbt.type_string() }} ) as hcpcs_modifier_3\n , cast(med.hcpcs_modifier_4 as {{ dbt.type_string() }} ) as hcpcs_modifier_4\n , cast(med.hcpcs_modifier_5 as {{ dbt.type_string() }} ) as hcpcs_modifier_5\n , cast(med.rendering_id as {{ dbt.type_string() }} ) as rendering_id\n , cast(med.rendering_tin as {{ dbt.type_string() }} ) as rendering_tin\n , cast(med.rendering_name as {{ dbt.type_string() }} ) as rendering_name\n , cast(med.billing_id as {{ dbt.type_string() }} ) as billing_id\n , cast(med.billing_tin as {{ dbt.type_string() }} ) as billing_tin\n , cast(med.billing_name as {{ dbt.type_string() }} ) as billing_name\n , cast(med.facility_id as {{ dbt.type_string() }} ) as facility_id\n , cast(med.facility_name as {{ dbt.type_string() }} ) as facility_name\n , {{ try_to_cast_date('med.paid_date', 'YYYY-MM-DD') }} as paid_date\n , cast(med.paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\n , cast(med.allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\n , cast(med.charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\n , cast(med.coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\n , cast(med.copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\n , cast(med.deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\n , cast(med.total_cost_amount as {{ dbt.type_numeric() }} ) as total_cost_amount\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast(\n case\n when enroll.claim_id is not null then 1\n else 0\n end as int) as enrollment_flag\n , cast(med.data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('normalized_input__medical_claim') }} as med\ninner join {{ ref('service_category__service_category_grouper') }} as srv_group\n on med.claim_id = srv_group.claim_id\n and med.claim_line_number = srv_group.claim_line_number\n and srv_group.duplicate_row_number = 1\ninner join all_encounters as x\n on med.claim_id = x.claim_id\n and med.claim_line_number = x.claim_line_number\nleft join {{ ref('claims_enrollment__flag_claims_with_enrollment') }} as enroll\n on med.claim_id = enroll.claim_id\n and med.claim_line_number = enroll.claim_line_number", "language": "sql", "refs": [{"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__orphaned_claims", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "claims_enrollment__flag_claims_with_enrollment", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.type_string", "macro.dbt.type_int", "macro.the_tuva_project.quote_column", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_medical_claim.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the medical_claim table\n-- in core. It adds these 4 fields to the input layer\n-- medical claim table:\n-- encounter_id\n-- service_category_1\n-- service_category_2\n-- *************************************************\n\nwith all_encounters as (\n select claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk\n where claim_line_attribution_number = 1\n \n union all \n\n select \n claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from cms_synthetic.claims_preprocessing.encounters__orphaned_claims\n)\n\n\nselect\n med.claim_id || '-' || med.claim_line_number as medical_claim_id\n , cast(med.claim_id as TEXT ) as claim_id\n , cast(med.claim_line_number as integer ) as claim_line_number\n , cast(x.encounter_id as int ) as encounter_id\n , cast(x.encounter_type as TEXT ) as encounter_type\n , cast(x.encounter_group as TEXT ) as encounter_group\n , cast(med.claim_type as TEXT ) as claim_type\n , cast(med.patient_id as TEXT ) as patient_id\n , cast(med.member_id as TEXT ) as member_id\n , cast(med.payer as TEXT ) as payer\n , med.plan\n , try_cast( med.claim_start_date as date ) as claim_start_date\n , try_cast( med.claim_end_date as date ) as claim_end_date\n , try_cast( med.claim_line_start_date as date ) as claim_line_start_date\n , try_cast( med.claim_line_end_date as date ) as claim_line_end_date\n , try_cast( med.admission_date as date ) as admission_date\n , try_cast( med.discharge_date as date ) as discharge_date\n , cast(srv_group.service_category_1 as TEXT ) as service_category_1\n , cast(srv_group.service_category_2 as TEXT ) as service_category_2\n , cast(srv_group.service_category_3 as TEXT ) as service_category_3\n , cast(med.admit_source_code as TEXT ) as admit_source_code\n , cast(med.admit_source_description as TEXT ) as admit_source_description\n , cast(med.admit_type_code as TEXT ) as admit_type_code\n , cast(med.admit_type_description as TEXT ) as admit_type_description\n , cast(med.discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(med.discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(med.place_of_service_code as TEXT ) as place_of_service_code\n , cast(med.place_of_service_description as TEXT ) as place_of_service_description\n , cast(med.bill_type_code as TEXT ) as bill_type_code\n , cast(med.bill_type_description as TEXT ) as bill_type_description\n , cast(med.ms_drg_code as TEXT ) as ms_drg_code\n , cast(med.ms_drg_description as TEXT ) as ms_drg_description\n , cast(med.apr_drg_code as TEXT ) as apr_drg_code\n , cast(med.apr_drg_description as TEXT ) as apr_drg_description\n , cast(med.revenue_center_code as TEXT ) as revenue_center_code\n , cast(med.revenue_center_description as TEXT ) as revenue_center_description\n , cast(med.service_unit_quantity as numeric(28,6) ) as service_unit_quantity\n , cast(med.hcpcs_code as TEXT ) as hcpcs_code\n , cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n , cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n , cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n , cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n , cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n , cast(med.rendering_id as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(med.rendering_name as TEXT ) as rendering_name\n , cast(med.billing_id as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(med.billing_name as TEXT ) as billing_name\n , cast(med.facility_id as TEXT ) as facility_id\n , cast(med.facility_name as TEXT ) as facility_name\n , try_cast( med.paid_date as date ) as paid_date\n , cast(med.paid_amount as numeric(28,6) ) as paid_amount\n , cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(med.charge_amount as numeric(28,6) ) as charge_amount\n , cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast(\n case\n when enroll.claim_id is not null then 1\n else 0\n end as int) as enrollment_flag\n , cast(med.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim as med\ninner join cms_synthetic.claims_preprocessing.service_category_grouper as srv_group\n on med.claim_id = srv_group.claim_id\n and med.claim_line_number = srv_group.claim_line_number\n and srv_group.duplicate_row_number = 1\ninner join all_encounters as x\n on med.claim_id = x.claim_id\n and med.claim_line_number = x.claim_line_number\nleft join cms_synthetic.claims_preprocessing.flag_claims_with_enrollment as enroll\n on med.claim_id = enroll.claim_id\n and med.claim_line_number = enroll.claim_line_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_procedure": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_procedure.sql", "original_file_path": "models/core/staging/core__stg_claims_procedure.sql", "unique_id": "model.the_tuva_project.core__stg_claims_procedure", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_procedure"], "alias": "core__stg_claims_procedure", "checksum": {"name": "sha256", "checksum": "f0afec415660bb5e37083c017b1218b9f42863690bff6a18a2b2e4bc516b59e8"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.165141, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_procedure", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the procedure table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id as claim_id\n , claim_line_number as procedure_sequence_id\n , patient_id as patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as procedure_date\n , 'hcpcs' as source_code_type\n , hcpcs_code as source_code\n , rendering_id as practitioner_npi\n , hcpcs_modifier_1 as modifier_1\n , hcpcs_modifier_2 as modifier_2\n , hcpcs_modifier_3 as modifier_3\n , hcpcs_modifier_4 as modifier_4\n , hcpcs_modifier_5 as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere hcpcs_code is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 1 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_1 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_1 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_1 is not null\n \n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 2 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_2 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_2 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_2 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 3 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_3 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_3 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_3 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 4 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_4 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_4 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_4 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 5 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_5 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_5 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_5 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 6 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_6 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_6 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_6 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 7 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_7 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_7 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_7 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 8 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_8 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_8 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_8 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 9 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_9 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_9 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_9 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 10 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_10 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_10 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_10 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 11 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_11 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_11 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_11 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 12 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_12 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_12 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_12 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 13 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_13 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_13 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_13 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 14 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_14 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_14 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_14 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 15 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_15 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_15 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_15 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 16 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_16 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_16 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_16 is not null\n \n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 17 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_17 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_17 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_17 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 18 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_18 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_18 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_18 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 19 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_19 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_19 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_19 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 20 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_20 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_20 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_20 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 21 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_21 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_21 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_21 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 22 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_22 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_22 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_22 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 23 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_23 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_23 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_23 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 24 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_24 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_24 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_24 is not null\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect\n claim_id as claim_id\n , 25 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_25 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_25 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere procedure_code_25 is not null\n\n)\n\nselect distinct\n{{ dbt.safe_cast(\n dbt.concat([\n \"unpivot_cte.data_source\",\n \"'_'\",\n \"unpivot_cte.claim_id\",\n \"'_'\",\n \"unpivot_cte.procedure_sequence_id\",\n \"'_'\",\n \"unpivot_cte.source_code\",\n \"case when unpivot_cte.modifier_1 is not null then CONCAT('_', unpivot_cte.modifier_1) else '' end\",\n \"case when unpivot_cte.modifier_2 is not null then CONCAT('_', unpivot_cte.modifier_2) else '' end\",\n \"case when unpivot_cte.modifier_3 is not null then CONCAT('_', unpivot_cte.modifier_3) else '' end\",\n \"case when unpivot_cte.modifier_4 is not null then CONCAT('_', unpivot_cte.modifier_4) else '' end\",\n \"case when unpivot_cte.modifier_5 is not null then CONCAT('_', unpivot_cte.modifier_5) else '' end\",\n \"case when unpivot_cte.practitioner_npi is not null then CONCAT('_', unpivot_cte.practitioner_npi) else '' end\"\n ]), api.Column.translate_type(\"string\"))\n }} as procedure_id\n , cast(unpivot_cte.patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as {{ dbt.type_string() }} ) as claim_id\n , {{ try_to_cast_date('unpivot_cte.procedure_date', 'YYYY-MM-DD') }} as procedure_date\n , cast(unpivot_cte.source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(unpivot_cte.source_code as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(\n case\n when icd.icd_10_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n end\n as {{ dbt.type_string() }} ) as normalized_code_type\n , cast (\n coalesce (\n icd.icd_10_pcs\n , hcpcs.hcpcs\n )\n as {{ dbt.type_string() }} ) as normalized_code\n , cast (\n coalesce (\n icd.description\n , hcpcs.short_description\n )\n as {{ dbt.type_string() }} ) as normalized_description\n , cast(unpivot_cte.modifier_1 as {{ dbt.type_string() }} ) as modifier_1\n , cast(unpivot_cte.modifier_2 as {{ dbt.type_string() }} ) as modifier_2\n , cast(unpivot_cte.modifier_3 as {{ dbt.type_string() }} ) as modifier_3\n , cast(unpivot_cte.modifier_4 as {{ dbt.type_string() }} ) as modifier_4\n , cast(unpivot_cte.modifier_5 as {{ dbt.type_string() }} ) as modifier_5\n , cast(unpivot_cte.practitioner_npi as {{ dbt.type_string() }} ) as practitioner_id\n , cast(unpivot_cte.data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom unpivot_cte\n--inner join {{ ref('encounters__combined_claim_line_crosswalk') }} x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join {{ ref('terminology__icd_10_pcs') }} as icd\n on unpivot_cte.source_code = icd.icd_10_pcs\nleft join {{ ref('terminology__hcpcs_level_2') }} as hcpcs\n on unpivot_cte.source_code = hcpcs.hcpcs", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.safe_cast", "macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_procedure.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the procedure table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id as claim_id\n , claim_line_number as procedure_sequence_id\n , patient_id as patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as procedure_date\n , 'hcpcs' as source_code_type\n , hcpcs_code as source_code\n , rendering_id as practitioner_npi\n , hcpcs_modifier_1 as modifier_1\n , hcpcs_modifier_2 as modifier_2\n , hcpcs_modifier_3 as modifier_3\n , hcpcs_modifier_4 as modifier_4\n , hcpcs_modifier_5 as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere hcpcs_code is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 1 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_1 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_1 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_1 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 2 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_2 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_2 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_2 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 3 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_3 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_3 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_3 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 4 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_4 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_4 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_4 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 5 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_5 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_5 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_5 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 6 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_6 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_6 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_6 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 7 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_7 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_7 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_7 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 8 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_8 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_8 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_8 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 9 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_9 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_9 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_9 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 10 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_10 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_10 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_10 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 11 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_11 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_11 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_11 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 12 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_12 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_12 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_12 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 13 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_13 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_13 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_13 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 14 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_14 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_14 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_14 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 15 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_15 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_15 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_15 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 16 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_16 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_16 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_16 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 17 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_17 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_17 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_17 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 18 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_18 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_18 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_18 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 19 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_19 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_19 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_19 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 20 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_20 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_20 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_20 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 21 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_21 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_21 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_21 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 22 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_22 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_22 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_22 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 23 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_23 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_23 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_23 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 24 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_24 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_24 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_24 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 25 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_25 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_25 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(unpivot_cte.data_source || '_' || unpivot_cte.claim_id || '_' || unpivot_cte.procedure_sequence_id || '_' || unpivot_cte.source_code || case when unpivot_cte.modifier_1 is not null then CONCAT('_', unpivot_cte.modifier_1) else '' end || case when unpivot_cte.modifier_2 is not null then CONCAT('_', unpivot_cte.modifier_2) else '' end || case when unpivot_cte.modifier_3 is not null then CONCAT('_', unpivot_cte.modifier_3) else '' end || case when unpivot_cte.modifier_4 is not null then CONCAT('_', unpivot_cte.modifier_4) else '' end || case when unpivot_cte.modifier_5 is not null then CONCAT('_', unpivot_cte.modifier_5) else '' end || case when unpivot_cte.practitioner_npi is not null then CONCAT('_', unpivot_cte.practitioner_npi) else '' end as TEXT)\n as procedure_id\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.procedure_date as date ) as procedure_date\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n end\n as TEXT ) as normalized_code_type\n , cast (\n coalesce (\n icd.icd_10_pcs\n , hcpcs.hcpcs\n )\n as TEXT ) as normalized_code\n , cast (\n coalesce (\n icd.description\n , hcpcs.short_description\n )\n as TEXT ) as normalized_description\n , cast(unpivot_cte.modifier_1 as TEXT ) as modifier_1\n , cast(unpivot_cte.modifier_2 as TEXT ) as modifier_2\n , cast(unpivot_cte.modifier_3 as TEXT ) as modifier_3\n , cast(unpivot_cte.modifier_4 as TEXT ) as modifier_4\n , cast(unpivot_cte.modifier_5 as TEXT ) as modifier_5\n , cast(unpivot_cte.practitioner_npi as TEXT ) as practitioner_id\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join cms_synthetic.terminology.icd_10_pcs as icd\n on unpivot_cte.source_code = icd.icd_10_pcs\nleft join cms_synthetic.terminology.hcpcs_level_2 as hcpcs\n on unpivot_cte.source_code = hcpcs.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_patient": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_patient.sql", "original_file_path": "models/core/staging/core__stg_clinical_patient.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_patient", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_patient"], "alias": "core__stg_clinical_patient", "checksum": {"name": "sha256", "checksum": "f6154800febb47e97cb13e7409ba79b6b299cc5ab052cdb6f652ace2e44a10a4"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.182774, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_patient", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nwith tuva_last_run as(\n select\n cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run_datetime\n , cast(substring('{{ var('tuva_last_run')}}',1,10) as date ) as tuva_last_run_date\n)\nSELECT\n cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(first_name as {{ dbt.type_string() }} ) as first_name\n , cast(last_name as {{ dbt.type_string() }} ) as last_name\n , cast(sex as {{ dbt.type_string() }} ) as sex\n , cast(race as {{ dbt.type_string() }} ) as race\n , {{ try_to_cast_date('birth_date', 'YYYY-MM-DD') }} as birth_date\n , {{ try_to_cast_date('death_date', 'YYYY-MM-DD') }} as death_date\n , cast(death_flag as {{ dbt.type_int() }} ) as death_flag\n , cast(social_security_number as {{ dbt.type_string() }} ) as social_security_number\n , cast(address as {{ dbt.type_string() }} ) as address\n , cast(city as {{ dbt.type_string() }} ) as city\n , cast(state as {{ dbt.type_string() }} ) as state\n , cast(zip_code as {{ dbt.type_string() }} ) as zip_code\n , cast(county as {{ dbt.type_string() }} ) as county\n , cast(latitude as {{ dbt.type_float() }} ) as latitude\n , cast(longitude as {{ dbt.type_float() }} ) as longitude\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) as age\n , cast(\n CASE\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 10 THEN '0-9'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 20 THEN '10-19'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 30 THEN '20-29'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 40 THEN '30-39'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 50 THEN '40-49'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 60 THEN '50-59'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 70 THEN '60-69'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 80 THEN '70-79'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 90 THEN '80-89'\n ELSE '90+'\n END as {{ dbt.type_string() }}\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nFROM {{ ref('patient') }}\ncross join tuva_last_run", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_timestamp", "macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_float", "macro.dbt.datediff"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_patient.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n select\n cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run_datetime\n , cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date ) as tuva_last_run_date\n)\nSELECT\n cast(patient_id as TEXT ) as patient_id\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(sex as TEXT ) as sex\n , cast(race as TEXT ) as race\n , try_cast( birth_date as date ) as birth_date\n , try_cast( death_date as date ) as death_date\n , cast(death_flag as integer ) as death_flag\n , cast(social_security_number as TEXT ) as social_security_number\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(county as TEXT ) as county\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nFROM tuva.input_layer.patient\ncross join tuva_last_run", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_procedure": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_procedure.sql", "original_file_path": "models/core/staging/core__stg_clinical_procedure.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_procedure", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_procedure"], "alias": "core__stg_clinical_procedure", "checksum": {"name": "sha256", "checksum": "a6da428700d51ecf60346084ea80a55f9178ac0a5125092d75e4616fc070df0c"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.193123, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_procedure", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nselect\n cast(procedure_id as {{ dbt.type_string() }} ) as procedure_id \n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\n , cast(claim_id as {{ dbt.type_string() }} ) as claim_id\n , {{ try_to_cast_date('procedure_date', 'YYYY-MM-DD') }} as procedure_date\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\n , cast(modifier_1 as {{ dbt.type_string() }} ) as modifier_1\n , cast(modifier_2 as {{ dbt.type_string() }} ) as modifier_2\n , cast(modifier_3 as {{ dbt.type_string() }} ) as modifier_3\n , cast(modifier_4 as {{ dbt.type_string() }} ) as modifier_4\n , cast(modifier_5 as {{ dbt.type_string() }} ) as modifier_5\n , cast(practitioner_id as {{ dbt.type_string() }} ) as practitioner_id\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('procedure') }}", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_procedure.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(procedure_id as TEXT ) as procedure_id \n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( procedure_date as date ) as procedure_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(modifier_1 as TEXT ) as modifier_1\n , cast(modifier_2 as TEXT ) as modifier_2\n , cast(modifier_3 as TEXT ) as modifier_3\n , cast(modifier_4 as TEXT ) as modifier_4\n , cast(modifier_5 as TEXT ) as modifier_5\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_encounter": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_encounter.sql", "original_file_path": "models/core/staging/core__stg_clinical_encounter.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_encounter", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_encounter"], "alias": "core__stg_clinical_encounter", "checksum": {"name": "sha256", "checksum": "a8a872628c63164ad5e431e8ea471e3b06050544a767989f6d357b0e501ae101"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.1992562, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_encounter", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nselect\n cast(encounter_id as {{ dbt.type_string() }}) as encounter_id\n , cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(encounter_type as {{ dbt.type_string() }}) as encounter_type\n , cast('clinical' as {{ dbt.type_string() }}) as encounter_group\n , {{ try_to_cast_date('encounter_start_date', 'YYYY-MM-DD') }} as encounter_start_date\n , {{ try_to_cast_date('encounter_end_date', 'YYYY-MM-DD') }} as encounter_end_date\n , cast(length_of_stay as {{ dbt.type_int() }}) as length_of_stay\n , cast(admit_source_code as {{ dbt.type_string() }}) as admit_source_code\n , cast(admit_source_description as {{ dbt.type_string() }}) as admit_source_description\n , cast(admit_type_code as {{ dbt.type_string() }}) as admit_type_code\n , cast(admit_type_description as {{ dbt.type_string() }}) as admit_type_description\n , cast(discharge_disposition_code as {{ dbt.type_string() }}) as discharge_disposition_code\n , cast(discharge_disposition_description as {{ dbt.type_string() }}) as discharge_disposition_description\n , cast(attending_provider_id as {{ dbt.type_string() }}) as attending_provider_id\n , cast(attending_provider_name as {{ dbt.type_string() }}) as attending_provider_name\n , cast(facility_id as {{ dbt.type_string() }}) as facility_id\n , cast(facility_name as {{ dbt.type_string() }}) as facility_name\n , cast(null as {{ dbt.type_string() }}) as facility_type\n , cast(null as {{ dbt.type_int() }}) as observation_flag\n , cast(null as {{ dbt.type_int() }}) as lab_flag\n , cast(null as {{ dbt.type_int() }}) as dme_flag\n , cast(null as {{ dbt.type_int() }}) as ambulance_flag\n , cast(null as {{ dbt.type_int() }}) as pharmacy_flag\n , cast(null as {{ dbt.type_int() }}) as ed_flag\n , cast(null as {{ dbt.type_int() }}) as delivery_flag\n , cast(null as {{ dbt.type_string() }}) as delivery_type\n , cast(null as {{ dbt.type_int() }}) as newborn_flag\n , cast(null as {{ dbt.type_int() }}) as nicu_flag\n , cast(primary_diagnosis_code_type as {{ dbt.type_string() }}) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as {{ dbt.type_string() }}) as primary_diagnosis_code\n , cast(primary_diagnosis_description as {{ dbt.type_string() }}) as primary_diagnosis_description\n , cast(ms_drg_code as {{ dbt.type_string() }}) as ms_drg_code\n , cast(ms_drg_description as {{ dbt.type_string() }}) as ms_drg_description\n , cast(apr_drg_code as {{ dbt.type_string() }}) as apr_drg_code\n , cast(apr_drg_description as {{ dbt.type_string() }}) as apr_drg_description\n , cast(paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\n , cast(allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\n , cast(charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\n , cast(null as {{ dbt.type_int() }}) as claim_count\n , cast(null as {{ dbt.type_int() }}) as inst_claim_count\n , cast(null as {{ dbt.type_int() }}) as prof_claim_count\n , cast(null as {{ dbt.type_string() }}) as source_model\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast('{{ var('tuva_last_run') }}' as {{ dbt.type_timestamp() }}) as tuva_last_run\nfrom {{ ref('encounter') }}", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(encounter_id as TEXT) as encounter_id\n , cast(patient_id as TEXT) as patient_id\n , cast(encounter_type as TEXT) as encounter_type\n , cast('clinical' as TEXT) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer) as length_of_stay\n , cast(admit_source_code as TEXT) as admit_source_code\n , cast(admit_source_description as TEXT) as admit_source_description\n , cast(admit_type_code as TEXT) as admit_type_code\n , cast(admit_type_description as TEXT) as admit_type_description\n , cast(discharge_disposition_code as TEXT) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT) as discharge_disposition_description\n , cast(attending_provider_id as TEXT) as attending_provider_id\n , cast(attending_provider_name as TEXT) as attending_provider_name\n , cast(facility_id as TEXT) as facility_id\n , cast(facility_name as TEXT) as facility_name\n , cast(null as TEXT) as facility_type\n , cast(null as integer) as observation_flag\n , cast(null as integer) as lab_flag\n , cast(null as integer) as dme_flag\n , cast(null as integer) as ambulance_flag\n , cast(null as integer) as pharmacy_flag\n , cast(null as integer) as ed_flag\n , cast(null as integer) as delivery_flag\n , cast(null as TEXT) as delivery_type\n , cast(null as integer) as newborn_flag\n , cast(null as integer) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT) as ms_drg_code\n , cast(ms_drg_description as TEXT) as ms_drg_description\n , cast(apr_drg_code as TEXT) as apr_drg_code\n , cast(apr_drg_description as TEXT) as apr_drg_description\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(null as integer) as claim_count\n , cast(null as integer) as inst_claim_count\n , cast(null as integer) as prof_claim_count\n , cast(null as TEXT) as source_model\n , cast(data_source as TEXT) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp) as tuva_last_run\nfrom tuva.input_layer.encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_medication": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_medication.sql", "original_file_path": "models/core/staging/core__stg_clinical_medication.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_medication", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_medication"], "alias": "core__stg_clinical_medication", "checksum": {"name": "sha256", "checksum": "80869ffb92f3f92bc59ff63a5c53934274fb6ddaec361b21dfa519b2763987b8"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.20861, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_medication", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nselect\n cast(medication_id as {{ dbt.type_string() }} ) as medication_id\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\n , {{ try_to_cast_date('dispensing_date', 'YYYY-MM-DD') }} as dispensing_date\n , {{ try_to_cast_date('prescribing_date', 'YYYY-MM-DD') }} as prescribing_date\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\n , cast(ndc_code as {{ dbt.type_string() }} ) as ndc_code\n , cast(ndc_description as {{ dbt.type_string() }} ) as ndc_description\n , cast(rxnorm_code as {{ dbt.type_string() }} ) as rxnorm_code\n , cast(rxnorm_description as {{ dbt.type_string() }} ) as rxnorm_description \n , cast(atc_code as {{ dbt.type_string() }} ) as atc_code\n , cast(atc_description as {{ dbt.type_string() }} ) as atc_description\n , cast(route as {{ dbt.type_string() }} ) as route\n , cast(strength as {{ dbt.type_string() }} ) as strength\n , cast(quantity as {{ dbt.type_int() }} ) as quantity\n , cast(quantity_unit as {{ dbt.type_string() }} ) as quantity_unit\n , cast(days_supply as {{ dbt.type_int() }} ) as days_supply\n , cast(practitioner_id as {{ dbt.type_string() }} ) as practitioner_id\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('medication') }}", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_medication.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(medication_id as TEXT ) as medication_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , try_cast( dispensing_date as date ) as dispensing_date\n , try_cast( prescribing_date as date ) as prescribing_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(rxnorm_code as TEXT ) as rxnorm_code\n , cast(rxnorm_description as TEXT ) as rxnorm_description \n , cast(atc_code as TEXT ) as atc_code\n , cast(atc_description as TEXT ) as atc_description\n , cast(route as TEXT ) as route\n , cast(strength as TEXT ) as strength\n , cast(quantity as integer ) as quantity\n , cast(quantity_unit as TEXT ) as quantity_unit\n , cast(days_supply as integer ) as days_supply\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.medication", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_condition": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_condition.sql", "original_file_path": "models/core/staging/core__stg_claims_condition.sql", "unique_id": "model.the_tuva_project.core__stg_claims_condition", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_condition"], "alias": "core__stg_claims_condition", "checksum": {"name": "sha256", "checksum": "4fd7de6b0fee534bc5db7ff1983e6a63c789976b459300969af9916363ecbc94"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.214994, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_condition", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the condition table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_1 as source_code\n , 1 as diagnosis_rank\n , diagnosis_poa_1 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }} \nwhere diagnosis_code_1 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n\t , discharge_date\n\t , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_2 as source_code\n , 2 as diagnosis_rank\n , diagnosis_poa_2 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_2 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_3 as source_code\n , 3 as diagnosis_rank\n , diagnosis_poa_3 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_3 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_4 as source_code\n , 4 as diagnosis_rank\n , diagnosis_poa_4 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_4 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_5 as source_code\n , 5 as diagnosis_rank\n , diagnosis_poa_5 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_5 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_6 as source_code\n , 6 as diagnosis_rank\n , diagnosis_poa_6 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_6 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_7 as source_code\n , 7 as diagnosis_rank\n , diagnosis_poa_7 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_7 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_8 as source_code\n , 8 as diagnosis_rank\n , diagnosis_poa_8 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_8 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_9 as source_code\n , 9 as diagnosis_rank\n , diagnosis_poa_9 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_9 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_10 as source_code\n , 10 as diagnosis_rank\n , diagnosis_poa_10 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_10 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_11 as source_code\n , 11 as diagnosis_rank\n , diagnosis_poa_11 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_11 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_12 as source_code\n , 12 as diagnosis_rank\n , diagnosis_poa_12 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_12 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_13 as source_code\n , 13 as diagnosis_rank\n , diagnosis_poa_13 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_13 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_14 as source_code\n , 14 as diagnosis_rank\n , diagnosis_poa_14 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_14 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_15 as source_code\n , 15 as diagnosis_rank\n , diagnosis_poa_15 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_15 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_16 as source_code\n , 16 as diagnosis_rank\n , diagnosis_poa_16 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_16 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_17 as source_code\n , 17 as diagnosis_rank\n , diagnosis_poa_17 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_17 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_18 as source_code\n , 18 as diagnosis_rank\n , diagnosis_poa_18 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_18 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_19 as source_code\n , 19 as diagnosis_rank\n , diagnosis_poa_19 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_19 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_20 as source_code\n , 20 as diagnosis_rank\n , diagnosis_poa_20 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_20 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_21 as source_code\n , 21 as diagnosis_rank\n , diagnosis_poa_21 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_21 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_22 as source_code\n , 22 as diagnosis_rank\n , diagnosis_poa_22 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_22 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_23 as source_code\n , 23 as diagnosis_rank\n , diagnosis_poa_23 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_23 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_24 as source_code\n , 24 as diagnosis_rank\n , diagnosis_poa_24 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_24 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_25 as source_code\n , 25 as diagnosis_rank\n , diagnosis_poa_25 as present_on_admit_code\n , data_source\nfrom {{ ref('normalized_input__medical_claim') }}\nwhere diagnosis_code_25 is not null\n\n)\n\nselect distinct\n{{ dbt.safe_cast(\n dbt.concat([\n \"CAST(unpivot_cte.data_source AS \" ~ dbt.type_string() ~ \")\",\n \"'_'\",\n \"CAST(unpivot_cte.claim_id AS \" ~ dbt.type_string() ~ \")\",\n \"'_'\",\n \"CAST(unpivot_cte.diagnosis_rank AS \" ~ dbt.type_string() ~ \")\",\n \"'_'\",\n \"CAST(unpivot_cte.source_code AS \" ~ dbt.type_string() ~ \")\",\n ]), api.Column.translate_type(\"string\"))\n }} as condition_id\n\n , cast(unpivot_cte.patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as {{ dbt.type_string() }} ) as claim_id\n , {{ try_to_cast_date('unpivot_cte.recorded_date', 'YYYY-MM-DD') }} as recorded_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as onset_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as resolved_date\n , cast('active' as {{ dbt.type_string() }} ) as status\n , cast(unpivot_cte.condition_type as {{ dbt.type_string() }} ) as condition_type\n , cast(unpivot_cte.source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(unpivot_cte.source_code as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_description\n , cast(\n case\n when icd.icd_10_cm is not null then 'icd-10-cm'\n end as {{ dbt.type_string() }}\n ) as normalized_code_type\n , cast(icd.icd_10_cm as {{ dbt.type_string() }} ) as normalized_code\n , cast(icd.long_description as {{ dbt.type_string() }} ) as normalized_description\n , cast(unpivot_cte.diagnosis_rank as {{ dbt.type_int() }} ) as condition_rank\n , cast(unpivot_cte.present_on_admit_code as {{ dbt.type_string() }} ) as present_on_admit_code\n , cast(poa.present_on_admit_description as {{ dbt.type_string() }} ) as present_on_admit_description\n , cast(unpivot_cte.data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom unpivot_cte\n--inner join {{ ref('encounters__combined_claim_line_crosswalk') }} x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join {{ ref('terminology__icd_10_cm') }} icd\n on unpivot_cte.source_code = icd.icd_10_cm\nleft join {{ ref('terminology__present_on_admission') }} as poa\n on unpivot_cte.present_on_admit_code = poa.present_on_admit_code", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__present_on_admission", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.safe_cast", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__present_on_admission"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_condition.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the condition table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_1 as source_code\n , 1 as diagnosis_rank\n , diagnosis_poa_1 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere diagnosis_code_1 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n\t , discharge_date\n\t , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_2 as source_code\n , 2 as diagnosis_rank\n , diagnosis_poa_2 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_2 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_3 as source_code\n , 3 as diagnosis_rank\n , diagnosis_poa_3 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_3 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_4 as source_code\n , 4 as diagnosis_rank\n , diagnosis_poa_4 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_4 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_5 as source_code\n , 5 as diagnosis_rank\n , diagnosis_poa_5 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_5 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_6 as source_code\n , 6 as diagnosis_rank\n , diagnosis_poa_6 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_6 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_7 as source_code\n , 7 as diagnosis_rank\n , diagnosis_poa_7 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_7 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_8 as source_code\n , 8 as diagnosis_rank\n , diagnosis_poa_8 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_8 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_9 as source_code\n , 9 as diagnosis_rank\n , diagnosis_poa_9 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_9 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_10 as source_code\n , 10 as diagnosis_rank\n , diagnosis_poa_10 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_10 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_11 as source_code\n , 11 as diagnosis_rank\n , diagnosis_poa_11 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_11 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_12 as source_code\n , 12 as diagnosis_rank\n , diagnosis_poa_12 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_12 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_13 as source_code\n , 13 as diagnosis_rank\n , diagnosis_poa_13 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_13 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_14 as source_code\n , 14 as diagnosis_rank\n , diagnosis_poa_14 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_14 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_15 as source_code\n , 15 as diagnosis_rank\n , diagnosis_poa_15 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_15 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_16 as source_code\n , 16 as diagnosis_rank\n , diagnosis_poa_16 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_16 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_17 as source_code\n , 17 as diagnosis_rank\n , diagnosis_poa_17 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_17 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_18 as source_code\n , 18 as diagnosis_rank\n , diagnosis_poa_18 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_18 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_19 as source_code\n , 19 as diagnosis_rank\n , diagnosis_poa_19 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_19 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_20 as source_code\n , 20 as diagnosis_rank\n , diagnosis_poa_20 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_20 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_21 as source_code\n , 21 as diagnosis_rank\n , diagnosis_poa_21 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_21 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_22 as source_code\n , 22 as diagnosis_rank\n , diagnosis_poa_22 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_22 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_23 as source_code\n , 23 as diagnosis_rank\n , diagnosis_poa_23 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_23 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_24 as source_code\n , 24 as diagnosis_rank\n , diagnosis_poa_24 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_24 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_25 as source_code\n , 25 as diagnosis_rank\n , diagnosis_poa_25 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(CAST(unpivot_cte.data_source AS TEXT) || '_' || CAST(unpivot_cte.claim_id AS TEXT) || '_' || CAST(unpivot_cte.diagnosis_rank AS TEXT) || '_' || CAST(unpivot_cte.source_code AS TEXT) as TEXT)\n as condition_id\n\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.recorded_date as date ) as recorded_date\n , try_cast( null as date ) as onset_date\n , try_cast( null as date ) as resolved_date\n , cast('active' as TEXT ) as status\n , cast(unpivot_cte.condition_type as TEXT ) as condition_type\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_cm is not null then 'icd-10-cm'\n end as TEXT\n ) as normalized_code_type\n , cast(icd.icd_10_cm as TEXT ) as normalized_code\n , cast(icd.long_description as TEXT ) as normalized_description\n , cast(unpivot_cte.diagnosis_rank as integer ) as condition_rank\n , cast(unpivot_cte.present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(poa.present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join cms_synthetic.terminology.icd_10_cm icd\n on unpivot_cte.source_code = icd.icd_10_cm\nleft join cms_synthetic.terminology.present_on_admission as poa\n on unpivot_cte.present_on_admit_code = poa.present_on_admit_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_lab_result": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_lab_result.sql", "original_file_path": "models/core/staging/core__stg_clinical_lab_result.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_lab_result", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_lab_result"], "alias": "core__stg_clinical_lab_result", "checksum": {"name": "sha256", "checksum": "5d7373fe2063ff38eba1c2cb5ba4cd7b13fdbd88375106439eb0e47fe709aeda"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.225984, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_lab_result", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nselect\n cast(lab_result_id as {{ dbt.type_string() }} ) as lab_result_id\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\n , cast(accession_number as {{ dbt.type_string() }} ) as accession_number\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\n , cast(source_component as {{ dbt.type_string() }} ) as source_component\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\n , cast(normalized_component as {{ dbt.type_string() }} ) as normalized_component\n , cast(status as {{ dbt.type_string() }} ) as status\n , cast(result as {{ dbt.type_string() }} ) as result\n , {{ try_to_cast_date('result_date', 'YYYY-MM-DD') }} as result_date\n , {{ try_to_cast_date('collection_date', 'YYYY-MM-DD') }} as collection_date\n , cast(source_units as {{ dbt.type_string() }} ) as source_units\n , cast(normalized_units as {{ dbt.type_string() }} ) as normalized_units\n , cast(source_reference_range_low as {{ dbt.type_string() }} ) as source_reference_range_low\n , cast(source_reference_range_high as {{ dbt.type_string() }} ) as source_reference_range_high\n , cast(normalized_reference_range_low as {{ dbt.type_string() }} ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as {{ dbt.type_string() }} ) as normalized_reference_range_high\n , cast(source_abnormal_flag as {{ dbt.type_string() }} ) as source_abnormal_flag\n , cast(normalized_abnormal_flag as {{ dbt.type_string() }} ) as normalized_abnormal_flag\n , cast(specimen as {{ dbt.type_string() }} ) as specimen\n , cast(ordering_practitioner_id as {{ dbt.type_string() }} ) as ordering_practitioner_id\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('lab_result') }}", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_lab_result.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(lab_result_id as TEXT ) as lab_result_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(accession_number as TEXT ) as accession_number\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(source_component as TEXT ) as source_component\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(normalized_component as TEXT ) as normalized_component\n , cast(status as TEXT ) as status\n , cast(result as TEXT ) as result\n , try_cast( result_date as date ) as result_date\n , try_cast( collection_date as date ) as collection_date\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(source_abnormal_flag as TEXT ) as source_abnormal_flag\n , cast(normalized_abnormal_flag as TEXT ) as normalized_abnormal_flag\n , cast(specimen as TEXT ) as specimen\n , cast(ordering_practitioner_id as TEXT ) as ordering_practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.lab_result", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_practitioner": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_practitioner", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_practitioner.sql", "original_file_path": "models/core/staging/core__stg_clinical_practitioner.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_practitioner", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_practitioner"], "alias": "core__stg_clinical_practitioner", "checksum": {"name": "sha256", "checksum": "55a38ade4c23cfcc0b7ecfe23f4591f7f7a23bbe5b32c3bd698eb96cd3183289"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.233334, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_practitioner", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nselect\n cast(practitioner_id as {{ dbt.type_string() }} ) as practitioner_id\n , cast(npi as {{ dbt.type_string() }} ) as npi\n , cast(first_name as {{ dbt.type_string() }} ) as first_name\n , cast(last_name as {{ dbt.type_string() }} ) as last_name\n , cast(practice_affiliation as {{ dbt.type_string() }} ) as practice_affiliation\n , cast(specialty as {{ dbt.type_string() }} ) as specialty\n , cast(sub_specialty as {{ dbt.type_string() }} ) as sub_specialty\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('practitioner') }}", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_practitioner.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(practitioner_id as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(practice_affiliation as TEXT ) as practice_affiliation\n , cast(specialty as TEXT ) as specialty\n , cast(sub_specialty as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.practitioner", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_pharmacy_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_pharmacy_claim.sql", "original_file_path": "models/core/staging/core__stg_claims_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.core__stg_claims_pharmacy_claim", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_pharmacy_claim"], "alias": "core__stg_claims_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "4eb32ea9a6b0e6eb5983809115d34d621b217a5bbb92dc9a005ba68622ac278e"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.23824, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the pharmacy_claim\n-- table in core.\n-- *************************************************\n\n\n\n\nselect\n {{ dbt.concat([\n \"cast(claim_id as \" ~ dbt.type_string() ~ \")\",\n \"'-'\",\n \"cast(claim_line_number as \" ~ dbt.type_string() ~ \")\"\n ]) }} as pharmacy_claim_id\n , cast(claim_id as {{ dbt.type_string() }} ) as claim_id\n , cast(claim_line_number as integer ) as claim_line_number\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(member_id as {{ dbt.type_string() }} ) as member_id\n , cast(payer as {{ dbt.type_string() }} ) as payer\n , {{ quote_column('plan') }}\n , cast(prescribing_provider_id as {{ dbt.type_string() }} ) as prescribing_provider_id\n , cast(prescribing_provider_name as {{ dbt.type_string() }} ) as prescribing_provider_name\n , cast(dispensing_provider_id as {{ dbt.type_string() }} ) as dispensing_provider_id\n , cast(dispensing_provider_name as {{ dbt.type_string() }} ) as dispensing_provider_name\n , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as {{ dbt.type_string() }} ) as ndc_code\n , cast(ndc_description as {{ dbt.type_string() }} ) as ndc_description\n , cast(quantity as integer ) as quantity\n , cast(days_supply as integer ) as days_supply\n , cast(refills as integer ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as {{ dbt.type_numeric() }}) as paid_amount\n , cast(allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\n , cast(charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\n , cast(coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\n , cast(copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\n , cast(deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__pharmacy_claim') }} pharm", "language": "sql", "refs": [{"name": "normalized_input__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.the_tuva_project.quote_column", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.normalized_input__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the pharmacy_claim\n-- table in core.\n-- *************************************************\n\n\n\n\nselect\n cast(claim_id as TEXT) || '-' || cast(claim_line_number as TEXT) as pharmacy_claim_id\n , cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as integer ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , plan\n , cast(prescribing_provider_id as TEXT ) as prescribing_provider_id\n , cast(prescribing_provider_name as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_id as TEXT ) as dispensing_provider_id\n , cast(dispensing_provider_name as TEXT ) as dispensing_provider_name\n , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(quantity as integer ) as quantity\n , cast(days_supply as integer ) as days_supply\n , cast(refills as integer ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6)) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_pharmacy_claim pharm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_location": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_location", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_location.sql", "original_file_path": "models/core/staging/core__stg_clinical_location.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_location", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_location"], "alias": "core__stg_clinical_location", "checksum": {"name": "sha256", "checksum": "6a259b80d51e583fc2fbedac359791c1461e2f34e9b72802d2b4e40d81d027f4"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.244739, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_location", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\nselect\r\n cast(location_id as {{ dbt.type_string() }} ) as location_id\r\n , cast(npi as {{ dbt.type_string() }} ) as npi\r\n , cast(name as {{ dbt.type_string() }} ) as name\r\n , cast(facility_type as {{ dbt.type_string() }} ) as facility_type\r\n , cast(parent_organization as {{ dbt.type_string() }} ) as parent_organization\r\n , cast(address as {{ dbt.type_string() }} ) as address\r\n , cast(city as {{ dbt.type_string() }} ) as city\r\n , cast(state as {{ dbt.type_string() }} ) as state\r\n , cast(zip_code as {{ dbt.type_string() }} ) as zip_code\r\n , cast(latitude as {{ dbt.type_float() }} ) as latitude\r\n , cast(longitude as {{ dbt.type_float() }} ) as longitude\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('location') }}", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_location.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(location_id as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(name as TEXT ) as name\n , cast(facility_type as TEXT ) as facility_type\n , cast(parent_organization as TEXT ) as parent_organization\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.location", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_patient": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_claims_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_claims_patient.sql", "original_file_path": "models/core/staging/core__stg_claims_patient.sql", "unique_id": "model.the_tuva_project.core__stg_claims_patient", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_patient"], "alias": "core__stg_claims_patient", "checksum": {"name": "sha256", "checksum": "5340b4300b894372056d19d2f11429c48f864aefa2e9334720875fe3ac11a32e"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.249943, "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_patient", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n-- *************************************************\n-- This dbt model creates the patient table in core.\n-- *************************************************\n\nwith patient_stage as(\n select\n patient_id\n ,first_name\n ,last_name\n ,gender\n ,race\n ,birth_date\n ,death_date\n ,death_flag\n ,social_security_number\n ,address\n ,city\n ,state\n ,zip_code\n ,phone\n ,data_source\n ,row_number() over (\n\t partition by patient_id\n\t order by case when enrollment_end_date is null\n then cast ('2050-01-01' as date)\n else enrollment_end_date end DESC)\n as row_sequence\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }}) as tuva_last_run_datetime\n , cast(substring('{{ var('tuva_last_run')}}',1,10) as date) as tuva_last_run_date\n from {{ ref('normalized_input__eligibility')}}\n)\n\nselect\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(first_name as {{ dbt.type_string() }}) as first_name\n , cast(last_name as {{ dbt.type_string() }}) as last_name\n , cast(gender as {{ dbt.type_string() }}) as sex\n , cast(race as {{ dbt.type_string() }}) as race\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(death_flag as int) as death_flag\n , cast(social_security_number as {{ dbt.type_string() }}) as social_security_number\n , cast(address as {{ dbt.type_string() }}) as address\n , cast(city as {{ dbt.type_string() }}) as city\n , cast(state as {{ dbt.type_string() }}) as state\n , cast(zip_code as {{ dbt.type_string() }}) as zip_code\n , cast(null as {{ dbt.type_string() }}) as county\n , cast(null as {{ dbt.type_float() }}) as latitude \n , cast(null as {{ dbt.type_float() }}) as longitude\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) as age\n , cast(\n CASE\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 10 THEN '0-9'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 20 THEN '10-19'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 30 THEN '20-29'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 40 THEN '30-39'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 50 THEN '40-49'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 60 THEN '50-59'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 70 THEN '60-69'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 80 THEN '70-79'\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 90 THEN '80-89'\n ELSE '90+'\n END as {{ dbt.type_string() }}\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nfrom patient_stage\nwhere row_sequence = 1", "language": "sql", "refs": [{"name": "normalized_input__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_timestamp", "macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.datediff", "macro.dbt.type_int"], "nodes": ["model.the_tuva_project.normalized_input__eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_claims_patient.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the patient table in core.\n-- *************************************************\n\nwith patient_stage as(\n select\n patient_id\n ,first_name\n ,last_name\n ,gender\n ,race\n ,birth_date\n ,death_date\n ,death_flag\n ,social_security_number\n ,address\n ,city\n ,state\n ,zip_code\n ,phone\n ,data_source\n ,row_number() over (\n\t partition by patient_id\n\t order by case when enrollment_end_date is null\n then cast ('2050-01-01' as date)\n else enrollment_end_date end DESC)\n as row_sequence\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp) as tuva_last_run_datetime\n , cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run_date\n from cms_synthetic.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(first_name as TEXT) as first_name\n , cast(last_name as TEXT) as last_name\n , cast(gender as TEXT) as sex\n , cast(race as TEXT) as race\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(death_flag as int) as death_flag\n , cast(social_security_number as TEXT) as social_security_number\n , cast(address as TEXT) as address\n , cast(city as TEXT) as city\n , cast(state as TEXT) as state\n , cast(zip_code as TEXT) as zip_code\n , cast(null as TEXT) as county\n , cast(null as float) as latitude \n , cast(null as float) as longitude\n , cast(data_source as TEXT) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nfrom patient_stage\nwhere row_sequence = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_observation": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "core__stg_clinical_observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/staging/core__stg_clinical_observation.sql", "original_file_path": "models/core/staging/core__stg_clinical_observation.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_observation", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_observation"], "alias": "core__stg_clinical_observation", "checksum": {"name": "sha256", "checksum": "0883430fec826dcbde173bb71611419df7dc969e19e22a50636d79b0b3cd6114"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623952.2612522, "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_observation", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n\nselect\n cast(observation_id as {{ dbt.type_string() }} ) as observation_id\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\n , cast(panel_id as {{ dbt.type_string() }} ) as panel_id\n , {{ try_to_cast_date('observation_date', 'YYYY-MM-DD') }} as observation_date\n , cast(observation_type as {{ dbt.type_string() }} ) as observation_type\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\n , cast(result as {{ dbt.type_string() }} ) as result\n , cast(source_units as {{ dbt.type_string() }} ) as source_units\n , cast(normalized_units as {{ dbt.type_string() }} ) as normalized_units\n , cast(source_reference_range_low as {{ dbt.type_string() }} ) as source_reference_range_low\n , cast(source_reference_range_high as {{ dbt.type_string() }} ) as source_reference_range_high\n , cast(normalized_reference_range_low as {{ dbt.type_string() }} ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as {{ dbt.type_string() }} ) as normalized_reference_range_high\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('observation') }}", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/staging/core__stg_clinical_observation.sql", "compiled": true, "compiled_code": "\n\n\nselect\n cast(observation_id as TEXT ) as observation_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(panel_id as TEXT ) as panel_id\n , try_cast( observation_date as date ) as observation_date\n , cast(observation_type as TEXT ) as observation_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(result as TEXT ) as result\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.observation", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__pharmacy_claim": {"database": "cms_synthetic", "schema": "core", "name": "core__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__pharmacy_claim.sql", "original_file_path": "models/core/final/core__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.core__pharmacy_claim", "fqn": ["the_tuva_project", "core", "final", "core__pharmacy_claim"], "alias": "pharmacy_claim", "checksum": {"name": "sha256", "checksum": "78711b940ffc41f4aa9dcdc0eafd9d8d8753cc313dec22d5282e7b10936dce37"}, "config": {"enabled": true, "alias": "pharmacy_claim", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The pharmacy claim table contains information on prescription drugs that were filled and billed to the insurer.\n", "columns": {"pharmacy_claim_id": {"name": "pharmacy_claim_id", "description": "Unique identifier for each row in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_id": {"name": "prescribing_provider_id", "description": "ID for the provider that wrote the prescription (e.g. priamry care physician).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_name": {"name": "prescribing_provider_name", "description": "Prescribing provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_id": {"name": "dispensing_provider_id", "description": "ID for the provider that dispensed the prescription (e.g. pharmacy).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_name": {"name": "dispensing_provider_name", "description": "Dispensing provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code associated with the medication.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description for the NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "The quantity of the medication.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "The number of days supply included.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the prescription.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "pharmacy_claim", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.815792, "relation_name": "cms_synthetic.core.pharmacy_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\nselect * from {{ ref('core__stg_claims_pharmacy_claim')}}", "language": "sql", "refs": [{"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__condition": {"database": "cms_synthetic", "schema": "core", "name": "core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__condition.sql", "original_file_path": "models/core/final/core__condition.sql", "unique_id": "model.the_tuva_project.core__condition", "fqn": ["the_tuva_project", "core", "final", "core__condition"], "alias": "condition", "checksum": {"name": "sha256", "checksum": "6d0556c1f5cc235e0947169ff246e7f4831bbc79388f06857c162749b25226f0"}, "config": {"enabled": true, "alias": "condition", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The core condition table contains information related to medical conditions patients have, including problems, admitting diagnosis codes, and billable diagnosis codes.\n", "columns": {"condition_id": {"name": "condition_id", "description": "Unique identifier for each condition in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date when the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "onset_date": {"name": "onset_date", "description": "Date when the condition first occurred.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "resolved_date": {"name": "resolved_date", "description": "Date when the condition was resolved.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of the record (e.g., condition, test, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition i.e. problem, admitting, or billing.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "The numerical ranking of a diagnosis code in a claim. Principle diagnosis code is given a ranking of 1. Claims data typically has a strict ranking of conditions whereas medical records will often not have this information or the information won't be accurate.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "present_on_admit_code": {"name": "present_on_admit_code", "description": "The present_on_admit_code related to the condition.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "present_on_admit_description": {"name": "present_on_admit_description", "description": "The description of the present_on_admit_code for the condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "condition", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.790855, "relation_name": "cms_synthetic.core.condition", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith all_conditions as (\n {% if var('clinical_enabled'\n , var('tuva_marts_enabled'\n , False)) == true and var('claims_enabled'\n , var('tuva_marts_enabled'\n , False)) == true -%}\n\nselect *\nfrom {{ ref('core__stg_claims_condition') }}\nunion all\nselect *\nfrom {{ ref('core__stg_clinical_condition') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect *\nfrom {{ ref('core__stg_clinical_condition') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect *\nfrom {{ ref('core__stg_claims_condition') }}\n\n{%- endif %}\n)\n\n\n{# is the default code that gets executed as long as an enable_normalize_engine var is false or not defined #}\n{% if var('enable_normalize_engine',false) != true %}\nselect\n all_conditions.condition_id\n , all_conditions.patient_id\n , all_conditions.encounter_id\n , all_conditions.claim_id\n , all_conditions.recorded_date\n , all_conditions.onset_date\n , all_conditions.resolved_date\n , all_conditions.status\n , all_conditions.condition_type\n , all_conditions.source_code_type\n , all_conditions.source_code\n , all_conditions.source_description\n , case\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\n when icd10.icd_10_cm is not null then 'icd-10-cm'\n when icd9.icd_9_cm is not null then 'icd-9-cm'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n all_conditions.normalized_code\n , icd10.icd_10_cm\n , icd9.icd_9_cm\n , snomed_ct.snomed_ct) as normalized_code\n , coalesce(\n all_conditions.normalized_description\n , icd10.short_description\n , icd9.short_description\n , snomed_ct.description) as normalized_description\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_conditions.condition_rank\n , all_conditions.present_on_admit_code\n , all_conditions.present_on_admit_description\n , all_conditions.data_source\n , all_conditions.tuva_last_run\nfrom\nall_conditions\nleft join {{ ref('terminology__icd_10_cm') }} icd10\n on all_conditions.source_code_type = 'icd-10-cm'\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\nleft join {{ ref('terminology__icd_9_cm') }} icd9\n on all_conditions.source_code_type = 'icd-9-cm'\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\nleft join {{ ref('terminology__snomed_ct') }} snomed_ct\n on all_conditions.source_code_type = 'snomed-ct'\n and all_conditions.source_code = snomed_ct.snomed_ct\n\n\n\n{# This code is only exectued if an enable_normalize_engine var is defined and set to true\n it expects a seed file called #}\n{% else %}\nselect\n all_conditions.condition_id\n , all_conditions.patient_id\n , all_conditions.encounter_id\n , all_conditions.claim_id\n , all_conditions.recorded_date\n , all_conditions.onset_date\n , all_conditions.resolved_date\n , all_conditions.status\n , all_conditions.condition_type\n , all_conditions.source_code_type\n , all_conditions.source_code\n , all_conditions.source_description\n , case\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\n when icd10.icd_10_cm is not null then 'icd-10-cm'\n when icd9.icd_9_cm is not null then 'icd-9-cm'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else custom_mapped.normalized_code_type end as normalized_code_type\n , coalesce(\n all_conditions.normalized_code\n , icd10.icd_10_cm\n , icd9.icd_9_cm\n , snomed_ct.snomed_ct\n , custom_mapped.normalized_code\n ) as NORMALIZED_CODE\n , coalesce(\n all_conditions.normalized_description\n , icd10.short_description\n , icd9.short_description\n , snomed_ct.description\n , custom_mapped.normalized_description\n ) as normalized_description\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\n end as mapping_method\n , all_conditions.condition_rank\n , all_conditions.present_on_admit_code\n , all_conditions.present_on_admit_description\n , all_conditions.data_source\n , all_conditions.tuva_last_run\nfrom\nall_conditions\nleft join {{ ref('terminology__icd_10_cm') }} icd10\n on all_conditions.source_code_type = 'icd-10-cm'\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\nleft join {{ ref('terminology__icd_9_cm') }} icd9\n on all_conditions.source_code_type = 'icd-9-cm'\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\nleft join {{ ref('terminology__snomed_ct') }} snomed_ct\n on all_conditions.source_code_type = 'snomed-ct'\n and all_conditions.source_code = snomed_ct.snomed_ct\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(all_conditions.source_code_type) = lower(custom_mapped.source_code_type)\n or ( all_conditions.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (all_conditions.source_code = custom_mapped.source_code\n or ( all_conditions.source_code is null and custom_mapped.source_code is null)\n )\n and (all_conditions.source_description = custom_mapped.source_description\n or ( all_conditions.source_description is null and custom_mapped.source_description is null)\n )\n and not (all_conditions.source_code is null and all_conditions.source_description is null)\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_condition", "package": null, "version": null}, {"name": "core__stg_clinical_condition", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_clinical_condition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__snomed_ct"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__condition.sql", "compiled": true, "compiled_code": "\n\n\nwith all_conditions as (\n select *\nfrom cms_synthetic.dbt_tom.core__stg_claims_condition\nunion all\nselect *\nfrom cms_synthetic.dbt_tom.core__stg_clinical_condition\n\n\n)\n\n\n\n\nselect\n all_conditions.condition_id\n , all_conditions.patient_id\n , all_conditions.encounter_id\n , all_conditions.claim_id\n , all_conditions.recorded_date\n , all_conditions.onset_date\n , all_conditions.resolved_date\n , all_conditions.status\n , all_conditions.condition_type\n , all_conditions.source_code_type\n , all_conditions.source_code\n , all_conditions.source_description\n , case\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\n when icd10.icd_10_cm is not null then 'icd-10-cm'\n when icd9.icd_9_cm is not null then 'icd-9-cm'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n all_conditions.normalized_code\n , icd10.icd_10_cm\n , icd9.icd_9_cm\n , snomed_ct.snomed_ct) as normalized_code\n , coalesce(\n all_conditions.normalized_description\n , icd10.short_description\n , icd9.short_description\n , snomed_ct.description) as normalized_description\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_conditions.condition_rank\n , all_conditions.present_on_admit_code\n , all_conditions.present_on_admit_description\n , all_conditions.data_source\n , all_conditions.tuva_last_run\nfrom\nall_conditions\nleft join cms_synthetic.terminology.icd_10_cm icd10\n on all_conditions.source_code_type = 'icd-10-cm'\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\nleft join cms_synthetic.terminology.icd_9_cm icd9\n on all_conditions.source_code_type = 'icd-9-cm'\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on all_conditions.source_code_type = 'snomed-ct'\n and all_conditions.source_code = snomed_ct.snomed_ct\n\n\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__patient": {"database": "cms_synthetic", "schema": "core", "name": "core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__patient.sql", "original_file_path": "models/core/final/core__patient.sql", "unique_id": "model.the_tuva_project.core__patient", "fqn": ["the_tuva_project", "core", "final", "core__patient"], "alias": "patient", "checksum": {"name": "sha256", "checksum": "91ee630a4a580f22cbd30dd748007dbe543ffc36b46d4c4e4b70a3fac167275f"}, "config": {"enabled": true, "alias": "patient", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The patient table contains demographic and geographic information on patients.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "A flag indicating if the patient has died.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "The first name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "The last name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "The social security number of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The street address of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "county": {"name": "county", "description": "The county for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "phone": {"name": "phone", "description": "The phone number for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "The age of the patient calculated based on their date of birth and the last time the tuva project was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "The decade age group the patient falls into based on their calculated age.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "patient", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.8133519, "relation_name": "cms_synthetic.core.patient", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_patient') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_patient') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_patient') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_patient') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_patient", "package": null, "version": null}, {"name": "core__stg_clinical_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_patient", "model.the_tuva_project.core__stg_clinical_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__patient.sql", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_patient\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_patient\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__lab_result": {"database": "cms_synthetic", "schema": "core", "name": "core__lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__lab_result.sql", "original_file_path": "models/core/final/core__lab_result.sql", "unique_id": "model.the_tuva_project.core__lab_result", "fqn": ["the_tuva_project", "core", "final", "core__lab_result"], "alias": "lab_result", "checksum": {"name": "sha256", "checksum": "e9d3a7df14dc938be4a6595be5350cbdb215507d5ea5f8c7f2a7e5f62c1bfe5c"}, "config": {"enabled": true, "alias": "lab_result", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The lab result table contains information about lab test results, including the LOINC code and description, units, reference range, and result.\n", "columns": {"lab_result_id": {"name": "lab_result_id", "description": "Unique identifier for each lab result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "accession_number": {"name": "accession_number", "description": "The lab order number from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_component": {"name": "source_component", "description": "The description for the component of the test from the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_component": {"name": "normalized_component", "description": "The normalized component.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of the record (e.g., condition, test, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the record (e.g., lab test, observation, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "collection_date": {"name": "collection_date", "description": "Date the test was collected.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_abnormal_flag": {"name": "source_abnormal_flag", "description": "Indicates whether the result is abnormal or normal.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_abnormal_flag": {"name": "normalized_abnormal_flag", "description": "Normalized abnormal flag.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specimen": {"name": "specimen", "description": "The type of specimen e.g. blood, plasma, urine.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ordering_practitioner_id": {"name": "ordering_practitioner_id", "description": "Unique identifier for the practitioner who ordered the lab test.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "lab_result", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.799765, "relation_name": "cms_synthetic.core.lab_result", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) != true %}\n\n\nselect\n labs.lab_result_id\n , labs.patient_id\n , labs.encounter_id\n , labs.accession_number\n , labs.source_code_type\n , labs.source_code\n , labs.source_description\n , labs.source_component\n , case\n when labs.normalized_code_type is not null then labs.normalized_code_type\n when loinc.loinc is not null then 'loinc'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n labs.normalized_code\n , loinc.loinc\n , snomed_ct.snomed_ct\n ) as normalized_code\n , coalesce(\n labs.normalized_description\n , loinc.long_common_name\n , snomed_ct.description\n ) normalized_description\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , labs.normalized_component\n , labs.status\n , labs.result\n , labs.result_date\n , labs.collection_date\n , labs.source_units\n , labs.normalized_units\n , labs.source_reference_range_low\n , labs.source_reference_range_high\n , labs.normalized_reference_range_low\n , labs.normalized_reference_range_high\n , labs.source_abnormal_flag\n , labs.normalized_abnormal_flag\n , labs.specimen\n , labs.ordering_practitioner_id\n , labs.data_source\n , labs.tuva_last_run\nFrom {{ ref('core__stg_clinical_lab_result')}} as labs\nleft join {{ ref('terminology__loinc') }} loinc\n on labs.source_code_type = 'loinc'\n and labs.source_code = loinc.loinc\nleft join {{ref('terminology__snomed_ct')}} snomed_ct\n on labs.source_code_type = 'snomed-ct'\n and labs.source_code = snomed_ct.snomed_ct\n\n {% else %}\n\nselect\n labs.lab_result_id\n , labs.patient_id\n , labs.encounter_id\n , labs.accession_number\n , labs.source_code_type\n , labs.source_code\n , labs.source_description\n , labs.source_component\n , case\n when labs.normalized_code_type is not null then labs.normalized_code_type\n when loinc.loinc is not null then 'loinc'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else custom_mapped.normalized_code_type end as normalized_code_type\n , coalesce(\n labs.normalized_code\n , loinc.loinc\n , snomed_ct.snomed_ct\n , custom_mapped.normalized_code\n ) as normalized_code\n , coalesce(\n labs.normalized_description\n , loinc.long_common_name\n , snomed_ct.description\n , custom_mapped.normalized_description\n ) normalized_description\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\n end as mapping_method\n , labs.normalized_component\n , labs.status\n , labs.result\n , labs.result_date\n , labs.collection_date\n , labs.source_units\n , labs.normalized_units\n , labs.source_reference_range_low\n , labs.source_reference_range_high\n , labs.normalized_reference_range_low\n , labs.normalized_reference_range_high\n , labs.source_abnormal_flag\n , labs.normalized_abnormal_flag\n , labs.specimen\n , labs.ordering_practitioner_id\n , labs.data_source\n , labs.tuva_last_run\nFrom {{ ref('core__stg_clinical_lab_result')}} as labs\nleft join {{ ref('terminology__loinc') }} loinc\n on labs.source_code_type = 'loinc'\n and labs.source_code = loinc.loinc\nleft join {{ref('terminology__snomed_ct')}} snomed_ct\n on labs.source_code_type = 'snomed-ct'\n and labs.source_code = snomed_ct.snomed_ct\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(labs.source_code_type) = lower(custom_mapped.source_code_type)\n or ( labs.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (labs.source_code = custom_mapped.source_code\n or ( labs.source_code is null and custom_mapped.source_code is null)\n )\n and (labs.source_description = custom_mapped.source_description\n or ( labs.source_description is null and custom_mapped.source_description is null)\n )\n and not (labs.source_code is null and labs.source_description is null)\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_clinical_lab_result", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_clinical_lab_result", "seed.the_tuva_project.terminology__loinc", "seed.the_tuva_project.terminology__snomed_ct"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__lab_result.sql", "compiled": true, "compiled_code": "\n\n\n\n\nselect\n labs.lab_result_id\n , labs.patient_id\n , labs.encounter_id\n , labs.accession_number\n , labs.source_code_type\n , labs.source_code\n , labs.source_description\n , labs.source_component\n , case\n when labs.normalized_code_type is not null then labs.normalized_code_type\n when loinc.loinc is not null then 'loinc'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n labs.normalized_code\n , loinc.loinc\n , snomed_ct.snomed_ct\n ) as normalized_code\n , coalesce(\n labs.normalized_description\n , loinc.long_common_name\n , snomed_ct.description\n ) normalized_description\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , labs.normalized_component\n , labs.status\n , labs.result\n , labs.result_date\n , labs.collection_date\n , labs.source_units\n , labs.normalized_units\n , labs.source_reference_range_low\n , labs.source_reference_range_high\n , labs.normalized_reference_range_low\n , labs.normalized_reference_range_high\n , labs.source_abnormal_flag\n , labs.normalized_abnormal_flag\n , labs.specimen\n , labs.ordering_practitioner_id\n , labs.data_source\n , labs.tuva_last_run\nFrom cms_synthetic.dbt_tom.core__stg_clinical_lab_result as labs\nleft join cms_synthetic.terminology.loinc loinc\n on labs.source_code_type = 'loinc'\n and labs.source_code = loinc.loinc\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on labs.source_code_type = 'snomed-ct'\n and labs.source_code = snomed_ct.snomed_ct\n\n ", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__encounter": {"database": "cms_synthetic", "schema": "core", "name": "core__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__encounter.sql", "original_file_path": "models/core/final/core__encounter.sql", "unique_id": "model.the_tuva_project.core__encounter", "fqn": ["the_tuva_project", "core", "final", "core__encounter"], "alias": "encounter", "checksum": {"name": "sha256", "checksum": "f3ede0cd925bb9587f658532dc4ab2f3d92bdf5a24983bdc301855cf0f5750f8"}, "config": {"enabled": true, "alias": "encounter", "schema": "core", "database": null, "tags": ["core", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core", "encounters"], "description": "The encounter table contains information about patients visits (i.e. encounters). This includes acute inpatient, emergency department, office visits, SNF stays, etc.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__encounter_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_id": {"name": "attending_provider_id", "description": "ID for the attending provider on the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_name": {"name": "attending_provider_name", "description": "Name of the attending provider on the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_model": {"name": "source_model", "description": "Indicates the DBT source relation name from which data is derived.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_source_type": {"name": "encounter_source_type", "description": "Indicates whether the encounter is from a claims or clinical data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "encounter", "tags": ["core", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.797886, "relation_name": "cms_synthetic.core.encounter", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n{% if var('clinical_enabled', false) == true and var('claims_enabled', false) == true -%}\n\nselect *\n,'claim' as encounter_source_type\n from {{ ref('core__stg_claims_encounter') }}\nunion all\n\nselect *\n,'clinical' as encounter_source_type\n from {{ ref('core__stg_clinical_encounter') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect *\n,'clinical' as encounter_source_type\n from {{ ref('core__stg_clinical_encounter') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect *\n,'claim' as encounter_source_type from {{ ref('core__stg_claims_encounter') }}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_encounter", "package": null, "version": null}, {"name": "core__stg_clinical_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_encounter", "model.the_tuva_project.core__stg_clinical_encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__encounter.sql", "compiled": true, "compiled_code": "\n\nselect *\n,'claim' as encounter_source_type\n from cms_synthetic.dbt_tom.core__stg_claims_encounter\nunion all\n\nselect *\n,'clinical' as encounter_source_type\n from cms_synthetic.dbt_tom.core__stg_clinical_encounter\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__eligibility": {"database": "cms_synthetic", "schema": "core", "name": "core__eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__eligibility.sql", "original_file_path": "models/core/final/core__eligibility.sql", "unique_id": "model.the_tuva_project.core__eligibility", "fqn": ["the_tuva_project", "core", "final", "core__eligibility"], "alias": "eligibility", "checksum": {"name": "sha256", "checksum": "40a7e07c415aa12f2c27b6cd23f2eb48368e6cfd79f21df4312e297abdbf0941"}, "config": {"enabled": true, "alias": "eligibility", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The eligibility table contains information on patient health plan and supplemental insurance eligibility.\n", "columns": {"eligibility_id": {"name": "eligibility_id", "description": "Unique identifier for each eligibility row in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_id": {"name": "subscriber_id", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_type": {"name": "payer_type", "description": "Type of payer (e.g. commercial, medicare, medicaid, etc.).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__payer_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "Original reason for Medicare entitlement code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_relation": {"name": "subscriber_relation", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "eligibility", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.792784, "relation_name": "cms_synthetic.core.eligibility", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect * from {{ ref('core__stg_claims_eligibility')}}", "language": "sql", "refs": [{"name": "core__stg_claims_eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__eligibility.sql", "compiled": true, "compiled_code": "\n\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__procedure": {"database": "cms_synthetic", "schema": "core", "name": "core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__procedure.sql", "original_file_path": "models/core/final/core__procedure.sql", "unique_id": "model.the_tuva_project.core__procedure", "fqn": ["the_tuva_project", "core", "final", "core__procedure"], "alias": "procedure", "checksum": {"name": "sha256", "checksum": "5149c080cafac2124ea40eea191ce7443af99ba3c4dd9329d49e7c1f888433cc"}, "config": {"enabled": true, "alias": "procedure", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The procedure table contains information on procedures that were performed on patients in the dataset.\n", "columns": {"procedure_id": {"name": "procedure_id", "description": "The unique identifier for the performed procedure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date": {"name": "procedure_date", "description": "Date when the procedure was performed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_1": {"name": "modifier_1", "description": "First modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_2": {"name": "modifier_2", "description": "Second modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_3": {"name": "modifier_3", "description": "Third modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_4": {"name": "modifier_4", "description": "Fourth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_5": {"name": "modifier_5", "description": "Fifth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "core__stg_claims_medical_claim": {"name": "core__stg_claims_medical_claim", "description": "Staging core medical claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_medical_claim", "tags": ["core_stage_claims", "encounters"], "materialized": "table"}}, "core__stg_claims_encounter": {"name": "core__stg_claims_encounter", "description": "Staging core claims encounters", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_encounter", "tags": ["core_stage_claims", "encounters"], "materialized": "table"}}, "core__stg_claims_location": {"name": "core__stg_claims_location", "description": "Staging core claims locations", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_location", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_patient": {"name": "core__stg_claims_patient", "description": "Staging core claims patients", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_patient", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_condition": {"name": "core__stg_claims_condition", "description": "Staging core claims conditions", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_condition", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_procedure": {"name": "core__stg_claims_procedure", "description": "Staging core claims procedures", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_procedure", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_pharmacy_claim": {"name": "core__stg_claims_pharmacy_claim", "description": "Staging core pharmacy claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_pharmacy_claim", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_eligibility": {"name": "core__stg_claims_eligibility", "description": "Staging core eligibility", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_eligibility", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_practitioner": {"name": "core__stg_claims_practitioner", "description": "Staging core providers in the claims dataset", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_practitioner", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_clinical_condition": {"name": "core__stg_clinical_condition", "description": "Staging core clinical conditions", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_condition", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_encounter": {"name": "core__stg_clinical_encounter", "description": "Staging core clinical encounters", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_encounter", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_lab_result": {"name": "core__stg_clinical_lab_result", "description": "Staging core clinical lab results", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_lab_result", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_location": {"name": "core__stg_clinical_location", "description": "Staging core clinical locations", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_location", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_medication": {"name": "core__stg_clinical_medication", "description": "Staging core clinical medications", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_medication", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_observation": {"name": "core__stg_clinical_observation", "description": "Staging core clinical observations", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_observation", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_patient": {"name": "core__stg_clinical_patient", "description": "Staging core clinical patients", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_patient", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_practitioner": {"name": "core__stg_clinical_practitioner", "description": "Staging core clinical providers", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_practitioner", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_procedure": {"name": "core__stg_clinical_procedure", "description": "Staging core clinical procedures", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_procedure", "tags": "core_stage_clinical", "materialized": "view"}}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "procedure", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.8335922, "relation_name": "cms_synthetic.core.procedure", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith all_procedures as (\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect * from {{ ref('core__stg_claims_procedure') }}\nunion all\nselect * from {{ ref('core__stg_clinical_procedure') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect * from {{ ref('core__stg_clinical_procedure') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect * from {{ ref('core__stg_claims_procedure') }}\n\n{%- endif %}\n)\n\n{% if var('enable_normalize_engine',false) != true %}\n\nselect\n all_procedures.procedure_id\n , all_procedures.patient_id\n , all_procedures.encounter_id\n , all_procedures.claim_id\n , all_procedures.procedure_date\n , all_procedures.source_code_type\n , all_procedures.source_code\n , all_procedures.source_description\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n end as normalized_code_type\n , coalesce(all_procedures.normalized_code\n , icd10.icd_10_pcs\n , icd9.icd_9_pcs\n , hcpcs.hcpcs\n ,snomed_ct.snomed_ct ) as normalized_code\n , coalesce(all_procedures.normalized_description\n , icd10.description\n , icd9.short_description\n , hcpcs.short_description\n , snomed_ct.description) normalized_description\n , case when coalesce(all_procedures.normalized_code, all_procedures.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_procedures.modifier_1\n , all_procedures.modifier_2\n , all_procedures.modifier_3\n , all_procedures.modifier_4\n , all_procedures.modifier_5\n , all_procedures.practitioner_id\n , all_procedures.data_source\n , all_procedures.tuva_last_run\nfrom all_procedures\nleft join {{ ref('terminology__icd_10_pcs') }} icd10\n on all_procedures.source_code_type = 'icd-10-pcs'\n and all_procedures.source_code = icd10.icd_10_pcs\nleft join {{ ref('terminology__icd_9_pcs') }} icd9\n on all_procedures.source_code_type = 'icd-9-pcs'\n and all_procedures.source_code = icd9.icd_9_pcs\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\n on all_procedures.source_code_type = 'hcpcs'\n and all_procedures.source_code = hcpcs.hcpcs\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\n on all_procedures.source_code_type = 'snomed-ct'\n and all_procedures.source_code = snomed_ct.snomed_ct\n\n\n{% else %}\n\n\nselect\n all_procedures.procedure_id\n , all_procedures.patient_id\n , all_procedures.encounter_id\n , all_procedures.claim_id\n , all_procedures.procedure_date\n , all_procedures.source_code_type\n , all_procedures.source_code\n , all_procedures.source_description\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else custom_mapped.normalized_code_type end as normalized_code_type\n , coalesce(all_procedures.normalized_code\n , icd10.icd_10_pcs\n , icd9.icd_9_pcs\n , hcpcs.hcpcs\n ,snomed_ct.snomed_ct\n ,custom_mapped.normalized_code ) as normalized_code\n , coalesce(all_procedures.normalized_description\n , icd10.description\n , icd9.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , custom_mapped.normalized_description) as normalized_description\n , case when coalesce(all_procedures.normalized_code ,all_procedures.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\n end as mapping_method\n , all_procedures.modifier_1\n , all_procedures.modifier_2\n , all_procedures.modifier_3\n , all_procedures.modifier_4\n , all_procedures.modifier_5\n , all_procedures.practitioner_id\n , all_procedures.data_source\n , all_procedures.tuva_last_run\nfrom all_procedures\nleft join {{ ref('terminology__icd_10_pcs') }} icd10\n on all_procedures.source_code_type = 'icd-10-pcs'\n and all_procedures.source_code = icd10.icd_10_pcs\nleft join {{ ref('terminology__icd_9_pcs') }} icd9\n on all_procedures.source_code_type = 'icd-9-pcs'\n and all_procedures.source_code = icd9.icd_9_pcs\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\n on all_procedures.source_code_type = 'hcpcs'\n and all_procedures.source_code = hcpcs.hcpcs\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\n on all_procedures.source_code_type = 'snomed-ct'\n and all_procedures.source_code = snomed_ct.snomed_ct\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(all_procedures.source_code_type) = lower(custom_mapped.source_code_type)\n or ( all_procedures.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (all_procedures.source_code = custom_mapped.source_code\n or ( all_procedures.source_code is null and custom_mapped.source_code is null)\n )\n and (all_procedures.source_description = custom_mapped.source_description\n or ( all_procedures.source_description is null and custom_mapped.source_description is null)\n )\n and not (all_procedures.source_code is null and all_procedures.source_description is null)\n\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_procedure", "package": null, "version": null}, {"name": "core__stg_clinical_procedure", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.core__stg_clinical_procedure", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__snomed_ct"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__procedure.sql", "compiled": true, "compiled_code": "\n\n\nwith all_procedures as (\nselect * from cms_synthetic.dbt_tom.core__stg_claims_procedure\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_procedure\n\n\n)\n\n\n\nselect\n all_procedures.procedure_id\n , all_procedures.patient_id\n , all_procedures.encounter_id\n , all_procedures.claim_id\n , all_procedures.procedure_date\n , all_procedures.source_code_type\n , all_procedures.source_code\n , all_procedures.source_description\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n end as normalized_code_type\n , coalesce(all_procedures.normalized_code\n , icd10.icd_10_pcs\n , icd9.icd_9_pcs\n , hcpcs.hcpcs\n ,snomed_ct.snomed_ct ) as normalized_code\n , coalesce(all_procedures.normalized_description\n , icd10.description\n , icd9.short_description\n , hcpcs.short_description\n , snomed_ct.description) normalized_description\n , case when coalesce(all_procedures.normalized_code, all_procedures.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_procedures.modifier_1\n , all_procedures.modifier_2\n , all_procedures.modifier_3\n , all_procedures.modifier_4\n , all_procedures.modifier_5\n , all_procedures.practitioner_id\n , all_procedures.data_source\n , all_procedures.tuva_last_run\nfrom all_procedures\nleft join cms_synthetic.terminology.icd_10_pcs icd10\n on all_procedures.source_code_type = 'icd-10-pcs'\n and all_procedures.source_code = icd10.icd_10_pcs\nleft join cms_synthetic.terminology.icd_9_pcs icd9\n on all_procedures.source_code_type = 'icd-9-pcs'\n and all_procedures.source_code = icd9.icd_9_pcs\nleft join cms_synthetic.terminology.hcpcs_level_2 hcpcs\n on all_procedures.source_code_type = 'hcpcs'\n and all_procedures.source_code = hcpcs.hcpcs\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on all_procedures.source_code_type = 'snomed-ct'\n and all_procedures.source_code = snomed_ct.snomed_ct\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__location": {"database": "cms_synthetic", "schema": "core", "name": "core__location", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__location.sql", "original_file_path": "models/core/final/core__location.sql", "unique_id": "model.the_tuva_project.core__location", "fqn": ["the_tuva_project", "core", "final", "core__location"], "alias": "location", "checksum": {"name": "sha256", "checksum": "25c3cd44422b697cd1494783c2e87d160c7aa163ddc1b175e23379583ee15845"}, "config": {"enabled": true, "alias": "location", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The location table contains information on practice and facility locations where patients receive medical care.\n", "columns": {"location_id": {"name": "location_id", "description": "Unique identifier for each location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "The national provider identifier associated with the record e.g. facility_npi, provider_npi", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "name": {"name": "name", "description": "The name of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_organization": {"name": "parent_organization", "description": "The parent organization associated with the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The street address of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "location", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.801409, "relation_name": "cms_synthetic.core.location", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_location') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_location') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_location') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_location') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_location", "package": null, "version": null}, {"name": "core__stg_clinical_location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_clinical_location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__location.sql", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_location\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_location\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__member_months": {"database": "cms_synthetic", "schema": "core", "name": "core__member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__member_months.sql", "original_file_path": "models/core/final/core__member_months.sql", "unique_id": "model.the_tuva_project.core__member_months", "fqn": ["the_tuva_project", "core", "final", "core__member_months"], "alias": "member_months", "checksum": {"name": "sha256", "checksum": "d19f26e699f588ac637be8d6d5cbcb74c6932e3535d9d7e001cedfe98c39c38e"}, "config": {"enabled": true, "alias": "member_months", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "Creates member months from eligibility data", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider": {"name": "payer_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the payer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "description": "Name of the practice for the payer attributed provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "description": "Name of the organization for the payer attributed provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "description": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider": {"name": "custom_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the user.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "description": "Name of the practice for the attributed provider assigned by the user.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "description": "Name of the organization for the attributed provider assigned by the user.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "description": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "member_months", "tags": ["core"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.809216, "relation_name": "cms_synthetic.core.member_months", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n\n\nwith month_start_and_end_dates as (\n select\n {{ dbt.concat([\"year\",\n dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from {{ ref('reference_data__calendar')}}\n group by year, month, year_month\n),\n\n\nfinal_before_attribution_fields as (\nselect distinct\n a.patient_id\n , year_month\n , a.payer\n , a.{{ quote_column('plan') }}\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__eligibility') }} a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date\n),\n\n\nadd_attribution_fields as (\nselect\n a.patient_id\n , a.year_month\n , a.payer\n , a.{{ quote_column('plan') }}\n , a.data_source\n , a.tuva_last_run\n \n , b.payer_attributed_provider\n , b.payer_attributed_provider_practice\n , b.payer_attributed_provider_organization\n , b.payer_attributed_provider_lob\n , b.custom_attributed_provider\n , b.custom_attributed_provider_practice\n , b.custom_attributed_provider_organization\n , b.custom_attributed_provider_lob\n\nfrom final_before_attribution_fields a\nleft join {{ ref('financial_pmpm__stg_provider_attribution') }} b\non a.patient_id = b.patient_id\nand a.year_month = b.year_month\nand a.payer = b.payer\nand a.{{ quote_column('plan') }} = b.{{ quote_column('plan') }}\nand a.data_source = b.data_source\n)\n\n\nselect *\nfrom add_attribution_fields", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "financial_pmpm__stg_provider_attribution", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.right", "macro.the_tuva_project.quote_column"], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.financial_pmpm__stg_provider_attribution"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__member_months.sql", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__financial_pmpm__stg_provider_attribution as (\n\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution\n), month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from cms_synthetic.reference_data.calendar\n group by year, month, year_month\n),\n\n\nfinal_before_attribution_fields as (\nselect distinct\n a.patient_id\n , year_month\n , a.payer\n , a.plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date\n),\n\n\nadd_attribution_fields as (\nselect\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.tuva_last_run\n \n , b.payer_attributed_provider\n , b.payer_attributed_provider_practice\n , b.payer_attributed_provider_organization\n , b.payer_attributed_provider_lob\n , b.custom_attributed_provider\n , b.custom_attributed_provider_practice\n , b.custom_attributed_provider_organization\n , b.custom_attributed_provider_lob\n\nfrom final_before_attribution_fields a\nleft join __dbt__cte__financial_pmpm__stg_provider_attribution b\non a.patient_id = b.patient_id\nand a.year_month = b.year_month\nand a.payer = b.payer\nand a.plan = b.plan\nand a.data_source = b.data_source\n)\n\n\nselect *\nfrom add_attribution_fields", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.financial_pmpm__stg_provider_attribution", "sql": " __dbt__cte__financial_pmpm__stg_provider_attribution as (\n\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__medication": {"database": "cms_synthetic", "schema": "core", "name": "core__medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__medication.sql", "original_file_path": "models/core/final/core__medication.sql", "unique_id": "model.the_tuva_project.core__medication", "fqn": ["the_tuva_project", "core", "final", "core__medication"], "alias": "medication", "checksum": {"name": "sha256", "checksum": "41781b14235e6e9617031669561000b5bf757720455b90def7011a78d1f64975"}, "config": {"enabled": true, "alias": "medication", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The medication table contains information on medications ordered and/or administered during a patient encounter.\n", "columns": {"medication_id": {"name": "medication_id", "description": "Unique identifier for each medication in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_date": {"name": "prescribing_date", "description": "Date the medication was prescribed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://www.nlm.nih.gov/research/umls/rxnorm/index.html"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code associated with the medication.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description for the NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_mapping_method": {"name": "ndc_mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "RxNorm code associated with the medication.", "meta": {"terminology": "https://www.nlm.nih.gov/research/umls/rxnorm/index.html"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "Description for the RxNorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_mapping_method": {"name": "rxnorm_mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_code": {"name": "atc_code", "description": "ATC code for the medication.", "meta": {"terminology": "https://www.who.int/tools/atc-ddd-toolkit/atc-classification"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_description": {"name": "atc_description", "description": "Description for the ATC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_mapping_method": {"name": "atc_mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "route": {"name": "route", "description": "The route used to administer the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "strength": {"name": "strength", "description": "The strength of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "The quantity of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity_unit": {"name": "quantity_unit", "description": "The units for the quantity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "The number of days supply included.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "medication", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.807563, "relation_name": "cms_synthetic.core.medication", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nwith source_mapping as (\n{% if var('enable_normalize_engine',false) != true %}\n select\n meds.medication_id\n , meds.patient_id\n , meds.encounter_id\n , meds.dispensing_date\n , meds.prescribing_date\n , meds.source_code_type\n , meds.source_code\n , meds.source_description\n , coalesce(\n meds.ndc_code\n , ndc.ndc\n ) as ndc_code\n , coalesce(\n meds.ndc_description\n , ndc.fda_description\n , ndc.rxnorm_description\n ) as ndc_description\n , case\n when meds.ndc_code is not null then 'manual'\n when ndc.ndc is not null then 'automatic'\n end as ndc_mapping_method\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxcui\n ) as rxnorm_code\n , coalesce(\n meds.rxnorm_description\n , rxatc.rxnorm_description\n ) as rxnorm_description\n , case\n when meds.rxnorm_code is not null then 'manual'\n when rxatc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n meds.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n meds.atc_description\n , rxatc.atc_4_name\n ) as atc_description\n , case\n when meds.atc_code is not null then 'manual'\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , meds.route\n , meds.strength\n , meds.quantity\n , meds.quantity_unit\n , meds.days_supply\n , meds.practitioner_id\n , meds.data_source\n , meds.tuva_last_run\nfrom {{ ref('core__stg_clinical_medication')}} meds\n left join {{ref('terminology__ndc')}} ndc\n on meds.source_code_type = 'ndc'\n and meds.source_code = ndc.ndc\n left join {{ref('terminology__rxnorm_to_atc')}} rxatc\n on meds.source_code_type = 'rxnorm'\n and meds.source_code = rxatc.rxcui\n\n\n{% else %}\n\n select\n meds.medication_id\n , meds.patient_id\n , meds.encounter_id\n , meds.dispensing_date\n , meds.prescribing_date\n , meds.source_code_type\n , meds.source_code\n , meds.source_description\n , coalesce(\n meds.ndc_code\n , ndc.ndc\n , custom_mapped_ndc.normalized_code\n ) as ndc_code\n , coalesce(\n meds.ndc_description\n , ndc.fda_description\n , ndc.rxnorm_description\n , custom_mapped_ndc.normalized_description\n ) as ndc_description\n , case\n when meds.ndc_code is not null then 'manual'\n when ndc.ndc is not null then 'automatic'\n when custom_mapped_ndc.not_mapped is not null then custom_mapped_ndc.not_mapped\n when custom_mapped_ndc.normalized_code is not null then 'custom'\n end as ndc_mapping_method\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxcui\n , custom_mapped_rxnorm.normalized_code\n ) as rxnorm_code\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxnorm_description\n , custom_mapped_rxnorm.normalized_description\n ) as rxnorm_description\n , case\n when meds.rxnorm_code is not null then 'manual'\n when rxatc.rxcui is not null then 'automatic'\n when custom_mapped_rxnorm.not_mapped is not null then custom_mapped_rxnorm.not_mapped\n when custom_mapped_rxnorm.normalized_code is not null then 'custom'\n end as rxnorm_mapping_method\n , coalesce(\n meds.atc_code\n , rxatc.atc_3_code\n , custom_mapped_atc.normalized_code\n ) as atc_code\n , coalesce(\n meds.atc_description\n , rxatc.atc_3_name\n , custom_mapped_atc.normalized_description\n ) as atc_description\n , case\n when meds.atc_code is not null then 'manual'\n when rxatc.atc_3_code is not null then 'automatic'\n when custom_mapped_atc.not_mapped is not null then custom_mapped_atc.not_mapped\n when custom_mapped_atc.normalized_code is not null then 'custom'\n end as atc_mapping_method\n , meds.route\n , meds.strength\n , meds.quantity\n , meds.quantity_unit\n , meds.days_supply\n , meds.practitioner_id\n , meds.data_source\n , meds.tuva_last_run\nfrom {{ ref('core__stg_clinical_medication')}} meds\n left join {{ref('terminology__ndc')}} ndc\n on meds.source_code_type = 'ndc'\n and meds.source_code = ndc.ndc\n left join {{ref('terminology__rxnorm_to_atc')}} rxatc\n on meds.source_code_type = 'rxnorm'\n and meds.source_code = rxatc.rxcui\n left join {{ ref('custom_mapped') }} custom_mapped_ndc\n on custom_mapped_ndc.normalized_code_type = 'ndc'\n and ( lower(meds.source_code_type) = lower(custom_mapped_ndc.source_code_type)\n or ( meds.source_code_type is null and custom_mapped_ndc.source_code_type is null)\n )\n and (meds.source_code = custom_mapped_ndc.source_code\n or ( meds.source_code is null and custom_mapped_ndc.source_code is null)\n )\n and (meds.source_description = custom_mapped_ndc.source_description\n or ( meds.source_description is null and custom_mapped_ndc.source_description is null)\n )\n and not (meds.source_code is null and meds.source_description is null)\n left join {{ ref('custom_mapped') }} custom_mapped_rxnorm\n on custom_mapped_rxnorm.normalized_code_type = 'rxnorm'\n and ( lower(meds.source_code_type) = lower(custom_mapped_rxnorm.source_code_type)\n or ( meds.source_code_type is null and custom_mapped_rxnorm.source_code_type is null)\n )\n and (meds.source_code = custom_mapped_rxnorm.source_code\n or ( meds.source_code is null and custom_mapped_rxnorm.source_code is null)\n )\n and (meds.source_description = custom_mapped_rxnorm.source_description\n or ( meds.source_description is null and custom_mapped_rxnorm.source_description is null)\n )\n and not (meds.source_code is null and meds.source_description is null)\n left join {{ ref('custom_mapped') }} custom_mapped_atc\n on custom_mapped_atc.normalized_code_type = 'atc'\n and ( lower(meds.source_code_type) = lower(custom_mapped_atc.source_code_type)\n or ( meds.source_code_type is null and custom_mapped_atc.source_code_type is null)\n )\n and (meds.source_code = custom_mapped_atc.source_code\n or ( meds.source_code is null and custom_mapped_atc.source_code is null)\n )\n and (meds.source_description = custom_mapped_atc.source_description\n or ( meds.source_description is null and custom_mapped_atc.source_description is null)\n )\n and not (meds.source_code is null and meds.source_description is null)\n{% endif %}\n )\n\n\n-- add auto rxnorm + atc\nselect\n sm.medication_id\n , sm.patient_id\n , sm.encounter_id\n , sm.dispensing_date\n , sm.prescribing_date\n , sm.source_code_type\n , sm.source_code\n , sm.source_description\n , sm.ndc_code\n , sm.ndc_description\n , sm.ndc_mapping_method\n , coalesce(\n sm.rxnorm_code\n , ndc.rxcui\n ) as rxnorm_code\n , coalesce(\n sm.rxnorm_description\n , ndc.rxnorm_description\n ) as rxnorm_description\n , case\n when sm.rxnorm_mapping_method is not null then sm.rxnorm_mapping_method\n when ndc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n sm.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n sm.atc_description\n , rxatc.atc_3_name\n ) as atc_description\n , case\n when sm.atc_mapping_method is not null then sm.atc_mapping_method\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , sm.route\n , sm.strength\n , sm.quantity\n , sm.quantity_unit\n , sm.days_supply\n , sm.practitioner_id\n , sm.data_source\n , sm.tuva_last_run\nfrom source_mapping sm\n left join {{ref('terminology__ndc')}} ndc\n on sm.ndc_code = ndc.ndc\n left join {{ref('terminology__rxnorm_to_atc')}} rxatc\n on coalesce( sm.rxnorm_code, ndc.rxcui ) = rxatc.rxcui", "language": "sql", "refs": [{"name": "core__stg_clinical_medication", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_clinical_medication", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__medication.sql", "compiled": true, "compiled_code": "\n\n\nwith source_mapping as (\n\n select\n meds.medication_id\n , meds.patient_id\n , meds.encounter_id\n , meds.dispensing_date\n , meds.prescribing_date\n , meds.source_code_type\n , meds.source_code\n , meds.source_description\n , coalesce(\n meds.ndc_code\n , ndc.ndc\n ) as ndc_code\n , coalesce(\n meds.ndc_description\n , ndc.fda_description\n , ndc.rxnorm_description\n ) as ndc_description\n , case\n when meds.ndc_code is not null then 'manual'\n when ndc.ndc is not null then 'automatic'\n end as ndc_mapping_method\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxcui\n ) as rxnorm_code\n , coalesce(\n meds.rxnorm_description\n , rxatc.rxnorm_description\n ) as rxnorm_description\n , case\n when meds.rxnorm_code is not null then 'manual'\n when rxatc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n meds.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n meds.atc_description\n , rxatc.atc_4_name\n ) as atc_description\n , case\n when meds.atc_code is not null then 'manual'\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , meds.route\n , meds.strength\n , meds.quantity\n , meds.quantity_unit\n , meds.days_supply\n , meds.practitioner_id\n , meds.data_source\n , meds.tuva_last_run\nfrom cms_synthetic.dbt_tom.core__stg_clinical_medication meds\n left join cms_synthetic.terminology.ndc ndc\n on meds.source_code_type = 'ndc'\n and meds.source_code = ndc.ndc\n left join cms_synthetic.terminology.rxnorm_to_atc rxatc\n on meds.source_code_type = 'rxnorm'\n and meds.source_code = rxatc.rxcui\n\n\n\n )\n\n\n-- add auto rxnorm + atc\nselect\n sm.medication_id\n , sm.patient_id\n , sm.encounter_id\n , sm.dispensing_date\n , sm.prescribing_date\n , sm.source_code_type\n , sm.source_code\n , sm.source_description\n , sm.ndc_code\n , sm.ndc_description\n , sm.ndc_mapping_method\n , coalesce(\n sm.rxnorm_code\n , ndc.rxcui\n ) as rxnorm_code\n , coalesce(\n sm.rxnorm_description\n , ndc.rxnorm_description\n ) as rxnorm_description\n , case\n when sm.rxnorm_mapping_method is not null then sm.rxnorm_mapping_method\n when ndc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n sm.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n sm.atc_description\n , rxatc.atc_3_name\n ) as atc_description\n , case\n when sm.atc_mapping_method is not null then sm.atc_mapping_method\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , sm.route\n , sm.strength\n , sm.quantity\n , sm.quantity_unit\n , sm.days_supply\n , sm.practitioner_id\n , sm.data_source\n , sm.tuva_last_run\nfrom source_mapping sm\n left join cms_synthetic.terminology.ndc ndc\n on sm.ndc_code = ndc.ndc\n left join cms_synthetic.terminology.rxnorm_to_atc rxatc\n on coalesce( sm.rxnorm_code, ndc.rxcui ) = rxatc.rxcui", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__observation": {"database": "cms_synthetic", "schema": "core", "name": "core__observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__observation.sql", "original_file_path": "models/core/final/core__observation.sql", "unique_id": "model.the_tuva_project.core__observation", "fqn": ["the_tuva_project", "core", "final", "core__observation"], "alias": "observation", "checksum": {"name": "sha256", "checksum": "5437373827e8b7ca63e9aaaaeba286d0219e0f7134e03838a978e782974bff7a"}, "config": {"enabled": true, "alias": "observation", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The observation table contains information on measurements other than lab tests e.g. blood pressure, height, and weight.\n", "columns": {"observation_id": {"name": "observation_id", "description": "Unique identifier for each observation in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "panel_id": {"name": "panel_id", "description": "Unique identifier for the panel.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "Date the observation was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_type": {"name": "observation_type", "description": "Type of observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the record (e.g., lab test, observation, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "observation", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.811166, "relation_name": "cms_synthetic.core.observation", "raw_code": "{{ config(\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) != true %}\nselect\n obs.observation_id\n , obs.patient_id\n , obs.encounter_id\n , obs.panel_id\n , obs.observation_date\n , obs.observation_type\n , obs.source_code_type\n , obs.source_code\n , obs.source_description\n , case\n when obs.normalized_code_type is not null then obs.normalized_code_type\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n when loinc.loinc is not null then 'loinc'\n end as normalized_code_type\n , coalesce(\n obs.normalized_code\n , icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc\n ) as normalized_code\n , coalesce(\n obs.normalized_description\n , icd10cm.short_description\n , icd9cm.short_description\n , icd10pcs.description\n , icd9pcs.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , loinc.long_common_name\n ) as normalized_description\n , case\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\n when coalesce(\n icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc) is not null then 'automatic'\n end as mapping_method\n , obs.result\n , obs.source_units\n , obs.normalized_units\n , obs.source_reference_range_low\n , obs.source_reference_range_high\n , obs.normalized_reference_range_low\n , obs.normalized_reference_range_high\n , obs.data_source\n , obs.tuva_last_run\nfrom {{ ref('core__stg_clinical_observation')}} obs\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on obs.source_code_type = 'icd-10-cm'\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on obs.source_code_type = 'icd-9-cm'\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\nleft join {{ ref('terminology__icd_10_pcs') }} icd10pcs\n on obs.source_code_type = 'icd-10-pcs'\n and obs.source_code = icd10pcs.icd_10_pcs\nleft join {{ ref('terminology__icd_9_pcs') }} icd9pcs\n on obs.source_code_type = 'icd-9-pcs'\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\n on obs.source_code_type = 'hcpcs'\n and obs.source_code = hcpcs.hcpcs\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\n on obs.source_code_type = 'snomed-ct'\n and obs.source_code = snomed_ct.snomed_ct\nleft join {{ ref('terminology__loinc') }} loinc\n on obs.source_code_type = 'loinc'\n and obs.source_code = loinc.loinc\n\n{% else %}\n\nselect\n obs.observation_id\n , obs.patient_id\n , obs.encounter_id\n , obs.panel_id\n , obs.observation_date\n , obs.observation_type\n , obs.source_code_type\n , obs.source_code\n , obs.source_description\n , case\n when obs.normalized_code_type is not null then obs.normalized_code_type\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n when loinc.loinc is not null then 'loinc'\n else custom_mapped.normalized_code_type end as normalized_code_type\n , coalesce(\n obs.normalized_code\n , icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc\n , custom_mapped.normalized_code\n ) as normalized_code\n , coalesce(\n obs.normalized_description\n , icd10cm.short_description\n , icd9cm.short_description\n , icd10pcs.description\n , icd9pcs.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , loinc.long_common_name\n , custom_mapped.normalized_description\n ) as normalized_description\n , case\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\n when coalesce(\n icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc) is not null then 'automatic'\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\n end as mapping_method\n , obs.result\n , obs.source_units\n , obs.normalized_units\n , obs.source_reference_range_low\n , obs.source_reference_range_high\n , obs.normalized_reference_range_low\n , obs.normalized_reference_range_high\n , obs.data_source\n , obs.tuva_last_run\nfrom {{ ref('core__stg_clinical_observation')}} obs\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on obs.source_code_type = 'icd-10-cm'\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on obs.source_code_type = 'icd-9-cm'\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\nleft join {{ ref('terminology__icd_10_pcs') }} icd10pcs\n on obs.source_code_type = 'icd-10-pcs'\n and obs.source_code = icd10pcs.icd_10_pcs\nleft join {{ ref('terminology__icd_9_pcs') }} icd9pcs\n on obs.source_code_type = 'icd-9-pcs'\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\n on obs.source_code_type = 'hcpcs'\n and obs.source_code = hcpcs.hcpcs\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\n on obs.source_code_type = 'snomed-ct'\n and obs.source_code = snomed_ct.snomed_ct\nleft join {{ ref('terminology__loinc') }} loinc\n on obs.source_code_type = 'loinc'\n and obs.source_code = loinc.loinc\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(obs.source_code_type) = lower(custom_mapped.source_code_type)\n or ( obs.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (obs.source_code = custom_mapped.source_code\n or ( obs.source_code is null and custom_mapped.source_code is null)\n )\n and (obs.source_description = custom_mapped.source_description\n or ( obs.source_description is null and custom_mapped.source_description is null)\n )\n and not (obs.source_code is null and obs.source_description is null)\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_clinical_observation", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_clinical_observation", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__snomed_ct", "seed.the_tuva_project.terminology__loinc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__observation.sql", "compiled": true, "compiled_code": "\n\n\nselect\n obs.observation_id\n , obs.patient_id\n , obs.encounter_id\n , obs.panel_id\n , obs.observation_date\n , obs.observation_type\n , obs.source_code_type\n , obs.source_code\n , obs.source_description\n , case\n when obs.normalized_code_type is not null then obs.normalized_code_type\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n when loinc.loinc is not null then 'loinc'\n end as normalized_code_type\n , coalesce(\n obs.normalized_code\n , icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc\n ) as normalized_code\n , coalesce(\n obs.normalized_description\n , icd10cm.short_description\n , icd9cm.short_description\n , icd10pcs.description\n , icd9pcs.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , loinc.long_common_name\n ) as normalized_description\n , case\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\n when coalesce(\n icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc) is not null then 'automatic'\n end as mapping_method\n , obs.result\n , obs.source_units\n , obs.normalized_units\n , obs.source_reference_range_low\n , obs.source_reference_range_high\n , obs.normalized_reference_range_low\n , obs.normalized_reference_range_high\n , obs.data_source\n , obs.tuva_last_run\nfrom cms_synthetic.dbt_tom.core__stg_clinical_observation obs\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on obs.source_code_type = 'icd-10-cm'\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on obs.source_code_type = 'icd-9-cm'\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\nleft join cms_synthetic.terminology.icd_10_pcs icd10pcs\n on obs.source_code_type = 'icd-10-pcs'\n and obs.source_code = icd10pcs.icd_10_pcs\nleft join cms_synthetic.terminology.icd_9_pcs icd9pcs\n on obs.source_code_type = 'icd-9-pcs'\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\nleft join cms_synthetic.terminology.hcpcs_level_2 hcpcs\n on obs.source_code_type = 'hcpcs'\n and obs.source_code = hcpcs.hcpcs\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on obs.source_code_type = 'snomed-ct'\n and obs.source_code = snomed_ct.snomed_ct\nleft join cms_synthetic.terminology.loinc loinc\n on obs.source_code_type = 'loinc'\n and obs.source_code = loinc.loinc\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__practitioner": {"database": "cms_synthetic", "schema": "core", "name": "core__practitioner", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__practitioner.sql", "original_file_path": "models/core/final/core__practitioner.sql", "unique_id": "model.the_tuva_project.core__practitioner", "fqn": ["the_tuva_project", "core", "final", "core__practitioner"], "alias": "practitioner", "checksum": {"name": "sha256", "checksum": "402fa1015c25b4347c00bde3d71b875be57fe24318ae1e40bcd349c6bf38f949"}, "config": {"enabled": true, "alias": "practitioner", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The practitioner table contains information on the providers in the dataset e.g. physicians, physicians assistants, etc.\n", "columns": {"practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "The national provider identifier associated with the record e.g. facility_npi, provider_npi", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_affiliation": {"name": "practice_affiliation", "description": "Practice affiliation of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty": {"name": "specialty", "description": "Specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sub_specialty": {"name": "sub_specialty", "description": "Sub specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "practitioner", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729623957.817333, "relation_name": "cms_synthetic.core.practitioner", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true-%}\r\n\r\nselect * from {{ ref('core__stg_claims_practitioner') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_practitioner') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_practitioner') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_practitioner') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_practitioner", "package": null, "version": null}, {"name": "core__stg_clinical_practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_practitioner", "model.the_tuva_project.core__stg_clinical_practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__practitioner.sql", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_practitioner\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_practitioner\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__stg_member_month": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__stg_member_month", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/stage/mart_review__stg_member_month.sql", "original_file_path": "models/data_quality/dqi/mart_review/stage/mart_review__stg_member_month.sql", "unique_id": "model.the_tuva_project.mart_review__stg_member_month", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "stage", "mart_review__stg_member_month"], "alias": "mart_review__stg_member_month", "checksum": {"name": "sha256", "checksum": "ab127fed9eef0e727630a85225147d85547085320461e0b84daa49b1515ae89b"}, "config": {"enabled": true, "alias": "mart_review__stg_member_month", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__stg_member_month", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.432153, "relation_name": "cms_synthetic.data_quality.mart_review__stg_member_month", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nwith cte as\n(\nselect distinct year_month_int\n,full_date\nfrom {{ ref('reference_data__calendar') }} c\nwhere day = 1\n\n)\n\nselect mm.*\n,c.year_month_int\n,c.full_date as year_month_date\nFROM {{ ref('core__member_months')}} mm\nleft join cte c on cast(mm.year_month as int) = c.year_month_int", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/stage/mart_review__stg_member_month.sql", "compiled": true, "compiled_code": "\n\nwith cte as\n(\nselect distinct year_month_int\n,full_date\nfrom cms_synthetic.reference_data.calendar c\nwhere day = 1\n\n)\n\nselect mm.*\n,c.year_month_int\n,c.full_date as year_month_date\nFROM cms_synthetic.core.member_months mm\nleft join cte c on cast(mm.year_month as int) = c.year_month_int", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__stg_medical_claim": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/stage/mart_review__stg_medical_claim.sql", "original_file_path": "models/data_quality/dqi/mart_review/stage/mart_review__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.mart_review__stg_medical_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "stage", "mart_review__stg_medical_claim"], "alias": "mart_review__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "b41aa0b0362058cc55721ff02c06c2da184e209b644b9406f212ec13afbfa0c5"}, "config": {"enabled": true, "alias": "mart_review__stg_medical_claim", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__stg_medical_claim", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.429683, "relation_name": "cms_synthetic.data_quality.mart_review__stg_medical_claim", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nselect mc.*,\ncast(c.year_month_int as {{ dbt.type_string() }}) as year_month\nFROM {{ ref('core__medical_claim')}} mc\nleft join {{ ref('reference_data__calendar') }} c on coalesce(mc.claim_line_start_date,mc.claim_start_date) = c.full_date", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/stage/mart_review__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM cms_synthetic.core.medical_claim mc\nleft join cms_synthetic.reference_data.calendar c on coalesce(mc.claim_line_start_date,mc.claim_start_date) = c.full_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__stg_pharmacy_claim": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/stage/mart_review__stg_pharmacy_claim.sql", "original_file_path": "models/data_quality/dqi/mart_review/stage/mart_review__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.mart_review__stg_pharmacy_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "stage", "mart_review__stg_pharmacy_claim"], "alias": "mart_review__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "5132bbf68674b092bb6cffa0a1c81f718c02d719675eee8cbf006929bceed518"}, "config": {"enabled": true, "alias": "mart_review__stg_pharmacy_claim", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__stg_pharmacy_claim", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.430979, "relation_name": "cms_synthetic.data_quality.mart_review__stg_pharmacy_claim", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nselect mc.*,\ncast(c.year_month_int as {{ dbt.type_string() }}) as year_month\nFROM {{ ref('core__pharmacy_claim')}} mc\nleft join {{ ref('reference_data__calendar') }} c on coalesce(mc.paid_date,mc.dispensing_date) = c.full_date", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/stage/mart_review__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM cms_synthetic.core.pharmacy_claim mc\nleft join cms_synthetic.reference_data.calendar c on coalesce(mc.paid_date,mc.dispensing_date) = c.full_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__data_source.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__data_source.sql", "unique_id": "model.the_tuva_project.mart_review__data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__data_source"], "alias": "mart_review__data_source", "checksum": {"name": "sha256", "checksum": "0a1ef97387e49d93bc7b10cf39f2d48b15a6aad07c789699fe54ad11c533751f"}, "config": {"enabled": true, "alias": "mart_review__data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4048, "relation_name": "cms_synthetic.data_quality.mart_review__data_source", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nSELECT DISTINCT data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('core__medical_claim')}}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__tuva_chronic_conditions": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__tuva_chronic_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__tuva_chronic_conditions.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__tuva_chronic_conditions.sql", "unique_id": "model.the_tuva_project.mart_review__tuva_chronic_conditions", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__tuva_chronic_conditions"], "alias": "mart_review__tuva_chronic_conditions", "checksum": {"name": "sha256", "checksum": "6cd871c62d97ceab3e5f173aafd89c6f0d5bef9ec863dd70d313534cd7c6f7fd"}, "config": {"enabled": true, "alias": "mart_review__tuva_chronic_conditions", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__tuva_chronic_conditions", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.421288, "relation_name": "cms_synthetic.data_quality.mart_review__tuva_chronic_conditions", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\nwith cte as (\n select distinct\n patient_id\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long')}}\n)\n\n, patientxwalk as (\n select distinct\n patient_id\n , data_source\n from {{ ref('core__patient')}}\n)\n\n, result as (\n select\n l.patient_id\n , p.data_source\n , l.condition\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long')}} as l\n inner join patientxwalk as p\n on l.patient_id = p.patient_id\n\n union all\n\n select\n p.patient_id\n , p.data_source\n , 'No Chronic Conditions' as condition\n from {{ ref('core__patient')}} as p\n left join cte\n on p.patient_id = cte.patient_id\n where cte.patient_id is null\n)\n\nselect *\n , {{ dbt.concat([\n 'patient_id',\n \"'|'\",\n 'data_source']) }} as patient_source_key\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom result", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__tuva_chronic_conditions.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n patient_id\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, patientxwalk as (\n select distinct\n patient_id\n , data_source\n from cms_synthetic.core.patient\n)\n\n, result as (\n select\n l.patient_id\n , p.data_source\n , l.condition\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long as l\n inner join patientxwalk as p\n on l.patient_id = p.patient_id\n\n union all\n\n select\n p.patient_id\n , p.data_source\n , 'No Chronic Conditions' as condition\n from cms_synthetic.core.patient as p\n left join cte\n on p.patient_id = cte.patient_id\n where cte.patient_id is null\n)\n\nselect *\n , patient_id || '|' || data_source as patient_source_key\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom result", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__inpatient": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__inpatient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__inpatient.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__inpatient.sql", "unique_id": "model.the_tuva_project.mart_review__inpatient", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__inpatient"], "alias": "mart_review__inpatient", "checksum": {"name": "sha256", "checksum": "d06fd1d0e73d56ff4c23ddedf2cba0a04b3e0739b6419bd3881922f210ceb0da"}, "config": {"enabled": true, "alias": "mart_review__inpatient", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__inpatient", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4089222, "relation_name": "cms_synthetic.data_quality.mart_review__inpatient", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith cte as (\n select distinct\n location_id\n , npi\n , name\n from {{ ref('core__location') }}\n)\n\n, final as (\n select\n e.*\n , {{ dbt.concat(['e.patient_id', \"'|'\", 'e.data_source']) }} as patient_source_key\n , {{ dbt.concat(['e.encounter_id', \"'|'\", 'e.data_source']) }} as encounter_source_key\n , {{ dbt.concat(['e.ms_drg_code', \"' | '\", 'e.ms_drg_description']) }} as drgwithdescription\n , {{ dbt.concat(['e.primary_diagnosis_code', \"' | '\", 'e.primary_diagnosis_description']) }} as primary_diagnosis_and_description\n , {{ dbt.concat(['e.admit_source_code', \"' | '\", 'e.admit_source_description']) }} as admit_source_code_and_description\n , {{ dbt.concat(['e.admit_type_code', \"' | '\", 'e.admit_type_description']) }} as admit_type_code_and_description\n , {{ dbt.concat(['e.discharge_disposition_code', \"' | '\", 'e.discharge_disposition_description']) }} as discharge_code_and_description\n , p.ccsr_parent_category\n , p.ccsr_category\n , p.ccsr_category_description\n , {{ dbt.concat(['p.ccsr_category', \"' | '\", 'p.ccsr_category_description']) }} as ccsr_category_and_description\n , b.body_system\n , case \n when e.length_of_stay <= 1 then '1. 0-1 day'\n when e.length_of_stay <= 3 then '2. 2-3 days'\n when e.length_of_stay <= 5 then '3. 4-5 days'\n when e.length_of_stay <= 7 then '4. 6-7 days'\n when e.length_of_stay <= 14 then '5. 8-14 days'\n when e.length_of_stay <= 30 then '6. 15-30 days'\n end as los_groups\n from {{ ref('core__encounter') }} as e\n left join cte as l\n on e.facility_id = l.location_id\n left join {{ ref('ccsr__dx_vertical_pivot') }} as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\n left join {{ ref('ccsr__dxccsr_v2023_1_body_systems') }} as b\n on p.ccsr_parent_category = b.ccsr_parent_category\n where e.encounter_type = 'acute inpatient'\n)\n\nselect * from final", "language": "sql", "refs": [{"name": "core__location", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "ccsr__dx_vertical_pivot", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_body_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__location", "model.the_tuva_project.core__encounter", "model.the_tuva_project.ccsr__dx_vertical_pivot", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__inpatient.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n location_id\n , npi\n , name\n from cms_synthetic.core.location\n)\n\n, final as (\n select\n e.*\n , e.patient_id || '|' || e.data_source as patient_source_key\n , e.encounter_id || '|' || e.data_source as encounter_source_key\n , e.ms_drg_code || ' | ' || e.ms_drg_description as drgwithdescription\n , e.primary_diagnosis_code || ' | ' || e.primary_diagnosis_description as primary_diagnosis_and_description\n , e.admit_source_code || ' | ' || e.admit_source_description as admit_source_code_and_description\n , e.admit_type_code || ' | ' || e.admit_type_description as admit_type_code_and_description\n , e.discharge_disposition_code || ' | ' || e.discharge_disposition_description as discharge_code_and_description\n , p.ccsr_parent_category\n , p.ccsr_category\n , p.ccsr_category_description\n , p.ccsr_category || ' | ' || p.ccsr_category_description as ccsr_category_and_description\n , b.body_system\n , case \n when e.length_of_stay <= 1 then '1. 0-1 day'\n when e.length_of_stay <= 3 then '2. 2-3 days'\n when e.length_of_stay <= 5 then '3. 4-5 days'\n when e.length_of_stay <= 7 then '4. 6-7 days'\n when e.length_of_stay <= 14 then '5. 8-14 days'\n when e.length_of_stay <= 30 then '6. 15-30 days'\n end as los_groups\n from cms_synthetic.core.encounter as e\n left join cte as l\n on e.facility_id = l.location_id\n left join cms_synthetic.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\n left join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems as b\n on p.ccsr_parent_category = b.ccsr_parent_category\n where e.encounter_type = 'acute inpatient'\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__pharmacy": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__pharmacy", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__pharmacy.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__pharmacy.sql", "unique_id": "model.the_tuva_project.mart_review__pharmacy", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__pharmacy"], "alias": "mart_review__pharmacy", "checksum": {"name": "sha256", "checksum": "b48995749f606d25d4f1da4ae14fc856f2b1c50eb2bc30608f9f211412d8d958"}, "config": {"enabled": true, "alias": "mart_review__pharmacy", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__pharmacy", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.417286, "relation_name": "cms_synthetic.data_quality.mart_review__pharmacy", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nWITH dedup_prac AS (\n SELECT DISTINCT practitioner_id,\n provider_first_name,\n provider_last_name,\n specialty\n FROM {{ ref('core__practitioner')}}\n),\ndedup_loc AS (\n SELECT DISTINCT location_id,\n npi,\n name\n FROM {{ ref('core__location')}}\n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.patient_id,\n p.data_source,\n {{ dbt.concat([\n 'p.patient_id',\n \"'|'\",\n 'p.data_source'\n ]) }} as patient_source_key,\n p.ndc_code,\n COALESCE(n.fda_description, n.rxnorm_description) AS ndc_description,\n p.paid_amount,\n p.allowed_amount,\n p.prescribing_provider_id,\n p.prescribing_provider_name,\n prac.specialty AS prescribing_specialty,\n p.dispensing_provider_id,\n p.dispensing_provider_name,\n p.paid_date,\n p.dispensing_date,\n p.days_supply,\n n.rxcui,\n n.rxnorm_description,\n r.brand_name,\n r.brand_vs_generic,\n r.ingredient_name,\n a.atc_1_name,\n a.atc_2_name,\n a.atc_3_name,\n a.atc_4_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('core__pharmacy_claim')}} p\nLEFT JOIN {{ ref('terminology__ndc')}} n ON p.ndc_code = n.ndc\nLEFT JOIN {{ ref('terminology__rxnorm_brand_generic') }} r ON n.rxcui = r.product_rxcui\nLEFT JOIN {{ ref('terminology__rxnorm_to_atc') }} a ON n.rxcui = a.rxcui\nLEFT JOIN dedup_prac prac ON p.prescribing_provider_id = prac.practitioner_id\nLEFT JOIN dedup_loc l ON p.dispensing_provider_id = l.location_id", "language": "sql", "refs": [{"name": "core__practitioner", "package": null, "version": null}, {"name": "core__location", "package": null, "version": null}, {"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "terminology__rxnorm_brand_generic", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__practitioner", "model.the_tuva_project.core__location", "model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__pharmacy.sql", "compiled": true, "compiled_code": "\n\n\nWITH dedup_prac AS (\n SELECT DISTINCT practitioner_id,\n provider_first_name,\n provider_last_name,\n specialty\n FROM cms_synthetic.core.practitioner\n),\ndedup_loc AS (\n SELECT DISTINCT location_id,\n npi,\n name\n FROM cms_synthetic.core.location\n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.patient_id,\n p.data_source,\n p.patient_id || '|' || p.data_source as patient_source_key,\n p.ndc_code,\n COALESCE(n.fda_description, n.rxnorm_description) AS ndc_description,\n p.paid_amount,\n p.allowed_amount,\n p.prescribing_provider_id,\n p.prescribing_provider_name,\n prac.specialty AS prescribing_specialty,\n p.dispensing_provider_id,\n p.dispensing_provider_name,\n p.paid_date,\n p.dispensing_date,\n p.days_supply,\n n.rxcui,\n n.rxnorm_description,\n r.brand_name,\n r.brand_vs_generic,\n r.ingredient_name,\n a.atc_1_name,\n a.atc_2_name,\n a.atc_3_name,\n a.atc_4_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.core.pharmacy_claim p\nLEFT JOIN cms_synthetic.terminology.ndc n ON p.ndc_code = n.ndc\nLEFT JOIN cms_synthetic.terminology.rxnorm_brand_generic r ON n.rxcui = r.product_rxcui\nLEFT JOIN cms_synthetic.terminology.rxnorm_to_atc a ON n.rxcui = a.rxcui\nLEFT JOIN dedup_prac prac ON p.prescribing_provider_id = prac.practitioner_id\nLEFT JOIN dedup_loc l ON p.dispensing_provider_id = l.location_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient_risk_scores": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__patient_risk_scores", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__patient_risk_scores.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__patient_risk_scores.sql", "unique_id": "model.the_tuva_project.mart_review__patient_risk_scores", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient_risk_scores"], "alias": "mart_review__patient_risk_scores", "checksum": {"name": "sha256", "checksum": "a1733798b94d535bca5905e754769b569473a7d36ee54f559833f296ae62a913"}, "config": {"enabled": true, "alias": "mart_review__patient_risk_scores", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient_risk_scores", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4239638, "relation_name": "cms_synthetic.data_quality.mart_review__patient_risk_scores", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nselect *\nfrom {{ ref('cms_hcc__patient_risk_scores') }} p", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_scores"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__patient_risk_scores.sql", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom cms_synthetic.cms_hcc.patient_risk_scores p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient_risk_factors": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__patient_risk_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__patient_risk_factors.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__patient_risk_factors.sql", "unique_id": "model.the_tuva_project.mart_review__patient_risk_factors", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient_risk_factors"], "alias": "mart_review__patient_risk_factors", "checksum": {"name": "sha256", "checksum": "61380b18ad5d25b538aec2c70ee14155ecf3d12e0d6953bdda7df66d0136d500"}, "config": {"enabled": true, "alias": "mart_review__patient_risk_factors", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient_risk_factors", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.425175, "relation_name": "cms_synthetic.data_quality.mart_review__patient_risk_factors", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nselect *\n,dense_rank() over (order by patient_id, model_version, payment_year ) as patient_risk_sk\nfrom {{ ref('cms_hcc__patient_risk_factors') }} p", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__patient_risk_factors.sql", "compiled": true, "compiled_code": "\n\nselect *\n,dense_rank() over (order by patient_id, model_version, payment_year ) as patient_risk_sk\nfrom cms_synthetic.cms_hcc.patient_risk_factors p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__patient.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__patient.sql", "unique_id": "model.the_tuva_project.mart_review__patient", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient"], "alias": "mart_review__patient", "checksum": {"name": "sha256", "checksum": "a497ea22f6e491df5285409a618abb140b3125bfa9931506bd39c2864a6f6eb9"}, "config": {"enabled": true, "alias": "mart_review__patient", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.414686, "relation_name": "cms_synthetic.data_quality.mart_review__patient", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\nSELECT *,\n {{ dbt.concat([\n 'patient_id',\n \"'|'\",\n 'data_source']) }} as patient_data_source_key\nFROM {{ ref('core__patient')}}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__patient.sql", "compiled": true, "compiled_code": "\n\nSELECT *,\n patient_id || '|' || data_source as patient_data_source_key\nFROM cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__quality_measures_summary_long": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__quality_measures_summary_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__quality_measures_summary_long.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__quality_measures_summary_long.sql", "unique_id": "model.the_tuva_project.mart_review__quality_measures_summary_long", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__quality_measures_summary_long"], "alias": "mart_review__quality_measures_summary_long", "checksum": {"name": "sha256", "checksum": "eb992a196ba9170278aa32f292eda25197627f8bf09deb861a1b8a7ee214ef1f"}, "config": {"enabled": true, "alias": "mart_review__quality_measures_summary_long", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__quality_measures_summary_long", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.42641, "relation_name": "cms_synthetic.data_quality.mart_review__quality_measures_summary_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n\nselect *\nfrom {{ ref('quality_measures__summary_long') }} s", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__summary_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__quality_measures_summary_long.sql", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom cms_synthetic.quality_measures.summary_long s", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__enrollment_change": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__enrollment_change", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__enrollment_change.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__enrollment_change.sql", "unique_id": "model.the_tuva_project.mart_review__enrollment_change", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__enrollment_change"], "alias": "mart_review__enrollment_change", "checksum": {"name": "sha256", "checksum": "684ba89fd191b827bafb397e6a4bbbc9da2526ddc01fbd60b5f0fc2ab2a7fb80"}, "config": {"enabled": true, "alias": "mart_review__enrollment_change", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__enrollment_change", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4075048, "relation_name": "cms_synthetic.data_quality.mart_review__enrollment_change", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nWITH RankedMonths AS (\n SELECT\n patient_id,\n year_month,\n data_source,\n lag(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as prev_year_month,\n lead(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as next_year_month,\n year_month_date\n FROM {{ ref('mart_review__stg_member_month') }}\n),\nChanges AS (\n SELECT\n patient_id,\n data_source,\n year_month_date as change_month,\n case\n when prev_year_month is null\n or {{ dateadd('month', -1, 'year_month_date') }} != prev_year_month\n then 'added'\n end as change_type\nFROM RankedMonths\nunion all\nSELECT\n patient_id,\n data_source,\n {{ dateadd('month', 1, 'year_month_date') }} as change_month,\n case\n when next_year_month is null\n or {{ dateadd('month', 1, 'year_month_date') }} != next_year_month\n then 'removed'\n end as change_type\nFROM RankedMonths\n\n),\nFinal AS (\n SELECT\n {{ dbt.concat([\"patient_id\", \"'|'\", \"change_month\"]) }} as membermonthkey,\n data_source,\n patient_id,\n change_month,\n change_type\n FROM Changes\n WHERE change_type IS NOT NULL\n),\nResult AS (\n SELECT\n data_source,\n change_month,\n change_type,\n count(*) as member_count\n FROM Final\n GROUP BY data_source\n , change_month\n , change_type\n)\n\n\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM Result", "language": "sql", "refs": [{"name": "mart_review__stg_member_month", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.mart_review__stg_member_month"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__enrollment_change.sql", "compiled": true, "compiled_code": "\n\nWITH RankedMonths AS (\n SELECT\n patient_id,\n year_month,\n data_source,\n lag(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as prev_year_month,\n lead(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as next_year_month,\n year_month_date\n FROM cms_synthetic.data_quality.mart_review__stg_member_month\n),\nChanges AS (\n SELECT\n patient_id,\n data_source,\n year_month_date as change_month,\n case\n when prev_year_month is null\n or \n\n dateadd(\n month,\n -1,\n year_month_date\n )\n\n != prev_year_month\n then 'added'\n end as change_type\nFROM RankedMonths\nunion all\nSELECT\n patient_id,\n data_source,\n \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n as change_month,\n case\n when next_year_month is null\n or \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n != next_year_month\n then 'removed'\n end as change_type\nFROM RankedMonths\n\n),\nFinal AS (\n SELECT\n patient_id || '|' || change_month as membermonthkey,\n data_source,\n patient_id,\n change_month,\n change_type\n FROM Changes\n WHERE change_type IS NOT NULL\n),\nResult AS (\n SELECT\n data_source,\n change_month,\n change_type,\n count(*) as member_count\n FROM Final\n GROUP BY data_source\n , change_month\n , change_type\n)\n\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM Result", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__pmpm": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__pmpm", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__pmpm.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__pmpm.sql", "unique_id": "model.the_tuva_project.mart_review__pmpm", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__pmpm"], "alias": "mart_review__pmpm", "checksum": {"name": "sha256", "checksum": "8990d5d56bc2c4baf35f7e02632f8ef84fc45fa5e07f5593a1cf1e5d087413ae"}, "config": {"enabled": true, "alias": "mart_review__pmpm", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__pmpm", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.418653, "relation_name": "cms_synthetic.data_quality.mart_review__pmpm", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nSELECT *,\n total_paid * member_months AS total_paid_absolute,\n medical_paid * member_months AS medical_paid_absolute,\n pharmacy_paid * member_months AS pharmacy_paid_absolute,\n inpatient_paid * member_months AS inpatient_paid_absolute,\n outpatient_paid * member_months AS outpatient_paid_absolute,\n office_based_paid * member_months AS office_based_paid_absolute,\n ancillary_paid * member_months AS ancillary_paid_absolute,\n other_paid * member_months AS other_paid_absolute,\n {{ dbt.concat([\n 'data_source',\n \"'|'\",\n 'year_month']) }} as data_source_month_key\nFROM {{ ref('financial_pmpm__pmpm_payer') }}", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_payer", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_payer"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__pmpm.sql", "compiled": true, "compiled_code": "\n\n\nSELECT *,\n total_paid * member_months AS total_paid_absolute,\n medical_paid * member_months AS medical_paid_absolute,\n pharmacy_paid * member_months AS pharmacy_paid_absolute,\n inpatient_paid * member_months AS inpatient_paid_absolute,\n outpatient_paid * member_months AS outpatient_paid_absolute,\n office_based_paid * member_months AS office_based_paid_absolute,\n ancillary_paid * member_months AS ancillary_paid_absolute,\n other_paid * member_months AS other_paid_absolute,\n data_source || '|' || year_month as data_source_month_key\nFROM cms_synthetic.financial_pmpm.pmpm_payer", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__members_with_claims": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__members_with_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__members_with_claims.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__members_with_claims.sql", "unique_id": "model.the_tuva_project.mart_review__members_with_claims", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__members_with_claims"], "alias": "mart_review__members_with_claims", "checksum": {"name": "sha256", "checksum": "12dcf6a126b6441b55ec85d52667e8c731890fa7a1638fc0c20cc93697c65a21"}, "config": {"enabled": true, "alias": "mart_review__members_with_claims", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__members_with_claims", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.411818, "relation_name": "cms_synthetic.data_quality.mart_review__members_with_claims", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nWITH medical_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM {{ ref('mart_review__stg_medical_claim') }}\n GROUP BY data_source\n , patient_id\n , year_month\n)\n\n,pharmacy_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM {{ ref('mart_review__stg_pharmacy_claim') }}\n GROUP BY data_source\n , patient_id\n , year_month\n)\n, final as(\nSELECT\n mm.data_source,\n mm.year_month,\n SUM(CASE WHEN mc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_medical_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_pharmacy_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1\n WHEN mc.patient_id is not null THEN 1 ELSE 0 END) AS members_with_claims,\n COUNT(*) AS total_member_months\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('core__member_months')}} mm\nLEFT JOIN medical_claim mc\n ON mm.patient_id = mc.patient_id\n AND mm.data_source = mc.data_source\n AND mm.year_month = mc.year_month\nLEFT JOIN pharmacy_claim pc\n ON mm.patient_id = pc.patient_id\n AND mm.data_source = pc.data_source\n AND mm.year_month = pc.year_month\nGROUP BY mm.data_source, mm.year_month\n)\n\nselect\n data_source\n , year_month\n , members_with_medical_claims\n , members_with_pharmacy_claims\n , members_with_claims\n , total_member_months\n , cast(members_with_claims/ total_member_months as {{ dbt.type_numeric()}}) as percent_members_with_claims\n , cast(members_with_medical_claims/ total_member_months as {{ dbt.type_numeric()}}) as percent_members_with_medical_claims\n , cast(members_with_pharmacy_claims/ total_member_months as {{ dbt.type_numeric()}}) as percent_members_with_pharmacy_claims\nfrom final", "language": "sql", "refs": [{"name": "mart_review__stg_medical_claim", "package": null, "version": null}, {"name": "mart_review__stg_pharmacy_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.mart_review__stg_pharmacy_claim", "model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__members_with_claims.sql", "compiled": true, "compiled_code": "\n\nWITH medical_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM cms_synthetic.data_quality.mart_review__stg_medical_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n\n,pharmacy_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM cms_synthetic.data_quality.mart_review__stg_pharmacy_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n, final as(\nSELECT\n mm.data_source,\n mm.year_month,\n SUM(CASE WHEN mc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_medical_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_pharmacy_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1\n WHEN mc.patient_id is not null THEN 1 ELSE 0 END) AS members_with_claims,\n COUNT(*) AS total_member_months\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.core.member_months mm\nLEFT JOIN medical_claim mc\n ON mm.patient_id = mc.patient_id\n AND mm.data_source = mc.data_source\n AND mm.year_month = mc.year_month\nLEFT JOIN pharmacy_claim pc\n ON mm.patient_id = pc.patient_id\n AND mm.data_source = pc.data_source\n AND mm.year_month = pc.year_month\nGROUP BY mm.data_source, mm.year_month\n)\n\nselect\n data_source\n , year_month\n , members_with_medical_claims\n , members_with_pharmacy_claims\n , members_with_claims\n , total_member_months\n , cast(members_with_claims/ total_member_months as numeric(28,6)) as percent_members_with_claims\n , cast(members_with_medical_claims/ total_member_months as numeric(28,6)) as percent_members_with_medical_claims\n , cast(members_with_pharmacy_claims/ total_member_months as numeric(28,6)) as percent_members_with_pharmacy_claims\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient_risk": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__patient_risk", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__patient_risk.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__patient_risk.sql", "unique_id": "model.the_tuva_project.mart_review__patient_risk", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient_risk"], "alias": "mart_review__patient_risk", "checksum": {"name": "sha256", "checksum": "3a86e5214b962a5c507e9fe9af4695bc07722e68a58b2b8d160ca7242d379107"}, "config": {"enabled": true, "alias": "mart_review__patient_risk", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient_risk", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.416051, "relation_name": "cms_synthetic.data_quality.mart_review__patient_risk", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nWITH cte AS (\n SELECT \n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n SUM(coefficient) AS risk_score\n FROM {{ ref('mart_review__patient_risk_factors') }}\n GROUP BY payment_year,\n patient_id,\n model_version,\n patient_risk_sk\n)\n\nSELECT \n CASE \n WHEN risk_score <= 0.5 THEN '.5'\n WHEN risk_score BETWEEN 0.5 AND 1.0 THEN '1'\n WHEN risk_score BETWEEN 1.0 AND 1.5 THEN '1.5'\n WHEN risk_score BETWEEN 1.5 AND 2.0 THEN '2'\n WHEN risk_score BETWEEN 2.0 AND 2.5 THEN '2.5'\n WHEN risk_score BETWEEN 2.5 AND 3.0 THEN '3'\n WHEN risk_score BETWEEN 3.0 AND 3.5 THEN '3.5'\n WHEN risk_score BETWEEN 3.5 AND 4.0 THEN '4'\n WHEN risk_score BETWEEN 4.0 AND 4.5 THEN '4.5'\n WHEN risk_score BETWEEN 4.5 AND 5.0 THEN '5'\n WHEN risk_score > 5.0 THEN '5+'\n ELSE null \n END AS risk_score_bucket,\n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n risk_score\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM cte", "language": "sql", "refs": [{"name": "mart_review__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.mart_review__patient_risk_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__patient_risk.sql", "compiled": true, "compiled_code": "\n\n\nWITH cte AS (\n SELECT \n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n SUM(coefficient) AS risk_score\n FROM cms_synthetic.data_quality.mart_review__patient_risk_factors\n GROUP BY payment_year,\n patient_id,\n model_version,\n patient_risk_sk\n)\n\nSELECT \n CASE \n WHEN risk_score <= 0.5 THEN '.5'\n WHEN risk_score BETWEEN 0.5 AND 1.0 THEN '1'\n WHEN risk_score BETWEEN 1.0 AND 1.5 THEN '1.5'\n WHEN risk_score BETWEEN 1.5 AND 2.0 THEN '2'\n WHEN risk_score BETWEEN 2.0 AND 2.5 THEN '2.5'\n WHEN risk_score BETWEEN 2.5 AND 3.0 THEN '3'\n WHEN risk_score BETWEEN 3.0 AND 3.5 THEN '3.5'\n WHEN risk_score BETWEEN 3.5 AND 4.0 THEN '4'\n WHEN risk_score BETWEEN 4.0 AND 4.5 THEN '4.5'\n WHEN risk_score BETWEEN 4.5 AND 5.0 THEN '5'\n WHEN risk_score > 5.0 THEN '5+'\n ELSE null \n END AS risk_score_bucket,\n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n risk_score\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__ed_classification": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__ed_classification", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__ed_classification.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__ed_classification.sql", "unique_id": "model.the_tuva_project.mart_review__ed_classification", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__ed_classification"], "alias": "mart_review__ed_classification", "checksum": {"name": "sha256", "checksum": "a2ef1e0ebdefcff71374e872af5255e8cef6cec44b8eab64f1c6b13f1d293435"}, "config": {"enabled": true, "alias": "mart_review__ed_classification", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__ed_classification", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.406045, "relation_name": "cms_synthetic.data_quality.mart_review__ed_classification", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nWITH cte AS\n(\n SELECT DISTINCT location_id, npi, name\n FROM {{ ref('core__location')}}\n)\n\nSELECT\n e.encounter_id,\n case when s.encounter_id is null then 'Not Classified' else s.ed_classification_description end as ed_classification_description,\n CASE\n when s.encounter_id is null then 'Non-Avoidable'\n when cast(s.ed_classification_order as int) <= 3 then s.ed_classification_description\n ELSE 'Non-Avoidable' END AS avoidable_category,\n e.paid_amount,\n e.primary_diagnosis_code,\n e.primary_diagnosis_description,\n {{ dbt.concat([\n 'e.primary_diagnosis_code',\n \"' | '\",\n 'e.primary_diagnosis_description'\n ]) }} as primary_diagnosis_and_description,\n p.ccsr_parent_category,\n p.ccsr_category,\n p.ccsr_category_description,\n {{ dbt.concat([\n 'p.ccsr_category',\n \"' | '\",\n 'p.ccsr_category_description'\n ]) }} as ccsr_parent_category_and_description,\n b.body_system,\n e.facility_id,\n e.allowed_amount,\n e.charge_amount,\n e.data_source,\n e.length_of_stay,\n {{ dbt.concat([\n \"e.discharge_disposition_code\",\n \"' | '\",\n \"e.discharge_disposition_description\"\n ]) }} as discharge_code_and_description,\n {{ dbt.concat([\n \"e.patient_id\",\n \"' | '\",\n \"e.data_source\"\n ]) }} as patient_source_key,\n e.facility_name,\n e.encounter_start_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__encounter')}} e\nleft join {{ ref('ed_classification__summary') }} s on e.encounter_id = s.encounter_id\nleft join cte on e.facility_id = cte.location_id\nleft join {{ ref('ccsr__dx_vertical_pivot') }} as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\nleft join {{ ref('ccsr__dxccsr_v2023_1_body_systems') }} b on p.ccsr_parent_category = b.ccsr_parent_category\nwhere e.encounter_type = 'emergency department'", "language": "sql", "refs": [{"name": "core__location", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "ed_classification__summary", "package": null, "version": null}, {"name": "ccsr__dx_vertical_pivot", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_body_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__location", "model.the_tuva_project.core__encounter", "model.the_tuva_project.ed_classification__summary", "model.the_tuva_project.ccsr__dx_vertical_pivot", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__ed_classification.sql", "compiled": true, "compiled_code": "\n\nWITH cte AS\n(\n SELECT DISTINCT location_id, npi, name\n FROM cms_synthetic.core.location\n)\n\nSELECT\n e.encounter_id,\n case when s.encounter_id is null then 'Not Classified' else s.ed_classification_description end as ed_classification_description,\n CASE\n when s.encounter_id is null then 'Non-Avoidable'\n when cast(s.ed_classification_order as int) <= 3 then s.ed_classification_description\n ELSE 'Non-Avoidable' END AS avoidable_category,\n e.paid_amount,\n e.primary_diagnosis_code,\n e.primary_diagnosis_description,\n e.primary_diagnosis_code || ' | ' || e.primary_diagnosis_description as primary_diagnosis_and_description,\n p.ccsr_parent_category,\n p.ccsr_category,\n p.ccsr_category_description,\n p.ccsr_category || ' | ' || p.ccsr_category_description as ccsr_parent_category_and_description,\n b.body_system,\n e.facility_id,\n e.allowed_amount,\n e.charge_amount,\n e.data_source,\n e.length_of_stay,\n e.discharge_disposition_code || ' | ' || e.discharge_disposition_description as discharge_code_and_description,\n e.patient_id || ' | ' || e.data_source as patient_source_key,\n e.facility_name,\n e.encounter_start_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter e\nleft join cms_synthetic.ed_classification.summary s on e.encounter_id = s.encounter_id\nleft join cte on e.facility_id = cte.location_id\nleft join cms_synthetic.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\nleft join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems b on p.ccsr_parent_category = b.ccsr_parent_category\nwhere e.encounter_type = 'emergency department'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__calendar_month": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__calendar_month", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__calendar_month.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__calendar_month.sql", "unique_id": "model.the_tuva_project.mart_review__calendar_month", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__calendar_month"], "alias": "mart_review__calendar_month", "checksum": {"name": "sha256", "checksum": "b81ef63cc6a4c254f6ccf6bdd8392080ec74678910b651f5ef5c637acf0bfa7a"}, "config": {"enabled": true, "alias": "mart_review__calendar_month", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__calendar_month", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.422484, "relation_name": "cms_synthetic.data_quality.mart_review__calendar_month", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect distinct\ncast(year_month_int as {{ dbt.type_string() }}) as year_month\n, full_date\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('reference_data__calendar') }} c\nwhere day = 1", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__calendar_month.sql", "compiled": true, "compiled_code": "\n\n\nselect distinct\ncast(year_month_int as TEXT) as year_month\n, full_date\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.reference_data.calendar c\nwhere day = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__member_months": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__member_months.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__member_months.sql", "unique_id": "model.the_tuva_project.mart_review__member_months", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__member_months"], "alias": "mart_review__member_months", "checksum": {"name": "sha256", "checksum": "5df88d5d05bf5f9a98b43a22d2953db041672ffb0cb06f936cddb3222dc48e8f"}, "config": {"enabled": true, "alias": "mart_review__member_months", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__member_months", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.410175, "relation_name": "cms_synthetic.data_quality.mart_review__member_months", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nSELECT m.*,\n COALESCE(p.total_paid, 0) AS total_paid,\n COALESCE(p.medical_paid, 0) AS medical_paid,\n COALESCE(p.pharmacy_paid, 0) AS pharmacy_paid,\n {{ dbt.concat([\n 'm.patient_id',\n \"' | '\",\n 'm.data_source'\n ]) }} AS patient_data_source_key,\n {{ dbt.concat([\n 'm.patient_id',\n \"' | '\",\n 'm.data_source',\n \"' | '\",\n 'm.year_month'\n ]) }} AS member_month_key\nFROM {{ ref('core__member_months')}} m\nLEFT JOIN {{ ref('financial_pmpm__pmpm_prep') }} p ON m.patient_id = p.patient_id\n AND m.data_source = p.data_source\n AND m.year_month = p.year_month", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__member_months.sql", "compiled": true, "compiled_code": "\n\nSELECT m.*,\n COALESCE(p.total_paid, 0) AS total_paid,\n COALESCE(p.medical_paid, 0) AS medical_paid,\n COALESCE(p.pharmacy_paid, 0) AS pharmacy_paid,\n m.patient_id || ' | ' || m.data_source AS patient_data_source_key,\n m.patient_id || ' | ' || m.data_source || ' | ' || m.year_month AS member_month_key\nFROM cms_synthetic.core.member_months m\nLEFT JOIN cms_synthetic.financial_pmpm.pmpm_prep p ON m.patient_id = p.patient_id\n AND m.data_source = p.data_source\n AND m.year_month = p.year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__claims_with_enrollment": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__claims_with_enrollment", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__claims_with_enrollment.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__claims_with_enrollment.sql", "unique_id": "model.the_tuva_project.mart_review__claims_with_enrollment", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__claims_with_enrollment"], "alias": "mart_review__claims_with_enrollment", "checksum": {"name": "sha256", "checksum": "9961c91c4ea461d4e41da1d74e4e2a87c8088afd93329b48bd3959755965c263"}, "config": {"enabled": true, "alias": "mart_review__claims_with_enrollment", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__claims_with_enrollment", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.403456, "relation_name": "cms_synthetic.data_quality.mart_review__claims_with_enrollment", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nwith enrollment_stage as(\nSELECT\n mc.data_source,\n mc.year_month,\n SUM(CASE WHEN mm.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS claims_with_enrollment,\n COUNT(*) AS claims\nFROM {{ ref('mart_review__stg_medical_claim') }} mc\nLEFT JOIN {{ ref('core__member_months')}} mm\n ON mc.patient_id = mm.patient_id\n AND mc.data_source = mm.data_source\n AND mc.year_month = mm.year_month\nGROUP BY mc.data_source\n, mc.year_month\n)\n\nselect\n data_source\n , year_month\n , claims_with_enrollment\n , claims\n , cast(claims_with_enrollment / claims as {{ dbt.type_numeric()}} ) AS percentage_claims_with_enrollment\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom enrollment_stage", "language": "sql", "refs": [{"name": "mart_review__stg_medical_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__claims_with_enrollment.sql", "compiled": true, "compiled_code": "\n\nwith enrollment_stage as(\nSELECT\n mc.data_source,\n mc.year_month,\n SUM(CASE WHEN mm.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS claims_with_enrollment,\n COUNT(*) AS claims\nFROM cms_synthetic.data_quality.mart_review__stg_medical_claim mc\nLEFT JOIN cms_synthetic.core.member_months mm\n ON mc.patient_id = mm.patient_id\n AND mc.data_source = mm.data_source\n AND mc.year_month = mm.year_month\nGROUP BY mc.data_source\n, mc.year_month\n)\n\nselect\n data_source\n , year_month\n , claims_with_enrollment\n , claims\n , cast(claims_with_enrollment / claims as numeric(28,6) ) AS percentage_claims_with_enrollment\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom enrollment_stage", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__readmissions": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__readmissions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__readmissions.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__readmissions.sql", "unique_id": "model.the_tuva_project.mart_review__readmissions", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__readmissions"], "alias": "mart_review__readmissions", "checksum": {"name": "sha256", "checksum": "5c51515a30eee302c1dccc45b69964be4e4fc1f5bf4e7371a46ec3c76f1bfbc1"}, "config": {"enabled": true, "alias": "mart_review__readmissions", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__readmissions", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.420058, "relation_name": "cms_synthetic.data_quality.mart_review__readmissions", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nSELECT *\nFROM {{ ref('readmissions__readmission_summary') }}\nWHERE index_admission_flag = 1", "language": "sql", "refs": [{"name": "readmissions__readmission_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__readmission_summary"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__readmissions.sql", "compiled": true, "compiled_code": "\n\nSELECT *\nFROM cms_synthetic.readmissions.readmission_summary\nWHERE index_admission_flag = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__quality_measures_value_set": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__quality_measures_value_set", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__quality_measures_value_set.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__quality_measures_value_set.sql", "unique_id": "model.the_tuva_project.mart_review__quality_measures_value_set", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__quality_measures_value_set"], "alias": "mart_review__quality_measures_value_set", "checksum": {"name": "sha256", "checksum": "80eabeec114985d3686b2833eaba92256cafb15fb6f4920cd1d74437141d5de9"}, "config": {"enabled": true, "alias": "mart_review__quality_measures_value_set", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__quality_measures_value_set", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.428074, "relation_name": "cms_synthetic.data_quality.mart_review__quality_measures_value_set", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('quality_measures__measures') }} p", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__quality_measures_value_set.sql", "compiled": true, "compiled_code": "\n\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.quality_measures._value_set_measures p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__number_of_conditions": {"database": "cms_synthetic", "schema": "data_quality", "name": "mart_review__number_of_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/mart_review/final/mart_review__number_of_conditions.sql", "original_file_path": "models/data_quality/dqi/mart_review/final/mart_review__number_of_conditions.sql", "unique_id": "model.the_tuva_project.mart_review__number_of_conditions", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__number_of_conditions"], "alias": "mart_review__number_of_conditions", "checksum": {"name": "sha256", "checksum": "e1b6e01c3215257f323baa0a55e8d4a5b4784477caa7de384a4bc7f0a19c9edd"}, "config": {"enabled": true, "alias": "mart_review__number_of_conditions", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/mart_review/mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__number_of_conditions", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4132721, "relation_name": "cms_synthetic.data_quality.mart_review__number_of_conditions", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\nwith xwalk as (\n select distinct patient_id, data_source\n from {{ ref('core__patient')}}\n),\ncte as (\n select l.patient_id,\n x.data_source,\n count(*) as numofconditions\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long') }} l\n left join xwalk x on l.patient_id = x.patient_id\n group by l.patient_id, x.data_source\n)\nselect p.patient_id,\n p.data_source,\n {{ dbt.concat([\n 'p.patient_id',\n \"'|'\",\n 'p.data_source']) }} as patient_source_key,\n coalesce(cte.numofconditions, 0) as numofconditions\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__patient')}} p\nleft join cte on p.patient_id = cte.patient_id and p.data_source = cte.data_source", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__patient", "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/mart_review/final/mart_review__number_of_conditions.sql", "compiled": true, "compiled_code": "\n\nwith xwalk as (\n select distinct patient_id, data_source\n from cms_synthetic.core.patient\n),\ncte as (\n select l.patient_id,\n x.data_source,\n count(*) as numofconditions\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long l\n left join xwalk x on l.patient_id = x.patient_id\n group by l.patient_id, x.data_source\n)\nselect p.patient_id,\n p.data_source,\n p.patient_id || '|' || p.data_source as patient_source_key,\n coalesce(cte.numofconditions, 0) as numofconditions\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient p\nleft join cte on p.patient_id = cte.patient_id and p.data_source = cte.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_institutional_inpatient": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "data_quality__stg_institutional_inpatient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/stage/data_quality__stg_institutional_inpatient.sql", "original_file_path": "models/data_quality/dqi/stage/data_quality__stg_institutional_inpatient.sql", "unique_id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_institutional_inpatient"], "alias": "data_quality__stg_institutional_inpatient", "checksum": {"name": "sha256", "checksum": "ffc1f4a4681d63809a17dab8d93dd280e2432b32a6018ea39dd8d697da4b510a"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.400325, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\n SELECT *\n FROM {{ ref('medical_claim') }}\n WHERE claim_type = 'institutional'\n AND {{ substring('bill_type_code', 1, 2) }} = '11'", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/stage/data_quality__stg_institutional_inpatient.sql", "compiled": true, "compiled_code": "\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_pharmacy_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "data_quality__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/stage/data_quality__stg_pharmacy_claim.sql", "original_file_path": "models/data_quality/dqi/stage/data_quality__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.data_quality__stg_pharmacy_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_pharmacy_claim"], "alias": "data_quality__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "c8a3c952dff7222984e0cc6085bf81d97f5f3a45713ad671d5154bd2a68dda4c"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.401618, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nselect * from {{ ref('pharmacy_claim')}}", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/stage/data_quality__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect * from tuva.input_layer.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_eligibility": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "data_quality__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/stage/data_quality__stg_eligibility.sql", "original_file_path": "models/data_quality/dqi/stage/data_quality__stg_eligibility.sql", "unique_id": "model.the_tuva_project.data_quality__stg_eligibility", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_eligibility"], "alias": "data_quality__stg_eligibility", "checksum": {"name": "sha256", "checksum": "1e2cea8a8f2fa6627a0a48d3505037471d3d14188ee4c23cbcab8516c6e1d89e"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.39966, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nselect * from {{ ref('eligibility')}}", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/stage/data_quality__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\nselect * from tuva.input_layer.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_medical_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "data_quality__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/stage/data_quality__stg_medical_claim.sql", "original_file_path": "models/data_quality/dqi/stage/data_quality__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.data_quality__stg_medical_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_medical_claim"], "alias": "data_quality__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "3afbb32dd0153963cee7e343ac28517f764126d222cde28304e7a3c95fd65818"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.400976, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nselect * from {{ ref('medical_claim')}}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/stage/data_quality__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect * from tuva.input_layer.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "data_quality__crosswalk_field_to_mart_sk", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/final/data_quality__crosswalk_field_to_mart_sk.sql", "original_file_path": "models/data_quality/dqi/final/data_quality__crosswalk_field_to_mart_sk.sql", "unique_id": "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__crosswalk_field_to_mart_sk"], "alias": "data_quality__crosswalk_field_to_mart_sk", "checksum": {"name": "sha256", "checksum": "f499d02980dfe9e1540351578b40c753628881ebae1e2da3a202ebbbe1ac3f83"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623952.4202712, "relation_name": "cms_synthetic.dbt_tom.data_quality__crosswalk_field_to_mart_sk", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('clinical_enabled', False))\n) }}\n\n{#\nThis code ensures all fields that have atomic level data quality checks\nrun against them are included in the SUMMARY_SK creation list even if they are not mapped to\nany downstream marts, and thus not in the crosswalk fields to marts.\n#}\n\nwith results as (\n\n select distinct\n table_name as input_layer_table_name\n , claim_type\n , field_name\n , cast(NULL as {{ dbt.type_string() }}) AS mart_name\n from {{ ref('data_quality__data_quality_detail') }}\n\n union all\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n from {{ ref('data_quality__crosswalk_field_to_mart') }}\n\n)\n\n, final as (\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n , DENSE_RANK () OVER (ORDER BY input_layer_table_name, claim_type, field_name) as table_claim_type_field_sk\n\t, '{{ var('tuva_last_run')}}' as tuva_last_run\n from results\n group by\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n\n)\n\nselect * from final", "language": "sql", "refs": [{"name": "data_quality__data_quality_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_to_mart", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_to_mart"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/final/data_quality__crosswalk_field_to_mart_sk.sql", "compiled": true, "compiled_code": "\n\n\n\nwith results as (\n\n select distinct\n table_name as input_layer_table_name\n , claim_type\n , field_name\n , cast(NULL as TEXT) AS mart_name\n from cms_synthetic.data_quality.data_quality_detail\n\n union all\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n from cms_synthetic.data_quality._value_set_crosswalk_field_to_mart\n\n)\n\n, final as (\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n , DENSE_RANK () OVER (ORDER BY input_layer_table_name, claim_type, field_name) as table_claim_type_field_sk\n\t, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from results\n group by\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__raw_summary": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__raw_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/final/data_quality__raw_summary.sql", "original_file_path": "models/data_quality/dqi/final/data_quality__raw_summary.sql", "unique_id": "model.the_tuva_project.data_quality__raw_summary", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__raw_summary"], "alias": "raw_summary", "checksum": {"name": "sha256", "checksum": "80f65475e59921da49d27decf7ae224708354ff13df7195d58578ed465995aa9"}, "config": {"enabled": true, "alias": "raw_summary", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"source": {"name": "source", "description": "Whether info came from raw data or input_layer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Table data check was run on", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "row_count": {"name": "row_count", "description": "Number of rows in table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "unique_check": {"name": "unique_check", "description": "Number of unique values in the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "unique_check_desc": {"name": "unique_check_desc", "description": "Explanation of what the unique check is on that specific table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_order": {"name": "table_order", "description": "Column used to sort the result set in a logical order", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "raw_summary", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.984669, "relation_name": "cms_synthetic.data_quality.raw_summary", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith cte as (\n select \n 'input_layer' as source\n , 'eligibility' as table_name\n , count(*) as row_count\n , count(distinct patient_id) as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 2 as table_order\n from {{ ref('eligibility') }}\n\n union all\n\n select \n 'raw_data' as source\n , 'eligibility' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 1 as table_order\n from {{ ref('eligibility') }}\n\n union all\n\n select \n 'input_layer' as source\n , 'medical_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 4 as table_order\n from {{ ref('medical_claim') }}\n\n union all\n\n select \n 'raw_data' as source\n , 'medical_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 3 as table_order\n from {{ ref('medical_claim') }}\n\n union all\n\n select \n 'input_layer' as source\n , 'pharmacy_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 6 as table_order\n from {{ ref('pharmacy_claim') }}\n\n union all\n\n select \n 'raw_data' as source\n , 'pharmacy_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 5 as table_order\n from {{ ref('pharmacy_claim') }}\n)\n\nselect\n cte.*\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom cte", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/final/data_quality__raw_summary.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n 'input_layer' as source\n , 'eligibility' as table_name\n , count(*) as row_count\n , count(distinct patient_id) as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 2 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'raw_data' as source\n , 'eligibility' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 1 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'input_layer' as source\n , 'medical_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 4 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'medical_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 3 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'input_layer' as source\n , 'pharmacy_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 6 as table_order\n from tuva.input_layer.pharmacy_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'pharmacy_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 5 as table_order\n from tuva.input_layer.pharmacy_claim\n)\n\nselect\n cte.*\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_detail": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_detail", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/final/data_quality__data_quality_detail.sql", "original_file_path": "models/data_quality/dqi/final/data_quality__data_quality_detail.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_detail", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__data_quality_detail"], "alias": "data_quality_detail", "checksum": {"name": "sha256", "checksum": "8164e4941eebbc47d08c8103111d9be3881b41d2c3a7311ea3f0751a46ccf23a"}, "config": {"enabled": true, "alias": "data_quality_detail", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_date": {"name": "source_date", "description": "The source date relevant to the field_name (e.g. field_name = death_date means the source_date = death_date)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Name of the input table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_key": {"name": "drill_down_key", "description": "Key for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_value": {"name": "drill_down_value", "description": "Value for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "The claim type (e.g. institutional or professional) or data type (e.g. clinical or claims)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_name": {"name": "field_name", "description": "Name of the input table column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bucket_name": {"name": "bucket_name", "description": "Category of data quality test result", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_reason": {"name": "invalid_reason", "description": "Reason row failed data quality test(s)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_value": {"name": "field_value", "description": "The source column value being tested", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_detail", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.978623, "relation_name": "cms_synthetic.data_quality.data_quality_detail", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',False))\n )\n}}\n\n{% if var('clinical_enabled', False) == true and var('claims_enabled', False) == true -%}\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\tclaim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\n\nunion all\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\t'CLINICAL' AS claim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_clinical_detail') }}\n\n{% elif var('claims_enabled', False) == true -%}\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\tclaim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\n\n{% elif var('clinical_enabled', False) == true -%}\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\t'clinical' as claim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_clinical_detail') }}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_claims_detail", "model.the_tuva_project.data_quality__data_quality_clinical_detail"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/final/data_quality__data_quality_detail.sql", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\tclaim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\n\nunion all\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\t'CLINICAL' AS claim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_clinical_detail\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__summary": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/final/data_quality__summary.sql", "original_file_path": "models/data_quality/dqi/final/data_quality__summary.sql", "unique_id": "model.the_tuva_project.data_quality__summary", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__summary"], "alias": "summary", "checksum": {"name": "sha256", "checksum": "57092ef04b8d50b1a6f3f6c168530a163cb0267e9b5f9c13dfa2a310730abcd4"}, "config": {"enabled": true, "alias": "summary", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_claim_type_field_sk": {"name": "table_claim_type_field_sk", "description": "Surrogate key for claim type field.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Name of the input table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "The claim type (e.g. institutional or professional) or data type (e.g. clinical or claims)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_name": {"name": "field_name", "description": "Name of the input table column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "red": {"name": "red", "description": "Percentage to show data quality check as red (bad)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "green": {"name": "green", "description": "Percentage to show data quality check as green (good)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "valid_num": {"name": "valid_num", "description": "Number of rows valid", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fill_num": {"name": "fill_num", "description": "Number of rows filled", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denom": {"name": "denom", "description": "The denominator for the data quality tests", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "summary", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.986702, "relation_name": "cms_synthetic.data_quality.summary", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',False))\n )\n}}\n\nWITH CTE AS (\n SELECT DISTINCT fm.field_name\n ,fm.input_layer_table_name\n ,fm.claim_type\n ,table_claim_type_field_sk\n FROM {{ ref('data_quality__crosswalk_field_to_mart_sk') }} fm\n)\n\nSELECT\n summary_sk,\n fm.table_claim_type_field_sk,\n data_source,\n x.table_name,\n x.claim_type,\n x.field_name,\n sct.red,\n sct.green,\n sum(case when bucket_name = 'valid' then 1 else 0 end) as valid_num,\n sum(case when bucket_name <> 'null' then 1 else 0 end) as fill_num,\n count(drill_down_value) as denom,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n {{ ref('data_quality__data_quality_detail') }} x\nLEFT JOIN CTE fm\n on x.field_name = fm.field_name\n and\n fm.input_layer_table_name = x.table_name\n and\n fm.claim_type = x.claim_type\nLEFT JOIN {{ ref('data_quality__crosswalk_field_info') }} sct\n on x.field_name = sct.field_name\n and\n sct.input_layer_table_name = x.table_name\n and\n sct.claim_type = x.claim_type\nGROUP BY\n summary_sk,\n data_source,\n fm.table_claim_type_field_sk,\n x.claim_type,\n x.table_name,\n x.field_name,\n sct.red,\n sct.green", "language": "sql", "refs": [{"name": "data_quality__crosswalk_field_to_mart_sk", "package": null, "version": null}, {"name": "data_quality__data_quality_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_info", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/final/data_quality__summary.sql", "compiled": true, "compiled_code": "\n\nWITH CTE AS (\n SELECT DISTINCT fm.field_name\n ,fm.input_layer_table_name\n ,fm.claim_type\n ,table_claim_type_field_sk\n FROM cms_synthetic.dbt_tom.data_quality__crosswalk_field_to_mart_sk fm\n)\n\nSELECT\n summary_sk,\n fm.table_claim_type_field_sk,\n data_source,\n x.table_name,\n x.claim_type,\n x.field_name,\n sct.red,\n sct.green,\n sum(case when bucket_name = 'valid' then 1 else 0 end) as valid_num,\n sum(case when bucket_name <> 'null' then 1 else 0 end) as fill_num,\n count(drill_down_value) as denom,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n cms_synthetic.data_quality.data_quality_detail x\nLEFT JOIN CTE fm\n on x.field_name = fm.field_name\n and\n fm.input_layer_table_name = x.table_name\n and\n fm.claim_type = x.claim_type\nLEFT JOIN cms_synthetic.data_quality._value_set_crosswalk_field_info sct\n on x.field_name = sct.field_name\n and\n sct.input_layer_table_name = x.table_name\n and\n sct.claim_type = x.claim_type\nGROUP BY\n summary_sk,\n data_source,\n fm.table_claim_type_field_sk,\n x.claim_type,\n x.table_name,\n x.field_name,\n sct.red,\n sct.green", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__quality_trend": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__quality_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/final/data_quality__quality_trend.sql", "original_file_path": "models/data_quality/dqi/final/data_quality__quality_trend.sql", "unique_id": "model.the_tuva_project.data_quality__quality_trend", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__quality_trend"], "alias": "quality_trend", "checksum": {"name": "sha256", "checksum": "ec7d140715b9bfef68ae977dcbce0bcd5d43abbf6e230196e4d3883757035e35"}, "config": {"enabled": true, "alias": "quality_trend", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"first_day_of_month": {"name": "first_day_of_month", "description": "The first day of a given month in date format", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "valid_num": {"name": "valid_num", "description": "Number of rows valid", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fill_num": {"name": "fill_num", "description": "Number of rows filled", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denom": {"name": "denom", "description": "The denominator for the data quality tests", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "quality_trend", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.9823859, "relation_name": "cms_synthetic.data_quality.quality_trend", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',False))\n )\n}}\n\n\nwith cte as (\nselect {{ try_to_cast_date('d.source_date' ) }} as source_date_type\n ,summary_sk\n ,SUM(CASE WHEN bucket_name = 'valid' THEN 1 ELSE 0 END) as valid_num\n ,SUM(CASE WHEN bucket_name <> 'null' THEN 1 ELSE 0 END) as fill_num\n ,COUNT(drill_down_value) as denom\nfrom {{ ref('data_quality__data_quality_detail') }} d\ngroup by\n {{ try_to_cast_date('d.source_date') }}\n ,summary_sk\n\n)\n\nselect\n c.first_day_of_month\n , summary_sk\n , sum(valid_num) as valid_num\n , sum(fill_num) as fill_num\n , sum(denom) as denom\nfrom cte\nleft join {{ ref('reference_data__calendar') }} c on cte.source_date_type = c.full_date\ngroup by\n c.first_day_of_month\n , summary_sk", "language": "sql", "refs": [{"name": "data_quality__data_quality_detail", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.try_to_cast_date"], "nodes": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/final/data_quality__quality_trend.sql", "compiled": true, "compiled_code": "\n\n\nwith cte as (\nselect try_cast( d.source_date as date ) as source_date_type\n ,summary_sk\n ,SUM(CASE WHEN bucket_name = 'valid' THEN 1 ELSE 0 END) as valid_num\n ,SUM(CASE WHEN bucket_name <> 'null' THEN 1 ELSE 0 END) as fill_num\n ,COUNT(drill_down_value) as denom\nfrom cms_synthetic.data_quality.data_quality_detail d\ngroup by\n try_cast( d.source_date as date )\n ,summary_sk\n\n)\n\nselect\n c.first_day_of_month\n , summary_sk\n , sum(valid_num) as valid_num\n , sum(fill_num) as fill_num\n , sum(denom) as denom\nfrom cte\nleft join cms_synthetic.reference_data.calendar c on cte.source_date_type = c.full_date\ngroup by\n c.first_day_of_month\n , summary_sk", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_for_pbi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_for_pbi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/final/data_quality__data_quality_for_pbi.sql", "original_file_path": "models/data_quality/dqi/final/data_quality__data_quality_for_pbi.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_for_pbi", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__data_quality_for_pbi"], "alias": "data_quality_for_pbi", "checksum": {"name": "sha256", "checksum": "90c189c3733499180e84fa4d2b5876e0864b73ef51542c19ee85cacf31de65a2"}, "config": {"enabled": true, "alias": "data_quality_for_pbi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Name of the input table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "The claim type (e.g. institutional or professional) or data type (e.g. clinical or claims)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_name": {"name": "field_name", "description": "Name of the input table column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bucket_name": {"name": "bucket_name", "description": "Category of data quality test result", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_reason": {"name": "invalid_reason", "description": "Reason row failed data quality test(s)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_key": {"name": "drill_down_key", "description": "Key for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_value": {"name": "drill_down_value", "description": "Value for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_value": {"name": "field_value", "description": "The source column value being tested", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "frequency": {"name": "frequency", "description": "Count of frequency", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_for_pbi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.9805372, "relation_name": "cms_synthetic.data_quality.data_quality_for_pbi", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('clinical_enabled',False))\n )\n}}\n\n{% if var('clinical_enabled', False) == true and var('claims_enabled', False) == true -%}\n\nSELECT\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_for_pbi') }}\n\nunion all\n\nSELECT\n data_source,\n field_name,\n table_name,\n 'CLINICAL' AS claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_clinical_for_pbi') }}\n\n{% elif var('claims_enabled', False) == true -%}\n\nSELECT\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_for_pbi') }}\n\n{% elif var('clinical_enabled', False) == true -%}\n\nSELECT\n data_source,\n field_name,\n table_name,\n 'CLINICAL' AS claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_clinical_for_pbi') }}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "data_quality__data_quality_claims_for_pbi", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_for_pbi", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/final/data_quality__data_quality_for_pbi.sql", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_for_pbi\n\nunion all\n\nSELECT\n data_source,\n field_name,\n table_name,\n 'CLINICAL' AS claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_clinical_for_pbi\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_practice_affiliation": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_practice_affiliation", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_practice_affiliation.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_practice_affiliation.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_practice_affiliation"], "alias": "practitioner_practice_affiliation", "checksum": {"name": "sha256", "checksum": "a6e8dbda851921e23fa00487b219cfc3af60068b2f97b436d5d37c682c00c259"}, "config": {"enabled": true, "alias": "practitioner_practice_affiliation", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_practice_affiliation", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.337374, "relation_name": "cms_synthetic.data_quality.practitioner_practice_affiliation", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTICE_AFFILIATION' AS field_name\n , case when m.practice_affiliation is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(practice_affiliation as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_practice_affiliation.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTICE_AFFILIATION' AS field_name\n , case when m.practice_affiliation is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practice_affiliation as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_sub_specialty": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_sub_specialty", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_sub_specialty.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_sub_specialty.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_sub_specialty", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_sub_specialty"], "alias": "practitioner_sub_specialty", "checksum": {"name": "sha256", "checksum": "37056550c6f1fbad99c639c7334ec0b78f079d5aae4ce8c9e1e05875106d3323"}, "config": {"enabled": true, "alias": "practitioner_sub_specialty", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_sub_specialty", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.338986, "relation_name": "cms_synthetic.data_quality.practitioner_sub_specialty", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SUB_SPECIALTY' as field_name\n , case when m.sub_specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(sub_specialty as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_sub_specialty.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SUB_SPECIALTY' as field_name\n , case when m.sub_specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(sub_specialty as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_last_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_last_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_last_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_last_name.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_last_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_last_name"], "alias": "practitioner_last_name", "checksum": {"name": "sha256", "checksum": "523ea44bce3418c8053a3088ed05019ae8ff6b55e4fe2e947167e9fc46e761a4"}, "config": {"enabled": true, "alias": "practitioner_last_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_last_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.34046, "relation_name": "cms_synthetic.data_quality.practitioner_last_name", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' as field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(last_name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_last_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' as field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_practitioner_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_practitioner_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_practitioner_id"], "alias": "practitioner_practitioner_id", "checksum": {"name": "sha256", "checksum": "4cb787b3500bcac5694b31e24c1f4758ba1aa99a986963f5da6841e8d75a5fdf"}, "config": {"enabled": true, "alias": "practitioner_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.341743, "relation_name": "cms_synthetic.data_quality.practitioner_practitioner_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(practitioner_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_data_source"], "alias": "practitioner_data_source", "checksum": {"name": "sha256", "checksum": "79cca80185450d2060ce6a6d53fc2507d6204236807e8afeb3ffec4fafaa6951"}, "config": {"enabled": true, "alias": "practitioner_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.342989, "relation_name": "cms_synthetic.data_quality.practitioner_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_npi.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_npi"], "alias": "practitioner_npi", "checksum": {"name": "sha256", "checksum": "a5a7c0a2c791e357aecbdea2d5a0b22a7ed2861bbec7c497f6d898bec4ca0afa"}, "config": {"enabled": true, "alias": "practitioner_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3446798, "relation_name": "cms_synthetic.data_quality.practitioner_npi", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m\nleft join {{ ref('terminology__provider')}} term on m.npi = term.npi", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_npi.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m\nleft join cms_synthetic.terminology.provider term on m.npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_first_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_first_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_first_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_first_name.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_first_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_first_name"], "alias": "practitioner_first_name", "checksum": {"name": "sha256", "checksum": "34a7887cc9e8a989095da917602c146d569dcf4c861d0e42aa92492ef7998325"}, "config": {"enabled": true, "alias": "practitioner_first_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_first_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.346323, "relation_name": "cms_synthetic.data_quality.practitioner_first_name", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(first_name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_first_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_specialty": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__practitioner_specialty", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_specialty.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_specialty.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_specialty", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_specialty"], "alias": "practitioner_specialty", "checksum": {"name": "sha256", "checksum": "bda072637d80b0ff915f09b949789dad98193886f8cdc63edeec601b39f76315"}, "config": {"enabled": true, "alias": "practitioner_specialty", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_specialty", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.347629, "relation_name": "cms_synthetic.data_quality.practitioner_specialty", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SPECIALTY' as field_name\n , case when m.specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(specialty as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/practitioner/data_quality__practitioner_specialty.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SPECIALTY' as field_name\n , case when m.specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specialty as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_parent_organization": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_parent_organization", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_parent_organization.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_parent_organization.sql", "unique_id": "model.the_tuva_project.data_quality__location_parent_organization", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_parent_organization"], "alias": "location_parent_organization", "checksum": {"name": "sha256", "checksum": "f4a2c42ccff815e06d9bbf5b600041f096bb4c83b3d1e72c0958f1f555e05573"}, "config": {"enabled": true, "alias": "location_parent_organization", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_parent_organization", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2346828, "relation_name": "cms_synthetic.data_quality.location_parent_organization", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'PARENT_ORGANIZATION' AS field_name\n , case when m.parent_organization is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(parent_organization as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_parent_organization.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'PARENT_ORGANIZATION' AS field_name\n , case when m.parent_organization is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(parent_organization as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_latitude": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_latitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_latitude.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_latitude.sql", "unique_id": "model.the_tuva_project.data_quality__location_latitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_latitude"], "alias": "location_latitude", "checksum": {"name": "sha256", "checksum": "f43823581c0ea50b929a829dc3624de29de9d9fbd8eb0c226f41ac67419a9e0c"}, "config": {"enabled": true, "alias": "location_latitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_latitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.236418, "relation_name": "cms_synthetic.data_quality.location_latitude", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(latitude as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_latitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_facility_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_facility_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_facility_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_facility_type.sql", "unique_id": "model.the_tuva_project.data_quality__location_facility_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_facility_type"], "alias": "location_facility_type", "checksum": {"name": "sha256", "checksum": "0fde4938529bdc28d1aa2b2333c6dbf01945e189e617d330db0b3cb3412ff3ab"}, "config": {"enabled": true, "alias": "location_facility_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_facility_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.238003, "relation_name": "cms_synthetic.data_quality.location_facility_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'FACILITY_TYPE' AS field_name\n ,case when m.facility_type is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(facility_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_facility_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'FACILITY_TYPE' AS field_name\n ,case when m.facility_type is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(facility_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_zip_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_zip_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_zip_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_zip_code.sql", "unique_id": "model.the_tuva_project.data_quality__location_zip_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_zip_code"], "alias": "location_zip_code", "checksum": {"name": "sha256", "checksum": "474b44e49a18ccf76d5887a526b293ca1d00c5ece721a1adfba233dadd9294c3"}, "config": {"enabled": true, "alias": "location_zip_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_zip_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.239465, "relation_name": "cms_synthetic.data_quality.location_zip_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(zip_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_zip_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__location_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_data_source"], "alias": "location_data_source", "checksum": {"name": "sha256", "checksum": "27e653819693922b98191a48ca031343cd68cf0824166fa87f6b6412a4bb1d7c"}, "config": {"enabled": true, "alias": "location_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.240979, "relation_name": "cms_synthetic.data_quality.location_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_city": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_city", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_city.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_city.sql", "unique_id": "model.the_tuva_project.data_quality__location_city", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_city"], "alias": "location_city", "checksum": {"name": "sha256", "checksum": "34cfefe760208ab723e9d09fe5419027e4586669f8bcf573c3c0c3cc785ac945"}, "config": {"enabled": true, "alias": "location_city", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_city", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2424052, "relation_name": "cms_synthetic.data_quality.location_city", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'CITY' AS field_name\n , case when m.city is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(city as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_city.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'CITY' AS field_name\n , case when m.city is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(city as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_npi.sql", "unique_id": "model.the_tuva_project.data_quality__location_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_npi"], "alias": "location_npi", "checksum": {"name": "sha256", "checksum": "6e3b55a0b510b1a3b740d0f74f72314a04a2df70fe3148d2fe85678bd073c36c"}, "config": {"enabled": true, "alias": "location_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.243778, "relation_name": "cms_synthetic.data_quality.location_npi", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m\nleft join {{ ref('terminology__provider')}} term on m.npi = term.npi", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_npi.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m\nleft join cms_synthetic.terminology.provider term on m.npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_location_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_location_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_location_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_location_id.sql", "unique_id": "model.the_tuva_project.data_quality__location_location_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_location_id"], "alias": "location_location_id", "checksum": {"name": "sha256", "checksum": "60b93f71258b82e7e2c47b5d613e1de0df90e8bfbbc27fc97155aee8667f9bdf"}, "config": {"enabled": true, "alias": "location_location_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_location_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.245537, "relation_name": "cms_synthetic.data_quality.location_location_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'LOCATION_ID' AS field_name\n ,case when m.location_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(location_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_location_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'LOCATION_ID' AS field_name\n ,case when m.location_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(location_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_longitude": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_longitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_longitude.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_longitude.sql", "unique_id": "model.the_tuva_project.data_quality__location_longitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_longitude"], "alias": "location_longitude", "checksum": {"name": "sha256", "checksum": "0088e8727b955e1f2ebafc841e26043b086b8a779a96b900c6dc438af7b3b267"}, "config": {"enabled": true, "alias": "location_longitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_longitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.247285, "relation_name": "cms_synthetic.data_quality.location_longitude", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(longitude as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_longitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_address": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_address", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_address.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_address.sql", "unique_id": "model.the_tuva_project.data_quality__location_address", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_address"], "alias": "location_address", "checksum": {"name": "sha256", "checksum": "35af08df0e65c3f1fd6b893fc8f664a991b98e353c65e304948fa78e17055e56"}, "config": {"enabled": true, "alias": "location_address", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_address", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.248706, "relation_name": "cms_synthetic.data_quality.location_address", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ADDRESS' AS field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(address as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_address.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ADDRESS' AS field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_state": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_state", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_state.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_state.sql", "unique_id": "model.the_tuva_project.data_quality__location_state", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_state"], "alias": "location_state", "checksum": {"name": "sha256", "checksum": "560bc5453f3d76b7844b38fa8fa4a09b6ffb739b1126fd85596b0c33f3c066ce"}, "config": {"enabled": true, "alias": "location_state", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_state", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.250116, "relation_name": "cms_synthetic.data_quality.location_state", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(state as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_state.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__location_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_name.sql", "unique_id": "model.the_tuva_project.data_quality__location_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_name"], "alias": "location_name", "checksum": {"name": "sha256", "checksum": "ff15bd9b142ac89c4972cd8d980147e45ad016a44f16aa76466e8efa3677cd5f"}, "config": {"enabled": true, "alias": "location_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.251652, "relation_name": "cms_synthetic.data_quality.location_name", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NAME' as field_name\n , case when m.name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/location/data_quality__location_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NAME' as field_name\n , case when m.name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_primary_diagnosis_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_primary_diagnosis_description"], "alias": "encounter_primary_diagnosis_description", "checksum": {"name": "sha256", "checksum": "62ea58aa3ef8087a845a16508324449e229c786eebab5a2988025ffe18af3d9d"}, "config": {"enabled": true, "alias": "encounter_primary_diagnosis_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_primary_diagnosis_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.192954, "relation_name": "cms_synthetic.data_quality.encounter_primary_diagnosis_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_DESCRIPTION' AS field_name\n , case when m.primary_diagnosis_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(primary_diagnosis_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_DESCRIPTION' AS field_name\n , case when m.primary_diagnosis_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(primary_diagnosis_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_type_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_admit_type_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_type_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_type_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_type_description"], "alias": "encounter_admit_type_description", "checksum": {"name": "sha256", "checksum": "80e3bb3ad8ce449558cacf0b349b4925ba1f06972a09fb97c73f720ed5b7abd1"}, "config": {"enabled": true, "alias": "encounter_admit_type_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_type_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.163062, "relation_name": "cms_synthetic.data_quality.encounter_admit_type_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'ADMIT_TYPE_DESCRIPTION' AS field_name\n ,case when m.admit_type_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(substring(admit_type_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_type_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'ADMIT_TYPE_DESCRIPTION' AS field_name\n ,case when m.admit_type_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(admit_type_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_primary_diagnosis_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_primary_diagnosis_code_type"], "alias": "encounter_primary_diagnosis_code_type", "checksum": {"name": "sha256", "checksum": "49a0974972ac61ff7dffae906306f3e78972f67ffbc1c5d2154c60b6ede41bfd"}, "config": {"enabled": true, "alias": "encounter_primary_diagnosis_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_primary_diagnosis_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1913621, "relation_name": "cms_synthetic.data_quality.encounter_primary_diagnosis_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.primary_diagnosis_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code_type is not null and term.code_type is null\n then 'Primary Diagnosis Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('reference_data__code_type')}} term on m.primary_diagnosis_code_type = term.code_type", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.primary_diagnosis_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code_type is not null and term.code_type is null\n then 'Primary Diagnosis Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.reference_data.code_type term on m.primary_diagnosis_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_encounter_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_type.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_type"], "alias": "encounter_encounter_type", "checksum": {"name": "sha256", "checksum": "5c89e0e54e4489c01396dfc1944aaff1fce0e16181d6e7d900a0fc96d08bb833"}, "config": {"enabled": true, "alias": "encounter_encounter_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.180116, "relation_name": "cms_synthetic.data_quality.encounter_encounter_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_TYPE' AS field_name\n , case when term.encounter_type is not null then 'valid'\n when m.encounter_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.encounter_type is not null and term.encounter_type is null\n then 'Encounter type does not join to Terminology encounter_type table'\n else null end as invalid_reason\n , cast(m.encounter_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__encounter_type')}} term on m.encounter_type = term.encounter_type", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__encounter_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__encounter_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_TYPE' AS field_name\n , case when term.encounter_type is not null then 'valid'\n when m.encounter_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.encounter_type is not null and term.encounter_type is null\n then 'Encounter type does not join to Terminology encounter_type table'\n else null end as invalid_reason\n , cast(m.encounter_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.encounter_type term on m.encounter_type = term.encounter_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_source_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_admit_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_source_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_source_description"], "alias": "encounter_admit_source_description", "checksum": {"name": "sha256", "checksum": "286a5f62f34383bf5ab2e99ab56e815078c6018f5addcbd3fe96e4b6265dc998"}, "config": {"enabled": true, "alias": "encounter_admit_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.159863, "relation_name": "cms_synthetic.data_quality.encounter_admit_source_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_DESCRIPTION' AS field_name\n , case when m.admit_source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(admit_source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_source_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_DESCRIPTION' AS field_name\n , case when m.admit_source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(admit_source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_ms_drg_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_ms_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_ms_drg_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_ms_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_ms_drg_code"], "alias": "encounter_ms_drg_code", "checksum": {"name": "sha256", "checksum": "bebc4a2f0a42f3688894ece81026d0e16387a811ee16f952aa8a8f497338faa1"}, "config": {"enabled": true, "alias": "encounter_ms_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_ms_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1843069, "relation_name": "cms_synthetic.data_quality.encounter_ms_drg_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_CODE' AS field_name\n , case when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ms_drg_code is not null and term.ms_drg_code is null\n then 'MS DRG Code does not join to Terminology ms_drg table'\n else null end as invalid_reason\n , cast(m.ms_drg_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__ms_drg')}} term on m.ms_drg_code = term.ms_drg_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_ms_drg_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_CODE' AS field_name\n , case when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ms_drg_code is not null and term.ms_drg_code is null\n then 'MS DRG Code does not join to Terminology ms_drg table'\n else null end as invalid_reason\n , cast(m.ms_drg_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.ms_drg term on m.ms_drg_code = term.ms_drg_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_discharge_disposition_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_discharge_disposition_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_discharge_disposition_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_discharge_disposition_description"], "alias": "encounter_discharge_disposition_description", "checksum": {"name": "sha256", "checksum": "add4c7b7c915259a440d1cb3a15a3870581e0c55cc9053098718a0c0b4e266f5"}, "config": {"enabled": true, "alias": "encounter_discharge_disposition_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_discharge_disposition_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.174231, "relation_name": "cms_synthetic.data_quality.encounter_discharge_disposition_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_DESCRIPTION' AS field_name\n , case when m.discharge_disposition_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(discharge_disposition_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_discharge_disposition_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_DESCRIPTION' AS field_name\n , case when m.discharge_disposition_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(discharge_disposition_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_admit_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_source_code"], "alias": "encounter_admit_source_code", "checksum": {"name": "sha256", "checksum": "4fc14feb95ccd1b0dc45370bfb57639bc652050cb0f5b5ddf44049442f4ce943"}, "config": {"enabled": true, "alias": "encounter_admit_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.158494, "relation_name": "cms_synthetic.data_quality.encounter_admit_source_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_source_code is not null and term.admit_source_code is null\n then 'Admit source code does not join to Terminology admit source table'\n else null end as invalid_reason\n , cast(m.admit_source_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__admit_source')}} term on m.admit_source_code = term.admit_source_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_source"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_source_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_source_code is not null and term.admit_source_code is null\n then 'Admit source code does not join to Terminology admit source table'\n else null end as invalid_reason\n , cast(m.admit_source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.admit_source term on m.admit_source_code = term.admit_source_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_charge_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_charge_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_charge_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_charge_amount.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_charge_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_charge_amount"], "alias": "encounter_charge_amount", "checksum": {"name": "sha256", "checksum": "ab710f5c01e7f74c1ea130662d778f72a5f728986951fb07bed05f9d4be50a7f"}, "config": {"enabled": true, "alias": "encounter_charge_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_charge_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1702468, "relation_name": "cms_synthetic.data_quality.encounter_charge_amount", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(charge_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_charge_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_length_of_stay": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_length_of_stay", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_length_of_stay.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_length_of_stay.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_length_of_stay", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_length_of_stay"], "alias": "encounter_length_of_stay", "checksum": {"name": "sha256", "checksum": "6a94c9a7cfe4c7b1b5accba32bc2c59de1a5a0c931b49c20f96e85798852f48c"}, "config": {"enabled": true, "alias": "encounter_length_of_stay", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_length_of_stay", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.182708, "relation_name": "cms_synthetic.data_quality.encounter_length_of_stay", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'LENGTH_OF_STAY' AS field_name\n ,case when m.length_of_stay is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(length_of_stay as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_length_of_stay.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'LENGTH_OF_STAY' AS field_name\n ,case when m.length_of_stay is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(length_of_stay as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_allowed_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_allowed_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_allowed_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_allowed_amount.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_allowed_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_allowed_amount"], "alias": "encounter_allowed_amount", "checksum": {"name": "sha256", "checksum": "dcca58fcd20507c0f01526e45de467c9d0c5907f8769ceab043df90f78ea2656"}, "config": {"enabled": true, "alias": "encounter_allowed_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_allowed_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1645162, "relation_name": "cms_synthetic.data_quality.encounter_allowed_amount", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(allowed_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_allowed_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_primary_diagnosis_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_primary_diagnosis_code"], "alias": "encounter_primary_diagnosis_code", "checksum": {"name": "sha256", "checksum": "374589a01fdb1c359ae35225d0ec0bd88cd0abfdb2b6d4b2dc2dc243a7b1b3a9"}, "config": {"enabled": true, "alias": "encounter_primary_diagnosis_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_primary_diagnosis_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.190091, "relation_name": "cms_synthetic.data_quality.encounter_primary_diagnosis_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.primary_diagnosis_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code is not null and term.icd_10_cm is null\n then 'Primary diagnosis code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__icd_10_cm')}} term on m.primary_diagnosis_code = term.icd_10_cm", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_primary_diagnosis_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.primary_diagnosis_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code is not null and term.icd_10_cm is null\n then 'Primary diagnosis code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.icd_10_cm term on m.primary_diagnosis_code = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_facility_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_facility_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_facility_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_facility_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_facility_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_facility_id"], "alias": "encounter_facility_id", "checksum": {"name": "sha256", "checksum": "1cdf9aac306e17b1f26b51ce024f892d4334e60c0e91db6ee2052b9c7f3b0617"}, "config": {"enabled": true, "alias": "encounter_facility_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_facility_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.181439, "relation_name": "cms_synthetic.data_quality.encounter_facility_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'FACILITY_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.facility_id is not null and term.npi is null\n then 'Facility NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(facility_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__provider')}} term on m.facility_id = term.npi", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_facility_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'FACILITY_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.facility_id is not null and term.npi is null\n then 'Facility NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(facility_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.provider term on m.facility_id = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_data_source"], "alias": "encounter_data_source", "checksum": {"name": "sha256", "checksum": "3ab50f23ed21b1c89364e90a9ef0d08e1eb61bc895be6050eef06b85382a160b"}, "config": {"enabled": true, "alias": "encounter_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.171571, "relation_name": "cms_synthetic.data_quality.encounter_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_attending_provider_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_attending_provider_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_attending_provider_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_attending_provider_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_attending_provider_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_attending_provider_id"], "alias": "encounter_attending_provider_id", "checksum": {"name": "sha256", "checksum": "c3121289dbe60adcc5fa19993c0087abe82b390569b5b0490264fb8b263be5a9"}, "config": {"enabled": true, "alias": "encounter_attending_provider_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_attending_provider_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1687229, "relation_name": "cms_synthetic.data_quality.encounter_attending_provider_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ATTENDING_PROVIDER_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.attending_provider_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.attending_provider_id is not null and term.npi is null\n then 'Attending provider ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(attending_provider_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__provider')}} term on m.attending_provider_id = term.npi", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_attending_provider_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ATTENDING_PROVIDER_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.attending_provider_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.attending_provider_id is not null and term.npi is null\n then 'Attending provider ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(attending_provider_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.provider term on m.attending_provider_id = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_start_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_encounter_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_start_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_start_date"], "alias": "encounter_encounter_start_date", "checksum": {"name": "sha256", "checksum": "d8f387f78291a6ebb0eee1e3e5145c2939f21b60db850a3ab3899f6c59c30853"}, "config": {"enabled": true, "alias": "encounter_encounter_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1787, "relation_name": "cms_synthetic.data_quality.encounter_encounter_start_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_START_DATE' AS field_name\n , case\n when m.encounter_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_start_date > m.encounter_end_date then 'invalid'\n when m.encounter_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_start_date > m.encounter_end_date then 'Encounter start date after encounter end date'\n else null\n end as invalid_reason\n , cast(encounter_start_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_start_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_START_DATE' AS field_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_start_date > m.encounter_end_date then 'invalid'\n when m.encounter_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_start_date > m.encounter_end_date then 'Encounter start date after encounter end date'\n else null\n end as invalid_reason\n , cast(encounter_start_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_paid_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_paid_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_paid_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_paid_amount.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_paid_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_paid_amount"], "alias": "encounter_paid_amount", "checksum": {"name": "sha256", "checksum": "0a53e243f99dd51fe8087b8471da316277323023785b78b96d7512dd3142f2b2"}, "config": {"enabled": true, "alias": "encounter_paid_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_paid_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1873548, "relation_name": "cms_synthetic.data_quality.encounter_paid_amount", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PAID_AMOUNT' AS field_name\n ,case when m.paid_amount is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(paid_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_paid_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PAID_AMOUNT' AS field_name\n ,case when m.paid_amount is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(paid_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_end_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_encounter_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_end_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_end_date"], "alias": "encounter_encounter_end_date", "checksum": {"name": "sha256", "checksum": "18b65e2fcf64d86a983680cc77d465cbd7cd2dcd28bc679c95fb0e95c143c7d5"}, "config": {"enabled": true, "alias": "encounter_encounter_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.175531, "relation_name": "cms_synthetic.data_quality.encounter_encounter_end_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_END_DATE' AS field_name\n , case\n when m.encounter_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_end_date < m.encounter_start_date then 'invalid'\n when m.encounter_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_end_date < m.encounter_start_date then 'Encounter end date before encounter start date'\n else null\n end as invalid_reason\n , cast(encounter_end_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_end_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_END_DATE' AS field_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_end_date < m.encounter_start_date then 'invalid'\n when m.encounter_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_end_date < m.encounter_start_date then 'Encounter end date before encounter start date'\n else null\n end as invalid_reason\n , cast(encounter_end_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_type_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_admit_type_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_type_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_type_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_type_code"], "alias": "encounter_admit_type_code", "checksum": {"name": "sha256", "checksum": "393496228d6216d82db62ba1060213d03dd929e74c1963117914d0feb52eb3a7"}, "config": {"enabled": true, "alias": "encounter_admit_type_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_type_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.161363, "relation_name": "cms_synthetic.data_quality.encounter_admit_type_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_type_code is not null and term.admit_type_code is null\n then 'Admit Type Code does not join to Terminology admit_type table'\n else null end as invalid_reason\n , cast(m.admit_type_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__admit_type')}} term on m.admit_type_code = term.admit_type_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_admit_type_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_type_code is not null and term.admit_type_code is null\n then 'Admit Type Code does not join to Terminology admit_type table'\n else null end as invalid_reason\n , cast(m.admit_type_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.admit_type term on m.admit_type_code = term.admit_type_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_id"], "alias": "encounter_encounter_id", "checksum": {"name": "sha256", "checksum": "ac5a2e6e4b77553fd8f7851d9022f2329a317d09de7716dad5c6bf3d24a831b2"}, "config": {"enabled": true, "alias": "encounter_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1769211, "relation_name": "cms_synthetic.data_quality.encounter_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' AS field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_encounter_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' AS field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_apr_drg_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_apr_drg_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_apr_drg_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_apr_drg_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_apr_drg_description"], "alias": "encounter_apr_drg_description", "checksum": {"name": "sha256", "checksum": "fcdb959e511dfa20d94dc5a61ec63ee789a9af43779e8a523e7bc287905b1a1d"}, "config": {"enabled": true, "alias": "encounter_apr_drg_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_apr_drg_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1672902, "relation_name": "cms_synthetic.data_quality.encounter_apr_drg_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'APR_DRG_DESCRIPTION' AS field_name\n , case when m.apr_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(apr_drg_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_apr_drg_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'APR_DRG_DESCRIPTION' AS field_name\n , case when m.apr_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(apr_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_patient_id"], "alias": "encounter_patient_id", "checksum": {"name": "sha256", "checksum": "16e1fce5eff7111ac6eb1a40aa3f3c36c152efe29c5c7fda5760d01770183f1e"}, "config": {"enabled": true, "alias": "encounter_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.188771, "relation_name": "cms_synthetic.data_quality.encounter_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_apr_drg_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_apr_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_apr_drg_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_apr_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_apr_drg_code"], "alias": "encounter_apr_drg_code", "checksum": {"name": "sha256", "checksum": "f645d6e392959e9e6c2f35b701812aecd656a3b622fcfc3d576d02492909ffc2"}, "config": {"enabled": true, "alias": "encounter_apr_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_apr_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.165947, "relation_name": "cms_synthetic.data_quality.encounter_apr_drg_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'APR_DRG_CODE' AS field_name\n ,case when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.apr_drg_code is not null and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology apr_drg table'\n else null end as invalid_reason\n ,cast(m.apr_drg_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__apr_drg')}} term on m.apr_drg_code = term.apr_drg_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_apr_drg_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'APR_DRG_CODE' AS field_name\n ,case when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.apr_drg_code is not null and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology apr_drg table'\n else null end as invalid_reason\n ,cast(m.apr_drg_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.apr_drg term on m.apr_drg_code = term.apr_drg_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_ms_drg_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_ms_drg_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_ms_drg_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_ms_drg_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_ms_drg_description"], "alias": "encounter_ms_drg_description", "checksum": {"name": "sha256", "checksum": "2c6f20d1b47b32a41ef2f8c2f41b5dab625ade59e36f84f3a5792bcdd0bd69cb"}, "config": {"enabled": true, "alias": "encounter_ms_drg_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_ms_drg_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.185937, "relation_name": "cms_synthetic.data_quality.encounter_ms_drg_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_DESCRIPTION' AS field_name\n , case when m.ms_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(ms_drg_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_ms_drg_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_DESCRIPTION' AS field_name\n , case when m.ms_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(ms_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounter_discharge_disposition_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_discharge_disposition_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_discharge_disposition_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_discharge_disposition_code"], "alias": "encounter_discharge_disposition_code", "checksum": {"name": "sha256", "checksum": "c8de2850b52b29753a24d3353a694076201a7ffcdefd32d2d03396308f5491be"}, "config": {"enabled": true, "alias": "encounter_discharge_disposition_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_discharge_disposition_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1728451, "relation_name": "cms_synthetic.data_quality.encounter_discharge_disposition_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.discharge_disposition_code is not null and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology discharge_disposition table'\n else null end as invalid_reason\n , cast(m.discharge_disposition_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('encounter')}} m\nleft join {{ ref('terminology__discharge_disposition')}} term on m.discharge_disposition_code = term.discharge_disposition_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/encounter/data_quality__encounter_discharge_disposition_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.discharge_disposition_code is not null and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology discharge_disposition table'\n else null end as invalid_reason\n , cast(m.discharge_disposition_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.discharge_disposition term on m.discharge_disposition_code = term.discharge_disposition_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_normalized_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_normalized_code_type"], "alias": "procedure_normalized_code_type", "checksum": {"name": "sha256", "checksum": "fe38abefff6faaba40a30bd41f0aa3f83bbc57b8f0f437d02e72b7d705cfa634"}, "config": {"enabled": true, "alias": "procedure_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3488681, "relation_name": "cms_synthetic.data_quality.procedure_normalized_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m\nleft join {{ ref('reference_data__code_type')}} term on m.normalized_code_type = term.code_type", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.reference_data.code_type term on m.normalized_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_normalized_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_normalized_description"], "alias": "procedure_normalized_description", "checksum": {"name": "sha256", "checksum": "53f9fa3074438b02a7bffca1b2dd37b4a05de4a45f3b6d46774b5e4d30cffffc"}, "config": {"enabled": true, "alias": "procedure_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.350239, "relation_name": "cms_synthetic.data_quality.procedure_normalized_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_procedure_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_procedure_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_procedure_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_procedure_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_procedure_id"], "alias": "procedure_procedure_id", "checksum": {"name": "sha256", "checksum": "8f936930afa98db110b0318ff27a9c8266605de03025548b4424320c4d075890"}, "config": {"enabled": true, "alias": "procedure_procedure_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_procedure_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.351487, "relation_name": "cms_synthetic.data_quality.procedure_procedure_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_ID' AS field_name\n , case when m.procedure_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(procedure_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_procedure_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_ID' AS field_name\n , case when m.procedure_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(procedure_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_claim_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_claim_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_claim_id"], "alias": "procedure_claim_id", "checksum": {"name": "sha256", "checksum": "48261853243de665701c6dc1aae794e54142d7fe55019710d8f7304fb5ece6b9"}, "config": {"enabled": true, "alias": "procedure_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.352894, "relation_name": "cms_synthetic.data_quality.procedure_claim_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' as field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(claim_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_claim_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' as field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_source_code"], "alias": "procedure_source_code", "checksum": {"name": "sha256", "checksum": "840b3341c4fa98427b40659537b648105100b0a07146feb8c85f6ddb48b82913"}, "config": {"enabled": true, "alias": "procedure_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.354645, "relation_name": "cms_synthetic.data_quality.procedure_source_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_source_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_source_code_type"], "alias": "procedure_source_code_type", "checksum": {"name": "sha256", "checksum": "12a2f49dea4439a3792fa5fb67767c6cd6dd007060c96d859e0b83a48beeb26b"}, "config": {"enabled": true, "alias": "procedure_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.356066, "relation_name": "cms_synthetic.data_quality.procedure_source_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_source_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_source_description"], "alias": "procedure_source_description", "checksum": {"name": "sha256", "checksum": "88912860043994ac74526535548a985ae10fc42217a75bca3f7e5573c101f63d"}, "config": {"enabled": true, "alias": "procedure_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3574889, "relation_name": "cms_synthetic.data_quality.procedure_source_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_practitioner_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_practitioner_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_practitioner_id"], "alias": "procedure_practitioner_id", "checksum": {"name": "sha256", "checksum": "f3522bfcb0b98963d4f1f1f425948163683498b4c2bfb8b12f9cf0c299248871"}, "config": {"enabled": true, "alias": "procedure_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.358836, "relation_name": "cms_synthetic.data_quality.procedure_practitioner_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' AS field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(practitioner_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' AS field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_data_source"], "alias": "procedure_data_source", "checksum": {"name": "sha256", "checksum": "383501e46cc547f6703c5ec1eb1eb224c4cc3a3fc9a05c70ca86eb61f139c747"}, "config": {"enabled": true, "alias": "procedure_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3602781, "relation_name": "cms_synthetic.data_quality.procedure_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_patient_id"], "alias": "procedure_patient_id", "checksum": {"name": "sha256", "checksum": "930e325c13a5fbbbe54d902cf8618fc407bf2104bb88eb2838babf614df034bf"}, "config": {"enabled": true, "alias": "procedure_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.361847, "relation_name": "cms_synthetic.data_quality.procedure_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_procedure_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_procedure_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_procedure_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_procedure_date.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_procedure_date"], "alias": "procedure_procedure_date", "checksum": {"name": "sha256", "checksum": "1b924048225c6f10bd4092b5de858ca8e8c1b5a35cde18e8ae74b647b0de92d8"}, "config": {"enabled": true, "alias": "procedure_procedure_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_procedure_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.363421, "relation_name": "cms_synthetic.data_quality.procedure_procedure_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_DATE' as field_name\n , case\n when m.procedure_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.procedure_date <= cast('1901-01-01' as date) then 'invalid'\n when m.procedure_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.procedure_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.procedure_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(procedure_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_procedure_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_DATE' as field_name\n , case\n when m.procedure_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date <= cast('1901-01-01' as date) then 'invalid'\n when m.procedure_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.procedure_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(procedure_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_encounter_id"], "alias": "procedure_encounter_id", "checksum": {"name": "sha256", "checksum": "edbb0715143b3cb8ca3194ed24484a50a7049b08a67c408a53c68f4f1defa403"}, "config": {"enabled": true, "alias": "procedure_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.364867, "relation_name": "cms_synthetic.data_quality.procedure_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_encounter_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_5": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_modifier_5", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_5.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_5.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_5", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_5"], "alias": "procedure_modifier_5", "checksum": {"name": "sha256", "checksum": "0d77d65dac199131b6bf8d1616dd9c87486a620fe2f3c9eb661ed133477edf3d"}, "config": {"enabled": true, "alias": "procedure_modifier_5", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_5", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.366355, "relation_name": "cms_synthetic.data_quality.procedure_modifier_5", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_5' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_5 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_5 is not null and term.hcpcs is null\n then 'Modifier 5 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_5 as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_5 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_5.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_5' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_5 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_5 is not null and term.hcpcs is null\n then 'Modifier 5 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_5 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_5 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_4": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_modifier_4", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_4.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_4.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_4", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_4"], "alias": "procedure_modifier_4", "checksum": {"name": "sha256", "checksum": "311c1dda8e2abcf12cff110d4205fa27cda154713f0e13227b86c86fd3297897"}, "config": {"enabled": true, "alias": "procedure_modifier_4", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_4", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3677812, "relation_name": "cms_synthetic.data_quality.procedure_modifier_4", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n ,coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n ,'PROCEDURE' AS table_name\n ,'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n ,'MODIFIER_4' as field_name\n ,case when term.hcpcs is not null then 'valid'\n when m.modifier_4 is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.modifier_4 is not null and term.hcpcs is null\n then 'Modifier 4 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n ,cast(modifier_4 as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_4 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_4.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n ,'PROCEDURE' AS table_name\n ,'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n ,'MODIFIER_4' as field_name\n ,case when term.hcpcs is not null then 'valid'\n when m.modifier_4 is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.modifier_4 is not null and term.hcpcs is null\n then 'Modifier 4 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n ,cast(modifier_4 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_4 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_normalized_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_normalized_code"], "alias": "procedure_normalized_code", "checksum": {"name": "sha256", "checksum": "985d09f573c72d14f82d09da3976494dbac09c3ceebb1e7b2b1e6f85c82f3d55"}, "config": {"enabled": true, "alias": "procedure_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3692029, "relation_name": "cms_synthetic.data_quality.procedure_normalized_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nwith icd9 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_9_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_9_pcs is null\n then 'Normalized code does not join to Terminology icd_9_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\n from {{ ref('procedure')}} m\n left join {{ ref('terminology__icd_9_pcs')}} term on m.normalized_code = term.icd_9_pcs\n where\n m.normalized_code_type = 'icd-9-pcs'\n),\nicd10 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_10_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_pcs is null\n then 'Normalized code does not join to Terminology icd_10_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__icd_10_pcs')}} term on m.normalized_code = term.icd_10_pcs\nwhere\n m.normalized_code_type = 'icd_10_pcs'\n),\nhcpcs_level_2 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.hcpcs is null\n then 'Normalized code does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.normalized_code = term.hcpcs\nwhere\n m.normalized_code_type = 'hcpcs_level_2'\n),\n\nothers as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , 'null' as bucket_name\n , 'code type does not have a matching code terminology table' as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\nfrom {{ ref('procedure')}} m\nwhere\n m.normalized_code_type not in ('icd-9-pcs', 'icd-10-pcs','hcpcs_level_2')\n)\n\nSELECT *, '{{ var('tuva_last_run')}}' as tuva_last_run FROM icd9\n\nunion all\n\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run FROM icd10\n\nunion all\n\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run FROM hcpcs_level_2\n\nunion all\n\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run FROM others", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}, {"name": "procedure", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_normalized_code.sql", "compiled": true, "compiled_code": "\n\nwith icd9 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_9_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_9_pcs is null\n then 'Normalized code does not join to Terminology icd_9_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n from tuva.input_layer.procedure m\n left join cms_synthetic.terminology.icd_9_pcs term on m.normalized_code = term.icd_9_pcs\n where\n m.normalized_code_type = 'icd-9-pcs'\n),\nicd10 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_10_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_pcs is null\n then 'Normalized code does not join to Terminology icd_10_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.icd_10_pcs term on m.normalized_code = term.icd_10_pcs\nwhere\n m.normalized_code_type = 'icd_10_pcs'\n),\nhcpcs_level_2 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.hcpcs is null\n then 'Normalized code does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.normalized_code = term.hcpcs\nwhere\n m.normalized_code_type = 'hcpcs_level_2'\n),\n\nothers as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , 'null' as bucket_name\n , 'code type does not have a matching code terminology table' as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nwhere\n m.normalized_code_type not in ('icd-9-pcs', 'icd-10-pcs','hcpcs_level_2')\n)\n\nSELECT *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM icd9\n\nunion all\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM icd10\n\nunion all\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM hcpcs_level_2\n\nunion all\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM others", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_1": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_modifier_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_1.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_1.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_1"], "alias": "procedure_modifier_1", "checksum": {"name": "sha256", "checksum": "ef982a51ae7e8feba8b17c58113bfe976957a824debb9271d8b8fbc16704f270"}, "config": {"enabled": true, "alias": "procedure_modifier_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.370949, "relation_name": "cms_synthetic.data_quality.procedure_modifier_1", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as SOURCE_DATE\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_1' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_1 is not null and term.hcpcs is null\n then 'Modifier 1 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_1 as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_1 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_1.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as SOURCE_DATE\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_1' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_1 is not null and term.hcpcs is null\n then 'Modifier 1 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_1 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_1 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_3": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_modifier_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_3.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_3.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_3"], "alias": "procedure_modifier_3", "checksum": {"name": "sha256", "checksum": "8e09dbe58bad94eae85fa6e23e00aca839d03c3917292b697f947c7313b14684"}, "config": {"enabled": true, "alias": "procedure_modifier_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.37232, "relation_name": "cms_synthetic.data_quality.procedure_modifier_3", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_3' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_3 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_3 is not null and term.hcpcs is null\n then 'Modifier 3 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_3 as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_3 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_3.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_3' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_3 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_3 is not null and term.hcpcs is null\n then 'Modifier 3 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_3 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_3 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_2": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__procedure_modifier_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_2.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_2.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_2"], "alias": "procedure_modifier_2", "checksum": {"name": "sha256", "checksum": "cbda87a0a9c4dc84b11e4923829d20263374ba658f9c51698b815bc878d6e5e0"}, "config": {"enabled": true, "alias": "procedure_modifier_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.373663, "relation_name": "cms_synthetic.data_quality.procedure_modifier_2", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_2' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_2 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_2 is not null and term.hcpcs is null\n then 'Modifier 2 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_2 as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('procedure')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_2 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/procedure/data_quality__procedure_modifier_2.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_2' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_2 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_2 is not null and term.hcpcs is null\n then 'Modifier 2 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_2 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_2 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_abnormal_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_abnormal_flag.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_abnormal_flag.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_abnormal_flag"], "alias": "lab_result_source_abnormal_flag", "checksum": {"name": "sha256", "checksum": "dfc5953fa0674e9ec9e8b35a5145cc5a399863ddb2de891eb59b50f59c681f2a"}, "config": {"enabled": true, "alias": "lab_result_source_abnormal_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_abnormal_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1947389, "relation_name": "cms_synthetic.data_quality.lab_result_source_abnormal_flag", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_ABNORMAL_FLAG' AS field_name\n , case when m.source_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_abnormal_flag as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_abnormal_flag.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_ABNORMAL_FLAG' AS field_name\n , case when m.source_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_abnormal_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_specimen": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_specimen", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_specimen.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_specimen.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_specimen", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_specimen"], "alias": "lab_result_specimen", "checksum": {"name": "sha256", "checksum": "f9f23a6ee08e8f8f62de25020cf689c899ecd60254b227dad12e77e49386976f"}, "config": {"enabled": true, "alias": "lab_result_specimen", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_specimen", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1963751, "relation_name": "cms_synthetic.data_quality.lab_result_specimen", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SPECIMEN' as field_name\n , case when m.specimen is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(specimen as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_specimen.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SPECIMEN' as field_name\n , case when m.specimen is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specimen as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_reference_range_low.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_reference_range_low"], "alias": "lab_result_source_reference_range_low", "checksum": {"name": "sha256", "checksum": "3b3559d92d8c80bf00a645a16e5856fde804879e05eb9c45fe723e6ddffb1382"}, "config": {"enabled": true, "alias": "lab_result_source_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.197856, "relation_name": "cms_synthetic.data_quality.lab_result_source_reference_range_low", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' AS field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_reference_range_low as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' AS field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_units": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_units.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_units.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_units"], "alias": "lab_result_source_units", "checksum": {"name": "sha256", "checksum": "da74b7671612b45f368dcc17dc3c9305cd3ea8d198410a05f9c597af8ef803d9"}, "config": {"enabled": true, "alias": "lab_result_source_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.199728, "relation_name": "cms_synthetic.data_quality.lab_result_source_units", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n ,coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n ,'LAB_RESULT' AS table_name\n ,'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n ,'SOURCE_UNITS' AS field_name\n ,case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(source_units as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n ,'LAB_RESULT' AS table_name\n ,'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n ,'SOURCE_UNITS' AS field_name\n ,case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_lab_result_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_lab_result_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_lab_result_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_lab_result_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_lab_result_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_lab_result_id"], "alias": "lab_result_lab_result_id", "checksum": {"name": "sha256", "checksum": "a58efa99672a0a7c2eab3168a409fe708ce0673c7a6fa54d2e7faf25aa8d69ed"}, "config": {"enabled": true, "alias": "lab_result_lab_result_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_lab_result_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.201201, "relation_name": "cms_synthetic.data_quality.lab_result_lab_result_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'LAB_RESULT_ID' as field_name\n , case when m.lab_result_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(lab_result_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_lab_result_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'LAB_RESULT_ID' as field_name\n , case when m.lab_result_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(lab_result_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_collection_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_collection_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_collection_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_collection_date.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_collection_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_collection_date"], "alias": "lab_result_collection_date", "checksum": {"name": "sha256", "checksum": "2d941736c021dd442e582344300a43f0733c2b7697684bbf429c20704f46551f"}, "config": {"enabled": true, "alias": "lab_result_collection_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_collection_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.202691, "relation_name": "cms_synthetic.data_quality.lab_result_collection_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'COLLECTION_DATE' AS field_name\n , case\n when m.collection_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.collection_date <= cast('1901-01-01' as date) then 'invalid'\n when m.collection_date > m.result_date then 'invalid'\n when m.collection_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.collection_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.collection_date <= cast('1901-01-01' as date) then 'too old'\n when m.collection_date > m.result_date then 'Collection date after result date'\n else null\n end as invalid_reason\n , cast(collection_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_collection_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'COLLECTION_DATE' AS field_name\n , case\n when m.collection_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.collection_date <= cast('1901-01-01' as date) then 'invalid'\n when m.collection_date > m.result_date then 'invalid'\n when m.collection_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.collection_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.collection_date <= cast('1901-01-01' as date) then 'too old'\n when m.collection_date > m.result_date then 'Collection date after result date'\n else null\n end as invalid_reason\n , cast(collection_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_component": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_component", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_component.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_component.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_component", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_component"], "alias": "lab_result_normalized_component", "checksum": {"name": "sha256", "checksum": "0a1d41c45069a71ddd46e72cb3e6faedbbd121c8ac947adbe8de1d25c501b23d"}, "config": {"enabled": true, "alias": "lab_result_normalized_component", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_component", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.20397, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_component", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_COMPONENT' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_component is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_component is not null and term.loinc is null\n then 'Normalized component does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_component as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m\nleft join {{ ref('terminology__loinc')}} term on m.normalized_component = term.loinc", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_component.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_COMPONENT' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_component is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_component is not null and term.loinc is null\n then 'Normalized component does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_component as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.terminology.loinc term on m.normalized_component = term.loinc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_ordering_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_ordering_practitioner_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_ordering_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_ordering_practitioner_id"], "alias": "lab_result_ordering_practitioner_id", "checksum": {"name": "sha256", "checksum": "4eaaf2dbd05cd5c6630824d8d81f0f9ec3ca05d47448a8b444aed4d6d9e08835"}, "config": {"enabled": true, "alias": "lab_result_ordering_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_ordering_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.205358, "relation_name": "cms_synthetic.data_quality.lab_result_ordering_practitioner_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ORDERING_PRACTITIONER_ID' as field_name\n , case when term.npi is not null then 'valid'\n when m.ordering_practitioner_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ordering_practitioner_id is not null and term.npi is null\n then 'Ordering practitioner ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(ordering_practitioner_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m\nleft join {{ ref('terminology__provider')}} term on m.ordering_practitioner_id = term.npi", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_ordering_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ORDERING_PRACTITIONER_ID' as field_name\n , case when term.npi is not null then 'valid'\n when m.ordering_practitioner_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ordering_practitioner_id is not null and term.npi is null\n then 'Ordering practitioner ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(ordering_practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.terminology.provider term on m.ordering_practitioner_id = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_result": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_result.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_result.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_result", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_result"], "alias": "lab_result_result", "checksum": {"name": "sha256", "checksum": "6fda94f02e8995e800eade0a3f955521e8be58a319ec94e41b21d0edd8945203"}, "config": {"enabled": true, "alias": "lab_result_result", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_result", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.206611, "relation_name": "cms_synthetic.data_quality.lab_result_result", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT' AS field_name\n , case when m.result is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(result as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_result.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT' AS field_name\n , case when m.result is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(result as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_code_type"], "alias": "lab_result_source_code_type", "checksum": {"name": "sha256", "checksum": "c7e8e9c6e159ea7792db580637d1f51bb0f158fbaf524d694078b8643f52fd3c"}, "config": {"enabled": true, "alias": "lab_result_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.207838, "relation_name": "cms_synthetic.data_quality.lab_result_source_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_description"], "alias": "lab_result_normalized_description", "checksum": {"name": "sha256", "checksum": "214add74deff114ceba82cf06a833d62d53536820d0a3bbcf8fe1e88f8559c09"}, "config": {"enabled": true, "alias": "lab_result_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2094011, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_reference_range_low.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_reference_range_low"], "alias": "lab_result_normalized_reference_range_low", "checksum": {"name": "sha256", "checksum": "3e26a584b4bf50e8182d88c657b02aec4da725d71d10e38e2159585b309b0781"}, "config": {"enabled": true, "alias": "lab_result_normalized_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.210797, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_reference_range_low", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' as field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_reference_range_low as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' as field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_reference_range_high.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_reference_range_high"], "alias": "lab_result_normalized_reference_range_high", "checksum": {"name": "sha256", "checksum": "3286a163ea95a54d27e8135817013f5944156df266bac8a94783c94e335c3edc"}, "config": {"enabled": true, "alias": "lab_result_normalized_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.212317, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_reference_range_high", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_reference_range_high as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_code"], "alias": "lab_result_normalized_code", "checksum": {"name": "sha256", "checksum": "8b42b624c7cbfde00cfa410b9c0a88b65ed5e122a0fe809317a2d1b44f08f55c"}, "config": {"enabled": true, "alias": "lab_result_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.213674, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.loinc is null\n then 'Normalized code does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m\nleft join {{ ref('terminology__loinc')}} term on m.normalized_code = term.loinc", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.loinc is null\n then 'Normalized code does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.terminology.loinc term on m.normalized_code = term.loinc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_description"], "alias": "lab_result_source_description", "checksum": {"name": "sha256", "checksum": "7483a17002571df131661cefda289aa12046c4d53a8412d8d6902d99b850ed08"}, "config": {"enabled": true, "alias": "lab_result_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.21524, "relation_name": "cms_synthetic.data_quality.lab_result_source_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_status": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_status", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_status.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_status.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_status", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_status"], "alias": "lab_result_status", "checksum": {"name": "sha256", "checksum": "897449c497f0818e83b1ea10df68f064ece7685de51db3918302523186533a6d"}, "config": {"enabled": true, "alias": "lab_result_status", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_status", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.216578, "relation_name": "cms_synthetic.data_quality.lab_result_status", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'STATUS' as field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(status as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_status.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'STATUS' as field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_accession_number": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_accession_number", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_accession_number.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_accession_number.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_accession_number", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_accession_number"], "alias": "lab_result_accession_number", "checksum": {"name": "sha256", "checksum": "af34498b29a11da5cf162648419300236e5c58501b2ab1065a392122c083bf66"}, "config": {"enabled": true, "alias": "lab_result_accession_number", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_accession_number", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.218195, "relation_name": "cms_synthetic.data_quality.lab_result_accession_number", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ACCESSION_NUMBER' AS field_name\n , case when m.accession_number is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(accession_number as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_accession_number.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ACCESSION_NUMBER' AS field_name\n , case when m.accession_number is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(accession_number as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_result_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_result_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_result_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_result_date.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_result_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_result_date"], "alias": "lab_result_result_date", "checksum": {"name": "sha256", "checksum": "cb680778fd5b92a12975c8448cea71b7787ff70532687a185f9c9931172fa962"}, "config": {"enabled": true, "alias": "lab_result_result_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_result_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2198799, "relation_name": "cms_synthetic.data_quality.lab_result_result_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT_DATE' as field_name\n , case\n when m.result_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.result_date <= cast('1901-01-01' as date) then 'invalid'\n when m.result_date < m.collection_date then 'invalid'\n when m.result_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.result_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.result_date <= cast('1901-01-01' as date) then 'too old'\n when m.result_date < m.collection_date then 'Result date before collection date'\n else null\n end as invalid_reason\n , cast(result_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_result_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT_DATE' as field_name\n , case\n when m.result_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.result_date <= cast('1901-01-01' as date) then 'invalid'\n when m.result_date < m.collection_date then 'invalid'\n when m.result_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.result_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.result_date <= cast('1901-01-01' as date) then 'too old'\n when m.result_date < m.collection_date then 'Result date before collection date'\n else null\n end as invalid_reason\n , cast(result_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_abnormal_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_abnormal_flag.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_abnormal_flag.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_abnormal_flag"], "alias": "lab_result_normalized_abnormal_flag", "checksum": {"name": "sha256", "checksum": "f29137052499d0cebf861e35c09630ec7e0c580faebf614832c12ac14776fdf8"}, "config": {"enabled": true, "alias": "lab_result_normalized_abnormal_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_abnormal_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.221359, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_abnormal_flag", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_ABNORMAL_FLAG' as field_name\n , case when m.normalized_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_abnormal_flag as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_abnormal_flag.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_ABNORMAL_FLAG' as field_name\n , case when m.normalized_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_abnormal_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_data_source"], "alias": "lab_result_data_source", "checksum": {"name": "sha256", "checksum": "a0cbc6ac59cde2adf6fa9d50f12a47291787df1d9a36ba1b0b477301a7b2aae9"}, "config": {"enabled": true, "alias": "lab_result_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.222763, "relation_name": "cms_synthetic.data_quality.lab_result_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_units": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_units.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_units.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_units"], "alias": "lab_result_normalized_units", "checksum": {"name": "sha256", "checksum": "2987cc946a5cc7afd1a98e3573fa7db596114efc253809706993e7c0e835b540"}, "config": {"enabled": true, "alias": "lab_result_normalized_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.224128, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_units", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_units as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_code_type"], "alias": "lab_result_normalized_code_type", "checksum": {"name": "sha256", "checksum": "d4b013f66e78e8fbb6c58c33fbfa5b1dd223e0763a91878f88dcfe3cbf797887"}, "config": {"enabled": true, "alias": "lab_result_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.22562, "relation_name": "cms_synthetic.data_quality.lab_result_normalized_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m\nleft join {{ ref('reference_data__code_type')}} term on m.normalized_code_type = term.code_type", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.reference_data.code_type term on m.normalized_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_reference_range_high.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_reference_range_high"], "alias": "lab_result_source_reference_range_high", "checksum": {"name": "sha256", "checksum": "4be26c66739267d98a1d1a73d727e6ddff75aa10f14210f240a7a83a20af4f50"}, "config": {"enabled": true, "alias": "lab_result_source_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2273018, "relation_name": "cms_synthetic.data_quality.lab_result_source_reference_range_high", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' AS field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_reference_range_high as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' AS field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_code"], "alias": "lab_result_source_code", "checksum": {"name": "sha256", "checksum": "ce7a368874b43334fbf01ff3d31d43764b681f059fc4f877ae91d2c977063b25"}, "config": {"enabled": true, "alias": "lab_result_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.22886, "relation_name": "cms_synthetic.data_quality.lab_result_source_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' AS field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' AS field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_patient_id"], "alias": "lab_result_patient_id", "checksum": {"name": "sha256", "checksum": "636666a5020091217d795a0aa4faea4f9fbe320afabfd0a01a6e3fb9ed071073"}, "config": {"enabled": true, "alias": "lab_result_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.230474, "relation_name": "cms_synthetic.data_quality.lab_result_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_component": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_source_component", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_component.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_component.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_component", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_component"], "alias": "lab_result_source_component", "checksum": {"name": "sha256", "checksum": "c15071682e1e2bf8d7c521d1e6b3af5887a47fd1d7173de5f866a99660e7ba2f"}, "config": {"enabled": true, "alias": "lab_result_source_component", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_component", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.231901, "relation_name": "cms_synthetic.data_quality.lab_result_source_component", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_COMPONENT' AS field_name\n , case when m.source_component is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_component as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_source_component.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_COMPONENT' AS field_name\n , case when m.source_component is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_component as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__lab_result_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_encounter_id"], "alias": "lab_result_encounter_id", "checksum": {"name": "sha256", "checksum": "05b59f12202ce41f3e7c5ebeff1a53f6a9b2895972b4f1c3cbbb0bcd8daf4b75"}, "config": {"enabled": true, "alias": "lab_result_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2333162, "relation_name": "cms_synthetic.data_quality.lab_result_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/lab_result/data_quality__lab_result_encounter_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_patient_id"], "alias": "condition_patient_id", "checksum": {"name": "sha256", "checksum": "26bc90a1a7e49d67bfb0fdf9f7dbda3cf43cf1d3ed786c9d8680c6dde940ac98"}, "config": {"enabled": true, "alias": "condition_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.145243, "relation_name": "cms_synthetic.data_quality.condition_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date) ) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date) ) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_normalized_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_normalized_code"], "alias": "condition_normalized_code", "checksum": {"name": "sha256", "checksum": "5ae8afe943f61747c6c7e32abd96779417a0438dd875a2bf69eeb8abd524a170"}, "config": {"enabled": true, "alias": "condition_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.140631, "relation_name": "cms_synthetic.data_quality.condition_normalized_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_cm is null\n then 'Normalized code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m\nleft join {{ ref('terminology__icd_10_cm')}} term on m.normalized_code = term.icd_10_cm", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_cm is null\n then 'Normalized code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join cms_synthetic.terminology.icd_10_cm term on m.normalized_code = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_encounter_id"], "alias": "condition_encounter_id", "checksum": {"name": "sha256", "checksum": "b00cd5a4d6a88ed4c073c14a0ae90318648caa6d4080bc2084a505b1079bceba"}, "config": {"enabled": true, "alias": "condition_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.137953, "relation_name": "cms_synthetic.data_quality.condition_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' AS field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(encounter_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_encounter_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' AS field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_status": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_status", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_status.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_status.sql", "unique_id": "model.the_tuva_project.data_quality__condition_status", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_status"], "alias": "condition_status", "checksum": {"name": "sha256", "checksum": "4acdaef87a26b55f3168eecc12612284b0ce1c0daff1f51a2543bdd2dc437f17"}, "config": {"enabled": true, "alias": "condition_status", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_status", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.156985, "relation_name": "cms_synthetic.data_quality.condition_status", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'STATUS' AS field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(status as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_status.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'STATUS' AS field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_present_on_admit_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_present_on_admit_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_present_on_admit_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_present_on_admit_description.sql", "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_present_on_admit_description"], "alias": "condition_present_on_admit_description", "checksum": {"name": "sha256", "checksum": "7b3e49e07027d9bf203211abbd0751c3d38170ca40a56decd9baf5a175609ddc"}, "config": {"enabled": true, "alias": "condition_present_on_admit_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_present_on_admit_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.14837, "relation_name": "cms_synthetic.data_quality.condition_present_on_admit_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_DESCRIPTION' AS field_name\n ,case when m.present_on_admit_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(substring(present_on_admit_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_present_on_admit_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_DESCRIPTION' AS field_name\n ,case when m.present_on_admit_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(present_on_admit_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_normalized_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__condition_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_normalized_description"], "alias": "condition_normalized_description", "checksum": {"name": "sha256", "checksum": "640e11fdb0b19d654ef4fc1002b7d8921ec34d96be3be4b6d34f6d10c242f31b"}, "config": {"enabled": true, "alias": "condition_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.141953, "relation_name": "cms_synthetic.data_quality.condition_normalized_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_condition_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_condition_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_condition_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_condition_id"], "alias": "condition_condition_id", "checksum": {"name": "sha256", "checksum": "218e3e65b99a65480cdf52c781fd48f89ee10723c456a9a72085cad648fff379"}, "config": {"enabled": true, "alias": "condition_condition_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_condition_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.132343, "relation_name": "cms_synthetic.data_quality.condition_condition_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_ID' AS field_name\n , case when m.condition_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(condition_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_ID' AS field_name\n , case when m.condition_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_condition_rank": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_condition_rank", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_rank.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_rank.sql", "unique_id": "model.the_tuva_project.data_quality__condition_condition_rank", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_condition_rank"], "alias": "condition_condition_rank", "checksum": {"name": "sha256", "checksum": "9c96965d2d042029b601150a660f95415d68369fd9e3bfeeac8db7fa750b4266"}, "config": {"enabled": true, "alias": "condition_condition_rank", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_condition_rank", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.133876, "relation_name": "cms_synthetic.data_quality.condition_condition_rank", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_RANK' AS field_name\n , case when m.condition_rank is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(condition_rank as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_rank.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_RANK' AS field_name\n , case when m.condition_rank is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_rank as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_normalized_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_normalized_code_type"], "alias": "condition_normalized_code_type", "checksum": {"name": "sha256", "checksum": "1f80ae7f2fd56ac1b4ad7afc166c1bc03970ed913ef0a2a13ed542bac80ede65"}, "config": {"enabled": true, "alias": "condition_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.139349, "relation_name": "cms_synthetic.data_quality.condition_normalized_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m\nleft join {{ ref('reference_data__code_type')}} as term on m.normalized_code_type = term.code_type", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join cms_synthetic.reference_data.code_type as term on m.normalized_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_onset_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_onset_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_onset_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_onset_date.sql", "unique_id": "model.the_tuva_project.data_quality__condition_onset_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_onset_date"], "alias": "condition_onset_date", "checksum": {"name": "sha256", "checksum": "e4571764bbfd00400faea525186f81dc7443e938ae53ce0a755e28941c7e9dfa"}, "config": {"enabled": true, "alias": "condition_onset_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_onset_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.14365, "relation_name": "cms_synthetic.data_quality.condition_onset_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ONSET_DATE' AS field_name\n ,case\n when m.onset_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.onset_date <= cast('1901-01-01' as date) then 'invalid'\n when m.onset_date > m.resolved_date then 'invalid'\n when m.onset_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.onset_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.onset_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.onset_date < m.resolved_date THEN 'Onset date after resolved date'\n else null\n end as invalid_reason\n ,cast(onset_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_onset_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ONSET_DATE' AS field_name\n ,case\n when m.onset_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.onset_date <= cast('1901-01-01' as date) then 'invalid'\n when m.onset_date > m.resolved_date then 'invalid'\n when m.onset_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.onset_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.onset_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.onset_date < m.resolved_date THEN 'Onset date after resolved date'\n else null\n end as invalid_reason\n ,cast(onset_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_recorded_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_recorded_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_recorded_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_recorded_date.sql", "unique_id": "model.the_tuva_project.data_quality__condition_recorded_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_recorded_date"], "alias": "condition_recorded_date", "checksum": {"name": "sha256", "checksum": "1138d50f83acdff57919edfb68ee53654fee98ec567b34d8b7f7566ab20388b1"}, "config": {"enabled": true, "alias": "condition_recorded_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_recorded_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1498182, "relation_name": "cms_synthetic.data_quality.condition_recorded_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'RECORDED_DATE' AS field_name\n ,CASE\n when m.recorded_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.recorded_date <= cast('1901-01-01' as date) then 'invalid'\n when m.recorded_date < m.onset_date then 'invalid'\n when m.recorded_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.recorded_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.recorded_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.recorded_date < m.onset_date THEN 'Recorded date before onset date'\n else null\n end as invalid_reason\n ,cast(recorded_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_recorded_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'RECORDED_DATE' AS field_name\n ,CASE\n when m.recorded_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.recorded_date <= cast('1901-01-01' as date) then 'invalid'\n when m.recorded_date < m.onset_date then 'invalid'\n when m.recorded_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.recorded_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.recorded_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.recorded_date < m.onset_date THEN 'Recorded date before onset date'\n else null\n end as invalid_reason\n ,cast(recorded_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_source_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__condition_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_source_description"], "alias": "condition_source_description", "checksum": {"name": "sha256", "checksum": "b067d95559170d43c957696bbd3fc5d7e67a3e3143b89328602750204bf7e7c7"}, "config": {"enabled": true, "alias": "condition_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.155623, "relation_name": "cms_synthetic.data_quality.condition_source_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' AS field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' AS field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_claim_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_claim_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_claim_id"], "alias": "condition_claim_id", "checksum": {"name": "sha256", "checksum": "a28ad4f6b95defad247999491b457ce73ea5b82425acd38d3cf5e5543be62650"}, "config": {"enabled": true, "alias": "condition_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.130948, "relation_name": "cms_synthetic.data_quality.condition_claim_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' AS field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(claim_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_claim_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' AS field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_source_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__condition_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_source_code_type"], "alias": "condition_source_code_type", "checksum": {"name": "sha256", "checksum": "6707e3e4e0924a51f9a9a85f23fc4ef01da26fe283fa81b4194d4b557bbadb91"}, "config": {"enabled": true, "alias": "condition_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1542552, "relation_name": "cms_synthetic.data_quality.condition_source_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' AS field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' AS field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__condition_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_data_source"], "alias": "condition_data_source", "checksum": {"name": "sha256", "checksum": "dbc46e78c1f7ea88c2f6a75700c5df177af79d186020d07ea4091213da615320"}, "config": {"enabled": true, "alias": "condition_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.136394, "relation_name": "cms_synthetic.data_quality.condition_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_condition_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_condition_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_type.sql", "unique_id": "model.the_tuva_project.data_quality__condition_condition_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_condition_type"], "alias": "condition_condition_type", "checksum": {"name": "sha256", "checksum": "b5f6c23ba550f517ac3fbf03a8617d1d9f53704cf29a1d7f28fec9957ad8f632"}, "config": {"enabled": true, "alias": "condition_condition_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_condition_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.135152, "relation_name": "cms_synthetic.data_quality.condition_condition_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_TYPE' AS field_name\n , case when m.condition_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(condition_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_condition_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_TYPE' AS field_name\n , case when m.condition_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_present_on_admit_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_present_on_admit_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_present_on_admit_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_present_on_admit_code.sql", "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_present_on_admit_code"], "alias": "condition_present_on_admit_code", "checksum": {"name": "sha256", "checksum": "0943078463cc1e6844a95e2f36880139caa3bad37ef707910c0a49e4cb276867"}, "config": {"enabled": true, "alias": "condition_present_on_admit_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_present_on_admit_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.14677, "relation_name": "cms_synthetic.data_quality.condition_present_on_admit_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_CODE' AS field_name\n ,case when term.present_on_admit_code is not null then 'valid'\n when m.present_on_admit_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.present_on_admit_code is not null and term.present_on_admit_code is null\n then 'Present On Admit Code does not join to Terminology present_on_admission table'\n else null\n end as invalid_reason\n ,cast(m.present_on_admit_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m\nleft join {{ ref('terminology__present_on_admission')}} term on m.present_on_admit_code = term.present_on_admit_code", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}, {"name": "terminology__present_on_admission", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition", "seed.the_tuva_project.terminology__present_on_admission"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_present_on_admit_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_CODE' AS field_name\n ,case when term.present_on_admit_code is not null then 'valid'\n when m.present_on_admit_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.present_on_admit_code is not null and term.present_on_admit_code is null\n then 'Present On Admit Code does not join to Terminology present_on_admission table'\n else null\n end as invalid_reason\n ,cast(m.present_on_admit_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join cms_synthetic.terminology.present_on_admission term on m.present_on_admit_code = term.present_on_admit_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_resolved_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_resolved_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_resolved_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_resolved_date.sql", "unique_id": "model.the_tuva_project.data_quality__condition_resolved_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_resolved_date"], "alias": "condition_resolved_date", "checksum": {"name": "sha256", "checksum": "3f8d20114a93295bd1c7b9a8ff32bdeafa631eb552062bbf607832d3744c8160"}, "config": {"enabled": true, "alias": "condition_resolved_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_resolved_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.151159, "relation_name": "cms_synthetic.data_quality.condition_resolved_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'RESOLVED_DATE' AS field_name\n , CASE\n when m.resolved_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.resolved_date <= cast('1901-01-01' as date) then 'invalid'\n when m.resolved_date < m.onset_date then 'invalid'\n when m.resolved_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.resolved_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.resolved_date <= cast('1901-01-01' as date) then 'too old'\n when m.resolved_date < m.onset_date THEN 'Resolved date before onset date'\n else null\n end as invalid_reason\n , cast(resolved_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_resolved_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'RESOLVED_DATE' AS field_name\n , CASE\n when m.resolved_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.resolved_date <= cast('1901-01-01' as date) then 'invalid'\n when m.resolved_date < m.onset_date then 'invalid'\n when m.resolved_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.resolved_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.resolved_date <= cast('1901-01-01' as date) then 'too old'\n when m.resolved_date < m.onset_date THEN 'Resolved date before onset date'\n else null\n end as invalid_reason\n , cast(resolved_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__condition_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__condition_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_source_code"], "alias": "condition_source_code", "checksum": {"name": "sha256", "checksum": "704ca60141eba8e514a5ddf194ffa96d272054d765c2df0bbff2e277be17602a"}, "config": {"enabled": true, "alias": "condition_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.152512, "relation_name": "cms_synthetic.data_quality.condition_source_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'SOURCE_CODE' AS field_name\n ,case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(source_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/condition/data_quality__condition_source_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'SOURCE_CODE' AS field_name\n ,case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_sex": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_sex", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_sex.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_sex.sql", "unique_id": "model.the_tuva_project.data_quality__patient_sex", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_sex"], "alias": "patient_sex", "checksum": {"name": "sha256", "checksum": "eec2a87532ec9f0880e499bb7e8ab9ccb6dda3e25c0cda33c4baab34455dd070"}, "config": {"enabled": true, "alias": "patient_sex", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_sex", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.314529, "relation_name": "cms_synthetic.data_quality.patient_sex", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'SEX' as field_name\n , case when term.gender is not null then 'valid'\n when m.sex is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.sex is not null and term.gender is null\n then 'Sex does not join to Terminology gender table'\n else null end as invalid_reason\n , cast(sex as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m\nleft join {{ ref('terminology__gender')}} term on m.sex = term.gender", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}, {"name": "terminology__gender", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient", "seed.the_tuva_project.terminology__gender"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_sex.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'SEX' as field_name\n , case when term.gender is not null then 'valid'\n when m.sex is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.sex is not null and term.gender is null\n then 'Sex does not join to Terminology gender table'\n else null end as invalid_reason\n , cast(sex as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join cms_synthetic.terminology.gender term on m.sex = term.gender", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_state": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_state", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_state.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_state.sql", "unique_id": "model.the_tuva_project.data_quality__patient_state", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_state"], "alias": "patient_state", "checksum": {"name": "sha256", "checksum": "6205e8f6ee916eba0e31561855ead14ac6de64a933d92ae0482daa9fa8bb8c95"}, "config": {"enabled": true, "alias": "patient_state", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_state", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.316375, "relation_name": "cms_synthetic.data_quality.patient_state", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(state as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_state.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_city": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_city", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_city.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_city.sql", "unique_id": "model.the_tuva_project.data_quality__patient_city", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_city"], "alias": "patient_city", "checksum": {"name": "sha256", "checksum": "872320379dbdc40ac2e481d244fae880c6f7f810916a05d77f3a63936eec65ee"}, "config": {"enabled": true, "alias": "patient_city", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_city", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3178189, "relation_name": "cms_synthetic.data_quality.patient_city", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'CITY' AS field_name\n ,case when m.city is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(city as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_city.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'CITY' AS field_name\n ,case when m.city is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(city as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_longitude": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_longitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_longitude.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_longitude.sql", "unique_id": "model.the_tuva_project.data_quality__patient_longitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_longitude"], "alias": "patient_longitude", "checksum": {"name": "sha256", "checksum": "b20eca6020333403f4a6e2f605764923c9f80c7793e5f27d474a5c24c99f11f5"}, "config": {"enabled": true, "alias": "patient_longitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_longitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.319167, "relation_name": "cms_synthetic.data_quality.patient_longitude", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(longitude as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_longitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_county": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_county", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_county.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_county.sql", "unique_id": "model.the_tuva_project.data_quality__patient_county", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_county"], "alias": "patient_county", "checksum": {"name": "sha256", "checksum": "e8feb45b32463a54c323bc276279b066ab0052743c5537896a907411ffab2e6d"}, "config": {"enabled": true, "alias": "patient_county", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_county", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.32076, "relation_name": "cms_synthetic.data_quality.patient_county", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'COUNTY' as field_name\n ,case when m.county is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(county as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_county.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'COUNTY' as field_name\n ,case when m.county is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(county as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_race": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_race", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_race.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_race.sql", "unique_id": "model.the_tuva_project.data_quality__patient_race", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_race"], "alias": "patient_race", "checksum": {"name": "sha256", "checksum": "11b8675fdf8836d88be72d8c3e45f28a271c00b0e48194b2962e18b33117a742"}, "config": {"enabled": true, "alias": "patient_race", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_race", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3222022, "relation_name": "cms_synthetic.data_quality.patient_race", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'RACE' as field_name\n , case when term.description is not null then 'valid'\n when m.race is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.race is not null and term.description is null\n then 'Race description does not join to Terminology race table'\n else null end as invalid_reason\n , cast(race as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m\nleft join {{ ref('terminology__race')}} term on m.race = term.description", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}, {"name": "terminology__race", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient", "seed.the_tuva_project.terminology__race"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_race.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'RACE' as field_name\n , case when term.description is not null then 'valid'\n when m.race is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.race is not null and term.description is null\n then 'Race description does not join to Terminology race table'\n else null end as invalid_reason\n , cast(race as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join cms_synthetic.terminology.race term on m.race = term.description", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_death_flag": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_death_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_death_flag.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_death_flag.sql", "unique_id": "model.the_tuva_project.data_quality__patient_death_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_death_flag"], "alias": "patient_death_flag", "checksum": {"name": "sha256", "checksum": "776ef00b815e0978361436567a414ad64c6316220e98d59fc4a911339aa09cfd"}, "config": {"enabled": true, "alias": "patient_death_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_death_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3236969, "relation_name": "cms_synthetic.data_quality.patient_death_flag", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_FLAG' as field_name\n , case when m.death_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(death_flag as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_death_flag.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_FLAG' as field_name\n , case when m.death_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(death_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_address": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_address", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_address.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_address.sql", "unique_id": "model.the_tuva_project.data_quality__patient_address", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_address"], "alias": "patient_address", "checksum": {"name": "sha256", "checksum": "c3014eccba95e9992c40c1acae80492b2fe42024d6731d15daf677d737673045"}, "config": {"enabled": true, "alias": "patient_address", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_address", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3250859, "relation_name": "cms_synthetic.data_quality.patient_address", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ADDRESS' as field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(address as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_address.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ADDRESS' as field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__patient_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_data_source"], "alias": "patient_data_source", "checksum": {"name": "sha256", "checksum": "f8596a3704bf12df396249de582ab6daf4cf5b9a40c9c9bd9efd5fd653e6e881"}, "config": {"enabled": true, "alias": "patient_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.32637, "relation_name": "cms_synthetic.data_quality.patient_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_zip_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_zip_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_zip_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_zip_code.sql", "unique_id": "model.the_tuva_project.data_quality__patient_zip_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_zip_code"], "alias": "patient_zip_code", "checksum": {"name": "sha256", "checksum": "2acf3140e3b2fb3e510279743bb23d11a39f88d854307a47121078ee0fe34926"}, "config": {"enabled": true, "alias": "patient_zip_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_zip_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.327861, "relation_name": "cms_synthetic.data_quality.patient_zip_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(zip_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_zip_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_first_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_first_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_first_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_first_name.sql", "unique_id": "model.the_tuva_project.data_quality__patient_first_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_first_name"], "alias": "patient_first_name", "checksum": {"name": "sha256", "checksum": "0de74376b58029bed87936098817cbd4edcdb9d6a0bf684f42d626bb39669efd"}, "config": {"enabled": true, "alias": "patient_first_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_first_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.329188, "relation_name": "cms_synthetic.data_quality.patient_first_name", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(first_name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_first_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_last_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_last_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_last_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_last_name.sql", "unique_id": "model.the_tuva_project.data_quality__patient_last_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_last_name"], "alias": "patient_last_name", "checksum": {"name": "sha256", "checksum": "6bf205a8697db8e69cf4186d9e233b4edf47578bbed780fa7ea6cdafd4b498cb"}, "config": {"enabled": true, "alias": "patient_last_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_last_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.330783, "relation_name": "cms_synthetic.data_quality.patient_last_name", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' AS field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(last_name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_last_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' AS field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_latitude": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_latitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_latitude.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_latitude.sql", "unique_id": "model.the_tuva_project.data_quality__patient_latitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_latitude"], "alias": "patient_latitude", "checksum": {"name": "sha256", "checksum": "0c02a459557fe16849919fb54b519a300153e7d883e732adfd8ec803ed3a9346"}, "config": {"enabled": true, "alias": "patient_latitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_latitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.332122, "relation_name": "cms_synthetic.data_quality.patient_latitude", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(latitude as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_latitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_birth_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_birth_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_birth_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_birth_date.sql", "unique_id": "model.the_tuva_project.data_quality__patient_birth_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_birth_date"], "alias": "patient_birth_date", "checksum": {"name": "sha256", "checksum": "155db4685cb12a8e206ad25f5f64036ef191dd1a351286e00b4b9ddf4273f3db"}, "config": {"enabled": true, "alias": "patient_birth_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_birth_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.333399, "relation_name": "cms_synthetic.data_quality.patient_birth_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'BIRTH_DATE' AS field_name\n , case\n when m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.birth_date <= cast('1901-01-01' as date) then 'invalid'\n when m.birth_date > m.death_date then 'invalid'\n when m.birth_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.birth_date <= cast('1901-01-01' as date) then 'too old'\n when m.birth_date > m.death_date then 'Birth date after death date'\n else null\n end as invalid_reason\n , cast(birth_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_birth_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'BIRTH_DATE' AS field_name\n , case\n when m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.birth_date <= cast('1901-01-01' as date) then 'invalid'\n when m.birth_date > m.death_date then 'invalid'\n when m.birth_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.birth_date <= cast('1901-01-01' as date) then 'too old'\n when m.birth_date > m.death_date then 'Birth date after death date'\n else null\n end as invalid_reason\n , cast(birth_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_death_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_death_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_death_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_death_date.sql", "unique_id": "model.the_tuva_project.data_quality__patient_death_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_death_date"], "alias": "patient_death_date", "checksum": {"name": "sha256", "checksum": "d499bf99f7b6562043a5249b97f71ef07dd46bfce98316f8d36290878e4822dd"}, "config": {"enabled": true, "alias": "patient_death_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_death_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.33477, "relation_name": "cms_synthetic.data_quality.patient_death_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_DATE' AS field_name\n , case\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date > m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date > m.birth_date then 'Death date after birth date'\n else null\n end as invalid_reason\n , cast(death_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_death_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_DATE' AS field_name\n , case\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date > m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date > m.birth_date then 'Death date after birth date'\n else null\n end as invalid_reason\n , cast(death_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__patient_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__patient_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_patient_id"], "alias": "patient_patient_id", "checksum": {"name": "sha256", "checksum": "8d65812bde0966159028be05bbf098d18595455142223722fa1e3b6f9de784cc"}, "config": {"enabled": true, "alias": "patient_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.336087, "relation_name": "cms_synthetic.data_quality.patient_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n {% if target.type == 'bigquery' %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\n {% else %}\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\n {% endif %}\n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/patient/data_quality__patient_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_rxnorm_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_rxnorm_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_rxnorm_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_rxnorm_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_rxnorm_code"], "alias": "medication_rxnorm_code", "checksum": {"name": "sha256", "checksum": "218e20904d2e8fc7df65df3d88fa4ea43fff15577876a07ab34ea7015aa53c98"}, "config": {"enabled": true, "alias": "medication_rxnorm_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_rxnorm_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.253042, "relation_name": "cms_synthetic.data_quality.medication_rxnorm_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_CODE' as field_name\n , case when term.rxcui is not null then 'valid'\n when m.rxnorm_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.rxnorm_code is not null and term.rxcui is null\n then 'RX norm code does not join to Terminology rxnorm_to_atc table'\n else null end as invalid_reason\n , cast(rxnorm_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m\nleft join {{ ref('terminology__rxnorm_to_atc')}} term on m.rxnorm_code = term.rxcui", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_rxnorm_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_CODE' as field_name\n , case when term.rxcui is not null then 'valid'\n when m.rxnorm_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.rxnorm_code is not null and term.rxcui is null\n then 'RX norm code does not join to Terminology rxnorm_to_atc table'\n else null end as invalid_reason\n , cast(rxnorm_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join cms_synthetic.terminology.rxnorm_to_atc term on m.rxnorm_code = term.rxcui", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_source_code"], "alias": "medication_source_code", "checksum": {"name": "sha256", "checksum": "6b743d99a54e7980231f8f6cf665bdff2a73277d68743d6b190f65338b88c102"}, "config": {"enabled": true, "alias": "medication_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.254833, "relation_name": "cms_synthetic.data_quality.medication_source_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_atc_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_atc_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_atc_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_atc_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_atc_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_atc_code"], "alias": "medication_atc_code", "checksum": {"name": "sha256", "checksum": "85519e5918ffbfd27db172cdba5421cf95b7901915181ebc6489434068846001"}, "config": {"enabled": true, "alias": "medication_atc_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_atc_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.256313, "relation_name": "cms_synthetic.data_quality.medication_atc_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_CODE' as field_name\n , case when coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is not null then 'valid'\n when m.atc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.atc_code is not null and coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is null\n then 'ATC Code does not join to Terminology rxnorm_to_atc table on any atc level'\n else null end as invalid_reason\n , cast(atc_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_1 on m.atc_code = term_1.atc_1_name\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_2 on m.atc_code = term_2.atc_2_name\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_3 on m.atc_code = term_3.atc_3_name\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_4 on m.atc_code = term_4.atc_4_name", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_atc_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_CODE' as field_name\n , case when coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is not null then 'valid'\n when m.atc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.atc_code is not null and coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is null\n then 'ATC Code does not join to Terminology rxnorm_to_atc table on any atc level'\n else null end as invalid_reason\n , cast(atc_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join cms_synthetic.terminology.rxnorm_to_atc term_1 on m.atc_code = term_1.atc_1_name\nleft join cms_synthetic.terminology.rxnorm_to_atc term_2 on m.atc_code = term_2.atc_2_name\nleft join cms_synthetic.terminology.rxnorm_to_atc term_3 on m.atc_code = term_3.atc_3_name\nleft join cms_synthetic.terminology.rxnorm_to_atc term_4 on m.atc_code = term_4.atc_4_name", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_dispensing_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_dispensing_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_dispensing_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_dispensing_date.sql", "unique_id": "model.the_tuva_project.data_quality__medication_dispensing_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_dispensing_date"], "alias": "medication_dispensing_date", "checksum": {"name": "sha256", "checksum": "221f642db4125feba8c2454a24aff521fe221b9ad15e39b2f0cd6c2d917a81a8"}, "config": {"enabled": true, "alias": "medication_dispensing_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_dispensing_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.25808, "relation_name": "cms_synthetic.data_quality.medication_dispensing_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DISPENSING_DATE' as field_name\n , case\n when m.dispensing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.dispensing_date < m.prescribing_date then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'too old'\n when m.dispensing_date < m.prescribing_date then 'Dispensing date before prescribing date'\n else null\n end as invalid_reason\n , cast(dispensing_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_dispensing_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DISPENSING_DATE' as field_name\n , case\n when m.dispensing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.dispensing_date < m.prescribing_date then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'too old'\n when m.dispensing_date < m.prescribing_date then 'Dispensing date before prescribing date'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_prescribing_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_prescribing_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_prescribing_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_prescribing_date.sql", "unique_id": "model.the_tuva_project.data_quality__medication_prescribing_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_prescribing_date"], "alias": "medication_prescribing_date", "checksum": {"name": "sha256", "checksum": "48c5bafd79aed438fa6241a8ef6f98b7d826c6292980369537620676ff10b409"}, "config": {"enabled": true, "alias": "medication_prescribing_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_prescribing_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2594821, "relation_name": "cms_synthetic.data_quality.medication_prescribing_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRESCRIBING_DATE' as field_name\n , case\n when m.prescribing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.prescribing_date > m.dispensing_date then 'invalid'\n when m.prescribing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.prescribing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'too old'\n when m.prescribing_date > m.dispensing_date then 'Prescribing date after dispensing date'\n else null\n end as invalid_reason\n , cast(prescribing_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_prescribing_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRESCRIBING_DATE' as field_name\n , case\n when m.prescribing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.prescribing_date > m.dispensing_date then 'invalid'\n when m.prescribing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.prescribing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'too old'\n when m.prescribing_date > m.dispensing_date then 'Prescribing date after dispensing date'\n else null\n end as invalid_reason\n , cast(prescribing_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_days_supply": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_days_supply", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_days_supply.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_days_supply.sql", "unique_id": "model.the_tuva_project.data_quality__medication_days_supply", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_days_supply"], "alias": "medication_days_supply", "checksum": {"name": "sha256", "checksum": "7a193946de20b29247c830b927ff23ff78385e2a2dc1e013fcf04a1a28f6b338"}, "config": {"enabled": true, "alias": "medication_days_supply", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_days_supply", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.260821, "relation_name": "cms_synthetic.data_quality.medication_days_supply", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DAYS_SUPPLY' AS field_name\n , case when m.days_supply is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(days_supply as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_days_supply.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DAYS_SUPPLY' AS field_name\n , case when m.days_supply is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_strength": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_strength", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_strength.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_strength.sql", "unique_id": "model.the_tuva_project.data_quality__medication_strength", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_strength"], "alias": "medication_strength", "checksum": {"name": "sha256", "checksum": "8de92dab23b9e5c61485ca41ca5e1f39b9533a1d71620bb543da4aa701d5cef0"}, "config": {"enabled": true, "alias": "medication_strength", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_strength", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.262753, "relation_name": "cms_synthetic.data_quality.medication_strength", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'STRENGTH' as field_name\n , case when m.strength is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(strength as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_strength.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'STRENGTH' as field_name\n , case when m.strength is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(strength as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_patient_id"], "alias": "medication_patient_id", "checksum": {"name": "sha256", "checksum": "64724e34733505b6d81f056961445ada634657167b81a2cb8c1956ac1f074d3d"}, "config": {"enabled": true, "alias": "medication_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2642171, "relation_name": "cms_synthetic.data_quality.medication_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_rxnorm_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_rxnorm_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_rxnorm_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_rxnorm_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_rxnorm_description"], "alias": "medication_rxnorm_description", "checksum": {"name": "sha256", "checksum": "7117dcfb8b16fc4963c859b176fe40c32af8f1721acde033bc0b022ecb1ea2a9"}, "config": {"enabled": true, "alias": "medication_rxnorm_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_rxnorm_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.26561, "relation_name": "cms_synthetic.data_quality.medication_rxnorm_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_DESCRIPTION' as field_name\n , case when m.rxnorm_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(rxnorm_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_rxnorm_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_DESCRIPTION' as field_name\n , case when m.rxnorm_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(rxnorm_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_encounter_id"], "alias": "medication_encounter_id", "checksum": {"name": "sha256", "checksum": "7d83db7f5b80314c11f8ed58a3bf51a14eff2621e09180ab703824ad16c9be83"}, "config": {"enabled": true, "alias": "medication_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.267002, "relation_name": "cms_synthetic.data_quality.medication_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_encounter_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__medication_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_data_source"], "alias": "medication_data_source", "checksum": {"name": "sha256", "checksum": "70c070d8efb763811babcf3e876804b7cd1c75e07c845e76e5a34d7f91311118"}, "config": {"enabled": true, "alias": "medication_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.268532, "relation_name": "cms_synthetic.data_quality.medication_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_atc_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_atc_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_atc_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_atc_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_atc_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_atc_description"], "alias": "medication_atc_description", "checksum": {"name": "sha256", "checksum": "6041c98ea4657478e00c4aec1987a99dee5d61467e1d0edce11bbd6a95feac03"}, "config": {"enabled": true, "alias": "medication_atc_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_atc_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2698612, "relation_name": "cms_synthetic.data_quality.medication_atc_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_DESCRIPTION' as field_name\n , case when m.atc_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(atc_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_atc_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_DESCRIPTION' as field_name\n , case when m.atc_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(atc_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_quantity_unit": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_quantity_unit", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_quantity_unit.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_quantity_unit.sql", "unique_id": "model.the_tuva_project.data_quality__medication_quantity_unit", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_quantity_unit"], "alias": "medication_quantity_unit", "checksum": {"name": "sha256", "checksum": "5b073a993cbb5bfd491b54ebd112f5fe7abe5171e96dc04dce403646127392c2"}, "config": {"enabled": true, "alias": "medication_quantity_unit", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_quantity_unit", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2715158, "relation_name": "cms_synthetic.data_quality.medication_quantity_unit", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY_UNIT' as field_name\n , case when m.quantity_unit is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(quantity_unit as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_quantity_unit.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY_UNIT' as field_name\n , case when m.quantity_unit is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity_unit as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_source_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_source_description"], "alias": "medication_source_description", "checksum": {"name": "sha256", "checksum": "fed0fbf68b571906c4ee9b0fc6f6e9dff2b203ed1c9e7949eede9d70032cc65c"}, "config": {"enabled": true, "alias": "medication_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.273164, "relation_name": "cms_synthetic.data_quality.medication_source_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_ndc_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_ndc_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_ndc_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_ndc_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_ndc_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_ndc_code"], "alias": "medication_ndc_code", "checksum": {"name": "sha256", "checksum": "c5cb3dea0db95d066a1e9cab37f511796031b63b694fd921dd3d61cfd2f944fe"}, "config": {"enabled": true, "alias": "medication_ndc_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_ndc_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.274515, "relation_name": "cms_synthetic.data_quality.medication_ndc_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_CODE' as field_name\n , case when m.ndc_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(ndc_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_ndc_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_CODE' as field_name\n , case when m.ndc_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(ndc_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_medication_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_medication_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_medication_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_medication_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_medication_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_medication_id"], "alias": "medication_medication_id", "checksum": {"name": "sha256", "checksum": "998061f7e4ad4ba8f465b31dd49b87849688fcbabd796773fb8717c7e9dd7881"}, "config": {"enabled": true, "alias": "medication_medication_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_medication_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2758, "relation_name": "cms_synthetic.data_quality.medication_medication_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'MEDICATION_ID' AS field_name\n , case when m.medication_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(medication_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_medication_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'MEDICATION_ID' AS field_name\n , case when m.medication_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(medication_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_source_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__medication_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_source_code_type"], "alias": "medication_source_code_type", "checksum": {"name": "sha256", "checksum": "d18ac3581f3886452096b89be72745255ad4ebc32d5dae75620352c1adf5886a"}, "config": {"enabled": true, "alias": "medication_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.277154, "relation_name": "cms_synthetic.data_quality.medication_source_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_ndc_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_ndc_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_ndc_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_ndc_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_ndc_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_ndc_description"], "alias": "medication_ndc_description", "checksum": {"name": "sha256", "checksum": "021e60830d2b164e0ea326818bd11ef8892ed52f6e2bca55f81a406f330a6397"}, "config": {"enabled": true, "alias": "medication_ndc_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_ndc_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.278763, "relation_name": "cms_synthetic.data_quality.medication_ndc_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_DESCRIPTION' as field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ndc_code is not null and term.ndc is null\n then 'NDC code type does not join to Terminology ndc table'\n else null end as invalid_reason\n , cast(substring(ndc_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m\nleft join {{ ref('terminology__ndc')}} term on m.ndc_code = term.ndc", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_ndc_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_DESCRIPTION' as field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ndc_code is not null and term.ndc is null\n then 'NDC code type does not join to Terminology ndc table'\n else null end as invalid_reason\n , cast(substring(ndc_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join cms_synthetic.terminology.ndc term on m.ndc_code = term.ndc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_quantity": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_quantity", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_quantity.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_quantity.sql", "unique_id": "model.the_tuva_project.data_quality__medication_quantity", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_quantity"], "alias": "medication_quantity", "checksum": {"name": "sha256", "checksum": "fa20b89aca2a6dbb6950b4d1d5ec59dc8ba506ca9f5959e171004f8c2c9bbee3"}, "config": {"enabled": true, "alias": "medication_quantity", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_quantity", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.280132, "relation_name": "cms_synthetic.data_quality.medication_quantity", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY' as field_name\n , case when m.quantity is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(quantity as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_quantity.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY' as field_name\n , case when m.quantity is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_practitioner_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_practitioner_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_practitioner_id"], "alias": "medication_practitioner_id", "checksum": {"name": "sha256", "checksum": "c2be43e33622d1ef7f1166f22b44b465550fba7a94c32c4e3e3389c2de2e9eaf"}, "config": {"enabled": true, "alias": "medication_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.281429, "relation_name": "cms_synthetic.data_quality.medication_practitioner_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(practitioner_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_route": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medication_route", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_route.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_route.sql", "unique_id": "model.the_tuva_project.data_quality__medication_route", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_route"], "alias": "medication_route", "checksum": {"name": "sha256", "checksum": "f7e78a8816f9166ee1eae03bc567e5f6b06d7139d4601a95d66f3b012e51ec0e"}, "config": {"enabled": true, "alias": "medication_route", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_route", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.283179, "relation_name": "cms_synthetic.data_quality.medication_route", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ROUTE' as field_name\n , case when m.route is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(route as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/medication/data_quality__medication_route.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ROUTE' as field_name\n , case when m.route is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(route as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_code"], "alias": "observation_source_code", "checksum": {"name": "sha256", "checksum": "21499e45430ca862bdda1481fdcc3ffabe90146f4f5f721e8d33978bb81d0d34"}, "config": {"enabled": true, "alias": "observation_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.28459, "relation_name": "cms_synthetic.data_quality.observation_source_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_normalized_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_reference_range_high.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_reference_range_high"], "alias": "observation_normalized_reference_range_high", "checksum": {"name": "sha256", "checksum": "32d7efe40d61c292510c22c557f17c912d333b3a30757c16dcc87bbb9d5893e2"}, "config": {"enabled": true, "alias": "observation_normalized_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2860632, "relation_name": "cms_synthetic.data_quality.observation_normalized_reference_range_high", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_reference_range_high as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_units": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_source_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_units.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_units.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_units"], "alias": "observation_source_units", "checksum": {"name": "sha256", "checksum": "d8ec184d9cef922dab0c35cc4f34a71bf51031a66aa635dd41be886c39df7666"}, "config": {"enabled": true, "alias": "observation_source_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.287487, "relation_name": "cms_synthetic.data_quality.observation_source_units", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS TABLE_NAME\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_UNITS' as field_name\n , case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_units as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS TABLE_NAME\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_UNITS' as field_name\n , case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_observation_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_observation_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_type.sql", "unique_id": "model.the_tuva_project.data_quality__observation_observation_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_observation_type"], "alias": "observation_observation_type", "checksum": {"name": "sha256", "checksum": "9ddc36953ce1f9f5438184f2d97efcbf2e13e92fc58ab9cad15c0360f3b60c17"}, "config": {"enabled": true, "alias": "observation_observation_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_observation_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.289088, "relation_name": "cms_synthetic.data_quality.observation_observation_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_TYPE' as field_name\n , case when m.observation_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(observation_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_TYPE' as field_name\n , case when m.observation_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_code"], "alias": "observation_normalized_code", "checksum": {"name": "sha256", "checksum": "de07b79ef2934d0815c1d7bdd4819278f4fdca0fd2f2c1de9a2f827365be803c"}, "config": {"enabled": true, "alias": "observation_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.290441, "relation_name": "cms_synthetic.data_quality.observation_normalized_code", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when m.normalized_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when m.normalized_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_description"], "alias": "observation_normalized_description", "checksum": {"name": "sha256", "checksum": "f088e62be6e7d758155179d6bfd628a8c259c24c19b9852e002cdd425fc6497f"}, "config": {"enabled": true, "alias": "observation_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.291806, "relation_name": "cms_synthetic.data_quality.observation_normalized_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' as field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' as field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__observation_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_data_source"], "alias": "observation_data_source", "checksum": {"name": "sha256", "checksum": "f2a5b8740f37afff41c363c56c57dfd7be9fe0649d21dd8417691f1cabfbe34b"}, "config": {"enabled": true, "alias": "observation_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.293817, "relation_name": "cms_synthetic.data_quality.observation_data_source", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_panel_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_panel_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_panel_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_panel_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_panel_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_panel_id"], "alias": "observation_panel_id", "checksum": {"name": "sha256", "checksum": "dd5433db0cc93cab7a056cafc990b13d46eb0bad38a2b585b299844c6e784a8c"}, "config": {"enabled": true, "alias": "observation_panel_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_panel_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2955241, "relation_name": "cms_synthetic.data_quality.observation_panel_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PANEL_ID' as field_name\n , case when m.panel_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(panel_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_panel_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PANEL_ID' as field_name\n , case when m.panel_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(panel_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_observation_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_observation_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_observation_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_observation_id"], "alias": "observation_observation_id", "checksum": {"name": "sha256", "checksum": "1fd8211a5ee0cb28f95e694af135fb990593f255435ce26ce15eb78553747816"}, "config": {"enabled": true, "alias": "observation_observation_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_observation_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.297002, "relation_name": "cms_synthetic.data_quality.observation_observation_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_ID' as field_name\n , case when m.observation_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(observation_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_ID' as field_name\n , case when m.observation_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_reference_range_low": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_source_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_reference_range_low.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_reference_range_low"], "alias": "observation_source_reference_range_low", "checksum": {"name": "sha256", "checksum": "f7d254d4f76b55afe5761dcd93c2ef7228e550461c3bc82f0acdc0bc700ddd2a"}, "config": {"enabled": true, "alias": "observation_source_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.2984362, "relation_name": "cms_synthetic.data_quality.observation_source_reference_range_low", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' as field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_reference_range_low as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' as field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_result": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_result.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_result.sql", "unique_id": "model.the_tuva_project.data_quality__observation_result", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_result"], "alias": "observation_result", "checksum": {"name": "sha256", "checksum": "b5cbafba0930cfeb651db8ede4faedc068191cc01fc6f44fe691423547bc7195"}, "config": {"enabled": true, "alias": "observation_result", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_result", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.299873, "relation_name": "cms_synthetic.data_quality.observation_result", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'RESULT' as field_name\n ,case when m.result is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(substring(result, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_result.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'RESULT' as field_name\n ,case when m.result is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(result, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_code_type"], "alias": "observation_source_code_type", "checksum": {"name": "sha256", "checksum": "0300a5ff0ed1aa2818f9e4995948b7082f3551a63503b053a68144d0e4e04519"}, "config": {"enabled": true, "alias": "observation_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3013701, "relation_name": "cms_synthetic.data_quality.observation_source_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_normalized_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_reference_range_low.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_reference_range_low"], "alias": "observation_normalized_reference_range_low", "checksum": {"name": "sha256", "checksum": "3c2d97db193f3c7009df72a873b946eaad97da89c2fc560d306521a585beb4d9"}, "config": {"enabled": true, "alias": "observation_normalized_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.302785, "relation_name": "cms_synthetic.data_quality.observation_normalized_reference_range_low", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' AS field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_reference_range_low as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' AS field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_observation_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_observation_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_date.sql", "unique_id": "model.the_tuva_project.data_quality__observation_observation_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_observation_date"], "alias": "observation_observation_date", "checksum": {"name": "sha256", "checksum": "57ac82df4f4b8e28422259c15283d3b8db87bf28f08c21984cf998b9d274fac1"}, "config": {"enabled": true, "alias": "observation_observation_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_observation_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.30431, "relation_name": "cms_synthetic.data_quality.observation_observation_date", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_DATE' as field_name\n , case\n when m.observation_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.observation_date <= cast('1901-01-01' as date) then 'invalid'\n when m.observation_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.observation_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.observation_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(observation_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_observation_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_DATE' as field_name\n , case\n when m.observation_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.observation_date <= cast('1901-01-01' as date) then 'invalid'\n when m.observation_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.observation_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.observation_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(observation_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_encounter_id"], "alias": "observation_encounter_id", "checksum": {"name": "sha256", "checksum": "d6d3b2688d964fb8ddc2dadfc3548fec6f70ac325ec85b56a1872d9d467c8a80"}, "config": {"enabled": true, "alias": "observation_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.305676, "relation_name": "cms_synthetic.data_quality.observation_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' as field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(encounter_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_encounter_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' as field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_description": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_description.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_description"], "alias": "observation_source_description", "checksum": {"name": "sha256", "checksum": "6927a80b948f88cefc73213f60850386f9187e877f6bbd1fb3aeac8717205639"}, "config": {"enabled": true, "alias": "observation_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.306967, "relation_name": "cms_synthetic.data_quality.observation_source_description", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_reference_range_high": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_source_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_reference_range_high.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_reference_range_high"], "alias": "observation_source_reference_range_high", "checksum": {"name": "sha256", "checksum": "28798e31ea80d13635ab7c931e46155c2baecf5944ba82b192b930ba6239090d"}, "config": {"enabled": true, "alias": "observation_source_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.308487, "relation_name": "cms_synthetic.data_quality.observation_source_reference_range_high", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' as field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(source_reference_range_high as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_source_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' as field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_units": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_normalized_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_units.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_units.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_units"], "alias": "observation_normalized_units", "checksum": {"name": "sha256", "checksum": "db1e03a83df6b523aeb6ccbacf8e14ec6fdba48cbf6ca374da7fddbcd461779d"}, "config": {"enabled": true, "alias": "observation_normalized_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.310064, "relation_name": "cms_synthetic.data_quality.observation_normalized_units", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_units as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_code_type"], "alias": "observation_normalized_code_type", "checksum": {"name": "sha256", "checksum": "8e338cd033bb7d3b2a73e3d77eb4fe84418bb862eb1d46015ed45c954579337f"}, "config": {"enabled": true, "alias": "observation_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.311448, "relation_name": "cms_synthetic.data_quality.observation_normalized_code_type", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when m.normalized_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when m.normalized_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__observation_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_patient_id"], "alias": "observation_patient_id", "checksum": {"name": "sha256", "checksum": "dd53c761d5188978823dbffc5a2c07b4f7c1184320505a11b38a7425cb852234"}, "config": {"enabled": true, "alias": "observation_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.312778, "relation_name": "cms_synthetic.data_quality.observation_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled', False)\n) }}\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/clinical/observation/data_quality__observation_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_data_source"], "alias": "pharmacy_data_source", "checksum": {"name": "sha256", "checksum": "451fa5d3f029e434ad763ee95ebf61ca28a06c7f76108c01f1f0efda1e8bf026"}, "config": {"enabled": true, "alias": "pharmacy_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1093, "relation_name": "cms_synthetic.data_quality.pharmacy_data_source", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DATA_SOURCE' AS field_name\n , case\n when m.data_source is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DATA_SOURCE' AS field_name\n , case\n when m.data_source is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_prescribing_provider_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_prescribing_provider_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_prescribing_provider_npi.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_prescribing_provider_npi"], "alias": "pharmacy_prescribing_provider_npi", "checksum": {"name": "sha256", "checksum": "8c448c2d2828f329875553f52005087f9a8d812ad6d2b71875a2254257ff9d0f"}, "config": {"enabled": true, "alias": "pharmacy_prescribing_provider_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_prescribing_provider_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.126226, "relation_name": "cms_synthetic.data_quality.pharmacy_prescribing_provider_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PRESCRIBING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.prescribing_provider_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.prescribing_provider_npi is not null\n and term.npi is null\n then 'Prescribing Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.prescribing_provider_npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m\nleft join {{ ref('terminology__provider')}} as term on m.prescribing_provider_npi = term.npi", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_prescribing_provider_npi.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PRESCRIBING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.prescribing_provider_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.prescribing_provider_npi is not null\n and term.npi is null\n then 'Prescribing Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.prescribing_provider_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join cms_synthetic.terminology.provider as term on m.prescribing_provider_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_line_number": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_line_number", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_claim_line_number.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_claim_line_number.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_claim_line_number"], "alias": "pharmacy_claim_line_number", "checksum": {"name": "sha256", "checksum": "b8bd8a9c6e1c44045cdc7657551e8d30fd4dcd38cc7dcc0d588bcc17904b9039"}, "config": {"enabled": true, "alias": "pharmacy_claim_line_number", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_line_number", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.10479, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_line_number", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_LINE_NUMBER' AS field_name\n , case\n when m.claim_line_number is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_claim_line_number.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_LINE_NUMBER' AS field_name\n , case\n when m.claim_line_number is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_days_supply": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_days_supply", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_days_supply.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_days_supply.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_days_supply", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_days_supply"], "alias": "pharmacy_days_supply", "checksum": {"name": "sha256", "checksum": "6a1cf9fb292725b8160039a207bd5a8e5f17f780d3ed7c8210783ff9cea94522"}, "config": {"enabled": true, "alias": "pharmacy_days_supply", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_days_supply", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.11074, "relation_name": "cms_synthetic.data_quality.pharmacy_days_supply", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DAYS_SUPPLY' AS field_name\n , case\n when m.days_supply is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(days_supply as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_days_supply.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DAYS_SUPPLY' AS field_name\n , case\n when m.days_supply is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_payer": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_payer.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_payer.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_payer", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_payer"], "alias": "pharmacy_payer", "checksum": {"name": "sha256", "checksum": "2db9ec3ee46d56ac9e6a6261945533739c516dc4a4ac8709f15cadc856301380"}, "config": {"enabled": true, "alias": "pharmacy_payer", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_payer", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.123544, "relation_name": "cms_synthetic.data_quality.pharmacy_payer", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAYER' AS field_name\n , case\n when m.payer is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(payer as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_payer.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAYER' AS field_name\n , case\n when m.payer is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(payer as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_paid_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_paid_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_paid_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_paid_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_paid_amount"], "alias": "pharmacy_paid_amount", "checksum": {"name": "sha256", "checksum": "e7682641cc89675819ec6e37c7d226cfc6e2106b5ff8e35881efbd0905330bda"}, "config": {"enabled": true, "alias": "pharmacy_paid_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_paid_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.119376, "relation_name": "cms_synthetic.data_quality.pharmacy_paid_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(paid_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_paid_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_dispensing_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_dispensing_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_dispensing_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_dispensing_date.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_dispensing_date"], "alias": "pharmacy_dispensing_date", "checksum": {"name": "sha256", "checksum": "ed94ef75642c07f29c433b436490fbf30772ece492198d43c904fbfb254ab947"}, "config": {"enabled": true, "alias": "pharmacy_dispensing_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_dispensing_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1137831, "relation_name": "cms_synthetic.data_quality.pharmacy_dispensing_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\nwith tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_DATE' AS field_name\n , case\n when m.dispensing_date > tuva_last_run then 'invalid'\n when m.dispensing_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > tuva_last_run then 'future'\n when m.dispensing_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n else null\n end as invalid_reason\n , cast(dispensing_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_dispensing_date.sql", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_DATE' AS field_name\n , case\n when m.dispensing_date > tuva_last_run then 'invalid'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > tuva_last_run then 'future'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_coinsurance_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_coinsurance_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_coinsurance_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_coinsurance_amount"], "alias": "pharmacy_coinsurance_amount", "checksum": {"name": "sha256", "checksum": "259a869a511ef11ae0c671438b26c99e7d1e14ab341d20f5cbe57208a1852cfc"}, "config": {"enabled": true, "alias": "pharmacy_coinsurance_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_coinsurance_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.10621, "relation_name": "cms_synthetic.data_quality.pharmacy_coinsurance_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(coinsurance_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_coinsurance_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_member_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_member_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_member_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_member_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_member_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_member_id"], "alias": "pharmacy_member_id", "checksum": {"name": "sha256", "checksum": "5462277a87f698ff8f6354b611e796c38197be014c2a46a6fb3eb1cf68e53a59"}, "config": {"enabled": true, "alias": "pharmacy_member_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_member_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.116676, "relation_name": "cms_synthetic.data_quality.pharmacy_member_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'MEMBER_ID' AS field_name\n , case\n when m.member_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_member_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'MEMBER_ID' AS field_name\n , case\n when m.member_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_ndc_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_ndc_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_ndc_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_ndc_code.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_ndc_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_ndc_code"], "alias": "pharmacy_ndc_code", "checksum": {"name": "sha256", "checksum": "123cbbde25c2653aaf78bdeaa67a399ebde6d6b0bda44e547d1c10b91de5bb14"}, "config": {"enabled": true, "alias": "pharmacy_ndc_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_ndc_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1180742, "relation_name": "cms_synthetic.data_quality.pharmacy_ndc_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'NDC_CODE' AS field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.ndc_code is not null\n and term.ndc is null\n then 'NDC Code does not join to Terminology NDC table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.ndc_code\", \"'|'\", \"coalesce(term.rxnorm_description, term.fda_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m\nleft join {{ ref('terminology__ndc')}} as term on m.ndc_code = term.ndc", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_ndc_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'NDC_CODE' AS field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.ndc_code is not null\n and term.ndc is null\n then 'NDC Code does not join to Terminology NDC table'\n else null\n end as invalid_reason\n , m.ndc_code || '|' || coalesce(term.rxnorm_description, term.fda_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join cms_synthetic.terminology.ndc as term on m.ndc_code = term.ndc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_paid_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_paid_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_paid_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_paid_date.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_paid_date"], "alias": "pharmacy_paid_date", "checksum": {"name": "sha256", "checksum": "36a3a16bb5fb78b737405906f18f716bec48c0ce39e0d3a514d1078b2b04e752"}, "config": {"enabled": true, "alias": "pharmacy_paid_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_paid_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.120573, "relation_name": "cms_synthetic.data_quality.pharmacy_paid_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\nwith tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n else null\n end as invalid_reason\n , cast(paid_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_paid_date.sql", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(paid_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_dispensing_provider_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_dispensing_provider_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_dispensing_provider_npi.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_dispensing_provider_npi"], "alias": "pharmacy_dispensing_provider_npi", "checksum": {"name": "sha256", "checksum": "ad0fe33e4d1059aeb893aaaa5f2de903b29fb1b9636e6526c3a1da6f348d1130"}, "config": {"enabled": true, "alias": "pharmacy_dispensing_provider_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_dispensing_provider_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.115196, "relation_name": "cms_synthetic.data_quality.pharmacy_dispensing_provider_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.dispensing_provider_npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.dispensing_provider_npi is not null\n and term.npi is null\n then 'dispensing provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n , cast(m.dispensing_provider_npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m\nleft join {{ ref('terminology__provider')}} as term on m.dispensing_provider_npi = term.npi", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_dispensing_provider_npi.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.dispensing_provider_npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.dispensing_provider_npi is not null\n and term.npi is null\n then 'dispensing provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n , cast(m.dispensing_provider_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join cms_synthetic.terminology.provider as term on m.dispensing_provider_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_refills": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_refills", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_refills.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_refills.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_refills", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_refills"], "alias": "pharmacy_refills", "checksum": {"name": "sha256", "checksum": "2b0697e8a715dc3505409cfbef3e258dccb6331993a465e6d40a9be69c7c1537"}, "config": {"enabled": true, "alias": "pharmacy_refills", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_refills", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.129445, "relation_name": "cms_synthetic.data_quality.pharmacy_refills", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'REFILLS' AS field_name\n , case\n when m.refills is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(refills as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_refills.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'REFILLS' AS field_name\n , case\n when m.refills is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(refills as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_plan": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_plan.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_plan.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_plan", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_plan"], "alias": "pharmacy_plan", "checksum": {"name": "sha256", "checksum": "aea16b974ff9bdbe0eb9d5a7e699212b5280c67aade84f82f597c14ccb05bcfc"}, "config": {"enabled": true, "alias": "pharmacy_plan", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_plan", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.124913, "relation_name": "cms_synthetic.data_quality.pharmacy_plan", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PLAN' AS field_name\n , case\n when m.{{ quote_column('plan') }} is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast({{ quote_column('plan') }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_plan.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PLAN' AS field_name\n , case\n when m.plan is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(plan as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_patient_id"], "alias": "pharmacy_patient_id", "checksum": {"name": "sha256", "checksum": "70071ca485b2c8b7b8dc76cf2cabbaa539ac13c45da1bea8c49a63f6f1bfd355"}, "config": {"enabled": true, "alias": "pharmacy_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.121902, "relation_name": "cms_synthetic.data_quality.pharmacy_patient_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PATIENT_ID' AS field_name\n , case\n when m.patient_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PATIENT_ID' AS field_name\n , case\n when m.patient_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_deductible_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_deductible_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_deductible_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_deductible_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_deductible_amount"], "alias": "pharmacy_deductible_amount", "checksum": {"name": "sha256", "checksum": "ba325303587ee858b120230382d77483d75c6626073160aceea3cdb28c2a9657"}, "config": {"enabled": true, "alias": "pharmacy_deductible_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_deductible_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1122901, "relation_name": "cms_synthetic.data_quality.pharmacy_deductible_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(deductible_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_deductible_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_quantity": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_quantity", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_quantity.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_quantity.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_quantity", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_quantity"], "alias": "pharmacy_quantity", "checksum": {"name": "sha256", "checksum": "cbcde9c500af04a3cd04374be1833fb767c9a395ac3ad6be163f140cbb52233f"}, "config": {"enabled": true, "alias": "pharmacy_quantity", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_quantity", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.128017, "relation_name": "cms_synthetic.data_quality.pharmacy_quantity", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.quantity is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(quantity as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_quantity.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.quantity is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_allowed_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_allowed_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_allowed_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_allowed_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_allowed_amount"], "alias": "pharmacy_allowed_amount", "checksum": {"name": "sha256", "checksum": "97035c185f3ff4c76c19d9db925eef059286f8791e191686063a864b9851baac"}, "config": {"enabled": true, "alias": "pharmacy_allowed_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_allowed_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.101973, "relation_name": "cms_synthetic.data_quality.pharmacy_allowed_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(allowed_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_allowed_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_copayment_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_copayment_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_copayment_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_copayment_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_copayment_amount"], "alias": "pharmacy_copayment_amount", "checksum": {"name": "sha256", "checksum": "134d43e4362569db50648fec949246216b55c4b1cb42566308edb002ef3075dd"}, "config": {"enabled": true, "alias": "pharmacy_copayment_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_copayment_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.107763, "relation_name": "cms_synthetic.data_quality.pharmacy_copayment_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(copayment_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_copayment_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_claim_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_claim_id"], "alias": "pharmacy_claim_id", "checksum": {"name": "sha256", "checksum": "80013e6011b31e26498ce392a9c86ba400d0e4a43f11d2247fcfef2a3cd9badd"}, "config": {"enabled": true, "alias": "pharmacy_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.1034648, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_ID' AS field_name\n , case\n when m.claim_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/pharmacy/data_quality__pharmacy_claim_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_ID' AS field_name\n , case\n when m.claim_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_payer_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_payer_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_payer_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_payer_type.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_payer_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_payer_type"], "alias": "eligibility_payer_type", "checksum": {"name": "sha256", "checksum": "e179d06c18604bd6f2dc5c2c6d575277d55b64ed364dbab205c245fe936fabae"}, "config": {"enabled": true, "alias": "eligibility_payer_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_payer_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0097978, "relation_name": "cms_synthetic.data_quality.eligibility_payer_type", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER_TYPE' AS field_name\n ,case when m.payer_type is null then 'null'\n when term.payer_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.payer_type is not null and term.payer_type is null then 'Payer Type does not join to Terminology Payer Type table'\n else null\n end as invalid_reason\n ,cast(m.payer_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('terminology__payer_type')}} term on m.payer_type = term.payer_type", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__payer_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_payer_type.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER_TYPE' AS field_name\n ,case when m.payer_type is null then 'null'\n when term.payer_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.payer_type is not null and term.payer_type is null then 'Payer Type does not join to Terminology Payer Type table'\n else null\n end as invalid_reason\n ,cast(m.payer_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.payer_type term on m.payer_type = term.payer_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_zip_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_zip_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_zip_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_zip_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_zip_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_zip_code"], "alias": "eligibility_zip_code", "checksum": {"name": "sha256", "checksum": "141e43dd255509c24922c251d9fb86c2c07ac1809ae7fae50c3ae4b0198e3b30"}, "config": {"enabled": true, "alias": "eligibility_zip_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_zip_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.019948, "relation_name": "cms_synthetic.data_quality.eligibility_zip_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ZIP_CODE' AS field_name\n {% if target.type == 'fabric' %}\n ,case when m.zip_code is null then 'null'\n when len(m.zip_code) in (5,9,10) then 'valid'\n else 'invalid' end as bucket_name\n ,case\n when m.zip_code is not null and len(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\n else null\n end as invalid_reason\n {% else %}\n ,case when m.zip_code is null then 'null'\n when length(m.zip_code) in (5,9,10) then 'valid'\n else 'invalid' end as bucket_name\n ,case\n when m.zip_code is not null and length(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\n else null\n end as invalid_reason\n {% endif %}\n ,cast(zip_code as {{ dbt.type_string() }}) as field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_zip_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ZIP_CODE' AS field_name\n \n ,case when m.zip_code is null then 'null'\n when length(m.zip_code) in (5,9,10) then 'valid'\n else 'invalid' end as bucket_name\n ,case\n when m.zip_code is not null and length(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\n else null\n end as invalid_reason\n \n ,cast(zip_code as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_start_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_start_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_start_date"], "alias": "eligibility_start_date", "checksum": {"name": "sha256", "checksum": "2d3e4c9f03e1bd5764d8e1eeb56dea717deef59fb8cee1de63a8e0b360b2d3fe"}, "config": {"enabled": true, "alias": "eligibility_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.017157, "relation_name": "cms_synthetic.data_quality.eligibility_start_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_START_DATE' AS field_name\n ,case\n when m.enrollment_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.enrollment_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n ,cast(enrollment_start_date as {{ dbt.type_string() }}) as field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_start_date.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_START_DATE' AS field_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n ,cast(enrollment_start_date as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_plan": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_plan.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_plan.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_plan", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_plan"], "alias": "eligibility_plan", "checksum": {"name": "sha256", "checksum": "616685efcdf4c1bda1c9cbc43a495fbb33e9c33452da810ab2d00f9c5b370ff0"}, "config": {"enabled": true, "alias": "eligibility_plan", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_plan", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.014432, "relation_name": "cms_synthetic.data_quality.eligibility_plan", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PLAN' AS field_name\n ,case when m.{{ quote_column('plan') }} is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(m.{{ quote_column('plan') }} as {{ dbt.type_string() }}) as field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_plan.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(m.plan as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_end_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_end_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_end_date"], "alias": "eligibility_end_date", "checksum": {"name": "sha256", "checksum": "5b4bc4871877885aa31b095a80d0891904112c6ffaccd0949a8d31f35a27cb73"}, "config": {"enabled": true, "alias": "eligibility_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.99854, "relation_name": "cms_synthetic.data_quality.eligibility_end_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id,'NULL') AS drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_END_DATE' AS field_name\n ,case\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_end_date < m.enrollment_start_date then 'invalid'\n when m.enrollment_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.enrollment_end_date < m.enrollment_start_date then 'end date before start date'\n else null\n end as invalid_reason\n ,cast(enrollment_end_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_end_date.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id,'NULL') AS drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_END_DATE' AS field_name\n ,case\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_end_date < m.enrollment_start_date then 'invalid'\n when m.enrollment_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.enrollment_end_date < m.enrollment_start_date then 'end date before start date'\n else null\n end as invalid_reason\n ,cast(enrollment_end_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_medicare_status_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_medicare_status_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_medicare_status_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_medicare_status_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_medicare_status_code"], "alias": "eligibility_medicare_status_code", "checksum": {"name": "sha256", "checksum": "17eda67cb89c36f362ce841e335f18e80bf858fe4789d3cada0ee56ec2e03c8a"}, "config": {"enabled": true, "alias": "eligibility_medicare_status_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_medicare_status_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.004089, "relation_name": "cms_synthetic.data_quality.eligibility_medicare_status_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEDICARE_STATUS_CODE' AS field_name\n ,case when m.medicare_status_code is null then 'null'\n when term.medicare_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.medicare_status_code is not null and term.medicare_status_code is null then 'Medicare Status Code does not join to Terminology Medicare Status table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.medicare_status_code\", \"'|'\", \"coalesce(term.medicare_status_description,'')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('terminology__medicare_status')}} term on m.medicare_status_code = term.medicare_status_code", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__medicare_status", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_status"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_medicare_status_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEDICARE_STATUS_CODE' AS field_name\n ,case when m.medicare_status_code is null then 'null'\n when term.medicare_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.medicare_status_code is not null and term.medicare_status_code is null then 'Medicare Status Code does not join to Terminology Medicare Status table'\n else null\n end as invalid_reason\n , m.medicare_status_code || '|' || coalesce(term.medicare_status_description,'') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.medicare_status term on m.medicare_status_code = term.medicare_status_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_death_flag": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_death_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_death_flag.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_death_flag.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_death_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_death_flag"], "alias": "eligibility_death_flag", "checksum": {"name": "sha256", "checksum": "a3cf737fc8a7d6134d984f9c3485215b5afaf5ffd3443ebc8193a13639071ac8"}, "config": {"enabled": true, "alias": "eligibility_death_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_death_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.99579, "relation_name": "cms_synthetic.data_quality.eligibility_death_flag", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_FLAG' AS field_name\n ,case\n when m.death_flag in (1,0) then 'valid'\n when m.death_flag is null then 'null'\n else 'invalid'\n end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(death_flag as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_death_flag.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_FLAG' AS field_name\n ,case\n when m.death_flag in (1,0) then 'valid'\n when m.death_flag is null then 'null'\n else 'invalid'\n end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(death_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_first_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_first_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_first_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_first_name.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_first_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_first_name"], "alias": "eligibility_first_name", "checksum": {"name": "sha256", "checksum": "98c411318fd930ff50c6f44c4b14fa08b64fd05ccbbfa83a8c9bbdb994e8cf52"}, "config": {"enabled": true, "alias": "eligibility_first_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_first_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.00004, "relation_name": "cms_synthetic.data_quality.eligibility_first_name", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'FIRST_NAME' AS field_name\n ,case when m.first_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(first_name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_first_name.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'FIRST_NAME' AS field_name\n ,case when m.first_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(first_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_phone": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_phone", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_phone.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_phone.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_phone", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_phone"], "alias": "eligibility_phone", "checksum": {"name": "sha256", "checksum": "3b4d1880c1d9e47a0359a1d19cbb578bc4a3218feeabdd3bfb4d1d8d94c81002"}, "config": {"enabled": true, "alias": "eligibility_phone", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_phone", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0131478, "relation_name": "cms_synthetic.data_quality.eligibility_phone", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PHONE' AS field_name\n ,case when m.phone is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(phone as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_phone.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PHONE' AS field_name\n ,case when m.phone is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(phone as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_payer": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_payer.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_payer.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_payer", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_payer"], "alias": "eligibility_payer", "checksum": {"name": "sha256", "checksum": "c3a4fec21db6ae289c071ba3e4844b7122fd0abe1dd63c2feaaec1affe9ad04d"}, "config": {"enabled": true, "alias": "eligibility_payer", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_payer", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0112672, "relation_name": "cms_synthetic.data_quality.eligibility_payer", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(payer as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_payer.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_state": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_state", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_state.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_state.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_state", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_state"], "alias": "eligibility_state", "checksum": {"name": "sha256", "checksum": "cc882b4c49b3892ed6fd53c88e4b98d3682b3da4863b91b429cb1b88516ad5e9"}, "config": {"enabled": true, "alias": "eligibility_state", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_state", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.018616, "relation_name": "cms_synthetic.data_quality.eligibility_state", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'STATE' AS field_name\n ,case when m.state is null then 'null'\n when term.ssa_fips_state_name is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.state is not null and term.ssa_fips_state_name is null then 'State does not join to Terminology SSA_FIPS_STATE table'\n else null\n end as invalid_reason\n ,cast(state as {{ dbt.type_string() }}) as field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('reference_data__ssa_fips_state')}} as term on m.state = term.ssa_fips_state_name", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "reference_data__ssa_fips_state", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__ssa_fips_state"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_state.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'STATE' AS field_name\n ,case when m.state is null then 'null'\n when term.ssa_fips_state_name is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.state is not null and term.ssa_fips_state_name is null then 'State does not join to Terminology SSA_FIPS_STATE table'\n else null\n end as invalid_reason\n ,cast(state as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.reference_data.ssa_fips_state as term on m.state = term.ssa_fips_state_name", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_member_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_member_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_member_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_member_id.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_member_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_member_id"], "alias": "eligibility_member_id", "checksum": {"name": "sha256", "checksum": "c1d934952975096340c99598b1b96629247c3a0df463a1e7e84d335e4385b473"}, "config": {"enabled": true, "alias": "eligibility_member_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_member_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.005337, "relation_name": "cms_synthetic.data_quality.eligibility_member_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_member_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_data_source"], "alias": "eligibility_data_source", "checksum": {"name": "sha256", "checksum": "baad42bd11c83fe7d28c861c229e2206e79713c5904630a18d6573d7e9ba6d00"}, "config": {"enabled": true, "alias": "eligibility_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.992958, "relation_name": "cms_synthetic.data_quality.eligibility_data_source", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_race": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_race", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_race.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_race.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_race", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_race"], "alias": "eligibility_race", "checksum": {"name": "sha256", "checksum": "e5f57ba5dab774a362f0ec4b8ae25175c721cf0c9be56449531d72d0aa63d95f"}, "config": {"enabled": true, "alias": "eligibility_race", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_race", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.015766, "relation_name": "cms_synthetic.data_quality.eligibility_race", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'RACE' AS field_name\n ,case when m.race is null then 'null'\n when r.description is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.race is not null and r.description is null then 'Race does not join to terminology race table'\n else null\n end as invalid_reason\n ,cast(race as {{ dbt.type_string() }}) as field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('terminology__race')}} r on m.race=r.description", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__race", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__race"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_race.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'RACE' AS field_name\n ,case when m.race is null then 'null'\n when r.description is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.race is not null and r.description is null then 'Race does not join to terminology race table'\n else null\n end as invalid_reason\n ,cast(race as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.race r on m.race=r.description", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_address": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_address", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_address.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_address.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_address", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_address"], "alias": "eligibility_address", "checksum": {"name": "sha256", "checksum": "dcb3e5732eb4f0e7de102ddca6a08ea0e87f7174151802e11f4e729debba90ae"}, "config": {"enabled": true, "alias": "eligibility_address", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_address", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.98822, "relation_name": "cms_synthetic.data_quality.eligibility_address", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'eligibility' as table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ADDRESS' AS field_name\n ,case when m.address is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,CAST(address as {{ dbt.type_string() }}) AS field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_address.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'eligibility' as table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ADDRESS' AS field_name\n ,case when m.address is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(address as TEXT) AS field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_patient_id"], "alias": "eligibility_patient_id", "checksum": {"name": "sha256", "checksum": "6d86e2fa21f34647e234aa59853027e7dd08b4028a78c74481588833ec1afd28"}, "config": {"enabled": true, "alias": "eligibility_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.00842, "relation_name": "cms_synthetic.data_quality.eligibility_patient_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_gender": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_gender", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_gender.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_gender.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_gender", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_gender"], "alias": "eligibility_gender", "checksum": {"name": "sha256", "checksum": "78d7a2ec40373ff9785f6aeb9a15e6b9cdd8fdcd36de04fec82ab7319b7298f2"}, "config": {"enabled": true, "alias": "eligibility_gender", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_gender", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.001397, "relation_name": "cms_synthetic.data_quality.eligibility_gender", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'GENDER' AS field_name\n ,case when m.gender is null then 'null'\n when term.gender is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.gender is not null and term.gender is null then 'Gender does not join to Terminology Gender table'\n else null\n end as invalid_reason\n ,cast(m.gender as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('terminology__gender')}} term on m.gender = term.gender", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__gender", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__gender"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_gender.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'GENDER' AS field_name\n ,case when m.gender is null then 'null'\n when term.gender is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.gender is not null and term.gender is null then 'Gender does not join to Terminology Gender table'\n else null\n end as invalid_reason\n ,cast(m.gender as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.gender term on m.gender = term.gender", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_birth_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_birth_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_birth_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_birth_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_birth_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_birth_date"], "alias": "eligibility_birth_date", "checksum": {"name": "sha256", "checksum": "06923efa156aef5c60d739d9815ab53fcbfc7c4a175a2a064003762d65daf14c"}, "config": {"enabled": true, "alias": "eligibility_birth_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_birth_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.98961, "relation_name": "cms_synthetic.data_quality.eligibility_birth_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nWITH base as (\n SELECT * \n FROM {{ ref('eligibility')}}\n\n),\nunique_field as (\n SELECT DISTINCT member_id\n ,cast(birth_date as {{ dbt.type_string() }}) as field\n ,data_source\n FROM base\n),\nclaim_grain as (\n SELECT member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n GROUP BY member_id\n ,data_source\n),\nclaim_agg as (\nSELECT\n member_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} AS field_aggregated\nFROM\n unique_field\nGROUP BY\n data_source,\n member_id\n)\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'BIRTH_DATE' AS field_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) THEN 'invalid'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'invalid'\n WHEN m.birth_date IS NULL THEN 'null'\n ELSE 'valid' \n END AS bucket_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) THEN 'future'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'too old'\n else null\n END AS invalid_reason\n,CAST({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) AS field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_birth_date.sql", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n SELECT DISTINCT member_id\n ,cast(birth_date as TEXT) as field\n ,data_source\n FROM base\n),\nclaim_grain as (\n SELECT member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n GROUP BY member_id\n ,data_source\n),\nclaim_agg as (\nSELECT\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) AS field_aggregated\nFROM\n unique_field\nGROUP BY\n data_source,\n member_id\n)\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'BIRTH_DATE' AS field_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) THEN 'invalid'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'invalid'\n WHEN m.birth_date IS NULL THEN 'null'\n ELSE 'valid' \n END AS bucket_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) THEN 'future'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'too old'\n else null\n END AS invalid_reason\n,CAST(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) AS field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_city": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_city", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_city.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_city.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_city", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_city"], "alias": "eligibility_city", "checksum": {"name": "sha256", "checksum": "1d3038b870c710e3a2bca48997c393c5be736b1cc7d726fdad7017117dd09929"}, "config": {"enabled": true, "alias": "eligibility_city", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_city", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.991262, "relation_name": "cms_synthetic.data_quality.eligibility_city", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'CITY' AS field_name\n ,case when m.race is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,CAST(city as {{ dbt.type_string() }}) AS field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_city.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'CITY' AS field_name\n ,case when m.race is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(city as TEXT) AS field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_dual_status_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_dual_status_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_dual_status_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_dual_status_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_dual_status_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_dual_status_code"], "alias": "eligibility_dual_status_code", "checksum": {"name": "sha256", "checksum": "4a14a7fa03e3d43acf24032ab7a5c566064d52f57bab93da1b5daa3507a8918f"}, "config": {"enabled": true, "alias": "eligibility_dual_status_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_dual_status_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.997235, "relation_name": "cms_synthetic.data_quality.eligibility_dual_status_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DUAL_STATUS_CODE' AS field_name\n ,case when m.dual_status_code is null then 'null'\n when term.dual_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.dual_status_code is not null and term.dual_status_code is null then 'Dual Status Code does not join to Terminology Medicare Dual Eligibility table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.dual_status_code\", \"'|'\", \"coalesce(term.dual_status_description,'')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('terminology__medicare_dual_eligibility')}} term on m.dual_status_code = term.dual_status_code", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__medicare_dual_eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_dual_eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_dual_status_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DUAL_STATUS_CODE' AS field_name\n ,case when m.dual_status_code is null then 'null'\n when term.dual_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.dual_status_code is not null and term.dual_status_code is null then 'Dual Status Code does not join to Terminology Medicare Dual Eligibility table'\n else null\n end as invalid_reason\n , m.dual_status_code || '|' || coalesce(term.dual_status_description,'') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.medicare_dual_eligibility term on m.dual_status_code = term.dual_status_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_last_name": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_last_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_last_name.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_last_name.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_last_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_last_name"], "alias": "eligibility_last_name", "checksum": {"name": "sha256", "checksum": "66764af4232a0711db956febe18c0377e38dd2dde68db841a8c027f718d09236"}, "config": {"enabled": true, "alias": "eligibility_last_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_last_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.00281, "relation_name": "cms_synthetic.data_quality.eligibility_last_name", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'LAST_NAME' AS field_name\n ,case when m.last_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(last_name as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_last_name.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'LAST_NAME' AS field_name\n ,case when m.last_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(last_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_original_reason_entitlement_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_original_reason_entitlement_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_original_reason_entitlement_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_original_reason_entitlement_code"], "alias": "eligibility_original_reason_entitlement_code", "checksum": {"name": "sha256", "checksum": "d57393a6f98d27d78606af7f1dd8bb239935a913a8ed0a78b55058a08fb695f0"}, "config": {"enabled": true, "alias": "eligibility_original_reason_entitlement_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_original_reason_entitlement_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.006955, "relation_name": "cms_synthetic.data_quality.eligibility_original_reason_entitlement_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ORIGINAL_REASON_ENTITLEMENT_CODE' AS field_name\n ,case when m.original_reason_entitlement_code is null then 'null'\n when term.original_reason_entitlement_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.original_reason_entitlement_code is not null and term.original_reason_entitlement_code is null then 'Original Reason Entitlement Code does not join to Terminology Original Reason Entitlement Code table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.original_reason_entitlement_code\", \"'|'\", \"coalesce(term.original_reason_entitlement_description,'')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility')}} m\nleft join {{ ref('terminology__medicare_orec')}} term on m.original_reason_entitlement_code = term.original_reason_entitlement_code", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__medicare_orec", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_orec"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_original_reason_entitlement_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ORIGINAL_REASON_ENTITLEMENT_CODE' AS field_name\n ,case when m.original_reason_entitlement_code is null then 'null'\n when term.original_reason_entitlement_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.original_reason_entitlement_code is not null and term.original_reason_entitlement_code is null then 'Original Reason Entitlement Code does not join to Terminology Original Reason Entitlement Code table'\n else null\n end as invalid_reason\n , m.original_reason_entitlement_code || '|' || coalesce(term.original_reason_entitlement_description,'') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.medicare_orec term on m.original_reason_entitlement_code = term.original_reason_entitlement_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_death_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_death_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_death_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_death_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_death_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_death_date"], "alias": "eligibility_death_date", "checksum": {"name": "sha256", "checksum": "4a426879e22c780cb41e9bd56c741b4e35f62bc06755f59c136860c9370e0189"}, "config": {"enabled": true, "alias": "eligibility_death_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_death_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.994448, "relation_name": "cms_synthetic.data_quality.eligibility_death_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nWITH base as (\n SELECT * \n FROM {{ ref('eligibility')}}\n\n),\nunique_field as (\n select distinct member_id\n ,cast(death_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by member_id\n ,data_source\n),\nclaim_agg as (\nselect\n member_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n data_source,\n member_id\n)\nselect distinct\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date <= m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date <= m.birth_date then 'death date before birth date'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/eligibility/data_quality__eligibility_death_date.sql", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n select distinct member_id\n ,cast(death_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by member_id\n ,data_source\n),\nclaim_agg as (\nselect\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n data_source,\n member_id\n)\nselect distinct\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date <= m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date <= m.birth_date then 'death date before birth date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_line_number": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_claim_line_number", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_number.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_number.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_number", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_line_number"], "alias": "claim_claim_line_number", "checksum": {"name": "sha256", "checksum": "a1905df1c5c1360097a4e7c28306136180aa3fd8d24e009ee4552f2baff7800a"}, "config": {"enabled": true, "alias": "claim_claim_line_number", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_line_number", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0270772, "relation_name": "cms_synthetic.data_quality.claim_claim_line_number", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_LINE_NUMBER' AS field_name\n ,case when m.claim_line_number is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_number.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_LINE_NUMBER' AS field_name\n ,case when m.claim_line_number is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_charge_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_charge_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_charge_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_charge_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_charge_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_charge_amount"], "alias": "claim_charge_amount", "checksum": {"name": "sha256", "checksum": "e81841432605bad3559ff60832387b681e7b8ac29a639db4470c9105f29b5005"}, "config": {"enabled": true, "alias": "claim_charge_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_charge_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0227609, "relation_name": "cms_synthetic.data_quality.claim_charge_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(charge_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_charge_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_paid_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_paid_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_paid_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_paid_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_paid_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_paid_amount"], "alias": "claim_paid_amount", "checksum": {"name": "sha256", "checksum": "ebe45347f2cabebaf7f32c66acef7ef8a569e820dce2231a507f12cba8a26381"}, "config": {"enabled": true, "alias": "claim_paid_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_paid_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.041717, "relation_name": "cms_synthetic.data_quality.claim_paid_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(paid_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_paid_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_data_source": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_data_source.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__claim_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_data_source"], "alias": "claim_data_source", "checksum": {"name": "sha256", "checksum": "395556214d6ae2e72c1bd6f1985b6607c7af97d4992fa4bb386a8e69911cd617"}, "config": {"enabled": true, "alias": "claim_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.03444, "relation_name": "cms_synthetic.data_quality.claim_data_source", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(data_source as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_line_start_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_claim_line_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_start_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_line_start_date"], "alias": "claim_claim_line_start_date", "checksum": {"name": "sha256", "checksum": "8d0f0518777ec463140a90f99c618c010ca4ec6fcbcb4e663c3fa82f0dcc55f7"}, "config": {"enabled": true, "alias": "claim_claim_line_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_line_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.028773, "relation_name": "cms_synthetic.data_quality.claim_claim_line_start_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith tuva_last_run as(\n\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_START_DATE' AS field_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'invalid'\n when m.claim_line_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp = \"cte.tuva_last_run\") }} then 'invalid'\n when m.claim_line_start_date < m.claim_start_date then 'invalid'\n when m.claim_line_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'future'\n when m.claim_line_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp = \"cte.tuva_last_run\" ) }} then 'too old'\n when m.claim_line_start_date < m.claim_start_date then 'line date less than than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_start_date.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_START_DATE' AS field_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'invalid'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_start_date < m.claim_start_date then 'invalid'\n when m.claim_line_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'future'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_start_date < m.claim_start_date then 'line date less than than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_paid_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_paid_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_paid_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_paid_date.sql", "unique_id": "model.the_tuva_project.data_quality__claim_paid_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_paid_date"], "alias": "claim_paid_date", "checksum": {"name": "sha256", "checksum": "668aff6d757564d7a036f9381107c846e40cf792a867c48dd038032054170a87"}, "config": {"enabled": true, "alias": "claim_paid_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_paid_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.043154, "relation_name": "cms_synthetic.data_quality.claim_paid_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith tuva_last_run as(\n\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.paid_date < m.claim_start_date then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when m.paid_date < m.claim_start_date then 'paid date before claim start date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_paid_date.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date < m.claim_start_date then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.paid_date < m.claim_start_date then 'paid date before claim start date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_member_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_member_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_member_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_member_id.sql", "unique_id": "model.the_tuva_project.data_quality__claim_member_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_member_id"], "alias": "claim_member_id", "checksum": {"name": "sha256", "checksum": "a0ff4d1f78d485f548d272bd0483bcad57581abb5ec505072cc8414d6ca169a3"}, "config": {"enabled": true, "alias": "claim_member_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_member_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.040361, "relation_name": "cms_synthetic.data_quality.claim_member_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_member_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__claim_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_patient_id"], "alias": "claim_patient_id", "checksum": {"name": "sha256", "checksum": "15ddb7e8c5f995785499d301499e0d14acc437ba85e7db6a82c48eef01c18885"}, "config": {"enabled": true, "alias": "claim_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.044587, "relation_name": "cms_synthetic.data_quality.claim_patient_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_payer": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_payer.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_payer.sql", "unique_id": "model.the_tuva_project.data_quality__claim_payer", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_payer"], "alias": "claim_payer", "checksum": {"name": "sha256", "checksum": "ca12eca92fb86716c546f3dcf4b6cd6816e13e4e8deacd24262cbbb01ce36c24"}, "config": {"enabled": true, "alias": "claim_payer", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_payer", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.046036, "relation_name": "cms_synthetic.data_quality.claim_payer", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(payer as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_payer.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_line_end_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_claim_line_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_end_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_line_end_date"], "alias": "claim_claim_line_end_date", "checksum": {"name": "sha256", "checksum": "33dc5e75b055c4482fddbbbd36e8478913e948ec49365618be5c2af57d199864"}, "config": {"enabled": true, "alias": "claim_claim_line_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_line_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.025577, "relation_name": "cms_synthetic.data_quality.claim_claim_line_end_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith tuva_last_run as(\n\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_END_DATE' AS field_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'invalid'\n when m.claim_line_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.claim_line_end_date > m.claim_line_end_date then 'invalid'\n when m.claim_line_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'future'\n when m.claim_line_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when m.claim_line_end_date > m.claim_end_date then 'line date greater than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_end_date as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_line_end_date.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_END_DATE' AS field_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'invalid'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_end_date > m.claim_line_end_date then 'invalid'\n when m.claim_line_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'future'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_end_date > m.claim_end_date then 'line date greater than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_end_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_coinsurance_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_coinsurance_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_coinsurance_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_coinsurance_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_coinsurance_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_coinsurance_amount"], "alias": "claim_coninsurance_amount", "checksum": {"name": "sha256", "checksum": "10e1e4db7961b6d7f64ff5aa1a57194fd7b5986d3c310e33e9f86116fcac7e33"}, "config": {"enabled": true, "alias": "claim_coninsurance_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_coninsurance_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0316339, "relation_name": "cms_synthetic.data_quality.claim_coninsurance_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(coinsurance_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_coinsurance_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_plan": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_plan.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_plan.sql", "unique_id": "model.the_tuva_project.data_quality__claim_plan", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_plan"], "alias": "claim_plan", "checksum": {"name": "sha256", "checksum": "1d4a9f6a1b105e05cd4b178d7a5b31bc9e1a5770f9533a2e5f23c6b361e8d9b2"}, "config": {"enabled": true, "alias": "claim_plan", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_plan", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.047443, "relation_name": "cms_synthetic.data_quality.claim_plan", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PLAN' AS field_name\n ,case when m.{{ quote_column('plan') }} is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast({{ quote_column('plan') }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_plan.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(plan as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_copayment_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_copayment_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_copayment_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_copayment_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_copayment_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_copayment_amount"], "alias": "claim_copayment_amount", "checksum": {"name": "sha256", "checksum": "50e2a134a38c2b809e00d903ac74474626a90b5c946b982fb34b970734e3640b"}, "config": {"enabled": true, "alias": "claim_copayment_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_copayment_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0330508, "relation_name": "cms_synthetic.data_quality.claim_copayment_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(copayment_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_copayment_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_total_cost_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_total_cost_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_total_cost_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_total_cost_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_total_cost_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_total_cost_amount"], "alias": "claim_total_cost_amount", "checksum": {"name": "sha256", "checksum": "6af69ed034d87b1011ebb3d932e5d1e28c0d72cb8eb03ea9c17baef3742facdd"}, "config": {"enabled": true, "alias": "claim_total_cost_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_total_cost_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.048783, "relation_name": "cms_synthetic.data_quality.claim_total_cost_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'TOTAL_COST_AMOUNT' AS field_name\n , case when m.total_cost_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(total_cost_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_total_cost_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'TOTAL_COST_AMOUNT' AS field_name\n , case when m.total_cost_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(total_cost_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_diagnosis_code_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_diagnosis_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_diagnosis_code_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_diagnosis_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_diagnosis_code_type"], "alias": "claim_diagnosis_code_type", "checksum": {"name": "sha256", "checksum": "368ad2d9f730545e49cba3f821a70c123a2d9546a2cc68abd36e66106a70045f"}, "config": {"enabled": true, "alias": "claim_diagnosis_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_diagnosis_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.037292, "relation_name": "cms_synthetic.data_quality.claim_diagnosis_code_type", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DIAGNOSIS_CODE_TYPE' AS field_name\n ,case when m.diagnosis_code_type is null then 'null'\n when term.code_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.diagnosis_code_type is not null and term.code_type is null then 'Diagnosis Code Type does not join to Terminology Code Type table'\n else null\n end as invalid_reason\n ,cast(m.diagnosis_code_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m\nleft join {{ ref('reference_data__code_type')}} term on m.diagnosis_code_type = term.code_type", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_diagnosis_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DIAGNOSIS_CODE_TYPE' AS field_name\n ,case when m.diagnosis_code_type is null then 'null'\n when term.code_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.diagnosis_code_type is not null and term.code_type is null then 'Diagnosis Code Type does not join to Terminology Code Type table'\n else null\n end as invalid_reason\n ,cast(m.diagnosis_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join cms_synthetic.reference_data.code_type term on m.diagnosis_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_deductible_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_deductible_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_deductible_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_deductible_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_deductible_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_deductible_amount"], "alias": "claim_deductible_amount", "checksum": {"name": "sha256", "checksum": "1e5109fb7080a04f3c12e94dc6d367cd855ba8ead98c3c117265deb3e9f3a572"}, "config": {"enabled": true, "alias": "claim_deductible_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_deductible_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.035744, "relation_name": "cms_synthetic.data_quality.claim_deductible_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(deductible_amount as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_deductible_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_type": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_claim_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_type.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_type.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_type"], "alias": "claim_claim_type", "checksum": {"name": "sha256", "checksum": "60c8ffe41429419281694629f8646b2029ab928209eef78f264191d4c4f7f33c"}, "config": {"enabled": true, "alias": "claim_claim_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0300858, "relation_name": "cms_synthetic.data_quality.claim_claim_type", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_TYPE' AS field_name\n ,case when m.claim_type is null then 'null'\n when term.claim_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.claim_type is not null and term.claim_type is null then 'Claim Type does not join to Terminology Claim Type table'\n else null\n end as invalid_reason\n ,cast(m.claim_type as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m\nleft join {{ ref('terminology__claim_type')}} term on m.claim_type = term.claim_type", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__claim_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__claim_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_type.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_TYPE' AS field_name\n ,case when m.claim_type is null then 'null'\n when term.claim_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.claim_type is not null and term.claim_type is null then 'Claim Type does not join to Terminology Claim Type table'\n else null\n end as invalid_reason\n ,cast(m.claim_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join cms_synthetic.terminology.claim_type term on m.claim_type = term.claim_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_allowed_amount": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_allowed_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_allowed_amount.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_allowed_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_allowed_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_allowed_amount"], "alias": "claim_allowed_amount", "checksum": {"name": "sha256", "checksum": "5f2a330f37a211fa8fe7bb9bd9f129e5c232513ebc6f7d60afb6fbc1ff18399b"}, "config": {"enabled": true, "alias": "claim_allowed_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_allowed_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.02119, "relation_name": "cms_synthetic.data_quality.claim_allowed_amount", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(allowed_amount as {{ dbt.type_string() }}) as field_value\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_allowed_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_id"], "alias": "claim_claim_id", "checksum": {"name": "sha256", "checksum": "1bb9bda01382587dfd00a9e690aaccf9009990fc0484c7c1ab2d7e7eb821fbb4"}, "config": {"enabled": true, "alias": "claim_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.024204, "relation_name": "cms_synthetic.data_quality.claim_claim_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_ID' AS field_name\n ,case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_claim_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_ID' AS field_name\n ,case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_hcpcs_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_hcpcs_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_hcpcs_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_hcpcs_code.sql", "unique_id": "model.the_tuva_project.data_quality__claim_hcpcs_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_hcpcs_code"], "alias": "claim_hcpcs_code", "checksum": {"name": "sha256", "checksum": "21c313db661322c0ff6fa20d7680d8d921457e4f9a6c812bc443befc008746bd"}, "config": {"enabled": true, "alias": "claim_hcpcs_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_hcpcs_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0388658, "relation_name": "cms_synthetic.data_quality.claim_hcpcs_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'HCPCS_CODE' AS field_name\n , case\n when term.hcpcs is not null then 'valid'\n when m.hcpcs_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.hcpcs_code is not null and term.hcpcs is null then 'HCPCS does not join to Terminology HCPCS_LEVEL_2 table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.hcpcs_code\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ ref('medical_claim')}} m\nleft join {{ ref('terminology__hcpcs_level_2')}} as term on m.hcpcs_code = term.hcpcs", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/data_quality__claim_hcpcs_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'HCPCS_CODE' AS field_name\n , case\n when term.hcpcs is not null then 'valid'\n when m.hcpcs_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.hcpcs_code is not null and term.hcpcs is null then 'HCPCS does not join to Terminology HCPCS_LEVEL_2 table'\n else null\n end as invalid_reason\n , m.hcpcs_code || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join cms_synthetic.terminology.hcpcs_level_2 as term on m.hcpcs_code = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_claim_start_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_claim_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_claim_start_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_claim_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__professional_claim_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_claim_start_date"], "alias": "professional_claim_start_date", "checksum": {"name": "sha256", "checksum": "f434fa43a8ecb084be9d67bef7ba065216fb311e71930bdac707562358e6007b"}, "config": {"enabled": true, "alias": "professional_claim_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_claim_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0963788, "relation_name": "cms_synthetic.data_quality.professional_claim_start_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n, tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_claim_start_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_diagnosis_code_1": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_diagnosis_code_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_1.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_1.sql", "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_diagnosis_code_1"], "alias": "professional_diagnosis_code_1", "checksum": {"name": "sha256", "checksum": "d6402f0e69bc0b0f1b331f85914a11e01a3af00f449164ba56e599abb6c25a2b"}, "config": {"enabled": true, "alias": "professional_diagnosis_code_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_diagnosis_code_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0978591, "relation_name": "cms_synthetic.data_quality.professional_diagnosis_code_1", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.diagnosis_code_1\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_1 = term.icd_10_cm", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_1.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_diagnosis_code_3": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_diagnosis_code_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_3.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_3.sql", "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_diagnosis_code_3"], "alias": "professional_diagnosis_code_3", "checksum": {"name": "sha256", "checksum": "d8299eed9bd409341289eb1f04d7a8196a67ac8a8af72064c396959b28aea4d1"}, "config": {"enabled": true, "alias": "professional_diagnosis_code_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_diagnosis_code_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.100707, "relation_name": "cms_synthetic.data_quality.professional_diagnosis_code_3", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.diagnosis_code_3\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_3 = term.icd_10_cm", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_3.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_diagnosis_code_2": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_diagnosis_code_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_2.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_2.sql", "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_diagnosis_code_2"], "alias": "professional_diagnosis_code_2", "checksum": {"name": "sha256", "checksum": "5d758f81f81c55b8ab5f9e45e8ef093b0808ec508679cf7a977dea0f0a7452e5"}, "config": {"enabled": true, "alias": "professional_diagnosis_code_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_diagnosis_code_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.099215, "relation_name": "cms_synthetic.data_quality.professional_diagnosis_code_2", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.diagnosis_code_2\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_2 = term.icd_10_cm", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_diagnosis_code_2.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_billing_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_billing_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_billing_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_billing_npi.sql", "unique_id": "model.the_tuva_project.data_quality__professional_billing_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_billing_npi"], "alias": "professional_billing_npi", "checksum": {"name": "sha256", "checksum": "7ed9e703ae31b4b224c7806bfe7c7b99027ba6698e7644f6ad1a6f322fe70aba"}, "config": {"enabled": true, "alias": "professional_billing_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_billing_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.088632, "relation_name": "cms_synthetic.data_quality.professional_billing_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'BILLING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.billing_npi is not null\n and term.npi is null\n then 'Billing NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.billing_npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__provider')}} as term on m.billing_npi = term.npi", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_billing_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'BILLING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.billing_npi is not null\n and term.npi is null\n then 'Billing NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.billing_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.provider as term on m.billing_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_place_of_service_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_place_of_service_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_place_of_service_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_place_of_service_code.sql", "unique_id": "model.the_tuva_project.data_quality__professional_place_of_service_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_place_of_service_code"], "alias": "professional_place_of_service_code", "checksum": {"name": "sha256", "checksum": "c4128aac9200b3a45ed9543d67c811cae8124ba95b0f313cccbdabe67a635f81"}, "config": {"enabled": true, "alias": "professional_place_of_service_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_place_of_service_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.093083, "relation_name": "cms_synthetic.data_quality.professional_place_of_service_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'PLACE_OF_SERVICE_CODE' AS field_name\n , case when term.place_of_service_code is not null then 'valid'\n when m.place_of_service_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.place_of_service_code is not null\n and term.place_of_service_code is null\n then 'Place of Service Code does not join to Terminology Place of Service table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.place_of_service_code\", \"'|'\", \"coalesce(term.place_of_service_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__place_of_service')}} as term on m.place_of_service_code = term.place_of_service_code", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__place_of_service"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_place_of_service_code.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'PLACE_OF_SERVICE_CODE' AS field_name\n , case when term.place_of_service_code is not null then 'valid'\n when m.place_of_service_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.place_of_service_code is not null\n and term.place_of_service_code is null\n then 'Place of Service Code does not join to Terminology Place of Service table'\n else null\n end as invalid_reason\n , m.place_of_service_code || '|' || coalesce(term.place_of_service_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.place_of_service as term on m.place_of_service_code = term.place_of_service_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_rendering_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_rendering_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_rendering_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_rendering_npi.sql", "unique_id": "model.the_tuva_project.data_quality__professional_rendering_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_rendering_npi"], "alias": "professional_rendering_npi", "checksum": {"name": "sha256", "checksum": "97b0dbafa4eabf3db0f57daa80e6b05926001cf5b541efa4577cc4afedc3c894"}, "config": {"enabled": true, "alias": "professional_rendering_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_rendering_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0899851, "relation_name": "cms_synthetic.data_quality.professional_rendering_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'RENDERING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.rendering_npi is not null\n and term.npi is null\n then 'Rendering Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.rendering_npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__provider')}} as term on m.rendering_npi = term.npi", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_rendering_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'RENDERING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.rendering_npi is not null\n and term.npi is null\n then 'Rendering Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.rendering_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.provider as term on m.rendering_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_facility_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_facility_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_facility_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_facility_npi.sql", "unique_id": "model.the_tuva_project.data_quality__professional_facility_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_facility_npi"], "alias": "professional_facility_npi", "checksum": {"name": "sha256", "checksum": "1b14ecf3bf22f1e85802791eb5572275c9d0aee3ea5cfc44188635562d264627"}, "config": {"enabled": true, "alias": "professional_facility_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_facility_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0914402, "relation_name": "cms_synthetic.data_quality.professional_facility_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'professional' AS claim_type\n , 'FACILITY_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.facility_npi is not null\n and term.npi is null\n then 'Facility NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.facility_npi as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join {{ ref('terminology__provider')}} as term on m.facility_npi = term.npi", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_facility_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'FACILITY_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.facility_npi is not null\n and term.npi is null\n then 'Facility NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.facility_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.provider as term on m.facility_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_claim_end_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__professional_claim_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_claim_end_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_claim_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__professional_claim_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_claim_end_date"], "alias": "professional_claim_end_date", "checksum": {"name": "sha256", "checksum": "c48cf03f2195d1103dc26e6c14365d44af07cd7d935c079a6383176495843b75"}, "config": {"enabled": true, "alias": "professional_claim_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_claim_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0949178, "relation_name": "cms_synthetic.data_quality.professional_claim_end_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n ,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before start date'\n when m.claim_end_date is null then null\n else 'valid'\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/professional/data_quality__professional_claim_end_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n ,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before start date'\n when m.claim_end_date is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_present_on_admission_2": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_present_on_admission_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_2.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_present_on_admission_2"], "alias": "institutional_present_on_admission_2", "checksum": {"name": "sha256", "checksum": "8db6a531872966ed20fc0d90315b6110c37fcaafc073b0592a90df3b883ec12e"}, "config": {"enabled": true, "alias": "institutional_present_on_admission_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_present_on_admission_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.07262, "relation_name": "cms_synthetic.data_quality.institutional_present_on_admission_2", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_2 as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_2' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_2 in ('y','n') then 'valid'\n when m.diagnosis_poa_2 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_2.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_2' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_2 in ('y','n') then 'valid'\n when m.diagnosis_poa_2 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_discharge_disposition_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_discharge_disposition_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_discharge_disposition_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_discharge_disposition_code"], "alias": "institutional_discharge_disposition_code", "checksum": {"name": "sha256", "checksum": "397488b23d065584f9a11a34181c273d307ad445ed094b0921ffa444f75afb05"}, "config": {"enabled": true, "alias": "institutional_discharge_disposition_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_discharge_disposition_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0681531, "relation_name": "cms_synthetic.data_quality.institutional_discharge_disposition_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"base.discharge_disposition_code\", \"'|'\", \"coalesce(term.discharge_disposition_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__discharge_disposition')}} as term on base.discharge_disposition_code = term.discharge_disposition_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.discharge_disposition_code is not null\n and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology Discharge_Disposition Table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__discharge_disposition')}} as term on m.discharge_disposition_code = term.discharge_disposition_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_discharge_disposition_code.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.discharge_disposition_code || '|' || coalesce(term.discharge_disposition_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.discharge_disposition as term on base.discharge_disposition_code = term.discharge_disposition_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.discharge_disposition_code is not null\n and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology Discharge_Disposition Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.discharge_disposition as term on m.discharge_disposition_code = term.discharge_disposition_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_admission_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_admission_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admission_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admission_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_admission_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_admission_date"], "alias": "institutional_admission_date", "checksum": {"name": "sha256", "checksum": "1ece76bdb096fee4204b1970473a8d495e6f441174e2f474ba19347e1cfc23d7"}, "config": {"enabled": true, "alias": "institutional_admission_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_admission_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.051421, "relation_name": "cms_synthetic.data_quality.institutional_admission_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n)\n, tuva_last_run as(\n\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(admission_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'ADMISSION_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.admission_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.admission_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.admission_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n else null\n end as invalid_reason\n ,cast(substring(agg.field_aggregated, 1, 255) as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admission_date.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(admission_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'ADMISSION_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.admission_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(substring(agg.field_aggregated, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_present_on_admission_3": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_present_on_admission_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_3.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_present_on_admission_3"], "alias": "institutional_present_on_admission_3", "checksum": {"name": "sha256", "checksum": "1e9a9dd684c0941968ca1326a55dbb1e05186836998a6763d202188d0c152f3e"}, "config": {"enabled": true, "alias": "institutional_present_on_admission_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_present_on_admission_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.073885, "relation_name": "cms_synthetic.data_quality.institutional_present_on_admission_3", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_3 as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_3' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_3 in ('y','n') then 'valid'\n when m.diagnosis_poa_3 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_3.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_3' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_3 in ('y','n') then 'valid'\n when m.diagnosis_poa_3 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_present_on_admission_1": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_present_on_admission_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_1.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_present_on_admission_1"], "alias": "institutional_present_on_admission_1", "checksum": {"name": "sha256", "checksum": "512594f1f978760ae6e9160d620756a37407830b4b8c9adcc9c527031a3f1d8a"}, "config": {"enabled": true, "alias": "institutional_present_on_admission_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_present_on_admission_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.071033, "relation_name": "cms_synthetic.data_quality.institutional_present_on_admission_1", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_1 as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_1' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_1 in ('y','n') then 'valid'\n when m.diagnosis_poa_1 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_present_on_admission_1.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_1' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_1 in ('y','n') then 'valid'\n when m.diagnosis_poa_1 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_ms_drg_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_ms_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_ms_drg_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_ms_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_ms_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_ms_drg_code"], "alias": "institutional_ms_drg_code", "checksum": {"name": "sha256", "checksum": "9a85d75361944e9499715e28a895f4174275b542d1c46dcc9f0d6e91d2f287e5"}, "config": {"enabled": true, "alias": "institutional_ms_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_ms_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.050096, "relation_name": "cms_synthetic.data_quality.institutional_ms_drg_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"base.ms_drg_code\", \"'|'\", \"coalesce(term.ms_drg_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__ms_drg')}} as term on base.ms_drg_code = term.ms_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'MS_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.ms_drg_code is not null\n and term.ms_drg_code is null\n then 'MS DRG does not join to Terminology MS DRG table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__ms_drg')}} as term on m.ms_drg_code = term.ms_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_ms_drg_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.ms_drg_code || '|' || coalesce(term.ms_drg_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.ms_drg as term on base.ms_drg_code = term.ms_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'MS_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.ms_drg_code is not null\n and term.ms_drg_code is null\n then 'MS DRG does not join to Terminology MS DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.ms_drg as term on m.ms_drg_code = term.ms_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_billing_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_billing_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_billing_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_billing_npi.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_billing_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_billing_npi"], "alias": "institutional_billing_npi", "checksum": {"name": "sha256", "checksum": "c3ff56d4f4e4b83ad3431adb9db4174beb59c717b455d67cc8a675c2ccac7b81"}, "config": {"enabled": true, "alias": "institutional_billing_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_billing_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0583198, "relation_name": "cms_synthetic.data_quality.institutional_billing_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(billing_npi as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'BILLING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.billing_npi is not null\n and term.npi is null\n then 'NPI is not in Terminology Provider table'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__provider')}} as term on m.billing_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_billing_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(billing_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'BILLING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.billing_npi is not null\n and term.npi is null\n then 'NPI is not in Terminology Provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.provider as term on m.billing_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_claim_start_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_claim_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_claim_start_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_claim_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_claim_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_claim_start_date"], "alias": "institutional_claim_start_date", "checksum": {"name": "sha256", "checksum": "918405dddaddb8e686c4300e1e2b3bbb0272744b60b576866321f944d8149b6d"}, "config": {"enabled": true, "alias": "institutional_claim_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_claim_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0609732, "relation_name": "cms_synthetic.data_quality.institutional_claim_start_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_claim_start_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_diagnosis_code_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_1.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_diagnosis_code_1"], "alias": "institutional_diagnosis_code_1", "checksum": {"name": "sha256", "checksum": "9e0548d6b7acd65d9d04008ecc2614329a45f065f8687a6a4ba24da886384c94"}, "config": {"enabled": true, "alias": "institutional_diagnosis_code_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_diagnosis_code_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.062478, "relation_name": "cms_synthetic.data_quality.institutional_diagnosis_code_1", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"diagnosis_code_1\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__icd_10_cm')}} as term on base.diagnosis_code_1 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_1 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_1.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_cm as term on base.diagnosis_code_1 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_date_1": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_procedure_date_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_1.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_date_1"], "alias": "institutional_procedure_date_1", "checksum": {"name": "sha256", "checksum": "6817d827c52ba7e78d7df1b10a29e6c44431f4b2f51c8851882fa13ffba291ec"}, "config": {"enabled": true, "alias": "institutional_procedure_date_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_date_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.079927, "relation_name": "cms_synthetic.data_quality.institutional_procedure_date_1", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n)\n, tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(procedure_date_1 as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_1' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.procedure_date_1 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_1 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.procedure_date_1 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_1.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(procedure_date_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_1' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_1 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_date_3": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_procedure_date_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_3.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_date_3"], "alias": "institutional_procedure_date_3", "checksum": {"name": "sha256", "checksum": "c374138175737e185dd7084dde795e7d4b373f7194ecf928dda5533bf0351b98"}, "config": {"enabled": true, "alias": "institutional_procedure_date_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_date_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.082839, "relation_name": "cms_synthetic.data_quality.institutional_procedure_date_3", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n)\n, tuva_last_run as(\n\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n\n)\n\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_3 as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_3' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.procedure_date_3 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_3 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.procedure_date_3 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_3.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_3' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_3 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_diagnosis_code_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_2.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_diagnosis_code_2"], "alias": "institutional_diagnosis_code_2", "checksum": {"name": "sha256", "checksum": "64fab6320bb999976bfe380bad7f4a593e0fdd124e6a88a41fb76e46a35e0e90"}, "config": {"enabled": true, "alias": "institutional_diagnosis_code_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_diagnosis_code_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.064089, "relation_name": "cms_synthetic.data_quality.institutional_diagnosis_code_2", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"diagnosis_code_2\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__icd_10_cm')}} as term on base.diagnosis_code_2 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_2 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_2.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_cm as term on base.diagnosis_code_2 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_diagnosis_code_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_3.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_diagnosis_code_3"], "alias": "institutional_diagnosis_code_3", "checksum": {"name": "sha256", "checksum": "3fdfda812d30e75e207d2918c1dfddefc27879bb0d871d8a174ac3187533a2ac"}, "config": {"enabled": true, "alias": "institutional_diagnosis_code_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_diagnosis_code_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.065357, "relation_name": "cms_synthetic.data_quality.institutional_diagnosis_code_3", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"diagnosis_code_3\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__icd_10_cm')}} as term on base.diagnosis_code_3 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_3 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_diagnosis_code_3.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_cm as term on base.diagnosis_code_3 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_date_2": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_procedure_date_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_2.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_date_2"], "alias": "institutional_procedure_date_2", "checksum": {"name": "sha256", "checksum": "6b21d072c0a2c251f92ced3067220cef55898c18025aad9e8ecddb0cd9cb8a66"}, "config": {"enabled": true, "alias": "institutional_procedure_date_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_date_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0813131, "relation_name": "cms_synthetic.data_quality.institutional_procedure_date_2", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n)\n, tuva_last_run as(\n\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_2 as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_2' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.procedure_date_2 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_2 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.procedure_date_2 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n when m.procedure_date_2 is null then null\n else 'valid'\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_date_2.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_2' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_2 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n when m.procedure_date_2 is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_admit_type_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_admit_type_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admit_type_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admit_type_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_admit_type_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_admit_type_code"], "alias": "institutional_admit_type_code", "checksum": {"name": "sha256", "checksum": "3e88d3bf8bf463602aaf20b552049d542e3a36793ac46ee52cf50b1d719ac32b"}, "config": {"enabled": true, "alias": "institutional_admit_type_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_admit_type_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0543811, "relation_name": "cms_synthetic.data_quality.institutional_admit_type_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"base.admit_type_code\", \"'|'\", \"coalesce(term.admit_type_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__admit_type')}} as term on base.admit_type_code = term.admit_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Member ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_type_code is not null\n and term.admit_type_code is null\n and cg.frequency = 1\n then 'Admit Type Code does not join to Terminology Admit Type table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__admit_type')}} as term on m.admit_type_code = term.admit_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admit_type_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_type_code || '|' || coalesce(term.admit_type_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.admit_type as term on base.admit_type_code = term.admit_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Member ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_type_code is not null\n and term.admit_type_code is null\n and cg.frequency = 1\n then 'Admit Type Code does not join to Terminology Admit Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.admit_type as term on m.admit_type_code = term.admit_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_claim_end_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_claim_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_claim_end_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_claim_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_claim_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_claim_end_date"], "alias": "institutional_claim_end_date", "checksum": {"name": "sha256", "checksum": "5515315c8448edde1b50083832f802ef2300111df882f599905962bfd80032de"}, "config": {"enabled": true, "alias": "institutional_claim_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_claim_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.059546, "relation_name": "cms_synthetic.data_quality.institutional_claim_end_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before claim start date'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_claim_end_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before claim start date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_apr_drg_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_apr_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_apr_drg_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_apr_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_apr_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_apr_drg_code"], "alias": "institutional_apr_drg_code", "checksum": {"name": "sha256", "checksum": "4a833196387f851f60d5740a8db5accc8543b8facd2ec69dc429bbf01e32c2c7"}, "config": {"enabled": true, "alias": "institutional_apr_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_apr_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.055716, "relation_name": "cms_synthetic.data_quality.institutional_apr_drg_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"base.apr_drg_code\", \"'|'\", \"coalesce(term.apr_drg_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__apr_drg')}} as term on base.apr_drg_code = term.apr_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'APR_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.apr_drg_code is not null\n and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology APR DRG table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__apr_drg')}} as term on m.apr_drg_code = term.apr_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_apr_drg_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.apr_drg_code || '|' || coalesce(term.apr_drg_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.apr_drg as term on base.apr_drg_code = term.apr_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'APR_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.apr_drg_code is not null\n and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology APR DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.apr_drg as term on m.apr_drg_code = term.apr_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_facility_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_facility_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_facility_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_facility_npi.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_facility_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_facility_npi"], "alias": "institutional_facility_npi", "checksum": {"name": "sha256", "checksum": "608b3804b14340b4c2aa2e3e77009f1fe1ccf663d4e7a467c9b9733ec56c7169"}, "config": {"enabled": true, "alias": "institutional_facility_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_facility_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.069639, "relation_name": "cms_synthetic.data_quality.institutional_facility_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'FACILITY_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.facility_npi is not null\n and term.npi is null\n then 'NPI not in Terminology Provider Table'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__provider')}} as term on m.facility_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_facility_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'FACILITY_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.facility_npi is not null\n and term.npi is null\n then 'NPI not in Terminology Provider Table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.provider as term on m.facility_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_discharge_date": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_discharge_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_discharge_date.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_discharge_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_discharge_date"], "alias": "institutional_discharge_date", "checksum": {"name": "sha256", "checksum": "9c0bdd98eb90cf34cdf2043ea87d38971d5c98817a772f545983724e7f463bed"}, "config": {"enabled": true, "alias": "institutional_discharge_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_discharge_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.066783, "relation_name": "cms_synthetic.data_quality.institutional_discharge_date", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n)\n, tuva_last_run as(\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(discharge_date as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DISCHARGE_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\n when m.discharge_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\n when m.discharge_date < m.admission_date then 'invalid'\n when m.discharge_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\n when m.discharge_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\n when m.discharge_date < m.admission_date then 'discharge date before admission date'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_discharge_date.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(discharge_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DISCHARGE_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.discharge_date < m.admission_date then 'invalid'\n when m.discharge_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.discharge_date < m.admission_date then 'discharge date before admission date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_bill_type_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_bill_type_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_bill_type_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_bill_type_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_bill_type_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_bill_type_code"], "alias": "institutional_bill_type_code", "checksum": {"name": "sha256", "checksum": "172ea3cc4e3078354d2dc2566b5c33ecc3ff8c3a532bd87f5a857b45f78974e6"}, "config": {"enabled": true, "alias": "institutional_bill_type_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_bill_type_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0570722, "relation_name": "cms_synthetic.data_quality.institutional_bill_type_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', false)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"base.bill_type_code\", \"'|'\", \"coalesce(term.bill_type_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__bill_type')}} as term on base.bill_type_code = term.bill_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'BILL_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.bill_type_code is not null then 'valid'\n when m.bill_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.bill_type_code is not null\n and term.bill_type_code is null\n and cg.frequency = 1\n then 'Bill Type Code does not join to Terminology Bill_Type table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__bill_type')}} as term on m.bill_type_code = term.bill_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_bill_type_code.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.bill_type_code || '|' || coalesce(term.bill_type_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.bill_type as term on base.bill_type_code = term.bill_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'BILL_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.bill_type_code is not null then 'valid'\n when m.bill_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.bill_type_code is not null\n and term.bill_type_code is null\n and cg.frequency = 1\n then 'Bill Type Code does not join to Terminology Bill_Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.bill_type as term on m.bill_type_code = term.bill_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_revenue_center_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_revenue_center_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_revenue_center_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_revenue_center_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_revenue_center_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_revenue_center_code"], "alias": "institutional_revenue_center_code", "checksum": {"name": "sha256", "checksum": "4a87b4a72144d6ddcba9a7aac5cc0a5e786568b9756a0f8a1511a05d96cfa3b2"}, "config": {"enabled": true, "alias": "institutional_revenue_center_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_revenue_center_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.085705, "relation_name": "cms_synthetic.data_quality.institutional_revenue_center_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , 'institutional' AS claim_type\n , 'REVENUE_CENTER_CODE' AS field_name\n , case\n when term.revenue_center_code is not null then 'valid'\n when m.revenue_center_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.revenue_center_code is not null\n and term.revenue_center_code is null\n then 'Revenue center code does not join to Terminology Revenue Center table'\n else null\n end as invalid_reason\n , {{ dbt.concat([\"m.revenue_center_code\", \"'|'\", \"coalesce(term.revenue_center_description, '')\"]) }} as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ ref('medical_claim')}} m\nleft join {{ ref('terminology__revenue_center')}} as term on m.revenue_center_code = term.revenue_center_code", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__revenue_center"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_revenue_center_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'institutional' AS claim_type\n , 'REVENUE_CENTER_CODE' AS field_name\n , case\n when term.revenue_center_code is not null then 'valid'\n when m.revenue_center_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.revenue_center_code is not null\n and term.revenue_center_code is null\n then 'Revenue center code does not join to Terminology Revenue Center table'\n else null\n end as invalid_reason\n , m.revenue_center_code || '|' || coalesce(term.revenue_center_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join cms_synthetic.terminology.revenue_center as term on m.revenue_center_code = term.revenue_center_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_service_unit_quantity": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_service_unit_quantity", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_service_unit_quantity.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_service_unit_quantity.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_service_unit_quantity"], "alias": "institutional_service_unit_quantity", "checksum": {"name": "sha256", "checksum": "2dd69c80b70d043111984f3403fc1be97efce584f135158a51029820ba868117"}, "config": {"enabled": true, "alias": "institutional_service_unit_quantity", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_service_unit_quantity", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.087148, "relation_name": "cms_synthetic.data_quality.institutional_service_unit_quantity", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\n \"'|'\",\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\n , m.claim_type as claim_type\n , 'service_unit_quantity' as field_name\n , case when m.service_unit_quantity is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\n , cast(service_unit_quantity as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_service_unit_quantity.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'service_unit_quantity' as field_name\n , case when m.service_unit_quantity is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(service_unit_quantity as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_admit_source_code": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_admit_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admit_source_code.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admit_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_admit_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_admit_source_code"], "alias": "institutional_admit_source_code", "checksum": {"name": "sha256", "checksum": "fdfeccafd54defdc66208f4cf51ef9a1c46046e07718c561143d31934c2df8c5"}, "config": {"enabled": true, "alias": "institutional_admit_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_admit_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.052809, "relation_name": "cms_synthetic.data_quality.institutional_admit_source_code", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"base.admit_source_code\", \"'|'\", \"coalesce(term.admit_source_description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__admit_source')}} as term on base.admit_source_code = term.admit_source_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_source_code is not null\n and term.admit_source_code is null\n and cg. frequency = 1\n then 'Admit source code does not join to Terminology Admit Source table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__admit_source')}} as term on m.admit_source_code = term.admit_source_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_source"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_admit_source_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_source_code || '|' || coalesce(term.admit_source_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.admit_source as term on base.admit_source_code = term.admit_source_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_source_code is not null\n and term.admit_source_code is null\n and cg. frequency = 1\n then 'Admit source code does not join to Terminology Admit Source table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.admit_source as term on m.admit_source_code = term.admit_source_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_code_1": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_procedure_code_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_1.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_code_1"], "alias": "institutional_procedure_code_1", "checksum": {"name": "sha256", "checksum": "7a18127333fc24f3c77be778ba72c4ed5ed1c939286e7cdac3d2a7084665ef8f"}, "config": {"enabled": true, "alias": "institutional_procedure_code_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_code_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0751748, "relation_name": "cms_synthetic.data_quality.institutional_procedure_code_1", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"procedure_code_1\", \"'|'\", \"coalesce(term.description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__icd_10_pcs')}} as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_1 is not null\n and term.icd_10_pcs is null\n then 'procedure code does not join to terminology procedure code table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__icd_10_pcs')}} as term on m.procedure_code_1 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_1.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_1 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_1 is not null\n and term.icd_10_pcs is null\n then 'procedure code does not join to terminology procedure code table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_pcs as term on m.procedure_code_1 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_rendering_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_rendering_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_rendering_npi.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_rendering_npi.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_rendering_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_rendering_npi"], "alias": "institutional_rendering_npi", "checksum": {"name": "sha256", "checksum": "e9b8d2fd97eb019fdcfd07a897a67b5651bf4b8a5f86a97b757c1d470c6a58d9"}, "config": {"enabled": true, "alias": "institutional_rendering_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_rendering_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.084224, "relation_name": "cms_synthetic.data_quality.institutional_rendering_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\n select *\n from {{ ref('medical_claim')}}\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as {{ dbt.type_string() }}) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'RENDERING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.rendering_npi is not null\n and term.npi is null\n then 'provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__provider')}} as term on m.rendering_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_rendering_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'RENDERING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.rendering_npi is not null\n and term.npi is null\n then 'provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.provider as term on m.rendering_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_code_2": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_procedure_code_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_2.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_code_2"], "alias": "institutional_procedure_code_2", "checksum": {"name": "sha256", "checksum": "28d6f6197b10604fb21afefd1ef4fa97f60f914750bd074148ff051b8d8b7a4e"}, "config": {"enabled": true, "alias": "institutional_procedure_code_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_code_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0768661, "relation_name": "cms_synthetic.data_quality.institutional_procedure_code_2", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"procedure_code_2\", \"'|'\", \"coalesce(term.description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__icd_10_pcs')}} as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_2 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__icd_10_pcs')}} as term on m.procedure_code_2 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_2.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_2 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_2 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_pcs as term on m.procedure_code_2 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_code_3": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__institutional_procedure_code_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_3.sql", "original_file_path": "models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_code_3"], "alias": "institutional_procedure_code_3", "checksum": {"name": "sha256", "checksum": "aa1cac8d32b1399e914032e7d5ed2b99200cb015f9f77677fe2843fa3a7a9afc"}, "config": {"enabled": true, "alias": "institutional_procedure_code_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_code_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.0784378, "relation_name": "cms_synthetic.data_quality.institutional_procedure_code_3", "raw_code": "{{ config(\n enabled = var('claims_enabled', False)\n) }}\n\nwith base as (\nselect *\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\n),\n\nunique_field as (\n select distinct claim_id\n , {{ dbt.concat([\"procedure_code_3\", \"'|'\", \"coalesce(term.description, '')\"]) }} as field\n , data_source\n from base\n left join {{ ref('terminology__icd_10_pcs')}} as term on base.procedure_code_3 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_3 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join {{ ref('terminology__icd_10_pcs')}} as term on m.procedure_code_3 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/atomic_checks/claims/medical/institutional/data_quality__institutional_procedure_code_3.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_3 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_pcs as term on base.procedure_code_3 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_3 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_pcs as term on m.procedure_code_3 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__unique_value_examples": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__unique_value_examples", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/data_quality__unique_value_examples.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/data_quality__unique_value_examples.sql", "unique_id": "model.the_tuva_project.data_quality__unique_value_examples", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "data_quality__unique_value_examples"], "alias": "unique_value_examples", "checksum": {"name": "sha256", "checksum": "f163775c2ff9158385f719342d942d143421dae99e2d3ecd561adddb616536f3"}, "config": {"enabled": true, "alias": "unique_value_examples", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "unique_value_examples", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.375057, "relation_name": "cms_synthetic.data_quality.unique_value_examples", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nSELECT * FROM {{ ref('data_quality__primary_keys_condition_condition_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_encounter_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_lab_result_lab_result_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_location_location_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_medication_medication_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_observation_observation_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_patient_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_practitioner_practitioner_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__primary_keys_procedure_procedure_id') }}", "language": "sql", "refs": [{"name": "data_quality__primary_keys_condition_condition_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_location_location_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_medication_medication_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_observation_observation_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_patient_patient_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_procedure_procedure_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "model.the_tuva_project.data_quality__primary_keys_location_location_id", "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/data_quality__unique_value_examples.sql", "compiled": true, "compiled_code": "\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_condition_condition_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_encounter_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_location_location_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_medication_medication_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_observation_observation_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_patient_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_procedure_procedure_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_patient_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_patient_patient_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_patient_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_patient_patient_id"], "alias": "primary_keys_patient_patient_id", "checksum": {"name": "sha256", "checksum": "b9124e2718e41cf961f8d49669732a3f084be6661f8b8161a085d51f7d854d63"}, "config": {"enabled": true, "alias": "primary_keys_patient_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_patient_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3882618, "relation_name": "cms_synthetic.data_quality.primary_keys_patient_patient_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__patient_patient_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__patient_patient_id') }}\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__patient_patient_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__patient_patient_id", "package": null, "version": null}, {"name": "data_quality__patient_patient_id", "package": null, "version": null}, {"name": "data_quality__patient_patient_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__patient_patient_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_patient_patient_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.patient_patient_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_practitioner_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_practitioner_practitioner_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_practitioner_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_practitioner_practitioner_id"], "alias": "primary_keys_practitioner_practitioner_id", "checksum": {"name": "sha256", "checksum": "cbba9a89a4528e121db36f25aaeda71326cb3899657d7dc172a87b2829052e1d"}, "config": {"enabled": true, "alias": "primary_keys_practitioner_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_practitioner_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.389772, "relation_name": "cms_synthetic.data_quality.primary_keys_practitioner_practitioner_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__practitioner_practitioner_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__practitioner_practitioner_id') }}\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__practitioner_practitioner_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__practitioner_practitioner_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_practitioner_practitioner_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.practitioner_practitioner_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_location_location_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_location_location_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_location_location_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_location_location_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_location_location_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_location_location_id"], "alias": "primary_keys_location_location_id", "checksum": {"name": "sha256", "checksum": "5f5d98f8d8dd91df53ab92f0693ef5c29b1ed388f1ca1ac6c8f682f236506408"}, "config": {"enabled": true, "alias": "primary_keys_location_location_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_location_location_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.381236, "relation_name": "cms_synthetic.data_quality.primary_keys_location_location_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__location_location_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__location_location_id') }}\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__location_location_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__location_location_id", "package": null, "version": null}, {"name": "data_quality__location_location_id", "package": null, "version": null}, {"name": "data_quality__location_location_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__location_location_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_location_location_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.location_location_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_encounter_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_encounter_encounter_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_encounter_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_encounter_encounter_id"], "alias": "primary_keys_encounter_encounter_id", "checksum": {"name": "sha256", "checksum": "2efcf159cb8c6c12aa3cea0d7b72ec426156797359afd7e49f2eb12c52886b1e"}, "config": {"enabled": true, "alias": "primary_keys_encounter_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_encounter_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3782709, "relation_name": "cms_synthetic.data_quality.primary_keys_encounter_encounter_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__encounter_encounter_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__encounter_encounter_id') }}\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__encounter_encounter_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__encounter_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_encounter_encounter_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.encounter_encounter_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_medication_medication_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_medication_medication_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_medication_medication_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_medication_medication_id"], "alias": "primary_keys_medication_medication_id", "checksum": {"name": "sha256", "checksum": "fed17b87811ce6d77cce993827b4c1915250fad4eebfe4a6d7c2ca63daeb49d8"}, "config": {"enabled": true, "alias": "primary_keys_medication_medication_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_medication_medication_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.382686, "relation_name": "cms_synthetic.data_quality.primary_keys_medication_medication_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__medication_medication_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__medication_medication_id') }}\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__medication_medication_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__medication_medication_id", "package": null, "version": null}, {"name": "data_quality__medication_medication_id", "package": null, "version": null}, {"name": "data_quality__medication_medication_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__medication_medication_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_medication_medication_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.medication_medication_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_condition_condition_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_condition_condition_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_condition_condition_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_condition_condition_id"], "alias": "primary_keys_condition_condition_id", "checksum": {"name": "sha256", "checksum": "9cb6327bae6053d4dccc81988fbbb561d04bd08ddb096ffb3310af10704df419"}, "config": {"enabled": true, "alias": "primary_keys_condition_condition_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_condition_condition_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.376502, "relation_name": "cms_synthetic.data_quality.primary_keys_condition_condition_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__condition_condition_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__condition_condition_id') }}\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__condition_condition_id') }} a\n inner JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__condition_condition_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__condition_condition_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_condition_condition_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.condition_condition_id a\n inner JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_observation_observation_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_observation_observation_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_observation_observation_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_observation_observation_id"], "alias": "primary_keys_observation_observation_id", "checksum": {"name": "sha256", "checksum": "5959527d6e63b4409e37eb96041e53717147e2f82de4f080f271e4ec3387b23f"}, "config": {"enabled": true, "alias": "primary_keys_observation_observation_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_observation_observation_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.385934, "relation_name": "cms_synthetic.data_quality.primary_keys_observation_observation_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__observation_observation_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__observation_observation_id') }}\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__observation_observation_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__observation_observation_id", "package": null, "version": null}, {"name": "data_quality__observation_observation_id", "package": null, "version": null}, {"name": "data_quality__observation_observation_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__observation_observation_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_observation_observation_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.observation_observation_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_procedure_procedure_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_procedure_procedure_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_procedure_procedure_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_procedure_procedure_id"], "alias": "primary_keys_procedure_procedure_id", "checksum": {"name": "sha256", "checksum": "b3f89c9e2abfc7ef0076025581f2f83fb1a7202ff9259885b25af9de5f65fe86"}, "config": {"enabled": true, "alias": "primary_keys_procedure_procedure_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_procedure_procedure_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.391241, "relation_name": "cms_synthetic.data_quality.primary_keys_procedure_procedure_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__procedure_procedure_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__procedure_procedure_id') }}\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__procedure_procedure_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__procedure_procedure_id", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_id", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__procedure_procedure_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_procedure_procedure_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.procedure_procedure_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_keys_lab_result_lab_result_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_lab_result_lab_result_id.sql", "original_file_path": "models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_lab_result_lab_result_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_lab_result_lab_result_id"], "alias": "primary_keys_lab_result_lab_result_id", "checksum": {"name": "sha256", "checksum": "3b0c64b829bbd9211979059454ae0468938f7245c1654876b06891c861fb1ee0"}, "config": {"enabled": true, "alias": "primary_keys_lab_result_lab_result_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_lab_result_lab_result_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3795562, "relation_name": "cms_synthetic.data_quality.primary_keys_lab_result_lab_result_id", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n {{ ref('data_quality__lab_result_lab_result_id') }}\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__lab_result_lab_result_id') }}\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n {{ ref('data_quality__lab_result_lab_result_id') }} a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__lab_result_lab_result_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/concepts/primary_keys/data_quality__primary_keys_lab_result_lab_result_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.lab_result_lab_result_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_clinical_for_pbi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/union_processing/clinical/data_quality__data_quality_clinical_for_pbi.sql", "original_file_path": "models/data_quality/dqi/intermediate/union_processing/clinical/data_quality__data_quality_clinical_for_pbi.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "clinical", "data_quality__data_quality_clinical_for_pbi"], "alias": "data_quality_clinical_for_pbi", "checksum": {"name": "sha256", "checksum": "40f535073f46cc6cf5979aeb74df43214b2d380e5c87db7d6c232d3d635f66c1"}, "config": {"enabled": true, "alias": "data_quality_clinical_for_pbi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_clinical_for_pbi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.39896, "relation_name": "cms_synthetic.data_quality.data_quality_clinical_for_pbi", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH Ranked_Examples as (\n SELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n FROM {{ ref('data_quality__data_quality_clinical_detail') }}\n where bucket_name not in ('valid', 'null')\n group by\n data_source,\n field_name,\n table_name,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n\n),\n\npk_examples as (\n SELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.drill_down_value as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency,\n row_number() over (partition by detail.summary_sk order by detail.summary_sk) as rn\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ ref('data_quality__data_quality_clinical_detail') }} as detail\n left join {{ ref('data_quality__crosswalk_field_info')}} as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\n where detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 1\n GROUP BY\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.drill_down_key,\n detail.drill_down_value,\n detail.invalid_reason,\n detail.summary_sk\n\n)\n--- Null Values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value,\n null as field_value,\n count(drill_down_value) as frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('data_quality__data_quality_clinical_detail') }}\nwhere bucket_name = 'null'\ngroup by\n data_source,\n field_name,\n table_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\n\n--- Valid Values except PKs\n\nSELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n max(detail.drill_down_value) as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('data_quality__data_quality_clinical_detail') }} as detail\nleft join {{ ref('data_quality__crosswalk_field_info') }} as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\nWHERE\n detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 0 --- need to handle pks differently since every value is supposed to be unique\ngroup by\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.summary_sk\n\nunion all\n\n-- 5 Examples of each invalid example\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggregating all other invalid examples into single row\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'all others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value\n\nunion all\n\n--- 5 Examples of valid primary key values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM pk_examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggegating all other valid primary key value examples\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n 'All Others' as field_value,\n sum(frequency) as frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM pk_examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "language": "sql", "refs": [{"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_info", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_info", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/union_processing/clinical/data_quality__data_quality_clinical_for_pbi.sql", "compiled": true, "compiled_code": "\n\nWITH Ranked_Examples as (\n SELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n FROM cms_synthetic.data_quality.data_quality_clinical_detail\n where bucket_name not in ('valid', 'null')\n group by\n data_source,\n field_name,\n table_name,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n\n),\n\npk_examples as (\n SELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.drill_down_value as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency,\n row_number() over (partition by detail.summary_sk order by detail.summary_sk) as rn\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.data_quality.data_quality_clinical_detail as detail\n left join cms_synthetic.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\n where detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 1\n GROUP BY\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.drill_down_key,\n detail.drill_down_value,\n detail.invalid_reason,\n detail.summary_sk\n\n)\n--- Null Values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value,\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality.data_quality_clinical_detail\nwhere bucket_name = 'null'\ngroup by\n data_source,\n field_name,\n table_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\n\n--- Valid Values except PKs\n\nSELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n max(detail.drill_down_value) as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality.data_quality_clinical_detail as detail\nleft join cms_synthetic.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\nWHERE\n detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 0 --- need to handle pks differently since every value is supposed to be unique\ngroup by\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.summary_sk\n\nunion all\n\n-- 5 Examples of each invalid example\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggregating all other invalid examples into single row\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'all others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value\n\nunion all\n\n--- 5 Examples of valid primary key values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggegating all other valid primary key value examples\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n 'All Others' as field_value,\n sum(frequency) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_clinical_detail": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_clinical_detail", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/union_processing/clinical/data_quality__data_quality_clinical_detail.sql", "original_file_path": "models/data_quality/dqi/intermediate/union_processing/clinical/data_quality__data_quality_clinical_detail.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_detail", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "clinical", "data_quality__data_quality_clinical_detail"], "alias": "data_quality_clinical_detail", "checksum": {"name": "sha256", "checksum": "f2bc83b73062a793f16ba05c76dd907c9513db09d4dd6ce52aece776d5cc9697"}, "config": {"enabled": true, "alias": "data_quality_clinical_detail", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_clinical_detail", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.397516, "relation_name": "cms_synthetic.data_quality.data_quality_clinical_detail", "raw_code": "{{ config(\n enabled = var('clinical_enabled',False)\n )\n}}\n\nWITH CTE as (\nSELECT * FROM {{ ref('data_quality__condition_claim_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_condition_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_condition_rank') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_condition_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_normalized_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_normalized_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_normalized_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_onset_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_present_on_admit_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_present_on_admit_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_recorded_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_resolved_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_source_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_source_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_source_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__condition_status') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_admit_source_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_admit_source_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_admit_type_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_admit_type_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_allowed_amount') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_apr_drg_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_apr_drg_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_attending_provider_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_charge_amount') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_discharge_disposition_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_discharge_disposition_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_encounter_end_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_encounter_start_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_encounter_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_facility_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_length_of_stay') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_ms_drg_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_ms_drg_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_paid_amount') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_primary_diagnosis_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_primary_diagnosis_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__encounter_primary_diagnosis_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_practice_affiliation') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_sub_specialty') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_last_name') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_practitioner_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_npi') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_first_name') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__practitioner_specialty') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_parent_organization') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_latitude') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_facility_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_zip_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_city') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_npi') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_location_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_longitude') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_address') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_state') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__location_name') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_normalized_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_normalized_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_procedure_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_claim_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_source_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_source_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_source_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_practitioner_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_procedure_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_modifier_5') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_modifier_4') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_normalized_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_modifier_1') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_modifier_3') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__procedure_modifier_2') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_abnormal_flag') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_specimen') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_reference_range_low') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_units') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_lab_result_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_collection_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_component') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_ordering_practitioner_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_result') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_reference_range_low') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_reference_range_high') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_status') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_accession_number') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_result_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_abnormal_flag') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_units') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_reference_range_high') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_source_component') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__lab_result_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_sex') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_state') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_city') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_longitude') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_county') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_race') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_death_flag') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_address') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_zip_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_first_name') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_last_name') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_latitude') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_birth_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_death_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__patient_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_rxnorm_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_source_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_atc_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_dispensing_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_prescribing_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_days_supply') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_strength') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_patient_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_rxnorm_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_atc_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_quantity_unit') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_source_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_ndc_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_medication_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_source_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_ndc_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_quantity') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_practitioner_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__medication_route') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_source_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_normalized_reference_range_high') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_source_units') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_observation_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_normalized_code') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_normalized_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_data_source') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_panel_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_observation_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_source_reference_range_low') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_result') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_source_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_normalized_reference_range_low') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_observation_date') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_encounter_id') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_source_description') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_source_reference_range_high') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_normalized_units') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_normalized_code_type') }}\n\nunion all\n\nSELECT * FROM {{ ref('data_quality__observation_patient_id') }}\n\n)\n\nSELECT\n data_source,\n cast(source_date as {{ dbt.type_string() }}) as source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n bucket_name,\n invalid_reason,\n field_value,\n tuva_last_run,\n dense_rank() over (order by data_source, table_name, field_name) + 100000 as summary_sk\nFROM CTE", "language": "sql", "refs": [{"name": "data_quality__condition_claim_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_rank", "package": null, "version": null}, {"name": "data_quality__condition_condition_type", "package": null, "version": null}, {"name": "data_quality__condition_data_source", "package": null, "version": null}, {"name": "data_quality__condition_encounter_id", "package": null, "version": null}, {"name": "data_quality__condition_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__condition_normalized_code", "package": null, "version": null}, {"name": "data_quality__condition_normalized_description", "package": null, "version": null}, {"name": "data_quality__condition_onset_date", "package": null, "version": null}, {"name": "data_quality__condition_patient_id", "package": null, "version": null}, {"name": "data_quality__condition_present_on_admit_code", "package": null, "version": null}, {"name": "data_quality__condition_present_on_admit_description", "package": null, "version": null}, {"name": "data_quality__condition_recorded_date", "package": null, "version": null}, {"name": "data_quality__condition_resolved_date", "package": null, "version": null}, {"name": "data_quality__condition_source_code", "package": null, "version": null}, {"name": "data_quality__condition_source_code_type", "package": null, "version": null}, {"name": "data_quality__condition_source_description", "package": null, "version": null}, {"name": "data_quality__condition_status", "package": null, "version": null}, {"name": "data_quality__encounter_admit_source_code", "package": null, "version": null}, {"name": "data_quality__encounter_admit_source_description", "package": null, "version": null}, {"name": "data_quality__encounter_admit_type_code", "package": null, "version": null}, {"name": "data_quality__encounter_admit_type_description", "package": null, "version": null}, {"name": "data_quality__encounter_allowed_amount", "package": null, "version": null}, {"name": "data_quality__encounter_apr_drg_code", "package": null, "version": null}, {"name": "data_quality__encounter_apr_drg_description", "package": null, "version": null}, {"name": "data_quality__encounter_attending_provider_id", "package": null, "version": null}, {"name": "data_quality__encounter_charge_amount", "package": null, "version": null}, {"name": "data_quality__encounter_data_source", "package": null, "version": null}, {"name": "data_quality__encounter_discharge_disposition_code", "package": null, "version": null}, {"name": "data_quality__encounter_discharge_disposition_description", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_end_date", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_start_date", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_type", "package": null, "version": null}, {"name": "data_quality__encounter_facility_id", "package": null, "version": null}, {"name": "data_quality__encounter_length_of_stay", "package": null, "version": null}, {"name": "data_quality__encounter_ms_drg_code", "package": null, "version": null}, {"name": "data_quality__encounter_ms_drg_description", "package": null, "version": null}, {"name": "data_quality__encounter_paid_amount", "package": null, "version": null}, {"name": "data_quality__encounter_patient_id", "package": null, "version": null}, {"name": "data_quality__encounter_primary_diagnosis_code", "package": null, "version": null}, {"name": "data_quality__encounter_primary_diagnosis_code_type", "package": null, "version": null}, {"name": "data_quality__encounter_primary_diagnosis_description", "package": null, "version": null}, {"name": "data_quality__practitioner_practice_affiliation", "package": null, "version": null}, {"name": "data_quality__practitioner_sub_specialty", "package": null, "version": null}, {"name": "data_quality__practitioner_last_name", "package": null, "version": null}, {"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__practitioner_data_source", "package": null, "version": null}, {"name": "data_quality__practitioner_npi", "package": null, "version": null}, {"name": "data_quality__practitioner_first_name", "package": null, "version": null}, {"name": "data_quality__practitioner_specialty", "package": null, "version": null}, {"name": "data_quality__location_parent_organization", "package": null, "version": null}, {"name": "data_quality__location_latitude", "package": null, "version": null}, {"name": "data_quality__location_facility_type", "package": null, "version": null}, {"name": "data_quality__location_zip_code", "package": null, "version": null}, {"name": "data_quality__location_data_source", "package": null, "version": null}, {"name": "data_quality__location_city", "package": null, "version": null}, {"name": "data_quality__location_npi", "package": null, "version": null}, {"name": "data_quality__location_location_id", "package": null, "version": null}, {"name": "data_quality__location_longitude", "package": null, "version": null}, {"name": "data_quality__location_address", "package": null, "version": null}, {"name": "data_quality__location_state", "package": null, "version": null}, {"name": "data_quality__location_name", "package": null, "version": null}, {"name": "data_quality__procedure_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__procedure_normalized_description", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_id", "package": null, "version": null}, {"name": "data_quality__procedure_claim_id", "package": null, "version": null}, {"name": "data_quality__procedure_source_code", "package": null, "version": null}, {"name": "data_quality__procedure_source_code_type", "package": null, "version": null}, {"name": "data_quality__procedure_source_description", "package": null, "version": null}, {"name": "data_quality__procedure_practitioner_id", "package": null, "version": null}, {"name": "data_quality__procedure_data_source", "package": null, "version": null}, {"name": "data_quality__procedure_patient_id", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_date", "package": null, "version": null}, {"name": "data_quality__procedure_encounter_id", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_5", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_4", "package": null, "version": null}, {"name": "data_quality__procedure_normalized_code", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_1", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_3", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_2", "package": null, "version": null}, {"name": "data_quality__lab_result_source_abnormal_flag", "package": null, "version": null}, {"name": "data_quality__lab_result_specimen", "package": null, "version": null}, {"name": "data_quality__lab_result_source_reference_range_low", "package": null, "version": null}, {"name": "data_quality__lab_result_source_units", "package": null, "version": null}, {"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__lab_result_collection_date", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_component", "package": null, "version": null}, {"name": "data_quality__lab_result_ordering_practitioner_id", "package": null, "version": null}, {"name": "data_quality__lab_result_result", "package": null, "version": null}, {"name": "data_quality__lab_result_source_code_type", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_description", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_reference_range_low", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_reference_range_high", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_code", "package": null, "version": null}, {"name": "data_quality__lab_result_source_description", "package": null, "version": null}, {"name": "data_quality__lab_result_status", "package": null, "version": null}, {"name": "data_quality__lab_result_accession_number", "package": null, "version": null}, {"name": "data_quality__lab_result_result_date", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_abnormal_flag", "package": null, "version": null}, {"name": "data_quality__lab_result_data_source", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_units", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__lab_result_source_reference_range_high", "package": null, "version": null}, {"name": "data_quality__lab_result_source_code", "package": null, "version": null}, {"name": "data_quality__lab_result_patient_id", "package": null, "version": null}, {"name": "data_quality__lab_result_source_component", "package": null, "version": null}, {"name": "data_quality__lab_result_encounter_id", "package": null, "version": null}, {"name": "data_quality__patient_sex", "package": null, "version": null}, {"name": "data_quality__patient_state", "package": null, "version": null}, {"name": "data_quality__patient_city", "package": null, "version": null}, {"name": "data_quality__patient_longitude", "package": null, "version": null}, {"name": "data_quality__patient_county", "package": null, "version": null}, {"name": "data_quality__patient_race", "package": null, "version": null}, {"name": "data_quality__patient_death_flag", "package": null, "version": null}, {"name": "data_quality__patient_address", "package": null, "version": null}, {"name": "data_quality__patient_data_source", "package": null, "version": null}, {"name": "data_quality__patient_zip_code", "package": null, "version": null}, {"name": "data_quality__patient_first_name", "package": null, "version": null}, {"name": "data_quality__patient_last_name", "package": null, "version": null}, {"name": "data_quality__patient_latitude", "package": null, "version": null}, {"name": "data_quality__patient_birth_date", "package": null, "version": null}, {"name": "data_quality__patient_death_date", "package": null, "version": null}, {"name": "data_quality__patient_patient_id", "package": null, "version": null}, {"name": "data_quality__medication_rxnorm_code", "package": null, "version": null}, {"name": "data_quality__medication_source_code", "package": null, "version": null}, {"name": "data_quality__medication_atc_code", "package": null, "version": null}, {"name": "data_quality__medication_dispensing_date", "package": null, "version": null}, {"name": "data_quality__medication_prescribing_date", "package": null, "version": null}, {"name": "data_quality__medication_days_supply", "package": null, "version": null}, {"name": "data_quality__medication_strength", "package": null, "version": null}, {"name": "data_quality__medication_patient_id", "package": null, "version": null}, {"name": "data_quality__medication_rxnorm_description", "package": null, "version": null}, {"name": "data_quality__medication_encounter_id", "package": null, "version": null}, {"name": "data_quality__medication_data_source", "package": null, "version": null}, {"name": "data_quality__medication_atc_description", "package": null, "version": null}, {"name": "data_quality__medication_quantity_unit", "package": null, "version": null}, {"name": "data_quality__medication_source_description", "package": null, "version": null}, {"name": "data_quality__medication_ndc_code", "package": null, "version": null}, {"name": "data_quality__medication_medication_id", "package": null, "version": null}, {"name": "data_quality__medication_source_code_type", "package": null, "version": null}, {"name": "data_quality__medication_ndc_description", "package": null, "version": null}, {"name": "data_quality__medication_quantity", "package": null, "version": null}, {"name": "data_quality__medication_practitioner_id", "package": null, "version": null}, {"name": "data_quality__medication_route", "package": null, "version": null}, {"name": "data_quality__observation_source_code", "package": null, "version": null}, {"name": "data_quality__observation_normalized_reference_range_high", "package": null, "version": null}, {"name": "data_quality__observation_source_units", "package": null, "version": null}, {"name": "data_quality__observation_observation_type", "package": null, "version": null}, {"name": "data_quality__observation_normalized_code", "package": null, "version": null}, {"name": "data_quality__observation_normalized_description", "package": null, "version": null}, {"name": "data_quality__observation_data_source", "package": null, "version": null}, {"name": "data_quality__observation_panel_id", "package": null, "version": null}, {"name": "data_quality__observation_observation_id", "package": null, "version": null}, {"name": "data_quality__observation_source_reference_range_low", "package": null, "version": null}, {"name": "data_quality__observation_result", "package": null, "version": null}, {"name": "data_quality__observation_source_code_type", "package": null, "version": null}, {"name": "data_quality__observation_normalized_reference_range_low", "package": null, "version": null}, {"name": "data_quality__observation_observation_date", "package": null, "version": null}, {"name": "data_quality__observation_encounter_id", "package": null, "version": null}, {"name": "data_quality__observation_source_description", "package": null, "version": null}, {"name": "data_quality__observation_source_reference_range_high", "package": null, "version": null}, {"name": "data_quality__observation_normalized_units", "package": null, "version": null}, {"name": "data_quality__observation_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__observation_patient_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.data_quality__condition_claim_id", "model.the_tuva_project.data_quality__condition_condition_id", "model.the_tuva_project.data_quality__condition_condition_rank", "model.the_tuva_project.data_quality__condition_condition_type", "model.the_tuva_project.data_quality__condition_data_source", "model.the_tuva_project.data_quality__condition_encounter_id", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__condition_normalized_description", "model.the_tuva_project.data_quality__condition_onset_date", "model.the_tuva_project.data_quality__condition_patient_id", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.data_quality__condition_present_on_admit_description", "model.the_tuva_project.data_quality__condition_recorded_date", "model.the_tuva_project.data_quality__condition_resolved_date", "model.the_tuva_project.data_quality__condition_source_code", "model.the_tuva_project.data_quality__condition_source_code_type", "model.the_tuva_project.data_quality__condition_source_description", "model.the_tuva_project.data_quality__condition_status", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__encounter_admit_source_description", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__encounter_admit_type_description", "model.the_tuva_project.data_quality__encounter_allowed_amount", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__encounter_apr_drg_description", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_charge_amount", "model.the_tuva_project.data_quality__encounter_data_source", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "model.the_tuva_project.data_quality__encounter_encounter_end_date", "model.the_tuva_project.data_quality__encounter_encounter_id", "model.the_tuva_project.data_quality__encounter_encounter_start_date", "model.the_tuva_project.data_quality__encounter_encounter_type", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__encounter_length_of_stay", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__encounter_ms_drg_description", "model.the_tuva_project.data_quality__encounter_paid_amount", "model.the_tuva_project.data_quality__encounter_patient_id", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "model.the_tuva_project.data_quality__practitioner_sub_specialty", "model.the_tuva_project.data_quality__practitioner_last_name", "model.the_tuva_project.data_quality__practitioner_practitioner_id", "model.the_tuva_project.data_quality__practitioner_data_source", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__practitioner_first_name", "model.the_tuva_project.data_quality__practitioner_specialty", "model.the_tuva_project.data_quality__location_parent_organization", "model.the_tuva_project.data_quality__location_latitude", "model.the_tuva_project.data_quality__location_facility_type", "model.the_tuva_project.data_quality__location_zip_code", "model.the_tuva_project.data_quality__location_data_source", "model.the_tuva_project.data_quality__location_city", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__location_location_id", "model.the_tuva_project.data_quality__location_longitude", "model.the_tuva_project.data_quality__location_address", "model.the_tuva_project.data_quality__location_state", "model.the_tuva_project.data_quality__location_name", "model.the_tuva_project.data_quality__procedure_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_description", "model.the_tuva_project.data_quality__procedure_procedure_id", "model.the_tuva_project.data_quality__procedure_claim_id", "model.the_tuva_project.data_quality__procedure_source_code", "model.the_tuva_project.data_quality__procedure_source_code_type", "model.the_tuva_project.data_quality__procedure_source_description", "model.the_tuva_project.data_quality__procedure_practitioner_id", "model.the_tuva_project.data_quality__procedure_data_source", "model.the_tuva_project.data_quality__procedure_patient_id", "model.the_tuva_project.data_quality__procedure_procedure_date", "model.the_tuva_project.data_quality__procedure_encounter_id", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_specimen", "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "model.the_tuva_project.data_quality__lab_result_source_units", "model.the_tuva_project.data_quality__lab_result_lab_result_id", "model.the_tuva_project.data_quality__lab_result_collection_date", "model.the_tuva_project.data_quality__lab_result_normalized_component", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__lab_result_result", "model.the_tuva_project.data_quality__lab_result_source_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_description", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_source_description", "model.the_tuva_project.data_quality__lab_result_status", "model.the_tuva_project.data_quality__lab_result_accession_number", "model.the_tuva_project.data_quality__lab_result_result_date", "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_data_source", "model.the_tuva_project.data_quality__lab_result_normalized_units", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "model.the_tuva_project.data_quality__lab_result_source_code", "model.the_tuva_project.data_quality__lab_result_patient_id", "model.the_tuva_project.data_quality__lab_result_source_component", "model.the_tuva_project.data_quality__lab_result_encounter_id", "model.the_tuva_project.data_quality__patient_sex", "model.the_tuva_project.data_quality__patient_state", "model.the_tuva_project.data_quality__patient_city", "model.the_tuva_project.data_quality__patient_longitude", "model.the_tuva_project.data_quality__patient_county", "model.the_tuva_project.data_quality__patient_race", "model.the_tuva_project.data_quality__patient_death_flag", "model.the_tuva_project.data_quality__patient_address", "model.the_tuva_project.data_quality__patient_data_source", "model.the_tuva_project.data_quality__patient_zip_code", "model.the_tuva_project.data_quality__patient_first_name", "model.the_tuva_project.data_quality__patient_last_name", "model.the_tuva_project.data_quality__patient_latitude", "model.the_tuva_project.data_quality__patient_birth_date", "model.the_tuva_project.data_quality__patient_death_date", "model.the_tuva_project.data_quality__patient_patient_id", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.data_quality__medication_source_code", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_dispensing_date", "model.the_tuva_project.data_quality__medication_prescribing_date", "model.the_tuva_project.data_quality__medication_days_supply", "model.the_tuva_project.data_quality__medication_strength", "model.the_tuva_project.data_quality__medication_patient_id", "model.the_tuva_project.data_quality__medication_rxnorm_description", "model.the_tuva_project.data_quality__medication_encounter_id", "model.the_tuva_project.data_quality__medication_data_source", "model.the_tuva_project.data_quality__medication_atc_description", "model.the_tuva_project.data_quality__medication_quantity_unit", "model.the_tuva_project.data_quality__medication_source_description", "model.the_tuva_project.data_quality__medication_ndc_code", "model.the_tuva_project.data_quality__medication_medication_id", "model.the_tuva_project.data_quality__medication_source_code_type", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__medication_quantity", "model.the_tuva_project.data_quality__medication_practitioner_id", "model.the_tuva_project.data_quality__medication_route", "model.the_tuva_project.data_quality__observation_source_code", "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "model.the_tuva_project.data_quality__observation_source_units", "model.the_tuva_project.data_quality__observation_observation_type", "model.the_tuva_project.data_quality__observation_normalized_code", "model.the_tuva_project.data_quality__observation_normalized_description", "model.the_tuva_project.data_quality__observation_data_source", "model.the_tuva_project.data_quality__observation_panel_id", "model.the_tuva_project.data_quality__observation_observation_id", "model.the_tuva_project.data_quality__observation_source_reference_range_low", "model.the_tuva_project.data_quality__observation_result", "model.the_tuva_project.data_quality__observation_source_code_type", "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "model.the_tuva_project.data_quality__observation_observation_date", "model.the_tuva_project.data_quality__observation_encounter_id", "model.the_tuva_project.data_quality__observation_source_description", "model.the_tuva_project.data_quality__observation_source_reference_range_high", "model.the_tuva_project.data_quality__observation_normalized_units", "model.the_tuva_project.data_quality__observation_normalized_code_type", "model.the_tuva_project.data_quality__observation_patient_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/union_processing/clinical/data_quality__data_quality_clinical_detail.sql", "compiled": true, "compiled_code": "\n\nWITH CTE as (\nSELECT * FROM cms_synthetic.data_quality.condition_claim_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_condition_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_condition_rank\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_condition_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_onset_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_present_on_admit_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_present_on_admit_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_recorded_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_resolved_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_status\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_type_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_type_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_allowed_amount\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_apr_drg_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_apr_drg_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_attending_provider_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_charge_amount\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_discharge_disposition_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_discharge_disposition_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_end_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_start_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_facility_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_length_of_stay\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_ms_drg_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_ms_drg_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_paid_amount\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_primary_diagnosis_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_primary_diagnosis_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_primary_diagnosis_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_practice_affiliation\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_sub_specialty\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_last_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_npi\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_first_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_specialty\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_parent_organization\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_latitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_facility_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_zip_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_city\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_npi\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_location_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_longitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_address\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_state\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_procedure_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_claim_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_procedure_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_5\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_4\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_1\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_3\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_2\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_abnormal_flag\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_specimen\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_collection_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_component\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_ordering_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_result\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_status\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_accession_number\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_result_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_abnormal_flag\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_component\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_sex\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_state\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_city\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_longitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_county\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_race\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_death_flag\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_address\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_zip_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_first_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_last_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_latitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_birth_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_death_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_rxnorm_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_atc_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_dispensing_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_prescribing_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_days_supply\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_strength\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_rxnorm_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_atc_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_quantity_unit\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_ndc_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_medication_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_ndc_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_quantity\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_route\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_observation_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_panel_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_observation_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_result\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_observation_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_patient_id\n\n)\n\nSELECT\n data_source,\n cast(source_date as TEXT) as source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n bucket_name,\n invalid_reason,\n field_value,\n tuva_last_run,\n dense_rank() over (order by data_source, table_name, field_name) + 100000 as summary_sk\nFROM CTE", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_type_summary": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_type_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/union_processing/claims/data_quality__claim_type_summary.sql", "original_file_path": "models/data_quality/dqi/intermediate/union_processing/claims/data_quality__claim_type_summary.sql", "unique_id": "model.the_tuva_project.data_quality__claim_type_summary", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "claims", "data_quality__claim_type_summary"], "alias": "claim_type_summary", "checksum": {"name": "sha256", "checksum": "263a1dd7f41d87116a4dc149d87c33d307f806d3e17bf8db7be2ddfcb1f9da5d"}, "config": {"enabled": true, "alias": "claim_type_summary", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_type_summary", "tags": ["data_quality"], "materialized": "table", "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.3925812, "relation_name": "cms_synthetic.data_quality.claim_type_summary", "raw_code": "{% if var('claims_enabled', False) == true -%}\n\nselect\n data_source\n ,claim_type\n ,count(distinct claim_id) as claim_count\n ,sum(paid_amount) as paid_amount\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('medical_claim')}}\ngroup by\n data_source\n ,claim_type\n\n{% else -%}\n\nselect\n null as data_source\n , null as claim_type\n , null as claim_count\n , null as paid_amount\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n\n{{ limit_zero()}}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/union_processing/claims/data_quality__claim_type_summary.sql", "compiled": true, "compiled_code": "select\n data_source\n ,claim_type\n ,count(distinct claim_id) as claim_count\n ,sum(paid_amount) as paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim\ngroup by\n data_source\n ,claim_type\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_claims_for_pbi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/union_processing/claims/data_quality__data_quality_claims_for_pbi.sql", "original_file_path": "models/data_quality/dqi/intermediate/union_processing/claims/data_quality__data_quality_claims_for_pbi.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "claims", "data_quality__data_quality_claims_for_pbi"], "alias": "data_quality_claims_for_pbi", "checksum": {"name": "sha256", "checksum": "2e139897a6caae878d102609ced0a79c783eb16df033bd84947fbb808edd7241"}, "config": {"enabled": true, "alias": "data_quality_claims_for_pbi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_claims_for_pbi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.396163, "relation_name": "cms_synthetic.data_quality.data_quality_claims_for_pbi", "raw_code": "{{ config(\n enabled = var('claims_enabled',False)\n )\n}}\n\nWITH ranked_examples as (\n select\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value, --all claims\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\nWHERE bucket_name not in ('valid', 'null')\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n)\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n null as field_value,\n count(drill_down_value) as frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\nWHERE bucket_name = 'null'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n field_value as field_value,\n count(drill_down_value) as frequency\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\nWHERE bucket_name = 'valid'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '{{ var('tuva_last_run')}}'\nFROM ranked_examples\nWHERE rn <= 5 -- 5 Example claims per unique SK / field value\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '{{ var('tuva_last_run')}}'\nFROM ranked_examples\nWHERE rn > 5 -- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "language": "sql", "refs": [{"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_claims_detail"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/union_processing/claims/data_quality__data_quality_claims_for_pbi.sql", "compiled": true, "compiled_code": "\n\nWITH ranked_examples as (\n select\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value, --all claims\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\nWHERE bucket_name not in ('valid', 'null')\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n)\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'null'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n field_value as field_value,\n count(drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'valid'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-22 19:20:26.762934+00:00'\nFROM ranked_examples\nWHERE rn <= 5 -- 5 Example claims per unique SK / field value\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-22 19:20:26.762934+00:00'\nFROM ranked_examples\nWHERE rn > 5 -- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_claims_detail": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_claims_detail", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/dqi/intermediate/union_processing/claims/data_quality__data_quality_claims_detail.sql", "original_file_path": "models/data_quality/dqi/intermediate/union_processing/claims/data_quality__data_quality_claims_detail.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_detail", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "claims", "data_quality__data_quality_claims_detail"], "alias": "data_quality_claims_detail", "checksum": {"name": "sha256", "checksum": "9ba69489535020f6958be7025a730e59286223f1db7e146379c7a3b4bb0543cd"}, "config": {"enabled": true, "alias": "data_quality_claims_detail", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/dqi/dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_claims_detail", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.394492, "relation_name": "cms_synthetic.data_quality.data_quality_claims_detail", "raw_code": "{{ config(\n enabled = var('claims_enabled',False)\n )\n}}\n\nWITH unioned_data as (\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_allowed_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_charge_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_claim_id') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_claim_line_end_date') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_claim_line_number') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_claim_line_start_date') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_claim_type') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_coinsurance_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_copayment_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_data_source') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_deductible_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_diagnosis_code_type') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_hcpcs_code') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_member_id') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_paid_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_paid_date') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_patient_id') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_payer') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_plan') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__claim_total_cost_amount') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_address') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_birth_date') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_city') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_data_source') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_death_date') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_death_flag') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_dual_status_code') }}\n\nunion all\n\nSELECT\n cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_end_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_first_name') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_gender') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_last_name') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_medicare_status_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_member_id') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_original_reason_entitlement_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_patient_id') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_payer_type') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_payer') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_phone') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_plan') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_race') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_start_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_state') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__eligibility_zip_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_ms_drg_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_admission_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_admit_source_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_admit_type_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_apr_drg_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_bill_type_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_billing_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_claim_end_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_claim_start_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_diagnosis_code_1') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_diagnosis_code_2') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_diagnosis_code_3') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_discharge_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_discharge_disposition_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_facility_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_present_on_admission_1') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_present_on_admission_2') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_present_on_admission_3') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_procedure_code_1') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_procedure_code_2') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_procedure_code_3') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_procedure_date_1') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_procedure_date_2') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_procedure_date_3') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_rendering_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_revenue_center_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__institutional_service_unit_quantity') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_allowed_amount') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_claim_id') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_claim_line_number') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_coinsurance_amount') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_copayment_amount') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_data_source') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_days_supply') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_deductible_amount') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_dispensing_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_dispensing_provider_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_member_id') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_ndc_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_paid_amount') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_paid_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_patient_id') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_payer') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_plan') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_prescribing_provider_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_quantity') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__pharmacy_refills') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_billing_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_facility_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_place_of_service_code') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_rendering_npi') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_claim_end_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_claim_start_date') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_diagnosis_code_1') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_diagnosis_code_2') }}\n\nunion all\n\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n\tFROM {{ ref('data_quality__professional_diagnosis_code_3') }}\n\n)\n\n\nselect\n cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(source_date as {{ dbt.type_string() }}) as source_date\n , cast(table_name as {{ dbt.type_string() }}) as table_name\n , cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\n , cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\n , cast(claim_type as {{ dbt.type_string() }}) as claim_type\n , cast(field_name as {{ dbt.type_string() }}) as field_name\n , cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\n , cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\n , cast(field_value as {{ dbt.type_string() }}) as field_value\n , cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\n , dense_rank() over (\n order by data_source\n , table_name\n , claim_type\n , field_name\n ) as summary_sk\nfrom unioned_data", "language": "sql", "refs": [{"name": "data_quality__claim_allowed_amount", "package": null, "version": null}, {"name": "data_quality__claim_charge_amount", "package": null, "version": null}, {"name": "data_quality__claim_claim_id", "package": null, "version": null}, {"name": "data_quality__claim_claim_line_end_date", "package": null, "version": null}, {"name": "data_quality__claim_claim_line_number", "package": null, "version": null}, {"name": "data_quality__claim_claim_line_start_date", "package": null, "version": null}, {"name": "data_quality__claim_claim_type", "package": null, "version": null}, {"name": "data_quality__claim_coinsurance_amount", "package": null, "version": null}, {"name": "data_quality__claim_copayment_amount", "package": null, "version": null}, {"name": "data_quality__claim_data_source", "package": null, "version": null}, {"name": "data_quality__claim_deductible_amount", "package": null, "version": null}, {"name": "data_quality__claim_diagnosis_code_type", "package": null, "version": null}, {"name": "data_quality__claim_hcpcs_code", "package": null, "version": null}, {"name": "data_quality__claim_member_id", "package": null, "version": null}, {"name": "data_quality__claim_paid_amount", "package": null, "version": null}, {"name": "data_quality__claim_paid_date", "package": null, "version": null}, {"name": "data_quality__claim_patient_id", "package": null, "version": null}, {"name": "data_quality__claim_payer", "package": null, "version": null}, {"name": "data_quality__claim_plan", "package": null, "version": null}, {"name": "data_quality__claim_total_cost_amount", "package": null, "version": null}, {"name": "data_quality__eligibility_address", "package": null, "version": null}, {"name": "data_quality__eligibility_birth_date", "package": null, "version": null}, {"name": "data_quality__eligibility_city", "package": null, "version": null}, {"name": "data_quality__eligibility_data_source", "package": null, "version": null}, {"name": "data_quality__eligibility_death_date", "package": null, "version": null}, {"name": "data_quality__eligibility_death_flag", "package": null, "version": null}, {"name": "data_quality__eligibility_dual_status_code", "package": null, "version": null}, {"name": "data_quality__eligibility_end_date", "package": null, "version": null}, {"name": "data_quality__eligibility_first_name", "package": null, "version": null}, {"name": "data_quality__eligibility_gender", "package": null, "version": null}, {"name": "data_quality__eligibility_last_name", "package": null, "version": null}, {"name": "data_quality__eligibility_medicare_status_code", "package": null, "version": null}, {"name": "data_quality__eligibility_member_id", "package": null, "version": null}, {"name": "data_quality__eligibility_original_reason_entitlement_code", "package": null, "version": null}, {"name": "data_quality__eligibility_patient_id", "package": null, "version": null}, {"name": "data_quality__eligibility_payer_type", "package": null, "version": null}, {"name": "data_quality__eligibility_payer", "package": null, "version": null}, {"name": "data_quality__eligibility_phone", "package": null, "version": null}, {"name": "data_quality__eligibility_plan", "package": null, "version": null}, {"name": "data_quality__eligibility_race", "package": null, "version": null}, {"name": "data_quality__eligibility_start_date", "package": null, "version": null}, {"name": "data_quality__eligibility_state", "package": null, "version": null}, {"name": "data_quality__eligibility_zip_code", "package": null, "version": null}, {"name": "data_quality__institutional_ms_drg_code", "package": null, "version": null}, {"name": "data_quality__institutional_admission_date", "package": null, "version": null}, {"name": "data_quality__institutional_admit_source_code", "package": null, "version": null}, {"name": "data_quality__institutional_admit_type_code", "package": null, "version": null}, {"name": "data_quality__institutional_apr_drg_code", "package": null, "version": null}, {"name": "data_quality__institutional_bill_type_code", "package": null, "version": null}, {"name": "data_quality__institutional_billing_npi", "package": null, "version": null}, {"name": "data_quality__institutional_claim_end_date", "package": null, "version": null}, {"name": "data_quality__institutional_claim_start_date", "package": null, "version": null}, {"name": "data_quality__institutional_diagnosis_code_1", "package": null, "version": null}, {"name": "data_quality__institutional_diagnosis_code_2", "package": null, "version": null}, {"name": "data_quality__institutional_diagnosis_code_3", "package": null, "version": null}, {"name": "data_quality__institutional_discharge_date", "package": null, "version": null}, {"name": "data_quality__institutional_discharge_disposition_code", "package": null, "version": null}, {"name": "data_quality__institutional_facility_npi", "package": null, "version": null}, {"name": "data_quality__institutional_present_on_admission_1", "package": null, "version": null}, {"name": "data_quality__institutional_present_on_admission_2", "package": null, "version": null}, {"name": "data_quality__institutional_present_on_admission_3", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_code_1", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_code_2", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_code_3", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_date_1", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_date_2", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_date_3", "package": null, "version": null}, {"name": "data_quality__institutional_rendering_npi", "package": null, "version": null}, {"name": "data_quality__institutional_revenue_center_code", "package": null, "version": null}, {"name": "data_quality__institutional_service_unit_quantity", "package": null, "version": null}, {"name": "data_quality__pharmacy_allowed_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_id", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_line_number", "package": null, "version": null}, {"name": "data_quality__pharmacy_coinsurance_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_copayment_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_data_source", "package": null, "version": null}, {"name": "data_quality__pharmacy_days_supply", "package": null, "version": null}, {"name": "data_quality__pharmacy_deductible_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_dispensing_date", "package": null, "version": null}, {"name": "data_quality__pharmacy_dispensing_provider_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_member_id", "package": null, "version": null}, {"name": "data_quality__pharmacy_ndc_code", "package": null, "version": null}, {"name": "data_quality__pharmacy_paid_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_paid_date", "package": null, "version": null}, {"name": "data_quality__pharmacy_patient_id", "package": null, "version": null}, {"name": "data_quality__pharmacy_payer", "package": null, "version": null}, {"name": "data_quality__pharmacy_plan", "package": null, "version": null}, {"name": "data_quality__pharmacy_prescribing_provider_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_quantity", "package": null, "version": null}, {"name": "data_quality__pharmacy_refills", "package": null, "version": null}, {"name": "data_quality__professional_billing_npi", "package": null, "version": null}, {"name": "data_quality__professional_facility_npi", "package": null, "version": null}, {"name": "data_quality__professional_place_of_service_code", "package": null, "version": null}, {"name": "data_quality__professional_rendering_npi", "package": null, "version": null}, {"name": "data_quality__professional_claim_end_date", "package": null, "version": null}, {"name": "data_quality__professional_claim_start_date", "package": null, "version": null}, {"name": "data_quality__professional_diagnosis_code_1", "package": null, "version": null}, {"name": "data_quality__professional_diagnosis_code_2", "package": null, "version": null}, {"name": "data_quality__professional_diagnosis_code_3", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.data_quality__claim_allowed_amount", "model.the_tuva_project.data_quality__claim_charge_amount", "model.the_tuva_project.data_quality__claim_claim_id", "model.the_tuva_project.data_quality__claim_claim_line_end_date", "model.the_tuva_project.data_quality__claim_claim_line_number", "model.the_tuva_project.data_quality__claim_claim_line_start_date", "model.the_tuva_project.data_quality__claim_claim_type", "model.the_tuva_project.data_quality__claim_coinsurance_amount", "model.the_tuva_project.data_quality__claim_copayment_amount", "model.the_tuva_project.data_quality__claim_data_source", "model.the_tuva_project.data_quality__claim_deductible_amount", "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__claim_member_id", "model.the_tuva_project.data_quality__claim_paid_amount", "model.the_tuva_project.data_quality__claim_paid_date", "model.the_tuva_project.data_quality__claim_patient_id", "model.the_tuva_project.data_quality__claim_payer", "model.the_tuva_project.data_quality__claim_plan", "model.the_tuva_project.data_quality__claim_total_cost_amount", "model.the_tuva_project.data_quality__eligibility_address", "model.the_tuva_project.data_quality__eligibility_birth_date", "model.the_tuva_project.data_quality__eligibility_city", "model.the_tuva_project.data_quality__eligibility_data_source", "model.the_tuva_project.data_quality__eligibility_death_date", "model.the_tuva_project.data_quality__eligibility_death_flag", "model.the_tuva_project.data_quality__eligibility_dual_status_code", "model.the_tuva_project.data_quality__eligibility_end_date", "model.the_tuva_project.data_quality__eligibility_first_name", "model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__eligibility_last_name", "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "model.the_tuva_project.data_quality__eligibility_member_id", "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "model.the_tuva_project.data_quality__eligibility_patient_id", "model.the_tuva_project.data_quality__eligibility_payer_type", "model.the_tuva_project.data_quality__eligibility_payer", "model.the_tuva_project.data_quality__eligibility_phone", "model.the_tuva_project.data_quality__eligibility_plan", "model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__eligibility_start_date", "model.the_tuva_project.data_quality__eligibility_state", "model.the_tuva_project.data_quality__eligibility_zip_code", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__institutional_admission_date", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_claim_end_date", "model.the_tuva_project.data_quality__institutional_claim_start_date", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__institutional_discharge_date", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__institutional_procedure_date_1", "model.the_tuva_project.data_quality__institutional_procedure_date_2", "model.the_tuva_project.data_quality__institutional_procedure_date_3", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "model.the_tuva_project.data_quality__pharmacy_claim_id", "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "model.the_tuva_project.data_quality__pharmacy_data_source", "model.the_tuva_project.data_quality__pharmacy_days_supply", "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_member_id", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.data_quality__pharmacy_paid_amount", "model.the_tuva_project.data_quality__pharmacy_paid_date", "model.the_tuva_project.data_quality__pharmacy_patient_id", "model.the_tuva_project.data_quality__pharmacy_payer", "model.the_tuva_project.data_quality__pharmacy_plan", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_quantity", "model.the_tuva_project.data_quality__pharmacy_refills", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.data_quality__professional_rendering_npi", "model.the_tuva_project.data_quality__professional_claim_end_date", "model.the_tuva_project.data_quality__professional_claim_start_date", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/dqi/intermediate/union_processing/claims/data_quality__data_quality_claims_detail.sql", "compiled": true, "compiled_code": "\n\nWITH unioned_data as (\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_allowed_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_charge_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_line_end_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_line_number\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_line_start_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_coninsurance_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_copayment_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_deductible_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_diagnosis_code_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_hcpcs_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_member_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_paid_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_paid_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_patient_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_payer\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_plan\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_total_cost_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_address\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_birth_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_city\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_death_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_death_flag\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_dual_status_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_first_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_gender\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_last_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_medicare_status_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_original_reason_entitlement_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_payer_type\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_phone\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_race\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_state\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_zip_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_ms_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_admission_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_admit_source_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_admit_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_apr_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_bill_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_diagnosis_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_discharge_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_discharge_disposition_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_present_on_admission_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_present_on_admission_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_present_on_admission_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_date_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_date_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_date_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_revenue_center_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_service_unit_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_allowed_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_claim_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_claim_line_number\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_coinsurance_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_copayment_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_data_source\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_days_supply\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_deductible_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_dispensing_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_dispensing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_ndc_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_paid_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_paid_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_prescribing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_refills\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_place_of_service_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_diagnosis_code_3\n\n)\n\n\nselect\n cast(data_source as TEXT) as data_source\n , cast(source_date as TEXT) as source_date\n , cast(table_name as TEXT) as table_name\n , cast(drill_down_key as TEXT) as drill_down_key\n , cast(drill_down_value as TEXT) as drill_down_value\n , cast(claim_type as TEXT) as claim_type\n , cast(field_name as TEXT) as field_name\n , cast(bucket_name as TEXT) as bucket_name\n , cast(invalid_reason as TEXT) as invalid_reason\n , cast(field_value as TEXT) as field_value\n , cast(tuva_last_run as TEXT) as tuva_last_run\n , dense_rank() over (\n order by data_source\n , table_name\n , claim_type\n , field_name\n ) as summary_sk\nfrom unioned_data", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_dq_stage": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_dq_stage", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/stage/data_quality__eligibility_dq_stage.sql", "original_file_path": "models/data_quality/stage/data_quality__eligibility_dq_stage.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_dq_stage", "fqn": ["the_tuva_project", "data_quality", "stage", "data_quality__eligibility_dq_stage"], "alias": "data_quality__eligibility_dq_stage", "checksum": {"name": "sha256", "checksum": "9391f359baec01642049dabf79c3b0e4ba26f4de634ce6873a67b4755a68d13e"}, "config": {"enabled": true, "alias": null, "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "tags": ["data_quality_audit"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.970356, "relation_name": "cms_synthetic.data_quality.data_quality__eligibility_dq_stage", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nwith month_start_and_end_dates as (\n select\n year_month_int as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from {{ ref('reference_data__calendar')}}\n group by year_month_int\n)\n\nselect distinct\n a.patient_id\n , b.year_month\n , b.month_start_date\n , b.month_end_date\n , a.payer\n , a.{{ quote_column('plan') }}\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('eligibility') }} a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/stage/data_quality__eligibility_dq_stage.sql", "compiled": true, "compiled_code": "\n\nwith month_start_and_end_dates as (\n select\n year_month_int as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from cms_synthetic.reference_data.calendar\n group by year_month_int\n)\n\nselect distinct\n a.patient_id\n , b.year_month\n , b.month_start_date\n , b.month_end_date\n , a.payer\n , a.plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__inpatient_dq_stage": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__inpatient_dq_stage", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/stage/data_quality__inpatient_dq_stage.sql", "original_file_path": "models/data_quality/stage/data_quality__inpatient_dq_stage.sql", "unique_id": "model.the_tuva_project.data_quality__inpatient_dq_stage", "fqn": ["the_tuva_project", "data_quality", "stage", "data_quality__inpatient_dq_stage"], "alias": "data_quality__inpatient_dq_stage", "checksum": {"name": "sha256", "checksum": "2697fa47f507560cb627c26b32a530033c3d5a254e12658a68f289dc8d07ab2b"}, "config": {"enabled": true, "alias": null, "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "tags": ["data_quality_audit"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.97229, "relation_name": "cms_synthetic.data_quality.data_quality__inpatient_dq_stage", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from {{ ref('medical_claim') }} as mc\n left join {{ ref('terminology__ms_drg') }} as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join {{ ref('terminology__apr_drg') }} as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from {{ ref('medical_claim') }}\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n )\n)\n\nselect distinct\n a.claim_id\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('medical_claim') }} as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct\n a.claim_id\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('medical_claim') }} as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/stage/data_quality__inpatient_dq_stage.sql", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from tuva.input_layer.medical_claim as mc\n left join cms_synthetic.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join cms_synthetic.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n )\n)\n\nselect distinct\n a.claim_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__service_category_pmpm_trend": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__service_category_pmpm_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__service_category_pmpm_trend.sql", "original_file_path": "models/data_quality/final/data_quality__service_category_pmpm_trend.sql", "unique_id": "model.the_tuva_project.data_quality__service_category_pmpm_trend", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__service_category_pmpm_trend"], "alias": "service_category_pmpm_trend", "checksum": {"name": "sha256", "checksum": "b7dc11d23b2bb8a0e63c045a0b2f42b76651d3e0d9c13667d744c282abf1e334"}, "config": {"enabled": true, "alias": "service_category_pmpm_trend", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "service_category_pmpm_trend", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.849761, "relation_name": "cms_synthetic.data_quality.service_category_pmpm_trend", "raw_code": "{{ config(enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool) }}\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from {{ ref('core__member_months') }}\n group by year_month\n)\n\n, service_categories as (\n select\n cast(c.year_month_int as {{ dbt.type_string() }}) as year_month\n , m.service_category_1\n , m.service_category_2\n , sum(m.paid_amount) as total_paid\n from {{ ref('core__medical_claim') }} as m\n left join {{ ref('reference_data__calendar') }} as c\n on m.claim_start_date = c.full_date\n group by\n cast(c.year_month_int as {{ dbt.type_string() }})\n , m.service_category_1\n , m.service_category_2\n)\n\nselect\n scat.year_month\n , scat.service_category_1\n , scat.service_category_2\n , scat.total_paid\n , scat.total_paid / mm.member_months as pmpm\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom service_categories as scat\ninner join member_months as mm\n on scat.year_month = mm.year_month", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__service_category_pmpm_trend.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from cms_synthetic.core.member_months\n group by year_month\n)\n\n, service_categories as (\n select\n cast(c.year_month_int as TEXT) as year_month\n , m.service_category_1\n , m.service_category_2\n , sum(m.paid_amount) as total_paid\n from cms_synthetic.core.medical_claim as m\n left join cms_synthetic.reference_data.calendar as c\n on m.claim_start_date = c.full_date\n group by\n cast(c.year_month_int as TEXT)\n , m.service_category_1\n , m.service_category_2\n)\n\nselect\n scat.year_month\n , scat.service_category_1\n , scat.service_category_2\n , scat.total_paid\n , scat.total_paid / mm.member_months as pmpm\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_categories as scat\ninner join member_months as mm\n on scat.year_month = mm.year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__analytics_reference_summary": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__analytics_reference_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__analytics_reference_summary.sql", "original_file_path": "models/data_quality/final/data_quality__analytics_reference_summary.sql", "unique_id": "model.the_tuva_project.data_quality__analytics_reference_summary", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__analytics_reference_summary"], "alias": "analytics_reference_summary", "checksum": {"name": "sha256", "checksum": "59256e9a2e6399016a0f5fe1ca16f80606b61dc131781b8db7e8cfbd7a289aee"}, "config": {"enabled": true, "alias": "analytics_reference_summary", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "analytics_reference_summary", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.8687449, "relation_name": "cms_synthetic.data_quality.analytics_reference_summary", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n {{ dbt_utils.union_relations(\n relations=[\n ref('data_quality__readmissions_reference')\n , ref('data_quality__cms_hcc_reference')\n , ref('data_quality__chronic_conditions_prevalence')\n , ref('data_quality__quality_measures_reference')\n , ref('data_quality__acute_inpatient_reference')\n , ref('data_quality__acute_inpatient_prevelence')\n , ref('data_quality__encounters_cost_and_utilization')\n , ref('data_quality__ed_classification_reference')\n , ref('data_quality__service_categories_pmpm')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n\n)\n\nselect\n analytics_concept \n , analytics_measure\n , data_source_value\n , analytics_value\n , value_rank\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom unioned_data", "language": "sql", "refs": [{"name": "data_quality__readmissions_reference", "package": null, "version": null}, {"name": "data_quality__cms_hcc_reference", "package": null, "version": null}, {"name": "data_quality__chronic_conditions_prevalence", "package": null, "version": null}, {"name": "data_quality__quality_measures_reference", "package": null, "version": null}, {"name": "data_quality__acute_inpatient_reference", "package": null, "version": null}, {"name": "data_quality__acute_inpatient_prevelence", "package": null, "version": null}, {"name": "data_quality__encounters_cost_and_utilization", "package": null, "version": null}, {"name": "data_quality__ed_classification_reference", "package": null, "version": null}, {"name": "data_quality__service_categories_pmpm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__quality_measures_reference", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__service_categories_pmpm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__analytics_reference_summary.sql", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_readmissions_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_readmissions_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_cms_hcc_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_cms_hcc_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.chronic_conditions_prevalence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"PATIENTS\" as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(\"MEDICARE_LDS_CONDITION_RANK\" as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.chronic_conditions_prevalence\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_quality_measures_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_quality_measures_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_acute_inpatient_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_acute_inpatient_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_acute_inpatient_prevelence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_acute_inpatient_prevelence\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.encounters_cost_and_utilization' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.encounters_cost_and_utilization\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_ed_classification_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_ed_classification_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.service_categories_pmpm' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(\"TOTAL_PAID\" as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(\"MEMBER_MONTHS\" as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.service_categories_pmpm\n\n \n )\n\n \n\n)\n\nselect\n analytics_concept \n , analytics_measure\n , data_source_value\n , analytics_value\n , value_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned_data", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_volume_and_dollars", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__pharmacy_claim_volume_and_dollars.sql", "original_file_path": "models/data_quality/final/data_quality__pharmacy_claim_volume_and_dollars.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__pharmacy_claim_volume_and_dollars"], "alias": "pharmacy_claim_volume_and_dollars", "checksum": {"name": "sha256", "checksum": "4889be2639c20ba3ea80698f01c44fff40ee32e5ae126ff5ad5e60f69715eb5e"}, "config": {"enabled": true, "alias": "pharmacy_claim_volume_and_dollars", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "the year and month in format yyyymm", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_volume": {"name": "claim_volume", "description": "the unique count of claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_volume_and_dollars", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.879887, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_volume_and_dollars", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nselect\n c.year_month_int as year_month\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('pharmacy_claim') }} p\nleft join {{ ref('reference_data__calendar') }} c\n on coalesce(p.paid_date, p.dispensing_date) = c.full_date\ngroup by\n c.year_month_int", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__pharmacy_claim_volume_and_dollars.sql", "compiled": true, "compiled_code": "\n\nselect\n c.year_month_int as year_month\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim p\nleft join cms_synthetic.reference_data.calendar c\n on coalesce(p.paid_date, p.dispensing_date) = c.full_date\ngroup by\n c.year_month_int", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_test_summary": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_quality_test_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__data_quality_test_summary.sql", "original_file_path": "models/data_quality/final/data_quality__data_quality_test_summary.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_test_summary", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__data_quality_test_summary"], "alias": "data_quality_test_summary", "checksum": {"name": "sha256", "checksum": "2def8f37d5f63c854ebfe2b3fd40d90f05bf05c72b5dc6e87a111f651501dfe2"}, "config": {"enabled": true, "alias": "data_quality_test_summary", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "the count of records that match the result of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_test_summary", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.8669598, "relation_name": "cms_synthetic.data_quality.data_quality_test_summary", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n {{ dbt_utils.union_relations(\n relations=[\n ref('data_quality__medical_claim_claim_line_fields')\n , ref('data_quality__medical_claim_date_checks')\n , ref('data_quality__medical_claim_inst_header_fields')\n , ref('data_quality__medical_claim_patient_id')\n , ref('data_quality__medical_claim_provider_npi')\n , ref('data_quality__pharmacy_claim_date_checks')\n , ref('data_quality__pharmacy_claim_ndc')\n , ref('data_quality__pharmacy_claim_npi')\n , ref('data_quality__pharmacy_claim_prescription_details')\n , ref('data_quality__pharmacy_claim_patient_id')\n , ref('data_quality__primary_key_check')\n , ref('data_quality__eligibility_date_checks')\n , ref('data_quality__eligibility_demographics')\n , ref('data_quality__eligibility_missing_patient_id')\n , ref('data_quality__eligibility_missing_payer')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n\n)\n\nselect\n data_quality_check\n , result_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom unioned_data\nwhere data_quality_check <> 'Percent of claims with secondary diagnosis'", "language": "sql", "refs": [{"name": "data_quality__medical_claim_claim_line_fields", "package": null, "version": null}, {"name": "data_quality__medical_claim_date_checks", "package": null, "version": null}, {"name": "data_quality__medical_claim_inst_header_fields", "package": null, "version": null}, {"name": "data_quality__medical_claim_patient_id", "package": null, "version": null}, {"name": "data_quality__medical_claim_provider_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_date_checks", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_ndc", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_prescription_details", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_patient_id", "package": null, "version": null}, {"name": "data_quality__primary_key_check", "package": null, "version": null}, {"name": "data_quality__eligibility_date_checks", "package": null, "version": null}, {"name": "data_quality__eligibility_demographics", "package": null, "version": null}, {"name": "data_quality__eligibility_missing_patient_id", "package": null, "version": null}, {"name": "data_quality__eligibility_missing_payer", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__eligibility_date_checks", "model.the_tuva_project.data_quality__eligibility_demographics", "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "model.the_tuva_project.data_quality__eligibility_missing_payer"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__data_quality_test_summary.sql", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_claim_line_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_claim_line_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_inst_header_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_inst_header_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_provider_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_provider_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_ndc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_ndc\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_prescription_details' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_prescription_details\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.primary_key_check' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.primary_key_check\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_demographics' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_demographics\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_missing_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_missing_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_missing_payer' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_missing_payer\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned_data\nwhere data_quality_check <> 'Percent of claims with secondary diagnosis'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__analytics_populated": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__analytics_populated", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__analytics_populated.sql", "original_file_path": "models/data_quality/final/data_quality__analytics_populated.sql", "unique_id": "model.the_tuva_project.data_quality__analytics_populated", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__analytics_populated"], "alias": "analytics_populated", "checksum": {"name": "sha256", "checksum": "909d37876277cabfe89c06daf47535220d34d15ea28f675389441e54b299c222"}, "config": {"enabled": true, "alias": "analytics_populated", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"table_name": {"name": "table_name", "description": "the name of the table's records being counted", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "record_count": {"name": "record_count", "description": "the total number of records belonging to the specific data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "analytics_populated", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.894777, "relation_name": "cms_synthetic.data_quality.analytics_populated", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith tuva_chronic_condition_long as (\n select\n 'tuva_chronic_condition_long' as table_name\n , count(*) as record_count\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\n)\n\n, cms_hcc_patient_risk_factors as (\n select\n 'cms_hcc__patient_risk_factors' as table_name\n , count(*) as record_count\n from {{ ref('cms_hcc__patient_risk_factors') }}\n)\n\n, service_category_grouper as (\n select\n 'service_category__service_category_grouper' as table_name\n , count(*) as record_count\n from {{ ref('service_category__service_category_grouper') }}\n)\n\n, financial_pmpm_payer as (\n select\n 'financial_pmpm__pmpm_payer' as table_name\n , count(*) as record_count\n from {{ ref('financial_pmpm__pmpm_payer') }}\n)\n\n, readmission_summary as (\n select\n 'readmissions__readmission_summary' as table_name\n , count(*) as record_count\n from {{ ref('readmissions__readmission_summary') }}\n)\n\n, quality_measures_summary_long as (\n select\n 'quality_measures__summary_long' as table_name\n , count(*) as record_count\n from {{ ref('quality_measures__summary_long') }}\n)\n\n, acute_inpatient_visits as (\n select\n 'acute_inpatient_visits' as table_name\n , count(*) as record_count\n from {{ ref('core__encounter') }}\n where encounter_type = 'acute inpatient'\n)\n\n, ed_visits as (\n select\n 'ed_visits' as table_name\n , count(*) as record_count\n from {{ ref('core__encounter') }}\n where encounter_type = 'emergency department'\n)\n\n,final as (\nselect * from tuva_chronic_condition_long\nunion all\nselect * from cms_hcc_patient_risk_factors\nunion all\nselect * from service_category_grouper\nunion all\nselect * from financial_pmpm_payer\nunion all\nselect * from readmission_summary\nunion all\nselect * from quality_measures_summary_long\nunion all\nselect * from acute_inpatient_visits\nunion all\nselect * from ed_visits\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "financial_pmpm__pmpm_payer", "package": null, "version": null}, {"name": "readmissions__readmission_summary", "package": null, "version": null}, {"name": "quality_measures__summary_long", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.financial_pmpm__pmpm_payer", "model.the_tuva_project.readmissions__readmission_summary", "model.the_tuva_project.quality_measures__summary_long", "model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__analytics_populated.sql", "compiled": true, "compiled_code": "\n\nwith tuva_chronic_condition_long as (\n select\n 'tuva_chronic_condition_long' as table_name\n , count(*) as record_count\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, cms_hcc_patient_risk_factors as (\n select\n 'cms_hcc__patient_risk_factors' as table_name\n , count(*) as record_count\n from cms_synthetic.cms_hcc.patient_risk_factors\n)\n\n, service_category_grouper as (\n select\n 'service_category__service_category_grouper' as table_name\n , count(*) as record_count\n from cms_synthetic.claims_preprocessing.service_category_grouper\n)\n\n, financial_pmpm_payer as (\n select\n 'financial_pmpm__pmpm_payer' as table_name\n , count(*) as record_count\n from cms_synthetic.financial_pmpm.pmpm_payer\n)\n\n, readmission_summary as (\n select\n 'readmissions__readmission_summary' as table_name\n , count(*) as record_count\n from cms_synthetic.readmissions.readmission_summary\n)\n\n, quality_measures_summary_long as (\n select\n 'quality_measures__summary_long' as table_name\n , count(*) as record_count\n from cms_synthetic.quality_measures.summary_long\n)\n\n, acute_inpatient_visits as (\n select\n 'acute_inpatient_visits' as table_name\n , count(*) as record_count\n from cms_synthetic.core.encounter\n where encounter_type = 'acute inpatient'\n)\n\n, ed_visits as (\n select\n 'ed_visits' as table_name\n , count(*) as record_count\n from cms_synthetic.core.encounter\n where encounter_type = 'emergency department'\n)\n\n,final as (\nselect * from tuva_chronic_condition_long\nunion all\nselect * from cms_hcc_patient_risk_factors\nunion all\nselect * from service_category_grouper\nunion all\nselect * from financial_pmpm_payer\nunion all\nselect * from readmission_summary\nunion all\nselect * from quality_measures_summary_long\nunion all\nselect * from acute_inpatient_visits\nunion all\nselect * from ed_visits\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__core_populated": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__core_populated", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__core_populated.sql", "original_file_path": "models/data_quality/final/data_quality__core_populated.sql", "unique_id": "model.the_tuva_project.data_quality__core_populated", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__core_populated"], "alias": "core_populated", "checksum": {"name": "sha256", "checksum": "c90bd93c3a359b179df6a756e81826540c4d10b3853a543c30112ada077e0d9b"}, "config": {"enabled": true, "alias": "core_populated", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"table_name": {"name": "table_name", "description": "the name of the table's records being counted", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "record_count": {"name": "record_count", "description": "the total number of records belonging to the specific data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "core_populated", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.893334, "relation_name": "cms_synthetic.data_quality.core_populated", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith medical as (\n select\n 'medical_claim' as table_name\n , count(*) as record_count\n from {{ ref('core__medical_claim') }}\n)\n\n, pharmacy as (\n select\n 'pharmacy_claim' as table_name\n , count(*) as record_count\n from {{ ref('core__pharmacy_claim') }}\n)\n\n, eligibility as (\n select\n 'eligibility' as table_name\n , count(*) as record_count\n from {{ ref('core__eligibility') }}\n)\n\n, member_months as (\n select\n 'member_months' as table_name\n , count(*) as record_count\n from {{ ref('core__member_months') }}\n)\n\n, patient as (\n select\n 'patient' as table_name\n , count(*) as record_count\n from {{ ref('core__patient') }}\n)\n\n, encounter as (\n select\n 'encounter' as table_name\n , count(*) as record_count\n from {{ ref('core__encounter') }}\n)\n\n, condition as (\n select\n 'condition' as table_name\n , count(*) as record_count\n from {{ ref('core__condition') }}\n)\n\n, procedure_cte as (\n select\n 'procedure' as table_name\n , count(*) as record_count\n from {{ ref('core__procedure') }}\n)\n\n,final as (\nselect * from medical\nunion all\nselect * from pharmacy\nunion all\nselect * from eligibility\nunion all\nselect * from member_months\nunion all\nselect * from patient\nunion all\nselect * from encounter\nunion all\nselect * from condition\nunion all\nselect * from procedure_cte\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}, {"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__condition", "package": null, "version": null}, {"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__patient", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__condition", "model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__core_populated.sql", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n 'medical_claim' as table_name\n , count(*) as record_count\n from cms_synthetic.core.medical_claim\n)\n\n, pharmacy as (\n select\n 'pharmacy_claim' as table_name\n , count(*) as record_count\n from cms_synthetic.core.pharmacy_claim\n)\n\n, eligibility as (\n select\n 'eligibility' as table_name\n , count(*) as record_count\n from cms_synthetic.core.eligibility\n)\n\n, member_months as (\n select\n 'member_months' as table_name\n , count(*) as record_count\n from cms_synthetic.core.member_months\n)\n\n, patient as (\n select\n 'patient' as table_name\n , count(*) as record_count\n from cms_synthetic.core.patient\n)\n\n, encounter as (\n select\n 'encounter' as table_name\n , count(*) as record_count\n from cms_synthetic.core.encounter\n)\n\n, condition as (\n select\n 'condition' as table_name\n , count(*) as record_count\n from cms_synthetic.core.condition\n)\n\n, procedure_cte as (\n select\n 'procedure' as table_name\n , count(*) as record_count\n from cms_synthetic.core.procedure\n)\n\n,final as (\nselect * from medical\nunion all\nselect * from pharmacy\nunion all\nselect * from eligibility\nunion all\nselect * from member_months\nunion all\nselect * from patient\nunion all\nselect * from encounter\nunion all\nselect * from condition\nunion all\nselect * from procedure_cte\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_loss": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__data_loss", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__data_loss.sql", "original_file_path": "models/data_quality/final/data_quality__data_loss.sql", "unique_id": "model.the_tuva_project.data_quality__data_loss", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__data_loss"], "alias": "data_loss", "checksum": {"name": "sha256", "checksum": "4d4f77dfc76eb0f2d5d752fbb159a440331e5066cf54cb8203ea5326dd6540fb"}, "config": {"enabled": true, "alias": "data_loss", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"table_name": {"name": "table_name", "description": "the name of the table's records being counted", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "metric": {"name": "metric", "description": "the name of the metric being analyzed", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "input_layer_value": {"name": "input_layer_value", "description": "the count of the metric found in the input layer schema of the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "core_value": {"name": "core_value", "description": "the count of the metric found in the core layer schema of the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_loss", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.891724, "relation_name": "cms_synthetic.data_quality.data_loss", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith input_medical as (\n select\n cast('medical_claim' as {{ dbt.type_string() }}) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from {{ ref('medical_claim') }}\n)\n\n, input_pharmacy as (\n select\n cast('pharmacy_claim' as {{ dbt.type_string() }}) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from {{ ref('pharmacy_claim') }}\n)\n\n,input_eligibility as (\nselect\n cast('eligibility' as {{ dbt.type_string() }}) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct {{ dbt.concat([\n 'member_id'\n , \"'-'\"\n , 'enrollment_start_date'\n , \"'-'\"\n , 'enrollment_end_date'\n , \"'-'\"\n , 'payer'\n , \"'-'\"\n , quote_column('plan')\n ]) }}) as span_count\nfrom {{ ref('eligibility') }}\n)\n\n , input_member_months as (\n select\n cast('eligibility' as {{ dbt.type_string() }}) as table_name\n , count(*) as member_month_count\n from {{ ref('data_quality__eligibility_dq_stage') }} e\n)\n\n-- Core layer CTEs\n, core_medical as (\n select\n cast( 'medical_claim' as {{ dbt.type_string() }}) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from {{ ref('core__medical_claim') }}\n)\n\n, core_pharmacy as (\n select\n cast( 'pharmacy_claim' as {{ dbt.type_string() }}) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from {{ ref('core__pharmacy_claim') }}\n)\n\n, core_eligibility as (\n select\n cast('eligibility' as {{ dbt.type_string() }})as table_name\n , count(distinct patient_id) as patient_count\n , count(*) as span_count\n from {{ ref('core__eligibility') }}\n)\n\n, core_member_months as (\n select\n cast('member_months' as {{ dbt.type_string() }}) as table_name\n , count(*) as member_month_count\n from {{ ref('core__member_months') }}\n)\n\n,final as (\n-- Combining both input and core layers\nselect\n input.table_name\n , cast('Total Unique Patients' as {{ dbt.type_string() }}) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as {{ dbt.type_string() }}) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as {{ dbt.type_string() }}) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as {{ dbt.type_string() }}) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as {{ dbt.type_string() }}) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\n-- Pharmacy layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as {{ dbt.type_string() }}) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as {{ dbt.type_string() }}) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as {{ dbt.type_string() }}) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as {{ dbt.type_string() }}) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as {{ dbt.type_string() }}) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\n-- Eligibility layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as {{ dbt.type_string() }}) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Eligibility Spans' as {{ dbt.type_string() }}) as metric\n , input.span_count as input_layer_value\n , core.span_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Member Months' as {{ dbt.type_string() }}) as metric\n , input.member_month_count as input_layer_value\n , core.member_month_count as core_value\nfrom input_member_months as input\ninner join core_member_months as core\n on input.table_name = core.table_name\n\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "model.input_layer.eligibility", "model.the_tuva_project.data_quality__eligibility_dq_stage", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__data_loss.sql", "compiled": true, "compiled_code": "\n\nwith input_medical as (\n select\n cast('medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.medical_claim\n)\n\n, input_pharmacy as (\n select\n cast('pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.pharmacy_claim\n)\n\n,input_eligibility as (\nselect\n cast('eligibility' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan) as span_count\nfrom tuva.input_layer.eligibility\n)\n\n , input_member_months as (\n select\n cast('eligibility' as TEXT) as table_name\n , count(*) as member_month_count\n from cms_synthetic.data_quality.data_quality__eligibility_dq_stage e\n)\n\n-- Core layer CTEs\n, core_medical as (\n select\n cast( 'medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from cms_synthetic.core.medical_claim\n)\n\n, core_pharmacy as (\n select\n cast( 'pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from cms_synthetic.core.pharmacy_claim\n)\n\n, core_eligibility as (\n select\n cast('eligibility' as TEXT)as table_name\n , count(distinct patient_id) as patient_count\n , count(*) as span_count\n from cms_synthetic.core.eligibility\n)\n\n, core_member_months as (\n select\n cast('member_months' as TEXT) as table_name\n , count(*) as member_month_count\n from cms_synthetic.core.member_months\n)\n\n,final as (\n-- Combining both input and core layers\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\n-- Pharmacy layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\n-- Eligibility layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Eligibility Spans' as TEXT) as metric\n , input.span_count as input_layer_value\n , core.span_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Member Months' as TEXT) as metric\n , input.member_month_count as input_layer_value\n , core.member_month_count as core_value\nfrom input_member_months as input\ninner join core_member_months as core\n on input.table_name = core.table_name\n\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_trend": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__eligibility_trend.sql", "original_file_path": "models/data_quality/final/data_quality__eligibility_trend.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_trend", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__eligibility_trend"], "alias": "eligibility_trend", "checksum": {"name": "sha256", "checksum": "9585da2457f5d54c367f12721727096fab439de433220ec1beb95daf118e148f"}, "config": {"enabled": true, "alias": "eligibility_trend", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "The year and month", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "The count of distinct members with eligibility in the corresponding year and month", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_trend", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.8636212, "relation_name": "cms_synthetic.data_quality.eligibility_trend", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nwith eligibility_spans as(\n select distinct\n {{ dbt.concat([\n \"member_id\",\n \"'-'\",\n \"enrollment_start_date\",\n \"'-'\",\n \"enrollment_end_date\",\n \"'-'\",\n \"payer\",\n \"'-'\",\n quote_column('plan'),\n ]) }} as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from {{ ref('eligibility') }}\n)\n, month_start_and_end_dates as (\n select\n {{ dbt.concat([\"year\",\n dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from {{ ref('reference_data__calendar')}}\n group by year, month, year_month\n)\n, member_months as (\n select distinct\n eligibility_span_id\n , year_month\n from eligibility_spans es\n inner join month_start_and_end_dates d\n on es.enrollment_start_date <= d.month_end_date\n and es.enrollment_end_date >= d.month_start_date\n)\n\n\nselect\n year_month\n , count(distinct eligibility_span_id) as member_months\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom member_months\ngroup by\n year_month", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.right"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__eligibility_trend.sql", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n, month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from cms_synthetic.reference_data.calendar\n group by year, month, year_month\n)\n, member_months as (\n select distinct\n eligibility_span_id\n , year_month\n from eligibility_spans es\n inner join month_start_and_end_dates d\n on es.enrollment_start_date <= d.month_end_date\n and es.enrollment_end_date >= d.month_start_date\n)\n\n\nselect\n year_month\n , count(distinct eligibility_span_id) as member_months\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom member_months\ngroup by\n year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__analytics_checks_summary": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__analytics_checks_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__analytics_checks_summary.sql", "original_file_path": "models/data_quality/final/data_quality__analytics_checks_summary.sql", "unique_id": "model.the_tuva_project.data_quality__analytics_checks_summary", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__analytics_checks_summary"], "alias": "analytics_checks_summary", "checksum": {"name": "sha256", "checksum": "cfede3d8d67c8ab1d05c7f33e3ba02b5e5c7a1ba305548587a789d6b8c235ab4"}, "config": {"enabled": true, "alias": "analytics_checks_summary", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "the count of records that match the result of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "analytics_checks_summary", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.870355, "relation_name": "cms_synthetic.data_quality.analytics_checks_summary", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n {{ dbt_utils.union_relations(\n relations=[\n ref('data_quality__readmissions')\n , ref('data_quality__chronic_conditions_none')\n , ref('data_quality__cms_hcc')\n , ref('data_quality__quality_measures')\n , ref('data_quality__encounters_missing_groups_union')\n , ref('data_quality__acute_inpatient')\n , ref('data_quality__ed_classification')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n\n)\n\nselect\n data_quality_check\n , result_count\n , coalesce(normally_zero ,1) as normally_zero\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom unioned_data", "language": "sql", "refs": [{"name": "data_quality__readmissions", "package": null, "version": null}, {"name": "data_quality__chronic_conditions_none", "package": null, "version": null}, {"name": "data_quality__cms_hcc", "package": null, "version": null}, {"name": "data_quality__quality_measures", "package": null, "version": null}, {"name": "data_quality__encounters_missing_groups_union", "package": null, "version": null}, {"name": "data_quality__acute_inpatient", "package": null, "version": null}, {"name": "data_quality__ed_classification", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.data_quality__readmissions", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__cms_hcc", "model.the_tuva_project.data_quality__quality_measures", "model.the_tuva_project.data_quality__encounters_missing_groups_union", "model.the_tuva_project.data_quality__acute_inpatient", "model.the_tuva_project.data_quality__ed_classification"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__analytics_checks_summary.sql", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_readmissions' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_readmissions\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.chronic_conditions_none' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"MEDICARE_LDS_REFERENCE\" as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(\"NORMALLY_ZERO\" as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.chronic_conditions_none\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_cms_hcc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_cms_hcc\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_quality_measures' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_quality_measures\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.encounters_missing_groups_union' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.encounters_missing_groups_union\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_acute_inpatient' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_acute_inpatient\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_ed_classification' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_ed_classification\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , coalesce(normally_zero ,1) as normally_zero\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned_data", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounters_cost_and_utilization_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__encounters_cost_and_utilization_trend.sql", "original_file_path": "models/data_quality/final/data_quality__encounters_cost_and_utilization_trend.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__encounters_cost_and_utilization_trend"], "alias": "encounters_cost_and_utilization_trend", "checksum": {"name": "sha256", "checksum": "c6e13b646a2b11fd3ab695cd569465bda18041fc46483133e94746cf7bbff6db"}, "config": {"enabled": true, "alias": "encounters_cost_and_utilization_trend", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_cost_and_utilization_trend", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.848093, "relation_name": "cms_synthetic.data_quality.encounters_cost_and_utilization_trend", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\n) }}\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from {{ ref('core__member_months') }}\n group by year_month\n)\n\n, encounters as (\n select\n cast(cal.year_month_int as {{ dbt.type_string() }}) as year_month\n , e.encounter_group\n , e.encounter_type\n , e.encounter_id\n , e.paid_amount\n from {{ ref('core__encounter') }} as e\n left join {{ ref('reference_data__calendar') }} as cal\n on e.encounter_start_date = cal.full_date\n)\n\n, pkpy_trend as (\n select\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , count(enc.encounter_id) / mm.member_months * 12000 as pkpy\n , sum(enc.paid_amount) / nullif(count(enc.encounter_id), 0) as paid_per\n from encounters as enc\n inner join member_months as mm\n on enc.year_month = mm.year_month\n group by\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , mm.member_months\n)\n\nselect\n pkpy_trend.year_month\n , pkpy_trend.encounter_group\n , pkpy_trend.encounter_type\n , pkpy_trend.pkpy\n , pkpy_trend.paid_per\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom pkpy_trend", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__encounter", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__encounters_cost_and_utilization_trend.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from cms_synthetic.core.member_months\n group by year_month\n)\n\n, encounters as (\n select\n cast(cal.year_month_int as TEXT) as year_month\n , e.encounter_group\n , e.encounter_type\n , e.encounter_id\n , e.paid_amount\n from cms_synthetic.core.encounter as e\n left join cms_synthetic.reference_data.calendar as cal\n on e.encounter_start_date = cal.full_date\n)\n\n, pkpy_trend as (\n select\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , count(enc.encounter_id) / mm.member_months * 12000 as pkpy\n , sum(enc.paid_amount) / nullif(count(enc.encounter_id), 0) as paid_per\n from encounters as enc\n inner join member_months as mm\n on enc.year_month = mm.year_month\n group by\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , mm.member_months\n)\n\nselect\n pkpy_trend.year_month\n , pkpy_trend.encounter_group\n , pkpy_trend.encounter_type\n , pkpy_trend.pkpy\n , pkpy_trend.paid_per\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pkpy_trend", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medical_claim_volume_and_dollars", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__medical_claim_volume_and_dollars.sql", "original_file_path": "models/data_quality/final/data_quality__medical_claim_volume_and_dollars.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__medical_claim_volume_and_dollars"], "alias": "medical_claim_volume_and_dollars", "checksum": {"name": "sha256", "checksum": "08b51dfc01af4fcf317c40905d909c3b300aeace988034d8d168fb5014004bc1"}, "config": {"enabled": true, "alias": "medical_claim_volume_and_dollars", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "the year and month in format yyyymm", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_volume": {"name": "claim_volume", "description": "the unique count of claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_volume_and_dollars", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.8896, "relation_name": "cms_synthetic.data_quality.medical_claim_volume_and_dollars", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith range_cte as (\n select\n min(claim_start_date) as first_date\n {% if target.type == 'fabric' %}\n , getdate() as last_date\n {% else %}\n , current_date as last_date\n {% endif %}\n from {{ ref('medical_claim') }} p\n)\n\n, date_cte as (\n select distinct\n year_month_int\n from {{ ref('reference_data__calendar') }} c\n inner join range_cte r\n on c.full_date between r.first_date and r.last_date\n)\n\n, medical_claim as (\n select\n c.year_month_int\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n from {{ ref('medical_claim') }} p\n left join {{ ref('reference_data__calendar') }} c\n on p.claim_start_date = c.full_date\n group by\n c.year_month_int\n)\n\nselect\n d.year_month_int as year_month\n , coalesce(claim_volume, 0) as claim_volume\n , coalesce(paid_amount, 0) as paid_amount\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom date_cte d\nleft join medical_claim m\n on d.year_month_int = m.year_month_int", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__medical_claim_volume_and_dollars.sql", "compiled": true, "compiled_code": "\n\nwith range_cte as (\n select\n min(claim_start_date) as first_date\n \n , current_date as last_date\n \n from tuva.input_layer.medical_claim p\n)\n\n, date_cte as (\n select distinct\n year_month_int\n from cms_synthetic.reference_data.calendar c\n inner join range_cte r\n on c.full_date between r.first_date and r.last_date\n)\n\n, medical_claim as (\n select\n c.year_month_int\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n from tuva.input_layer.medical_claim p\n left join cms_synthetic.reference_data.calendar c\n on p.claim_start_date = c.full_date\n group by\n c.year_month_int\n)\n\nselect\n d.year_month_int as year_month\n , coalesce(claim_volume, 0) as claim_volume\n , coalesce(paid_amount, 0) as paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom date_cte d\nleft join medical_claim m\n on d.year_month_int = m.year_month_int", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_date_trends": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_date_trends", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/final/data_quality__claim_date_trends.sql", "original_file_path": "models/data_quality/final/data_quality__claim_date_trends.sql", "unique_id": "model.the_tuva_project.data_quality__claim_date_trends", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__claim_date_trends"], "alias": "claim_date_trends", "checksum": {"name": "sha256", "checksum": "0e75fcbb06f0bd99812171ef98fce9ba7f82c08765e836ac5a0f1b3e8ba31e58"}, "config": {"enabled": true, "alias": "claim_date_trends", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "The count of distinct claims with a claim start date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "The count of distinct claims with a claim end date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "The count of distinct claims with a admission date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The count of distinct claims with a discharge date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid_date": {"name": "medical_paid_date", "description": "The count of distinct claims with a medical paid date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "The count of distinct claims with a dispensing date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid_date": {"name": "pharmacy_paid_date", "description": "The count of distinct claims with a pharmacy paid date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_date_trends", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.865375, "relation_name": "cms_synthetic.data_quality.claim_date_trends", "raw_code": "{{ config(\n enabled = var('data_quality_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith date_stage as(\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'claim_start_date' as date_field\n , cast({{ date_part(\"year\", \"claim_start_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"claim_start_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('medical_claim') }}\n group by\n cast({{ date_part(\"year\", \"claim_start_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"claim_start_date\") }} as {{ dbt.type_string() }})\n )x\n\n union all\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'claim_end_date' as date_field\n , cast({{ date_part(\"year\", \"claim_end_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"claim_end_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('medical_claim') }}\n group by\n cast({{ date_part(\"year\", \"claim_end_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"claim_end_date\") }} as {{ dbt.type_string() }})\n )x\n\n union all\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'admission_date' as date_field\n , cast({{ date_part(\"year\", \"admission_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"admission_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('medical_claim') }}\n group by\n cast({{ date_part(\"year\", \"admission_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"admission_date\") }} as {{ dbt.type_string() }})\n )x\n\n union all\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'discharge_date' as date_field\n , cast({{ date_part(\"year\", \"discharge_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"discharge_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('medical_claim') }}\n group by\n cast({{ date_part(\"year\", \"discharge_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"discharge_date\") }} as {{ dbt.type_string() }})\n )x\n\n union all\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'medical paid_date' as date_field\n , cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('medical_claim') }}\n group by\n cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }})\n )x\n\n union all\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'dispensing_date' as date_field\n , cast({{ date_part(\"year\", \"dispensing_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"dispensing_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('pharmacy_claim') }}\n group by\n cast({{ date_part(\"year\", \"dispensing_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"dispensing_date\") }} as {{ dbt.type_string() }})\n )x\n\n union all\n\n select\n date_field\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\n , result_count\n from\n (\n select\n 'pharmacy paid_date' as date_field\n , cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }}) as year\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }}) as month\n , count(distinct claim_id) as result_count\n from {{ ref('pharmacy_claim') }}\n group by\n cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }})\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }})\n )x\n\n)\n\n\n, all_date_range as (\n select distinct\n replace(cal.year_month,'-','') as year_month\n from {{ ref('reference_data__calendar') }} cal\n where (cal.year_month >= (select min(year_month) from date_stage)\n and cal.year_month <= (select max(year_month) from date_stage))\n\n)\n\nselect\n cast(all_date.year_month as {{ dbt.type_int() }} ) as year_month\n , claim_start.result_count as claim_start_date\n , claim_end.result_count as claim_end_date\n , admission_date.result_count as admission_date\n , discharge_date.result_count as discharge_date\n , med_paid_date.result_count as medical_paid_date\n , dispensing_date.result_count as dispensing_date\n , pharm_paid_date.result_count as pharmacy_paid_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom all_date_range all_date\nleft join date_stage claim_start\n on all_date.year_month = claim_start.year_month\n and claim_start.date_field = 'claim_start_date'\nleft join date_stage claim_end\n on all_date.year_month = claim_end.year_month\n and claim_end.date_field = 'claim_end_date'\nleft join date_stage admission_date\n on all_date.year_month = admission_date.year_month\n and admission_date.date_field = 'admission_date'\nleft join date_stage discharge_date\n on all_date.year_month = discharge_date.year_month\n and discharge_date.date_field = 'discharge_date'\nleft join date_stage med_paid_date\n on all_date.year_month = med_paid_date.year_month\n and med_paid_date.date_field = 'medical paid_date'\nleft join date_stage dispensing_date\n on all_date.year_month = dispensing_date.year_month\n and dispensing_date.date_field = 'dispensing_date'\nleft join date_stage pharm_paid_date\n on all_date.year_month = pharm_paid_date.year_month\n and pharm_paid_date.date_field = 'pharmacy paid_date'", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.right", "macro.the_tuva_project.date_part", "macro.dbt.type_string", "macro.dbt.type_int"], "nodes": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/final/data_quality__claim_date_trends.sql", "compiled": true, "compiled_code": "\n\nwith date_stage as(\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_start_date' as date_field\n , cast(date_part('year', claim_start_date) as TEXT) as year\n , cast(date_part('month', claim_start_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_start_date) as TEXT)\n , cast(date_part('month', claim_start_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_end_date' as date_field\n , cast(date_part('year', claim_end_date) as TEXT) as year\n , cast(date_part('month', claim_end_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_end_date) as TEXT)\n , cast(date_part('month', claim_end_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'admission_date' as date_field\n , cast(date_part('year', admission_date) as TEXT) as year\n , cast(date_part('month', admission_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', admission_date) as TEXT)\n , cast(date_part('month', admission_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'discharge_date' as date_field\n , cast(date_part('year', discharge_date) as TEXT) as year\n , cast(date_part('month', discharge_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', discharge_date) as TEXT)\n , cast(date_part('month', discharge_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'medical paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'dispensing_date' as date_field\n , cast(date_part('year', dispensing_date) as TEXT) as year\n , cast(date_part('month', dispensing_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', dispensing_date) as TEXT)\n , cast(date_part('month', dispensing_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'pharmacy paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n)\n\n\n, all_date_range as (\n select distinct\n replace(cal.year_month,'-','') as year_month\n from cms_synthetic.reference_data.calendar cal\n where (cal.year_month >= (select min(year_month) from date_stage)\n and cal.year_month <= (select max(year_month) from date_stage))\n\n)\n\nselect\n cast(all_date.year_month as integer ) as year_month\n , claim_start.result_count as claim_start_date\n , claim_end.result_count as claim_end_date\n , admission_date.result_count as admission_date\n , discharge_date.result_count as discharge_date\n , med_paid_date.result_count as medical_paid_date\n , dispensing_date.result_count as dispensing_date\n , pharm_paid_date.result_count as pharmacy_paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom all_date_range all_date\nleft join date_stage claim_start\n on all_date.year_month = claim_start.year_month\n and claim_start.date_field = 'claim_start_date'\nleft join date_stage claim_end\n on all_date.year_month = claim_end.year_month\n and claim_end.date_field = 'claim_end_date'\nleft join date_stage admission_date\n on all_date.year_month = admission_date.year_month\n and admission_date.date_field = 'admission_date'\nleft join date_stage discharge_date\n on all_date.year_month = discharge_date.year_month\n and discharge_date.date_field = 'discharge_date'\nleft join date_stage med_paid_date\n on all_date.year_month = med_paid_date.year_month\n and med_paid_date.date_field = 'medical paid_date'\nleft join date_stage dispensing_date\n on all_date.year_month = dispensing_date.year_month\n and dispensing_date.date_field = 'dispensing_date'\nleft join date_stage pharm_paid_date\n on all_date.year_month = pharm_paid_date.year_month\n and pharm_paid_date.date_field = 'pharmacy paid_date'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__chronic_conditions_none": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__chronic_conditions_none", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__chronic_conditions_none.sql", "original_file_path": "models/data_quality/intermediate/data_quality__chronic_conditions_none.sql", "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_none", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__chronic_conditions_none"], "alias": "chronic_conditions_none", "checksum": {"name": "sha256", "checksum": "d046e47418dc800b65d8c314911340d6d2b8283563ed8a03442bf22e77f3f721"}, "config": {"enabled": true, "alias": "chronic_conditions_none", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "chronic_conditions_none", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.846741, "relation_name": "cms_synthetic.data_quality.chronic_conditions_none", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith chronic_conditions as \n(\n select distinct patient_id \n from {{ ref('chronic_conditions__cms_chronic_conditions_long') }}\n)\n\n,results as (\n select \n cast('Percent of patients without chronic conditions' as {{dbt.type_string()}}) as data_quality_check\n , sum(case when cccw.patient_id is null then 1 else 0 end) / count(distinct e.patient_id) * 100 as result_count\n from {{ ref('core__patient') }} e\n left join chronic_conditions cccw \n on e.patient_id = cccw.patient_id\n)\n\nselect\n results.data_quality_check\n , results.result_count\n , ref_data.analytics_value as medicare_lds_reference\n , 0 as normally_zero \n , cast('{{ var('tuva_last_run') }}' as {{dbt.type_string()}}) as tuva_last_run\n \nfrom results\nleft join {{ ref('data_quality__reference_mart_analytics') }} as ref_data \n on results.data_quality_check = ref_data.analytics_measure", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.core__patient", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__chronic_conditions_none.sql", "compiled": true, "compiled_code": "\n\nwith chronic_conditions as \n(\n select distinct patient_id \n from cms_synthetic.chronic_conditions.cms_chronic_conditions_long\n)\n\n,results as (\n select \n cast('Percent of patients without chronic conditions' as TEXT) as data_quality_check\n , sum(case when cccw.patient_id is null then 1 else 0 end) / count(distinct e.patient_id) * 100 as result_count\n from cms_synthetic.core.patient e\n left join chronic_conditions cccw \n on e.patient_id = cccw.patient_id\n)\n\nselect\n results.data_quality_check\n , results.result_count\n , ref_data.analytics_value as medicare_lds_reference\n , 0 as normally_zero \n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT) as tuva_last_run\n \nfrom results\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics as ref_data \n on results.data_quality_check = ref_data.analytics_measure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_date_checks": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_date_checks", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__eligibility_date_checks.sql", "original_file_path": "models/data_quality/intermediate/data_quality__eligibility_date_checks.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_date_checks", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_date_checks"], "alias": "eligibility_date_checks", "checksum": {"name": "sha256", "checksum": "e39261aabb64a2e109af13133eccd6ae1ca12ae00d41c213ac279a63ca84ece2"}, "config": {"enabled": true, "alias": "eligibility_date_checks", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_date_checks", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.85311, "relation_name": "cms_synthetic.data_quality.eligibility_date_checks", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nwith eligibility_spans as(\n select distinct\n {{ dbt.concat([\n \"member_id\",\n \"'-'\",\n \"enrollment_start_date\",\n \"'-'\",\n \"enrollment_end_date\",\n \"'-'\",\n \"payer\",\n \"'-'\",\n quote_column('plan'),\n ]) }} as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from {{ ref('eligibility') }}\n)\n\n, missing_start_date as (\n select\n 'Missing enrollment_start_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is null\n),\n\nmissing_end_date as (\n select\n 'Missing enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is null\n),\n\ninvalid_start_date as (\n select\n 'Enrollment_start_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is not null\n and not {{ try_to_cast_date('enrollment_start_date') }} is not null\n),\n\ninvalid_end_date as (\n select\n 'Enrollment_end_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is not null\n and not {{ try_to_cast_date('enrollment_end_date') }} is not null\n),\n\nstart_after_end as (\n select\n 'Enrollment_start_date after enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date > enrollment_end_date\n),\n\nfuture_end_date as (\n select\n 'Future enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n {% if target.type == 'fabric' %}\n where enrollment_end_date > GETDATE()\n {% else %}\n where enrollment_end_date > current_date\n {% endif %}\n\n),\n\nnonsensical_dates as (\n select\n 'Nonsensical dates' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date < '1900-01-01'\n or enrollment_end_date < '1900-01-01'\n or enrollment_start_date > '2100-01-01'\n)\n\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_start_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_end_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_start_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_end_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from start_after_end\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from future_end_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from nonsensical_dates", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.the_tuva_project.try_to_cast_date"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__eligibility_date_checks.sql", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n\n, missing_start_date as (\n select\n 'Missing enrollment_start_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is null\n),\n\nmissing_end_date as (\n select\n 'Missing enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is null\n),\n\ninvalid_start_date as (\n select\n 'Enrollment_start_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is not null\n and not try_cast( enrollment_start_date as date ) is not null\n),\n\ninvalid_end_date as (\n select\n 'Enrollment_end_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is not null\n and not try_cast( enrollment_end_date as date ) is not null\n),\n\nstart_after_end as (\n select\n 'Enrollment_start_date after enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date > enrollment_end_date\n),\n\nfuture_end_date as (\n select\n 'Future enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n \n where enrollment_end_date > current_date\n \n\n),\n\nnonsensical_dates as (\n select\n 'Nonsensical dates' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date < '1900-01-01'\n or enrollment_end_date < '1900-01-01'\n or enrollment_start_date > '2100-01-01'\n)\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_start_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_end_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_start_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_end_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from start_after_end\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from future_end_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from nonsensical_dates", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__ed_classification": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__ed_classification", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__ed_classification.sql", "original_file_path": "models/data_quality/intermediate/data_quality__ed_classification.sql", "unique_id": "model.the_tuva_project.data_quality__ed_classification", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__ed_classification"], "alias": "data_quality_ed_classification", "checksum": {"name": "sha256", "checksum": "5cfef8a84e08dcfce945ed364588f0d7f6caf40fb32fe4697cce8bbf40697f8f"}, "config": {"enabled": true, "alias": "data_quality_ed_classification", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_ed_classification", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.9624362, "relation_name": "cms_synthetic.data_quality.data_quality_ed_classification", "raw_code": "{{ config(\n enabled = var('data_quality_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith cte as (\n select \n max(case when ed_classification_description = 'Emergent, ED Care Needed, Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_preventable,\n max(case when ed_classification_description = 'Emergent, Primary Care Treatable' then 1 else 0 end) as pc_treatable,\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Not Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_not_preventable,\n max(case when ed_classification_description = 'Non-Emergent' then 1 else 0 end) as non_emergent\n from {{ ref('ed_classification__summary') }}\n)\n\n,final as (\nselect 'ed classification missing ed_care_needed_preventable' as data_quality_check,\n case when ed_care_needed_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing pc_treatable' as data_quality_check,\n case when pc_treatable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing ed_care_needed_not_preventable' as data_quality_check,\n case when ed_care_needed_not_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing non_emergent' as data_quality_check,\n case when non_emergent = 0 then 1 else 0 end as result_count\nfrom cte\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "ed_classification__summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ed_classification__summary"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__ed_classification.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n max(case when ed_classification_description = 'Emergent, ED Care Needed, Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_preventable,\n max(case when ed_classification_description = 'Emergent, Primary Care Treatable' then 1 else 0 end) as pc_treatable,\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Not Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_not_preventable,\n max(case when ed_classification_description = 'Non-Emergent' then 1 else 0 end) as non_emergent\n from cms_synthetic.ed_classification.summary\n)\n\n,final as (\nselect 'ed classification missing ed_care_needed_preventable' as data_quality_check,\n case when ed_care_needed_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing pc_treatable' as data_quality_check,\n case when pc_treatable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing ed_care_needed_not_preventable' as data_quality_check,\n case when ed_care_needed_not_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing non_emergent' as data_quality_check,\n case when non_emergent = 0 then 1 else 0 end as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__cms_hcc_reference": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__cms_hcc_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__cms_hcc_reference.sql", "original_file_path": "models/data_quality/intermediate/data_quality__cms_hcc_reference.sql", "unique_id": "model.the_tuva_project.data_quality__cms_hcc_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__cms_hcc_reference"], "alias": "data_quality_cms_hcc_reference", "checksum": {"name": "sha256", "checksum": "0dd4394ff93aa43ce38f478ed69d728bd1fbfcb2500ed29e5335d04d5c761af1"}, "config": {"enabled": true, "alias": "data_quality_cms_hcc_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_cms_hcc_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.901889, "relation_name": "cms_synthetic.data_quality.data_quality_cms_hcc_reference", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\nselect avg(normalized_risk_score) data_source_value\n,cast('normalized risk score' as {{ dbt.type_string() }}) as analytics_measure\n,cast('cms-hcc' as {{ dbt.type_string() }}) as analytics_concept\nfrom {{ ref('cms_hcc__patient_risk_scores') }}\n)\n\nselect \n m.analytics_concept as analytics_concept\n,m.analytics_measure as analytics_measure\n,cte.data_source_value\n,m.analytics_value\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = 'cms-hcc'\nand\nm.analytics_measure = 'normalized risk score'", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_scores", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__cms_hcc_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(normalized_risk_score) data_source_value\n,cast('normalized risk score' as TEXT) as analytics_measure\n,cast('cms-hcc' as TEXT) as analytics_concept\nfrom cms_synthetic.cms_hcc.patient_risk_scores\n)\n\nselect \n m.analytics_concept as analytics_concept\n,m.analytics_measure as analytics_measure\n,cte.data_source_value\n,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = 'cms-hcc'\nand\nm.analytics_measure = 'normalized risk score'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__acute_inpatient_prevelence": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__acute_inpatient_prevelence", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__acute_inpatient_prevelence.sql", "original_file_path": "models/data_quality/intermediate/data_quality__acute_inpatient_prevelence.sql", "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__acute_inpatient_prevelence"], "alias": "data_quality_acute_inpatient_prevelence", "checksum": {"name": "sha256", "checksum": "350f1bcbe0f737f7b43f6a7bc29470d69a295aa7ee8236056327102d7908d1c1"}, "config": {"enabled": true, "alias": "data_quality_acute_inpatient_prevelence", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_acute_inpatient_prevelence", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.960823, "relation_name": "cms_synthetic.data_quality.data_quality_acute_inpatient_prevelence", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith total_cte as (\nselect cast(count(*) as {{ dbt.type_numeric() }} ) as total_encounters\nfrom {{ ref('core__encounter') }}\nwhere encounter_type = 'acute inpatient'\n) \n\n,cte as (\nselect \n {{ dbt.concat([\n 'ms_drg_code',\n \"' - '\",\n 'ms_drg_description'\n ]) }} as ms_drg_code_and_description\n ,cast('acute inpatient drg distribution' as {{ dbt.type_string() }} ) as analytics_concept\n ,cast(count(*) as {{ dbt.type_numeric() }} )/total_encounters as encounter_percent\n ,total_encounters\n ,row_number() over (order by count(*) desc) as rank_nbr\nfrom {{ ref('core__encounter') }}\ncross join total_cte \nwhere encounter_type = 'acute inpatient'\nand\nms_drg_code is not null\ngroup by \n {{ dbt.concat([\n 'ms_drg_code',\n \"' - '\",\n 'ms_drg_description'\n ]) }},\n total_encounters\n)\n\nselect \n cte.analytics_concept\n ,ms_drg_code_and_description as analytics_measure\n ,encounter_percent as data_source_value\n ,m.analytics_value\n ,rank_nbr as value_rank\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join cte on\nm.analytics_concept = cte.analytics_concept\nand\ncte.rank_nbr = m.value_rank\nwhere m.analytics_concept = 'acute inpatient drg distribution'\nand rank_nbr < 11", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__acute_inpatient_prevelence.sql", "compiled": true, "compiled_code": "\n\nwith total_cte as (\nselect cast(count(*) as numeric(28,6) ) as total_encounters\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n) \n\n,cte as (\nselect \n ms_drg_code || ' - ' || ms_drg_description as ms_drg_code_and_description\n ,cast('acute inpatient drg distribution' as TEXT ) as analytics_concept\n ,cast(count(*) as numeric(28,6) )/total_encounters as encounter_percent\n ,total_encounters\n ,row_number() over (order by count(*) desc) as rank_nbr\nfrom cms_synthetic.core.encounter\ncross join total_cte \nwhere encounter_type = 'acute inpatient'\nand\nms_drg_code is not null\ngroup by \n ms_drg_code || ' - ' || ms_drg_description,\n total_encounters\n)\n\nselect \n cte.analytics_concept\n ,ms_drg_code_and_description as analytics_measure\n ,encounter_percent as data_source_value\n ,m.analytics_value\n ,rank_nbr as value_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on\nm.analytics_concept = cte.analytics_concept\nand\ncte.rank_nbr = m.value_rank\nwhere m.analytics_concept = 'acute inpatient drg distribution'\nand rank_nbr < 11", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_date_checks": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medical_claim_date_checks", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__medical_claim_date_checks.sql", "original_file_path": "models/data_quality/intermediate/data_quality__medical_claim_date_checks.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_date_checks", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_date_checks"], "alias": "medical_claim_date_checks", "checksum": {"name": "sha256", "checksum": "575b4b9b9acf27244c688c484bbcffdab4428c3a11405f05135d4187a42e32d7"}, "config": {"enabled": true, "alias": "medical_claim_date_checks", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_date_checks", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.884167, "relation_name": "cms_synthetic.data_quality.medical_claim_date_checks", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\nwith medical_claim as (\n select m.claim_id,\n max(case when claim_start_date is null then 1 else 0 end) as missing_claim_start_date,\n max(case when claim_end_date is null then 1 else 0 end) as missing_claim_end_date,\n max(case when claim_line_start_date is null then 1 else 0 end) as missing_claim_line_start_date,\n max(case when claim_line_end_date is null then 1 else 0 end) as missing_claim_line_end_date,\n max(case when admission_date is null and d.claim_id is not null then 1 else 0 end) as missing_admission_date,\n max(case when discharge_date is null and d.claim_id is not null then 1 else 0 end) as missing_discharge_date,\n max(case when paid_date is null then 1 else 0 end) as missing_paid_date,\n count(distinct case when d.claim_id is not null then claim_start_date else null end) as claim_start_count,\n count(distinct case when d.claim_id is not null then claim_end_date else null end) as claim_end_count,\n count(distinct case when d.claim_id is not null then admission_date else null end) as admission_date_count,\n count(distinct case when d.claim_id is not null then discharge_date else null end) as discharge_date_count\n from {{ ref('medical_claim')}} m\n left join {{ ref('data_quality__inpatient_dq_stage')}} d on m.claim_id = d.claim_id\n group by m.claim_id\n)\n\n,final as (\nselect 'missing claim_start_date' as data_quality_check,\n sum(missing_claim_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_end_date' as data_quality_check,\n sum(missing_claim_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_start_date' as data_quality_check,\n sum(missing_claim_line_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_end_date' as data_quality_check,\n sum(missing_claim_line_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing admission_date' as data_quality_check,\n sum(missing_admission_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing discharge_date' as data_quality_check,\n sum(missing_discharge_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing medical_claim paid_date' as data_quality_check,\n sum(missing_paid_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'claim start multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_start_count > 1\n\nunion all\n\nselect 'claim end multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_end_count > 1\n\nunion all\n\nselect 'admission date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere admission_date_count > 1\n\nunion all\n\nselect 'discharge date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere discharge_date_count > 1\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "data_quality__inpatient_dq_stage", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__medical_claim_date_checks.sql", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select m.claim_id,\n max(case when claim_start_date is null then 1 else 0 end) as missing_claim_start_date,\n max(case when claim_end_date is null then 1 else 0 end) as missing_claim_end_date,\n max(case when claim_line_start_date is null then 1 else 0 end) as missing_claim_line_start_date,\n max(case when claim_line_end_date is null then 1 else 0 end) as missing_claim_line_end_date,\n max(case when admission_date is null and d.claim_id is not null then 1 else 0 end) as missing_admission_date,\n max(case when discharge_date is null and d.claim_id is not null then 1 else 0 end) as missing_discharge_date,\n max(case when paid_date is null then 1 else 0 end) as missing_paid_date,\n count(distinct case when d.claim_id is not null then claim_start_date else null end) as claim_start_count,\n count(distinct case when d.claim_id is not null then claim_end_date else null end) as claim_end_count,\n count(distinct case when d.claim_id is not null then admission_date else null end) as admission_date_count,\n count(distinct case when d.claim_id is not null then discharge_date else null end) as discharge_date_count\n from tuva.input_layer.medical_claim m\n left join cms_synthetic.data_quality.data_quality__inpatient_dq_stage d on m.claim_id = d.claim_id\n group by m.claim_id\n)\n\n,final as (\nselect 'missing claim_start_date' as data_quality_check,\n sum(missing_claim_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_end_date' as data_quality_check,\n sum(missing_claim_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_start_date' as data_quality_check,\n sum(missing_claim_line_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_end_date' as data_quality_check,\n sum(missing_claim_line_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing admission_date' as data_quality_check,\n sum(missing_admission_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing discharge_date' as data_quality_check,\n sum(missing_discharge_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing medical_claim paid_date' as data_quality_check,\n sum(missing_paid_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'claim start multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_start_count > 1\n\nunion all\n\nselect 'claim end multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_end_count > 1\n\nunion all\n\nselect 'admission date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere admission_date_count > 1\n\nunion all\n\nselect 'discharge date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere discharge_date_count > 1\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_missing_payer": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_missing_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__eligibility_missing_payer.sql", "original_file_path": "models/data_quality/intermediate/data_quality__eligibility_missing_payer.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_payer", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_missing_payer"], "alias": "eligibility_missing_payer", "checksum": {"name": "sha256", "checksum": "36bbe3965e9e23a566152e67d250818c8f61077458f4d09ffe763f419becb020"}, "config": {"enabled": true, "alias": "eligibility_missing_payer", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_missing_payer", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.857492, "relation_name": "cms_synthetic.data_quality.eligibility_missing_payer", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\nwith eligibility_spans as(\n select distinct\n {{ dbt.concat([\n \"member_id\",\n \"'-'\",\n \"enrollment_start_date\",\n \"'-'\",\n \"enrollment_end_date\",\n \"'-'\",\n \"payer\",\n \"'-'\",\n quote_column('plan'),\n ]) }} as eligibility_span_id\n , payer\n , payer_type\n from {{ ref('eligibility') }}\n)\n\n, missing_payer_type as(\n select\n 'Missing payer type' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer_type is null\n)\n, missing_payer_name as(\n select\n 'Missing payer name' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer is null\n)\n, invalid_payer_type as(\n select\n 'Payer type does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join {{ ref('terminology__payer_type') }} pt\n on e.payer_type = pt.payer_type\n where pt.payer_type is null\n)\n\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from missing_payer_type\nunion all\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from missing_payer_name\nunion all\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_payer_type", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__payer_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__eligibility_missing_payer.sql", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , payer\n , payer_type\n from tuva.input_layer.eligibility\n)\n\n, missing_payer_type as(\n select\n 'Missing payer type' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer_type is null\n)\n, missing_payer_name as(\n select\n 'Missing payer name' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer is null\n)\n, invalid_payer_type as(\n select\n 'Payer type does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join cms_synthetic.terminology.payer_type pt\n on e.payer_type = pt.payer_type\n where pt.payer_type is null\n)\n\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_payer_type\nunion all\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_payer_name\nunion all\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_payer_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_missing_groups": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounters_missing_groups", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__encounters_missing_groups.sql", "original_file_path": "models/data_quality/intermediate/data_quality__encounters_missing_groups.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__encounters_missing_groups"], "alias": "encounters_missing_groups", "checksum": {"name": "sha256", "checksum": "b875e9dbd63b9dc250e99b36629810505152f4dc17af0896712cdcf52e197f5e"}, "config": {"enabled": true, "alias": "encounters_missing_groups", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_missing_groups", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.8620229, "relation_name": "cms_synthetic.data_quality.encounters_missing_groups", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\n) }}\n\nwith expected_groups as (\n select 'inpatient' as encounter_group\n union all\n select 'outpatient'\n union all\n select 'office based'\n union all\n select 'other'\n)\n\n, actual_groups as (\n select distinct\n encounter_group\n from {{ ref('core__encounter') }}\n)\n\nselect\n e.encounter_group as missing_encounter_group\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom expected_groups e\n left join actual_groups a\n on e.encounter_group = a.encounter_group\nwhere a.encounter_group is null", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__encounters_missing_groups.sql", "compiled": true, "compiled_code": "\n\nwith expected_groups as (\n select 'inpatient' as encounter_group\n union all\n select 'outpatient'\n union all\n select 'office based'\n union all\n select 'other'\n)\n\n, actual_groups as (\n select distinct\n encounter_group\n from cms_synthetic.core.encounter\n)\n\nselect\n e.encounter_group as missing_encounter_group\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom expected_groups e\n left join actual_groups a\n on e.encounter_group = a.encounter_group\nwhere a.encounter_group is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__readmissions_reference": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__readmissions_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__readmissions_reference.sql", "original_file_path": "models/data_quality/intermediate/data_quality__readmissions_reference.sql", "unique_id": "model.the_tuva_project.data_quality__readmissions_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__readmissions_reference"], "alias": "data_quality_readmissions_reference", "checksum": {"name": "sha256", "checksum": "0e178609373ae7d82add36157d3c83a0b4879a397668783b19afe7a9316743d7"}, "config": {"enabled": true, "alias": "data_quality_readmissions_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_readmissions_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.897609, "relation_name": "cms_synthetic.data_quality.data_quality_readmissions_reference", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\nselect \n cast('readmission rate' as {{dbt.type_string()}}) as analytics_measure\n ,cast('readmissions' as {{dbt.type_string()}}) as analytics_concept\n ,sum(unplanned_readmit_30_flag)/cast(count(*) as {{dbt.type_numeric() }} ) as data_source_value\nfrom {{ ref('readmissions__readmission_summary') }} r \nwhere index_admission_flag = 1\n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('readmissions' as {{dbt.type_string()}})", "language": "sql", "refs": [{"name": "readmissions__readmission_summary", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.readmissions__readmission_summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__readmissions_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('readmission rate' as TEXT) as analytics_measure\n ,cast('readmissions' as TEXT) as analytics_concept\n ,sum(unplanned_readmit_30_flag)/cast(count(*) as numeric(28,6) ) as data_source_value\nfrom cms_synthetic.readmissions.readmission_summary r \nwhere index_admission_flag = 1\n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('readmissions' as TEXT)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__pharmacy_claim_npi.sql", "original_file_path": "models/data_quality/intermediate/data_quality__pharmacy_claim_npi.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_npi", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_npi"], "alias": "pharmacy_claim_npi", "checksum": {"name": "sha256", "checksum": "c4b57a2a3213fe6452fd4d8148fa86b3d2becd11ce5d2899cc4ebcef806b1efd"}, "config": {"enabled": true, "alias": "pharmacy_claim_npi", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_npi", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.877569, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n )\n}}\n\nwith pharmacy_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.prescribing_provider_npi is not null then 1 else 0 end) as invalid_prescribing_npi\n , max(case when m.prescribing_provider_npi is null then 1 else 0 end) as missing_prescribing_npi\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_prescribing_npi\n , max(case when term2.npi is null and m.dispensing_provider_npi is not null then 1 else 0 end) as invalid_dispensing_npi\n , max(case when m.dispensing_provider_npi is null then 1 else 0 end) as missing_dispensing_npi\n , max(case when term2.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_dispensing_npi\n from {{ ref('pharmacy_claim') }} as m\n left join {{ ref('terminology__provider') }} as term\n on m.prescribing_provider_npi = term.npi\n left join {{ ref('terminology__provider') }} as term2\n on m.dispensing_provider_npi = term2.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid prescribing_npi' as data_quality_check\n , sum(invalid_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing prescribing_npi' as data_quality_check\n , sum(missing_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type prescribing_npi' as data_quality_check\n , sum(wrong_entity_type_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'invalid dispensing_npi' as data_quality_check\n , sum(invalid_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing dispensing_npi' as data_quality_check\n , sum(missing_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type dispensing_npi' as data_quality_check\n , sum(wrong_entity_type_dispensing_npi) as result_count\nfrom pharmacy_claim\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__pharmacy_claim_npi.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.prescribing_provider_npi is not null then 1 else 0 end) as invalid_prescribing_npi\n , max(case when m.prescribing_provider_npi is null then 1 else 0 end) as missing_prescribing_npi\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_prescribing_npi\n , max(case when term2.npi is null and m.dispensing_provider_npi is not null then 1 else 0 end) as invalid_dispensing_npi\n , max(case when m.dispensing_provider_npi is null then 1 else 0 end) as missing_dispensing_npi\n , max(case when term2.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_dispensing_npi\n from tuva.input_layer.pharmacy_claim as m\n left join cms_synthetic.terminology.provider as term\n on m.prescribing_provider_npi = term.npi\n left join cms_synthetic.terminology.provider as term2\n on m.dispensing_provider_npi = term2.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid prescribing_npi' as data_quality_check\n , sum(invalid_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing prescribing_npi' as data_quality_check\n , sum(missing_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type prescribing_npi' as data_quality_check\n , sum(wrong_entity_type_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'invalid dispensing_npi' as data_quality_check\n , sum(invalid_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing dispensing_npi' as data_quality_check\n , sum(missing_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type dispensing_npi' as data_quality_check\n , sum(wrong_entity_type_dispensing_npi) as result_count\nfrom pharmacy_claim\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medical_claim_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__medical_claim_patient_id.sql", "original_file_path": "models/data_quality/intermediate/data_quality__medical_claim_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_patient_id", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_patient_id"], "alias": "medical_claim_patient_id", "checksum": {"name": "sha256", "checksum": "b494e63b3b67f455773d1b7816a94bcfc679707382e7daf1ea264faa6f3ba561"}, "config": {"enabled": true, "alias": "medical_claim_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_patient_id", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.882593, "relation_name": "cms_synthetic.data_quality.medical_claim_patient_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith medical as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(\n case \n when startdts.month_start_date is null then 1\n when enddts.month_start_date is null then 1\n else 0\n end\n ) as missing_eligibility\n from {{ ref('medical_claim') }} p\n left join {{ ref('data_quality__eligibility_dq_stage') }} startdts\n on p.patient_id = startdts.patient_id\n and p.claim_start_date between startdts.month_start_date and startdts.month_end_date\n left join {{ ref('data_quality__eligibility_dq_stage') }} enddts\n on p.patient_id = enddts.patient_id\n and p.claim_end_date between enddts.month_start_date and enddts.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple medical_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from medical\n\n union all\n\n select\n 'missing medical_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from medical\n\n union all\n\n select\n 'orphaned medical_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from medical\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__medical_claim_patient_id.sql", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(\n case \n when startdts.month_start_date is null then 1\n when enddts.month_start_date is null then 1\n else 0\n end\n ) as missing_eligibility\n from tuva.input_layer.medical_claim p\n left join cms_synthetic.data_quality.data_quality__eligibility_dq_stage startdts\n on p.patient_id = startdts.patient_id\n and p.claim_start_date between startdts.month_start_date and startdts.month_end_date\n left join cms_synthetic.data_quality.data_quality__eligibility_dq_stage enddts\n on p.patient_id = enddts.patient_id\n and p.claim_end_date between enddts.month_start_date and enddts.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple medical_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from medical\n\n union all\n\n select\n 'missing medical_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from medical\n\n union all\n\n select\n 'orphaned medical_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from medical\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medical_claim_claim_line_fields", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__medical_claim_claim_line_fields.sql", "original_file_path": "models/data_quality/intermediate/data_quality__medical_claim_claim_line_fields.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_claim_line_fields"], "alias": "medical_claim_claim_line_fields", "checksum": {"name": "sha256", "checksum": "15ce4a0796be5b8501860ad72aec59f607a7368eb3ef526d101fdcf22459b546"}, "config": {"enabled": true, "alias": "medical_claim_claim_line_fields", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_claim_line_fields", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.88685, "relation_name": "cms_synthetic.data_quality.medical_claim_claim_line_fields", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when hcpc.hcpcs is null and m.hcpcs_code is not null then 1 else 0 end) as invalid_hcpcs_code\n , max(case when m.claim_type = 'professional' and pos.place_of_service_code is null and m.place_of_service_code is not null then 1 else 0 end) as invalid_place_of_service_code\n , max(case when m.claim_type = 'institutional' and rev.revenue_center_code is null and m.revenue_center_code is not null then 1 else 0 end) as invalid_revenue_center_code\n , max(case when m.hcpcs_code is null then 1 else 0 end) as missing_hcpcs_code\n , max(case when m.claim_type = 'professional' and m.place_of_service_code is null then 1 else 0 end) as missing_place_of_service_code\n , max(case when m.claim_type = 'institutional' and m.revenue_center_code is null then 1 else 0 end) as missing_revenue_center_code\n from {{ ref('medical_claim') }} as m\n left join {{ ref('terminology__hcpcs_level_2') }} as hcpc\n on m.hcpcs_code = hcpc.hcpcs\n left join {{ ref('terminology__place_of_service') }} as pos\n on m.place_of_service_code = pos.place_of_service_code\n left join {{ ref('terminology__revenue_center') }} as rev\n on m.revenue_center_code = rev.revenue_center_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid hcpcs_code' as data_quality_check\n , sum(invalid_hcpcs_code) as result_count\n from medical_claim\n \n union all\n\n select\n 'invalid place_of_service_code' as data_quality_check\n , sum(invalid_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'invalid revenue_center_code' as data_quality_check\n , sum(invalid_revenue_center_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing hcpcs_code' as data_quality_check\n , sum(missing_hcpcs_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing place_of_service_code' as data_quality_check\n , sum(missing_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing revenue_center_code' as data_quality_check\n , sum(missing_revenue_center_code) as result_count\n from medical_claim\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__revenue_center"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__medical_claim_claim_line_fields.sql", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when hcpc.hcpcs is null and m.hcpcs_code is not null then 1 else 0 end) as invalid_hcpcs_code\n , max(case when m.claim_type = 'professional' and pos.place_of_service_code is null and m.place_of_service_code is not null then 1 else 0 end) as invalid_place_of_service_code\n , max(case when m.claim_type = 'institutional' and rev.revenue_center_code is null and m.revenue_center_code is not null then 1 else 0 end) as invalid_revenue_center_code\n , max(case when m.hcpcs_code is null then 1 else 0 end) as missing_hcpcs_code\n , max(case when m.claim_type = 'professional' and m.place_of_service_code is null then 1 else 0 end) as missing_place_of_service_code\n , max(case when m.claim_type = 'institutional' and m.revenue_center_code is null then 1 else 0 end) as missing_revenue_center_code\n from tuva.input_layer.medical_claim as m\n left join cms_synthetic.terminology.hcpcs_level_2 as hcpc\n on m.hcpcs_code = hcpc.hcpcs\n left join cms_synthetic.terminology.place_of_service as pos\n on m.place_of_service_code = pos.place_of_service_code\n left join cms_synthetic.terminology.revenue_center as rev\n on m.revenue_center_code = rev.revenue_center_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid hcpcs_code' as data_quality_check\n , sum(invalid_hcpcs_code) as result_count\n from medical_claim\n \n union all\n\n select\n 'invalid place_of_service_code' as data_quality_check\n , sum(invalid_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'invalid revenue_center_code' as data_quality_check\n , sum(invalid_revenue_center_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing hcpcs_code' as data_quality_check\n , sum(missing_hcpcs_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing place_of_service_code' as data_quality_check\n , sum(missing_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing revenue_center_code' as data_quality_check\n , sum(missing_revenue_center_code) as result_count\n from medical_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__pharmacy_claim_patient_id.sql", "original_file_path": "models/data_quality/intermediate/data_quality__pharmacy_claim_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_patient_id"], "alias": "pharmacy_claim_patient_id", "checksum": {"name": "sha256", "checksum": "fe759854c820c55ced015b8e7bbeebadc6ccb4a7ef7c0f3e605ce85d67e43135"}, "config": {"enabled": true, "alias": "pharmacy_claim_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_patient_id", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.8716538, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_patient_id", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith pharmacy as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(case when e.month_start_date is null then 1 else 0 end) as missing_eligibility\n from {{ ref('pharmacy_claim') }} p\n left join {{ ref('data_quality__eligibility_dq_stage') }} e\n on p.patient_id = e.patient_id\n and coalesce(p.paid_date, p.dispensing_date) between e.month_start_date and e.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple pharmacy_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from pharmacy\n\n union all\n\n select\n 'missing pharmacy_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from pharmacy\n\n union all\n\n select\n 'orphaned pharmacy_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from pharmacy\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__pharmacy_claim_patient_id.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(case when e.month_start_date is null then 1 else 0 end) as missing_eligibility\n from tuva.input_layer.pharmacy_claim p\n left join cms_synthetic.data_quality.data_quality__eligibility_dq_stage e\n on p.patient_id = e.patient_id\n and coalesce(p.paid_date, p.dispensing_date) between e.month_start_date and e.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple pharmacy_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from pharmacy\n\n union all\n\n select\n 'missing pharmacy_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from pharmacy\n\n union all\n\n select\n 'orphaned pharmacy_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from pharmacy\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__acute_inpatient": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__acute_inpatient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__acute_inpatient.sql", "original_file_path": "models/data_quality/intermediate/data_quality__acute_inpatient.sql", "unique_id": "model.the_tuva_project.data_quality__acute_inpatient", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__acute_inpatient"], "alias": "data_quality_acute_inpatient", "checksum": {"name": "sha256", "checksum": "5bc8ac91b878126f2505de1c0c842e9f56945a36f1f61925143776871cbf39e1"}, "config": {"enabled": true, "alias": "data_quality_acute_inpatient", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_acute_inpatient", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.9593658, "relation_name": "cms_synthetic.data_quality.data_quality_acute_inpatient", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\n select count(*) as result_count\n ,'inpatient encounter missing professional claim' as data_quality_check\n from {{ ref('core__encounter') }}\n where encounter_type = 'acute inpatient'\n and prof_claim_count = 0 \n)\n\n\nselect data_quality_check\n,result_count\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom cte", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__acute_inpatient.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select count(*) as result_count\n ,'inpatient encounter missing professional claim' as data_quality_check\n from cms_synthetic.core.encounter\n where encounter_type = 'acute inpatient'\n and prof_claim_count = 0 \n)\n\n\nselect data_quality_check\n,result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_date_checks", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__pharmacy_claim_date_checks.sql", "original_file_path": "models/data_quality/intermediate/data_quality__pharmacy_claim_date_checks.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_date_checks"], "alias": "pharmacy_claim_date_checks", "checksum": {"name": "sha256", "checksum": "4220c2de89fb7f22d94f313c9cb60e055fa444ae4714560044e89290f09b778f"}, "config": {"enabled": true, "alias": "pharmacy_claim_date_checks", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_date_checks", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.873155, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_date_checks", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when paid_date is null then 1 else 0 end) as missing_paid_date\n , max(case when dispensing_date is null then 1 else 0 end) as missing_dispensing_date\n from {{ ref('pharmacy_claim') }}\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing pharmacy_claim paid_date' as data_quality_check\n , sum(missing_paid_date) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing dispensing_date' as data_quality_check\n , sum(missing_dispensing_date) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__pharmacy_claim_date_checks.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when paid_date is null then 1 else 0 end) as missing_paid_date\n , max(case when dispensing_date is null then 1 else 0 end) as missing_dispensing_date\n from tuva.input_layer.pharmacy_claim\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing pharmacy_claim paid_date' as data_quality_check\n , sum(missing_paid_date) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing dispensing_date' as data_quality_check\n , sum(missing_dispensing_date) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_demographics": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_demographics", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__eligibility_demographics.sql", "original_file_path": "models/data_quality/intermediate/data_quality__eligibility_demographics.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_demographics", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_demographics"], "alias": "eligibility_demographics", "checksum": {"name": "sha256", "checksum": "f8452240222193079c12aae888c17824053c46d3781210e46765927bcf58eb4f"}, "config": {"enabled": true, "alias": "eligibility_demographics", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria (multiple birth dates\ncount unique members)\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_demographics", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.85478, "relation_name": "cms_synthetic.data_quality.eligibility_demographics", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nwith eligibility_spans as(\n select distinct\n {{ dbt.concat([\n \"member_id\",\n \"'-'\",\n \"enrollment_start_date\",\n \"'-'\",\n \"enrollment_end_date\",\n \"'-'\",\n \"payer\",\n \"'-'\",\n quote_column('plan'),\n ]) }} as eligibility_span_id\n , patient_id\n , birth_date\n , gender\n from {{ ref('eligibility') }}\n)\n\n, missing_birth_date as(\n select\n 'Missing birthday' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_birth_date as(\n select\n 'Birthday is not a valid date' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join reference_data.calendar c\n on e.birth_date = c.full_date\n where c.full_date is null\n)\n, future_birth_date as(\n select\n 'Birthday is in the future' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n {% if target.type == 'fabric' %}\n where birth_date > GETDATE()\n {% else %}\n where birth_date > current_date\n {% endif %}\n)\n, past_birth_date as(\n select\n 'Birthday is too far in the past' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n {% if target.type == 'fabric' %}\n where cast(floor({{ datediff('birth_date', 'getdate()', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) > 110\n {% else %}\n where cast(floor({{ datediff('birth_date', 'current_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) > 110\n {% endif %}\n\n)\n, multiple_birth_date as(\n select\n 'Patient has multiple birthdays' as data_quality_check\n , count(distinct patient_id) as result_count\n from(\n select\n patient_id\n , birth_date\n , rank() over (partition by patient_id, birth_date order by birth_date) as rank_birth_date\n from eligibility_spans e\n where birth_date is not null\n )x\nwhere rank_birth_date > 1\n)\n, missing_gender as(\n select\n 'Missing gender' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_gender as(\n select\n 'Patient gender does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_birth_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_birth_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from future_birth_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from past_birth_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from multiple_birth_date\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_gender\nunion all\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_gender", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.datediff", "macro.dbt.type_int"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__eligibility_demographics.sql", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n , birth_date\n , gender\n from tuva.input_layer.eligibility\n)\n\n, missing_birth_date as(\n select\n 'Missing birthday' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_birth_date as(\n select\n 'Birthday is not a valid date' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join reference_data.calendar c\n on e.birth_date = c.full_date\n where c.full_date is null\n)\n, future_birth_date as(\n select\n 'Birthday is in the future' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where birth_date > current_date\n \n)\n, past_birth_date as(\n select\n 'Birthday is too far in the past' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where cast(floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8760.0) as integer ) > 110\n \n\n)\n, multiple_birth_date as(\n select\n 'Patient has multiple birthdays' as data_quality_check\n , count(distinct patient_id) as result_count\n from(\n select\n patient_id\n , birth_date\n , rank() over (partition by patient_id, birth_date order by birth_date) as rank_birth_date\n from eligibility_spans e\n where birth_date is not null\n )x\nwhere rank_birth_date > 1\n)\n, missing_gender as(\n select\n 'Missing gender' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_gender as(\n select\n 'Patient gender does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from future_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from past_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from multiple_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_gender\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_gender", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_prescription_details", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__pharmacy_claim_prescription_details.sql", "original_file_path": "models/data_quality/intermediate/data_quality__pharmacy_claim_prescription_details.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_prescription_details"], "alias": "pharmacy_claim_prescription_details", "checksum": {"name": "sha256", "checksum": "720bfdc7123888657a493d9fc702174c1218b5529c97dad7e2befa13c6cbb529"}, "config": {"enabled": true, "alias": "pharmacy_claim_prescription_details", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_prescription_details", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.875982, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_prescription_details", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case \n when quantity is null then 1\n when quantity = 0 then 1\n else 0\n end) as missing_quantity\n , max(case \n when days_supply is null then 1\n when days_supply = 0 then 1\n else 0\n end) as missing_days_supply\n , max(case \n when refills is null then 1\n else 0\n end) as missing_refills\n from {{ ref('pharmacy_claim') }} m\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing quantity' as data_quality_check\n , sum(missing_quantity) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing days supply' as data_quality_check\n , sum(missing_days_supply) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing refills' as data_quality_check\n , sum(missing_refills) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__pharmacy_claim_prescription_details.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case \n when quantity is null then 1\n when quantity = 0 then 1\n else 0\n end) as missing_quantity\n , max(case \n when days_supply is null then 1\n when days_supply = 0 then 1\n else 0\n end) as missing_days_supply\n , max(case \n when refills is null then 1\n else 0\n end) as missing_refills\n from tuva.input_layer.pharmacy_claim m\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing quantity' as data_quality_check\n , sum(missing_quantity) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing days supply' as data_quality_check\n , sum(missing_days_supply) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing refills' as data_quality_check\n , sum(missing_refills) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medical_claim_inst_header_fields", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__medical_claim_inst_header_fields.sql", "original_file_path": "models/data_quality/intermediate/data_quality__medical_claim_inst_header_fields.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_inst_header_fields"], "alias": "medical_claim_inst_header_fields", "checksum": {"name": "sha256", "checksum": "b4720bf5147d5ba4aee7741169dd9e9e8eac0b467c93dd265d36e44e5640b51c"}, "config": {"enabled": true, "alias": "medical_claim_inst_header_fields", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_inst_header_fields", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.885514, "relation_name": "cms_synthetic.data_quality.medical_claim_inst_header_fields", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith inst_header as (\n select\n m.claim_id\n , max(case when m.claim_type = 'institutional' and btc.bill_type_code is null and m.bill_type_code is not null then 1 else 0 end) as invalid_bill_type_code\n , max(case when m.claim_type = 'institutional' and dd.discharge_disposition_code is null and m.discharge_disposition_code is not null then 1 else 0 end) as invalid_discharge_disposition_code\n , max(case when d.claim_id is not null and ms.ms_drg_code is null and m.ms_drg_code is not null then 1 else 0 end) as invalid_ms_drg_code\n , max(case when d.claim_id is not null and apr.apr_drg_code is null and m.apr_drg_code is not null then 1 else 0 end) as invalid_apr_drg_code\n , max(case when m.claim_type = 'institutional' and m.bill_type_code is null then 1 else 0 end) as missing_bill_type_code\n , max(case when m.claim_type = 'institutional' and m.discharge_disposition_code is null then 1 else 0 end) as missing_discharge_disposition_code\n , max(case when d.claim_id is not null and m.ms_drg_code is null then 1 else 0 end) as missing_ms_drg_code\n , max(case when d.claim_id is not null and m.apr_drg_code is null then 1 else 0 end) as missing_apr_drg_code\n , count(distinct case when m.claim_type = 'institutional' then m.bill_type_code else null end) as bill_type_code_count\n , count(distinct case when m.claim_type = 'institutional' then m.discharge_disposition_code else null end) as discharge_disposition_code_count\n , count(distinct case when d.claim_id is not null then m.ms_drg_code else null end) as ms_drg_code_count\n , count(distinct case when d.claim_id is not null then m.apr_drg_code else null end) as apr_drg_code_count\n from {{ ref('medical_claim') }} as m\n left join {{ ref('data_quality__inpatient_dq_stage') }} as d\n on m.claim_id = d.claim_id\n left join {{ ref('terminology__bill_type') }} as btc\n on m.bill_type_code = btc.bill_type_code\n left join {{ ref('terminology__ms_drg') }} as ms\n on m.ms_drg_code = ms.ms_drg_code\n left join {{ ref('terminology__apr_drg') }} as apr\n on m.ms_drg_code = apr.apr_drg_code\n left join {{ ref('terminology__discharge_disposition') }} as dd\n on m.discharge_disposition_code = dd.discharge_disposition_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid bill_type_code' as data_quality_check\n , sum(invalid_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid ms_drg_code' as data_quality_check\n , sum(invalid_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid apr_drg_code' as data_quality_check\n , sum(invalid_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid discharge_disposition_code' as data_quality_check\n , sum(invalid_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing bill_type_code' as data_quality_check\n , sum(missing_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing ms_drg_code' as data_quality_check\n , sum(missing_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing apr_drg_code' as data_quality_check\n , sum(missing_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing discharge_disposition_code' as data_quality_check\n , sum(missing_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'bill_type_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where bill_type_code_count > 1\n\n union all\n\n select\n 'ms_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where ms_drg_code_count > 1\n\n union all\n\n select\n 'apr_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where apr_drg_code_count > 1\n\n union all\n\n select\n 'discharge_disposition_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where discharge_disposition_code_count > 1\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "data_quality__inpatient_dq_stage", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__medical_claim_inst_header_fields.sql", "compiled": true, "compiled_code": "\n\nwith inst_header as (\n select\n m.claim_id\n , max(case when m.claim_type = 'institutional' and btc.bill_type_code is null and m.bill_type_code is not null then 1 else 0 end) as invalid_bill_type_code\n , max(case when m.claim_type = 'institutional' and dd.discharge_disposition_code is null and m.discharge_disposition_code is not null then 1 else 0 end) as invalid_discharge_disposition_code\n , max(case when d.claim_id is not null and ms.ms_drg_code is null and m.ms_drg_code is not null then 1 else 0 end) as invalid_ms_drg_code\n , max(case when d.claim_id is not null and apr.apr_drg_code is null and m.apr_drg_code is not null then 1 else 0 end) as invalid_apr_drg_code\n , max(case when m.claim_type = 'institutional' and m.bill_type_code is null then 1 else 0 end) as missing_bill_type_code\n , max(case when m.claim_type = 'institutional' and m.discharge_disposition_code is null then 1 else 0 end) as missing_discharge_disposition_code\n , max(case when d.claim_id is not null and m.ms_drg_code is null then 1 else 0 end) as missing_ms_drg_code\n , max(case when d.claim_id is not null and m.apr_drg_code is null then 1 else 0 end) as missing_apr_drg_code\n , count(distinct case when m.claim_type = 'institutional' then m.bill_type_code else null end) as bill_type_code_count\n , count(distinct case when m.claim_type = 'institutional' then m.discharge_disposition_code else null end) as discharge_disposition_code_count\n , count(distinct case when d.claim_id is not null then m.ms_drg_code else null end) as ms_drg_code_count\n , count(distinct case when d.claim_id is not null then m.apr_drg_code else null end) as apr_drg_code_count\n from tuva.input_layer.medical_claim as m\n left join cms_synthetic.data_quality.data_quality__inpatient_dq_stage as d\n on m.claim_id = d.claim_id\n left join cms_synthetic.terminology.bill_type as btc\n on m.bill_type_code = btc.bill_type_code\n left join cms_synthetic.terminology.ms_drg as ms\n on m.ms_drg_code = ms.ms_drg_code\n left join cms_synthetic.terminology.apr_drg as apr\n on m.ms_drg_code = apr.apr_drg_code\n left join cms_synthetic.terminology.discharge_disposition as dd\n on m.discharge_disposition_code = dd.discharge_disposition_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid bill_type_code' as data_quality_check\n , sum(invalid_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid ms_drg_code' as data_quality_check\n , sum(invalid_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid apr_drg_code' as data_quality_check\n , sum(invalid_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid discharge_disposition_code' as data_quality_check\n , sum(invalid_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing bill_type_code' as data_quality_check\n , sum(missing_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing ms_drg_code' as data_quality_check\n , sum(missing_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing apr_drg_code' as data_quality_check\n , sum(missing_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing discharge_disposition_code' as data_quality_check\n , sum(missing_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'bill_type_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where bill_type_code_count > 1\n\n union all\n\n select\n 'ms_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where ms_drg_code_count > 1\n\n union all\n\n select\n 'apr_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where apr_drg_code_count > 1\n\n union all\n\n select\n 'discharge_disposition_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where discharge_disposition_code_count > 1\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_ndc": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__pharmacy_claim_ndc", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__pharmacy_claim_ndc.sql", "original_file_path": "models/data_quality/intermediate/data_quality__pharmacy_claim_ndc.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_ndc"], "alias": "pharmacy_claim_ndc", "checksum": {"name": "sha256", "checksum": "99212f81065c1ab170548041095b0d0b214ed80a24348c3bb06eb5645095a44d"}, "config": {"enabled": true, "alias": "pharmacy_claim_ndc", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_ndc", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.874493, "relation_name": "cms_synthetic.data_quality.pharmacy_claim_ndc", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when term.ndc is null and m.ndc_code is not null then 1 else 0 end) as invalid_ndc\n , max(case when m.ndc_code is null then 1 else 0 end) as missing_ndc\n from {{ ref('pharmacy_claim') }} m\n left join {{ ref('terminology__ndc') }} as term\n on m.ndc_code = term.ndc\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing ndc' as data_quality_check\n , sum(missing_ndc) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'invalid ndc' as data_quality_check\n , sum(invalid_ndc) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__pharmacy_claim_ndc.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when term.ndc is null and m.ndc_code is not null then 1 else 0 end) as invalid_ndc\n , max(case when m.ndc_code is null then 1 else 0 end) as missing_ndc\n from tuva.input_layer.pharmacy_claim m\n left join cms_synthetic.terminology.ndc as term\n on m.ndc_code = term.ndc\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing ndc' as data_quality_check\n , sum(missing_ndc) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'invalid ndc' as data_quality_check\n , sum(invalid_ndc) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__cms_hcc": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__cms_hcc", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__cms_hcc.sql", "original_file_path": "models/data_quality/intermediate/data_quality__cms_hcc.sql", "unique_id": "model.the_tuva_project.data_quality__cms_hcc", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__cms_hcc"], "alias": "data_quality_cms_hcc", "checksum": {"name": "sha256", "checksum": "f19a21a252cac102b81eea922666e03059ba11c7f46d11a42fe33017230e0c03"}, "config": {"enabled": true, "alias": "data_quality_cms_hcc", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_cms_hcc", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.90048, "relation_name": "cms_synthetic.data_quality.data_quality_cms_hcc", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\nselect max(case when factor_type = 'Demographic' then 1 else 0 end) demographic_factor\n,max(case when factor_type = 'Disease' then 1 else 0 end) as disease_factor\nfrom {{ ref('cms_hcc__patient_risk_factors') }}\n)\n\nselect 'missing cms-hcc demographic factor' as data_quality_check\n,case when demographic_factor = 0 then 1 else 0 end as result_count\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom cte \n\nunion all\n\nselect 'missing cms-hcc disease factor' as data_quality_check\n,case when disease_factor = 0 then 1 else 0 end as result_count\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom cte", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__cms_hcc.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect max(case when factor_type = 'Demographic' then 1 else 0 end) demographic_factor\n,max(case when factor_type = 'Disease' then 1 else 0 end) as disease_factor\nfrom cms_synthetic.cms_hcc.patient_risk_factors\n)\n\nselect 'missing cms-hcc demographic factor' as data_quality_check\n,case when demographic_factor = 0 then 1 else 0 end as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte \n\nunion all\n\nselect 'missing cms-hcc disease factor' as data_quality_check\n,case when disease_factor = 0 then 1 else 0 end as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__service_categories_pmpm": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__service_categories_pmpm", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__service_categories_pmpm.sql", "original_file_path": "models/data_quality/intermediate/data_quality__service_categories_pmpm.sql", "unique_id": "model.the_tuva_project.data_quality__service_categories_pmpm", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__service_categories_pmpm"], "alias": "service_categories_pmpm", "checksum": {"name": "sha256", "checksum": "9fa0494ffd30bff612e44a6d051499486ad6b42707124014a447f1a3830475a1"}, "config": {"enabled": true, "alias": "service_categories_pmpm", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "service_categories_pmpm", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.899112, "relation_name": "cms_synthetic.data_quality.service_categories_pmpm", "raw_code": "{{ config(enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool) }}\n\nwith member_months as (\n select\n count(1) as member_months\n from {{ ref('core__member_months') }} mm\n)\n\n, pmpm as (\n select\n cast('service categories pmpm' as {{dbt.type_string() }} ) as analytics_concept\n , mc.service_category_2 as analytics_measure\n , sum(mc.paid_amount) as total_paid\n , avg(mm.member_months) as member_months\n , case when avg(mm.member_months) = 0 then null\n else sum(mc.paid_amount) / avg(mm.member_months)\n end as data_source_value\n from {{ ref('core__medical_claim') }} mc\n cross join member_months mm\n group by\n mc.service_category_2\n)\n\nselect\n pmpm.*\n , ref_data.analytics_value\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom pmpm\nleft join {{ ref('data_quality__reference_mart_analytics') }} ref_data\n on pmpm.analytics_concept = ref_data.analytics_concept\n and pmpm.analytics_measure = ref_data.analytics_measure", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__service_categories_pmpm.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n count(1) as member_months\n from cms_synthetic.core.member_months mm\n)\n\n, pmpm as (\n select\n cast('service categories pmpm' as TEXT ) as analytics_concept\n , mc.service_category_2 as analytics_measure\n , sum(mc.paid_amount) as total_paid\n , avg(mm.member_months) as member_months\n , case when avg(mm.member_months) = 0 then null\n else sum(mc.paid_amount) / avg(mm.member_months)\n end as data_source_value\n from cms_synthetic.core.medical_claim mc\n cross join member_months mm\n group by\n mc.service_category_2\n)\n\nselect\n pmpm.*\n , ref_data.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pmpm\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data\n on pmpm.analytics_concept = ref_data.analytics_concept\n and pmpm.analytics_measure = ref_data.analytics_measure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__ed_classification_reference": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__ed_classification_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__ed_classification_reference.sql", "original_file_path": "models/data_quality/intermediate/data_quality__ed_classification_reference.sql", "unique_id": "model.the_tuva_project.data_quality__ed_classification_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__ed_classification_reference"], "alias": "data_quality_ed_classification_reference", "checksum": {"name": "sha256", "checksum": "b9c353aa3e835424e3d3e4d72f7334d3a690ede9e51f9814c16df0277e9ec2a7"}, "config": {"enabled": true, "alias": "data_quality_ed_classification_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_ed_classification_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.964052, "relation_name": "cms_synthetic.data_quality.data_quality_ed_classification_reference", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith total_cte as \n(\nselect count(*) as total_encounters\nfrom {{ ref('core__encounter') }}\nwhere encounter_type = cast('emergency department' as {{dbt.type_string()}})\n) \n\n,final as (\nselect coalesce(cast(ed_classification_description as {{dbt.type_string()}}), cast('Not Classified' as {{dbt.type_string()}})) as ed_classification_description\n,count(*) as encounters\n,total_cte.total_encounters\n,count(*)/total_cte.total_encounters as percent_of_total\n,row_number() over (order by count(*) desc) as value_rank\nfrom {{ ref('core__encounter') }} e\ncross join total_cte\nleft join {{ ref('ed_classification__summary') }} s on e.encounter_id = s.encounter_id \nwhere encounter_type = cast('emergency department' as {{dbt.type_string()}})\ngroup by coalesce(cast(ed_classification_description as {{dbt.type_string()}}), cast('Not Classified' as {{dbt.type_string()}}))\n,total_cte.total_encounters\n)\n\n,actually_final as (\nselect cast('ed classification' as {{dbt.type_string()}}) as analytics_concept\n,ed_classification_description as analytics_measure\n,percent_of_total as data_source_value\n,value_rank as value_rank\nfrom final\n)\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n,m.value_rank\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join actually_final on actually_final.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = actually_final.analytics_concept\nwhere m.analytics_concept = cast('ed classification' as {{dbt.type_string()}})", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "ed_classification__summary", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.ed_classification__summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__ed_classification_reference.sql", "compiled": true, "compiled_code": "\n\nwith total_cte as \n(\nselect count(*) as total_encounters\nfrom cms_synthetic.core.encounter\nwhere encounter_type = cast('emergency department' as TEXT)\n) \n\n,final as (\nselect coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT)) as ed_classification_description\n,count(*) as encounters\n,total_cte.total_encounters\n,count(*)/total_cte.total_encounters as percent_of_total\n,row_number() over (order by count(*) desc) as value_rank\nfrom cms_synthetic.core.encounter e\ncross join total_cte\nleft join cms_synthetic.ed_classification.summary s on e.encounter_id = s.encounter_id \nwhere encounter_type = cast('emergency department' as TEXT)\ngroup by coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT))\n,total_cte.total_encounters\n)\n\n,actually_final as (\nselect cast('ed classification' as TEXT) as analytics_concept\n,ed_classification_description as analytics_measure\n,percent_of_total as data_source_value\n,value_rank as value_rank\nfrom final\n)\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n,m.value_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join actually_final on actually_final.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = actually_final.analytics_concept\nwhere m.analytics_concept = cast('ed classification' as TEXT)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__financial_pmpm": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__financial_pmpm", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__financial_pmpm.sql", "original_file_path": "models/data_quality/intermediate/data_quality__financial_pmpm.sql", "unique_id": "model.the_tuva_project.data_quality__financial_pmpm", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__financial_pmpm"], "alias": "data_quality_financial_pmpm", "checksum": {"name": "sha256", "checksum": "c45489afd19882d64975f44f83c2f582729c130bf56cef583cb2ac110b9f078a"}, "config": {"enabled": true, "alias": "data_quality_financial_pmpm", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_financial_pmpm", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.965586, "relation_name": "cms_synthetic.data_quality.data_quality_financial_pmpm", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\n) }}\n\nwith cte as (\nselect distinct cast(year_month_int as {{ dbt.type_string() }} ) as year_month\n,year as year_number\nfrom {{ ref('reference_data__calendar') }}\n)\n\nselect count(*) as member_months\n,sum(total_paid) / cast(count(*) as {{ dbt.type_numeric() }}) as total_pmpm\n,c.year_number as year_number\nfrom {{ ref('financial_pmpm__pmpm_prep') }} p \nleft join cte c on p.year_month = c.year_month \ngroup by c.year_number", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__financial_pmpm.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect distinct cast(year_month_int as TEXT ) as year_month\n,year as year_number\nfrom cms_synthetic.reference_data.calendar\n)\n\nselect count(*) as member_months\n,sum(total_paid) / cast(count(*) as numeric(28,6)) as total_pmpm\n,c.year_number as year_number\nfrom cms_synthetic.financial_pmpm.pmpm_prep p \nleft join cte c on p.year_month = c.year_month \ngroup by c.year_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__quality_measures": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__quality_measures", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__quality_measures.sql", "original_file_path": "models/data_quality/intermediate/data_quality__quality_measures.sql", "unique_id": "model.the_tuva_project.data_quality__quality_measures", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__quality_measures"], "alias": "data_quality_quality_measures", "checksum": {"name": "sha256", "checksum": "1b73ae67bc53f568ab3ab3a7d8525211630ec1ba9db4ca2c2b53129bf4787154"}, "config": {"enabled": true, "alias": "data_quality_quality_measures", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_quality_measures", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.956488, "relation_name": "cms_synthetic.data_quality.data_quality_quality_measures", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\nselect sum(case when numerator_sum = 0 then 1 else 0 end) as numerator_zero_count\n,sum(case when denominator_sum = 0 then 1 else 0 end) as denominator_zero_count\nfrom {{ ref('quality_measures__summary_counts') }} \n)\n\n,final as (\nselect 'quality measure numerator zero' as data_quality_check\n,numerator_zero_count as result_count\nfrom cte \n\nunion all \n\nselect 'quality measure denominator zero' as data_quality_check\n,denominator_zero_count as result_count\nfrom cte\n)\n\nselect *\n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "quality_measures__summary_counts", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__summary_counts"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__quality_measures.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect sum(case when numerator_sum = 0 then 1 else 0 end) as numerator_zero_count\n,sum(case when denominator_sum = 0 then 1 else 0 end) as denominator_zero_count\nfrom cms_synthetic.quality_measures.summary_counts \n)\n\n,final as (\nselect 'quality measure numerator zero' as data_quality_check\n,numerator_zero_count as result_count\nfrom cte \n\nunion all \n\nselect 'quality measure denominator zero' as data_quality_check\n,denominator_zero_count as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__readmissions": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__readmissions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__readmissions.sql", "original_file_path": "models/data_quality/intermediate/data_quality__readmissions.sql", "unique_id": "model.the_tuva_project.data_quality__readmissions", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__readmissions"], "alias": "data_quality_readmissions", "checksum": {"name": "sha256", "checksum": "8e4a08fa14ce38907e9f20400ac20eec3d86772a8e97d67e9b20d2769cb38061"}, "config": {"enabled": true, "alias": "data_quality_readmissions", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_readmissions", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.896089, "relation_name": "cms_synthetic.data_quality.data_quality_readmissions", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\n\nwith disqualified_unpivot as (\n {{ dbt_utils.unpivot(\n relation=ref('readmissions__encounter_augmented'),\n cast_to=type_string(), \n exclude=['encounter_id'], \n field_name='disqualified_reason',\n value_name='flagvalue',\n remove=[\n 'encounter_id',\n 'patient_id',\n 'admit_date',\n 'discharge_date',\n 'discharge_disposition_code',\n 'facility_id',\n 'ms_drg_code',\n 'paid_amount',\n 'length_of_stay',\n 'index_admission_flag',\n 'planned_flag',\n 'specialty_cohort',\n 'died_flag',\n 'diagnosis_ccs',\n 'disqualified_encounter_flag',\n 'tuva_last_run'\n]\n ) }}\n)\n\n-- Using the transformed data to perform aggregation\nselect \n {{ dbt.concat([\"'inpatient encounter '\", \"d.disqualified_reason\"]) }} as data_quality_check\n , count(distinct encounter_id) as result_count\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom disqualified_unpivot d\nwhere cast(flagvalue as {{ dbt.type_int() }} ) = 1 \ngroup by disqualified_reason", "language": "sql", "refs": [{"name": "readmissions__encounter_augmented", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt_utils.unpivot", "macro.dbt.concat", "macro.dbt.type_int"], "nodes": ["model.the_tuva_project.readmissions__encounter_augmented"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__readmissions.sql", "compiled": true, "compiled_code": "\n\n\nwith disqualified_unpivot as (\n select\n encounter_id,\n\n cast('MISSING_ADMIT_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_ADMIT_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('ADMIT_AFTER_DISCHARGE_FLAG' as TEXT) as disqualified_reason,\n cast( \n ADMIT_AFTER_DISCHARGE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_PRIMARY_DIAGNOSIS_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_PRIMARY_DIAGNOSIS_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('NO_DIAGNOSIS_CCS_FLAG' as TEXT) as disqualified_reason,\n cast( \n NO_DIAGNOSIS_CCS_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG' as TEXT) as disqualified_reason,\n cast( \n OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n \n)\n\n-- Using the transformed data to perform aggregation\nselect \n 'inpatient encounter ' || d.disqualified_reason as data_quality_check\n , count(distinct encounter_id) as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom disqualified_unpivot d\nwhere cast(flagvalue as integer ) = 1 \ngroup by disqualified_reason", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__dx_and_px": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__dx_and_px", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__dx_and_px.sql", "original_file_path": "models/data_quality/intermediate/data_quality__dx_and_px.sql", "unique_id": "model.the_tuva_project.data_quality__dx_and_px", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__dx_and_px"], "alias": "dx_and_px", "checksum": {"name": "sha256", "checksum": "226cf6f207d484973da487c88a19d8c94b406edd3be17f28100da3aa74b0e1ef"}, "config": {"enabled": true, "alias": "dx_and_px", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of rows in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "dx_and_px", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.851758, "relation_name": "cms_synthetic.data_quality.dx_and_px", "raw_code": "{{ config(\n enabled = var('data_quality_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith unpivot_diagnosis as(\n {{ dbt_utils.unpivot(\n relation=ref('medical_claim'),\n cast_to=type_string(),\n exclude=['claim_id', 'diagnosis_code_type'],\n field_name='diagnosis_column',\n value_name='diagnosis_code',\n remove=[ 'claim_line_number'\n , 'claim_type'\n , 'patient_id'\n , 'member_id'\n , 'payer'\n , 'plan'\n , 'claim_start_date'\n , 'claim_end_date'\n , 'claim_line_start_date'\n , 'claim_line_end_date'\n , 'admission_date'\n , 'discharge_date'\n , 'admit_source_code'\n , 'admit_type_code'\n , 'discharge_disposition_code'\n , 'place_of_service_code'\n , 'bill_type_code'\n , 'ms_drg_code'\n , 'apr_drg_code'\n , 'revenue_center_code'\n , 'service_unit_quantity'\n , 'hcpcs_code'\n , 'hcpcs_modifier_1'\n , 'hcpcs_modifier_2'\n , 'hcpcs_modifier_3'\n , 'hcpcs_modifier_4'\n , 'hcpcs_modifier_5'\n , 'rendering_npi'\n , 'rendering_tin'\n , 'billing_npi'\n , 'billing_tin'\n , 'facility_npi'\n , 'paid_date'\n , 'paid_amount'\n , 'allowed_amount'\n , 'charge_amount'\n , 'coinsurance_amount'\n , 'copayment_amount'\n , 'deductible_amount'\n , 'total_cost_amount'\n , 'diagnosis_poa_1'\n , 'diagnosis_poa_2'\n , 'diagnosis_poa_3'\n , 'diagnosis_poa_4'\n , 'diagnosis_poa_5'\n , 'diagnosis_poa_6'\n , 'diagnosis_poa_7'\n , 'diagnosis_poa_8'\n , 'diagnosis_poa_9'\n , 'diagnosis_poa_10'\n , 'diagnosis_poa_11'\n , 'diagnosis_poa_12'\n , 'diagnosis_poa_13'\n , 'diagnosis_poa_14'\n , 'diagnosis_poa_15'\n , 'diagnosis_poa_16'\n , 'diagnosis_poa_17'\n , 'diagnosis_poa_18'\n , 'diagnosis_poa_19'\n , 'diagnosis_poa_20'\n , 'diagnosis_poa_21'\n , 'diagnosis_poa_22'\n , 'diagnosis_poa_23'\n , 'diagnosis_poa_24'\n , 'diagnosis_poa_25'\n , 'procedure_code_type'\n , 'procedure_code_1'\n , 'procedure_code_2'\n , 'procedure_code_3'\n , 'procedure_code_4'\n , 'procedure_code_5'\n , 'procedure_code_6'\n , 'procedure_code_7'\n , 'procedure_code_8'\n , 'procedure_code_9'\n , 'procedure_code_10'\n , 'procedure_code_11'\n , 'procedure_code_12'\n , 'procedure_code_13'\n , 'procedure_code_14'\n , 'procedure_code_15'\n , 'procedure_code_16'\n , 'procedure_code_17'\n , 'procedure_code_18'\n , 'procedure_code_19'\n , 'procedure_code_20'\n , 'procedure_code_21'\n , 'procedure_code_22'\n , 'procedure_code_23'\n , 'procedure_code_24'\n , 'procedure_code_25'\n , 'procedure_date_1'\n , 'procedure_date_2'\n , 'procedure_date_3'\n , 'procedure_date_4'\n , 'procedure_date_5'\n , 'procedure_date_6'\n , 'procedure_date_7'\n , 'procedure_date_8'\n , 'procedure_date_9'\n , 'procedure_date_10'\n , 'procedure_date_11'\n , 'procedure_date_12'\n , 'procedure_date_13'\n , 'procedure_date_14'\n , 'procedure_date_15'\n , 'procedure_date_16'\n , 'procedure_date_17'\n , 'procedure_date_18'\n , 'procedure_date_19'\n , 'procedure_date_20'\n , 'procedure_date_21'\n , 'procedure_date_22'\n , 'procedure_date_23'\n , 'procedure_date_24'\n , 'procedure_date_25'\n , 'in_network_flag'\n , 'data_source'\n , 'file_name'\n , 'ingest_datetime']\n ) }}\n)\n, unpivot_procedure as(\n {{ dbt_utils.unpivot(\n relation=ref('medical_claim'),\n cast_to=type_string(),\n exclude=['claim_id', 'procedure_code_type'],\n field_name='procedure_column',\n value_name='procedure_code',\n remove=[ 'claim_line_number'\n , 'claim_type'\n , 'patient_id'\n , 'member_id'\n , 'payer'\n , 'plan'\n , 'claim_start_date'\n , 'claim_end_date'\n , 'claim_line_start_date'\n , 'claim_line_end_date'\n , 'admission_date'\n , 'discharge_date'\n , 'admit_source_code'\n , 'admit_type_code'\n , 'discharge_disposition_code'\n , 'place_of_service_code'\n , 'bill_type_code'\n , 'ms_drg_code'\n , 'apr_drg_code'\n , 'revenue_center_code'\n , 'service_unit_quantity'\n , 'hcpcs_code'\n , 'hcpcs_modifier_1'\n , 'hcpcs_modifier_2'\n , 'hcpcs_modifier_3'\n , 'hcpcs_modifier_4'\n , 'hcpcs_modifier_5'\n , 'rendering_npi'\n , 'rendering_tin'\n , 'billing_npi'\n , 'billing_tin'\n , 'facility_npi'\n , 'paid_date'\n , 'paid_amount'\n , 'allowed_amount'\n , 'charge_amount'\n , 'coinsurance_amount'\n , 'copayment_amount'\n , 'deductible_amount'\n , 'total_cost_amount'\n , 'diagnosis_code_type'\n , 'diagnosis_code_1'\n , 'diagnosis_code_2'\n , 'diagnosis_code_3'\n , 'diagnosis_code_4'\n , 'diagnosis_code_5'\n , 'diagnosis_code_6'\n , 'diagnosis_code_7'\n , 'diagnosis_code_8'\n , 'diagnosis_code_9'\n , 'diagnosis_code_10'\n , 'diagnosis_code_11'\n , 'diagnosis_code_12'\n , 'diagnosis_code_13'\n , 'diagnosis_code_14'\n , 'diagnosis_code_15'\n , 'diagnosis_code_16'\n , 'diagnosis_code_17'\n , 'diagnosis_code_18'\n , 'diagnosis_code_19'\n , 'diagnosis_code_20'\n , 'diagnosis_code_21'\n , 'diagnosis_code_22'\n , 'diagnosis_code_23'\n , 'diagnosis_code_24'\n , 'diagnosis_code_25'\n , 'diagnosis_poa_1'\n , 'diagnosis_poa_2'\n , 'diagnosis_poa_3'\n , 'diagnosis_poa_4'\n , 'diagnosis_poa_5'\n , 'diagnosis_poa_6'\n , 'diagnosis_poa_7'\n , 'diagnosis_poa_8'\n , 'diagnosis_poa_9'\n , 'diagnosis_poa_10'\n , 'diagnosis_poa_11'\n , 'diagnosis_poa_12'\n , 'diagnosis_poa_13'\n , 'diagnosis_poa_14'\n , 'diagnosis_poa_15'\n , 'diagnosis_poa_16'\n , 'diagnosis_poa_17'\n , 'diagnosis_poa_18'\n , 'diagnosis_poa_19'\n , 'diagnosis_poa_20'\n , 'diagnosis_poa_21'\n , 'diagnosis_poa_22'\n , 'diagnosis_poa_23'\n , 'diagnosis_poa_24'\n , 'diagnosis_poa_25'\n , 'procedure_date_1'\n , 'procedure_date_2'\n , 'procedure_date_3'\n , 'procedure_date_4'\n , 'procedure_date_5'\n , 'procedure_date_6'\n , 'procedure_date_7'\n , 'procedure_date_8'\n , 'procedure_date_9'\n , 'procedure_date_10'\n , 'procedure_date_11'\n , 'procedure_date_12'\n , 'procedure_date_13'\n , 'procedure_date_14'\n , 'procedure_date_15'\n , 'procedure_date_16'\n , 'procedure_date_17'\n , 'procedure_date_18'\n , 'procedure_date_19'\n , 'procedure_date_20'\n , 'procedure_date_21'\n , 'procedure_date_22'\n , 'procedure_date_23'\n , 'procedure_date_24'\n , 'procedure_date_25'\n , 'in_network_flag'\n , 'data_source'\n , 'file_name'\n , 'ingest_datetime'\n ]\n ) }}\n\n\n)\n\n, total_claims as(\n select\n cast(count(distinct claim_id) as integer ) as total_claims\n from {{ ref('medical_claim') }}\n)\n\n, claims_with_primary_dx as(\n select\n count(diagnosis_code_1) as distinct_claims_with_primary\n from {{ ref('medical_claim') }}\n)\n\n, secondary_dx_prep_cte as ( \n select\n tc.total_claims\n , cast(count(distinct claim_id) as integer) as secondary_dx_claim_count\n from unpivot_diagnosis\n cross join total_claims tc\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and\n cast(diagnosis_code as {{ dbt.type_string() }} ) is not null\n group by total_claims\n ) \n\n, claims_with_secondary_dx as (\n select\n total_claims\n , cast(secondary_dx_claim_count as integer ) as secondary_dx_claim_count\n , (cast(secondary_dx_claim_count as integer ) / cast(total_claims as integer )) * 100 as result_count\n , cast('Percent of claims with secondary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\n from\n secondary_dx_prep_cte\n\n)\n, missing_primary_dx as (\n select\n cast('missing primary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\n , cast(count(distinct claim_id) as integer ) as result_count\n from {{ ref('medical_claim') }} m\n where diagnosis_code_1 is null\n)\n, invalid_primary_dx as(\n select\n data_quality_check\n , count(distinct claim_id) as result_count\n from (\n select\n cast('invalid primary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\n , claim_id\n , diagnosis_code_type\n , diagnosis_column\n , diagnosis_code\n , icd_10_cm\n , icd_9_cm\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join {{ ref('terminology__icd_10_cm') }} icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join {{ ref('terminology__icd_9_cm') }} icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n, multiple_primary_dx as(\n\n select\n cast('multiple primary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\n , cast(count(*) as integer ) as result_count\n from\n (\n select\n claim_id\n , row_number() over (partition by claim_id order by claim_id) as row_nbr\n from unpivot_diagnosis\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n group by\n claim_id\n )x\n where row_nbr > 1\n\n)\n, invalid_secondary_dx as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid secondary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join {{ ref('terminology__icd_10_cm') }} icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join {{ ref('terminology__icd_9_cm') }} icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n\n, invalid_procedure as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid procedure' as {{ dbt.type_string() }}) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_pcs is null and icd9.icd_9_pcs is null\n then 1\n else 0\n end as invalid_procedure\n from unpivot_procedure px\n left join {{ ref('terminology__icd_10_pcs') }} icd10\n on px.procedure_code = icd10.icd_10_pcs\n left join {{ ref('terminology__icd_9_pcs') }} icd9\n on px.procedure_code = icd9.icd_9_pcs\n where px.procedure_code is not null\n )x\n where invalid_procedure = 1\n group by\n data_quality_check\n)\n\n, final as (\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\n ,result_count\n from missing_primary_dx\n\n union all\n\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\n ,result_count\n from invalid_primary_dx\n\n union all\n\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\n ,result_count\n from multiple_primary_dx\n\n union all\n\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\n ,result_count\n from invalid_secondary_dx\n\n union all\n\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\n ,result_count\n from claims_with_secondary_dx\n\n union all\n\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\n ,result_count\n from invalid_procedure\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt_utils.unpivot"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__dx_and_px.sql", "compiled": true, "compiled_code": "\n\nwith unpivot_diagnosis as(\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_1' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_1\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_2' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_2\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_3' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_3\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_4' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_4\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_5' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_5\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_6' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_6\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_7' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_7\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_8' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_8\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_9' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_9\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_10' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_10\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_11' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_11\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_12' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_12\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_13' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_13\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_14' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_14\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_15' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_15\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_16' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_16\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_17' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_17\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_18' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_18\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_19' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_19\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_20' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_20\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_21' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_21\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_22' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_22\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_23' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_23\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_24' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_24\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_25' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_25\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n \n)\n, unpivot_procedure as(\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_1' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_1\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_2' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_2\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_3' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_3\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_4' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_4\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_5' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_5\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_6' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_6\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_7' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_7\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_8' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_8\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_9' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_9\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_10' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_10\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_11' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_11\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_12' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_12\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_13' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_13\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_14' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_14\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_15' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_15\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_16' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_16\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_17' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_17\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_18' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_18\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_19' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_19\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_20' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_20\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_21' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_21\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_22' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_22\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_23' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_23\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_24' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_24\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_25' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_25\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n \n\n\n)\n\n, total_claims as(\n select\n cast(count(distinct claim_id) as integer ) as total_claims\n from tuva.input_layer.medical_claim\n)\n\n, claims_with_primary_dx as(\n select\n count(diagnosis_code_1) as distinct_claims_with_primary\n from tuva.input_layer.medical_claim\n)\n\n, secondary_dx_prep_cte as ( \n select\n tc.total_claims\n , cast(count(distinct claim_id) as integer) as secondary_dx_claim_count\n from unpivot_diagnosis\n cross join total_claims tc\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and\n cast(diagnosis_code as TEXT ) is not null\n group by total_claims\n ) \n\n, claims_with_secondary_dx as (\n select\n total_claims\n , cast(secondary_dx_claim_count as integer ) as secondary_dx_claim_count\n , (cast(secondary_dx_claim_count as integer ) / cast(total_claims as integer )) * 100 as result_count\n , cast('Percent of claims with secondary diagnosis' as TEXT) as data_quality_check\n from\n secondary_dx_prep_cte\n\n)\n, missing_primary_dx as (\n select\n cast('missing primary diagnosis' as TEXT) as data_quality_check\n , cast(count(distinct claim_id) as integer ) as result_count\n from tuva.input_layer.medical_claim m\n where diagnosis_code_1 is null\n)\n, invalid_primary_dx as(\n select\n data_quality_check\n , count(distinct claim_id) as result_count\n from (\n select\n cast('invalid primary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , diagnosis_code_type\n , diagnosis_column\n , diagnosis_code\n , icd_10_cm\n , icd_9_cm\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join cms_synthetic.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join cms_synthetic.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n, multiple_primary_dx as(\n\n select\n cast('multiple primary diagnosis' as TEXT) as data_quality_check\n , cast(count(*) as integer ) as result_count\n from\n (\n select\n claim_id\n , row_number() over (partition by claim_id order by claim_id) as row_nbr\n from unpivot_diagnosis\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n group by\n claim_id\n )x\n where row_nbr > 1\n\n)\n, invalid_secondary_dx as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid secondary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join cms_synthetic.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join cms_synthetic.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n\n, invalid_procedure as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid procedure' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_pcs is null and icd9.icd_9_pcs is null\n then 1\n else 0\n end as invalid_procedure\n from unpivot_procedure px\n left join cms_synthetic.terminology.icd_10_pcs icd10\n on px.procedure_code = icd10.icd_10_pcs\n left join cms_synthetic.terminology.icd_9_pcs icd9\n on px.procedure_code = icd9.icd_9_pcs\n where px.procedure_code is not null\n )x\n where invalid_procedure = 1\n group by\n data_quality_check\n)\n\n, final as (\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from missing_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from multiple_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from claims_with_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_procedure\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__chronic_conditions_prevalence": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__chronic_conditions_prevalence", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__chronic_conditions_prevalence.sql", "original_file_path": "models/data_quality/intermediate/data_quality__chronic_conditions_prevalence.sql", "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__chronic_conditions_prevalence"], "alias": "chronic_conditions_prevalence", "checksum": {"name": "sha256", "checksum": "cc59c0250cd3b6c83d41dbf4588a9a43ae0ee34adaca5d2ea48f76b20f9a52d4"}, "config": {"enabled": true, "alias": "chronic_conditions_prevalence", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "chronic_conditions_prevalence", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.845267, "relation_name": "cms_synthetic.data_quality.chronic_conditions_prevalence", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith condition_counts as (\n select\n condition\n , count(distinct patient_id) as patients\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\n group by condition\n)\n, total_patients as (\n select \n count(distinct patient_id) as total_distinct_patients\n from {{ ref('core__eligibility') }}\n)\n\n, results_first as (\nselect\n conditions.condition\n , conditions.patients\n , CASE \n WHEN total_patients.total_distinct_patients = 0 THEN NULL\n ELSE (conditions.patients / total_patients.total_distinct_patients) * 100 \n END as percent_of_total\n\nfrom condition_counts as conditions\ncross join total_patients\n)\n\n,results_second as (\n select \n condition\n , patients\n , percent_of_total\n , ROW_NUMBER() OVER (ORDER BY percent_of_total desc) AS condition_rank\n from results_first\n)\n\n\nselect\n ref_data.analytics_concept\n , coalesce(results.condition, ref_data.analytics_measure) as analytics_measure\n , results.patients\n , results.condition_rank as value_rank\n , results.percent_of_total as data_source_value\n , ref_data.analytics_value\n , ref_data.value_rank as medicare_lds_condition_rank\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} ref_data\nleft join results_second as results on results.condition = ref_data.analytics_measure\nwhere ref_data.analytics_concept = 'chronic conditions top 10'", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__eligibility", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__chronic_conditions_prevalence.sql", "compiled": true, "compiled_code": "\n\nwith condition_counts as (\n select\n condition\n , count(distinct patient_id) as patients\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n group by condition\n)\n, total_patients as (\n select \n count(distinct patient_id) as total_distinct_patients\n from cms_synthetic.core.eligibility\n)\n\n, results_first as (\nselect\n conditions.condition\n , conditions.patients\n , CASE \n WHEN total_patients.total_distinct_patients = 0 THEN NULL\n ELSE (conditions.patients / total_patients.total_distinct_patients) * 100 \n END as percent_of_total\n\nfrom condition_counts as conditions\ncross join total_patients\n)\n\n,results_second as (\n select \n condition\n , patients\n , percent_of_total\n , ROW_NUMBER() OVER (ORDER BY percent_of_total desc) AS condition_rank\n from results_first\n)\n\n\nselect\n ref_data.analytics_concept\n , coalesce(results.condition, ref_data.analytics_measure) as analytics_measure\n , results.patients\n , results.condition_rank as value_rank\n , results.percent_of_total as data_source_value\n , ref_data.analytics_value\n , ref_data.value_rank as medicare_lds_condition_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data\nleft join results_second as results on results.condition = ref_data.analytics_measure\nwhere ref_data.analytics_concept = 'chronic conditions top 10'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_key_check": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__primary_key_check", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__primary_key_check.sql", "original_file_path": "models/data_quality/intermediate/data_quality__primary_key_check.sql", "unique_id": "model.the_tuva_project.data_quality__primary_key_check", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__primary_key_check"], "alias": "primary_key_check", "checksum": {"name": "sha256", "checksum": "93900fdd41fd41462466064e4aa9524897f6c891bdf5296423315efa24f51329"}, "config": {"enabled": true, "alias": "primary_key_check", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_key_check", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.881255, "relation_name": "cms_synthetic.data_quality.primary_key_check", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n) }}\n\nwith pharmacy as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from {{ ref('pharmacy_claim') }} p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, medical as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from {{ ref('medical_claim') }} p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, eligibility as (\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , {{ quote_column('plan') }}\n , data_source\n , count(*) as result_count\n from {{ ref('eligibility') }} p\n group by\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , {{ quote_column('plan') }}\n , data_source\n having count(*) > 1\n)\n\n, final as (\n select\n 'pk errors pharmacy claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from pharmacy\n\n union all\n\n select\n 'pk errors medical claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from medical\n\n union all\n\n select\n 'pk errors eligibility' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from eligibility\n)\n\nselect\n *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.pharmacy_claim", "model.input_layer.medical_claim", "model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__primary_key_check.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.pharmacy_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, medical as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.medical_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, eligibility as (\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n , count(*) as result_count\n from tuva.input_layer.eligibility p\n group by\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n having count(*) > 1\n)\n\n, final as (\n select\n 'pk errors pharmacy claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from pharmacy\n\n union all\n\n select\n 'pk errors medical claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from medical\n\n union all\n\n select\n 'pk errors eligibility' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from eligibility\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounters_cost_and_utilization", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__encounters_cost_and_utilization.sql", "original_file_path": "models/data_quality/intermediate/data_quality__encounters_cost_and_utilization.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__encounters_cost_and_utilization"], "alias": "encounters_cost_and_utilization", "checksum": {"name": "sha256", "checksum": "6480387167aa05aa584759a024086b88dff640ae0918ca40950abea82402d535"}, "config": {"enabled": true, "alias": "encounters_cost_and_utilization", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_cost_and_utilization", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.85886, "relation_name": "cms_synthetic.data_quality.encounters_cost_and_utilization", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\n) }}\n\nwith member_months as (\n select \n count(1) as member_months \n from {{ ref('core__member_months') }}\n)\n,pkpy as (\nselect\n cast('encounters cost and utilization PKPY' as {{dbt.type_string()}}) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as {{dbt.type_string()}}) as analytics_measure\n , count(enc.encounter_id) / avg(mm.member_months) * 12000 as data_source_value\nfrom {{ ref('core__encounter') }} as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\n,paid_per as (\nselect\n cast('encounters cost and utilization paid per' as {{dbt.type_string()}}) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as {{dbt.type_string()}}) as analytics_measure\n , sum(enc.paid_amount) / count(enc.encounter_id) as data_source_value\nfrom {{ ref('core__encounter') }} as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\nselect\n pkpy.*\n ,ref_data.analytics_value\n ,cast('{{ var('tuva_last_run')}}' as {{dbt.type_string()}}) as tuva_last_run\nfrom pkpy\nleft join {{ ref('data_quality__reference_mart_analytics') }} ref_data on pkpy.analytics_concept = ref_data.analytics_concept and pkpy.analytics_measure = ref_data.analytics_measure\nunion all\nselect\n paid_per.*\n ,ref_data.analytics_value\n ,cast('{{ var('tuva_last_run')}}' as {{dbt.type_string()}}) as tuva_last_run\nfrom paid_per\nleft join {{ ref('data_quality__reference_mart_analytics') }} ref_data on paid_per.analytics_concept = paid_per.analytics_concept and paid_per.analytics_measure = paid_per.analytics_measure", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__encounters_cost_and_utilization.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select \n count(1) as member_months \n from cms_synthetic.core.member_months\n)\n,pkpy as (\nselect\n cast('encounters cost and utilization PKPY' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , count(enc.encounter_id) / avg(mm.member_months) * 12000 as data_source_value\nfrom cms_synthetic.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\n,paid_per as (\nselect\n cast('encounters cost and utilization paid per' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , sum(enc.paid_amount) / count(enc.encounter_id) as data_source_value\nfrom cms_synthetic.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\nselect\n pkpy.*\n ,ref_data.analytics_value\n ,cast('2024-10-22 19:20:26.762934+00:00' as TEXT) as tuva_last_run\nfrom pkpy\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data on pkpy.analytics_concept = ref_data.analytics_concept and pkpy.analytics_measure = ref_data.analytics_measure\nunion all\nselect\n paid_per.*\n ,ref_data.analytics_value\n ,cast('2024-10-22 19:20:26.762934+00:00' as TEXT) as tuva_last_run\nfrom paid_per\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data on paid_per.analytics_concept = paid_per.analytics_concept and paid_per.analytics_measure = paid_per.analytics_measure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_missing_patient_id": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__eligibility_missing_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__eligibility_missing_patient_id.sql", "original_file_path": "models/data_quality/intermediate/data_quality__eligibility_missing_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_missing_patient_id"], "alias": "eligibility_missing_patient_id", "checksum": {"name": "sha256", "checksum": "422eccb69ec9b77448f4a98b197dbfd29b883d39c82414f19b002820b4ee6d05"}, "config": {"enabled": true, "alias": "eligibility_missing_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_missing_patient_id", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.856163, "relation_name": "cms_synthetic.data_quality.eligibility_missing_patient_id", "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\n | as_bool\n )\n}}\n\n\nwith eligibility_spans as(\n select distinct\n {{ dbt.concat([\n \"member_id\",\n \"'-'\",\n \"enrollment_start_date\",\n \"'-'\",\n \"enrollment_end_date\",\n \"'-'\",\n \"payer\",\n \"'-'\",\n quote_column('plan'),\n ]) }} as eligibility_span_id\n , patient_id\n from {{ ref('eligibility') }}\n)\n\nselect\n 'Missing patient_id' as data_quality_check\n ,count(*) as result_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom eligibility_spans\nwhere\n patient_id is null or patient_id = ''", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__eligibility_missing_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n from tuva.input_layer.eligibility\n)\n\nselect\n 'Missing patient_id' as data_quality_check\n ,count(*) as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom eligibility_spans\nwhere\n patient_id is null or patient_id = ''", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_provider_npi": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__medical_claim_provider_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__medical_claim_provider_npi.sql", "original_file_path": "models/data_quality/intermediate/data_quality__medical_claim_provider_npi.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_provider_npi", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_provider_npi"], "alias": "medical_claim_provider_npi", "checksum": {"name": "sha256", "checksum": "4952e2c70a7bc78ac5cc4e7fc9779b9a6910ddbc01ddea0a9e119cd422b1b72e"}, "config": {"enabled": true, "alias": "medical_claim_provider_npi", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_provider_npi", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.888133, "relation_name": "cms_synthetic.data_quality.medical_claim_provider_npi", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n )\n}}\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.rendering_npi is not null then 1 else 0 end) as invalid_rendering_npi\n , max(case when term2.npi is null and m.billing_npi is not null then 1 else 0 end) as invalid_billing_npi\n , max(case when term3.npi is null and m.facility_npi is not null then 1 else 0 end) as invalid_facility_npi\n\n , max(case when m.rendering_npi is null then 1 else 0 end) as missing_rendering_npi\n , max(case when m.billing_npi is null then 1 else 0 end) as missing_billing_npi\n , max(case when m.facility_npi is null then 1 else 0 end) as missing_facility_npi\n\n , count(distinct m.rendering_npi) as rendering_npi_count\n , count(distinct m.billing_npi) as billing_npi_count\n , count(distinct m.facility_npi) as facility_npi_count\n\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_rendering_npi\n , max(case when term3.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_facility_npi\n\n from {{ ref('medical_claim') }} as m\n left join {{ ref('terminology__provider') }} as term\n on m.rendering_npi = term.npi\n left join {{ ref('terminology__provider') }} as term2\n on m.billing_npi = term2.npi\n left join {{ ref('terminology__provider') }} as term3\n on m.facility_npi = term3.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid rendering_npi' as data_quality_check\n , sum(invalid_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid billing_npi' as data_quality_check\n , sum(invalid_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid facility_npi' as data_quality_check\n , sum(invalid_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing rendering_npi' as data_quality_check\n , sum(missing_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing billing_npi' as data_quality_check\n , sum(missing_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing facility_npi' as data_quality_check\n , sum(missing_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type rendering_npi' as data_quality_check\n , sum(wrong_entity_type_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type facility_npi' as data_quality_check\n , sum(wrong_entity_type_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'multiple rendering_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere rendering_npi_count > 1\n\nunion all\n\nselect\n 'multiple billing_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere billing_npi_count > 1\n\nunion all\n\nselect\n 'multiple facility_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere facility_npi_count > 1\n)\n\nselect *\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__medical_claim_provider_npi.sql", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.rendering_npi is not null then 1 else 0 end) as invalid_rendering_npi\n , max(case when term2.npi is null and m.billing_npi is not null then 1 else 0 end) as invalid_billing_npi\n , max(case when term3.npi is null and m.facility_npi is not null then 1 else 0 end) as invalid_facility_npi\n\n , max(case when m.rendering_npi is null then 1 else 0 end) as missing_rendering_npi\n , max(case when m.billing_npi is null then 1 else 0 end) as missing_billing_npi\n , max(case when m.facility_npi is null then 1 else 0 end) as missing_facility_npi\n\n , count(distinct m.rendering_npi) as rendering_npi_count\n , count(distinct m.billing_npi) as billing_npi_count\n , count(distinct m.facility_npi) as facility_npi_count\n\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_rendering_npi\n , max(case when term3.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_facility_npi\n\n from tuva.input_layer.medical_claim as m\n left join cms_synthetic.terminology.provider as term\n on m.rendering_npi = term.npi\n left join cms_synthetic.terminology.provider as term2\n on m.billing_npi = term2.npi\n left join cms_synthetic.terminology.provider as term3\n on m.facility_npi = term3.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid rendering_npi' as data_quality_check\n , sum(invalid_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid billing_npi' as data_quality_check\n , sum(invalid_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid facility_npi' as data_quality_check\n , sum(invalid_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing rendering_npi' as data_quality_check\n , sum(missing_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing billing_npi' as data_quality_check\n , sum(missing_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing facility_npi' as data_quality_check\n , sum(missing_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type rendering_npi' as data_quality_check\n , sum(wrong_entity_type_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type facility_npi' as data_quality_check\n , sum(wrong_entity_type_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'multiple rendering_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere rendering_npi_count > 1\n\nunion all\n\nselect\n 'multiple billing_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere billing_npi_count > 1\n\nunion all\n\nselect\n 'multiple facility_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere facility_npi_count > 1\n)\n\nselect *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_percent": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__claim_percent", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__claim_percent.sql", "original_file_path": "models/data_quality/intermediate/data_quality__claim_percent.sql", "unique_id": "model.the_tuva_project.data_quality__claim_percent", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__claim_percent"], "alias": "data_quality_claim_percent", "checksum": {"name": "sha256", "checksum": "537dfeb71b5cf96a60298ddbb7a7ac5590a47339c67e66258e9bf20a993eda96"}, "config": {"enabled": true, "alias": "data_quality_claim_percent", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_claim_percent", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.967154, "relation_name": "cms_synthetic.data_quality.data_quality_claim_percent", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\n) }}\n\n\nwith cte as \n(\nselect sum(paid_amount) as paid_amount\n,claim_type\nfrom {{ ref('medical_claim') }}\ngroup by claim_type\n\nunion all\n\nselect sum(paid_amount) as paid_amount\n,'pharmacy' as claim_type\nfrom {{ ref('pharmacy_claim') }}\n)\n\n,total_cte as \n(\nselect sum(paid_amount) as total_paid_amount\nfrom cte\n)\n\nselect claim_type\n,paid_amount/total_paid_amount as percent_of_total_paid\nfrom cte\ncross join total_cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__claim_percent.sql", "compiled": true, "compiled_code": "\n\n\nwith cte as \n(\nselect sum(paid_amount) as paid_amount\n,claim_type\nfrom tuva.input_layer.medical_claim\ngroup by claim_type\n\nunion all\n\nselect sum(paid_amount) as paid_amount\n,'pharmacy' as claim_type\nfrom tuva.input_layer.pharmacy_claim\n)\n\n,total_cte as \n(\nselect sum(paid_amount) as total_paid_amount\nfrom cte\n)\n\nselect claim_type\n,paid_amount/total_paid_amount as percent_of_total_paid\nfrom cte\ncross join total_cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__acute_inpatient_reference": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__acute_inpatient_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__acute_inpatient_reference.sql", "original_file_path": "models/data_quality/intermediate/data_quality__acute_inpatient_reference.sql", "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__acute_inpatient_reference"], "alias": "data_quality_acute_inpatient_reference", "checksum": {"name": "sha256", "checksum": "87cfad8994c064be2de54f2a39cb99f7e93fe7cf8f5925aa12b5afa7eb50bf0a"}, "config": {"enabled": true, "alias": "data_quality_acute_inpatient_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_acute_inpatient_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.9580412, "relation_name": "cms_synthetic.data_quality.data_quality_acute_inpatient_reference", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\nselect avg(length_of_stay) los\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end) deceased_encounters\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end)/count(*) as mortality_rate\nfrom {{ ref('core__encounter') }}\nwhere encounter_type = 'acute inpatient'\n)\n\n\n,long_cte as (\n select 'acute inpatient' as analytics_concept\n,'length of stay' as analytics_measure\n,los as data_source_value\nfrom cte\n\nunion all \n\n select 'acute inpatient' as analytics_concept\n,'mortality rate' as analytics_measure\n,mortality_rate as data_source_value\nfrom cte\n)\n\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'length of stay'\n\nunion all \n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'mortality rate'", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__acute_inpatient_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(length_of_stay) los\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end) deceased_encounters\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end)/count(*) as mortality_rate\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n)\n\n\n,long_cte as (\n select 'acute inpatient' as analytics_concept\n,'length of stay' as analytics_measure\n,los as data_source_value\nfrom cte\n\nunion all \n\n select 'acute inpatient' as analytics_concept\n,'mortality rate' as analytics_measure\n,mortality_rate as data_source_value\nfrom cte\n)\n\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'length of stay'\n\nunion all \n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'mortality rate'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__quality_measures_reference": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__quality_measures_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__quality_measures_reference.sql", "original_file_path": "models/data_quality/intermediate/data_quality__quality_measures_reference.sql", "unique_id": "model.the_tuva_project.data_quality__quality_measures_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__quality_measures_reference"], "alias": "data_quality_quality_measures_reference", "checksum": {"name": "sha256", "checksum": "b1f802e23442ea70a805b621c08faa7337ee0a45a240108e5549e5d790f6823e"}, "config": {"enabled": true, "alias": "data_quality_quality_measures_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_quality_measures_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.954485, "relation_name": "cms_synthetic.data_quality.data_quality_quality_measures_reference", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\n)}}\n\nwith cte as (\nselect \n cast('quality measures' as {{dbt.type_string()}}) as analytics_concept\n ,measure_name as analytics_measure\n ,performance_rate as data_source_value\nfrom {{ ref('quality_measures__summary_counts') }} r \n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('quality measures' as {{dbt.type_string()}})", "language": "sql", "refs": [{"name": "quality_measures__summary_counts", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__summary_counts", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__quality_measures_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('quality measures' as TEXT) as analytics_concept\n ,measure_name as analytics_measure\n ,performance_rate as data_source_value\nfrom cms_synthetic.quality_measures.summary_counts r \n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('quality measures' as TEXT)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_missing_groups_union": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__encounters_missing_groups_union", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality/intermediate/data_quality__encounters_missing_groups_union.sql", "original_file_path": "models/data_quality/intermediate/data_quality__encounters_missing_groups_union.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups_union", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__encounters_missing_groups_union"], "alias": "encounters_missing_groups_union", "checksum": {"name": "sha256", "checksum": "136e20423be537d120a12249fd244bf71b9799c3cf9a22aa354f4f3e8a141494"}, "config": {"enabled": true, "alias": "encounters_missing_groups_union", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/data_quality/data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_missing_groups_union", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623957.860415, "relation_name": "cms_synthetic.data_quality.encounters_missing_groups_union", "raw_code": "{{ config(\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\n) }}\n\nselect\n 'number of missing encounter groups' as data_quality_check\n , count(*) as result_count\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('data_quality__encounters_missing_groups') }}", "language": "sql", "refs": [{"name": "data_quality__encounters_missing_groups", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__encounters_missing_groups"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/intermediate/data_quality__encounters_missing_groups_union.sql", "compiled": true, "compiled_code": "\n\nselect\n 'number of missing encounter groups' as data_quality_check\n , count(*) as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality.encounters_missing_groups", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": {"database": "cms_synthetic", "schema": "clinical_concept_library", "name": "clinical_concept_library__value_set_member_relevant_fields", "resource_type": "model", "package_name": "the_tuva_project", "path": "clinical_concept_library/clinical_concept_library__value_set_member_relevant_fields.sql", "original_file_path": "models/clinical_concept_library/clinical_concept_library__value_set_member_relevant_fields.sql", "unique_id": "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__value_set_member_relevant_fields"], "alias": "value_set_member_relevant_fields", "checksum": {"name": "sha256", "checksum": "bd7f76303a9191d33183bdbd2b90b9066aaee171ae0e5adbd3ebaad932d07c3d"}, "config": {"enabled": true, "alias": "value_set_member_relevant_fields", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["clinical_concept_library"], "description": "This model creates one record per value set member, but it includes relevant fields for each value set member taken from the clnical_concepts and coding_systems tables.\n", "columns": {"concept_id": {"name": "concept_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_name": {"name": "concept_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_type": {"name": "concept_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "value_set_member_id": {"name": "value_set_member_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_id": {"name": "coding_system_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "include_descendants": {"name": "include_descendants", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_name": {"name": "coding_system_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/clinical_concept_library/clinical_concept_library_models.yml", "build_path": null, "unrendered_config": {"schema": "clinical_concept_library", "alias": "value_set_member_relevant_fields", "tags": ["clinical_concept_library"], "materialized": "table", "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.433722, "relation_name": "cms_synthetic.clinical_concept_library.value_set_member_relevant_fields", "raw_code": "with value_set_member_relevant_fields as (\nselect \n aa.concept_id,\n aa.concept_name,\n aa.concept_type,\n \n bb.value_set_member_id,\n bb.code,\n bb.coding_system_id,\n bb.include_descendants,\n\n cc.coding_system_name\n \nfrom {{ ref('clinical_concept_library__clinical_concepts') }} aa\n\nleft join {{ ref('clinical_concept_library__value_set_members') }} bb\non aa.concept_id = bb.concept_id\n\nleft join {{ ref('clinical_concept_library__coding_systems') }} cc\non bb.coding_system_id = cc.coding_system_id\n)\n\n\nselect *\nfrom value_set_member_relevant_fields", "language": "sql", "refs": [{"name": "clinical_concept_library__clinical_concepts", "package": null, "version": null}, {"name": "clinical_concept_library__value_set_members", "package": null, "version": null}, {"name": "clinical_concept_library__coding_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.clinical_concept_library__clinical_concepts", "seed.the_tuva_project.clinical_concept_library__value_set_members", "seed.the_tuva_project.clinical_concept_library__coding_systems"]}, "compiled_path": "../target/compiled/the_tuva_project/models/clinical_concept_library/clinical_concept_library__value_set_member_relevant_fields.sql", "compiled": true, "compiled_code": "with value_set_member_relevant_fields as (\nselect \n aa.concept_id,\n aa.concept_name,\n aa.concept_type,\n \n bb.value_set_member_id,\n bb.code,\n bb.coding_system_id,\n bb.include_descendants,\n\n cc.coding_system_name\n \nfrom cms_synthetic.clinical_concept_library.clinical_concepts aa\n\nleft join cms_synthetic.clinical_concept_library.value_set_members bb\non aa.concept_id = bb.concept_id\n\nleft join cms_synthetic.clinical_concept_library.coding_systems cc\non bb.coding_system_id = cc.coding_system_id\n)\n\n\nselect *\nfrom value_set_member_relevant_fields", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__stg_patient": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__stg_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification/staging/ed_classification__stg_patient.sql", "original_file_path": "models/ed_classification/staging/ed_classification__stg_patient.sql", "unique_id": "model.the_tuva_project.ed_classification__stg_patient", "fqn": ["the_tuva_project", "ed_classification", "staging", "ed_classification__stg_patient"], "alias": "ed_classification__stg_patient", "checksum": {"name": "sha256", "checksum": "93bf9eadd001ac5f3e55956ede7e67da0b6f74958c993f297531954824a8e919"}, "config": {"enabled": true, "alias": null, "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ed_classification/ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "tags": "ed_classification", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.442773, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nselect\r\n patient_id\r\n , sex\r\n , birth_date\r\n , race\r\n , state\r\n , zip_code\r\n , latitude\r\n , longitude\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ed_classification/staging/ed_classification__stg_patient.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__stg_encounter": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__stg_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification/staging/ed_classification__stg_encounter.sql", "original_file_path": "models/ed_classification/staging/ed_classification__stg_encounter.sql", "unique_id": "model.the_tuva_project.ed_classification__stg_encounter", "fqn": ["the_tuva_project", "ed_classification", "staging", "ed_classification__stg_encounter"], "alias": "ed_classification__stg_encounter", "checksum": {"name": "sha256", "checksum": "525a4f9c49844caff49f705a367d314a0f74ff1dce35189ddd77cdf24e32341e"}, "config": {"enabled": true, "alias": null, "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ed_classification/ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "tags": "ed_classification", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.441508, "relation_name": null, "raw_code": "{{ config(\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom {{ ref('core__encounter') }}", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ed_classification/staging/ed_classification__stg_encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom cms_synthetic.core.encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__summary": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification/final/ed_classification__summary.sql", "original_file_path": "models/ed_classification/final/ed_classification__summary.sql", "unique_id": "model.the_tuva_project.ed_classification__summary", "fqn": ["the_tuva_project", "ed_classification", "final", "ed_classification__summary"], "alias": "summary", "checksum": {"name": "sha256", "checksum": "6d9836c0139a8da865128c9622eb2284e09e2844226e1988592feca5040e74ca"}, "config": {"enabled": true, "alias": "summary", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "ED Classification as a cube that can be summarized\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for the emergency_department encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_classification_description": {"name": "ed_classification_description", "description": "ED classification category.", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/ed_classification/ed_classification__categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_classification_order": {"name": "ed_classification_order", "description": "The order of the classification.", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/ed_classification/ed_classification__categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the patient was discharged.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Year and month of the encounter end date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total paid amount across all claims for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total allowed amount across all claims for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total charge amount across all claims for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "The ID for the facility where the encounter occurred.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "The name of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_state": {"name": "facility_state", "description": "The state of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_city": {"name": "facility_city", "description": "The city of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_zip_code": {"name": "facility_zip_code", "description": "The zip code of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_sex": {"name": "patient_sex", "description": "The sex of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_age": {"name": "patient_age", "description": "The age of the patient at the time of the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_zip_code": {"name": "patient_zip_code", "description": "The zip code for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_latitude": {"name": "patient_latitude", "description": "The latitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_longitude": {"name": "patient_longitude", "description": "The longitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_race": {"name": "patient_race", "description": "The race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ed_classification/ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "alias": "summary", "tags": "ed_classification", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.436896, "relation_name": "cms_synthetic.ed_classification.summary", "raw_code": "{{ config(\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\nselect\n class.encounter_id\n , cat.classification_name as ed_classification_description\n , cat.classification_order as ed_classification_order\n , class.patient_id\n , class.encounter_end_date\n , {{ dbt.concat([date_part('year', 'class.encounter_end_date'),\n dbt.right(\n dbt.concat([\"'00'\", date_part('month', 'class.encounter_end_date')])\n , 2)]) }} as year_month\n , class.primary_diagnosis_code\n , class.primary_diagnosis_description\n , class.paid_amount\n , class.allowed_amount\n , class.charge_amount\n , class.facility_id\n , fac_prov.provider_organization_name as facility_name\n , practice_state as facility_state\n , practice_city as facility_city\n , practice_zip_code as facility_zip_code\n , pat.sex as patient_sex\n , floor({{ datediff('pat.birth_date', 'class.encounter_end_date', 'hour') }} / 8766.0) as patient_age\n , zip_code as patient_zip_code\n , latitude as patient_latitude\n , longitude as patient_longitude\n , race as patient_race\nfrom {{ ref('ed_classification__int_filter_encounter_with_classification') }} class\ninner join {{ ref('ed_classification__categories') }} cat\n on class.classification = cat.classification\nleft join {{ ref('terminology__provider') }} fac_prov \n on class.facility_id = fac_prov.npi\nleft join {{ ref('ed_classification__stg_patient') }} pat\n on class.patient_id = pat.patient_id", "language": "sql", "refs": [{"name": "ed_classification__int_filter_encounter_with_classification", "package": null, "version": null}, {"name": "ed_classification__categories", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "ed_classification__stg_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.right", "macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "seed.the_tuva_project.ed_classification__categories", "seed.the_tuva_project.terminology__provider", "model.the_tuva_project.ed_classification__stg_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ed_classification/final/ed_classification__summary.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__ed_classification__stg_patient as (\n\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom cms_synthetic.core.patient\n) select\n class.encounter_id\n , cat.classification_name as ed_classification_description\n , cat.classification_order as ed_classification_order\n , class.patient_id\n , class.encounter_end_date\n , date_part('year', class.encounter_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '00' || date_part('month', class.encounter_end_date),\n 2\n )\n end as year_month\n , class.primary_diagnosis_code\n , class.primary_diagnosis_description\n , class.paid_amount\n , class.allowed_amount\n , class.charge_amount\n , class.facility_id\n , fac_prov.provider_organization_name as facility_name\n , practice_state as facility_state\n , practice_city as facility_city\n , practice_zip_code as facility_zip_code\n , pat.sex as patient_sex\n , floor(datediff(\n hour,\n pat.birth_date,\n class.encounter_end_date\n ) / 8766.0) as patient_age\n , zip_code as patient_zip_code\n , latitude as patient_latitude\n , longitude as patient_longitude\n , race as patient_race\nfrom cms_synthetic.ed_classification._int_filter_encounter_with_classification class\ninner join cms_synthetic.ed_classification._value_set_categories cat\n on class.classification = cat.classification\nleft join cms_synthetic.terminology.provider fac_prov \n on class.facility_id = fac_prov.npi\nleft join __dbt__cte__ed_classification__stg_patient pat\n on class.patient_id = pat.patient_id", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ed_classification__stg_patient", "sql": " __dbt__cte__ed_classification__stg_patient as (\n\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__int_filter_encounter_with_classification", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification/intermediate/ed_classification__int_filter_encounter_with_classification.sql", "original_file_path": "models/ed_classification/intermediate/ed_classification__int_filter_encounter_with_classification.sql", "unique_id": "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "fqn": ["the_tuva_project", "ed_classification", "intermediate", "ed_classification__int_filter_encounter_with_classification"], "alias": "_int_filter_encounter_with_classification", "checksum": {"name": "sha256", "checksum": "2f3015483c0870f1d9d0a95c3dacdd5bb02f7819982ff47aa7c7e59b36af8ae9"}, "config": {"enabled": true, "alias": "_int_filter_encounter_with_classification", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "Filter out ED visits that were not classified", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ed_classification/ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "alias": "_int_filter_encounter_with_classification", "tags": "ed_classification", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.438503, "relation_name": "cms_synthetic.ed_classification._int_filter_encounter_with_classification", "raw_code": "/*\nFilter conditions to those that were classified and pick the classification\nwith the greatest probability (that's the greatest logic). This logic removes\nany rows that were not classified.\n*/\n{{ config(\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n a.*\n , case greatest(edcnnpa, edcnpa, epct, noner, injury, psych, alcohol, drug)\n when edcnnpa then 'edcnnpa'\n when edcnpa then 'edcnpa'\n when epct then 'epct'\n when noner then 'noner'\n when injury then 'injury'\n when psych then 'psych'\n when alcohol then 'alcohol'\n when drug then 'drug'\n else 'unclassified'\n end as classification\nfrom {{ ref('ed_classification__int_map_primary_dx') }} a\nwhere ed_classification_capture = 1", "language": "sql", "refs": [{"name": "ed_classification__int_map_primary_dx", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ed_classification__int_map_primary_dx"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ed_classification/intermediate/ed_classification__int_filter_encounter_with_classification.sql", "compiled": true, "compiled_code": "/*\nFilter conditions to those that were classified and pick the classification\nwith the greatest probability (that's the greatest logic). This logic removes\nany rows that were not classified.\n*/\n\n\nselect\n a.*\n , case greatest(edcnnpa, edcnpa, epct, noner, injury, psych, alcohol, drug)\n when edcnnpa then 'edcnnpa'\n when edcnpa then 'edcnpa'\n when epct then 'epct'\n when noner then 'noner'\n when injury then 'injury'\n when psych then 'psych'\n when alcohol then 'alcohol'\n when drug then 'drug'\n else 'unclassified'\n end as classification\nfrom cms_synthetic.ed_classification._int_by_provider_parent_organization a\nwhere ed_classification_capture = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__int_map_primary_dx": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__int_map_primary_dx", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification/intermediate/ed_classification__int_map_primary_dx.sql", "original_file_path": "models/ed_classification/intermediate/ed_classification__int_map_primary_dx.sql", "unique_id": "model.the_tuva_project.ed_classification__int_map_primary_dx", "fqn": ["the_tuva_project", "ed_classification", "intermediate", "ed_classification__int_map_primary_dx"], "alias": "_int_by_provider_parent_organization", "checksum": {"name": "sha256", "checksum": "643f0e5d59ab25994503a2b4862de511fcffe6c40d0e37f482f4e71f66cb59a4"}, "config": {"enabled": true, "alias": "_int_by_provider_parent_organization", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "Map ED encounter primary dx to classification", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ed_classification/ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "alias": "_int_by_provider_parent_organization", "tags": "ed_classification", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.440019, "relation_name": "cms_synthetic.ed_classification._int_by_provider_parent_organization", "raw_code": "/*\nAll condition discharge diagnosis left join with probabilistic\nindicators of ED classification terminology\n*/\n\n{{ config(\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n{% set colnames = [\"edcnnpa\", \"edcnpa\", \"epct\", \"noner\", \"injury\", \"psych\", \"alcohol\", \"drug\"] %}\n\nwith condition as (\n select * \n from {{ ref('ed_classification__stg_encounter') }}\n where encounter_type = 'emergency department'\n)\n, icd9 as (\n select\n icd9 as code\n {% for colname in colnames %}\n , {{colname}}\n {% endfor %}\n , 1 as ed_classification_capture\n from {{ ref('ed_classification__johnston_icd9') }}\n)\n, icd10 as (\n select\n icd10 as code\n {% for colname in colnames %}\n , {{colname}}\n {% endfor %}\n , 1 as ed_classification_capture\n from {{ ref('ed_classification__johnston_icd10') }}\n)\n\nselect\n a.*\n {% for colname in colnames %}\n , icd10.{{colname}}\n {% endfor %}\n , coalesce(icd10.ed_classification_capture, 0) as ed_classification_capture\nfrom condition a\nleft join icd10\n on a.primary_diagnosis_code = icd10.code \n and a.primary_diagnosis_code_type = 'icd-10-cm'\n\nunion all\n\nselect\n a.*\n {% for colname in colnames %}\n , icd9.{{colname}}\n {% endfor %}\n , coalesce(icd9.ed_classification_capture, 0) ed_classification_capture\nfrom condition a\ninner join icd9\n on a.primary_diagnosis_code = icd9.code \n and a.primary_diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "ed_classification__stg_encounter", "package": null, "version": null}, {"name": "ed_classification__johnston_icd9", "package": null, "version": null}, {"name": "ed_classification__johnston_icd10", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ed_classification__stg_encounter", "seed.the_tuva_project.ed_classification__johnston_icd9", "seed.the_tuva_project.ed_classification__johnston_icd10"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ed_classification/intermediate/ed_classification__int_map_primary_dx.sql", "compiled": true, "compiled_code": "/*\nAll condition discharge diagnosis left join with probabilistic\nindicators of ED classification terminology\n*/\n\n\n\n\nwith __dbt__cte__ed_classification__stg_encounter as (\n\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom cms_synthetic.core.encounter\n), condition as (\n select * \n from __dbt__cte__ed_classification__stg_encounter\n where encounter_type = 'emergency department'\n)\n, icd9 as (\n select\n icd9 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from cms_synthetic.ed_classification._value_set_johnston_icd9\n)\n, icd10 as (\n select\n icd10 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from cms_synthetic.ed_classification._value_set_johnston_icd10\n)\n\nselect\n a.*\n \n , icd10.edcnnpa\n \n , icd10.edcnpa\n \n , icd10.epct\n \n , icd10.noner\n \n , icd10.injury\n \n , icd10.psych\n \n , icd10.alcohol\n \n , icd10.drug\n \n , coalesce(icd10.ed_classification_capture, 0) as ed_classification_capture\nfrom condition a\nleft join icd10\n on a.primary_diagnosis_code = icd10.code \n and a.primary_diagnosis_code_type = 'icd-10-cm'\n\nunion all\n\nselect\n a.*\n \n , icd9.edcnnpa\n \n , icd9.edcnpa\n \n , icd9.epct\n \n , icd9.noner\n \n , icd9.injury\n \n , icd9.psych\n \n , icd9.alcohol\n \n , icd9.drug\n \n , coalesce(icd9.ed_classification_capture, 0) ed_classification_capture\nfrom condition a\ninner join icd9\n on a.primary_diagnosis_code = icd9.code \n and a.primary_diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ed_classification__stg_encounter", "sql": " __dbt__cte__ed_classification__stg_encounter as (\n\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom cms_synthetic.core.encounter\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__stg_core__encounter": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "readmissions__stg_core__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/staging/readmissions__stg_core__encounter.sql", "original_file_path": "models/readmissions/staging/readmissions__stg_core__encounter.sql", "unique_id": "model.the_tuva_project.readmissions__stg_core__encounter", "fqn": ["the_tuva_project", "readmissions", "staging", "readmissions__stg_core__encounter"], "alias": "readmissions__stg_core__encounter", "checksum": {"name": "sha256", "checksum": "66ffb8120d08b36145ee89a9a2c29176ab1fd289dd1a409d879f609498360d87"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"tags": "readmissions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.475801, "relation_name": null, "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__encounter') }}\nwhere encounter_type = 'acute inpatient'", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/staging/readmissions__stg_core__encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__stg_core__procedure": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "readmissions__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/staging/readmissions__stg_core__procedure.sql", "original_file_path": "models/readmissions/staging/readmissions__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.readmissions__stg_core__procedure", "fqn": ["the_tuva_project", "readmissions", "staging", "readmissions__stg_core__procedure"], "alias": "readmissions__stg_core__procedure", "checksum": {"name": "sha256", "checksum": "c816d91c30e6ce803762c90aee634d96f897551abf96317ec163e0e8a2c98ed0"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"tags": "readmissions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.47662, "relation_name": null, "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/staging/readmissions__stg_core__procedure.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_augmented": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__encounter_augmented", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/final/readmissions__encounter_augmented.sql", "original_file_path": "models/readmissions/final/readmissions__encounter_augmented.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_augmented", "fqn": ["the_tuva_project", "readmissions", "final", "readmissions__encounter_augmented"], "alias": "encounter_augmented", "checksum": {"name": "sha256", "checksum": "b0bf7d467d0eb4b923e1f0970f2656635777d4faada47ab38e94135ba9f9e00a"}, "config": {"enabled": true, "alias": "encounter_augmented", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model includes all encounters from the stg_encounter model, and for each encounter_id we add fields relevant for the encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The date of discharge for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "The valid 2-digit discharge status for the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "An ID for the facility where the inpatient visit occurred", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "The MS-DRG associted with the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The number of dollars paid on the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Integer representing the length of stay of the inpatient visit in days", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "index_admission_flag": {"name": "index_admission_flag", "description": "Flag to indicate if the encounter is an index admission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "planned_flag": {"name": "planned_flag", "description": "Flag to indicate if the encounter was planned", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort the encounter belongs to", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__specialty_cohort.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "died_flag": {"name": "died_flag", "description": "Flag to indicate of the patient died in this encounter", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "diagnosis_ccs": {"name": "diagnosis_ccs", "description": "CCS code associated with the primary diagnosis for the encounter", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "disqualified_encounter_flag": {"name": "disqualified_encounter_flag", "description": "A flag that indicates whether this encounter is disqualified from being used in readmission measures for any critical data quality problem.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_admit_date_flag": {"name": "missing_admit_date_flag", "description": "A flag that indicates whether the admit date is missing from this encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_discharge_date_flag": {"name": "missing_discharge_date_flag", "description": "A flag that indicates whether the discharge date is missing from this encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "admit_after_discharge_flag": {"name": "admit_after_discharge_flag", "description": "A flag that indicates whether the admit date for the encounter is after the discharge date for the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_discharge_disposition_code_flag": {"name": "missing_discharge_disposition_code_flag", "description": "A flag that indicates whether the discharge status code is missing for the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "invalid_discharge_disposition_code_flag": {"name": "invalid_discharge_disposition_code_flag", "description": "A flag that indicates whether the discharge status code that is present for this encounter is invalid. This flag is 1 only when the discharge status code is present but invalid.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_primary_diagnosis_flag": {"name": "missing_primary_diagnosis_flag", "description": "A flag that indicates whether there is no primary diagnosis associated with the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "multiple_primary_diagnoses_flag": {"name": "multiple_primary_diagnoses_flag", "description": "A flag that indicates whether there are multiple primary diagnoses associated with the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "invalid_primary_diagnosis_code_flag": {"name": "invalid_primary_diagnosis_code_flag", "description": "A flag that indicates whether the primary diagnosis present for this encounter is invalid, i.e. a non existing ICD-10-CM code. This flag indicates that a primary diagnosis code is indeed present for the encounter, but it is not a valid ICD-10-CM code.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "no_diagnosis_ccs_flag": {"name": "no_diagnosis_ccs_flag", "description": "A flag that indicates whether there is no CCS diagnosis category associated with the primary ICD-10-CM diagnosis code for the encounter. This flag indicates that there is a valid primary ICD-10-CM diagnosis code associated with the encounter, but there is no CCS diagnosis category associated with that ICD-10-CM code.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "overlaps_with_another_encounter_flag": {"name": "overlaps_with_another_encounter_flag", "description": "A flag that indicates whether this encounter's dates overlap with those of another encounter in the dataset", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_ms_drg_flag": {"name": "missing_ms_drg_flag", "description": "A flag that indicates whether this encounter contains a claim with a missing ms-drg code", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "invalid_ms_drg_flag": {"name": "invalid_ms_drg_flag", "description": "A flag that indicates whether this encounter contains a claim with an invalid missing ms-drg code", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "encounter_augmented", "tags": "readmissions", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.448162, "relation_name": "cms_synthetic.readmissions.encounter_augmented", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list all encounters from the stg_encounter model\n-- and we augment them with extra fields\n-- that are relevant for readmission measures\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n {{ dbt.datediff(\"aa.admit_date\", \"aa.discharge_date\",\"day\") }} as length_of_stay,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as index_admission_flag,\n case\n when cc.encounter_id is not null then 1\n\t else 0\n end as planned_flag,\n dd.specialty_cohort,\n case\n when aa.discharge_disposition_code = '20' then 1\n\t else 0\n end as died_flag,\n ee.diagnosis_ccs,\n ee.disqualified_encounter_flag,\n ee.missing_admit_date_flag,\n ee.missing_discharge_date_flag,\n ee.admit_after_discharge_flag,\n ee.missing_discharge_disposition_code_flag,\n ee.invalid_discharge_disposition_code_flag,\n ee.missing_primary_diagnosis_flag,\n ee.invalid_primary_diagnosis_code_flag,\n ee.no_diagnosis_ccs_flag,\n ee.overlaps_with_another_encounter_flag,\n ee.missing_ms_drg_flag,\n ee.invalid_ms_drg_flag,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom\n {{ ref('readmissions__encounter') }} aa\n left join {{ ref('readmissions__index_admission') }} bb\n on aa.encounter_id = bb.encounter_id\n left join {{ ref('readmissions__planned_encounter') }} cc\n on aa.encounter_id = cc.encounter_id \n left join {{ ref('readmissions__encounter_specialty_cohort') }} dd\n on aa.encounter_id = dd.encounter_id\n left join {{ ref('readmissions__encounter_data_quality') }} ee\n on aa.encounter_id = ee.encounter_id", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__index_admission", "package": null, "version": null}, {"name": "readmissions__planned_encounter", "package": null, "version": null}, {"name": "readmissions__encounter_specialty_cohort", "package": null, "version": null}, {"name": "readmissions__encounter_data_quality", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__index_admission", "model.the_tuva_project.readmissions__planned_encounter", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__encounter_data_quality"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/final/readmissions__encounter_augmented.sql", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter model\n-- and we augment them with extra fields\n-- that are relevant for readmission measures\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n datediff(\n day,\n aa.admit_date,\n aa.discharge_date\n ) as length_of_stay,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as index_admission_flag,\n case\n when cc.encounter_id is not null then 1\n\t else 0\n end as planned_flag,\n dd.specialty_cohort,\n case\n when aa.discharge_disposition_code = '20' then 1\n\t else 0\n end as died_flag,\n ee.diagnosis_ccs,\n ee.disqualified_encounter_flag,\n ee.missing_admit_date_flag,\n ee.missing_discharge_date_flag,\n ee.admit_after_discharge_flag,\n ee.missing_discharge_disposition_code_flag,\n ee.invalid_discharge_disposition_code_flag,\n ee.missing_primary_diagnosis_flag,\n ee.invalid_primary_diagnosis_code_flag,\n ee.no_diagnosis_ccs_flag,\n ee.overlaps_with_another_encounter_flag,\n ee.missing_ms_drg_flag,\n ee.invalid_ms_drg_flag,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n cms_synthetic.readmissions._int_encounter aa\n left join cms_synthetic.readmissions._int_index_admission bb\n on aa.encounter_id = bb.encounter_id\n left join cms_synthetic.readmissions._int_planned_encounter cc\n on aa.encounter_id = cc.encounter_id \n left join cms_synthetic.readmissions._int_encounter_specialty_cohort dd\n on aa.encounter_id = dd.encounter_id\n left join cms_synthetic.readmissions._int_encounter_data_quality ee\n on aa.encounter_id = ee.encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__readmission_summary": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__readmission_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/final/readmissions__readmission_summary.sql", "original_file_path": "models/readmissions/final/readmissions__readmission_summary.sql", "unique_id": "model.the_tuva_project.readmissions__readmission_summary", "fqn": ["the_tuva_project", "readmissions", "final", "readmissions__readmission_summary"], "alias": "readmission_summary", "checksum": {"name": "sha256", "checksum": "435069b12a42e54d399c51de99bf45fdc3fef2e7a12031208b965b755838e9b2"}, "config": {"enabled": true, "alias": "readmission_summary", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model includes all rows from the encounter_augmented model where disqualified_encounter_flag = 0 (all rows for encounters that are not disqualified for data quality issues). For each of these encounters we add fields to indicate whether it had a readmission and, when a readmission was present, to show relevant fields for the readmission.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The date of discharge for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "The valid 2-digit discharge status for the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "An ID for the facility where the inpatient visit occurred", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "The MS-DRG associted with the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The amount paid for the visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Integer representing the length of stay of the inpatient visit in days", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "index_admission_flag": {"name": "index_admission_flag", "description": "Flag to indicate if the encounter is an index admission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "planned_flag": {"name": "planned_flag", "description": "Flag to indicate if the encounter was planned", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort the encounter belongs to", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__specialty_cohort.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "died_flag": {"name": "died_flag", "description": "Flag to indicate of the patient died in this encounter", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "diagnosis_ccs": {"name": "diagnosis_ccs", "description": "CCS code associated with the primary diagnosis for the encounter", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "had_readmission_flag": {"name": "had_readmission_flag", "description": "A flag to indicate whether the encounter had a readmission any number of days after discharge", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "days_to_readmit": {"name": "days_to_readmit", "description": "An integer to indicate the number of days to readmission", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "readmit_30_flag": {"name": "readmit_30_flag", "description": "A flag to indicate whether the encounter had a 30-day readmission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "unplanned_readmit_30_flag": {"name": "unplanned_readmit_30_flag", "description": "A flag to indicate whether the encounter had an unplanned 30-day readmission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_encounter_id": {"name": "readmission_encounter_id", "description": "The unique identifier for the readmission encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_admit_date": {"name": "readmission_admit_date", "description": "The date of admission for the readmission inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_discharge_date": {"name": "readmission_discharge_date", "description": "The date of discharge for the readmission inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_discharge_disposition_code": {"name": "readmission_discharge_disposition_code", "description": "The valid 2-digit discharge status for the readmission inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_facility": {"name": "readmission_facility", "description": "A name or ID for the facility where the readmission inpatient visit occured", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_ms_drg": {"name": "readmission_ms_drg", "description": "The MS-DRG associted with the readmission inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_length_of_stay": {"name": "readmission_length_of_stay", "description": "Integer representing the length of stay of the readmission inpatient visit in days", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "readmission_index_admission_flag": {"name": "readmission_index_admission_flag", "description": "Flag to indicate if the readmission encounter is an index admission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_planned_flag": {"name": "readmission_planned_flag", "description": "Flag to indicate if the readmission encounter was planned", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_specialty_cohort": {"name": "readmission_specialty_cohort", "description": "Specialty cohort the readmission encounter belongs to", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__specialty_cohort.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_died_flag": {"name": "readmission_died_flag", "description": "Flag to indicate of the patient died in the readmission encounter", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_diagnosis_ccs": {"name": "readmission_diagnosis_ccs", "description": "CCS code associated with the primary diagnosis for the readmission encounter", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "readmission_summary", "tags": "readmissions", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.452839, "relation_name": "cms_synthetic.readmissions.readmission_summary", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here calculate days to readmission for encounters\n-- that had a readmission and create readmission flags\n\n\n-- We create the encounter_sequence integer count\n-- which keeps track of what number of encounter each\n-- encounter is for a given patient\nwith encounter_sequence as (\nselect\n *,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom {{ ref('readmissions__encounter_augmented') }}\nwhere disqualified_encounter_flag = 0\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.length_of_stay,\n aa.index_admission_flag,\n aa.planned_flag,\n aa.specialty_cohort,\n aa.died_flag,\n aa.diagnosis_ccs,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as had_readmission_flag,\n {{ dbt.datediff(\"aa.discharge_date\", \"bb.admit_date\",\"day\") }} as days_to_readmit,\n case\n when ({{ dbt.datediff(\"aa.discharge_date\", \"bb.admit_date\",\"day\") }}) <= 30 then 1\n\t else 0\n end as readmit_30_flag,\n case\n when\n\t (({{ dbt.datediff(\"aa.discharge_date\", \"bb.admit_date\", \"day\") }}) <= 30) and (bb.planned_flag = 0) then 1\n\t else 0\n end as unplanned_readmit_30_flag,\n bb.encounter_id as readmission_encounter_id,\n bb.admit_date as readmission_admit_date,\n bb.discharge_date as readmission_discharge_date,\n bb.discharge_disposition_code as readmission_discharge_disposition_code,\n bb.facility_id as readmission_facility,\n bb.ms_drg_code as readmission_ms_drg,\n bb.length_of_stay as readmission_length_of_stay,\n bb.index_admission_flag as readmission_index_admission_flag,\n bb.planned_flag as readmission_planned_flag,\n bb.specialty_cohort as readmission_specialty_cohort,\n bb.died_flag as readmission_died_flag,\n bb.diagnosis_ccs as readmission_diagnosis_ccs,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom\n encounter_sequence aa\n left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\nselect *\nfrom readmission_calc", "language": "sql", "refs": [{"name": "readmissions__encounter_augmented", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.readmissions__encounter_augmented"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/final/readmissions__readmission_summary.sql", "compiled": true, "compiled_code": "\n\n-- Here calculate days to readmission for encounters\n-- that had a readmission and create readmission flags\n\n\n-- We create the encounter_sequence integer count\n-- which keeps track of what number of encounter each\n-- encounter is for a given patient\nwith encounter_sequence as (\nselect\n *,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom cms_synthetic.readmissions.encounter_augmented\nwhere disqualified_encounter_flag = 0\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.length_of_stay,\n aa.index_admission_flag,\n aa.planned_flag,\n aa.specialty_cohort,\n aa.died_flag,\n aa.diagnosis_ccs,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as had_readmission_flag,\n datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30 then 1\n\t else 0\n end as readmit_30_flag,\n case\n when\n\t ((datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30) and (bb.planned_flag = 0) then 1\n\t else 0\n end as unplanned_readmit_30_flag,\n bb.encounter_id as readmission_encounter_id,\n bb.admit_date as readmission_admit_date,\n bb.discharge_date as readmission_discharge_date,\n bb.discharge_disposition_code as readmission_discharge_disposition_code,\n bb.facility_id as readmission_facility,\n bb.ms_drg_code as readmission_ms_drg,\n bb.length_of_stay as readmission_length_of_stay,\n bb.index_admission_flag as readmission_index_admission_flag,\n bb.planned_flag as readmission_planned_flag,\n bb.specialty_cohort as readmission_specialty_cohort,\n bb.died_flag as readmission_died_flag,\n bb.diagnosis_ccs as readmission_diagnosis_ccs,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n encounter_sequence aa\n left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\nselect *\nfrom readmission_calc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_overlap": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__encounter_overlap", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__encounter_overlap.sql", "original_file_path": "models/readmissions/intermediate/readmissions__encounter_overlap.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_overlap", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_overlap"], "alias": "_int_encounter_overlap", "checksum": {"name": "sha256", "checksum": "eb8a395a092863ed43d1b50a23475b1a081b5852a2a5fd033dfd069cabd0bd12"}, "config": {"enabled": true, "alias": "_int_encounter_overlap", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all pairs of encounters that have some date overlap.", "columns": {"patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id_A": {"name": "encounter_id_A", "description": "Unique identifier for one of the overlapping encounters", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id_B": {"name": "encounter_id_B", "description": "Unique identifier for the other overlapping encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_overlap", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.457315, "relation_name": "cms_synthetic.readmissions._int_encounter_overlap", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we give a list of all pairs of encounters\n-- that have some date overlap.\n\n\nwith encounters_with_row_num as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over (\n partition by patient_id order by encounter_id\n\t) as row_num\nfrom {{ ref('readmissions__encounter') }}\n),\n\n\ncartesian as (\nselect\n aa.encounter_id as encounter_id_A,\n bb.encounter_id as encounter_id_B,\n aa.patient_id,\n aa.admit_date as Ai,\n aa.discharge_date as Af,\n bb.admit_date as Bi,\n bb.discharge_date as Bf,\n case\n when (aa.admit_date between bb.admit_date and bb.discharge_date) or (aa.discharge_date between bb.admit_date and bb.discharge_date) or\n (bb.admit_date between aa.admit_date and aa.discharge_date) or (bb.discharge_date between aa.admit_date and aa.discharge_date)\n then 1\n else 0\n end as overlap\n from encounters_with_row_num aa\n left join encounters_with_row_num bb\n on aa.patient_id = bb.patient_id and aa.row_num < bb.row_num\n),\n\n\noverlapping_pairs\nas\n(\n select\n patient_id,\n encounter_id_A,\n\tencounter_id_B\n from cartesian\n where overlap = 1\n)\n\n\n\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom overlapping_pairs", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__encounter_overlap.sql", "compiled": true, "compiled_code": "\n\n-- Here we give a list of all pairs of encounters\n-- that have some date overlap.\n\n\nwith encounters_with_row_num as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over (\n partition by patient_id order by encounter_id\n\t) as row_num\nfrom cms_synthetic.readmissions._int_encounter\n),\n\n\ncartesian as (\nselect\n aa.encounter_id as encounter_id_A,\n bb.encounter_id as encounter_id_B,\n aa.patient_id,\n aa.admit_date as Ai,\n aa.discharge_date as Af,\n bb.admit_date as Bi,\n bb.discharge_date as Bf,\n case\n when (aa.admit_date between bb.admit_date and bb.discharge_date) or (aa.discharge_date between bb.admit_date and bb.discharge_date) or\n (bb.admit_date between aa.admit_date and aa.discharge_date) or (bb.discharge_date between aa.admit_date and aa.discharge_date)\n then 1\n else 0\n end as overlap\n from encounters_with_row_num aa\n left join encounters_with_row_num bb\n on aa.patient_id = bb.patient_id and aa.row_num < bb.row_num\n),\n\n\noverlapping_pairs\nas\n(\n select\n patient_id,\n encounter_id_A,\n\tencounter_id_B\n from cartesian\n where overlap = 1\n)\n\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom overlapping_pairs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_specialty_cohort": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__encounter_specialty_cohort", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__encounter_specialty_cohort.sql", "original_file_path": "models/readmissions/intermediate/readmissions__encounter_specialty_cohort.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_specialty_cohort", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_specialty_cohort"], "alias": "_int_encounter_specialty_cohort", "checksum": {"name": "sha256", "checksum": "292379dd0c9c63875534ec93898088800dbb0b644b11a7b18198bcb337e0112c"}, "config": {"enabled": true, "alias": "_int_encounter_specialty_cohort", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists the specialty cohort associated with each inpatient encounter. All encounters in the stg_encounter model are present here, and each gets a specialty cohort assigned from the following list of 5 options: Surgery/Gynecology, Medicine, Cardiorespiratory, Cardiovascular, Neurology. Encounters that don't have a specialty cohort get 'Medicine' assigned by default.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "The specialty cohort associated with the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_specialty_cohort", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.458904, "relation_name": "cms_synthetic.readmissions._int_encounter_specialty_cohort", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list the specialty cohort for each encounter that has\n-- an associated specialty cohort.\n-- There are 5 possible specialty cohorts:\n-- [1] Medicine\n-- [2] Surgery/Gynecology\n-- [3] Cardiology\n-- [4] Cardiovascular\n-- [5] Neurology\n-- An encounter that has an ICD-10-PCS procedure code or a\n-- CCS procedure category that corresponds to the\n-- 'Surgery/Gynecology' cohort will always be in that cohort.\n-- For encounters that are not in the 'Surgery/Gynecology' cohort,\n-- we then check to see if they are in one of the other 4 cohorts.\n\n--ranking to eventually assign a cohort to encounters in multiple cohorts\nwith cohort_ranks as (\n select 'Surgery/Gynecology' as cohort, 1 as c_rank\n union all\n select 'Cardiorespiratory' as cohort, 2 as c_rank\n union all\n select 'Cardiovascular' as cohort, 3 as c_rank\n union all\n select 'Neurology' as cohort, 4 as c_rank\n union all\n select 'Medicine' as cohort, 5 as c_rank\n)\n\n\n--get all encounter ids in any procedure or diagnosis based cohorts\n, all_encounter_cohorts as (\n\n --encounter ids in procedure based cohorts\n select procs.encounter_id, 1 as c_rank\n from {{ ref('readmissions__procedure_ccs') }} procs\n left join {{ ref('readmissions__surgery_gynecology_cohort') }} sgc\n on procs.procedure_code = sgc.icd_10_pcs\n left join {{ ref('readmissions__specialty_cohort') }} sgsc\n on procs.ccs_procedure_category = sgsc.ccs and sgsc.specialty_cohort = 'Surgery/Gynecology'\n where sgc.icd_10_pcs is not null or sgsc.ccs is not null\n\n union all\n\n --encounter ids in diagnosis based cohorts\n select diag.encounter_id, cohort_ranks.c_rank\n from {{ ref('readmissions__encounter_with_ccs') }} diag\n inner join {{ ref('readmissions__specialty_cohort') }} sc\n on diag.ccs_diagnosis_category = sc.ccs and sc.procedure_or_diagnosis = 'Diagnosis'\n inner join cohort_ranks\n on sc.specialty_cohort = cohort_ranks.cohort\n)\n\n\n-- getting one cohort per encounter\n, main_encounter_cohort as (\n select encounter_id, min(c_rank) as main_c_rank\n from all_encounter_cohorts\n group by encounter_id\n\n)\n\n\n--getting all encounters, with labeled cohorts, if no cohort cohort is \"medicine\"\nselect enc.encounter_id, coalesce(cohort_ranks.cohort, 'Medicine') as specialty_cohort, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('readmissions__encounter') }} enc\nleft join main_encounter_cohort mec\n on enc.encounter_id = mec.encounter_id\nleft join cohort_ranks\n on mec.main_c_rank = cohort_ranks.c_rank", "language": "sql", "refs": [{"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__surgery_gynecology_cohort", "package": null, "version": null}, {"name": "readmissions__specialty_cohort", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__specialty_cohort", "package": null, "version": null}, {"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__surgery_gynecology_cohort", "seed.the_tuva_project.readmissions__specialty_cohort", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__encounter_specialty_cohort.sql", "compiled": true, "compiled_code": "\n\n-- Here we list the specialty cohort for each encounter that has\n-- an associated specialty cohort.\n-- There are 5 possible specialty cohorts:\n-- [1] Medicine\n-- [2] Surgery/Gynecology\n-- [3] Cardiology\n-- [4] Cardiovascular\n-- [5] Neurology\n-- An encounter that has an ICD-10-PCS procedure code or a\n-- CCS procedure category that corresponds to the\n-- 'Surgery/Gynecology' cohort will always be in that cohort.\n-- For encounters that are not in the 'Surgery/Gynecology' cohort,\n-- we then check to see if they are in one of the other 4 cohorts.\n\n--ranking to eventually assign a cohort to encounters in multiple cohorts\nwith cohort_ranks as (\n select 'Surgery/Gynecology' as cohort, 1 as c_rank\n union all\n select 'Cardiorespiratory' as cohort, 2 as c_rank\n union all\n select 'Cardiovascular' as cohort, 3 as c_rank\n union all\n select 'Neurology' as cohort, 4 as c_rank\n union all\n select 'Medicine' as cohort, 5 as c_rank\n)\n\n\n--get all encounter ids in any procedure or diagnosis based cohorts\n, all_encounter_cohorts as (\n\n --encounter ids in procedure based cohorts\n select procs.encounter_id, 1 as c_rank\n from cms_synthetic.readmissions._int_procedure_ccs procs\n left join cms_synthetic.readmissions._value_set_surgery_gynecology_cohort sgc\n on procs.procedure_code = sgc.icd_10_pcs\n left join cms_synthetic.readmissions._value_set_specialty_cohort sgsc\n on procs.ccs_procedure_category = sgsc.ccs and sgsc.specialty_cohort = 'Surgery/Gynecology'\n where sgc.icd_10_pcs is not null or sgsc.ccs is not null\n\n union all\n\n --encounter ids in diagnosis based cohorts\n select diag.encounter_id, cohort_ranks.c_rank\n from cms_synthetic.readmissions._int_encounter_with_ccs diag\n inner join cms_synthetic.readmissions._value_set_specialty_cohort sc\n on diag.ccs_diagnosis_category = sc.ccs and sc.procedure_or_diagnosis = 'Diagnosis'\n inner join cohort_ranks\n on sc.specialty_cohort = cohort_ranks.cohort\n)\n\n\n-- getting one cohort per encounter\n, main_encounter_cohort as (\n select encounter_id, min(c_rank) as main_c_rank\n from all_encounter_cohorts\n group by encounter_id\n\n)\n\n\n--getting all encounters, with labeled cohorts, if no cohort cohort is \"medicine\"\nselect enc.encounter_id, coalesce(cohort_ranks.cohort, 'Medicine') as specialty_cohort, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter enc\nleft join main_encounter_cohort mec\n on enc.encounter_id = mec.encounter_id\nleft join cohort_ranks\n on mec.main_c_rank = cohort_ranks.c_rank", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_data_quality": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__encounter_data_quality", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__encounter_data_quality.sql", "original_file_path": "models/readmissions/intermediate/readmissions__encounter_data_quality.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_data_quality", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_data_quality"], "alias": "_int_encounter_data_quality", "checksum": {"name": "sha256", "checksum": "31c256f2bc613d506ea3de4c3d2addf5f8d00ab1e623d92a1439a6caa995b141"}, "config": {"enabled": true, "alias": "_int_encounter_data_quality", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model has the same number of rows as the stg_encounter model. Here we have one row for every unique encounter in the stg_encounter model, and for each encounter we have a flag (disqualified_encounter_flag) to indicte if the encounter is disqualified from being useful for readmission measures. We also have other flags to indicate which specific data quality issues this encounter has that may disqualify it from being used in readmission measures.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_ccs": {"name": "diagnosis_ccs", "description": "The CCS diagnosis category associated with the primary diagnosis of this encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "disqualified_encounter_flag": {"name": "disqualified_encounter_flag", "description": "A flag that indicates whether this encounter is disqualified from being used in readmission measures for any critical data quality problem.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_admit_date_flag": {"name": "missing_admit_date_flag", "description": "A flag that indicates whether the admit date is missing from this encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_discharge_date_flag": {"name": "missing_discharge_date_flag", "description": "A flag that indicates whether the discharge date is missing from this encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_after_discharge_flag": {"name": "admit_after_discharge_flag", "description": "A flag that indicates whether the admit date for the encounter is after the discharge date for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_discharge_status_code_flag": {"name": "missing_discharge_status_code_flag", "description": "A flag that indicates whether the discharge status code is missing for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_discharge_status_code_flag": {"name": "invalid_discharge_status_code_flag", "description": "A flag that indicates whether the discharge status code that is present for this encounter is invalid. This flag is 1 only when the discharge status code is present but invalid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_primary_diagnosis_flag": {"name": "missing_primary_diagnosis_flag", "description": "A flag that indicates whether there is no primary diagnosis associated with the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "multiple_primary_diagnosis": {"name": "multiple_primary_diagnosis", "description": "A flag that indicates whether there are multiple primary diagnoses associated with the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_primary_diagnosis_code": {"name": "invalid_primary_diagnosis_code", "description": "A flag that indicates whether the primary diagnosis present for this encounter is invalid, i.e. a non existing ICD-10-CM code. This flag indicates that a primary diagnosis code is indeed present for the encounter, but it is not a valid ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "no_diagnosis_ccs_flag": {"name": "no_diagnosis_ccs_flag", "description": "A flag that indicates whether there is no CCS diagnosis category associated with the primary ICD-10-CM diagnosis code for the encounter. This flag indicates that there is a valid primary ICD-10-CM diagnosis code associated with the encounter, but there is no CCS diagnosis category associated with that ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "overlaps_with_another_encounter_flag": {"name": "overlaps_with_another_encounter_flag", "description": "A flag that indicates whether this encounter's dates overlap with those of another encounter in the dataset", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_data_quality", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.455194, "relation_name": "cms_synthetic.readmissions._int_encounter_data_quality", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list all encounters from the stg_encounter table\n-- with data quality flags that may disqualify them from\n-- being used for readmission measures \n\n\n-- Flag several potential data quality issues\n-- with all encounters.\n-- Every encounter_id from the stg_encounter model\n-- will be here. This CTE should have the same\n-- number of rows as the stg_encounter model, i.e.,\n-- there is a one to one correspondence between the\n-- rows in stg_encounter and this CTE.\nwith encounter_data_quality_issues as (\nselect\n aa.encounter_id,\n case\n when aa.admit_date is null then 1\n\telse 0\n end as missing_admit_date_flag,\n case\n when aa.discharge_date is null then 1\n\telse 0\n end as missing_discharge_date_flag,\n case\n when aa.admit_date > aa.discharge_date then 1\n\telse 0\n end as admit_after_discharge_flag,\n case\n when aa.discharge_disposition_code is null then 1\n\telse 0\n end as missing_discharge_disposition_code_flag,\n case\n when\n\t (aa.discharge_disposition_code is not null)\n\t and\n\t (bb.discharge_disposition_code is null) then 1\n\telse 0\n end as invalid_discharge_disposition_code_flag,\n case\n when aa.primary_diagnosis_code is null then 1\n else 0\n end as missing_primary_diagnosis_flag,\n case\n when aa.valid_primary_diagnosis_code_flag = 0 then 1\n\telse 0\n end as invalid_primary_diagnosis_code_flag,\n case\n when aa.ccs_diagnosis_category is null then 1\n\telse 0\n end as no_diagnosis_ccs_flag,\n aa.ccs_diagnosis_category as diagnosis_ccs,\n case\n when aa.encounter_id in (select distinct encounter_id_A\n\t from {{ ref('readmissions__encounter_overlap') }} )\n\t or\n\t aa.encounter_id in (select distinct encounter_id_B\n\t from {{ ref('readmissions__encounter_overlap') }} )\n\tthen 1\n\telse 0\n end as overlaps_with_another_encounter_flag,\n case\n when aa.ms_drg_code is null then 1\n\telse 0\n end as missing_ms_drg_flag,\n case\n when cc.ms_drg_code is null then 1\n\telse 0\n end as invalid_ms_drg_flag\n\nfrom {{ ref('readmissions__encounter_with_ccs') }} aa\n left join {{ ref('terminology__discharge_disposition') }} bb\n on aa.discharge_disposition_code = bb.discharge_disposition_code\n left join {{ ref('terminology__ms_drg') }} cc\n on aa.ms_drg_code = cc.ms_drg_code\n),\n\n\n-- Here we add a disqualified_encounter_flag.\n-- This disqualified_encounter_flag = 1\n-- when any of the critical data quality flags\n-- from the above CTE are equal to 1.\nall_data_quality_flags as (\nselect\n encounter_id,\n diagnosis_ccs,\n case\n when\n\t (missing_admit_date_flag = 1)\n\t or\n\t (missing_discharge_date_flag = 1)\n\t or\n\t (admit_after_discharge_flag = 1)\n\t or\n\t (missing_discharge_disposition_code_flag = 1)\n\t or\n\t (invalid_discharge_disposition_code_flag = 1)\n\t or\n\t (missing_primary_diagnosis_flag = 1)\n\t or\n\t (invalid_primary_diagnosis_code_flag = 1)\n\t or\n\t (no_diagnosis_ccs_flag = 1)\n\t or\n\t (overlaps_with_another_encounter_flag = 1)\n\t or\n\t (missing_ms_drg_flag = 1)\n\t or\n\t (invalid_ms_drg_flag = 1)\n\t then 1\n\telse 0\n end as disqualified_encounter_flag,\n missing_admit_date_flag,\n missing_discharge_date_flag,\n admit_after_discharge_flag,\n missing_discharge_disposition_code_flag,\n invalid_discharge_disposition_code_flag,\n missing_primary_diagnosis_flag,\n invalid_primary_diagnosis_code_flag,\n no_diagnosis_ccs_flag,\n overlaps_with_another_encounter_flag,\n missing_ms_drg_flag,\n invalid_ms_drg_flag\nfrom encounter_data_quality_issues\n) \n\n\n\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom all_data_quality_flags", "language": "sql", "refs": [{"name": "readmissions__encounter_overlap", "package": null, "version": null}, {"name": "readmissions__encounter_overlap", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter_overlap", "model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__encounter_data_quality.sql", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter table\n-- with data quality flags that may disqualify them from\n-- being used for readmission measures \n\n\n-- Flag several potential data quality issues\n-- with all encounters.\n-- Every encounter_id from the stg_encounter model\n-- will be here. This CTE should have the same\n-- number of rows as the stg_encounter model, i.e.,\n-- there is a one to one correspondence between the\n-- rows in stg_encounter and this CTE.\nwith encounter_data_quality_issues as (\nselect\n aa.encounter_id,\n case\n when aa.admit_date is null then 1\n\telse 0\n end as missing_admit_date_flag,\n case\n when aa.discharge_date is null then 1\n\telse 0\n end as missing_discharge_date_flag,\n case\n when aa.admit_date > aa.discharge_date then 1\n\telse 0\n end as admit_after_discharge_flag,\n case\n when aa.discharge_disposition_code is null then 1\n\telse 0\n end as missing_discharge_disposition_code_flag,\n case\n when\n\t (aa.discharge_disposition_code is not null)\n\t and\n\t (bb.discharge_disposition_code is null) then 1\n\telse 0\n end as invalid_discharge_disposition_code_flag,\n case\n when aa.primary_diagnosis_code is null then 1\n else 0\n end as missing_primary_diagnosis_flag,\n case\n when aa.valid_primary_diagnosis_code_flag = 0 then 1\n\telse 0\n end as invalid_primary_diagnosis_code_flag,\n case\n when aa.ccs_diagnosis_category is null then 1\n\telse 0\n end as no_diagnosis_ccs_flag,\n aa.ccs_diagnosis_category as diagnosis_ccs,\n case\n when aa.encounter_id in (select distinct encounter_id_A\n\t from cms_synthetic.readmissions._int_encounter_overlap )\n\t or\n\t aa.encounter_id in (select distinct encounter_id_B\n\t from cms_synthetic.readmissions._int_encounter_overlap )\n\tthen 1\n\telse 0\n end as overlaps_with_another_encounter_flag,\n case\n when aa.ms_drg_code is null then 1\n\telse 0\n end as missing_ms_drg_flag,\n case\n when cc.ms_drg_code is null then 1\n\telse 0\n end as invalid_ms_drg_flag\n\nfrom cms_synthetic.readmissions._int_encounter_with_ccs aa\n left join cms_synthetic.terminology.discharge_disposition bb\n on aa.discharge_disposition_code = bb.discharge_disposition_code\n left join cms_synthetic.terminology.ms_drg cc\n on aa.ms_drg_code = cc.ms_drg_code\n),\n\n\n-- Here we add a disqualified_encounter_flag.\n-- This disqualified_encounter_flag = 1\n-- when any of the critical data quality flags\n-- from the above CTE are equal to 1.\nall_data_quality_flags as (\nselect\n encounter_id,\n diagnosis_ccs,\n case\n when\n\t (missing_admit_date_flag = 1)\n\t or\n\t (missing_discharge_date_flag = 1)\n\t or\n\t (admit_after_discharge_flag = 1)\n\t or\n\t (missing_discharge_disposition_code_flag = 1)\n\t or\n\t (invalid_discharge_disposition_code_flag = 1)\n\t or\n\t (missing_primary_diagnosis_flag = 1)\n\t or\n\t (invalid_primary_diagnosis_code_flag = 1)\n\t or\n\t (no_diagnosis_ccs_flag = 1)\n\t or\n\t (overlaps_with_another_encounter_flag = 1)\n\t or\n\t (missing_ms_drg_flag = 1)\n\t or\n\t (invalid_ms_drg_flag = 1)\n\t then 1\n\telse 0\n end as disqualified_encounter_flag,\n missing_admit_date_flag,\n missing_discharge_date_flag,\n admit_after_discharge_flag,\n missing_discharge_disposition_code_flag,\n invalid_discharge_disposition_code_flag,\n missing_primary_diagnosis_flag,\n invalid_primary_diagnosis_code_flag,\n no_diagnosis_ccs_flag,\n overlaps_with_another_encounter_flag,\n missing_ms_drg_flag,\n invalid_ms_drg_flag\nfrom encounter_data_quality_issues\n) \n\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom all_data_quality_flags", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__exclusion": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__exclusion", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__exclusion.sql", "original_file_path": "models/readmissions/intermediate/readmissions__exclusion.sql", "unique_id": "model.the_tuva_project.readmissions__exclusion", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__exclusion"], "alias": "_int_exclusion", "checksum": {"name": "sha256", "checksum": "d61953c63b412d70c922eddb567012beb053fdfa03a431c459854480de823216"}, "config": {"enabled": true, "alias": "_int_exclusion", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters that are excluded from being index admissions because they belong to one of the exclusion categories.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_exclusion", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4625752, "relation_name": "cms_synthetic.readmissions._int_exclusion", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list encounter_ids that are excluded\n-- from being index admissions because they\n-- belong to one of these categories:\n-- [1] Medical Treatment of Cancer\n-- [2] Rehabilitation\n-- [3] Psychiatric\n\n\n-- encounter_ids for encounters that should be\n-- excluded because they belong to one of the\n-- exclusion categories\nwith exclusions as (\nselect distinct encounter_id\nfrom {{ ref('readmissions__encounter_with_ccs') }}\nwhere\n(ccs_diagnosis_category is not null)\nand\n(\nccs_diagnosis_category in\n (select distinct ccs_diagnosis_category\n from {{ ref('readmissions__exclusion_ccs_diagnosis_category') }} )\n)\n)\n\n\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom exclusions", "language": "sql", "refs": [{"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__exclusion_ccs_diagnosis_category", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__exclusion.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that are excluded\n-- from being index admissions because they\n-- belong to one of these categories:\n-- [1] Medical Treatment of Cancer\n-- [2] Rehabilitation\n-- [3] Psychiatric\n\n\n-- encounter_ids for encounters that should be\n-- excluded because they belong to one of the\n-- exclusion categories\nwith exclusions as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_encounter_with_ccs\nwhere\n(ccs_diagnosis_category is not null)\nand\n(\nccs_diagnosis_category in\n (select distinct ccs_diagnosis_category\n from cms_synthetic.readmissions._value_set_exclusion_ccs_diagnosis_category )\n)\n)\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__index_admission": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__index_admission", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__index_admission.sql", "original_file_path": "models/readmissions/intermediate/readmissions__index_admission.sql", "unique_id": "model.the_tuva_project.readmissions__index_admission", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__index_admission"], "alias": "_int_index_admission", "checksum": {"name": "sha256", "checksum": "7a8187b5c42f86b734604e09a5527d1b772e5b8166def99606c73f5755db9cc3"}, "config": {"enabled": true, "alias": "_int_index_admission", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all index admissions for the hospital wide readmissions measure. These represent encounter_ids that meet the requirements to be an index admission for the HWR measure.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_index_admission", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.464401, "relation_name": "cms_synthetic.readmissions._int_index_admission", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list all index admissions for the hospital wide readmissions\n-- measure.\n-- These represent encounter_ids that meet the requirements to be an\n-- index admission for the HWR measure.\n-- These are the requirements for a hospitalization to be an index admission\n-- for the HWR measure:\n--\n-- Time Requirement: The discharge data must be at least 30 days\n-- earlier than the last dischareg date available\n-- in the dataset.\n-- \n-- Discharge Requirements: The patient must not be discharged to another\n-- acute care hospital; the patient must not have\n-- left against medical advice; and the patient\n-- must be alive at discharge.\n--\n-- Diagnosis Requirements: Exclude encounters where based on the CCS\n-- (exclusions) diagnosis category we know the encounter was\n-- for medical treatment of cancer, rehabilitation,\n-- or psychiatric reasons.\n\n\n\nselect distinct a.encounter_id, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('readmissions__encounter') }} a\ninner join {{ ref('readmissions__index_time_requirement') }} b\n on a.encounter_id = b.encounter_id\ninner join {{ ref('readmissions__index_discharge_requirement') }} c\n on a.encounter_id = c.encounter_id\nleft join {{ ref('readmissions__exclusion') }} d\n on a.encounter_id = d.encounter_id\nwhere d.encounter_id is null", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__index_time_requirement", "package": null, "version": null}, {"name": "readmissions__index_discharge_requirement", "package": null, "version": null}, {"name": "readmissions__exclusion", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__index_time_requirement", "model.the_tuva_project.readmissions__index_discharge_requirement", "model.the_tuva_project.readmissions__exclusion"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__index_admission.sql", "compiled": true, "compiled_code": "\n\n-- Here we list all index admissions for the hospital wide readmissions\n-- measure.\n-- These represent encounter_ids that meet the requirements to be an\n-- index admission for the HWR measure.\n-- These are the requirements for a hospitalization to be an index admission\n-- for the HWR measure:\n--\n-- Time Requirement: The discharge data must be at least 30 days\n-- earlier than the last dischareg date available\n-- in the dataset.\n-- \n-- Discharge Requirements: The patient must not be discharged to another\n-- acute care hospital; the patient must not have\n-- left against medical advice; and the patient\n-- must be alive at discharge.\n--\n-- Diagnosis Requirements: Exclude encounters where based on the CCS\n-- (exclusions) diagnosis category we know the encounter was\n-- for medical treatment of cancer, rehabilitation,\n-- or psychiatric reasons.\n\n\n\nselect distinct a.encounter_id, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter a\ninner join cms_synthetic.readmissions._int_index_time_requirement b\n on a.encounter_id = b.encounter_id\ninner join cms_synthetic.readmissions._int_index_discharge_requirement c\n on a.encounter_id = c.encounter_id\nleft join cms_synthetic.readmissions._int_exclusion d\n on a.encounter_id = d.encounter_id\nwhere d.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__index_time_requirement": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__index_time_requirement", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__index_time_requirement.sql", "original_file_path": "models/readmissions/intermediate/readmissions__index_time_requirement.sql", "unique_id": "model.the_tuva_project.readmissions__index_time_requirement", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__index_time_requirement"], "alias": "_int_index_time_requirement", "checksum": {"name": "sha256", "checksum": "c04a72526e55169b4beee090676d31142027bbf9a2018b42336f9745f426afd8"}, "config": {"enabled": true, "alias": "_int_index_time_requirement", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters that meet the time requirement to be an index admission.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_index_time_requirement", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.467403, "relation_name": "cms_synthetic.readmissions._int_index_time_requirement", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list encounter_ids that meet\n-- the time requirement to be an index admission:\n-- The discharge date must be at least 30 days\n-- earlier than the last discharge date available\n-- in the dataset.\n\n\nwith cte as (\n select max(discharge_date) max_discharge\n from {{ ref('readmissions__encounter') }}\n)\n\nselect encounter_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('readmissions__encounter') }}\ncross join cte\nwhere discharge_date <= {{ dbt.dateadd (\ndatepart = \"day\"\n, interval = -30\n, from_date_or_timestamp = \"cte.max_discharge\"\n)}}", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__index_time_requirement.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the time requirement to be an index admission:\n-- The discharge date must be at least 30 days\n-- earlier than the last discharge date available\n-- in the dataset.\n\n\nwith cte as (\n select max(discharge_date) max_discharge\n from cms_synthetic.readmissions._int_encounter\n)\n\nselect encounter_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter\ncross join cte\nwhere discharge_date <= \n\n dateadd(\n day,\n -30,\n cte.max_discharge\n )\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__planned_encounter": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__planned_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__planned_encounter.sql", "original_file_path": "models/readmissions/intermediate/readmissions__planned_encounter.sql", "unique_id": "model.the_tuva_project.readmissions__planned_encounter", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__planned_encounter"], "alias": "_int_planned_encounter", "checksum": {"name": "sha256", "checksum": "fdb6d5b90842284e7d87101bc28201294f6000d6170e26be523aeec7930b1d23"}, "config": {"enabled": true, "alias": "_int_planned_encounter", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model gives a list of all encounter_ids that were planned encounters.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_planned_encounter", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4692411, "relation_name": "cms_synthetic.readmissions._int_planned_encounter", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list encounter_ids for all encounters\n-- that are planned.\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a procedure category\n-- that is only present for planned encounters \nwith always_planned_px as (\nselect distinct pccs.encounter_id\nfrom {{ ref('readmissions__procedure_ccs') }} pccs\ninner join {{ ref('readmissions__always_planned_ccs_procedure_category') }} apc\n on pccs.ccs_procedure_category = apc.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a diagnosis category\n-- that is only present for planned encounters\nalways_planned_dx as (\nselect distinct encounter_id\nfrom {{ ref('readmissions__encounter_with_ccs') }} dccs\ninner join {{ ref('readmissions__always_planned_ccs_diagnosis_category') }} apd\n on dccs.ccs_diagnosis_category = apd.ccs_diagnosis_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on one of their CCS procedure categories.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_ccs as (\nselect distinct encounter_id\nfrom {{ ref('readmissions__procedure_ccs') }} pccs\ninner join {{ ref('readmissions__potentially_planned_ccs_procedure_category') }} pcs\n on pccs.ccs_procedure_category = pcs.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on their ICD-10-PCS procedure codes.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_icd_10_pcs as (\nselect distinct encounter_id\nfrom {{ ref('readmissions__procedure_ccs') }} pcs\ninner join {{ ref('readmissions__potentially_planned_icd_10_pcs') }} pps\n on pcs.procedure_code = pps.icd_10_pcs\n),\n\n\n-- encounter_ids for encounters that are acute based\n-- on their primary diagnosis code or their CCS diagnosis category\nacute_encounters as (\nselect distinct encounter_id\nfrom {{ ref('readmissions__encounter_with_ccs') }} dccs\nleft join {{ ref('readmissions__acute_diagnosis_icd_10_cm') }} adi\n on dccs.primary_diagnosis_code = adi.icd_10_cm\nleft join {{ ref('readmissions__acute_diagnosis_ccs') }} adc\n on dccs.ccs_diagnosis_category = adc.ccs_diagnosis_category\nwhere adi.icd_10_cm is not null or adc.ccs_diagnosis_category is not null\n),\n\n\n-- encounter_ids for encounters that are:\n-- [1] potentially planned, based on one of\n-- their CCS procedure categories or\n-- their ICD-10-PCS procedure codes\n-- [2] not acute, based on their primary diagnosis code\n-- or their CCS diagnosis category\n-- These encounters are therefore confirmed to be planned\npotentially_planned_that_are_actually_planned as (\nselect distinct ppp.encounter_id\nfrom (\n select * from potentially_planned_px_ccs\n union all\n select * from potentially_planned_px_icd_10_pcs) ppp\nleft join acute_encounters\n on ppp.encounter_id = acute_encounters.encounter_id\nwhere acute_encounters.encounter_id is null\n\n)\n\n\n-- Aggregate of all encounter_ids for planned encounters\n\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from always_planned_px\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from always_planned_dx\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from potentially_planned_that_are_actually_planned", "language": "sql", "refs": [{"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__always_planned_ccs_procedure_category", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__always_planned_ccs_diagnosis_category", "package": null, "version": null}, {"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__potentially_planned_ccs_procedure_category", "package": null, "version": null}, {"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__potentially_planned_icd_10_pcs", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__acute_diagnosis_icd_10_cm", "package": null, "version": null}, {"name": "readmissions__acute_diagnosis_ccs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs", "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "seed.the_tuva_project.readmissions__acute_diagnosis_ccs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__planned_encounter.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids for all encounters\n-- that are planned.\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a procedure category\n-- that is only present for planned encounters \nwith always_planned_px as (\nselect distinct pccs.encounter_id\nfrom cms_synthetic.readmissions._int_procedure_ccs pccs\ninner join cms_synthetic.readmissions._value_set_always_planned_ccs_procedure_category apc\n on pccs.ccs_procedure_category = apc.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a diagnosis category\n-- that is only present for planned encounters\nalways_planned_dx as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_encounter_with_ccs dccs\ninner join cms_synthetic.readmissions._value_set_always_planned_ccs_diagnosis_category apd\n on dccs.ccs_diagnosis_category = apd.ccs_diagnosis_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on one of their CCS procedure categories.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_ccs as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_procedure_ccs pccs\ninner join cms_synthetic.readmissions._value_set_potentially_planned_ccs_procedure_category pcs\n on pccs.ccs_procedure_category = pcs.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on their ICD-10-PCS procedure codes.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_icd_10_pcs as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_procedure_ccs pcs\ninner join cms_synthetic.readmissions._value_set_potentially_planned_icd_10_pcs pps\n on pcs.procedure_code = pps.icd_10_pcs\n),\n\n\n-- encounter_ids for encounters that are acute based\n-- on their primary diagnosis code or their CCS diagnosis category\nacute_encounters as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_encounter_with_ccs dccs\nleft join cms_synthetic.readmissions._value_set_acute_diagnosis_icd_10_cm adi\n on dccs.primary_diagnosis_code = adi.icd_10_cm\nleft join cms_synthetic.readmissions._value_set_acute_diagnosis_ccs adc\n on dccs.ccs_diagnosis_category = adc.ccs_diagnosis_category\nwhere adi.icd_10_cm is not null or adc.ccs_diagnosis_category is not null\n),\n\n\n-- encounter_ids for encounters that are:\n-- [1] potentially planned, based on one of\n-- their CCS procedure categories or\n-- their ICD-10-PCS procedure codes\n-- [2] not acute, based on their primary diagnosis code\n-- or their CCS diagnosis category\n-- These encounters are therefore confirmed to be planned\npotentially_planned_that_are_actually_planned as (\nselect distinct ppp.encounter_id\nfrom (\n select * from potentially_planned_px_ccs\n union all\n select * from potentially_planned_px_icd_10_pcs) ppp\nleft join acute_encounters\n on ppp.encounter_id = acute_encounters.encounter_id\nwhere acute_encounters.encounter_id is null\n\n)\n\n\n-- Aggregate of all encounter_ids for planned encounters\n\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from always_planned_px\n\nunion distinct\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from always_planned_dx\n\nunion distinct\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from potentially_planned_that_are_actually_planned", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__encounter.sql", "original_file_path": "models/readmissions/intermediate/readmissions__encounter.sql", "unique_id": "model.the_tuva_project.readmissions__encounter", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter"], "alias": "_int_encounter", "checksum": {"name": "sha256", "checksum": "f1aa314d6b24bc9112db10c7ee41f4658103bfad22dc78975c284da42ffcf273"}, "config": {"enabled": true, "alias": "_int_encounter", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This is a staging table for the input layer. Each row represents a unique acute inpatient encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The date of discharge for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_status_code": {"name": "discharge_status_code", "description": "The valid 2-digit discharge status for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility": {"name": "facility", "description": "A name or ID for the facility where the inpatient visit occured", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg": {"name": "ms_drg", "description": "The MS-DRG associted with the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4750469, "relation_name": "cms_synthetic.readmissions._int_encounter", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Staging model for the input layer:\n-- stg_encounter input layer model.\n-- This contains one row for every unique encounter in the dataset.\n\nselect\n cast(encounter_id as {{ dbt.type_string() }}) as encounter_id,\n cast(patient_id as {{ dbt.type_string() }}) as patient_id,\n cast(encounter_start_date as date) as admit_date,\n cast(encounter_end_date as date) as discharge_date,\n cast(discharge_disposition_code as {{ dbt.type_string() }}) as discharge_disposition_code,\n cast(facility_id as {{ dbt.type_string() }}) as facility_id,\n cast(ms_drg_code as {{ dbt.type_string() }}) as ms_drg_code,\n cast(paid_amount as {{ dbt.type_numeric() }}) as paid_amount,\n cast(primary_diagnosis_code as {{ dbt.type_string() }}) as primary_diagnosis_code,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('readmissions__stg_core__encounter') }}", "language": "sql", "refs": [{"name": "readmissions__stg_core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.readmissions__stg_core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__encounter.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__encounter as (\n\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n) -- Staging model for the input layer:\n-- stg_encounter input layer model.\n-- This contains one row for every unique encounter in the dataset.\n\nselect\n cast(encounter_id as TEXT) as encounter_id,\n cast(patient_id as TEXT) as patient_id,\n cast(encounter_start_date as date) as admit_date,\n cast(encounter_end_date as date) as discharge_date,\n cast(discharge_disposition_code as TEXT) as discharge_disposition_code,\n cast(facility_id as TEXT) as facility_id,\n cast(ms_drg_code as TEXT) as ms_drg_code,\n cast(paid_amount as numeric(28,6)) as paid_amount,\n cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__readmissions__stg_core__encounter", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.readmissions__stg_core__encounter", "sql": " __dbt__cte__readmissions__stg_core__encounter as (\n\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__readmission_crude": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__readmission_crude", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__readmission_crude.sql", "original_file_path": "models/readmissions/intermediate/readmissions__readmission_crude.sql", "unique_id": "model.the_tuva_project.readmissions__readmission_crude", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__readmission_crude"], "alias": "_int_readmission_crude", "checksum": {"name": "sha256", "checksum": "67443fb192b362710c3e897cdbdf7e9178a4228cc41ce6d8e4c07d48fc22f204"}, "config": {"enabled": true, "alias": "_int_readmission_crude", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters and whether they had a 'crude' readmission, meaning that the encounter had a hospitalization after discharge, without regard to all CMS readmission logic.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "had_readmission_flag": {"name": "had_readmission_flag", "description": "A flag to indicate whether the encounter had a readmission any number of days after discharge", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_to_readmit": {"name": "days_to_readmit", "description": "An integer to indicate the number of days to readmission", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmit_30_flag": {"name": "readmit_30_flag", "description": "A flag to indicate whether the encounter had a 30-day readmission", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_readmission_crude", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.472895, "relation_name": "cms_synthetic.readmissions._int_readmission_crude", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we calculate readmissions using all encounters\n-- that have valid admit and discharge dates and no overlap.\n-- This is meant to give a crude sense of the readmission\n-- rate without taking into account all the CMS HWR logic.\n\n\nwith encounter_info as (\nselect\n enc.encounter_id,\n enc.patient_id,\n enc.admit_date,\n enc.discharge_date\nfrom {{ ref('readmissions__encounter') }} enc\nleft join {{ ref('readmissions__encounter_overlap') }} over_a\n on enc.encounter_id = over_a.encounter_id_A\nleft join {{ ref('readmissions__encounter_overlap') }} over_b\n on enc.encounter_id = over_b.encounter_id_B\nwhere\n admit_date is not null\n and\n discharge_date is not null\n and\n admit_date <= discharge_date\nand over_a.encounter_id_A is null and over_b.encounter_id_B is null\n ),\n\n\nencounter_sequence as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom encounter_info\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n case\n when bb.encounter_id is not null then 1\n\telse 0\n end as had_readmission_flag,\n {{ dbt.datediff(\"bb.admit_date\", \"aa.discharge_date\", \"day\") }} as days_to_readmit,\n case\n when ({{ dbt.datediff(\"bb.admit_date\", \"aa.discharge_date\", \"day\") }}) <= 30 then 1\n\telse 0\n end as readmit_30_flag\nfrom encounter_sequence aa left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\n\n\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom readmission_calc", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__encounter_overlap", "package": null, "version": null}, {"name": "readmissions__encounter_overlap", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_overlap"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__readmission_crude.sql", "compiled": true, "compiled_code": "\n\n-- Here we calculate readmissions using all encounters\n-- that have valid admit and discharge dates and no overlap.\n-- This is meant to give a crude sense of the readmission\n-- rate without taking into account all the CMS HWR logic.\n\n\nwith encounter_info as (\nselect\n enc.encounter_id,\n enc.patient_id,\n enc.admit_date,\n enc.discharge_date\nfrom cms_synthetic.readmissions._int_encounter enc\nleft join cms_synthetic.readmissions._int_encounter_overlap over_a\n on enc.encounter_id = over_a.encounter_id_A\nleft join cms_synthetic.readmissions._int_encounter_overlap over_b\n on enc.encounter_id = over_b.encounter_id_B\nwhere\n admit_date is not null\n and\n discharge_date is not null\n and\n admit_date <= discharge_date\nand over_a.encounter_id_A is null and over_b.encounter_id_B is null\n ),\n\n\nencounter_sequence as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom encounter_info\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n case\n when bb.encounter_id is not null then 1\n\telse 0\n end as had_readmission_flag,\n datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n )) <= 30 then 1\n\telse 0\n end as readmit_30_flag\nfrom encounter_sequence aa left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom readmission_calc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__procedure_ccs": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__procedure_ccs", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__procedure_ccs.sql", "original_file_path": "models/readmissions/intermediate/readmissions__procedure_ccs.sql", "unique_id": "model.the_tuva_project.readmissions__procedure_ccs", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__procedure_ccs"], "alias": "_int_procedure_ccs", "checksum": {"name": "sha256", "checksum": "ee4eea416b1cd86928d652d313497d153188280324859f52270d4f9ac5c2af71"}, "config": {"enabled": true, "alias": "_int_procedure_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model includes all procedures from the stg_procedure model and adds a valid_icd_10_pcs_flag to indicate if the ICD-10-PCS code for this procedure is valid. We also add the CCS procedure category associated with the procedure", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code": {"name": "procedure_code", "description": "An ICD-10-PCS code associated with this encounter_id", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "valid_icd_10_pcs_flag": {"name": "valid_icd_10_pcs_flag", "description": "A flag indicating if the ICD-10-PCS procedure code given is valid", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_procedure_category": {"name": "ccs_procedure_category", "description": "The CCS code associated with the given ICD-10-PCS procedure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_procedure_ccs", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.471185, "relation_name": "cms_synthetic.readmissions._int_procedure_ccs", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we map every procedure code to its corresponding\n-- CCS procedure category.\n-- This model may list more than one CCS procedure category\n-- per encounter_id because different procedures associated with the\n-- encounter (different rows on the stg_procedure model) may have\n-- different associated CCS procedure categories.\n\n\n\nselect\n aa.encounter_id,\n aa.normalized_code as procedure_code,\n case\n when bb.icd_10_pcs is null then 0\n\telse 1\n end as valid_icd_10_pcs_flag,\n cc.ccs_procedure_category,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom\n {{ ref('readmissions__stg_core__procedure') }} aa\n left join {{ ref('terminology__icd_10_pcs') }} bb\n on aa.normalized_code = bb.icd_10_pcs\n left join {{ ref('readmissions__icd_10_pcs_to_ccs') }} cc\n on aa.normalized_code = cc.icd_10_pcs\nwhere aa.normalized_code_type = 'icd-10-pcs'", "language": "sql", "refs": [{"name": "readmissions__stg_core__procedure", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "readmissions__icd_10_pcs_to_ccs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__stg_core__procedure", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__procedure_ccs.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__procedure as (\n\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n) -- Here we map every procedure code to its corresponding\n-- CCS procedure category.\n-- This model may list more than one CCS procedure category\n-- per encounter_id because different procedures associated with the\n-- encounter (different rows on the stg_procedure model) may have\n-- different associated CCS procedure categories.\n\n\n\nselect\n aa.encounter_id,\n aa.normalized_code as procedure_code,\n case\n when bb.icd_10_pcs is null then 0\n\telse 1\n end as valid_icd_10_pcs_flag,\n cc.ccs_procedure_category,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n __dbt__cte__readmissions__stg_core__procedure aa\n left join cms_synthetic.terminology.icd_10_pcs bb\n on aa.normalized_code = bb.icd_10_pcs\n left join cms_synthetic.readmissions._value_set_icd_10_pcs_to_ccs cc\n on aa.normalized_code = cc.icd_10_pcs\nwhere aa.normalized_code_type = 'icd-10-pcs'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.readmissions__stg_core__procedure", "sql": " __dbt__cte__readmissions__stg_core__procedure as (\n\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_with_ccs": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__encounter_with_ccs", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__encounter_with_ccs.sql", "original_file_path": "models/readmissions/intermediate/readmissions__encounter_with_ccs.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_with_ccs", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_with_ccs"], "alias": "_int_encounter_with_ccs", "checksum": {"name": "sha256", "checksum": "a0b8dedf19d9388fd8e36604c63d45ef4157356292fb234eefbc7b8771421ac9"}, "config": {"enabled": true, "alias": "_int_encounter_with_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_with_ccs", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.460593, "relation_name": "cms_synthetic.readmissions._int_encounter_with_ccs", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we add a CCS diagnosis category to\n-- every encounter that we can add a CCS diagnosis category to.\n-- The CCS diagnosis category is found using\n-- the encounter's primary diagnosis code.\n\n\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.primary_diagnosis_code,\n\n case\n when bb.icd_10_cm is not null then 1\n else 0\n end as valid_primary_diagnosis_code_flag,\n\n cc.ccs_diagnosis_category,\n\n '{{ var('tuva_last_run')}}' as tuva_last_run\n\nfrom\n {{ ref('readmissions__encounter') }} aa\n left join {{ ref('terminology__icd_10_cm') }} bb\n on aa.primary_diagnosis_code = bb.icd_10_cm\n left join {{ ref('readmissions__icd_10_cm_to_ccs') }} cc\n on aa.primary_diagnosis_code = cc.icd_10_cm", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "readmissions__icd_10_cm_to_ccs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__encounter_with_ccs.sql", "compiled": true, "compiled_code": "\n\n-- Here we add a CCS diagnosis category to\n-- every encounter that we can add a CCS diagnosis category to.\n-- The CCS diagnosis category is found using\n-- the encounter's primary diagnosis code.\n\n\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.primary_diagnosis_code,\n\n case\n when bb.icd_10_cm is not null then 1\n else 0\n end as valid_primary_diagnosis_code_flag,\n\n cc.ccs_diagnosis_category,\n\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n\nfrom\n cms_synthetic.readmissions._int_encounter aa\n left join cms_synthetic.terminology.icd_10_cm bb\n on aa.primary_diagnosis_code = bb.icd_10_cm\n left join cms_synthetic.readmissions._value_set_icd_10_cm_to_ccs cc\n on aa.primary_diagnosis_code = cc.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__index_discharge_requirement": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__index_discharge_requirement", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions/intermediate/readmissions__index_discharge_requirement.sql", "original_file_path": "models/readmissions/intermediate/readmissions__index_discharge_requirement.sql", "unique_id": "model.the_tuva_project.readmissions__index_discharge_requirement", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__index_discharge_requirement"], "alias": "_int_index_discharge_requirement", "checksum": {"name": "sha256", "checksum": "553edf3861bc7fcaf69a4900fb7ae16e7a503043df22ef87715d2eb061512fae"}, "config": {"enabled": true, "alias": "_int_index_discharge_requirement", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters that meet the discharge disposition requirement to be an index admission.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/readmissions/readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_index_discharge_requirement", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.465926, "relation_name": "cms_synthetic.readmissions._int_index_discharge_requirement", "raw_code": "{{ config(\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n-- Here we list encounter_ids that meet\n-- the discharge_disposition_code requirements to be an\n-- index admission:\n-- *** Must NOT be discharged to another acute care hospital\n-- *** Must NOT have left against medical advice\n-- *** Patient must be alive at discharge\n\n\n\nwith all_invalid_discharges as (\nselect encounter_id\nfrom {{ ref('readmissions__encounter') }}\nwhere discharge_disposition_code in (\n '02' -- Patient discharged/transferred to other short term general hospital for inpatient care.\n ,'07' -- Patient left against medical advice\n ,'20' -- Patient died\n )\n)\n\n-- All discharges that meet the discharge_disposition_code\n-- requirements to be an index admission\nselect a.encounter_id, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('readmissions__encounter') }} a\nleft join all_invalid_discharges b\n on a.encounter_id = b.encounter_id\nwhere b.encounter_id is null", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/readmissions/intermediate/readmissions__index_discharge_requirement.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the discharge_disposition_code requirements to be an\n-- index admission:\n-- *** Must NOT be discharged to another acute care hospital\n-- *** Must NOT have left against medical advice\n-- *** Patient must be alive at discharge\n\n\n\nwith all_invalid_discharges as (\nselect encounter_id\nfrom cms_synthetic.readmissions._int_encounter\nwhere discharge_disposition_code in (\n '02' -- Patient discharged/transferred to other short term general hospital for inpatient care.\n ,'07' -- Patient left against medical advice\n ,'20' -- Patient died\n )\n)\n\n-- All discharges that meet the discharge_disposition_code\n-- requirements to be an index admission\nselect a.encounter_id, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter a\nleft join all_invalid_discharges b\n on a.encounter_id = b.encounter_id\nwhere b.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__condition": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/staging/cms_hcc__stg_core__condition.sql", "original_file_path": "models/cms_hcc/staging/cms_hcc__stg_core__condition.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__condition", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__condition"], "alias": "_stg_condition", "checksum": {"name": "sha256", "checksum": "8284308d6f3a80643038c9973c3084feac7c345e1256f89fcb1e326be6646f9f"}, "config": {"enabled": true, "alias": "_stg_condition", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging conditions from core.", "columns": {"claim_id": {"name": "claim_id", "description": "Unique claim_id for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "The type of condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "The condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_condition", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.519009, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/staging/cms_hcc__stg_core__condition.sql", "compiled": true, "compiled_code": "\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__patient": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/staging/cms_hcc__stg_core__patient.sql", "original_file_path": "models/cms_hcc/staging/cms_hcc__stg_core__patient.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__patient", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__patient"], "alias": "_stg_patient", "checksum": {"name": "sha256", "checksum": "43b1f73e0fe35fbf8603c19825ed67de16b2882a64037286bbef3a1e61d6f95e"}, "config": {"enabled": true, "alias": "_stg_patient", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging patient from core.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "Biological sex of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "Date the patient was born.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "The death date of the patient if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_patient", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5238478, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/staging/cms_hcc__stg_core__patient.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__member_months": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__stg_core__member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/staging/cms_hcc__stg_core__member_months.sql", "original_file_path": "models/cms_hcc/staging/cms_hcc__stg_core__member_months.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__member_months", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__member_months"], "alias": "_stg_member_months", "checksum": {"name": "sha256", "checksum": "b69b35f8eaea84f6aeb0077e32256eb477fa4dc46737f5b302775cd367ad9b0b"}, "config": {"enabled": true, "alias": "_stg_member_months", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging member months from financial_pmpm", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_member_months", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.525494, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('financial_pmpm_enabled', var('claims_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__member_months') }}", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/staging/cms_hcc__stg_core__member_months.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.member_months", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__medical_claim": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__stg_core__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/staging/cms_hcc__stg_core__medical_claim.sql", "original_file_path": "models/cms_hcc/staging/cms_hcc__stg_core__medical_claim.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__medical_claim"], "alias": "_stg_medical_claim", "checksum": {"name": "sha256", "checksum": "764152968d03daa73e3c582e32a1aa08a149956296a87e37701d77d7da8b47d9"}, "config": {"enabled": true, "alias": "_stg_medical_claim", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging medical claims from core.", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "Start date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "HCPCS level 1 or level 2 code for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_medical_claim", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5221918, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medical_claim') }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/staging/cms_hcc__stg_core__medical_claim.sql", "compiled": true, "compiled_code": "\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__eligibility": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__stg_core__eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/staging/cms_hcc__stg_core__eligibility.sql", "original_file_path": "models/cms_hcc/staging/cms_hcc__stg_core__eligibility.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__eligibility", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__eligibility"], "alias": "_stg_eligibility", "checksum": {"name": "sha256", "checksum": "b3c5476fbf016489bff2413c0d02c60260b4ce36c5a13575c97b94764f2a19e7"}, "config": {"enabled": true, "alias": "_stg_eligibility", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging eligibility from core.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_eligibility", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.520674, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__eligibility') }}", "language": "sql", "refs": [{"name": "core__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/staging/cms_hcc__stg_core__eligibility.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__patient_risk_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/final/cms_hcc__patient_risk_factors.sql", "original_file_path": "models/cms_hcc/final/cms_hcc__patient_risk_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_factors", "fqn": ["the_tuva_project", "cms_hcc", "final", "cms_hcc__patient_risk_factors"], "alias": "patient_risk_factors", "checksum": {"name": "sha256", "checksum": "23a0b19c0ec53391312262b0b6cfb8b7434f042ae4855eebeffe74a99187abea"}, "config": {"enabled": true, "alias": "patient_risk_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "This final model displays the contributing demographic and disease risk factors, interactions, and HCCs for each enrollee in the payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status_default": {"name": "enrollment_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_dual_status_default": {"name": "medicaid_dual_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec_default": {"name": "orec_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status_default": {"name": "institutional_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "risk_factor_description": {"name": "risk_factor_description", "description": "Description of the risk factor.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "patient_risk_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4963121, "relation_name": "cms_synthetic.cms_hcc.patient_risk_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nwith demographic_factors as (\n\n select\n patient_id\n /* concatenate demographic risk factors */\n\n , {{ dbt.concat(\n [\n \"gender\",\n \"', '\",\n \"age_group\",\n \"' Years'\",\n \"', '\",\n \"enrollment_status\",\n \"' Enrollee'\",\n \"', '\",\n \"CASE\"\n \" WHEN medicaid_status = 'Yes' THEN 'Medicaid'\"\n \" ELSE 'Non-Medicaid'\"\n \" END\",\n \"', '\",\n \"dual_status\",\n \"' Dual'\",\n \"', '\",\n \"orec\",\n \"', '\",\n \"CASE\"\n \" WHEN institutional_status = 'Yes' THEN 'Institutional'\"\n \" ELSE 'Non-Institutional'\"\n \" END\"\n ]\n ) }} as description\n\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, demographic_defaults as (\n\n select\n patient_id\n , model_version\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, disease_factors as (\n\n select\n patient_id\n , {{ dbt.concat([\"hcc_description\", \"' (HCC '\", \"hcc_code\", \"')'\"]) }} as description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_disease_factors') }}\n\n)\n\n, enrollment_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_enrollment_interaction_factors') }}\n\n)\n\n, disabled_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_disabled_interaction_factors') }}\n\n)\n\n, disease_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_disease_interaction_factors') }}\n\n)\n\n, hcc_counts as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_hcc_count_factors') }}\n\n)\n\n, unioned as (\n\n select * from demographic_factors\n union all\n select * from disease_factors\n union all\n select * from enrollment_interactions\n union all\n select * from disabled_interactions\n union all\n select * from disease_interactions\n union all\n select * from hcc_counts\n\n)\n\n, add_defaults as (\n\n select\n unioned.patient_id\n , demographic_defaults.enrollment_status_default\n , demographic_defaults.medicaid_dual_status_default\n , demographic_defaults.orec_default\n , demographic_defaults.institutional_status_default\n , unioned.description as risk_factor_description\n , unioned.coefficient\n , unioned.factor_type\n , unioned.model_version\n , unioned.payment_year\n from unioned\n left join demographic_defaults\n on unioned.patient_id = demographic_defaults.patient_id\n and unioned.model_version = demographic_defaults.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n {% if target.type == 'fabric' %}\n , cast(enrollment_status_default as bit) as enrollment_status_default\n , cast(medicaid_dual_status_default as bit) as medicaid_dual_status_default\n , cast(orec_default as bit) as orec_default\n , cast(institutional_status_default as bit) as institutional_status_default\n {% else %}\n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n {% endif %}\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(risk_factor_description as {{ dbt.type_string() }}) as risk_factor_description\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from add_defaults\n\n)\n\nselect\n patient_id\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , factor_type\n , risk_factor_description\n , coefficient\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_disease_factors", "package": null, "version": null}, {"name": "cms_hcc__int_enrollment_interaction_factors", "package": null, "version": null}, {"name": "cms_hcc__int_disabled_interaction_factors", "package": null, "version": null}, {"name": "cms_hcc__int_disease_interaction_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_count_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/final/cms_hcc__patient_risk_factors.sql", "compiled": true, "compiled_code": "\nwith demographic_factors as (\n\n select\n patient_id\n /* concatenate demographic risk factors */\n\n , gender || ', ' || age_group || ' Years' || ', ' || enrollment_status || ' Enrollee' || ', ' || CASE WHEN medicaid_status = 'Yes' THEN 'Medicaid' ELSE 'Non-Medicaid' END || ', ' || dual_status || ' Dual' || ', ' || orec || ', ' || CASE WHEN institutional_status = 'Yes' THEN 'Institutional' ELSE 'Non-Institutional' END as description\n\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, demographic_defaults as (\n\n select\n patient_id\n , model_version\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, disease_factors as (\n\n select\n patient_id\n , hcc_description || ' (HCC ' || hcc_code || ')' as description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_disease_factors\n\n)\n\n, enrollment_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_enrollment_interaction_factors\n\n)\n\n, disabled_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_disabled_interaction_factors\n\n)\n\n, disease_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_disease_interaction_factors\n\n)\n\n, hcc_counts as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_hcc_count_factors\n\n)\n\n, unioned as (\n\n select * from demographic_factors\n union all\n select * from disease_factors\n union all\n select * from enrollment_interactions\n union all\n select * from disabled_interactions\n union all\n select * from disease_interactions\n union all\n select * from hcc_counts\n\n)\n\n, add_defaults as (\n\n select\n unioned.patient_id\n , demographic_defaults.enrollment_status_default\n , demographic_defaults.medicaid_dual_status_default\n , demographic_defaults.orec_default\n , demographic_defaults.institutional_status_default\n , unioned.description as risk_factor_description\n , unioned.coefficient\n , unioned.factor_type\n , unioned.model_version\n , unioned.payment_year\n from unioned\n left join demographic_defaults\n on unioned.patient_id = demographic_defaults.patient_id\n and unioned.model_version = demographic_defaults.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast(factor_type as TEXT) as factor_type\n , cast(risk_factor_description as TEXT) as risk_factor_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from add_defaults\n\n)\n\nselect\n patient_id\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , factor_type\n , risk_factor_description\n , coefficient\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__patient_risk_scores": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_scores", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/final/cms_hcc__patient_risk_scores.sql", "original_file_path": "models/cms_hcc/final/cms_hcc__patient_risk_scores.sql", "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_scores", "fqn": ["the_tuva_project", "cms_hcc", "final", "cms_hcc__patient_risk_scores"], "alias": "patient_risk_scores", "checksum": {"name": "sha256", "checksum": "986d69abb1d2ec1c3c980b6dd9fc75f30cf71d42afbac9d82eab08c8dfa92157"}, "config": {"enabled": true, "alias": "patient_risk_scores", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "This final model calculates the CMS HCC raw risk score, blended risk score, normalized risk score, and payment risk score for each enrollee in the payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "v24_risk_score": {"name": "v24_risk_score", "description": "The sum of all patient risk factors from model version CMS-HCC-V24. If payment year >= 2024 then the score may be weighted following CMS's transition plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "v28_risk_score": {"name": "v28_risk_score", "description": "The sum of all patient risk factors from model version CMS-HCC-V28. If payment year >= 2024 then the score may be weighted following CMS's transition plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "blended_risk_score": {"name": "blended_risk_score", "description": "The of sum v24_risk_score and v28_risk_score.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_risk_score": {"name": "normalized_risk_score", "description": "The blended risk score divided by the normalization adjustment factor for the corresponding HCC model version and payment year's rate announcement from CMS.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_risk_score": {"name": "payment_risk_score", "description": "The normalized risk score multiplied by the MA coding pattern adjustment factor for the corresponding HCC model version and payment year's rate announcement from CMS.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_risk_score_weighted_by_months": {"name": "payment_risk_score_weighted_by_months", "description": "Payment risk score multiplied by member_months.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "Member months derived from the finanicial_pmpm mart utilizing payment year eligibility.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "patient_risk_scores", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.49906, "relation_name": "cms_synthetic.cms_hcc.patient_risk_scores", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nwith seed_adjustment_rates as (\n\n select\n model_version\n , payment_year\n , normalization_factor\n , ma_coding_pattern_adjustment\n from {{ ref('cms_hcc__adjustment_rates') }}\n\n)\n\n, risk_factors as (\n\n select\n patient_id\n , coefficient\n , model_version\n , payment_year\n from {{ ref('cms_hcc__patient_risk_factors') }}\n\n)\n\n, member_months as (\n\n select\n patient_id\n , cast({{ substring('year_month', 1, 4) }} as integer) as eligible_year\n , COUNT(1) as member_months\n from {{ ref('cms_hcc__stg_core__member_months') }}\n group by\n patient_id\n , cast({{ substring('year_month', 1, 4) }} as integer)\n)\n\n, raw_score as (\n\n select\n patient_id\n , sum(coefficient) as risk_score\n , model_version\n , payment_year\n from risk_factors\n group by\n patient_id\n , model_version\n , payment_year\n\n)\n\n/*\n CMS Guidance for the transition from v24 to v28:\n\n PY2024 risk scores will be blended using 67% of the risk score calculated\n from v24 and 33% from v28.\n\n PY2025 risk scores will be blended using 33% of the risk score calculated\n from v24 and 67% from v28.\n\n PY2026 risk scores will be 100% from v28.\n\n Prior payment years will still be calculated from v24 only.\n*/\n, transition_scores as (\n\n select\n patient_id\n , risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V24' then risk_score\n when payment_year = 2024 and model_version = 'CMS-HCC-V24' then risk_score * 0.67\n when payment_year = 2025 and model_version = 'CMS-HCC-V24' then risk_score * 0.33\n when payment_year >= 2026 and model_version = 'CMS-HCC-V24' then 0\n end as v24_risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V28' then 0\n when payment_year = 2024 and model_version = 'CMS-HCC-V28' then risk_score * 0.33\n when payment_year = 2025 and model_version = 'CMS-HCC-V28' then risk_score * 0.67\n when payment_year >= 2026 and model_version = 'CMS-HCC-V28' then risk_score\n end as v28_risk_score\n , model_version\n , payment_year\n from raw_score\n\n)\n\n/*\n Grouping by patient to create a single row per patient.\n*/\n, transition_scores_grouped as (\n\n select\n patient_id\n , max(v24_risk_score) as v24_risk_score\n , max(v28_risk_score) as v28_risk_score\n , payment_year\n from transition_scores\n group by\n patient_id\n , payment_year\n\n)\n\n, blended as (\n\n select\n patient_id\n , v24_risk_score\n , v28_risk_score\n , v24_risk_score + v28_risk_score as blended_risk_score\n , payment_year\n from transition_scores_grouped\n\n)\n\n, normalized as (\n\n select\n blended.patient_id\n , blended.v24_risk_score\n , blended.v28_risk_score\n , blended.blended_risk_score\n , blended.blended_risk_score / seed_adjustment_rates.normalization_factor as normalized_risk_score\n , blended.payment_year\n from blended\n left join seed_adjustment_rates\n on blended.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, payment as (\n\n select\n normalized.patient_id\n , normalized.v24_risk_score\n , normalized.v28_risk_score\n , normalized.blended_risk_score\n , normalized.normalized_risk_score\n , normalized.normalized_risk_score * (1 - seed_adjustment_rates.ma_coding_pattern_adjustment) as payment_risk_score\n , normalized.payment_year\n from normalized\n left join seed_adjustment_rates\n on normalized.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, weighted_score as (\n\n select\n payment.patient_id\n , payment.v24_risk_score\n , payment.v28_risk_score\n , payment.blended_risk_score\n , payment.normalized_risk_score\n , payment.payment_risk_score\n , member_months.member_months\n , payment.payment_risk_score * member_months.member_months as payment_risk_score_weighted_by_months\n , payment.payment_year\n from payment\n left join member_months\n on payment.patient_id = member_months.patient_id\n and payment.payment_year = member_months.eligible_year\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , round(cast(v24_risk_score as {{ dbt.type_numeric() }}),3) as v24_risk_score\n , round(cast(v28_risk_score as {{ dbt.type_numeric() }}),3) as v28_risk_score\n , round(cast(blended_risk_score as {{ dbt.type_numeric() }}),3) as blended_risk_score\n , round(cast(normalized_risk_score as {{ dbt.type_numeric() }}),3) as normalized_risk_score\n , round(cast(payment_risk_score as {{ dbt.type_numeric() }}),3) as payment_risk_score\n , round(cast(payment_risk_score_weighted_by_months as {{ dbt.type_numeric() }}),3) as payment_risk_score_weighted_by_months\n , cast(member_months as integer) as member_months\n , cast(payment_year as integer) as payment_year\n from weighted_score\n\n)\n\nselect\n patient_id\n , v24_risk_score\n , v28_risk_score\n , blended_risk_score\n , normalized_risk_score\n , payment_risk_score\n , payment_risk_score_weighted_by_months\n , member_months\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__adjustment_rates", "package": null, "version": null}, {"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}, {"name": "cms_hcc__stg_core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.substring", "macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["seed.the_tuva_project.cms_hcc__adjustment_rates", "model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.cms_hcc__stg_core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/final/cms_hcc__patient_risk_scores.sql", "compiled": true, "compiled_code": "\nwith __dbt__cte___stg_member_months as (\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.member_months\n), seed_adjustment_rates as (\n\n select\n model_version\n , payment_year\n , normalization_factor\n , ma_coding_pattern_adjustment\n from cms_synthetic.cms_hcc._value_set_adjustment_rates\n\n)\n\n, risk_factors as (\n\n select\n patient_id\n , coefficient\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc.patient_risk_factors\n\n)\n\n, member_months as (\n\n select\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer) as eligible_year\n , COUNT(1) as member_months\n from __dbt__cte___stg_member_months\n group by\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer)\n)\n\n, raw_score as (\n\n select\n patient_id\n , sum(coefficient) as risk_score\n , model_version\n , payment_year\n from risk_factors\n group by\n patient_id\n , model_version\n , payment_year\n\n)\n\n/*\n CMS Guidance for the transition from v24 to v28:\n\n PY2024 risk scores will be blended using 67% of the risk score calculated\n from v24 and 33% from v28.\n\n PY2025 risk scores will be blended using 33% of the risk score calculated\n from v24 and 67% from v28.\n\n PY2026 risk scores will be 100% from v28.\n\n Prior payment years will still be calculated from v24 only.\n*/\n, transition_scores as (\n\n select\n patient_id\n , risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V24' then risk_score\n when payment_year = 2024 and model_version = 'CMS-HCC-V24' then risk_score * 0.67\n when payment_year = 2025 and model_version = 'CMS-HCC-V24' then risk_score * 0.33\n when payment_year >= 2026 and model_version = 'CMS-HCC-V24' then 0\n end as v24_risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V28' then 0\n when payment_year = 2024 and model_version = 'CMS-HCC-V28' then risk_score * 0.33\n when payment_year = 2025 and model_version = 'CMS-HCC-V28' then risk_score * 0.67\n when payment_year >= 2026 and model_version = 'CMS-HCC-V28' then risk_score\n end as v28_risk_score\n , model_version\n , payment_year\n from raw_score\n\n)\n\n/*\n Grouping by patient to create a single row per patient.\n*/\n, transition_scores_grouped as (\n\n select\n patient_id\n , max(v24_risk_score) as v24_risk_score\n , max(v28_risk_score) as v28_risk_score\n , payment_year\n from transition_scores\n group by\n patient_id\n , payment_year\n\n)\n\n, blended as (\n\n select\n patient_id\n , v24_risk_score\n , v28_risk_score\n , v24_risk_score + v28_risk_score as blended_risk_score\n , payment_year\n from transition_scores_grouped\n\n)\n\n, normalized as (\n\n select\n blended.patient_id\n , blended.v24_risk_score\n , blended.v28_risk_score\n , blended.blended_risk_score\n , blended.blended_risk_score / seed_adjustment_rates.normalization_factor as normalized_risk_score\n , blended.payment_year\n from blended\n left join seed_adjustment_rates\n on blended.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, payment as (\n\n select\n normalized.patient_id\n , normalized.v24_risk_score\n , normalized.v28_risk_score\n , normalized.blended_risk_score\n , normalized.normalized_risk_score\n , normalized.normalized_risk_score * (1 - seed_adjustment_rates.ma_coding_pattern_adjustment) as payment_risk_score\n , normalized.payment_year\n from normalized\n left join seed_adjustment_rates\n on normalized.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, weighted_score as (\n\n select\n payment.patient_id\n , payment.v24_risk_score\n , payment.v28_risk_score\n , payment.blended_risk_score\n , payment.normalized_risk_score\n , payment.payment_risk_score\n , member_months.member_months\n , payment.payment_risk_score * member_months.member_months as payment_risk_score_weighted_by_months\n , payment.payment_year\n from payment\n left join member_months\n on payment.patient_id = member_months.patient_id\n and payment.payment_year = member_months.eligible_year\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(v24_risk_score as numeric(28,6)),3) as v24_risk_score\n , round(cast(v28_risk_score as numeric(28,6)),3) as v28_risk_score\n , round(cast(blended_risk_score as numeric(28,6)),3) as blended_risk_score\n , round(cast(normalized_risk_score as numeric(28,6)),3) as normalized_risk_score\n , round(cast(payment_risk_score as numeric(28,6)),3) as payment_risk_score\n , round(cast(payment_risk_score_weighted_by_months as numeric(28,6)),3) as payment_risk_score_weighted_by_months\n , cast(member_months as integer) as member_months\n , cast(payment_year as integer) as payment_year\n from weighted_score\n\n)\n\nselect\n patient_id\n , v24_risk_score\n , v28_risk_score\n , blended_risk_score\n , normalized_risk_score\n , payment_risk_score\n , payment_risk_score_weighted_by_months\n , member_months\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_hcc__stg_core__member_months", "sql": " __dbt__cte___stg_member_months as (\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.member_months\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_disease_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_disease_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_disease_factors.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_disease_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_disease_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_disease_factors"], "alias": "_int_disease_factors", "checksum": {"name": "sha256", "checksum": "f911e5b352b9158834350a69fd45954c64df5ed8a6c121d0ee2a29a0847369b5"}, "config": {"enabled": true, "alias": "_int_disease_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Disease factor values for every enrollee's final payment-eligible HCC after the hierarchy has been applied and necessary HCCs dropped for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_disease_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.504429, "relation_name": "cms_synthetic.cms_hcc._int_disease_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\n\n)\n\n, seed_disease_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , hcc_code\n , description\n , coefficient\n from {{ ref('cms_hcc__disease_factors') }}\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.gender\n , demographics.age_group\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, disease_factors as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.hcc_code\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_disease_factors.factor_type\n , seed_disease_factors.description\n , seed_disease_factors.coefficient\n from demographics_with_hccs\n inner join seed_disease_factors\n on demographics_with_hccs.enrollment_status = seed_disease_factors.enrollment_status\n and demographics_with_hccs.medicaid_status = seed_disease_factors.medicaid_status\n and demographics_with_hccs.dual_status = seed_disease_factors.dual_status\n and demographics_with_hccs.orec = seed_disease_factors.orec\n and demographics_with_hccs.institutional_status = seed_disease_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_disease_factors.hcc_code\n and demographics_with_hccs.model_version = seed_disease_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(description as {{ dbt.type_string() }}) as hcc_description\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_factors\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}, {"name": "cms_hcc__disease_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_disease_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_disease_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , hcc_code\n , description\n , coefficient\n from cms_synthetic.cms_hcc._value_set_disease_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.gender\n , demographics.age_group\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, disease_factors as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.hcc_code\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_disease_factors.factor_type\n , seed_disease_factors.description\n , seed_disease_factors.coefficient\n from demographics_with_hccs\n inner join seed_disease_factors\n on demographics_with_hccs.enrollment_status = seed_disease_factors.enrollment_status\n and demographics_with_hccs.medicaid_status = seed_disease_factors.medicaid_status\n and demographics_with_hccs.dual_status = seed_disease_factors.dual_status\n and demographics_with_hccs.orec = seed_disease_factors.orec\n and demographics_with_hccs.institutional_status = seed_disease_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_disease_factors.hcc_code\n and demographics_with_hccs.model_version = seed_disease_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(description as TEXT) as hcc_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_factors\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_eligible_conditions": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_eligible_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_eligible_conditions.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_eligible_conditions.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_eligible_conditions", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_eligible_conditions"], "alias": "_int_eligible_conditions", "checksum": {"name": "sha256", "checksum": "91101eccd93eea58c2b2937d80ee325cb752e5d21cc50dd130828a9aff41d80e"}, "config": {"enabled": true, "alias": "_int_eligible_conditions", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Conditions from eligible risk-adjustable claims per claim type for the collection year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_code": {"name": "condition_code", "description": "The condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_eligible_conditions", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5078049, "relation_name": "cms_synthetic.cms_hcc._int_eligible_conditions", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n/*\nSteps for staging condition data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs\n\nClaims filtering logic:\n - Professional:\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n - Inpatient:\n - Bill type code in (11X, 41X)\n - Outpatient:\n - Bill type code in (12X, 13X, 43X, 71X, 73X, 76X, 77X, 85X)\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - The collection year is one year prior to the payment year.\n*/\n\n{% set payment_year = var('cms_hcc_payment_year') | int() -%}\n{% set collection_year = payment_year - 1 -%}\n\nwith medical_claims as (\n\n select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n from {{ ref('cms_hcc__stg_core__medical_claim') }}\n\n)\n\n, conditions as (\n\n select\n claim_id\n , patient_id\n , code\n from {{ ref('cms_hcc__stg_core__condition') }}\n where code_type = 'icd-10-cm'\n\n)\n\n, cpt_hcpcs_list as (\n\n select\n payment_year\n , hcpcs_cpt_code\n from {{ ref('cms_hcc__cpt_hcpcs') }}\n\n)\n\n, professional_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'professional'\n and {{ date_part('year', 'claim_end_date') }} = {{ collection_year }}\n and cpt_hcpcs_list.payment_year = {{ payment_year }}\n\n)\n\n\n, inpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n where claim_type = 'institutional'\n {% if target.type == 'fabric' %}\n and YEAR(claim_end_date) = {{ collection_year }}\n {% else %}\n and extract(year from claim_end_date) = {{ collection_year }}\n {% endif %}\n and substring(bill_type_code, 1, 2) in ('11','41')\n\n)\n\n, outpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'institutional'\n {% if target.type == 'fabric' %}\n and YEAR(claim_end_date) = {{ collection_year }}\n {% else %}\n and extract(year from claim_end_date) = {{ collection_year }}\n {% endif %}\n and cpt_hcpcs_list.payment_year = {{ payment_year }}\n and substring(bill_type_code, 1, 2) in ('12','13','43','71','73','76','77','85')\n\n)\n\n, eligible_claims as (\n\n select * from professional_claims\n union all\n select * from inpatient_claims\n union all\n select * from outpatient_claims\n\n)\n\n, eligible_conditions as (\n\n select distinct\n eligible_claims.claim_id\n , eligible_claims.patient_id\n , conditions.code\n from eligible_claims\n inner join conditions\n on eligible_claims.claim_id = conditions.claim_id\n and eligible_claims.patient_id = conditions.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(code as {{ dbt.type_string() }}) as condition_code\n , cast('{{ payment_year }}' as integer) as payment_year\n from eligible_conditions\n\n)\n\nselect\n patient_id\n , condition_code\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__stg_core__medical_claim", "package": null, "version": null}, {"name": "cms_hcc__stg_core__condition", "package": null, "version": null}, {"name": "cms_hcc__cpt_hcpcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__stg_core__medical_claim", "model.the_tuva_project.cms_hcc__stg_core__condition", "seed.the_tuva_project.cms_hcc__cpt_hcpcs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_eligible_conditions.sql", "compiled": true, "compiled_code": "\n/*\nSteps for staging condition data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs\n\nClaims filtering logic:\n - Professional:\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n - Inpatient:\n - Bill type code in (11X, 41X)\n - Outpatient:\n - Bill type code in (12X, 13X, 43X, 71X, 73X, 76X, 77X, 85X)\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - The collection year is one year prior to the payment year.\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), medical_claims as (\n\n select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, conditions as (\n\n select\n claim_id\n , patient_id\n , code\n from __dbt__cte___stg_condition\n where code_type = 'icd-10-cm'\n\n)\n\n, cpt_hcpcs_list as (\n\n select\n payment_year\n , hcpcs_cpt_code\n from cms_synthetic.cms_hcc._value_set_cpt_hcpcs\n\n)\n\n, professional_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'professional'\n and date_part('year', claim_end_date) = 2023\n and cpt_hcpcs_list.payment_year = 2024\n\n)\n\n\n, inpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and substring(bill_type_code, 1, 2) in ('11','41')\n\n)\n\n, outpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and cpt_hcpcs_list.payment_year = 2024\n and substring(bill_type_code, 1, 2) in ('12','13','43','71','73','76','77','85')\n\n)\n\n, eligible_claims as (\n\n select * from professional_claims\n union all\n select * from inpatient_claims\n union all\n select * from outpatient_claims\n\n)\n\n, eligible_conditions as (\n\n select distinct\n eligible_claims.claim_id\n , eligible_claims.patient_id\n , conditions.code\n from eligible_claims\n inner join conditions\n on eligible_claims.claim_id = conditions.claim_id\n and eligible_claims.patient_id = conditions.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(code as TEXT) as condition_code\n , cast('2024' as integer) as payment_year\n from eligible_conditions\n\n)\n\nselect\n patient_id\n , condition_code\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n)"}, {"id": "model.the_tuva_project.cms_hcc__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_disease_interaction_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_disease_interaction_factors.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_disease_interaction_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_disease_interaction_factors"], "alias": "_int_disease_interaction_factors", "checksum": {"name": "sha256", "checksum": "576de6d097918a3a96aa44e338eada4b67741cd50607e1232848e0be1c196202"}, "config": {"enabled": true, "alias": "_int_disease_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Disease interaction factor values for final payment-eligible HCC after the hierarchy has been applied and necessary HCCs dropped for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_1": {"name": "hcc_code_1", "description": "HCC code 1 of the interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_2": {"name": "hcc_code_2", "description": "HCC code 2 of the interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disease interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_disease_interaction_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.506081, "relation_name": "cms_synthetic.cms_hcc._int_disease_interaction_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , short_name\n , description\n , hcc_code_1\n , hcc_code_2\n , coefficient\n from {{ ref('cms_hcc__disease_interaction_factors') }}\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, demographics_with_interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , interactions_code_1.factor_type\n , interactions_code_1.description\n , interactions_code_1.hcc_code_1\n , interactions_code_1.hcc_code_2\n , interactions_code_1.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors as interactions_code_1\n on demographics_with_hccs.enrollment_status = interactions_code_1.enrollment_status\n and demographics_with_hccs.medicaid_status = interactions_code_1.medicaid_status\n and demographics_with_hccs.dual_status = interactions_code_1.dual_status\n and demographics_with_hccs.orec = interactions_code_1.orec\n and demographics_with_hccs.institutional_status = interactions_code_1.institutional_status\n and demographics_with_hccs.hcc_code = interactions_code_1.hcc_code_1\n and demographics_with_hccs.model_version = interactions_code_1.model_version\n\n)\n\n, disease_interactions as (\n\n select\n demographics_with_interactions.patient_id\n , demographics_with_interactions.factor_type\n , demographics_with_interactions.hcc_code_1\n , demographics_with_interactions.hcc_code_2\n , demographics_with_interactions.description\n , demographics_with_interactions.coefficient\n , demographics_with_interactions.model_version\n , demographics_with_interactions.payment_year\n from demographics_with_interactions\n inner join demographics_with_hccs as interactions_code_2\n on demographics_with_interactions.patient_id = interactions_code_2.patient_id\n and demographics_with_interactions.hcc_code_2 = interactions_code_2.hcc_code\n and demographics_with_interactions.model_version = interactions_code_2.model_version\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(hcc_code_1 as {{ dbt.type_string() }}) as hcc_code_1\n , cast(hcc_code_2 as {{ dbt.type_string() }}) as hcc_code_2\n , cast(description as {{ dbt.type_string() }}) as description\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_interactions\n\n)\n\nselect\n patient_id\n , hcc_code_1\n , hcc_code_2\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}, {"name": "cms_hcc__disease_interaction_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_interaction_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_disease_interaction_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , short_name\n , description\n , hcc_code_1\n , hcc_code_2\n , coefficient\n from cms_synthetic.cms_hcc._value_set_disease_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, demographics_with_interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , interactions_code_1.factor_type\n , interactions_code_1.description\n , interactions_code_1.hcc_code_1\n , interactions_code_1.hcc_code_2\n , interactions_code_1.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors as interactions_code_1\n on demographics_with_hccs.enrollment_status = interactions_code_1.enrollment_status\n and demographics_with_hccs.medicaid_status = interactions_code_1.medicaid_status\n and demographics_with_hccs.dual_status = interactions_code_1.dual_status\n and demographics_with_hccs.orec = interactions_code_1.orec\n and demographics_with_hccs.institutional_status = interactions_code_1.institutional_status\n and demographics_with_hccs.hcc_code = interactions_code_1.hcc_code_1\n and demographics_with_hccs.model_version = interactions_code_1.model_version\n\n)\n\n, disease_interactions as (\n\n select\n demographics_with_interactions.patient_id\n , demographics_with_interactions.factor_type\n , demographics_with_interactions.hcc_code_1\n , demographics_with_interactions.hcc_code_2\n , demographics_with_interactions.description\n , demographics_with_interactions.coefficient\n , demographics_with_interactions.model_version\n , demographics_with_interactions.payment_year\n from demographics_with_interactions\n inner join demographics_with_hccs as interactions_code_2\n on demographics_with_interactions.patient_id = interactions_code_2.patient_id\n and demographics_with_interactions.hcc_code_2 = interactions_code_2.hcc_code\n and demographics_with_interactions.model_version = interactions_code_2.model_version\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code_1 as TEXT) as hcc_code_1\n , cast(hcc_code_2 as TEXT) as hcc_code_2\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_interactions\n\n)\n\nselect\n patient_id\n , hcc_code_1\n , hcc_code_2\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_hcc_hierarchy", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_hcc_hierarchy.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_hcc_hierarchy.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_hcc_hierarchy"], "alias": "_int_hcc_hierarchy", "checksum": {"name": "sha256", "checksum": "17868e2052af0624173eb164532c7ecc2d42bffa30a031c7169d0ea2055bcb26"}, "config": {"enabled": true, "alias": "_int_hcc_hierarchy", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "HCC hierarchy for the corresponding HCC model version and payment year applied to the mapped payment-eligible HCCs.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_hcc_hierarchy", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.513982, "relation_name": "cms_synthetic.cms_hcc._int_hcc_hierarchy", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n/*\n Staging HCCs that will be used in disease factor calculations.\n Final output for each CMS model version includes:\n - hccs without a hierarchy\n - lower-level hccs with hierarchy where top-level hcc is missing\n - top-level hccs from hierarchy\n*/\n\nwith hcc_mapping as (\n\n select distinct\n patient_id\n , hcc_code\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_hcc_mapping') }}\n\n)\n\n, seed_hcc_hierarchy as (\n\n select\n model_version\n , hcc_code\n , description\n , hccs_to_exclude\n from {{ ref('cms_hcc__disease_hierarchy') }}\n\n)\n\n/*\n selecting hccs that do not have a hierarchy\n all codes in this cte are included in final output\n*/\n, hccs_without_hierarchy as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n left join seed_hcc_hierarchy as hcc_top_level\n on hcc_mapping.hcc_code = hcc_top_level.hcc_code\n and hcc_mapping.model_version = hcc_top_level.model_version\n left join seed_hcc_hierarchy as hcc_exclusions\n on hcc_mapping.hcc_code = hcc_exclusions.hccs_to_exclude\n and hcc_mapping.model_version = hcc_exclusions.model_version\n where hcc_top_level.hcc_code is null\n and hcc_exclusions.hccs_to_exclude is null\n\n)\n\n/*\n selecting hccs that have a hierarchy to be evaluated in the next cte\n*/\n, hccs_with_hierarchy as (\n\n select\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n , seed_hcc_hierarchy.hcc_code as top_level_hcc\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hccs_to_exclude\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n\n)\n\n/*\n applying hcc hierarchy and grouping by patient and hcc\n to account for multiple hcc combinations\n minimum HCC is included following CMS's severity logic\n*/\n, hierarchy_applied as (\n\n select\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n , min(hcc_mapping.hcc_code) as top_level_hcc\n from hccs_with_hierarchy\n left join hcc_mapping\n on hcc_mapping.patient_id = hccs_with_hierarchy.patient_id\n and hcc_mapping.hcc_code = hccs_with_hierarchy.top_level_hcc\n and hcc_mapping.model_version = hccs_with_hierarchy.model_version\n group by\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n\n)\n\n/*\n selecting lower-level hccs in hierarchy\n all codes in this cte are included in final output\n*/\n, lower_level_inclusions as (\n\n select distinct\n patient_id\n , model_version\n , payment_year\n , case\n when top_level_hcc is not null then top_level_hcc\n else hcc_code\n end as hcc_code\n from hierarchy_applied\n\n)\n\n/*\n selecting top-level hccs not in previous steps\n all codes in this cte are included in final output\n*/\n, top_level_inclusions as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hcc_code\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n left join lower_level_inclusions\n on hcc_mapping.patient_id = lower_level_inclusions.patient_id\n and hcc_mapping.hcc_code = lower_level_inclusions.hcc_code\n and hcc_mapping.model_version = lower_level_inclusions.model_version\n left join hierarchy_applied\n on hcc_mapping.patient_id = hierarchy_applied.patient_id\n and hcc_mapping.hcc_code = hierarchy_applied.hcc_code\n and hcc_mapping.model_version = hierarchy_applied.model_version\n where lower_level_inclusions.hcc_code is null\n and hierarchy_applied.top_level_hcc is null\n\n)\n\n, unioned as (\n\n select * from hccs_without_hierarchy\n union all\n select * from lower_level_inclusions\n union all\n select * from top_level_inclusions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n from unioned\n\n)\n\nselect\n patient_id\n , model_version\n , payment_year\n , hcc_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_hcc_mapping", "package": null, "version": null}, {"name": "cms_hcc__disease_hierarchy", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__int_hcc_mapping", "seed.the_tuva_project.cms_hcc__disease_hierarchy"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_hcc_hierarchy.sql", "compiled": true, "compiled_code": "\n/*\n Staging HCCs that will be used in disease factor calculations.\n Final output for each CMS model version includes:\n - hccs without a hierarchy\n - lower-level hccs with hierarchy where top-level hcc is missing\n - top-level hccs from hierarchy\n*/\n\nwith hcc_mapping as (\n\n select distinct\n patient_id\n , hcc_code\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_hcc_mapping\n\n)\n\n, seed_hcc_hierarchy as (\n\n select\n model_version\n , hcc_code\n , description\n , hccs_to_exclude\n from cms_synthetic.cms_hcc._value_set_disease_hierarchy\n\n)\n\n/*\n selecting hccs that do not have a hierarchy\n all codes in this cte are included in final output\n*/\n, hccs_without_hierarchy as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n left join seed_hcc_hierarchy as hcc_top_level\n on hcc_mapping.hcc_code = hcc_top_level.hcc_code\n and hcc_mapping.model_version = hcc_top_level.model_version\n left join seed_hcc_hierarchy as hcc_exclusions\n on hcc_mapping.hcc_code = hcc_exclusions.hccs_to_exclude\n and hcc_mapping.model_version = hcc_exclusions.model_version\n where hcc_top_level.hcc_code is null\n and hcc_exclusions.hccs_to_exclude is null\n\n)\n\n/*\n selecting hccs that have a hierarchy to be evaluated in the next cte\n*/\n, hccs_with_hierarchy as (\n\n select\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n , seed_hcc_hierarchy.hcc_code as top_level_hcc\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hccs_to_exclude\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n\n)\n\n/*\n applying hcc hierarchy and grouping by patient and hcc\n to account for multiple hcc combinations\n minimum HCC is included following CMS's severity logic\n*/\n, hierarchy_applied as (\n\n select\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n , min(hcc_mapping.hcc_code) as top_level_hcc\n from hccs_with_hierarchy\n left join hcc_mapping\n on hcc_mapping.patient_id = hccs_with_hierarchy.patient_id\n and hcc_mapping.hcc_code = hccs_with_hierarchy.top_level_hcc\n and hcc_mapping.model_version = hccs_with_hierarchy.model_version\n group by\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n\n)\n\n/*\n selecting lower-level hccs in hierarchy\n all codes in this cte are included in final output\n*/\n, lower_level_inclusions as (\n\n select distinct\n patient_id\n , model_version\n , payment_year\n , case\n when top_level_hcc is not null then top_level_hcc\n else hcc_code\n end as hcc_code\n from hierarchy_applied\n\n)\n\n/*\n selecting top-level hccs not in previous steps\n all codes in this cte are included in final output\n*/\n, top_level_inclusions as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hcc_code\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n left join lower_level_inclusions\n on hcc_mapping.patient_id = lower_level_inclusions.patient_id\n and hcc_mapping.hcc_code = lower_level_inclusions.hcc_code\n and hcc_mapping.model_version = lower_level_inclusions.model_version\n left join hierarchy_applied\n on hcc_mapping.patient_id = hierarchy_applied.patient_id\n and hcc_mapping.hcc_code = hierarchy_applied.hcc_code\n and hcc_mapping.model_version = hierarchy_applied.model_version\n where lower_level_inclusions.hcc_code is null\n and hierarchy_applied.top_level_hcc is null\n\n)\n\n, unioned as (\n\n select * from hccs_without_hierarchy\n union all\n select * from lower_level_inclusions\n union all\n select * from top_level_inclusions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n , cast(hcc_code as TEXT) as hcc_code\n from unioned\n\n)\n\nselect\n patient_id\n , model_version\n , payment_year\n , hcc_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_hcc_mapping": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_hcc_mapping", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_hcc_mapping.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_hcc_mapping.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_mapping", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_hcc_mapping"], "alias": "_int_hcc_mapping", "checksum": {"name": "sha256", "checksum": "2b2fdde0c4c29df4bc390c73f70884ab019b3fac742cbb48ce1dea6599b89abb"}, "config": {"enabled": true, "alias": "_int_hcc_mapping", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Eligible conditions mapped to HCC codes for the corresponding HCC model version and payment year\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_code": {"name": "condition_code", "description": "Condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_hcc_mapping", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.515614, "relation_name": "cms_synthetic.cms_hcc._int_hcc_mapping", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n/*\nSteps for staging the medical claim data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from Condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs for each CMS model version\n 4) Union results from each CMS model version\n (note: some payment years may not have results for v28)\n*/\n\nwith conditions as (\n\n select\n patient_id\n , condition_code\n , payment_year\n from {{ ref('cms_hcc__int_eligible_conditions') }}\n\n)\n\n, seed_hcc_mapping as (\n\n select\n payment_year\n , diagnosis_code\n , cms_hcc_v24\n , cms_hcc_v24_flag\n , cms_hcc_v28\n , cms_hcc_v28_flag\n from {{ ref('cms_hcc__icd_10_cm_mappings') }}\n\n)\n\n/* casting hcc_code to avoid formatting changes during union */\n, v24_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V24' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v24 as {{ dbt.type_string() }}) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v24_flag = 'Yes'\n\n)\n\n, v28_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V28' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v28 as {{ dbt.type_string() }}) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v28_flag = 'Yes'\n\n)\n\n, unioned as (\n\n select * from v24_mapped\n union all\n select * from v28_mapped\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(condition_code as {{ dbt.type_string() }}) as condition_code\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , condition_code\n , hcc_code\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_eligible_conditions", "package": null, "version": null}, {"name": "cms_hcc__icd_10_cm_mappings", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__int_eligible_conditions", "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_hcc_mapping.sql", "compiled": true, "compiled_code": "\n/*\nSteps for staging the medical claim data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from Condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs for each CMS model version\n 4) Union results from each CMS model version\n (note: some payment years may not have results for v28)\n*/\n\nwith conditions as (\n\n select\n patient_id\n , condition_code\n , payment_year\n from cms_synthetic.cms_hcc._int_eligible_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n payment_year\n , diagnosis_code\n , cms_hcc_v24\n , cms_hcc_v24_flag\n , cms_hcc_v28\n , cms_hcc_v28_flag\n from cms_synthetic.cms_hcc._value_set_icd_10_cm_mappings\n\n)\n\n/* casting hcc_code to avoid formatting changes during union */\n, v24_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V24' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v24 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v24_flag = 'Yes'\n\n)\n\n, v28_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V28' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v28 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v28_flag = 'Yes'\n\n)\n\n, unioned as (\n\n select * from v24_mapped\n union all\n select * from v28_mapped\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(condition_code as TEXT) as condition_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , condition_code\n , hcc_code\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_disabled_interaction_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_disabled_interaction_factors.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_disabled_interaction_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_disabled_interaction_factors"], "alias": "_int_disabled_interaction_factors", "checksum": {"name": "sha256", "checksum": "675035e50cdcd4a18b254b69e74f3d6ca9e6c6478724b708c2d8eae15874acf9"}, "config": {"enabled": true, "alias": "_int_disabled_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Disabled and disease interaction factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disabled and disease interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_disabled_interaction_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.502856, "relation_name": "cms_synthetic.cms_hcc._int_disabled_interaction_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , institutional_status\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , institutional_status\n , short_name\n , description\n , hcc_code\n , coefficient\n from {{ ref('cms_hcc__disabled_interaction_factors') }}\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors\n on demographics_with_hccs.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics_with_hccs.institutional_status = seed_interaction_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_interaction_factors.hcc_code\n and demographics_with_hccs.model_version = seed_interaction_factors.model_version\n\n)\n\n, add_data_types as (\n\nselect\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(description as {{ dbt.type_string() }}) as description\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\nfrom interactions\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}, {"name": "cms_hcc__disabled_interaction_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disabled_interaction_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_disabled_interaction_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , institutional_status\n , short_name\n , description\n , hcc_code\n , coefficient\n from cms_synthetic.cms_hcc._value_set_disabled_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors\n on demographics_with_hccs.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics_with_hccs.institutional_status = seed_interaction_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_interaction_factors.hcc_code\n and demographics_with_hccs.model_version = seed_interaction_factors.model_version\n\n)\n\n, add_data_types as (\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\nfrom interactions\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_hcc_count_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_hcc_count_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_hcc_count_factors.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_hcc_count_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_count_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_hcc_count_factors"], "alias": "_int_hcc_count_factors", "checksum": {"name": "sha256", "checksum": "bacca82d3bceb4e1c6c29031f130fc9fa401221c3a357032eb8ab6a683a934f2"}, "config": {"enabled": true, "alias": "_int_hcc_count_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Final payment-eligible HCC count factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "HCC counts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_hcc_count_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5122938, "relation_name": "cms_synthetic.cms_hcc._int_hcc_count_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, seed_payment_hcc_count_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , payment_hcc_count\n , description\n , coefficient\n from {{ ref('cms_hcc__payment_hcc_count_factors') }}\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\n\n)\n\n, demographics_with_hcc_counts as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , count(hcc_hierarchy.hcc_code) as hcc_count\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n group by\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n\n)\n\n, hcc_counts_normalized as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n , case\n when hcc_count >= 10 then '>=10'\n else cast(hcc_count as {{ dbt.type_string() }})\n end as hcc_count_string\n from demographics_with_hcc_counts\n\n)\n\n, hcc_counts as (\n\n select\n hcc_counts_normalized.patient_id\n , hcc_counts_normalized.model_version\n , hcc_counts_normalized.payment_year\n , seed_payment_hcc_count_factors.factor_type\n , seed_payment_hcc_count_factors.description\n , seed_payment_hcc_count_factors.coefficient\n from hcc_counts_normalized\n inner join seed_payment_hcc_count_factors\n on hcc_counts_normalized.enrollment_status = seed_payment_hcc_count_factors.enrollment_status\n and hcc_counts_normalized.medicaid_status = seed_payment_hcc_count_factors.medicaid_status\n and hcc_counts_normalized.dual_status = seed_payment_hcc_count_factors.dual_status\n and hcc_counts_normalized.orec = seed_payment_hcc_count_factors.orec\n and hcc_counts_normalized.institutional_status = seed_payment_hcc_count_factors.institutional_status\n and hcc_counts_normalized.hcc_count_string = seed_payment_hcc_count_factors.payment_hcc_count\n and hcc_counts_normalized.model_version = seed_payment_hcc_count_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(description as {{ dbt.type_string() }}) as description\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from hcc_counts\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__payment_hcc_count_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_hcc_count_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, seed_payment_hcc_count_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , payment_hcc_count\n , description\n , coefficient\n from cms_synthetic.cms_hcc._value_set_payment_hcc_count_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, demographics_with_hcc_counts as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , count(hcc_hierarchy.hcc_code) as hcc_count\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n group by\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n\n)\n\n, hcc_counts_normalized as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n , case\n when hcc_count >= 10 then '>=10'\n else cast(hcc_count as TEXT)\n end as hcc_count_string\n from demographics_with_hcc_counts\n\n)\n\n, hcc_counts as (\n\n select\n hcc_counts_normalized.patient_id\n , hcc_counts_normalized.model_version\n , hcc_counts_normalized.payment_year\n , seed_payment_hcc_count_factors.factor_type\n , seed_payment_hcc_count_factors.description\n , seed_payment_hcc_count_factors.coefficient\n from hcc_counts_normalized\n inner join seed_payment_hcc_count_factors\n on hcc_counts_normalized.enrollment_status = seed_payment_hcc_count_factors.enrollment_status\n and hcc_counts_normalized.medicaid_status = seed_payment_hcc_count_factors.medicaid_status\n and hcc_counts_normalized.dual_status = seed_payment_hcc_count_factors.dual_status\n and hcc_counts_normalized.orec = seed_payment_hcc_count_factors.orec\n and hcc_counts_normalized.institutional_status = seed_payment_hcc_count_factors.institutional_status\n and hcc_counts_normalized.hcc_count_string = seed_payment_hcc_count_factors.payment_hcc_count\n and hcc_counts_normalized.model_version = seed_payment_hcc_count_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from hcc_counts\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_demographic_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_demographic_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_demographic_factors.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_demographic_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_demographic_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_demographic_factors"], "alias": "_int_demographic_factors", "checksum": {"name": "sha256", "checksum": "f21e709285200c445b27be121811fe238fe3ee359c0e5d8560f3e5098b6ec19f"}, "config": {"enabled": true, "alias": "_int_demographic_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Demographic and enrollment risk relative factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Indicates whether the patient is a \"Continuing\" or \"New\" enrollee.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Indicates whether the patient is \"Female\" or \"Male\".", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "Indicates what age group the patient is in. (e.g. \"60-64\"). CMS guidance: Age is calculated as of Feb 1 of the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Indicates whether the patient is enrolled in Medicaid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Indicates whether the patient has \"Full\", \"Partial\", or \"Non\" dual status.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Indicates the Original Reason for Entitlement Code (OREC) \"Aged\", \"Disabled\", or \"ESRD\".\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Indicates whether the patient resided in an institution for at least 90 days.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status_default": {"name": "enrollment_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_dual_status_default": {"name": "medicaid_dual_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec_default": {"name": "orec_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status_default": {"name": "institutional_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_demographic_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.500879, "relation_name": "cms_synthetic.cms_hcc._int_demographic_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith members as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n from {{ ref('cms_hcc__int_members') }}\n\n)\n\n, seed_demographic_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , coefficient\n from {{ ref('cms_hcc__demographic_factors') }}\n where plan_segment is null /* data not available */\n\n)\n\n, v24_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v24_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v28_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, v28_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, unioned as (\n\n select * from v24_new_enrollees\n union all\n select * from v24_continuining_enrollees\n union all\n select * from v28_new_enrollees\n union all\n select * from v28_continuining_enrollees\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(enrollment_status as {{ dbt.type_string() }}) as enrollment_status\n , cast(gender as {{ dbt.type_string() }}) as gender\n , cast(age_group as {{ dbt.type_string() }}) as age_group\n , cast(medicaid_status as {{ dbt.type_string() }}) as medicaid_status\n , cast(dual_status as {{ dbt.type_string() }}) as dual_status\n , cast(orec as {{ dbt.type_string() }}) as orec\n , cast(institutional_status as {{ dbt.type_string() }}) as institutional_status\n {% if target.type == 'fabric' %}\n , cast(enrollment_status_default as bit) as enrollment_status_default\n , cast(medicaid_dual_status_default as bit) as medicaid_dual_status_default\n , cast(orec_default as bit) as orec_default\n , cast(institutional_status_default as bit) as institutional_status_default\n {% else %}\n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n {% endif %}\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_members", "package": null, "version": null}, {"name": "cms_hcc__demographic_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_members", "seed.the_tuva_project.cms_hcc__demographic_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_demographic_factors.sql", "compiled": true, "compiled_code": "\n\nwith members as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n from cms_synthetic.cms_hcc._int_members\n\n)\n\n, seed_demographic_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , coefficient\n from cms_synthetic.cms_hcc._value_set_demographic_factors\n where plan_segment is null /* data not available */\n\n)\n\n, v24_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v24_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v28_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, v28_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, unioned as (\n\n select * from v24_new_enrollees\n union all\n select * from v24_continuining_enrollees\n union all\n select * from v28_new_enrollees\n union all\n select * from v28_continuining_enrollees\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_members": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_members", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_members.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_members.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_members", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_members"], "alias": "_int_members", "checksum": {"name": "sha256", "checksum": "a8eb07038f2d26aa4327eba01b1ac5d3d09d9a8b52ad758f22d072e52c3b401a"}, "config": {"enabled": true, "alias": "_int_members", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Transformed eligibility data into the demographic risk segments required for the CMS HCC and risk calculations.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Indicates whether the patient is a \"Continuing\" or \"New\" enrollee.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Indicates whether the patient is \"Female\" or \"Male\".", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "Indicates what age group the patient is in. (e.g. \"60-64\"). CMS guidance: Age is calculated as of Feb 1 of the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Indicates whether the patient is enrolled in Medicaid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Indicates whether the patient has \"Full\", \"Partial\", or \"Non\" dual status.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Indicates the Original Reason for Entitlement Code (OREC) \"Aged\", \"Disabled\", or \"ESRD\". If available, current Medicare Status is used when OREC is missing.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Indicates whether the patient resided in an institution for at least 90 days.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status_default": {"name": "enrollment_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_dual_status_default": {"name": "medicaid_dual_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec_default": {"name": "orec_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status_default": {"name": "institutional_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_members", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5172732, "relation_name": "cms_synthetic.cms_hcc._int_members", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n/*\nSteps for transforming eligibility data into member demographics:\n 1) Determine enrollment status using eligibility from the collection year.\n 2) Roll up to latest eligibility record for enrollment statuses.\n 3) Add age groups based on the payment year.\n 4) Determine other statuses.\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - CMS guidance: Age is calculated as of Feb 1 of the payment year.\n - The collection year is one year prior to the payment year.\n*/\n\n{% set payment_year = var('cms_hcc_payment_year') | int() -%}\n{% set payment_year_age_date = payment_year ~ '-02-01' -%}\n{% set collection_year = payment_year - 1 -%}\n{% set collection_year_start = \"'\" ~ collection_year ~ \"-01-01'\" %}\n{% set collection_year_end = \"'\" ~ payment_year ~ \"-12-31'\" %}\n\nwith stg_eligibility as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , row_number() over(\n partition by patient_id\n order by enrollment_end_date desc\n ) as row_num /* used to dedupe eligibility */\n from {{ ref('cms_hcc__stg_core__eligibility') }}\n where (\n /* Include members with any overlap in the collection or payment year */\n enrollment_start_date <= {{ collection_year_end }}\n and enrollment_end_date >= {{ collection_year_start }}\n )\n\n)\n\n, stg_patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , floor({{ datediff('birth_date', \"'\"~payment_year_age_date~\"'\", 'hour') }} / 8766.0) as payment_year_age\n , death_date\n from {{ ref('cms_hcc__stg_core__patient') }}\n\n)\n\n/* create proxy enrollment dates if outside of the collection year */\n, cap_collection_start_end_dates as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , case\n when enrollment_start_date < {{ try_to_cast_date(collection_year_start, 'YYYY-MM-DD') }}\n then {{ try_to_cast_date(collection_year_start, 'YYYY-MM-DD') }}\n else enrollment_start_date\n end as proxy_enrollment_start_date\n , case\n when enrollment_end_date > {{ try_to_cast_date(collection_year_end, 'YYYY-MM-DD') }}\n then {{ try_to_cast_date(collection_year_end, 'YYYY-MM-DD') }}\n else enrollment_end_date\n end as proxy_enrollment_end_date\n from stg_eligibility\n where (\n /* filter to members with eligibility in collection or payment year */\n {% if target.type == 'fabric' %}\n YEAR(enrollment_start_date)\n between {{ collection_year }}\n and {{ payment_year }}\n or YEAR(enrollment_end_date)\n between {{ collection_year }}\n and {{ payment_year }}\n {% else %}\n extract(year from enrollment_start_date)\n between {{ collection_year }}\n and {{ payment_year }}\n or extract(year from enrollment_end_date)\n between {{ collection_year }}\n and {{ payment_year }}\n {% endif %}\n )\n\n)\n\n, calculate_prior_coverage as (\n\n select patient_id\n , sum({{ datediff('proxy_enrollment_start_date', 'proxy_enrollment_end_date', 'month') }} + 1) as coverage_months /* include starting month */\n from cap_collection_start_end_dates\n group by patient_id\n\n)\n\n/*\n CMS guidance: A \u201cNew Enrollee\u201d status is when a beneficiary has less than\n 12 months of coverage prior to the payment year.\n*/\n, add_enrollment as (\n\n select\n patient_id\n , case\n when coverage_months < 12 then 'New'\n else 'Continuing'\n end as enrollment_status\n from calculate_prior_coverage\n\n)\n\n, latest_eligibility as (\n\n select\n stg_eligibility.patient_id\n , stg_patient.sex as gender\n , stg_patient.payment_year_age\n , stg_eligibility.original_reason_entitlement_code\n , stg_eligibility.dual_status_code\n , stg_eligibility.medicare_status_code\n /* Defaulting to \"New\" enrollment status when missing */\n , case\n when add_enrollment.enrollment_status is null then 'New'\n else add_enrollment.enrollment_status\n end as enrollment_status\n {% if target.type == 'fabric' %}\n , case\n when add_enrollment.enrollment_status is null then 1\n else 0\n end as enrollment_status_default\n {% else %}\n , case\n when add_enrollment.enrollment_status is null then TRUE\n else FALSE\n end as enrollment_status_default\n {% endif %}\n from stg_eligibility\n left join add_enrollment\n on stg_eligibility.patient_id = add_enrollment.patient_id\n left join stg_patient\n on stg_eligibility.patient_id = stg_patient.patient_id\n where stg_eligibility.row_num = 1\n\n)\n\n, add_age_group as (\n\n select\n patient_id\n , gender\n , payment_year_age\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , enrollment_status\n , enrollment_status_default\n , case\n when enrollment_status = 'Continuing' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'Continuing' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'Continuing' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'Continuing' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'Continuing' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'Continuing' and payment_year_age between 65 and 69 then '65-69'\n when enrollment_status = 'Continuing' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'Continuing' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'Continuing' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'Continuing' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'Continuing' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'Continuing' and payment_year_age >= 95 then '>=95'\n when enrollment_status = 'New' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'New' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'New' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'New' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'New' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'New' and payment_year_age = 65 then '65'\n when enrollment_status = 'New' and payment_year_age = 66 then '66'\n when enrollment_status = 'New' and payment_year_age = 67 then '67'\n when enrollment_status = 'New' and payment_year_age = 68 then '68'\n when enrollment_status = 'New' and payment_year_age = 69 then '69'\n when enrollment_status = 'New' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'New' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'New' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'New' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'New' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'New' and payment_year_age >= 95 then '>=95'\n end as age_group\n from latest_eligibility\n\n)\n\n, add_status_logic as (\n\n select\n patient_id\n , enrollment_status\n , case\n when gender = 'female' then 'Female'\n when gender = 'male' then 'Male'\n else null\n end as gender\n , age_group\n , case\n when dual_status_code in ('01','02','03','04','05','06','08') then 'Yes'\n else 'No'\n end as medicaid_status\n , case\n when dual_status_code in ('02','04','08') then 'Full'\n when dual_status_code in ('01','03','05','06') then 'Partial'\n else 'Non'\n end as dual_status\n /*\n The CMS-HCC model does not have factors for ESRD for these edge-cases,\n we default to 'Aged'. When OREC is missing, latest Medicare status is\n used, if available.\n */\n , case\n when original_reason_entitlement_code in ('0','2') then 'Aged'\n when original_reason_entitlement_code in ('1','3') then 'Disabled'\n when original_reason_entitlement_code is null and medicare_status_code in ('10','11','31') then 'Aged'\n when original_reason_entitlement_code is null and medicare_status_code in ('20','21') then 'Disabled'\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 'Aged'\n end as orec\n /* Defaulting everyone to non-institutional until logic is added */\n , cast('No' as {{ dbt.type_string() }}) as institutional_status\n , enrollment_status_default\n , case\n {% if target.type == 'fabric' %}\n when dual_status_code is null then 1\n else 0\n {% else %}\n when dual_status_code is null then TRUE\n else FALSE\n {% endif %}\n end as medicaid_dual_status_default\n /* Setting default true when OREC or Medicare Status is ESRD, or null */\n , case\n {% if target.type == 'fabric' %}\n when original_reason_entitlement_code in ('2') then 1\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then 1\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 1\n else 0\n {% else %}\n when original_reason_entitlement_code in ('2') then TRUE\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then TRUE\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then TRUE\n else FALSE\n {% endif %}\n end as orec_default\n /* Setting default true until institutional logic is added */\n {% if target.type == 'fabric' %}\n , 1 as institutional_status_default\n {% else %}\n , TRUE as institutional_status_default\n {% endif %}\n from add_age_group\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(enrollment_status as {{ dbt.type_string() }}) as enrollment_status\n , cast(gender as {{ dbt.type_string() }}) as gender\n , cast(age_group as {{ dbt.type_string() }}) as age_group\n , cast(medicaid_status as {{ dbt.type_string() }}) as medicaid_status\n , cast(dual_status as {{ dbt.type_string() }}) as dual_status\n , cast(orec as {{ dbt.type_string() }}) as orec\n , cast(institutional_status as {{ dbt.type_string() }}) as institutional_status\n {% if target.type == 'fabric' %}\n , cast(enrollment_status_default as bit) as enrollment_status_default\n , cast(medicaid_dual_status_default as bit) as medicaid_dual_status_default\n , cast(orec_default as bit) as orec_default\n , cast(institutional_status_default as bit) as institutional_status_default\n {% else %}\n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n {% endif %}\n , cast('{{ payment_year }}' as integer) as payment_year\n from add_status_logic\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__stg_core__eligibility", "package": null, "version": null}, {"name": "cms_hcc__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__stg_core__eligibility", "model.the_tuva_project.cms_hcc__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_members.sql", "compiled": true, "compiled_code": "\n/*\nSteps for transforming eligibility data into member demographics:\n 1) Determine enrollment status using eligibility from the collection year.\n 2) Roll up to latest eligibility record for enrollment statuses.\n 3) Add age groups based on the payment year.\n 4) Determine other statuses.\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - CMS guidance: Age is calculated as of Feb 1 of the payment year.\n - The collection year is one year prior to the payment year.\n*/\n\n\n\n\nwith __dbt__cte___stg_eligibility as (\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), stg_eligibility as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , row_number() over(\n partition by patient_id\n order by enrollment_end_date desc\n ) as row_num /* used to dedupe eligibility */\n from __dbt__cte___stg_eligibility\n where (\n /* Include members with any overlap in the collection or payment year */\n enrollment_start_date <= '2024-12-31'\n and enrollment_end_date >= '2023-01-01'\n )\n\n)\n\n, stg_patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , floor(datediff(\n hour,\n birth_date,\n '2024-02-01'\n ) / 8766.0) as payment_year_age\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n/* create proxy enrollment dates if outside of the collection year */\n, cap_collection_start_end_dates as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , case\n when enrollment_start_date < try_cast( '2023-01-01' as date )\n then try_cast( '2023-01-01' as date )\n else enrollment_start_date\n end as proxy_enrollment_start_date\n , case\n when enrollment_end_date > try_cast( '2024-12-31' as date )\n then try_cast( '2024-12-31' as date )\n else enrollment_end_date\n end as proxy_enrollment_end_date\n from stg_eligibility\n where (\n /* filter to members with eligibility in collection or payment year */\n \n extract(year from enrollment_start_date)\n between 2023\n and 2024\n or extract(year from enrollment_end_date)\n between 2023\n and 2024\n \n )\n\n)\n\n, calculate_prior_coverage as (\n\n select patient_id\n , sum(datediff(\n month,\n proxy_enrollment_start_date,\n proxy_enrollment_end_date\n ) + 1) as coverage_months /* include starting month */\n from cap_collection_start_end_dates\n group by patient_id\n\n)\n\n/*\n CMS guidance: A \u201cNew Enrollee\u201d status is when a beneficiary has less than\n 12 months of coverage prior to the payment year.\n*/\n, add_enrollment as (\n\n select\n patient_id\n , case\n when coverage_months < 12 then 'New'\n else 'Continuing'\n end as enrollment_status\n from calculate_prior_coverage\n\n)\n\n, latest_eligibility as (\n\n select\n stg_eligibility.patient_id\n , stg_patient.sex as gender\n , stg_patient.payment_year_age\n , stg_eligibility.original_reason_entitlement_code\n , stg_eligibility.dual_status_code\n , stg_eligibility.medicare_status_code\n /* Defaulting to \"New\" enrollment status when missing */\n , case\n when add_enrollment.enrollment_status is null then 'New'\n else add_enrollment.enrollment_status\n end as enrollment_status\n \n , case\n when add_enrollment.enrollment_status is null then TRUE\n else FALSE\n end as enrollment_status_default\n \n from stg_eligibility\n left join add_enrollment\n on stg_eligibility.patient_id = add_enrollment.patient_id\n left join stg_patient\n on stg_eligibility.patient_id = stg_patient.patient_id\n where stg_eligibility.row_num = 1\n\n)\n\n, add_age_group as (\n\n select\n patient_id\n , gender\n , payment_year_age\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , enrollment_status\n , enrollment_status_default\n , case\n when enrollment_status = 'Continuing' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'Continuing' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'Continuing' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'Continuing' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'Continuing' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'Continuing' and payment_year_age between 65 and 69 then '65-69'\n when enrollment_status = 'Continuing' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'Continuing' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'Continuing' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'Continuing' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'Continuing' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'Continuing' and payment_year_age >= 95 then '>=95'\n when enrollment_status = 'New' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'New' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'New' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'New' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'New' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'New' and payment_year_age = 65 then '65'\n when enrollment_status = 'New' and payment_year_age = 66 then '66'\n when enrollment_status = 'New' and payment_year_age = 67 then '67'\n when enrollment_status = 'New' and payment_year_age = 68 then '68'\n when enrollment_status = 'New' and payment_year_age = 69 then '69'\n when enrollment_status = 'New' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'New' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'New' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'New' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'New' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'New' and payment_year_age >= 95 then '>=95'\n end as age_group\n from latest_eligibility\n\n)\n\n, add_status_logic as (\n\n select\n patient_id\n , enrollment_status\n , case\n when gender = 'female' then 'Female'\n when gender = 'male' then 'Male'\n else null\n end as gender\n , age_group\n , case\n when dual_status_code in ('01','02','03','04','05','06','08') then 'Yes'\n else 'No'\n end as medicaid_status\n , case\n when dual_status_code in ('02','04','08') then 'Full'\n when dual_status_code in ('01','03','05','06') then 'Partial'\n else 'Non'\n end as dual_status\n /*\n The CMS-HCC model does not have factors for ESRD for these edge-cases,\n we default to 'Aged'. When OREC is missing, latest Medicare status is\n used, if available.\n */\n , case\n when original_reason_entitlement_code in ('0','2') then 'Aged'\n when original_reason_entitlement_code in ('1','3') then 'Disabled'\n when original_reason_entitlement_code is null and medicare_status_code in ('10','11','31') then 'Aged'\n when original_reason_entitlement_code is null and medicare_status_code in ('20','21') then 'Disabled'\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 'Aged'\n end as orec\n /* Defaulting everyone to non-institutional until logic is added */\n , cast('No' as TEXT) as institutional_status\n , enrollment_status_default\n , case\n \n when dual_status_code is null then TRUE\n else FALSE\n \n end as medicaid_dual_status_default\n /* Setting default true when OREC or Medicare Status is ESRD, or null */\n , case\n \n when original_reason_entitlement_code in ('2') then TRUE\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then TRUE\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then TRUE\n else FALSE\n \n end as orec_default\n /* Setting default true until institutional logic is added */\n \n , TRUE as institutional_status_default\n \n from add_age_group\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast('2024' as integer) as payment_year\n from add_status_logic\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_hcc__stg_core__eligibility", "sql": " __dbt__cte___stg_eligibility as (\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility\n)"}, {"id": "model.the_tuva_project.cms_hcc__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__int_enrollment_interaction_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc/intermediate/cms_hcc__int_enrollment_interaction_factors.sql", "original_file_path": "models/cms_hcc/intermediate/cms_hcc__int_enrollment_interaction_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_enrollment_interaction_factors"], "alias": "_int_enrollment_interaction_factors", "checksum": {"name": "sha256", "checksum": "628c8c0c557439f426c05e149e4ff3ae0438a27cad6600799f70a4222c610314"}, "config": {"enabled": true, "alias": "_int_enrollment_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Enrollment interaction factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the enrollment interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/cms_hcc/cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_enrollment_interaction_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5093918, "relation_name": "cms_synthetic.cms_hcc._int_enrollment_interaction_factors", "raw_code": "{{ config(\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from {{ ref('cms_hcc__int_demographic_factors') }}\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , gender\n , enrollment_status\n , medicaid_status\n , dual_status\n , institutional_status\n , description\n , coefficient\n from {{ ref('cms_hcc__enrollment_interaction_factors') }}\n\n)\n\n/*\n Originally disabled interactions for non-institutional members >= 65\n*/\n, non_institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.gender = seed_interaction_factors.gender\n and demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.medicaid_status = seed_interaction_factors.medicaid_status\n and demographics.dual_status = seed_interaction_factors.dual_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'No'\n and demographics.orec = 'Disabled'\n and demographics.age_group in (\n '65-69'\n , '70-74'\n , '75-79'\n , '80-84'\n , '85-89'\n , '90-94'\n , '>=95'\n )\n\n)\n\n/*\n Medicaid interactions for institutional members\n*/\n, institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'Yes'\n and demographics.medicaid_status = 'Yes'\n\n)\n\n, unioned as (\n\n select * from non_institutional_interactions\n union all\n select * from institutional_interactions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(description as {{ dbt.type_string() }}) as description\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\n , cast(model_version as {{ dbt.type_string() }}) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__enrollment_interaction_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/intermediate/cms_hcc__int_enrollment_interaction_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , gender\n , enrollment_status\n , medicaid_status\n , dual_status\n , institutional_status\n , description\n , coefficient\n from cms_synthetic.cms_hcc._value_set_enrollment_interaction_factors\n\n)\n\n/*\n Originally disabled interactions for non-institutional members >= 65\n*/\n, non_institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.gender = seed_interaction_factors.gender\n and demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.medicaid_status = seed_interaction_factors.medicaid_status\n and demographics.dual_status = seed_interaction_factors.dual_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'No'\n and demographics.orec = 'Disabled'\n and demographics.age_group in (\n '65-69'\n , '70-74'\n , '75-79'\n , '80-84'\n , '85-89'\n , '90-94'\n , '>=95'\n )\n\n)\n\n/*\n Medicaid interactions for institutional members\n*/\n, institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'Yes'\n and demographics.medicaid_status = 'Yes'\n\n)\n\n, unioned as (\n\n select * from non_institutional_interactions\n union all\n select * from institutional_interactions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__stg_medical_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalized_input__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/staging/normalized_input__stg_medical_claim.sql", "original_file_path": "models/claims_preprocessing/normalized_input/staging/normalized_input__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__stg_medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "staging", "normalized_input__stg_medical_claim"], "alias": "normalized_input__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "19ce2734bd48a3785804040dedeecdb07426fef753d0dac5fe9135fda4837854"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"materialized": "ephemeral", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.593996, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , {{ quote_column('plan') }}\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom {{ ref('medical_claim') }}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/staging/normalized_input__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__stg_pharmacy_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalized_input__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/staging/normalized_input__stg_pharmacy_claim.sql", "original_file_path": "models/claims_preprocessing/normalized_input/staging/normalized_input__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__stg_pharmacy_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "staging", "normalized_input__stg_pharmacy_claim"], "alias": "normalized_input__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "d11e1cb49987782bf02bdd91975f39d807508cf2095ad94b7d6b1d0ce7538858"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"materialized": "ephemeral", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.594806, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , {{ quote_column('plan') }}\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom {{ ref('pharmacy_claim') }}", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/staging/normalized_input__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__stg_eligibility": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalized_input__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/staging/normalized_input__stg_eligibility.sql", "original_file_path": "models/claims_preprocessing/normalized_input/staging/normalized_input__stg_eligibility.sql", "unique_id": "model.the_tuva_project.normalized_input__stg_eligibility", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "staging", "normalized_input__stg_eligibility"], "alias": "normalized_input__stg_eligibility", "checksum": {"name": "sha256", "checksum": "8d9923673a9f6bfbe26687be69e11cf00110ae5edeec6adf71260a41cf7c9cbc"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"materialized": "ephemeral", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.593264, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n patient_id\n , {{ dbt.concat([\n \"patient_id\",\n \"coalesce(data_source,'')\",\n \"coalesce(payer,'')\",\n \"coalesce(\" ~ quote_column('plan') ~ \",'')\",\n \"coalesce(cast(enrollment_start_date as \" ~ dbt.type_string() ~ \"),'')\",\n \"coalesce(cast(enrollment_end_date as \" ~ dbt.type_string() ~ \"),'')\"\n ]) }} as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , {{ quote_column('plan') }}\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom {{ ref('eligibility') }}", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/staging/normalized_input__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__eligibility": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/final/normalized_input__eligibility.sql", "original_file_path": "models/claims_preprocessing/normalized_input/final/normalized_input__eligibility.sql", "unique_id": "model.the_tuva_project.normalized_input__eligibility", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "final", "normalized_input__eligibility"], "alias": "normalized_input_eligibility", "checksum": {"name": "sha256", "checksum": "1a6a9c41e6b0c516dadbb1acf000ad4b4d7774ced9458f44b1d83c51790f3318"}, "config": {"enabled": true, "alias": "normalized_input_eligibility", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "The eligibility table contains information on patient health plan and \nsupplemental insurance eligibility.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_id": {"name": "subscriber_id", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Biological sex of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "Race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "Date the patient was born.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "Flag indicating if the patient is deceased", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_type": {"name": "payer_type", "description": "Type of payer (e.g. commercial, medicare, medicaid, etc.).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__payer_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "Original reason for Medicare entitlement code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "Patient's first name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Patient's last name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "Patient's social security number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_relation": {"name": "subscriber_relation", "description": "Relationship to the policy holder (self, spouse, dependent, etc)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "Patient's street address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "Patient's city of address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "State the patient lives in (most recent known address)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "Zip code the patient lives in (most recent known address).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "phone": {"name": "phone", "description": "Patient's phone number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "normalized_input_eligibility", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.536696, "relation_name": "cms_synthetic.claims_preprocessing.normalized_input_eligibility", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n cast(elig.patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(elig.member_id as {{ dbt.type_string() }} ) as member_id\n , cast(elig.subscriber_id as {{ dbt.type_string() }} ) as subscriber_id\n , cast(elig.gender as {{ dbt.type_string() }} ) as gender\n , cast(elig.race as {{ dbt.type_string() }} ) as race\n , cast(date_norm.normalized_birth_date as date ) as birth_date\n , cast(date_norm.normalized_death_date as date ) as death_date\n , cast(elig.death_flag as int ) as death_flag\n , cast(date_norm.normalized_enrollment_start_date as date ) as enrollment_start_date\n , cast(date_norm.normalized_enrollment_end_date as date ) as enrollment_end_date\n , cast(elig.payer as {{ dbt.type_string() }} ) as payer\n , cast(elig.payer_type as {{ dbt.type_string() }} ) as payer_type\n , cast(elig.{{ quote_column('plan') }} as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\n , cast(elig.original_reason_entitlement_code as {{ dbt.type_string() }} ) as original_reason_entitlement_code\n , cast(elig.dual_status_code as {{ dbt.type_string() }} ) as dual_status_code\n , cast(elig.medicare_status_code as {{ dbt.type_string() }} ) as medicare_status_code\n , cast(elig.first_name as {{ dbt.type_string() }} ) as first_name\n , cast(elig.last_name as {{ dbt.type_string() }} ) as last_name\n , cast(elig.social_security_number as {{ dbt.type_string() }} ) as social_security_number\n , cast(elig.subscriber_relation as {{ dbt.type_string() }} ) as subscriber_relation\n , cast(elig.address as {{ dbt.type_string() }} ) as address\n , cast(elig.city as {{ dbt.type_string() }} ) as city\n , cast(elig.state as {{ dbt.type_string() }} ) as state\n , cast(elig.zip_code as {{ dbt.type_string() }} ) as zip_code\n , cast(elig.phone as {{ dbt.type_string() }} ) as phone\n , cast(elig.data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_string() }} ) as tuva_last_run\nfrom {{ ref('normalized_input__stg_eligibility') }} elig\nleft join {{ ref('normalized_input__int_eligibility_dates_normalize') }} date_norm\n on elig.patient_id_key = date_norm.patient_id_key", "language": "sql", "refs": [{"name": "normalized_input__stg_eligibility", "package": null, "version": null}, {"name": "normalized_input__int_eligibility_dates_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.normalized_input__stg_eligibility", "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/final/normalized_input__eligibility.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select\n cast(elig.patient_id as TEXT ) as patient_id\n , cast(elig.member_id as TEXT ) as member_id\n , cast(elig.subscriber_id as TEXT ) as subscriber_id\n , cast(elig.gender as TEXT ) as gender\n , cast(elig.race as TEXT ) as race\n , cast(date_norm.normalized_birth_date as date ) as birth_date\n , cast(date_norm.normalized_death_date as date ) as death_date\n , cast(elig.death_flag as int ) as death_flag\n , cast(date_norm.normalized_enrollment_start_date as date ) as enrollment_start_date\n , cast(date_norm.normalized_enrollment_end_date as date ) as enrollment_end_date\n , cast(elig.payer as TEXT ) as payer\n , cast(elig.payer_type as TEXT ) as payer_type\n , cast(elig.plan as TEXT ) as plan\n , cast(elig.original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(elig.dual_status_code as TEXT ) as dual_status_code\n , cast(elig.medicare_status_code as TEXT ) as medicare_status_code\n , cast(elig.first_name as TEXT ) as first_name\n , cast(elig.last_name as TEXT ) as last_name\n , cast(elig.social_security_number as TEXT ) as social_security_number\n , cast(elig.subscriber_relation as TEXT ) as subscriber_relation\n , cast(elig.address as TEXT ) as address\n , cast(elig.city as TEXT ) as city\n , cast(elig.state as TEXT ) as state\n , cast(elig.zip_code as TEXT ) as zip_code\n , cast(elig.phone as TEXT ) as phone\n , cast(elig.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_eligibility_dates_normalize date_norm\n on elig.patient_id_key = date_norm.patient_id_key", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_eligibility", "sql": " __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__pharmacy_claim": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/final/normalized_input__pharmacy_claim.sql", "original_file_path": "models/claims_preprocessing/normalized_input/final/normalized_input__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__pharmacy_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "final", "normalized_input__pharmacy_claim"], "alias": "normalized_input_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "85d38183b494b1a7b13a193415e1df0ce9ffe6999d89368dacf50fb4ec2d6d0c"}, "config": {"enabled": true, "alias": "normalized_input_pharmacy_claim", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "The pharmacy claim table contains information on prescription drugs that \nwere filled and billed to the insurer.\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_npi": {"name": "prescribing_provider_npi", "description": "NPI for the provider that wrote the prescription (e.g. priamry care physician).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_npi": {"name": "dispensing_provider_npi", "description": "NPI for the provider that dispensed the prescription (e.g. pharmacy).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "Number of doses.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days supply.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the prescription.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "Date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid by the health insurer for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "Contractual amount allowed to be paid by the payer + patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "normalized_input_pharmacy_claim", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.544323, "relation_name": "cms_synthetic.claims_preprocessing.normalized_input_pharmacy_claim", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n cast(claim_id as {{ dbt.type_string() }} ) as claim_id\n , cast(claim_line_number as int ) as claim_line_number\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(member_id as {{ dbt.type_string() }} ) as member_id\n , cast(payer as {{ dbt.type_string() }} ) as payer\n , cast({{ quote_column('plan') }} as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\n , cast(prescribing_provider_npi as {{ dbt.type_string() }} ) as prescribing_provider_id\n , cast(coalesce({{ dbt.concat([\"pres.provider_last_name\", \"', '\", \"pres.provider_first_name\"]) }}, pres.provider_organization_name) as {{ dbt.type_string() }} ) as prescribing_provider_name\n , cast(dispensing_provider_npi as {{ dbt.type_string() }} ) as dispensing_provider_id\n , cast(coalesce({{ dbt.concat([\"disp.provider_last_name\", \"', '\", \"disp.provider_first_name\"]) }}, disp.provider_organization_name) as {{ dbt.type_string() }} ) as dispensing_provider_name , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as {{ dbt.type_string() }} ) as ndc_code\n , cast(ndc.fda_description as {{ dbt.type_string() }} ) as ndc_description\n , cast(quantity as int ) as quantity\n , cast(days_supply as int ) as days_supply\n , cast(refills as int ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\n , cast(allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\n , cast(charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\n , cast(coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\n , cast(copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\n , cast(deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_string() }} ) as tuva_last_run\nfrom {{ ref('normalized_input__stg_pharmacy_claim') }} pharm\nleft join {{ ref('terminology__provider') }} pres\n on pharm.prescribing_provider_npi = pres.npi\nleft join {{ ref('terminology__provider') }} disp\n on pharm.dispensing_provider_npi = disp.npi\nleft join {{ ref('terminology__ndc') }} ndc\n on pharm.ndc_code = ndc.ndc", "language": "sql", "refs": [{"name": "normalized_input__stg_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.normalized_input__stg_pharmacy_claim", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/final/normalized_input__pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_pharmacy_claim as (\n\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim\n) select\n cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as int ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , cast(plan as TEXT ) as plan\n , cast(prescribing_provider_npi as TEXT ) as prescribing_provider_id\n , cast(coalesce(pres.provider_last_name || ', ' || pres.provider_first_name, pres.provider_organization_name) as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_npi as TEXT ) as dispensing_provider_id\n , cast(coalesce(disp.provider_last_name || ', ' || disp.provider_first_name, disp.provider_organization_name) as TEXT ) as dispensing_provider_name , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc.fda_description as TEXT ) as ndc_description\n , cast(quantity as int ) as quantity\n , cast(days_supply as int ) as days_supply\n , cast(refills as int ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_pharmacy_claim pharm\nleft join cms_synthetic.terminology.provider pres\n on pharm.prescribing_provider_npi = pres.npi\nleft join cms_synthetic.terminology.provider disp\n on pharm.dispensing_provider_npi = disp.npi\nleft join cms_synthetic.terminology.ndc ndc\n on pharm.ndc_code = ndc.ndc", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_pharmacy_claim", "sql": " __dbt__cte__normalized_input__stg_pharmacy_claim as (\n\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__medical_claim": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/final/normalized_input__medical_claim.sql", "original_file_path": "models/claims_preprocessing/normalized_input/final/normalized_input__medical_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "final", "normalized_input__medical_claim"], "alias": "normalized_input_medical_claim", "checksum": {"name": "sha256", "checksum": "0e8d188e57f74e5cfb32872a8957ae68c7cd126c9802ff6867d602e491e31827"}, "config": {"enabled": true, "alias": "normalized_input_medical_claim", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "The medical claim table contains information on services rendered to \npatients and billed by the provider to the insurer as claims.\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__claim_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "Start date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_start_date": {"name": "claim_line_start_date", "description": "Start date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_end_date": {"name": "claim_line_end_date", "description": "End date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "Admission date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Discharge date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Place of service for the claim (professional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__place_of_service.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__bill_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code for the claim line (institutional only and typically multiple codes per claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__revenue_center.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_unit_quantity": {"name": "service_unit_quantity", "description": "The number of units for the particular revenue center code.", "meta": {}, "data_type": "float", "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "HCPCS level 1 or level 2 code for the claim line.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "1st modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "2nd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "3rd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "4th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "5th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_npi": {"name": "rendering_npi", "description": "Rendering NPI for the claim (typically represents the physician or entity providing services).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_npi": {"name": "billing_npi", "description": "Billing NPI for the claim (typically represents organization billing the claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid on the claim by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient) on the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_cost_amount": {"name": "total_cost_amount", "description": "The total amount paid on the claim by different parties.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_type": {"name": "diagnosis_code_type", "description": "Indicates the type of diagnosis code (e.g. ICD-10-CM).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_1": {"name": "diagnosis_code_1", "description": "1st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_2": {"name": "diagnosis_code_2", "description": "2nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_3": {"name": "diagnosis_code_3", "description": "3rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_4": {"name": "diagnosis_code_4", "description": "4th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_5": {"name": "diagnosis_code_5", "description": "5th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_6": {"name": "diagnosis_code_6", "description": "6th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_7": {"name": "diagnosis_code_7", "description": "7th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_8": {"name": "diagnosis_code_8", "description": "8th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_9": {"name": "diagnosis_code_9", "description": "9th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_10": {"name": "diagnosis_code_10", "description": "10th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_11": {"name": "diagnosis_code_11", "description": "11th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_12": {"name": "diagnosis_code_12", "description": "12th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_13": {"name": "diagnosis_code_13", "description": "13th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_14": {"name": "diagnosis_code_14", "description": "14th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_15": {"name": "diagnosis_code_15", "description": "15th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_16": {"name": "diagnosis_code_16", "description": "16th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_17": {"name": "diagnosis_code_17", "description": "17th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_18": {"name": "diagnosis_code_18", "description": "18th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_19": {"name": "diagnosis_code_19", "description": "19th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_20": {"name": "diagnosis_code_20", "description": "20th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_21": {"name": "diagnosis_code_21", "description": "21st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_22": {"name": "diagnosis_code_22", "description": "22nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_23": {"name": "diagnosis_code_23", "description": "23rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_24": {"name": "diagnosis_code_24", "description": "24th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_25": {"name": "diagnosis_code_25", "description": "25th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_1": {"name": "diagnosis_poa_1", "description": "Present on admission code for the 1st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_2": {"name": "diagnosis_poa_2", "description": "Present on admission code for the 2nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_3": {"name": "diagnosis_poa_3", "description": "Present on admission code for the 3rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_4": {"name": "diagnosis_poa_4", "description": "Present on admission code for the 4th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_5": {"name": "diagnosis_poa_5", "description": "Present on admission code for the 5th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_6": {"name": "diagnosis_poa_6", "description": "Present on admission code for the 6th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_7": {"name": "diagnosis_poa_7", "description": "Present on admission code for the 7th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_8": {"name": "diagnosis_poa_8", "description": "Present on admission code for the 8th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_9": {"name": "diagnosis_poa_9", "description": "Present on admission code for the 9th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_10": {"name": "diagnosis_poa_10", "description": "Present on admission code for the 10th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_11": {"name": "diagnosis_poa_11", "description": "Present on admission code for the 11th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_12": {"name": "diagnosis_poa_12", "description": "Present on admission code for the 12th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_13": {"name": "diagnosis_poa_13", "description": "Present on admission code for the 13th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_14": {"name": "diagnosis_poa_14", "description": "Present on admission code for the 14th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_15": {"name": "diagnosis_poa_15", "description": "Present on admission code for the 15th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_16": {"name": "diagnosis_poa_16", "description": "Present on admission code for the 16th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_17": {"name": "diagnosis_poa_17", "description": "Present on admission code for the 17th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_18": {"name": "diagnosis_poa_18", "description": "Present on admission code for the 18th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_19": {"name": "diagnosis_poa_19", "description": "Present on admission code for the 19th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_20": {"name": "diagnosis_poa_20", "description": "Present on admission code for the 20th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_21": {"name": "diagnosis_poa_21", "description": "Present on admission code for the 21st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_22": {"name": "diagnosis_poa_22", "description": "Present on admission code for the 22nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_23": {"name": "diagnosis_poa_23", "description": "Present on admission code for the 23rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_24": {"name": "diagnosis_poa_24", "description": "Present on admission code for the 24th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_25": {"name": "diagnosis_poa_25", "description": "Present on admission code for the 25th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_type": {"name": "procedure_code_type", "description": "Indicates the type of procedure code (e.g. ICD-10-PCS).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_1": {"name": "procedure_code_1", "description": "1st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_2": {"name": "procedure_code_2", "description": "2nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_3": {"name": "procedure_code_3", "description": "3rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_4": {"name": "procedure_code_4", "description": "4th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_5": {"name": "procedure_code_5", "description": "5th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_6": {"name": "procedure_code_6", "description": "6th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_7": {"name": "procedure_code_7", "description": "7th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_8": {"name": "procedure_code_8", "description": "8th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_9": {"name": "procedure_code_9", "description": "9th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_10": {"name": "procedure_code_10", "description": "10th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_11": {"name": "procedure_code_11", "description": "11th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_12": {"name": "procedure_code_12", "description": "12th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_13": {"name": "procedure_code_13", "description": "13th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_14": {"name": "procedure_code_14", "description": "14th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_15": {"name": "procedure_code_15", "description": "15th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_16": {"name": "procedure_code_16", "description": "16th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_17": {"name": "procedure_code_17", "description": "17th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_18": {"name": "procedure_code_18", "description": "18th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_19": {"name": "procedure_code_19", "description": "19th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_20": {"name": "procedure_code_20", "description": "20th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_21": {"name": "procedure_code_21", "description": "21st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_22": {"name": "procedure_code_22", "description": "22nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_23": {"name": "procedure_code_23", "description": "23rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_24": {"name": "procedure_code_24", "description": "24th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_25": {"name": "procedure_code_25", "description": "25th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_1": {"name": "procedure_date_1", "description": "Date of the 1st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_2": {"name": "procedure_date_2", "description": "Date of the 2nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_3": {"name": "procedure_date_3", "description": "Date of the 3rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_4": {"name": "procedure_date_4", "description": "Date of the 4th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_5": {"name": "procedure_date_5", "description": "Date of the 5th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_6": {"name": "procedure_date_6", "description": "Date of the 6th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_7": {"name": "procedure_date_7", "description": "Date of the 7th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_8": {"name": "procedure_date_8", "description": "Date of the 8th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_9": {"name": "procedure_date_9", "description": "Date of the 9th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_10": {"name": "procedure_date_10", "description": "Date of the 10th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_11": {"name": "procedure_date_11", "description": "Date of the 11th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_12": {"name": "procedure_date_12", "description": "Date of the 12th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_13": {"name": "procedure_date_13", "description": "Date of the 13th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_14": {"name": "procedure_date_14", "description": "Date of the 14th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_15": {"name": "procedure_date_15", "description": "Date of the 15th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_16": {"name": "procedure_date_16", "description": "Date of the 16th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_17": {"name": "procedure_date_17", "description": "Date of the 17th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_18": {"name": "procedure_date_18", "description": "Date of the 18th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_19": {"name": "procedure_date_19", "description": "Date of the 19th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_20": {"name": "procedure_date_20", "description": "Date of the 20th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_21": {"name": "procedure_date_21", "description": "Date of the 21st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_22": {"name": "procedure_date_22", "description": "Date of the 22nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_23": {"name": "procedure_date_23", "description": "Date of the 23rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_24": {"name": "procedure_date_24", "description": "Date of the 24th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_25": {"name": "procedure_date_25", "description": "Date of the 25th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "normalized_input_medical_claim", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5420868, "relation_name": "cms_synthetic.claims_preprocessing.normalized_input_medical_claim", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n\tcast(med.claim_id as {{ dbt.type_string() }} ) as claim_id\n\t, cast(med.claim_line_number as int ) as claim_line_number\n\t, cast(med.claim_type as {{ dbt.type_string() }} ) as claim_type\n\t, cast(med.patient_id as {{ dbt.type_string() }} ) as patient_id\n\t, cast(med.member_id as {{ dbt.type_string() }} ) as member_id\n\t, cast(med.payer as {{ dbt.type_string() }} ) as payer\n , cast(med.{{ quote_column('plan') }} as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\n\t, cast(coalesce(dates.minimum_claim_start_date, undetermined.claim_start_date) as date ) as claim_start_date\n\t, cast(coalesce(dates.maximum_claim_end_date, undetermined.claim_start_date) as date ) as claim_end_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_start_date, undetermined.claim_line_start_date) as date ) as claim_line_start_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_end_date, undetermined.claim_line_end_date) as date ) as claim_line_end_date\n\t, cast(coalesce(dates.minimum_admission_date, undetermined.admission_date) as date ) as admission_date\n\t, cast(coalesce(dates.maximum_discharge_date, undetermined.discharge_date) as date ) as discharge_date\n\t, cast(coalesce(ad_source.normalized_code, undetermined.admit_source_code) as {{ dbt.type_string() }} ) as admit_source_code\n , cast(coalesce(ad_source.normalized_description, undetermined.admit_source_description) as {{ dbt.type_string() }} ) as admit_source_description\n\t, cast(coalesce(ad_type.normalized_code, undetermined.admit_type_code) as {{ dbt.type_string() }} ) as admit_type_code\n , cast(coalesce(ad_type.normalized_description, undetermined.admit_type_description) as {{ dbt.type_string() }} ) as admit_type_description\n\t, cast(coalesce(disch_disp.normalized_code, undetermined.discharge_disposition_code) as {{ dbt.type_string() }} ) as discharge_disposition_code\n , cast(coalesce(disch_disp.normalized_description, undetermined.discharge_disposition_description) as {{ dbt.type_string() }} ) as discharge_disposition_description\n\t, cast(coalesce(pos.normalized_code, undetermined.place_of_service_code) as {{ dbt.type_string() }} ) as place_of_service_code\n , cast(coalesce(pos.normalized_description, undetermined.place_of_service_description) as {{ dbt.type_string() }} ) as place_of_service_description\n\t, cast(coalesce(bill.normalized_code, undetermined.bill_type_code) as {{ dbt.type_string() }} ) as bill_type_code\n , cast(coalesce(bill.normalized_description, undetermined.bill_type_description) as {{ dbt.type_string() }} ) as bill_type_description\n\t, cast(coalesce(ms.normalized_code, undetermined.ms_drg_code) as {{ dbt.type_string() }} ) as ms_drg_code\n , cast(coalesce(ms.normalized_description, undetermined.ms_drg_description) as {{ dbt.type_string() }} ) as ms_drg_description\n\t, cast(coalesce(apr.normalized_code, undetermined.apr_drg_code) as {{ dbt.type_string() }} ) as apr_drg_code\n , cast(coalesce(apr.normalized_description, undetermined.apr_drg_description) as {{ dbt.type_string() }} ) as apr_drg_description\n\t, cast(coalesce(rev.normalized_code, undetermined.revenue_center_code) as {{ dbt.type_string() }} ) as revenue_center_code\n , cast(coalesce(rev.normalized_description, undetermined.revenue_center_description) as {{ dbt.type_string() }} ) as revenue_center_description\n\t, cast(med.service_unit_quantity as {{ dbt.type_string() }} ) as service_unit_quantity\n\t, cast(med.hcpcs_code as {{ dbt.type_string() }} ) as hcpcs_code\n\t, cast(med.hcpcs_modifier_1 as {{ dbt.type_string() }} ) as hcpcs_modifier_1\n\t, cast(med.hcpcs_modifier_2 as {{ dbt.type_string() }} ) as hcpcs_modifier_2\n\t, cast(med.hcpcs_modifier_3 as {{ dbt.type_string() }} ) as hcpcs_modifier_3\n\t, cast(med.hcpcs_modifier_4 as {{ dbt.type_string() }} ) as hcpcs_modifier_4\n\t, cast(med.hcpcs_modifier_5 as {{ dbt.type_string() }} ) as hcpcs_modifier_5\n\t, cast(coalesce(med_npi.normalized_rendering_npi, undetermined.rendering_npi) as {{ dbt.type_string() }} ) as rendering_id\n , cast(med.rendering_tin as {{ dbt.type_string() }} ) as rendering_tin\n , cast(coalesce(med_npi.normalized_rendering_name, undetermined.rendering_name) as {{ dbt.type_string() }} ) as rendering_name\n\t, cast(coalesce(med_npi.normalized_billing_npi, undetermined.billing_npi) as {{ dbt.type_string() }} ) as billing_id\n , cast(med.billing_tin as {{ dbt.type_string() }} ) as billing_tin\n , cast(coalesce(med_npi.normalized_billing_name, undetermined.billing_name) as {{ dbt.type_string() }} ) as billing_name\n\t, cast(coalesce(med_npi.normalized_facility_npi, undetermined.facility_npi) as {{ dbt.type_string() }} ) as facility_id\n\t, cast(coalesce(med_npi.normalized_facility_name, undetermined.facility_name) as {{ dbt.type_string() }} ) as facility_name\n , cast(med.paid_date as date ) as paid_date\n\t, cast(med.paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\n\t, cast(med.allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\n\t, cast(med.charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\n\t, cast(med.coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\n\t, cast(med.copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\n\t, cast(med.deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\n\t, cast(med.total_cost_amount as {{ dbt.type_numeric() }} ) as total_cost_amount\n\t, cast(med.diagnosis_code_type as {{ dbt.type_string() }} ) as diagnosis_code_type\n\t, cast(coalesce(dx_code.diagnosis_code_1, undetermined.diagnosis_code_1) as {{ dbt.type_string() }} ) as diagnosis_code_1\n\t, cast(coalesce(dx_code.diagnosis_code_2, undetermined.diagnosis_code_2) as {{ dbt.type_string() }} ) as diagnosis_code_2\n\t, cast(coalesce(dx_code.diagnosis_code_3, undetermined.diagnosis_code_3) as {{ dbt.type_string() }} ) as diagnosis_code_3\n\t, cast(coalesce(dx_code.diagnosis_code_4, undetermined.diagnosis_code_4) as {{ dbt.type_string() }} ) as diagnosis_code_4\n\t, cast(coalesce(dx_code.diagnosis_code_5, undetermined.diagnosis_code_5) as {{ dbt.type_string() }} ) as diagnosis_code_5\n\t, cast(coalesce(dx_code.diagnosis_code_6, undetermined.diagnosis_code_6) as {{ dbt.type_string() }} ) as diagnosis_code_6\n\t, cast(coalesce(dx_code.diagnosis_code_7, undetermined.diagnosis_code_7) as {{ dbt.type_string() }} ) as diagnosis_code_7\n\t, cast(coalesce(dx_code.diagnosis_code_8, undetermined.diagnosis_code_8) as {{ dbt.type_string() }} ) as diagnosis_code_8\n\t, cast(coalesce(dx_code.diagnosis_code_9, undetermined.diagnosis_code_9) as {{ dbt.type_string() }} ) as diagnosis_code_9\n\t, cast(coalesce(dx_code.diagnosis_code_10, undetermined.diagnosis_code_10) as {{ dbt.type_string() }} ) as diagnosis_code_10\n\t, cast(coalesce(dx_code.diagnosis_code_11, undetermined.diagnosis_code_11) as {{ dbt.type_string() }} ) as diagnosis_code_11\n\t, cast(coalesce(dx_code.diagnosis_code_12, undetermined.diagnosis_code_12) as {{ dbt.type_string() }} ) as diagnosis_code_12\n\t, cast(coalesce(dx_code.diagnosis_code_13, undetermined.diagnosis_code_13) as {{ dbt.type_string() }} ) as diagnosis_code_13\n\t, cast(coalesce(dx_code.diagnosis_code_14, undetermined.diagnosis_code_14) as {{ dbt.type_string() }} ) as diagnosis_code_14\n\t, cast(coalesce(dx_code.diagnosis_code_15, undetermined.diagnosis_code_15) as {{ dbt.type_string() }} ) as diagnosis_code_15\n\t, cast(coalesce(dx_code.diagnosis_code_16, undetermined.diagnosis_code_16) as {{ dbt.type_string() }} ) as diagnosis_code_16\n\t, cast(coalesce(dx_code.diagnosis_code_17, undetermined.diagnosis_code_17) as {{ dbt.type_string() }} ) as diagnosis_code_17\n\t, cast(coalesce(dx_code.diagnosis_code_18, undetermined.diagnosis_code_18) as {{ dbt.type_string() }} ) as diagnosis_code_18\n\t, cast(coalesce(dx_code.diagnosis_code_19, undetermined.diagnosis_code_19) as {{ dbt.type_string() }} ) as diagnosis_code_19\n\t, cast(coalesce(dx_code.diagnosis_code_20, undetermined.diagnosis_code_20) as {{ dbt.type_string() }} ) as diagnosis_code_20\n\t, cast(coalesce(dx_code.diagnosis_code_21, undetermined.diagnosis_code_21) as {{ dbt.type_string() }} ) as diagnosis_code_21\n\t, cast(coalesce(dx_code.diagnosis_code_22, undetermined.diagnosis_code_22) as {{ dbt.type_string() }} ) as diagnosis_code_22\n\t, cast(coalesce(dx_code.diagnosis_code_23, undetermined.diagnosis_code_23) as {{ dbt.type_string() }} ) as diagnosis_code_23\n\t, cast(coalesce(dx_code.diagnosis_code_24, undetermined.diagnosis_code_24) as {{ dbt.type_string() }} ) as diagnosis_code_24\n\t, cast(coalesce(dx_code.diagnosis_code_25, undetermined.diagnosis_code_25) as {{ dbt.type_string() }} ) as diagnosis_code_25\n\t, cast(coalesce(poa.diagnosis_poa_1, undetermined.diagnosis_poa_1) as {{ dbt.type_string() }} ) as diagnosis_poa_1\n\t, cast(coalesce(poa.diagnosis_poa_2, undetermined.diagnosis_poa_2) as {{ dbt.type_string() }} ) as diagnosis_poa_2\n\t, cast(coalesce(poa.diagnosis_poa_3, undetermined.diagnosis_poa_3) as {{ dbt.type_string() }} ) as diagnosis_poa_3\n\t, cast(coalesce(poa.diagnosis_poa_4, undetermined.diagnosis_poa_4) as {{ dbt.type_string() }} ) as diagnosis_poa_4\n\t, cast(coalesce(poa.diagnosis_poa_5, undetermined.diagnosis_poa_5) as {{ dbt.type_string() }} ) as diagnosis_poa_5\n\t, cast(coalesce(poa.diagnosis_poa_6, undetermined.diagnosis_poa_6) as {{ dbt.type_string() }} ) as diagnosis_poa_6\n\t, cast(coalesce(poa.diagnosis_poa_7, undetermined.diagnosis_poa_7) as {{ dbt.type_string() }} ) as diagnosis_poa_7\n\t, cast(coalesce(poa.diagnosis_poa_8, undetermined.diagnosis_poa_8) as {{ dbt.type_string() }} ) as diagnosis_poa_8\n\t, cast(coalesce(poa.diagnosis_poa_9, undetermined.diagnosis_poa_9) as {{ dbt.type_string() }} ) as diagnosis_poa_9\n\t, cast(coalesce(poa.diagnosis_poa_10, undetermined.diagnosis_poa_10) as {{ dbt.type_string() }} ) as diagnosis_poa_10\n\t, cast(coalesce(poa.diagnosis_poa_11, undetermined.diagnosis_poa_11) as {{ dbt.type_string() }} ) as diagnosis_poa_11\n\t, cast(coalesce(poa.diagnosis_poa_12, undetermined.diagnosis_poa_12) as {{ dbt.type_string() }} ) as diagnosis_poa_12\n\t, cast(coalesce(poa.diagnosis_poa_13, undetermined.diagnosis_poa_13) as {{ dbt.type_string() }} ) as diagnosis_poa_13\n\t, cast(coalesce(poa.diagnosis_poa_14, undetermined.diagnosis_poa_14) as {{ dbt.type_string() }} ) as diagnosis_poa_14\n\t, cast(coalesce(poa.diagnosis_poa_15, undetermined.diagnosis_poa_15) as {{ dbt.type_string() }} ) as diagnosis_poa_15\n\t, cast(coalesce(poa.diagnosis_poa_16, undetermined.diagnosis_poa_16) as {{ dbt.type_string() }} ) as diagnosis_poa_16\n\t, cast(coalesce(poa.diagnosis_poa_17, undetermined.diagnosis_poa_17) as {{ dbt.type_string() }} ) as diagnosis_poa_17\n\t, cast(coalesce(poa.diagnosis_poa_18, undetermined.diagnosis_poa_18) as {{ dbt.type_string() }} ) as diagnosis_poa_18\n\t, cast(coalesce(poa.diagnosis_poa_19, undetermined.diagnosis_poa_19) as {{ dbt.type_string() }} ) as diagnosis_poa_19\n\t, cast(coalesce(poa.diagnosis_poa_20, undetermined.diagnosis_poa_20) as {{ dbt.type_string() }} ) as diagnosis_poa_20\n\t, cast(coalesce(poa.diagnosis_poa_21, undetermined.diagnosis_poa_21) as {{ dbt.type_string() }} ) as diagnosis_poa_21\n\t, cast(coalesce(poa.diagnosis_poa_22, undetermined.diagnosis_poa_22) as {{ dbt.type_string() }} ) as diagnosis_poa_22\n\t, cast(coalesce(poa.diagnosis_poa_23, undetermined.diagnosis_poa_23) as {{ dbt.type_string() }} ) as diagnosis_poa_23\n\t, cast(coalesce(poa.diagnosis_poa_24, undetermined.diagnosis_poa_24) as {{ dbt.type_string() }} ) as diagnosis_poa_24\n\t, cast(coalesce(poa.diagnosis_poa_25, undetermined.diagnosis_poa_25) as {{ dbt.type_string() }} ) as diagnosis_poa_25\n\t, cast(med.procedure_code_type as {{ dbt.type_string() }} ) as procedure_code_type\n\t, cast(coalesce(px_code.procedure_code_1, undetermined.procedure_code_1) as {{ dbt.type_string() }} ) as procedure_code_1\n\t, cast(coalesce(px_code.procedure_code_2, undetermined.procedure_code_2) as {{ dbt.type_string() }} ) as procedure_code_2\n\t, cast(coalesce(px_code.procedure_code_3, undetermined.procedure_code_3) as {{ dbt.type_string() }} ) as procedure_code_3\n\t, cast(coalesce(px_code.procedure_code_4, undetermined.procedure_code_4) as {{ dbt.type_string() }} ) as procedure_code_4\n\t, cast(coalesce(px_code.procedure_code_5, undetermined.procedure_code_5) as {{ dbt.type_string() }} ) as procedure_code_5\n\t, cast(coalesce(px_code.procedure_code_6, undetermined.procedure_code_6) as {{ dbt.type_string() }} ) as procedure_code_6\n\t, cast(coalesce(px_code.procedure_code_7, undetermined.procedure_code_7) as {{ dbt.type_string() }} ) as procedure_code_7\n\t, cast(coalesce(px_code.procedure_code_8, undetermined.procedure_code_8) as {{ dbt.type_string() }} ) as procedure_code_8\n\t, cast(coalesce(px_code.procedure_code_9, undetermined.procedure_code_9) as {{ dbt.type_string() }} ) as procedure_code_9\n\t, cast(coalesce(px_code.procedure_code_10, undetermined.procedure_code_10) as {{ dbt.type_string() }} ) as procedure_code_10\n\t, cast(coalesce(px_code.procedure_code_11, undetermined.procedure_code_11) as {{ dbt.type_string() }} ) as procedure_code_11\n\t, cast(coalesce(px_code.procedure_code_12, undetermined.procedure_code_12) as {{ dbt.type_string() }} ) as procedure_code_12\n\t, cast(coalesce(px_code.procedure_code_13, undetermined.procedure_code_13) as {{ dbt.type_string() }} ) as procedure_code_13\n\t, cast(coalesce(px_code.procedure_code_14, undetermined.procedure_code_14) as {{ dbt.type_string() }} ) as procedure_code_14\n\t, cast(coalesce(px_code.procedure_code_15, undetermined.procedure_code_15) as {{ dbt.type_string() }} ) as procedure_code_15\n\t, cast(coalesce(px_code.procedure_code_16, undetermined.procedure_code_16) as {{ dbt.type_string() }} ) as procedure_code_16\n\t, cast(coalesce(px_code.procedure_code_17, undetermined.procedure_code_17) as {{ dbt.type_string() }} ) as procedure_code_17\n\t, cast(coalesce(px_code.procedure_code_18, undetermined.procedure_code_18) as {{ dbt.type_string() }} ) as procedure_code_18\n\t, cast(coalesce(px_code.procedure_code_19, undetermined.procedure_code_19) as {{ dbt.type_string() }} ) as procedure_code_19\n\t, cast(coalesce(px_code.procedure_code_20, undetermined.procedure_code_20) as {{ dbt.type_string() }} ) as procedure_code_20\n\t, cast(coalesce(px_code.procedure_code_21, undetermined.procedure_code_21) as {{ dbt.type_string() }} ) as procedure_code_21\n\t, cast(coalesce(px_code.procedure_code_22, undetermined.procedure_code_22) as {{ dbt.type_string() }} ) as procedure_code_22\n\t, cast(coalesce(px_code.procedure_code_23, undetermined.procedure_code_23) as {{ dbt.type_string() }} ) as procedure_code_23\n\t, cast(coalesce(px_code.procedure_code_24, undetermined.procedure_code_24) as {{ dbt.type_string() }} ) as procedure_code_24\n\t, cast(coalesce(px_code.procedure_code_25, undetermined.procedure_code_25) as {{ dbt.type_string() }} ) as procedure_code_25\n\t, cast(coalesce(px_date.procedure_date_1, undetermined.procedure_date_1) as date ) as procedure_date_1\n\t, cast(coalesce(px_date.procedure_date_2, undetermined.procedure_date_2) as date ) as procedure_date_2\n\t, cast(coalesce(px_date.procedure_date_3, undetermined.procedure_date_3) as date ) as procedure_date_3\n\t, cast(coalesce(px_date.procedure_date_4, undetermined.procedure_date_4) as date ) as procedure_date_4\n\t, cast(coalesce(px_date.procedure_date_5, undetermined.procedure_date_5) as date ) as procedure_date_5\n\t, cast(coalesce(px_date.procedure_date_6, undetermined.procedure_date_6) as date ) as procedure_date_6\n\t, cast(coalesce(px_date.procedure_date_7, undetermined.procedure_date_7) as date ) as procedure_date_7\n\t, cast(coalesce(px_date.procedure_date_8, undetermined.procedure_date_8) as date ) as procedure_date_8\n\t, cast(coalesce(px_date.procedure_date_9, undetermined.procedure_date_9) as date ) as procedure_date_9\n\t, cast(coalesce(px_date.procedure_date_10, undetermined.procedure_date_10) as date ) as procedure_date_10\n\t, cast(coalesce(px_date.procedure_date_11, undetermined.procedure_date_11) as date ) as procedure_date_11\n\t, cast(coalesce(px_date.procedure_date_12, undetermined.procedure_date_12) as date ) as procedure_date_12\n\t, cast(coalesce(px_date.procedure_date_13, undetermined.procedure_date_13) as date ) as procedure_date_13\n\t, cast(coalesce(px_date.procedure_date_14, undetermined.procedure_date_14) as date ) as procedure_date_14\n\t, cast(coalesce(px_date.procedure_date_15, undetermined.procedure_date_15) as date ) as procedure_date_15\n\t, cast(coalesce(px_date.procedure_date_16, undetermined.procedure_date_16) as date ) as procedure_date_16\n\t, cast(coalesce(px_date.procedure_date_17, undetermined.procedure_date_17) as date ) as procedure_date_17\n\t, cast(coalesce(px_date.procedure_date_18, undetermined.procedure_date_18) as date ) as procedure_date_18\n\t, cast(coalesce(px_date.procedure_date_19, undetermined.procedure_date_19) as date ) as procedure_date_19\n\t, cast(coalesce(px_date.procedure_date_20, undetermined.procedure_date_20) as date ) as procedure_date_20\n\t, cast(coalesce(px_date.procedure_date_21, undetermined.procedure_date_21) as date ) as procedure_date_21\n\t, cast(coalesce(px_date.procedure_date_22, undetermined.procedure_date_22) as date ) as procedure_date_22\n\t, cast(coalesce(px_date.procedure_date_23, undetermined.procedure_date_23) as date ) as procedure_date_23\n\t, cast(coalesce(px_date.procedure_date_24, undetermined.procedure_date_24) as date ) as procedure_date_24\n\t, cast(coalesce(px_date.procedure_date_25, undetermined.procedure_date_25) as date ) as procedure_date_25\n\t, cast(med.data_source as {{ dbt.type_string() }} ) as data_source\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_string() }} ) as tuva_last_run\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\nleft join {{ref('normalized_input__int_admit_source_final') }} ad_source\n on med.claim_id = ad_source.claim_id\n and med.data_source = ad_source.data_source\nleft join {{ref('normalized_input__int_admit_type_final') }} ad_type\n on med.claim_id = ad_type.claim_id\n and med.data_source = ad_type.data_source\nleft join {{ref('normalized_input__int_apr_drg_final') }} apr\n on med.claim_id = apr.claim_id\n and med.data_source = apr.data_source\nleft join {{ref('normalized_input__int_bill_type_final') }} bill\n on med.claim_id = bill.claim_id\n and med.data_source = bill.data_source\nleft join {{ref('normalized_input__int_medical_claim_date_normalize') }} claim_line_dates\n on med.claim_id = claim_line_dates.claim_id\n and med.claim_line_number = claim_line_dates.claim_line_number\n and med.data_source = claim_line_dates.data_source\nleft join {{ref('normalized_input__int_medical_date_aggregation') }} dates\n on med.claim_id = dates.claim_id\n and med.data_source = dates.data_source\nleft join {{ref('normalized_input__int_medical_npi_normalize') }} med_npi\n on med.claim_id = med_npi.claim_id\n and med.claim_line_number = med_npi.claim_line_number\n and med.data_source = med_npi.data_source\nleft join {{ref('normalized_input__int_discharge_disposition_final') }} disch_disp\n on med.claim_id = disch_disp.claim_id\n and med.data_source = disch_disp.data_source\nleft join {{ref('normalized_input__int_ms_drg_final') }} ms\n on med.claim_id = ms.claim_id\n and med.data_source = ms.data_source\nleft join {{ref('normalized_input__int_place_of_service_normalize') }} pos\n on med.claim_id = pos.claim_id\n and med.claim_line_number = pos.claim_line_number\n and med.data_source = pos.data_source\nleft join {{ref('normalized_input__int_diagnosis_code_final') }} dx_code\n on med.claim_id = dx_code.claim_id\n and med.data_source = dx_code.data_source\nleft join {{ref('normalized_input__int_present_on_admit_final') }} poa\n on med.claim_id = poa.claim_id\n and med.data_source = poa.data_source\nleft join {{ref('normalized_input__int_procedure_code_final') }} px_code\n on med.claim_id = px_code.claim_id\n and med.data_source = px_code.data_source\nleft join {{ref('normalized_input__int_procedure_date_final') }} px_date\n on med.claim_id = px_date.claim_id\n and med.data_source = px_date.data_source\nleft join {{ref('normalized_input__int_revenue_center_normalize') }} rev\n on med.claim_id = rev.claim_id\n and med.claim_line_number = rev.claim_line_number\n and med.data_source = rev.data_source\nleft join {{ref('normalized_input__int_undetermined_claim_type') }} undetermined\n on med.claim_id = undetermined.claim_id\n and med.claim_line_number = undetermined.claim_line_number\n and med.data_source = undetermined.data_source", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__int_admit_source_final", "package": null, "version": null}, {"name": "normalized_input__int_admit_type_final", "package": null, "version": null}, {"name": "normalized_input__int_apr_drg_final", "package": null, "version": null}, {"name": "normalized_input__int_bill_type_final", "package": null, "version": null}, {"name": "normalized_input__int_medical_claim_date_normalize", "package": null, "version": null}, {"name": "normalized_input__int_medical_date_aggregation", "package": null, "version": null}, {"name": "normalized_input__int_medical_npi_normalize", "package": null, "version": null}, {"name": "normalized_input__int_discharge_disposition_final", "package": null, "version": null}, {"name": "normalized_input__int_ms_drg_final", "package": null, "version": null}, {"name": "normalized_input__int_place_of_service_normalize", "package": null, "version": null}, {"name": "normalized_input__int_diagnosis_code_final", "package": null, "version": null}, {"name": "normalized_input__int_present_on_admit_final", "package": null, "version": null}, {"name": "normalized_input__int_procedure_code_final", "package": null, "version": null}, {"name": "normalized_input__int_procedure_date_final", "package": null, "version": null}, {"name": "normalized_input__int_revenue_center_normalize", "package": null, "version": null}, {"name": "normalized_input__int_undetermined_claim_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "model.the_tuva_project.normalized_input__int_admit_source_final", "model.the_tuva_project.normalized_input__int_admit_type_final", "model.the_tuva_project.normalized_input__int_apr_drg_final", "model.the_tuva_project.normalized_input__int_bill_type_final", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "model.the_tuva_project.normalized_input__int_ms_drg_final", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "model.the_tuva_project.normalized_input__int_present_on_admit_final", "model.the_tuva_project.normalized_input__int_procedure_code_final", "model.the_tuva_project.normalized_input__int_procedure_date_final", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/final/normalized_input__medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n\tcast(med.claim_id as TEXT ) as claim_id\n\t, cast(med.claim_line_number as int ) as claim_line_number\n\t, cast(med.claim_type as TEXT ) as claim_type\n\t, cast(med.patient_id as TEXT ) as patient_id\n\t, cast(med.member_id as TEXT ) as member_id\n\t, cast(med.payer as TEXT ) as payer\n , cast(med.plan as TEXT ) as plan\n\t, cast(coalesce(dates.minimum_claim_start_date, undetermined.claim_start_date) as date ) as claim_start_date\n\t, cast(coalesce(dates.maximum_claim_end_date, undetermined.claim_start_date) as date ) as claim_end_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_start_date, undetermined.claim_line_start_date) as date ) as claim_line_start_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_end_date, undetermined.claim_line_end_date) as date ) as claim_line_end_date\n\t, cast(coalesce(dates.minimum_admission_date, undetermined.admission_date) as date ) as admission_date\n\t, cast(coalesce(dates.maximum_discharge_date, undetermined.discharge_date) as date ) as discharge_date\n\t, cast(coalesce(ad_source.normalized_code, undetermined.admit_source_code) as TEXT ) as admit_source_code\n , cast(coalesce(ad_source.normalized_description, undetermined.admit_source_description) as TEXT ) as admit_source_description\n\t, cast(coalesce(ad_type.normalized_code, undetermined.admit_type_code) as TEXT ) as admit_type_code\n , cast(coalesce(ad_type.normalized_description, undetermined.admit_type_description) as TEXT ) as admit_type_description\n\t, cast(coalesce(disch_disp.normalized_code, undetermined.discharge_disposition_code) as TEXT ) as discharge_disposition_code\n , cast(coalesce(disch_disp.normalized_description, undetermined.discharge_disposition_description) as TEXT ) as discharge_disposition_description\n\t, cast(coalesce(pos.normalized_code, undetermined.place_of_service_code) as TEXT ) as place_of_service_code\n , cast(coalesce(pos.normalized_description, undetermined.place_of_service_description) as TEXT ) as place_of_service_description\n\t, cast(coalesce(bill.normalized_code, undetermined.bill_type_code) as TEXT ) as bill_type_code\n , cast(coalesce(bill.normalized_description, undetermined.bill_type_description) as TEXT ) as bill_type_description\n\t, cast(coalesce(ms.normalized_code, undetermined.ms_drg_code) as TEXT ) as ms_drg_code\n , cast(coalesce(ms.normalized_description, undetermined.ms_drg_description) as TEXT ) as ms_drg_description\n\t, cast(coalesce(apr.normalized_code, undetermined.apr_drg_code) as TEXT ) as apr_drg_code\n , cast(coalesce(apr.normalized_description, undetermined.apr_drg_description) as TEXT ) as apr_drg_description\n\t, cast(coalesce(rev.normalized_code, undetermined.revenue_center_code) as TEXT ) as revenue_center_code\n , cast(coalesce(rev.normalized_description, undetermined.revenue_center_description) as TEXT ) as revenue_center_description\n\t, cast(med.service_unit_quantity as TEXT ) as service_unit_quantity\n\t, cast(med.hcpcs_code as TEXT ) as hcpcs_code\n\t, cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n\t, cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n\t, cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n\t, cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n\t, cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n\t, cast(coalesce(med_npi.normalized_rendering_npi, undetermined.rendering_npi) as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(coalesce(med_npi.normalized_rendering_name, undetermined.rendering_name) as TEXT ) as rendering_name\n\t, cast(coalesce(med_npi.normalized_billing_npi, undetermined.billing_npi) as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(coalesce(med_npi.normalized_billing_name, undetermined.billing_name) as TEXT ) as billing_name\n\t, cast(coalesce(med_npi.normalized_facility_npi, undetermined.facility_npi) as TEXT ) as facility_id\n\t, cast(coalesce(med_npi.normalized_facility_name, undetermined.facility_name) as TEXT ) as facility_name\n , cast(med.paid_date as date ) as paid_date\n\t, cast(med.paid_amount as numeric(28,6) ) as paid_amount\n\t, cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n\t, cast(med.charge_amount as numeric(28,6) ) as charge_amount\n\t, cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n\t, cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n\t, cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n\t, cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n\t, cast(med.diagnosis_code_type as TEXT ) as diagnosis_code_type\n\t, cast(coalesce(dx_code.diagnosis_code_1, undetermined.diagnosis_code_1) as TEXT ) as diagnosis_code_1\n\t, cast(coalesce(dx_code.diagnosis_code_2, undetermined.diagnosis_code_2) as TEXT ) as diagnosis_code_2\n\t, cast(coalesce(dx_code.diagnosis_code_3, undetermined.diagnosis_code_3) as TEXT ) as diagnosis_code_3\n\t, cast(coalesce(dx_code.diagnosis_code_4, undetermined.diagnosis_code_4) as TEXT ) as diagnosis_code_4\n\t, cast(coalesce(dx_code.diagnosis_code_5, undetermined.diagnosis_code_5) as TEXT ) as diagnosis_code_5\n\t, cast(coalesce(dx_code.diagnosis_code_6, undetermined.diagnosis_code_6) as TEXT ) as diagnosis_code_6\n\t, cast(coalesce(dx_code.diagnosis_code_7, undetermined.diagnosis_code_7) as TEXT ) as diagnosis_code_7\n\t, cast(coalesce(dx_code.diagnosis_code_8, undetermined.diagnosis_code_8) as TEXT ) as diagnosis_code_8\n\t, cast(coalesce(dx_code.diagnosis_code_9, undetermined.diagnosis_code_9) as TEXT ) as diagnosis_code_9\n\t, cast(coalesce(dx_code.diagnosis_code_10, undetermined.diagnosis_code_10) as TEXT ) as diagnosis_code_10\n\t, cast(coalesce(dx_code.diagnosis_code_11, undetermined.diagnosis_code_11) as TEXT ) as diagnosis_code_11\n\t, cast(coalesce(dx_code.diagnosis_code_12, undetermined.diagnosis_code_12) as TEXT ) as diagnosis_code_12\n\t, cast(coalesce(dx_code.diagnosis_code_13, undetermined.diagnosis_code_13) as TEXT ) as diagnosis_code_13\n\t, cast(coalesce(dx_code.diagnosis_code_14, undetermined.diagnosis_code_14) as TEXT ) as diagnosis_code_14\n\t, cast(coalesce(dx_code.diagnosis_code_15, undetermined.diagnosis_code_15) as TEXT ) as diagnosis_code_15\n\t, cast(coalesce(dx_code.diagnosis_code_16, undetermined.diagnosis_code_16) as TEXT ) as diagnosis_code_16\n\t, cast(coalesce(dx_code.diagnosis_code_17, undetermined.diagnosis_code_17) as TEXT ) as diagnosis_code_17\n\t, cast(coalesce(dx_code.diagnosis_code_18, undetermined.diagnosis_code_18) as TEXT ) as diagnosis_code_18\n\t, cast(coalesce(dx_code.diagnosis_code_19, undetermined.diagnosis_code_19) as TEXT ) as diagnosis_code_19\n\t, cast(coalesce(dx_code.diagnosis_code_20, undetermined.diagnosis_code_20) as TEXT ) as diagnosis_code_20\n\t, cast(coalesce(dx_code.diagnosis_code_21, undetermined.diagnosis_code_21) as TEXT ) as diagnosis_code_21\n\t, cast(coalesce(dx_code.diagnosis_code_22, undetermined.diagnosis_code_22) as TEXT ) as diagnosis_code_22\n\t, cast(coalesce(dx_code.diagnosis_code_23, undetermined.diagnosis_code_23) as TEXT ) as diagnosis_code_23\n\t, cast(coalesce(dx_code.diagnosis_code_24, undetermined.diagnosis_code_24) as TEXT ) as diagnosis_code_24\n\t, cast(coalesce(dx_code.diagnosis_code_25, undetermined.diagnosis_code_25) as TEXT ) as diagnosis_code_25\n\t, cast(coalesce(poa.diagnosis_poa_1, undetermined.diagnosis_poa_1) as TEXT ) as diagnosis_poa_1\n\t, cast(coalesce(poa.diagnosis_poa_2, undetermined.diagnosis_poa_2) as TEXT ) as diagnosis_poa_2\n\t, cast(coalesce(poa.diagnosis_poa_3, undetermined.diagnosis_poa_3) as TEXT ) as diagnosis_poa_3\n\t, cast(coalesce(poa.diagnosis_poa_4, undetermined.diagnosis_poa_4) as TEXT ) as diagnosis_poa_4\n\t, cast(coalesce(poa.diagnosis_poa_5, undetermined.diagnosis_poa_5) as TEXT ) as diagnosis_poa_5\n\t, cast(coalesce(poa.diagnosis_poa_6, undetermined.diagnosis_poa_6) as TEXT ) as diagnosis_poa_6\n\t, cast(coalesce(poa.diagnosis_poa_7, undetermined.diagnosis_poa_7) as TEXT ) as diagnosis_poa_7\n\t, cast(coalesce(poa.diagnosis_poa_8, undetermined.diagnosis_poa_8) as TEXT ) as diagnosis_poa_8\n\t, cast(coalesce(poa.diagnosis_poa_9, undetermined.diagnosis_poa_9) as TEXT ) as diagnosis_poa_9\n\t, cast(coalesce(poa.diagnosis_poa_10, undetermined.diagnosis_poa_10) as TEXT ) as diagnosis_poa_10\n\t, cast(coalesce(poa.diagnosis_poa_11, undetermined.diagnosis_poa_11) as TEXT ) as diagnosis_poa_11\n\t, cast(coalesce(poa.diagnosis_poa_12, undetermined.diagnosis_poa_12) as TEXT ) as diagnosis_poa_12\n\t, cast(coalesce(poa.diagnosis_poa_13, undetermined.diagnosis_poa_13) as TEXT ) as diagnosis_poa_13\n\t, cast(coalesce(poa.diagnosis_poa_14, undetermined.diagnosis_poa_14) as TEXT ) as diagnosis_poa_14\n\t, cast(coalesce(poa.diagnosis_poa_15, undetermined.diagnosis_poa_15) as TEXT ) as diagnosis_poa_15\n\t, cast(coalesce(poa.diagnosis_poa_16, undetermined.diagnosis_poa_16) as TEXT ) as diagnosis_poa_16\n\t, cast(coalesce(poa.diagnosis_poa_17, undetermined.diagnosis_poa_17) as TEXT ) as diagnosis_poa_17\n\t, cast(coalesce(poa.diagnosis_poa_18, undetermined.diagnosis_poa_18) as TEXT ) as diagnosis_poa_18\n\t, cast(coalesce(poa.diagnosis_poa_19, undetermined.diagnosis_poa_19) as TEXT ) as diagnosis_poa_19\n\t, cast(coalesce(poa.diagnosis_poa_20, undetermined.diagnosis_poa_20) as TEXT ) as diagnosis_poa_20\n\t, cast(coalesce(poa.diagnosis_poa_21, undetermined.diagnosis_poa_21) as TEXT ) as diagnosis_poa_21\n\t, cast(coalesce(poa.diagnosis_poa_22, undetermined.diagnosis_poa_22) as TEXT ) as diagnosis_poa_22\n\t, cast(coalesce(poa.diagnosis_poa_23, undetermined.diagnosis_poa_23) as TEXT ) as diagnosis_poa_23\n\t, cast(coalesce(poa.diagnosis_poa_24, undetermined.diagnosis_poa_24) as TEXT ) as diagnosis_poa_24\n\t, cast(coalesce(poa.diagnosis_poa_25, undetermined.diagnosis_poa_25) as TEXT ) as diagnosis_poa_25\n\t, cast(med.procedure_code_type as TEXT ) as procedure_code_type\n\t, cast(coalesce(px_code.procedure_code_1, undetermined.procedure_code_1) as TEXT ) as procedure_code_1\n\t, cast(coalesce(px_code.procedure_code_2, undetermined.procedure_code_2) as TEXT ) as procedure_code_2\n\t, cast(coalesce(px_code.procedure_code_3, undetermined.procedure_code_3) as TEXT ) as procedure_code_3\n\t, cast(coalesce(px_code.procedure_code_4, undetermined.procedure_code_4) as TEXT ) as procedure_code_4\n\t, cast(coalesce(px_code.procedure_code_5, undetermined.procedure_code_5) as TEXT ) as procedure_code_5\n\t, cast(coalesce(px_code.procedure_code_6, undetermined.procedure_code_6) as TEXT ) as procedure_code_6\n\t, cast(coalesce(px_code.procedure_code_7, undetermined.procedure_code_7) as TEXT ) as procedure_code_7\n\t, cast(coalesce(px_code.procedure_code_8, undetermined.procedure_code_8) as TEXT ) as procedure_code_8\n\t, cast(coalesce(px_code.procedure_code_9, undetermined.procedure_code_9) as TEXT ) as procedure_code_9\n\t, cast(coalesce(px_code.procedure_code_10, undetermined.procedure_code_10) as TEXT ) as procedure_code_10\n\t, cast(coalesce(px_code.procedure_code_11, undetermined.procedure_code_11) as TEXT ) as procedure_code_11\n\t, cast(coalesce(px_code.procedure_code_12, undetermined.procedure_code_12) as TEXT ) as procedure_code_12\n\t, cast(coalesce(px_code.procedure_code_13, undetermined.procedure_code_13) as TEXT ) as procedure_code_13\n\t, cast(coalesce(px_code.procedure_code_14, undetermined.procedure_code_14) as TEXT ) as procedure_code_14\n\t, cast(coalesce(px_code.procedure_code_15, undetermined.procedure_code_15) as TEXT ) as procedure_code_15\n\t, cast(coalesce(px_code.procedure_code_16, undetermined.procedure_code_16) as TEXT ) as procedure_code_16\n\t, cast(coalesce(px_code.procedure_code_17, undetermined.procedure_code_17) as TEXT ) as procedure_code_17\n\t, cast(coalesce(px_code.procedure_code_18, undetermined.procedure_code_18) as TEXT ) as procedure_code_18\n\t, cast(coalesce(px_code.procedure_code_19, undetermined.procedure_code_19) as TEXT ) as procedure_code_19\n\t, cast(coalesce(px_code.procedure_code_20, undetermined.procedure_code_20) as TEXT ) as procedure_code_20\n\t, cast(coalesce(px_code.procedure_code_21, undetermined.procedure_code_21) as TEXT ) as procedure_code_21\n\t, cast(coalesce(px_code.procedure_code_22, undetermined.procedure_code_22) as TEXT ) as procedure_code_22\n\t, cast(coalesce(px_code.procedure_code_23, undetermined.procedure_code_23) as TEXT ) as procedure_code_23\n\t, cast(coalesce(px_code.procedure_code_24, undetermined.procedure_code_24) as TEXT ) as procedure_code_24\n\t, cast(coalesce(px_code.procedure_code_25, undetermined.procedure_code_25) as TEXT ) as procedure_code_25\n\t, cast(coalesce(px_date.procedure_date_1, undetermined.procedure_date_1) as date ) as procedure_date_1\n\t, cast(coalesce(px_date.procedure_date_2, undetermined.procedure_date_2) as date ) as procedure_date_2\n\t, cast(coalesce(px_date.procedure_date_3, undetermined.procedure_date_3) as date ) as procedure_date_3\n\t, cast(coalesce(px_date.procedure_date_4, undetermined.procedure_date_4) as date ) as procedure_date_4\n\t, cast(coalesce(px_date.procedure_date_5, undetermined.procedure_date_5) as date ) as procedure_date_5\n\t, cast(coalesce(px_date.procedure_date_6, undetermined.procedure_date_6) as date ) as procedure_date_6\n\t, cast(coalesce(px_date.procedure_date_7, undetermined.procedure_date_7) as date ) as procedure_date_7\n\t, cast(coalesce(px_date.procedure_date_8, undetermined.procedure_date_8) as date ) as procedure_date_8\n\t, cast(coalesce(px_date.procedure_date_9, undetermined.procedure_date_9) as date ) as procedure_date_9\n\t, cast(coalesce(px_date.procedure_date_10, undetermined.procedure_date_10) as date ) as procedure_date_10\n\t, cast(coalesce(px_date.procedure_date_11, undetermined.procedure_date_11) as date ) as procedure_date_11\n\t, cast(coalesce(px_date.procedure_date_12, undetermined.procedure_date_12) as date ) as procedure_date_12\n\t, cast(coalesce(px_date.procedure_date_13, undetermined.procedure_date_13) as date ) as procedure_date_13\n\t, cast(coalesce(px_date.procedure_date_14, undetermined.procedure_date_14) as date ) as procedure_date_14\n\t, cast(coalesce(px_date.procedure_date_15, undetermined.procedure_date_15) as date ) as procedure_date_15\n\t, cast(coalesce(px_date.procedure_date_16, undetermined.procedure_date_16) as date ) as procedure_date_16\n\t, cast(coalesce(px_date.procedure_date_17, undetermined.procedure_date_17) as date ) as procedure_date_17\n\t, cast(coalesce(px_date.procedure_date_18, undetermined.procedure_date_18) as date ) as procedure_date_18\n\t, cast(coalesce(px_date.procedure_date_19, undetermined.procedure_date_19) as date ) as procedure_date_19\n\t, cast(coalesce(px_date.procedure_date_20, undetermined.procedure_date_20) as date ) as procedure_date_20\n\t, cast(coalesce(px_date.procedure_date_21, undetermined.procedure_date_21) as date ) as procedure_date_21\n\t, cast(coalesce(px_date.procedure_date_22, undetermined.procedure_date_22) as date ) as procedure_date_22\n\t, cast(coalesce(px_date.procedure_date_23, undetermined.procedure_date_23) as date ) as procedure_date_23\n\t, cast(coalesce(px_date.procedure_date_24, undetermined.procedure_date_24) as date ) as procedure_date_24\n\t, cast(coalesce(px_date.procedure_date_25, undetermined.procedure_date_25) as date ) as procedure_date_25\n\t, cast(med.data_source as TEXT ) as data_source\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_final ad_source\n on med.claim_id = ad_source.claim_id\n and med.data_source = ad_source.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_final ad_type\n on med.claim_id = ad_type.claim_id\n and med.data_source = ad_type.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_final apr\n on med.claim_id = apr.claim_id\n and med.data_source = apr.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_final bill\n on med.claim_id = bill.claim_id\n and med.data_source = bill.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize claim_line_dates\n on med.claim_id = claim_line_dates.claim_id\n and med.claim_line_number = claim_line_dates.claim_line_number\n and med.data_source = claim_line_dates.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_medical_date_aggregation dates\n on med.claim_id = dates.claim_id\n and med.data_source = dates.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_medical_npi_normalize med_npi\n on med.claim_id = med_npi.claim_id\n and med.claim_line_number = med_npi.claim_line_number\n and med.data_source = med_npi.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_final disch_disp\n on med.claim_id = disch_disp.claim_id\n and med.data_source = disch_disp.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_final ms\n on med.claim_id = ms.claim_id\n and med.data_source = ms.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_place_of_service_normalize pos\n on med.claim_id = pos.claim_id\n and med.claim_line_number = pos.claim_line_number\n and med.data_source = pos.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_final dx_code\n on med.claim_id = dx_code.claim_id\n and med.data_source = dx_code.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_final poa\n on med.claim_id = poa.claim_id\n and med.data_source = poa.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_final px_code\n on med.claim_id = px_code.claim_id\n and med.data_source = px_code.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_final px_date\n on med.claim_id = px_date.claim_id\n and med.data_source = px_date.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_revenue_center_normalize rev\n on med.claim_id = rev.claim_id\n and med.claim_line_number = rev.claim_line_number\n and med.data_source = rev.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_undetermined_claim_type undetermined\n on med.claim_id = undetermined.claim_id\n and med.claim_line_number = undetermined.claim_line_number\n and med.data_source = undetermined.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_revenue_center_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_revenue_center_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_revenue_center_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_revenue_center_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_revenue_center_normalize"], "alias": "_int_normalized_input_revenue_center_normalize", "checksum": {"name": "sha256", "checksum": "922c4c90868b35b866b7baf0f254ff3088f451e4f1a7bda733b6a9fc62bb3734"}, "config": {"enabled": true, "alias": "_int_normalized_input_revenue_center_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_revenue_center_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.590867, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_revenue_center_normalize", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , claim_line_number\n , data_source\n , rev.revenue_center_code as normalized_code\n , rev.revenue_center_description as normalized_description\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\nleft join {{ ref('terminology__revenue_center') }} rev\n {% if target.type == 'fabric' %}\n on RIGHT(REPLICATE('0', 4) + med.revenue_center_code, 4) = rev.revenue_center_code\n {% else %}\n on lpad(med.revenue_center_code, 4, '0') = rev.revenue_center_code\n {% endif %}\nwhere claim_type = 'institutional'", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__revenue_center"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_revenue_center_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , rev.revenue_center_code as normalized_code\n , rev.revenue_center_description as normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.revenue_center rev\n \n on lpad(med.revenue_center_code, 4, '0') = rev.revenue_center_code\n \nwhere claim_type = 'institutional'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_medical_claim_date_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_claim_date_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_claim_date_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_medical_claim_date_normalize"], "alias": "_int_normalized_input_medical_claim_date_normalize", "checksum": {"name": "sha256", "checksum": "63bde22f6fe54c7de757daf1745800a976d53fc1d8a6be9317f3946717c0180f"}, "config": {"enabled": true, "alias": "_int_normalized_input_medical_claim_date_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_medical_claim_date_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5683699, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , cal_claim_start.full_date as normalized_claim_start_date\n , cal_claim_end.full_date as normalized_claim_end_date\n , cal_claim_line_start.full_date as normalized_claim_line_start_date\n , cal_claim_line_end.full_date as normalized_claim_line_end_date\n , cal_admission.full_date as normalized_admission_date\n , cal_discharge.full_date as normalized_discharge_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\nleft join {{ ref('reference_data__calendar') }} cal_claim_start\n on med.claim_start_date = cal_claim_start.full_date\nleft join {{ ref('reference_data__calendar') }} cal_claim_end\n on med.claim_end_date = cal_claim_end.full_date\nleft join {{ ref('reference_data__calendar') }} cal_claim_line_start\n on med.claim_line_start_date = cal_claim_line_start.full_date\nleft join {{ ref('reference_data__calendar') }} cal_claim_line_end\n on med.claim_line_end_date = cal_claim_line_end.full_date\nleft join {{ ref('reference_data__calendar') }} cal_admission\n on med.admission_date = cal_admission.full_date\nleft join {{ ref('reference_data__calendar') }} cal_discharge\n on med.discharge_date = cal_discharge.full_date", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_claim_date_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , cal_claim_start.full_date as normalized_claim_start_date\n , cal_claim_end.full_date as normalized_claim_end_date\n , cal_claim_line_start.full_date as normalized_claim_line_start_date\n , cal_claim_line_end.full_date as normalized_claim_line_end_date\n , cal_admission.full_date as normalized_admission_date\n , cal_discharge.full_date as normalized_discharge_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.reference_data.calendar cal_claim_start\n on med.claim_start_date = cal_claim_start.full_date\nleft join cms_synthetic.reference_data.calendar cal_claim_end\n on med.claim_end_date = cal_claim_end.full_date\nleft join cms_synthetic.reference_data.calendar cal_claim_line_start\n on med.claim_line_start_date = cal_claim_line_start.full_date\nleft join cms_synthetic.reference_data.calendar cal_claim_line_end\n on med.claim_line_end_date = cal_claim_line_end.full_date\nleft join cms_synthetic.reference_data.calendar cal_admission\n on med.admission_date = cal_admission.full_date\nleft join cms_synthetic.reference_data.calendar cal_discharge\n on med.discharge_date = cal_discharge.full_date", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_medical_date_aggregation": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_medical_date_aggregation", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_date_aggregation.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_date_aggregation.sql", "unique_id": "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_medical_date_aggregation"], "alias": "_int_normalized_input_medical_date_aggregation", "checksum": {"name": "sha256", "checksum": "5596dbf9586a54cac39aaf04d1f8e561dae60f0be82b9e6c0b069182267831f0"}, "config": {"enabled": true, "alias": "_int_normalized_input_medical_date_aggregation", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_medical_date_aggregation", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.570028, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_medical_date_aggregation", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , min(normalized_claim_start_date) as minimum_claim_start_date\r\n , max(normalized_claim_end_date) as maximum_claim_end_date\r\n , min(normalized_admission_date) as minimum_admission_date\r\n , max(normalized_discharge_date) as maximum_discharge_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_medical_claim_date_normalize') }}\r\nwhere claim_type = 'institutional'\r\ngroup by\r\n claim_id\r\n , data_source\r\n\r\nunion all\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , min(normalized_claim_start_date) as minimum_claim_start_date\r\n , max(normalized_claim_end_date) as maximum_claim_end_date\r\n , null as minimum_admission_date\r\n , null as maximum_discharge_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_medical_claim_date_normalize') }}\r\nwhere claim_type = 'professional'\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_medical_claim_date_normalize", "package": null, "version": null}, {"name": "normalized_input__int_medical_claim_date_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_medical_claim_date_normalize"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_date_aggregation.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , min(normalized_admission_date) as minimum_admission_date\n , max(normalized_discharge_date) as maximum_discharge_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'institutional'\ngroup by\n claim_id\n , data_source\n\nunion all\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , null as minimum_admission_date\n , null as maximum_discharge_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'professional'\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_date_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_date_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_date_voting"], "alias": "_int_normalized_input_procedure_date_voting", "checksum": {"name": "sha256", "checksum": "fad7970b88cdd165e60d1c66fd8ef6f5645a57d543ac6965cae6ca4ec06f2bbf"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_date_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_date_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.589401, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_procedure_date_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.procedure_column as column_name\r\n , norm.procedure_date as normalized_code\r\n , norm.procedure_date_occurrence_count as occurrence_count\r\n , coalesce(lead(procedure_date_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_date_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.procedure_column = dist.procedure_column", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_date_normalize", "package": null, "version": null}, {"name": "normalized_input__int_procedure_date_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_date_normalize"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.procedure_date as normalized_code\n , norm.procedure_date_occurrence_count as occurrence_count\n , coalesce(lead(procedure_date_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_present_on_admit_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_present_on_admit_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_present_on_admit_final"], "alias": "_int_normalized_input_present_on_admit_final", "checksum": {"name": "sha256", "checksum": "ffd6b269b3f66e12d285c19dd8ef53c79e00a531b6bff27fd7dead01dd0852fb"}, "config": {"enabled": true, "alias": "_int_normalized_input_present_on_admit_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_present_on_admit_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.57759, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when column_name = 'DIAGNOSIS_POA_1' then normalized_code else null end) as diagnosis_poa_1\r\n , max(case when column_name = 'DIAGNOSIS_POA_2' then normalized_code else null end) as diagnosis_poa_2\r\n , max(case when column_name = 'DIAGNOSIS_POA_3' then normalized_code else null end) as diagnosis_poa_3\r\n , max(case when column_name = 'DIAGNOSIS_POA_4' then normalized_code else null end) as diagnosis_poa_4\r\n , max(case when column_name = 'DIAGNOSIS_POA_5' then normalized_code else null end) as diagnosis_poa_5\r\n , max(case when column_name = 'DIAGNOSIS_POA_6' then normalized_code else null end) as diagnosis_poa_6\r\n , max(case when column_name = 'DIAGNOSIS_POA_7' then normalized_code else null end) as diagnosis_poa_7\r\n , max(case when column_name = 'DIAGNOSIS_POA_8' then normalized_code else null end) as diagnosis_poa_8\r\n , max(case when column_name = 'DIAGNOSIS_POA_9' then normalized_code else null end) as diagnosis_poa_9\r\n , max(case when column_name = 'DIAGNOSIS_POA_10' then normalized_code else null end) as diagnosis_poa_10\r\n , max(case when column_name = 'DIAGNOSIS_POA_11' then normalized_code else null end) as diagnosis_poa_11\r\n , max(case when column_name = 'DIAGNOSIS_POA_12' then normalized_code else null end) as diagnosis_poa_12\r\n , max(case when column_name = 'DIAGNOSIS_POA_13' then normalized_code else null end) as diagnosis_poa_13\r\n , max(case when column_name = 'DIAGNOSIS_POA_14' then normalized_code else null end) as diagnosis_poa_14\r\n , max(case when column_name = 'DIAGNOSIS_POA_15' then normalized_code else null end) as diagnosis_poa_15\r\n , max(case when column_name = 'DIAGNOSIS_POA_16' then normalized_code else null end) as diagnosis_poa_16\r\n , max(case when column_name = 'DIAGNOSIS_POA_17' then normalized_code else null end) as diagnosis_poa_17\r\n , max(case when column_name = 'DIAGNOSIS_POA_18' then normalized_code else null end) as diagnosis_poa_18\r\n , max(case when column_name = 'DIAGNOSIS_POA_19' then normalized_code else null end) as diagnosis_poa_19\r\n , max(case when column_name = 'DIAGNOSIS_POA_20' then normalized_code else null end) as diagnosis_poa_20\r\n , max(case when column_name = 'DIAGNOSIS_POA_21' then normalized_code else null end) as diagnosis_poa_21\r\n , max(case when column_name = 'DIAGNOSIS_POA_22' then normalized_code else null end) as diagnosis_poa_22\r\n , max(case when column_name = 'DIAGNOSIS_POA_23' then normalized_code else null end) as diagnosis_poa_23\r\n , max(case when column_name = 'DIAGNOSIS_POA_24' then normalized_code else null end) as diagnosis_poa_24\r\n , max(case when column_name = 'DIAGNOSIS_POA_25' then normalized_code else null end) as diagnosis_poa_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_present_on_admit_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_present_on_admit_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_present_on_admit_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_final.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when column_name = 'DIAGNOSIS_POA_1' then normalized_code else null end) as diagnosis_poa_1\n , max(case when column_name = 'DIAGNOSIS_POA_2' then normalized_code else null end) as diagnosis_poa_2\n , max(case when column_name = 'DIAGNOSIS_POA_3' then normalized_code else null end) as diagnosis_poa_3\n , max(case when column_name = 'DIAGNOSIS_POA_4' then normalized_code else null end) as diagnosis_poa_4\n , max(case when column_name = 'DIAGNOSIS_POA_5' then normalized_code else null end) as diagnosis_poa_5\n , max(case when column_name = 'DIAGNOSIS_POA_6' then normalized_code else null end) as diagnosis_poa_6\n , max(case when column_name = 'DIAGNOSIS_POA_7' then normalized_code else null end) as diagnosis_poa_7\n , max(case when column_name = 'DIAGNOSIS_POA_8' then normalized_code else null end) as diagnosis_poa_8\n , max(case when column_name = 'DIAGNOSIS_POA_9' then normalized_code else null end) as diagnosis_poa_9\n , max(case when column_name = 'DIAGNOSIS_POA_10' then normalized_code else null end) as diagnosis_poa_10\n , max(case when column_name = 'DIAGNOSIS_POA_11' then normalized_code else null end) as diagnosis_poa_11\n , max(case when column_name = 'DIAGNOSIS_POA_12' then normalized_code else null end) as diagnosis_poa_12\n , max(case when column_name = 'DIAGNOSIS_POA_13' then normalized_code else null end) as diagnosis_poa_13\n , max(case when column_name = 'DIAGNOSIS_POA_14' then normalized_code else null end) as diagnosis_poa_14\n , max(case when column_name = 'DIAGNOSIS_POA_15' then normalized_code else null end) as diagnosis_poa_15\n , max(case when column_name = 'DIAGNOSIS_POA_16' then normalized_code else null end) as diagnosis_poa_16\n , max(case when column_name = 'DIAGNOSIS_POA_17' then normalized_code else null end) as diagnosis_poa_17\n , max(case when column_name = 'DIAGNOSIS_POA_18' then normalized_code else null end) as diagnosis_poa_18\n , max(case when column_name = 'DIAGNOSIS_POA_19' then normalized_code else null end) as diagnosis_poa_19\n , max(case when column_name = 'DIAGNOSIS_POA_20' then normalized_code else null end) as diagnosis_poa_20\n , max(case when column_name = 'DIAGNOSIS_POA_21' then normalized_code else null end) as diagnosis_poa_21\n , max(case when column_name = 'DIAGNOSIS_POA_22' then normalized_code else null end) as diagnosis_poa_22\n , max(case when column_name = 'DIAGNOSIS_POA_23' then normalized_code else null end) as diagnosis_poa_23\n , max(case when column_name = 'DIAGNOSIS_POA_24' then normalized_code else null end) as diagnosis_poa_24\n , max(case when column_name = 'DIAGNOSIS_POA_25' then normalized_code else null end) as diagnosis_poa_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_apr_drg_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_apr_drg_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_apr_drg_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_apr_drg_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_apr_drg_final"], "alias": "_int_normalized_input_apr_drg_final", "checksum": {"name": "sha256", "checksum": "fc90e7e7a19590c3102cf132a10fca4c964d329d10a3e6c8a14dd79ddc757f69"}, "config": {"enabled": true, "alias": "_int_normalized_input_apr_drg_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_apr_drg_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.552209, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_final", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__int_apr_drg_voting') }}\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_apr_drg_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_apr_drg_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_apr_drg_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_type_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_type_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_type_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_type_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_type_final"], "alias": "_int_normalized_input_admit_type_final", "checksum": {"name": "sha256", "checksum": "6330819fb560b15e1d558b7185f702d26d873b8a10b6d124440c7de7b3843bf3"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_type_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_type_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.549284, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_final", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__int_admit_type_voting') }}\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_admit_type_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_admit_type_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_type_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_normalize_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_source_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_source_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_source_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_source_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_source_final"], "alias": "_int_normalized_input_admit_source_final", "checksum": {"name": "sha256", "checksum": "236c6efeaaab916e2520cf8d8919d55fc529ca5afcfce9c9c6dc817ddcc847ed"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_source_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_source_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5460181, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_final", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__int_admit_source_voting') }}\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_admit_source_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_admit_source_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_source_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_eligibility_dates_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_eligibility_dates_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_eligibility_dates_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_eligibility_dates_normalize"], "alias": "_int_normalized_input_eligibility_dates_normalize", "checksum": {"name": "sha256", "checksum": "3243663ba7efa75eeb1ff6fd77f5c15c2ca0425437f6c7dfbfaad49dd8a55a7e"}, "config": {"enabled": true, "alias": "_int_normalized_input_eligibility_dates_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_eligibility_dates_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.566875, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_eligibility_dates_normalize", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect distinct\n elig.patient_id\n , {{ dbt.concat([\n \"elig.patient_id\",\n \"coalesce(elig.data_source,'')\",\n \"coalesce(elig.payer,'')\",\n \"coalesce(elig.\" ~ quote_column('plan') ~ \",'')\",\n \"coalesce(cast(elig.enrollment_start_date as \" ~ dbt.type_string() ~ \"),'')\",\n \"coalesce(cast(elig.enrollment_end_date as \" ~ dbt.type_string() ~ \"),'')\"\n ]) }} as patient_id_key\n , cal_dob.full_date as normalized_birth_date\n , cal_death.full_date as normalized_death_date\n , cal_enroll_start.full_date as normalized_enrollment_start_date\n , cal_enroll_end.full_date as normalized_enrollment_end_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__stg_eligibility') }} elig\nleft join {{ ref('reference_data__calendar') }} cal_dob\n on elig.birth_date = cal_dob.full_date\nleft join {{ ref('reference_data__calendar') }} cal_death\n on elig.death_date = cal_death.full_date\nleft join {{ ref('reference_data__calendar') }} cal_enroll_start\n on elig.enrollment_start_date = cal_enroll_start.full_date\nleft join {{ ref('reference_data__calendar') }} cal_enroll_end\n on elig.enrollment_end_date = cal_enroll_end.full_date", "language": "sql", "refs": [{"name": "normalized_input__stg_eligibility", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.normalized_input__stg_eligibility", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_eligibility_dates_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select distinct\n elig.patient_id\n , elig.patient_id || coalesce(elig.data_source,'') || coalesce(elig.payer,'') || coalesce(elig.plan,'') || coalesce(cast(elig.enrollment_start_date as TEXT),'') || coalesce(cast(elig.enrollment_end_date as TEXT),'') as patient_id_key\n , cal_dob.full_date as normalized_birth_date\n , cal_death.full_date as normalized_death_date\n , cal_enroll_start.full_date as normalized_enrollment_start_date\n , cal_enroll_end.full_date as normalized_enrollment_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join cms_synthetic.reference_data.calendar cal_dob\n on elig.birth_date = cal_dob.full_date\nleft join cms_synthetic.reference_data.calendar cal_death\n on elig.death_date = cal_death.full_date\nleft join cms_synthetic.reference_data.calendar cal_enroll_start\n on elig.enrollment_start_date = cal_enroll_start.full_date\nleft join cms_synthetic.reference_data.calendar cal_enroll_end\n on elig.enrollment_end_date = cal_enroll_end.full_date", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_eligibility", "sql": " __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_source_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_source_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_source_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_source_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_source_voting"], "alias": "_int_normalized_input_admit_source_voting", "checksum": {"name": "sha256", "checksum": "6ddfeafbf35ef7a9fe68c48bd39f8fc63ef3d12c5f801001fb60e68afad92491"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_source_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_source_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5477, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_voting", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\n\nwith normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_source_code\n\n , admit.admit_source_description\n from {{ ref('normalized_input__stg_medical_claim') }} med\n inner join {{ ref('terminology__admit_source') }} admit\n on med.admit_source_code = admit.admit_source_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n , count(*) as admit_source_occurrence_count\n from normalize_cte\n where admit_source_code is not null\n group by \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_source_code' as column_name\n , admit_source_code as normalized_code\n , admit_source_description as normalized_description\n , admit_source_occurrence_count as occurrence_count\n , coalesce(lead(admit_source_occurrence_count) \n over (partition by claim_id, data_source order by admit_source_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_source_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_source_voting.sql", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_source_code\n\n , admit.admit_source_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.admit_source admit\n on med.admit_source_code = admit.admit_source_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n , count(*) as admit_source_occurrence_count\n from normalize_cte\n where admit_source_code is not null\n group by \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_source_code' as column_name\n , admit_source_code as normalized_code\n , admit_source_description as normalized_description\n , admit_source_occurrence_count as occurrence_count\n , coalesce(lead(admit_source_occurrence_count) \n over (partition by claim_id, data_source order by admit_source_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_source_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_ms_drg_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_ms_drg_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_ms_drg_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_ms_drg_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_ms_drg_voting"], "alias": "_int_normalized_input_ms_drg_voting", "checksum": {"name": "sha256", "checksum": "958e04a23b1958e6e8171884549ee13ad67978f8d464263551c371a349d36ef8"}, "config": {"enabled": true, "alias": "_int_normalized_input_ms_drg_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_ms_drg_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.574074, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_voting", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , ms.ms_drg_code\n , ms.ms_drg_description\n from {{ ref('normalized_input__stg_medical_claim') }} med\n inner join {{ ref('terminology__ms_drg') }} ms\n on med.ms_drg_code = ms.ms_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , count(*) as ms_drg_occurrence_count\n from normalize_cte\n where ms_drg_code is not null\n group by \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'ms_drg_code' as column_name\n , ms_drg_code as normalized_code\n , ms_drg_description as normalized_description\n , ms_drg_occurrence_count as occurrence_count\n , coalesce(lead(ms_drg_occurrence_count) \n over (partition by claim_id, data_source order by ms_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by ms_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_ms_drg_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , ms.ms_drg_code\n , ms.ms_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.ms_drg ms\n on med.ms_drg_code = ms.ms_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , count(*) as ms_drg_occurrence_count\n from normalize_cte\n where ms_drg_code is not null\n group by \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'ms_drg_code' as column_name\n , ms_drg_code as normalized_code\n , ms_drg_description as normalized_description\n , ms_drg_occurrence_count as occurrence_count\n , coalesce(lead(ms_drg_occurrence_count) \n over (partition by claim_id, data_source order by ms_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by ms_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_discharge_disposition_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_discharge_disposition_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_discharge_disposition_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_discharge_disposition_voting"], "alias": "_int_normalized_input_discharge_disposition_voting", "checksum": {"name": "sha256", "checksum": "846a0c894b6100af9c95d9be5d6e6bb1461432ae9ee96eae5ae1d1328d1733df"}, "config": {"enabled": true, "alias": "_int_normalized_input_discharge_disposition_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_discharge_disposition_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5654552, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_voting", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , disch.discharge_disposition_code\n , disch.discharge_disposition_description\n from {{ ref('normalized_input__stg_medical_claim') }} med\n inner join {{ ref('terminology__discharge_disposition') }} disch\n on med.discharge_disposition_code = disch.discharge_disposition_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n , count(*) as discharge_disposition_occurrence_count\n from normalize_cte\n where discharge_disposition_code is not null\n group by \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'discharge_disposition_code' as column_name\n , discharge_disposition_code as normalized_code\n , discharge_disposition_description as normalized_description\n , discharge_disposition_occurrence_count as occurrence_count\n , coalesce(lead(discharge_disposition_occurrence_count) \n over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_discharge_disposition_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , disch.discharge_disposition_code\n , disch.discharge_disposition_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.discharge_disposition disch\n on med.discharge_disposition_code = disch.discharge_disposition_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n , count(*) as discharge_disposition_occurrence_count\n from normalize_cte\n where discharge_disposition_code is not null\n group by \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'discharge_disposition_code' as column_name\n , discharge_disposition_code as normalized_code\n , discharge_disposition_description as normalized_description\n , discharge_disposition_occurrence_count as occurrence_count\n , coalesce(lead(discharge_disposition_occurrence_count) \n over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_discharge_disposition_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_discharge_disposition_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_discharge_disposition_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_discharge_disposition_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_discharge_disposition_final"], "alias": "_int_normalized_input_discharge_disposition_final", "checksum": {"name": "sha256", "checksum": "38155dca5b31577926e8f9136975c8788841028b7724a682285e32e93e5f86c5"}, "config": {"enabled": true, "alias": "_int_normalized_input_discharge_disposition_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_discharge_disposition_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.563353, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_final", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__int_discharge_disposition_voting') }}\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_discharge_disposition_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_discharge_disposition_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_discharge_disposition_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_diagnosis_code_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_diagnosis_code_voting"], "alias": "_int_normalized_input_diagnosis_code_voting", "checksum": {"name": "sha256", "checksum": "d19ae69e58ccaffcf91a85e79d9dde2e838c628acf597b917be7bf34823bd738"}, "config": {"enabled": true, "alias": "_int_normalized_input_diagnosis_code_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_diagnosis_code_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5617778, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_diagnosis_code_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.diagnosis_column as column_name\r\n , norm.normalized_diagnosis_code as normalized_code\r\n , norm.diagnosis_code_occurrence_count as occurrence_count\r\n , coalesce(lead(diagnosis_code_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_diagnosis_code_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.diagnosis_column = dist.diagnosis_column", "language": "sql", "refs": [{"name": "normalized_input__int_diagnosis_code_normalize", "package": null, "version": null}, {"name": "normalized_input__int_diagnosis_code_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_diagnosis_code_normalize"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_diagnosis_code as normalized_code\n , norm.diagnosis_code_occurrence_count as occurrence_count\n , coalesce(lead(diagnosis_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_diagnosis_code_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_diagnosis_code_normalize"], "alias": "_int_normalized_input_diagnosis_code_normalize", "checksum": {"name": "sha256", "checksum": "179014e4821ac7e90ccc56a81480f28b3eaa3e970b84d32dc4c046820f42d2c8"}, "config": {"enabled": true, "alias": "_int_normalized_input_diagnosis_code_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_diagnosis_code_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.560117, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nwith pivot_diagnosis as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_1' as diagnosis_column\r\n , diagnosis_code_1 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_2' as diagnosis_column\r\n , diagnosis_code_2 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_3' as diagnosis_column\r\n , diagnosis_code_3 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_4' as diagnosis_column\r\n , diagnosis_code_4 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_5' as diagnosis_column\r\n , diagnosis_code_5 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_6' as diagnosis_column\r\n , diagnosis_code_6 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_7' as diagnosis_column\r\n , diagnosis_code_7 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_8' as diagnosis_column\r\n , diagnosis_code_8 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_9' as diagnosis_column\r\n , diagnosis_code_9 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_10' as diagnosis_column\r\n , diagnosis_code_10 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_11' as diagnosis_column\r\n , diagnosis_code_11 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_12' as diagnosis_column\r\n , diagnosis_code_12 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_13' as diagnosis_column\r\n , diagnosis_code_13 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_14' as diagnosis_column\r\n , diagnosis_code_14 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_15' as diagnosis_column\r\n , diagnosis_code_15 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_16' as diagnosis_column\r\n , diagnosis_code_16 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_17' as diagnosis_column\r\n , diagnosis_code_17 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_18' as diagnosis_column\r\n , diagnosis_code_18 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_19' as diagnosis_column\r\n , diagnosis_code_19 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_20' as diagnosis_column\r\n , diagnosis_code_20 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_21' as diagnosis_column\r\n , diagnosis_code_21 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_22' as diagnosis_column\r\n , diagnosis_code_22 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_23' as diagnosis_column\r\n , diagnosis_code_24 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_24' as diagnosis_column\r\n , diagnosis_code_24 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_25' as diagnosis_column\r\n , diagnosis_code_25 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , diagnosis_code_type\r\n , diagnosis_column\r\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm) as normalized_diagnosis_code\r\n , count(*) as diagnosis_code_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_diagnosis piv\r\nleft join {{ ref('terminology__icd_10_cm') }} icd_10\r\n on replace(piv.diagnosis_code,'.','') = icd_10.icd_10_cm\r\n and piv.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd_9\r\n on replace(piv.diagnosis_code,'.','') = icd_9.icd_9_cm\r\n and piv.diagnosis_code_type = 'icd-9-cm'\r\nwhere claim_type <> 'undetermined'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , diagnosis_code_type\r\n , diagnosis_column\r\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm)", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_diagnosis as(\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_1' as diagnosis_column\n , diagnosis_code_1 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_2' as diagnosis_column\n , diagnosis_code_2 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_3' as diagnosis_column\n , diagnosis_code_3 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_4' as diagnosis_column\n , diagnosis_code_4 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_5' as diagnosis_column\n , diagnosis_code_5 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_6' as diagnosis_column\n , diagnosis_code_6 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_7' as diagnosis_column\n , diagnosis_code_7 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_8' as diagnosis_column\n , diagnosis_code_8 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_9' as diagnosis_column\n , diagnosis_code_9 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_10' as diagnosis_column\n , diagnosis_code_10 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_11' as diagnosis_column\n , diagnosis_code_11 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_12' as diagnosis_column\n , diagnosis_code_12 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_13' as diagnosis_column\n , diagnosis_code_13 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_14' as diagnosis_column\n , diagnosis_code_14 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_15' as diagnosis_column\n , diagnosis_code_15 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_16' as diagnosis_column\n , diagnosis_code_16 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_17' as diagnosis_column\n , diagnosis_code_17 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_18' as diagnosis_column\n , diagnosis_code_18 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_19' as diagnosis_column\n , diagnosis_code_19 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_20' as diagnosis_column\n , diagnosis_code_20 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_21' as diagnosis_column\n , diagnosis_code_21 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_22' as diagnosis_column\n , diagnosis_code_22 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_23' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_24' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_25' as diagnosis_column\n , diagnosis_code_25 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm) as normalized_diagnosis_code\n , count(*) as diagnosis_code_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_diagnosis piv\nleft join cms_synthetic.terminology.icd_10_cm icd_10\n on replace(piv.diagnosis_code,'.','') = icd_10.icd_10_cm\n and piv.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd_9\n on replace(piv.diagnosis_code,'.','') = icd_9.icd_9_cm\n and piv.diagnosis_code_type = 'icd-9-cm'\nwhere claim_type <> 'undetermined'\ngroup by \n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm)", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_date_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_date_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_date_normalize"], "alias": "_int_normalized_input_procedure_date_normalize", "checksum": {"name": "sha256", "checksum": "9bf8a31a655a562600cd96451e050a1a245bbb3bbc3196162475c99d6e8f545c"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_date_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_date_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5879612, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_normalize", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_1' as procedure_column\n , procedure_date_1 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_2' as procedure_column\n , procedure_date_2 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_3' as procedure_column\n , procedure_date_3 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_4' as procedure_column\n , procedure_date_4 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_5' as procedure_column\n , procedure_date_5 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_6' as procedure_column\n , procedure_date_6 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_7' as procedure_column\n , procedure_date_7 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_8' as procedure_column\n , procedure_date_8 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_9' as procedure_column\n , procedure_date_9 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_10' as procedure_column\n , procedure_date_10 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_11' as procedure_column\n , procedure_date_11 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_12' as procedure_column\n , procedure_date_12 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_13' as procedure_column\n , procedure_date_13 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_14' as procedure_column\n , procedure_date_14 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_15' as procedure_column\n , procedure_date_15 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_16' as procedure_column\n , procedure_date_16 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_17' as procedure_column\n , procedure_date_17 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_18' as procedure_column\n , procedure_date_18 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_19' as procedure_column\n , procedure_date_19 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_20' as procedure_column\n , procedure_date_20 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_21' as procedure_column\n , procedure_date_21 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_22' as procedure_column\n , procedure_date_22 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_23' as procedure_column\n , procedure_date_23 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_24' as procedure_column\n , procedure_date_24 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_25' as procedure_column\n , procedure_date_25 as procedure_date\n from {{ ref('normalized_input__stg_medical_claim') }}\n)\n\nselect\n claim_id\n , data_source\n , procedure_column\n , cal.full_date as procedure_date\n , count(*) as procedure_date_occurrence_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom pivot_procedure piv\nleft join {{ ref('reference_data__calendar') }} cal\n on piv.procedure_date = cal.full_date\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_column\n , cal.full_date", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_1' as procedure_column\n , procedure_date_1 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_2' as procedure_column\n , procedure_date_2 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_3' as procedure_column\n , procedure_date_3 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_4' as procedure_column\n , procedure_date_4 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_5' as procedure_column\n , procedure_date_5 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_6' as procedure_column\n , procedure_date_6 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_7' as procedure_column\n , procedure_date_7 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_8' as procedure_column\n , procedure_date_8 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_9' as procedure_column\n , procedure_date_9 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_10' as procedure_column\n , procedure_date_10 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_11' as procedure_column\n , procedure_date_11 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_12' as procedure_column\n , procedure_date_12 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_13' as procedure_column\n , procedure_date_13 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_14' as procedure_column\n , procedure_date_14 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_15' as procedure_column\n , procedure_date_15 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_16' as procedure_column\n , procedure_date_16 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_17' as procedure_column\n , procedure_date_17 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_18' as procedure_column\n , procedure_date_18 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_19' as procedure_column\n , procedure_date_19 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_20' as procedure_column\n , procedure_date_20 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_21' as procedure_column\n , procedure_date_21 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_22' as procedure_column\n , procedure_date_22 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_23' as procedure_column\n , procedure_date_23 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_24' as procedure_column\n , procedure_date_24 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_25' as procedure_column\n , procedure_date_25 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_column\n , cal.full_date as procedure_date\n , count(*) as procedure_date_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join cms_synthetic.reference_data.calendar cal\n on piv.procedure_date = cal.full_date\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_column\n , cal.full_date", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_date_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_date_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_date_final"], "alias": "_int_normalized_input_procedure_date_final", "checksum": {"name": "sha256", "checksum": "b2a28ab6f81ece5f5d0721efbc53d9c732dcf4b0bc0fcfbbeec9187cdb975e41"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_date_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_date_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.586466, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when lower(column_name) = 'procedure_date_1' then normalized_code else null end) as procedure_date_1\r\n , max(case when lower(column_name) = 'procedure_date_2' then normalized_code else null end) as procedure_date_2\r\n , max(case when lower(column_name) = 'procedure_date_3' then normalized_code else null end) as procedure_date_3\r\n , max(case when lower(column_name) = 'procedure_date_4' then normalized_code else null end) as procedure_date_4\r\n , max(case when lower(column_name) = 'procedure_date_5' then normalized_code else null end) as procedure_date_5\r\n , max(case when lower(column_name) = 'procedure_date_6' then normalized_code else null end) as procedure_date_6\r\n , max(case when lower(column_name) = 'procedure_date_7' then normalized_code else null end) as procedure_date_7\r\n , max(case when lower(column_name) = 'procedure_date_8' then normalized_code else null end) as procedure_date_8\r\n , max(case when lower(column_name) = 'procedure_date_9' then normalized_code else null end) as procedure_date_9\r\n , max(case when lower(column_name) = 'procedure_date_10' then normalized_code else null end) as procedure_date_10\r\n , max(case when lower(column_name) = 'procedure_date_11' then normalized_code else null end) as procedure_date_11\r\n , max(case when lower(column_name) = 'procedure_date_12' then normalized_code else null end) as procedure_date_12\r\n , max(case when lower(column_name) = 'procedure_date_13' then normalized_code else null end) as procedure_date_13\r\n , max(case when lower(column_name) = 'procedure_date_14' then normalized_code else null end) as procedure_date_14\r\n , max(case when lower(column_name) = 'procedure_date_15' then normalized_code else null end) as procedure_date_15\r\n , max(case when lower(column_name) = 'procedure_date_16' then normalized_code else null end) as procedure_date_16\r\n , max(case when lower(column_name) = 'procedure_date_17' then normalized_code else null end) as procedure_date_17\r\n , max(case when lower(column_name) = 'procedure_date_18' then normalized_code else null end) as procedure_date_18\r\n , max(case when lower(column_name) = 'procedure_date_19' then normalized_code else null end) as procedure_date_19\r\n , max(case when lower(column_name) = 'procedure_date_20' then normalized_code else null end) as procedure_date_20\r\n , max(case when lower(column_name) = 'procedure_date_21' then normalized_code else null end) as procedure_date_21\r\n , max(case when lower(column_name) = 'procedure_date_22' then normalized_code else null end) as procedure_date_22\r\n , max(case when lower(column_name) = 'procedure_date_23' then normalized_code else null end) as procedure_date_23\r\n , max(case when lower(column_name) = 'procedure_date_24' then normalized_code else null end) as procedure_date_24\r\n , max(case when lower(column_name) = 'procedure_date_25' then normalized_code else null end) as procedure_date_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_date_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_date_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_date_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_date_final.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_date_1' then normalized_code else null end) as procedure_date_1\n , max(case when lower(column_name) = 'procedure_date_2' then normalized_code else null end) as procedure_date_2\n , max(case when lower(column_name) = 'procedure_date_3' then normalized_code else null end) as procedure_date_3\n , max(case when lower(column_name) = 'procedure_date_4' then normalized_code else null end) as procedure_date_4\n , max(case when lower(column_name) = 'procedure_date_5' then normalized_code else null end) as procedure_date_5\n , max(case when lower(column_name) = 'procedure_date_6' then normalized_code else null end) as procedure_date_6\n , max(case when lower(column_name) = 'procedure_date_7' then normalized_code else null end) as procedure_date_7\n , max(case when lower(column_name) = 'procedure_date_8' then normalized_code else null end) as procedure_date_8\n , max(case when lower(column_name) = 'procedure_date_9' then normalized_code else null end) as procedure_date_9\n , max(case when lower(column_name) = 'procedure_date_10' then normalized_code else null end) as procedure_date_10\n , max(case when lower(column_name) = 'procedure_date_11' then normalized_code else null end) as procedure_date_11\n , max(case when lower(column_name) = 'procedure_date_12' then normalized_code else null end) as procedure_date_12\n , max(case when lower(column_name) = 'procedure_date_13' then normalized_code else null end) as procedure_date_13\n , max(case when lower(column_name) = 'procedure_date_14' then normalized_code else null end) as procedure_date_14\n , max(case when lower(column_name) = 'procedure_date_15' then normalized_code else null end) as procedure_date_15\n , max(case when lower(column_name) = 'procedure_date_16' then normalized_code else null end) as procedure_date_16\n , max(case when lower(column_name) = 'procedure_date_17' then normalized_code else null end) as procedure_date_17\n , max(case when lower(column_name) = 'procedure_date_18' then normalized_code else null end) as procedure_date_18\n , max(case when lower(column_name) = 'procedure_date_19' then normalized_code else null end) as procedure_date_19\n , max(case when lower(column_name) = 'procedure_date_20' then normalized_code else null end) as procedure_date_20\n , max(case when lower(column_name) = 'procedure_date_21' then normalized_code else null end) as procedure_date_21\n , max(case when lower(column_name) = 'procedure_date_22' then normalized_code else null end) as procedure_date_22\n , max(case when lower(column_name) = 'procedure_date_23' then normalized_code else null end) as procedure_date_23\n , max(case when lower(column_name) = 'procedure_date_24' then normalized_code else null end) as procedure_date_24\n , max(case when lower(column_name) = 'procedure_date_25' then normalized_code else null end) as procedure_date_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_undetermined_claim_type": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_undetermined_claim_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_undetermined_claim_type.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_undetermined_claim_type.sql", "unique_id": "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_undetermined_claim_type"], "alias": "_int_normalized_input_undetermined_claim_type", "checksum": {"name": "sha256", "checksum": "3128edfe3c7f46a00688b24ee9ea16901ec6bf438f34754cb0a75225c0158407"}, "config": {"enabled": true, "alias": "_int_normalized_input_undetermined_claim_type", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_undetermined_claim_type", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.592463, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_undetermined_claim_type", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , {{ quote_column('plan') }}\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , ad_src.admit_source_code\n , ad_src.admit_source_description\n , ad_type.admit_type_code\n , ad_type.admit_type_description\n , dis.discharge_disposition_code\n , dis.discharge_disposition_description\n , pos.place_of_service_code\n , pos.place_of_service_description\n , tob.bill_type_code\n , tob.bill_type_description\n , msdrg.ms_drg_code\n , msdrg.ms_drg_description\n , aprdrg.apr_drg_code\n , aprdrg.apr_drg_description\n , rev.revenue_center_code\n , rev.revenue_center_description\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendnpi.npi as rendering_name\n , billing_npi\n , billnpi.npi as billing_name\n , facility_npi\n , facnpi.npi as facility_name\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\nleft join {{ ref('terminology__admit_source')}} ad_src\n on med.admit_source_code = ad_src.admit_source_code\nleft join {{ ref('terminology__admit_type')}} ad_type\n on med.admit_type_code = ad_type.admit_type_code\nleft join {{ ref('terminology__discharge_disposition')}} dis\n on med.discharge_disposition_code = dis.discharge_disposition_code\nleft join {{ ref('terminology__place_of_service')}} pos\n on med.place_of_service_code = pos.place_of_service_code\nleft join {{ ref('terminology__bill_type')}} tob\n on med.bill_type_code = tob.bill_type_code\nleft join {{ ref('terminology__ms_drg')}} msdrg\n on med.ms_drg_code = msdrg.ms_drg_code\nleft join {{ ref('terminology__apr_drg')}} aprdrg\n on med.apr_drg_code = aprdrg.apr_drg_code\nleft join {{ ref('terminology__revenue_center')}} rev\n on med.revenue_center_code = rev.revenue_center_code\nleft join {{ ref('terminology__provider')}} rendnpi\n on med.rendering_npi = rendnpi.npi\nleft join {{ ref('terminology__provider')}} billnpi\n on med.billing_npi = billnpi.npi\nleft join {{ ref('terminology__provider')}} facnpi\n on med.facility_npi = facnpi.npi\nwhere claim_type in ('undetermined')", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__revenue_center", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_undetermined_claim_type.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , ad_src.admit_source_code\n , ad_src.admit_source_description\n , ad_type.admit_type_code\n , ad_type.admit_type_description\n , dis.discharge_disposition_code\n , dis.discharge_disposition_description\n , pos.place_of_service_code\n , pos.place_of_service_description\n , tob.bill_type_code\n , tob.bill_type_description\n , msdrg.ms_drg_code\n , msdrg.ms_drg_description\n , aprdrg.apr_drg_code\n , aprdrg.apr_drg_description\n , rev.revenue_center_code\n , rev.revenue_center_description\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendnpi.npi as rendering_name\n , billing_npi\n , billnpi.npi as billing_name\n , facility_npi\n , facnpi.npi as facility_name\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.admit_source ad_src\n on med.admit_source_code = ad_src.admit_source_code\nleft join cms_synthetic.terminology.admit_type ad_type\n on med.admit_type_code = ad_type.admit_type_code\nleft join cms_synthetic.terminology.discharge_disposition dis\n on med.discharge_disposition_code = dis.discharge_disposition_code\nleft join cms_synthetic.terminology.place_of_service pos\n on med.place_of_service_code = pos.place_of_service_code\nleft join cms_synthetic.terminology.bill_type tob\n on med.bill_type_code = tob.bill_type_code\nleft join cms_synthetic.terminology.ms_drg msdrg\n on med.ms_drg_code = msdrg.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg aprdrg\n on med.apr_drg_code = aprdrg.apr_drg_code\nleft join cms_synthetic.terminology.revenue_center rev\n on med.revenue_center_code = rev.revenue_center_code\nleft join cms_synthetic.terminology.provider rendnpi\n on med.rendering_npi = rendnpi.npi\nleft join cms_synthetic.terminology.provider billnpi\n on med.billing_npi = billnpi.npi\nleft join cms_synthetic.terminology.provider facnpi\n on med.facility_npi = facnpi.npi\nwhere claim_type in ('undetermined')", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_code_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_code_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_code_final"], "alias": "_int_normalized_input_procedure_code_final", "checksum": {"name": "sha256", "checksum": "7bdf91705a81d2db2c780dbd651d62835213dfde60545b4e567df4b69ff0d9fe"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_code_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_code_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.581755, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when lower(column_name) = 'procedure_code_1' then normalized_code else null end) as procedure_code_1\r\n , max(case when lower(column_name) = 'procedure_code_2' then normalized_code else null end) as procedure_code_2\r\n , max(case when lower(column_name) = 'procedure_code_3' then normalized_code else null end) as procedure_code_3\r\n , max(case when lower(column_name) = 'procedure_code_4' then normalized_code else null end) as procedure_code_4\r\n , max(case when lower(column_name) = 'procedure_code_5' then normalized_code else null end) as procedure_code_5\r\n , max(case when lower(column_name) = 'procedure_code_6' then normalized_code else null end) as procedure_code_6\r\n , max(case when lower(column_name) = 'procedure_code_7' then normalized_code else null end) as procedure_code_7\r\n , max(case when lower(column_name) = 'procedure_code_8' then normalized_code else null end) as procedure_code_8\r\n , max(case when lower(column_name) = 'procedure_code_9' then normalized_code else null end) as procedure_code_9\r\n , max(case when lower(column_name) = 'procedure_code_10' then normalized_code else null end) as procedure_code_10\r\n , max(case when lower(column_name) = 'procedure_code_11' then normalized_code else null end) as procedure_code_11\r\n , max(case when lower(column_name) = 'procedure_code_12' then normalized_code else null end) as procedure_code_12\r\n , max(case when lower(column_name) = 'procedure_code_13' then normalized_code else null end) as procedure_code_13\r\n , max(case when lower(column_name) = 'procedure_code_14' then normalized_code else null end) as procedure_code_14\r\n , max(case when lower(column_name) = 'procedure_code_15' then normalized_code else null end) as procedure_code_15\r\n , max(case when lower(column_name) = 'procedure_code_16' then normalized_code else null end) as procedure_code_16\r\n , max(case when lower(column_name) = 'procedure_code_17' then normalized_code else null end) as procedure_code_17\r\n , max(case when lower(column_name) = 'procedure_code_18' then normalized_code else null end) as procedure_code_18\r\n , max(case when lower(column_name) = 'procedure_code_19' then normalized_code else null end) as procedure_code_19\r\n , max(case when lower(column_name) = 'procedure_code_20' then normalized_code else null end) as procedure_code_20\r\n , max(case when lower(column_name) = 'procedure_code_21' then normalized_code else null end) as procedure_code_21\r\n , max(case when lower(column_name) = 'procedure_code_22' then normalized_code else null end) as procedure_code_22\r\n , max(case when lower(column_name) = 'procedure_code_23' then normalized_code else null end) as procedure_code_23\r\n , max(case when lower(column_name) = 'procedure_code_24' then normalized_code else null end) as procedure_code_24\r\n , max(case when lower(column_name) = 'procedure_code_25' then normalized_code else null end) as procedure_code_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_code_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_code_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_code_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_final.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_code_1' then normalized_code else null end) as procedure_code_1\n , max(case when lower(column_name) = 'procedure_code_2' then normalized_code else null end) as procedure_code_2\n , max(case when lower(column_name) = 'procedure_code_3' then normalized_code else null end) as procedure_code_3\n , max(case when lower(column_name) = 'procedure_code_4' then normalized_code else null end) as procedure_code_4\n , max(case when lower(column_name) = 'procedure_code_5' then normalized_code else null end) as procedure_code_5\n , max(case when lower(column_name) = 'procedure_code_6' then normalized_code else null end) as procedure_code_6\n , max(case when lower(column_name) = 'procedure_code_7' then normalized_code else null end) as procedure_code_7\n , max(case when lower(column_name) = 'procedure_code_8' then normalized_code else null end) as procedure_code_8\n , max(case when lower(column_name) = 'procedure_code_9' then normalized_code else null end) as procedure_code_9\n , max(case when lower(column_name) = 'procedure_code_10' then normalized_code else null end) as procedure_code_10\n , max(case when lower(column_name) = 'procedure_code_11' then normalized_code else null end) as procedure_code_11\n , max(case when lower(column_name) = 'procedure_code_12' then normalized_code else null end) as procedure_code_12\n , max(case when lower(column_name) = 'procedure_code_13' then normalized_code else null end) as procedure_code_13\n , max(case when lower(column_name) = 'procedure_code_14' then normalized_code else null end) as procedure_code_14\n , max(case when lower(column_name) = 'procedure_code_15' then normalized_code else null end) as procedure_code_15\n , max(case when lower(column_name) = 'procedure_code_16' then normalized_code else null end) as procedure_code_16\n , max(case when lower(column_name) = 'procedure_code_17' then normalized_code else null end) as procedure_code_17\n , max(case when lower(column_name) = 'procedure_code_18' then normalized_code else null end) as procedure_code_18\n , max(case when lower(column_name) = 'procedure_code_19' then normalized_code else null end) as procedure_code_19\n , max(case when lower(column_name) = 'procedure_code_20' then normalized_code else null end) as procedure_code_20\n , max(case when lower(column_name) = 'procedure_code_21' then normalized_code else null end) as procedure_code_21\n , max(case when lower(column_name) = 'procedure_code_22' then normalized_code else null end) as procedure_code_22\n , max(case when lower(column_name) = 'procedure_code_23' then normalized_code else null end) as procedure_code_23\n , max(case when lower(column_name) = 'procedure_code_24' then normalized_code else null end) as procedure_code_24\n , max(case when lower(column_name) = 'procedure_code_25' then normalized_code else null end) as procedure_code_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_apr_drg_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_apr_drg_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_apr_drg_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_apr_drg_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_apr_drg_voting"], "alias": "_int_normalized_input_apr_drg_voting", "checksum": {"name": "sha256", "checksum": "63c62ec7400d32156dba49b1af49db0f5b563736a37b4c53fb78d9b1059c2ae4"}, "config": {"enabled": true, "alias": "_int_normalized_input_apr_drg_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_apr_drg_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.553868, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_voting", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith normalize_cte as(\n\n select \n med.claim_id\n , med.data_source\n , apr.apr_drg_code\n , apr.apr_drg_description\n from {{ ref('normalized_input__stg_medical_claim') }} med\n inner join {{ ref('terminology__apr_drg') }} apr\n on med.apr_drg_code = apr.apr_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n , count(*) as apr_drg_occurrence_count\n from normalize_cte\n where apr_drg_code is not null\n group by \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'apr_drg_code' as column_name\n , apr_drg_code as normalized_code\n , apr_drg_description as normalized_description\n , apr_drg_occurrence_count as occurrence_count\n , coalesce(lead(apr_drg_occurrence_count) \n over (partition by claim_id, data_source order by apr_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by apr_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_apr_drg_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n\n select \n med.claim_id\n , med.data_source\n , apr.apr_drg_code\n , apr.apr_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.apr_drg apr\n on med.apr_drg_code = apr.apr_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n , count(*) as apr_drg_occurrence_count\n from normalize_cte\n where apr_drg_code is not null\n group by \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'apr_drg_code' as column_name\n , apr_drg_code as normalized_code\n , apr_drg_description as normalized_description\n , apr_drg_occurrence_count as occurrence_count\n , coalesce(lead(apr_drg_occurrence_count) \n over (partition by claim_id, data_source order by apr_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by apr_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_ms_drg_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_ms_drg_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_ms_drg_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_ms_drg_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_ms_drg_final"], "alias": "_int_normalized_input_ms_drg_final", "checksum": {"name": "sha256", "checksum": "3d46adc20cae2e32d259897a95675920c6b9166bae6fa5f1acfc7903bfefed39"}, "config": {"enabled": true, "alias": "_int_normalized_input_ms_drg_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_ms_drg_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.572646, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_final", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__int_ms_drg_voting') }}\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_ms_drg_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_ms_drg_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_ms_drg_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_type_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_type_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_type_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_type_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_type_voting"], "alias": "_int_normalized_input_admit_type_normalize_voting", "checksum": {"name": "sha256", "checksum": "54fea3c172b0bdfb9b5de7bcf8c4b9b40d503b4b6673e49930f4fcc350ea2188"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_type_normalize_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_type_normalize_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5506701, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_normalize_voting", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_type_code\n , admit.admit_type_description\n from {{ ref('normalized_input__stg_medical_claim') }} med\n inner join {{ ref('terminology__admit_type') }} admit\n on med.admit_type_code = admit.admit_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n , count(*) as admit_type_occurrence_count\n from normalize_cte\n\n where admit_type_code is not null\n group by \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_type_code' as column_name\n , admit_type_code as normalized_code\n , admit_type_description as normalized_description\n , admit_type_occurrence_count as occurrence_count\n , coalesce(lead(admit_type_occurrence_count) \n over (partition by claim_id, data_source order by admit_type_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_type_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_admit_type_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_type_code\n , admit.admit_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.admit_type admit\n on med.admit_type_code = admit.admit_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n , count(*) as admit_type_occurrence_count\n from normalize_cte\n\n where admit_type_code is not null\n group by \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_type_code' as column_name\n , admit_type_code as normalized_code\n , admit_type_description as normalized_description\n , admit_type_occurrence_count as occurrence_count\n , coalesce(lead(admit_type_occurrence_count) \n over (partition by claim_id, data_source order by admit_type_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_type_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_present_on_admit_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_present_on_admit_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_present_on_admit_voting"], "alias": "_int_normalized_input_present_on_admit_voting", "checksum": {"name": "sha256", "checksum": "eb0123290dd8ea0f0222f45ce161e6163f5db9b1bedb124f334a8419b2fa9e9a"}, "config": {"enabled": true, "alias": "_int_normalized_input_present_on_admit_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_present_on_admit_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5804422, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_present_on_admit_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.diagnosis_column as column_name\r\n , norm.normalized_present_on_admit_code as normalized_code\r\n , norm.present_on_admit_occurrence_count as occurrence_count\r\n , coalesce(lead(present_on_admit_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_present_on_admit_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.diagnosis_column = dist.diagnosis_column", "language": "sql", "refs": [{"name": "normalized_input__int_present_on_admit_normalize", "package": null, "version": null}, {"name": "normalized_input__int_present_on_admit_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_present_on_admit_normalize"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_present_on_admit_code as normalized_code\n , norm.present_on_admit_occurrence_count as occurrence_count\n , coalesce(lead(present_on_admit_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_code_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_code_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_code_normalize"], "alias": "_int_normalized_input_procedure_code_normalize", "checksum": {"name": "sha256", "checksum": "373c2c62f9bea674fe68fa7a35b0af32019e0efd086302c3e9733f468ff56c8f"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_code_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_code_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.5830379, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith pivot_procedure as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_1' as procedure_column\r\n , procedure_code_1 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_2' as procedure_column\r\n , procedure_code_2 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_3' as procedure_column\r\n , procedure_code_3 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_4' as procedure_column\r\n , procedure_code_4 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_5' as procedure_column\r\n , procedure_code_5 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_6' as procedure_column\r\n , procedure_code_6 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_7' as procedure_column\r\n , procedure_code_7 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_8' as procedure_column\r\n , procedure_code_8 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_9' as procedure_column\r\n , procedure_code_9 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_10' as procedure_column\r\n , procedure_code_10 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_11' as procedure_column\r\n , procedure_code_11 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_12' as procedure_column\r\n , procedure_code_12 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_13' as procedure_column\r\n , procedure_code_13 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_14' as procedure_column\r\n , procedure_code_14 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_15' as procedure_column\r\n , procedure_code_15 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_16' as procedure_column\r\n , procedure_code_16 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_17' as procedure_column\r\n , procedure_code_17 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_18' as procedure_column\r\n , procedure_code_18 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_19' as procedure_column\r\n , procedure_code_19 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_20' as procedure_column\r\n , procedure_code_20 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_21' as procedure_column\r\n , procedure_code_21 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_22' as procedure_column\r\n , procedure_code_22 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_23' as procedure_column\r\n , procedure_code_23 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_24' as procedure_column\r\n , procedure_code_24 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_25' as procedure_column\r\n , procedure_code_25 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , procedure_code_type\r\n , procedure_column\r\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs) as normalized_procedure_code\r\n , count(*) as procedure_code_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_procedure piv\r\nleft join {{ ref('terminology__icd_10_pcs') }} icd_10\r\n on replace(piv.procedure_code,'.','') = icd_10.icd_10_pcs\r\n and piv.procedure_code_type = 'icd-10-pcs'\r\nleft join {{ ref('terminology__icd_9_pcs') }} icd_9\r\n on replace(piv.procedure_code,'.','') = icd_9.icd_9_pcs\r\n and piv.procedure_code_type = 'icd-9-pcs'\r\nwhere claim_type = 'institutional'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , procedure_code_type\r\n , procedure_column\r\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs)", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_1' as procedure_column\n , procedure_code_1 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_2' as procedure_column\n , procedure_code_2 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_3' as procedure_column\n , procedure_code_3 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_4' as procedure_column\n , procedure_code_4 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_5' as procedure_column\n , procedure_code_5 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_6' as procedure_column\n , procedure_code_6 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_7' as procedure_column\n , procedure_code_7 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_8' as procedure_column\n , procedure_code_8 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_9' as procedure_column\n , procedure_code_9 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_10' as procedure_column\n , procedure_code_10 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_11' as procedure_column\n , procedure_code_11 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_12' as procedure_column\n , procedure_code_12 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_13' as procedure_column\n , procedure_code_13 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_14' as procedure_column\n , procedure_code_14 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_15' as procedure_column\n , procedure_code_15 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_16' as procedure_column\n , procedure_code_16 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_17' as procedure_column\n , procedure_code_17 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_18' as procedure_column\n , procedure_code_18 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_19' as procedure_column\n , procedure_code_19 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_20' as procedure_column\n , procedure_code_20 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_21' as procedure_column\n , procedure_code_21 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_22' as procedure_column\n , procedure_code_22 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_23' as procedure_column\n , procedure_code_23 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_24' as procedure_column\n , procedure_code_24 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_25' as procedure_column\n , procedure_code_25 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs) as normalized_procedure_code\n , count(*) as procedure_code_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join cms_synthetic.terminology.icd_10_pcs icd_10\n on replace(piv.procedure_code,'.','') = icd_10.icd_10_pcs\n and piv.procedure_code_type = 'icd-10-pcs'\nleft join cms_synthetic.terminology.icd_9_pcs icd_9\n on replace(piv.procedure_code,'.','') = icd_9.icd_9_pcs\n and piv.procedure_code_type = 'icd-9-pcs'\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs)", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_bill_type_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_bill_type_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_bill_type_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_bill_type_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_bill_type_final"], "alias": "_int_normalized_input_bill_type_final", "checksum": {"name": "sha256", "checksum": "65f80b9ef24d2df8a68c653ea030d60955ffa4f16a3903e238d73b5f725cdf56"}, "config": {"enabled": true, "alias": "_int_normalized_input_bill_type_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_bill_type_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.555264, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_final", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__int_bill_type_voting') }}\nwhere occurrence_row_count = 1", "language": "sql", "refs": [{"name": "normalized_input__int_bill_type_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_bill_type_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_bill_type_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_voting\nwhere occurrence_row_count = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_bill_type_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_bill_type_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_bill_type_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_bill_type_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_bill_type_voting"], "alias": "_int_normalized_input_bill_type_voting", "checksum": {"name": "sha256", "checksum": "a014341dec6ed55c5d0cfddb8ad2bfec8451c204cef91c13667c5aab602e776b"}, "config": {"enabled": true, "alias": "_int_normalized_input_bill_type_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_bill_type_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.556881, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_voting", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , bill.bill_type_code\n , bill.bill_type_description\n from {{ ref('normalized_input__stg_medical_claim') }} med\n inner join {{ ref('terminology__bill_type') }} bill\n on {{ ltrim('med.bill_type_code', '0') }} = bill.bill_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n , count(*) as bill_type_occurrence_count\n from normalize_cte\n where bill_type_code is not null\n group by \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'bill_type_code' as column_name\n , bill_type_code as normalized_code\n , bill_type_description as normalized_description\n , bill_type_occurrence_count as occurrence_count\n , row_number() over (partition by claim_id, data_source order by bill_type_occurrence_count desc, bill_type_code asc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.ltrim"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_bill_type_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , bill.bill_type_code\n , bill.bill_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.bill_type bill\n on ltrim(med.bill_type_code, '0') = bill.bill_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n , count(*) as bill_type_occurrence_count\n from normalize_cte\n where bill_type_code is not null\n group by \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'bill_type_code' as column_name\n , bill_type_code as normalized_code\n , bill_type_description as normalized_description\n , bill_type_occurrence_count as occurrence_count\n , row_number() over (partition by claim_id, data_source order by bill_type_occurrence_count desc, bill_type_code asc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_present_on_admit_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_present_on_admit_normalize"], "alias": "_int_normalized_input_present_on_admit_normalize", "checksum": {"name": "sha256", "checksum": "bddfc433eda6677655f5ce0809136b91f5451863ff74e71b69b55e02f7321643"}, "config": {"enabled": true, "alias": "_int_normalized_input_present_on_admit_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_present_on_admit_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.579008, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nwith pivot_poa as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_1' as diagnosis_column\r\n , diagnosis_poa_1 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_2' as diagnosis_column\r\n , diagnosis_poa_2 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_3' as diagnosis_column\r\n , diagnosis_poa_3 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_4' as diagnosis_column\r\n , diagnosis_poa_4 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_5' as diagnosis_column\r\n , diagnosis_poa_5 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_6' as diagnosis_column\r\n , diagnosis_poa_6 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_7' as diagnosis_column\r\n , diagnosis_poa_7 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_8' as diagnosis_column\r\n , diagnosis_poa_8 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_9' as diagnosis_column\r\n , diagnosis_poa_9 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_10' as diagnosis_column\r\n , diagnosis_poa_10 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_11' as diagnosis_column\r\n , diagnosis_poa_11 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_12' as diagnosis_column\r\n , diagnosis_poa_12 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_13' as diagnosis_column\r\n , diagnosis_poa_13 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_14' as diagnosis_column\r\n , diagnosis_poa_14 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_15' as diagnosis_column\r\n , diagnosis_poa_15 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_16' as diagnosis_column\r\n , diagnosis_poa_16 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_17' as diagnosis_column\r\n , diagnosis_poa_17 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_18' as diagnosis_column\r\n , diagnosis_poa_18 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_19' as diagnosis_column\r\n , diagnosis_poa_19 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_20' as diagnosis_column\r\n , diagnosis_poa_20 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_21' as diagnosis_column\r\n , diagnosis_poa_21 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_22' as diagnosis_column\r\n , diagnosis_poa_22 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_23' as diagnosis_column\r\n , diagnosis_poa_24 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_24' as diagnosis_column\r\n , diagnosis_poa_24 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_25' as diagnosis_column\r\n , diagnosis_poa_25 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , poa.present_on_admit_code as normalized_present_on_admit_code\r\n , count(*) as present_on_admit_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_poa piv\r\nleft join {{ ref('terminology__present_on_admission') }} poa\r\n on replace(piv.present_on_admit_code,'.','') = poa.present_on_admit_code\r\nwhere claim_type = 'institutional'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , poa.present_on_admit_code", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__present_on_admission", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__present_on_admission"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_present_on_admit_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_poa as(\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_1' as diagnosis_column\n , diagnosis_poa_1 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_2' as diagnosis_column\n , diagnosis_poa_2 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_3' as diagnosis_column\n , diagnosis_poa_3 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_4' as diagnosis_column\n , diagnosis_poa_4 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_5' as diagnosis_column\n , diagnosis_poa_5 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_6' as diagnosis_column\n , diagnosis_poa_6 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_7' as diagnosis_column\n , diagnosis_poa_7 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_8' as diagnosis_column\n , diagnosis_poa_8 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_9' as diagnosis_column\n , diagnosis_poa_9 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_10' as diagnosis_column\n , diagnosis_poa_10 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_11' as diagnosis_column\n , diagnosis_poa_11 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_12' as diagnosis_column\n , diagnosis_poa_12 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_13' as diagnosis_column\n , diagnosis_poa_13 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_14' as diagnosis_column\n , diagnosis_poa_14 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_15' as diagnosis_column\n , diagnosis_poa_15 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_16' as diagnosis_column\n , diagnosis_poa_16 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_17' as diagnosis_column\n , diagnosis_poa_17 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_18' as diagnosis_column\n , diagnosis_poa_18 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_19' as diagnosis_column\n , diagnosis_poa_19 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_20' as diagnosis_column\n , diagnosis_poa_20 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_21' as diagnosis_column\n , diagnosis_poa_21 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_22' as diagnosis_column\n , diagnosis_poa_22 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_23' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_24' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_25' as diagnosis_column\n , diagnosis_poa_25 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code as normalized_present_on_admit_code\n , count(*) as present_on_admit_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_poa piv\nleft join cms_synthetic.terminology.present_on_admission poa\n on replace(piv.present_on_admit_code,'.','') = poa.present_on_admit_code\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_place_of_service_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_place_of_service_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_place_of_service_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_place_of_service_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_place_of_service_normalize"], "alias": "_int_normalized_input_place_of_service_normalize", "checksum": {"name": "sha256", "checksum": "9ec4d73bd278da5a7c915908a4f6a614ac71bb215a18f150a76d2d4103f2925d"}, "config": {"enabled": true, "alias": "_int_normalized_input_place_of_service_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_place_of_service_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.57569, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_place_of_service_normalize", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect\n claim_id\n , claim_line_number\n , data_source\n , pos.place_of_service_code as normalized_code\n , pos.place_of_service_description as normalized_description\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\nleft join {{ ref('terminology__place_of_service') }} pos\n {% if target.type == 'fabric' %}\n on RIGHT(REPLICATE('0', 2) + med.place_of_service_code, 2) = pos.place_of_service_code\n {% else %}\n on lpad(med.place_of_service_code, 2, '0') = pos.place_of_service_code\n {% endif %}\nwhere claim_type = 'professional'", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__place_of_service"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_place_of_service_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , pos.place_of_service_code as normalized_code\n , pos.place_of_service_description as normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.place_of_service pos\n \n on lpad(med.place_of_service_code, 2, '0') = pos.place_of_service_code\n \nwhere claim_type = 'professional'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_medical_npi_normalize": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_medical_npi_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_npi_normalize.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_npi_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_medical_npi_normalize"], "alias": "_int_normalized_input_medical_npi_normalize", "checksum": {"name": "sha256", "checksum": "f7a6d3c538744cfe3e709244fee3db3286639a12a1f4a1a08c1b68cc00dd4c57"}, "config": {"enabled": true, "alias": "_int_normalized_input_medical_npi_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_medical_npi_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.571362, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_medical_npi_normalize", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , rend_prov.npi as normalized_rendering_npi\n , cast(coalesce({{ dbt.concat([\"rend_prov.provider_last_name\", \"', '\", \"rend_prov.provider_first_name\"]) }}, rend_prov.provider_organization_name) as {{ dbt.type_string() }} ) as normalized_rendering_name\n , bill_prov.npi as normalized_billing_npi\n , cast(coalesce({{ dbt.concat([\"bill_prov.provider_last_name\", \"', '\", \"bill_prov.provider_first_name\"]) }}, bill_prov.provider_organization_name) as {{ dbt.type_string() }} ) as normalized_billing_name\n , fac_prov.npi as normalized_facility_npi\n , cast(coalesce({{ dbt.concat([\"fac_prov.provider_last_name\", \"', '\", \"fac_prov.provider_first_name\"]) }}, fac_prov.provider_organization_name) as {{ dbt.type_string() }} ) as normalized_facility_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\nleft join {{ ref('terminology__provider') }} rend_prov\n on med.rendering_npi = rend_prov.npi\n and rend_prov.entity_type_description = 'Individual'\nleft join {{ ref('terminology__provider') }} bill_prov\n on med.billing_npi = bill_prov.npi\nleft join {{ ref('terminology__provider') }} fac_prov\n on med.facility_npi = fac_prov.npi\n and fac_prov.entity_type_description = 'Organization'\n and med.claim_type = 'institutional'", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_medical_npi_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , rend_prov.npi as normalized_rendering_npi\n , cast(coalesce(rend_prov.provider_last_name || ', ' || rend_prov.provider_first_name, rend_prov.provider_organization_name) as TEXT ) as normalized_rendering_name\n , bill_prov.npi as normalized_billing_npi\n , cast(coalesce(bill_prov.provider_last_name || ', ' || bill_prov.provider_first_name, bill_prov.provider_organization_name) as TEXT ) as normalized_billing_name\n , fac_prov.npi as normalized_facility_npi\n , cast(coalesce(fac_prov.provider_last_name || ', ' || fac_prov.provider_first_name, fac_prov.provider_organization_name) as TEXT ) as normalized_facility_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.provider rend_prov\n on med.rendering_npi = rend_prov.npi\n and rend_prov.entity_type_description = 'Individual'\nleft join cms_synthetic.terminology.provider bill_prov\n on med.billing_npi = bill_prov.npi\nleft join cms_synthetic.terminology.provider fac_prov\n on med.facility_npi = fac_prov.npi\n and fac_prov.entity_type_description = 'Organization'\n and med.claim_type = 'institutional'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_diagnosis_code_final": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_diagnosis_code_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_final.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_diagnosis_code_final"], "alias": "_int_normalized_input_diagnosis_code_final", "checksum": {"name": "sha256", "checksum": "833f3dc13b44d2155cc4bfe573841485e4c4b44a1d6cf6ecf9d0b39f91712fcf"}, "config": {"enabled": true, "alias": "_int_normalized_input_diagnosis_code_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_diagnosis_code_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.558497, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when lower(column_name) = 'diagnosis_code_1' then normalized_code else null end) as diagnosis_code_1\r\n , max(case when lower(column_name) = 'diagnosis_code_2' then normalized_code else null end) as diagnosis_code_2\r\n , max(case when lower(column_name) = 'diagnosis_code_3' then normalized_code else null end) as diagnosis_code_3\r\n , max(case when lower(column_name) = 'diagnosis_code_4' then normalized_code else null end) as diagnosis_code_4\r\n , max(case when lower(column_name) = 'diagnosis_code_5' then normalized_code else null end) as diagnosis_code_5\r\n , max(case when lower(column_name) = 'diagnosis_code_6' then normalized_code else null end) as diagnosis_code_6\r\n , max(case when lower(column_name) = 'diagnosis_code_7' then normalized_code else null end) as diagnosis_code_7\r\n , max(case when lower(column_name) = 'diagnosis_code_8' then normalized_code else null end) as diagnosis_code_8\r\n , max(case when lower(column_name) = 'diagnosis_code_9' then normalized_code else null end) as diagnosis_code_9\r\n , max(case when lower(column_name) = 'diagnosis_code_10' then normalized_code else null end) as diagnosis_code_10\r\n , max(case when lower(column_name) = 'diagnosis_code_11' then normalized_code else null end) as diagnosis_code_11\r\n , max(case when lower(column_name) = 'diagnosis_code_12' then normalized_code else null end) as diagnosis_code_12\r\n , max(case when lower(column_name) = 'diagnosis_code_13' then normalized_code else null end) as diagnosis_code_13\r\n , max(case when lower(column_name) = 'diagnosis_code_14' then normalized_code else null end) as diagnosis_code_14\r\n , max(case when lower(column_name) = 'diagnosis_code_15' then normalized_code else null end) as diagnosis_code_15\r\n , max(case when lower(column_name) = 'diagnosis_code_16' then normalized_code else null end) as diagnosis_code_16\r\n , max(case when lower(column_name) = 'diagnosis_code_17' then normalized_code else null end) as diagnosis_code_17\r\n , max(case when lower(column_name) = 'diagnosis_code_18' then normalized_code else null end) as diagnosis_code_18\r\n , max(case when lower(column_name) = 'diagnosis_code_19' then normalized_code else null end) as diagnosis_code_19\r\n , max(case when lower(column_name) = 'diagnosis_code_20' then normalized_code else null end) as diagnosis_code_20\r\n , max(case when lower(column_name) = 'diagnosis_code_21' then normalized_code else null end) as diagnosis_code_21\r\n , max(case when lower(column_name) = 'diagnosis_code_22' then normalized_code else null end) as diagnosis_code_22\r\n , max(case when lower(column_name) = 'diagnosis_code_23' then normalized_code else null end) as diagnosis_code_23\r\n , max(case when lower(column_name) = 'diagnosis_code_24' then normalized_code else null end) as diagnosis_code_24\r\n , max(case when lower(column_name) = 'diagnosis_code_25' then normalized_code else null end) as diagnosis_code_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_diagnosis_code_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_diagnosis_code_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_diagnosis_code_voting"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_diagnosis_code_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'diagnosis_code_1' then normalized_code else null end) as diagnosis_code_1\n , max(case when lower(column_name) = 'diagnosis_code_2' then normalized_code else null end) as diagnosis_code_2\n , max(case when lower(column_name) = 'diagnosis_code_3' then normalized_code else null end) as diagnosis_code_3\n , max(case when lower(column_name) = 'diagnosis_code_4' then normalized_code else null end) as diagnosis_code_4\n , max(case when lower(column_name) = 'diagnosis_code_5' then normalized_code else null end) as diagnosis_code_5\n , max(case when lower(column_name) = 'diagnosis_code_6' then normalized_code else null end) as diagnosis_code_6\n , max(case when lower(column_name) = 'diagnosis_code_7' then normalized_code else null end) as diagnosis_code_7\n , max(case when lower(column_name) = 'diagnosis_code_8' then normalized_code else null end) as diagnosis_code_8\n , max(case when lower(column_name) = 'diagnosis_code_9' then normalized_code else null end) as diagnosis_code_9\n , max(case when lower(column_name) = 'diagnosis_code_10' then normalized_code else null end) as diagnosis_code_10\n , max(case when lower(column_name) = 'diagnosis_code_11' then normalized_code else null end) as diagnosis_code_11\n , max(case when lower(column_name) = 'diagnosis_code_12' then normalized_code else null end) as diagnosis_code_12\n , max(case when lower(column_name) = 'diagnosis_code_13' then normalized_code else null end) as diagnosis_code_13\n , max(case when lower(column_name) = 'diagnosis_code_14' then normalized_code else null end) as diagnosis_code_14\n , max(case when lower(column_name) = 'diagnosis_code_15' then normalized_code else null end) as diagnosis_code_15\n , max(case when lower(column_name) = 'diagnosis_code_16' then normalized_code else null end) as diagnosis_code_16\n , max(case when lower(column_name) = 'diagnosis_code_17' then normalized_code else null end) as diagnosis_code_17\n , max(case when lower(column_name) = 'diagnosis_code_18' then normalized_code else null end) as diagnosis_code_18\n , max(case when lower(column_name) = 'diagnosis_code_19' then normalized_code else null end) as diagnosis_code_19\n , max(case when lower(column_name) = 'diagnosis_code_20' then normalized_code else null end) as diagnosis_code_20\n , max(case when lower(column_name) = 'diagnosis_code_21' then normalized_code else null end) as diagnosis_code_21\n , max(case when lower(column_name) = 'diagnosis_code_22' then normalized_code else null end) as diagnosis_code_22\n , max(case when lower(column_name) = 'diagnosis_code_23' then normalized_code else null end) as diagnosis_code_23\n , max(case when lower(column_name) = 'diagnosis_code_24' then normalized_code else null end) as diagnosis_code_24\n , max(case when lower(column_name) = 'diagnosis_code_25' then normalized_code else null end) as diagnosis_code_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_code_voting": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_code_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_voting.sql", "original_file_path": "models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_code_voting"], "alias": "_int_normalized_input_procedure_code_voting", "checksum": {"name": "sha256", "checksum": "bece822a93f1ddeb86cf9da2b160d157ccaae782c9f481d29e2f8725bfff79ef"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_code_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_code_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.584773, "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_procedure_code_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.procedure_column as column_name\r\n , norm.normalized_procedure_code as normalized_code\r\n , norm.procedure_code_occurrence_count as occurrence_count\r\n , coalesce(lead(procedure_code_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_code_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.procedure_column = dist.procedure_column", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_code_normalize", "package": null, "version": null}, {"name": "normalized_input__int_procedure_code_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_code_normalize"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/normalized_input/intermediate/normalized_input__int_procedure_code_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.normalized_procedure_code as normalized_code\n , norm.procedure_code_occurrence_count as occurrence_count\n , coalesce(lead(procedure_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "claims_enrollment__flag_claims_with_enrollment", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/claims_enrollment/claims_enrollment__flag_claims_with_enrollment.sql", "original_file_path": "models/claims_preprocessing/claims_enrollment/claims_enrollment__flag_claims_with_enrollment.sql", "unique_id": "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "fqn": ["the_tuva_project", "claims_preprocessing", "claims_enrollment", "claims_enrollment__flag_claims_with_enrollment"], "alias": "flag_claims_with_enrollment", "checksum": {"name": "sha256", "checksum": "0715c836232894c432bee48c930b27a9b584820db0cb64570cfb3434a72be723"}, "config": {"enabled": true, "alias": "flag_claims_with_enrollment", "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing"], "description": "This table contains claims with matching enrollment", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_start_year_month": {"name": "inferred_claim_start_year_month", "description": "The claim start date year and month. If claim line start date is missing then the following column will be used, \nin the following order if also NULL: claim start date, admission date\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_end_year_month": {"name": "inferred_claim_end_year_month", "description": "The claim end date year and month. If claim line end date is missing then the following column will be used, \nin the following order if also NULL: claim end date, discharge date\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_start_column_used": {"name": "inferred_claim_start_column_used", "description": "The name of the column used to populated inferred_claim_start_year_month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_end_column_used": {"name": "inferred_claim_end_column_used", "description": "The name of the column used to populated inferred_claim_start_column_used.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "flag_claims_with_enrollment", "tags": ["claims_preprocessing"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.534034, "relation_name": "cms_synthetic.claims_preprocessing.flag_claims_with_enrollment", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\n | as_bool\n )\n}}\n\n\nwith claim_dates as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , {{ quote_column('plan') }}\n , coalesce(claim_line_start_date, claim_start_date, admission_date) as inferred_claim_start_date\n , coalesce(claim_line_end_date, claim_end_date, discharge_date) as inferred_claim_end_date\n , case\n when claim_line_start_date is not null then 'claim_line_start_date'\n when claim_line_start_date is null and claim_start_date is not null then 'claim_start_date'\n when claim_line_start_date is null and claim_start_date is null and admission_date is not null then 'admission_date'\n end as inferred_claim_start_column_used\n , case\n when claim_line_end_date is not null then 'claim_line_end_date'\n when claim_line_end_date is null and claim_end_date is not null then 'claim_end_date'\n when claim_line_end_date is null and claim_end_date is null and discharge_date is not null then 'discharge_date'\n end as inferred_claim_end_column_used\n from {{ ref('normalized_input__medical_claim') }}\n)\n\n, claim_year_month as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , {{ quote_column('plan') }}\n , inferred_claim_start_date\n , inferred_claim_end_date\n , inferred_claim_start_column_used\n , inferred_claim_end_column_used\n\n , {{ dbt.concat([\n date_part('year', 'inferred_claim_start_date'),\n dbt.right(\n dbt.concat([\n \"'0'\",\n date_part('month', 'inferred_claim_start_date'),\n ]),\n 2\n )\n ]) }} as inferred_claim_start_year_month\n\n , {{ dbt.concat([\n date_part('year', 'inferred_claim_end_date'),\n dbt.right(\n dbt.concat([\n \"'0'\",\n date_part('month', 'inferred_claim_end_date'),\n ]),\n 2\n )\n ]) }} as inferred_claim_end_year_month\n\nfrom claim_dates\n\n)\n\nselect distinct\n claim.claim_id\n , claim.claim_line_number\n , claim.patient_id\n , claim.payer\n , claim.{{ quote_column('plan') }}\n , claim.inferred_claim_start_year_month\n , claim.inferred_claim_end_year_month\n , claim.inferred_claim_start_column_used\n , claim.inferred_claim_end_column_used\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\nfrom {{ ref('core__member_months')}} mm\ninner join claim_year_month claim\n on mm.patient_id = claim.patient_id\n and mm.payer = claim.payer\n and mm.{{ quote_column('plan') }} = claim.{{ quote_column('plan') }}\n and mm.year_month >= claim.inferred_claim_start_year_month\n and mm.year_month <= claim.inferred_claim_end_year_month", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.right", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/claims_enrollment/claims_enrollment__flag_claims_with_enrollment.sql", "compiled": true, "compiled_code": "\n\n\nwith claim_dates as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , coalesce(claim_line_start_date, claim_start_date, admission_date) as inferred_claim_start_date\n , coalesce(claim_line_end_date, claim_end_date, discharge_date) as inferred_claim_end_date\n , case\n when claim_line_start_date is not null then 'claim_line_start_date'\n when claim_line_start_date is null and claim_start_date is not null then 'claim_start_date'\n when claim_line_start_date is null and claim_start_date is null and admission_date is not null then 'admission_date'\n end as inferred_claim_start_column_used\n , case\n when claim_line_end_date is not null then 'claim_line_end_date'\n when claim_line_end_date is null and claim_end_date is not null then 'claim_end_date'\n when claim_line_end_date is null and claim_end_date is null and discharge_date is not null then 'discharge_date'\n end as inferred_claim_end_column_used\n from cms_synthetic.claims_preprocessing.normalized_input_medical_claim\n)\n\n, claim_year_month as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , inferred_claim_start_date\n , inferred_claim_end_date\n , inferred_claim_start_column_used\n , inferred_claim_end_column_used\n\n , date_part('year', inferred_claim_start_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_start_date),\n 2\n )\n end as inferred_claim_start_year_month\n\n , date_part('year', inferred_claim_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_end_date),\n 2\n )\n end as inferred_claim_end_year_month\n\nfrom claim_dates\n\n)\n\nselect distinct\n claim.claim_id\n , claim.claim_line_number\n , claim.patient_id\n , claim.payer\n , claim.plan\n , claim.inferred_claim_start_year_month\n , claim.inferred_claim_end_year_month\n , claim.inferred_claim_start_column_used\n , claim.inferred_claim_end_column_used\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom cms_synthetic.core.member_months mm\ninner join claim_year_month claim\n on mm.patient_id = claim.patient_id\n and mm.payer = claim.payer\n and mm.plan = claim.plan\n and mm.year_month >= claim.inferred_claim_start_year_month\n and mm.year_month <= claim.inferred_claim_end_year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_medical_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "service_category__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/staging/service_category__stg_medical_claim.sql", "original_file_path": "models/claims_preprocessing/service_category/staging/service_category__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.service_category__stg_medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_medical_claim"], "alias": "service_category__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "5224949cb4fbc49f3fe6c3880105950f0ee8f1aa22b7a08aa1276e132d826906"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper_base", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper_base", "claims_preprocessing"], "description": "Staging med claims for sc grouper", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper_base", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.68856, "relation_name": "cms_synthetic.dbt_tom.service_category__stg_medical_claim", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n m.apr_drg_code\n , m.claim_id\n , m.claim_line_number\n , {{ dbt.concat([\"m.claim_id\", \"'|'\", \"cast(m.claim_line_number as \" ~ dbt.type_string() ~ \")\"]) }} as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , rend.primary_specialty_description as rend_primary_specialty_description\n , n.modality\n , m.data_source\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('normalized_input__medical_claim') }} m\nleft join {{ ref('ccsr__dxccsr_v2023_1_cleaned_map') }} dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join {{ ref('terminology__provider') }} p on m.facility_id = p.npi\nleft join {{ ref('terminology__ccs_services_procedures') }} c on m.hcpcs_code = c.hcpcs_code\nleft join {{ ref('terminology__nitos') }} n on m.hcpcs_code = n.hcpcs_code\nleft join {{ ref('terminology__ms_drg') }} drg on m.ms_drg_code = drg.ms_drg_code\nleft join {{ ref('terminology__revenue_center') }} r on m.revenue_center_code = r.revenue_center_code\nleft join {{ ref('terminology__place_of_service') }} pos on m.place_of_service_code = pos.place_of_service_code\nleft join {{ ref('terminology__bill_type') }} bt on m.bill_type_code = bt.bill_type_code\nleft join {{ ref('terminology__provider')}} rend on m.rendering_id = rend.npi", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_cleaned_map", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__ccs_services_procedures", "package": null, "version": null}, {"name": "terminology__nitos", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__revenue_center", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/staging/service_category__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n m.apr_drg_code\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , rend.primary_specialty_description as rend_primary_specialty_description\n , n.modality\n , m.data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim m\nleft join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join cms_synthetic.terminology.provider p on m.facility_id = p.npi\nleft join cms_synthetic.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join cms_synthetic.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join cms_synthetic.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join cms_synthetic.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join cms_synthetic.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join cms_synthetic.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join cms_synthetic.terminology.provider rend on m.rendering_id = rend.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_outpatient_institutional": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "service_category__stg_outpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/staging/service_category__stg_outpatient_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/staging/service_category__stg_outpatient_institutional.sql", "unique_id": "model.the_tuva_project.service_category__stg_outpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_outpatient_institutional"], "alias": "service_category__stg_outpatient_institutional", "checksum": {"name": "sha256", "checksum": "3630d5f9d1ae3f8dbd51150f059426a1ad715a90559682f2efb7a713712865a6"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.690063, "relation_name": "cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n a.claim_id\n, 'outpatient' as service_type\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} a\nleft join {{ ref('service_category__stg_inpatient_institutional') }} i on a.claim_id = i.claim_id\nwhere i.claim_id is null\nand\na.claim_type = 'institutional'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/staging/service_category__stg_outpatient_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n, 'outpatient' as service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nleft join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional i on a.claim_id = i.claim_id\nwhere i.claim_id is null\nand\na.claim_type = 'institutional'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_office_based": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "service_category__stg_office_based", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/staging/service_category__stg_office_based.sql", "original_file_path": "models/claims_preprocessing/service_category/staging/service_category__stg_office_based.sql", "unique_id": "model.the_tuva_project.service_category__stg_office_based", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_office_based"], "alias": "service_category__stg_office_based", "checksum": {"name": "sha256", "checksum": "67022e8d535b8d278e123133b29576b6de35d674f8a642b9d196694594a41e60"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.691756, "relation_name": "cms_synthetic.dbt_tom.service_category__stg_office_based", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id\n , 'office based' as service_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} a\ninner join {{ ref('service_category__stg_professional') }} p on a.claim_id = p.claim_id \nand\na.claim_line_number = p.claim_line_number\nwhere a.place_of_service_code in ( '11' -- office\n,'02' --telehealth \n,'10' --telehealth\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/staging/service_category__stg_office_based.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id\n , 'office based' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\ninner join cms_synthetic.dbt_tom.service_category__stg_professional p on a.claim_id = p.claim_id \nand\na.claim_line_number = p.claim_line_number\nwhere a.place_of_service_code in ( '11' -- office\n,'02' --telehealth \n,'10' --telehealth\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_inpatient_institutional": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "service_category__stg_inpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/staging/service_category__stg_inpatient_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/staging/service_category__stg_inpatient_institutional.sql", "unique_id": "model.the_tuva_project.service_category__stg_inpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_inpatient_institutional"], "alias": "service_category__stg_inpatient_institutional", "checksum": {"name": "sha256", "checksum": "13f549fc6fc8504811371695fa480d867f3ed7d3188b7ba7f11f7b6e132bb5a0"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.689335, "relation_name": "cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from {{ ref('service_category__stg_medical_claim') }} as mc\n left join {{ ref('terminology__ms_drg') }} as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join {{ ref('terminology__apr_drg') }} as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from {{ ref('service_category__stg_medical_claim') }}\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n , '21' -- SNF inpatient\n , '82' -- inpatient hospice\n )\n)\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/staging/service_category__stg_inpatient_institutional.sql", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as mc\n left join cms_synthetic.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join cms_synthetic.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n , '21' -- SNF inpatient\n , '82' -- inpatient hospice\n )\n)\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_professional": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "service_category__stg_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/staging/service_category__stg_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/staging/service_category__stg_professional.sql", "unique_id": "model.the_tuva_project.service_category__stg_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_professional"], "alias": "service_category__stg_professional", "checksum": {"name": "sha256", "checksum": "86172f6832bf04ee7d9cfa29c14626e2ba504b9dc76523ab8ed33987db914f01"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.690923, "relation_name": "cms_synthetic.dbt_tom.service_category__stg_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id as claim_line_id\n , 'professional' as service_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} a\nwhere a.claim_type = 'professional'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/staging/service_category__stg_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id as claim_line_id\n , 'professional' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nwhere a.claim_type = 'professional'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__service_category_grouper": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__service_category_grouper", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/final/service_category__service_category_grouper.sql", "original_file_path": "models/claims_preprocessing/service_category/final/service_category__service_category_grouper.sql", "unique_id": "model.the_tuva_project.service_category__service_category_grouper", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "final", "service_category__service_category_grouper"], "alias": "service_category_grouper", "checksum": {"name": "sha256", "checksum": "bef0ac121a08e3d23126a6f49705b7838a0662cfd25cd6a3c1986a41004352d1"}, "config": {"enabled": true, "alias": "service_category_grouper", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "Assigns every claim line into a unique service category.", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicated the type of claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_1": {"name": "service_category_1", "description": "The first service category of the claim line", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_2": {"name": "service_category_2", "description": "The second, more specific service category of the claim line", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_3": {"name": "service_category_3", "description": "The third, even more specific service category of the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_service_cat_2": {"name": "original_service_cat_2", "description": "Original categorization of service category 2 before any transformation or normalization.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_service_cat_3": {"name": "original_service_cat_3", "description": "Original categorization of service category 3 before any transformation or normalization.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_id": {"name": "claim_line_id", "description": "Concatenated field of claim_id and claim_line_number, providing a unique identifier for each line within a claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "duplicate_row_number": {"name": "duplicate_row_number", "description": "Row number used to identify duplicate entries within the data set.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_category": {"name": "ccs_category", "description": "Clinical Classifications Software category associated with the service provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_category_description": {"name": "ccs_category_description", "description": "Description of the Clinical Classifications Software category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "Medicare Severity Diagnosis Related Group code related to the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the Medicare Severity Diagnosis Related Group code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Code that identifies the place where service was provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_description": {"name": "place_of_service_description", "description": "Description of the place where service was provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code associated with the financial aspects of the care provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_description": {"name": "revenue_center_description", "description": "Description of the revenue center code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "Healthcare Common Procedure Coding System code that identifies specific services provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_ip": {"name": "default_ccsr_category_ip", "description": "Default Clinical Classifications Software for Services and Procedures category for inpatient services.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_op": {"name": "default_ccsr_category_op", "description": "Default Clinical Classifications Software for Services and Procedures category for outpatient services.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_ip": {"name": "default_ccsr_category_description_ip", "description": "Description of the default CCS for Services and Procedures category for inpatient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_op": {"name": "default_ccsr_category_description_op", "description": "Description of the default CCS for Services and Procedures category for outpatient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_taxonomy_code": {"name": "primary_taxonomy_code", "description": "Taxonomy code that classifies the providers type or specialization.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_specialty_description": {"name": "primary_specialty_description", "description": "Description of the providers primary specialty.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modality": {"name": "modality", "description": "The type of modality used in the service provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Code that identifies the type of bill submitted for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_description": {"name": "bill_type_description", "description": "Description of the bill type code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_model_name": {"name": "source_model_name", "description": "Name of the source model from which this data was derived.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "The original source of the data used in this model.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category_grouper", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.600557, "relation_name": "cms_synthetic.claims_preprocessing.service_category_grouper", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category_1_mapping as(\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n , b.source_model_name\n from {{ ref('service_category__stg_medical_claim') }} a\n left join {{ ref('service_category__combined_professional') }} b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join {{ ref('service_category__service_categories') }} s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'professional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n , b.source_model_name\n from {{ ref('service_category__stg_medical_claim') }} a\n left join {{ ref('service_category__combined_institutional_header_level') }} b\n on a.claim_id = b.claim_id\n left join {{ ref('service_category__service_categories') }} s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n , b.source_model_name\n from {{ ref('service_category__stg_medical_claim') }} a\n left join {{ ref('service_category__combined_institutional_line_level') }} b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join {{ ref('service_category__service_categories') }} s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n)\n\n, service_category_2_deduplication as(\n select \n claim_id\n , claim_line_number\n , claim_type\n , service_category_1\n , service_category_2\n , service_category_3\n ,original_service_cat_2\n ,original_service_cat_3\n , source_model_name\n , row_number() over (partition by claim_id, claim_line_number order by priority) as duplicate_row_number\n from service_category_1_mapping\n)\n\nselect\n d.claim_id\n , d.claim_line_number\n , d.claim_type\n , coalesce(service_category_1,'other') as service_category_1\n , coalesce(service_category_2,'other') as service_category_2\n , coalesce(service_category_3,'other') as service_category_3\n , original_service_cat_2\n , original_service_cat_3\n , duplicate_row_number\n , s.ccs_category\n , s.ccs_category_description\n , s.ms_drg_code\n , s.ms_drg_description\n , s.place_of_service_code\n , s.place_of_service_description\n , s.revenue_center_code\n , s.revenue_center_description\n , s.hcpcs_code\n , s.default_ccsr_category_ip\n , s.default_ccsr_category_op\n , s.default_ccsr_category_description_ip\n , s.default_ccsr_category_description_op\n , s.primary_taxonomy_code\n , s.primary_specialty_description\n , s.modality\n , s.bill_type_code\n , s.bill_type_description\n , d.source_model_name\n , s.data_source\nfrom service_category_2_deduplication d\ninner join {{ ref('service_category__stg_medical_claim') }} s on d.claim_id = s.claim_id\nand\nd.claim_line_number = s.claim_line_number\n--where duplicate_row_number = 1", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_professional", "package": null, "version": null}, {"name": "service_category__service_categories", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_institutional_header_level", "package": null, "version": null}, {"name": "service_category__service_categories", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_institutional_line_level", "package": null, "version": null}, {"name": "service_category__service_categories", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__combined_professional", "seed.the_tuva_project.service_category__service_categories", "model.the_tuva_project.service_category__combined_institutional_header_level", "model.the_tuva_project.service_category__combined_institutional_line_level"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/final/service_category__service_category_grouper.sql", "compiled": true, "compiled_code": "\n\nwith service_category_1_mapping as(\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , b.source_model_name\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim a\n left join cms_synthetic.claims_preprocessing._int_combined_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join cms_synthetic.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'professional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , b.source_model_name\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim a\n left join cms_synthetic.claims_preprocessing._int_combined_institutional_header_level b\n on a.claim_id = b.claim_id\n left join cms_synthetic.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , b.source_model_name\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim a\n left join cms_synthetic.claims_preprocessing._int_combined_institutional_line_level b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join cms_synthetic.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n)\n\n, service_category_2_deduplication as(\n select \n claim_id\n , claim_line_number\n , claim_type\n , service_category_1\n , service_category_2\n , service_category_3\n ,original_service_cat_2\n ,original_service_cat_3\n , source_model_name\n , row_number() over (partition by claim_id, claim_line_number order by priority) as duplicate_row_number\n from service_category_1_mapping\n)\n\nselect\n d.claim_id\n , d.claim_line_number\n , d.claim_type\n , coalesce(service_category_1,'other') as service_category_1\n , coalesce(service_category_2,'other') as service_category_2\n , coalesce(service_category_3,'other') as service_category_3\n , original_service_cat_2\n , original_service_cat_3\n , duplicate_row_number\n , s.ccs_category\n , s.ccs_category_description\n , s.ms_drg_code\n , s.ms_drg_description\n , s.place_of_service_code\n , s.place_of_service_description\n , s.revenue_center_code\n , s.revenue_center_description\n , s.hcpcs_code\n , s.default_ccsr_category_ip\n , s.default_ccsr_category_op\n , s.default_ccsr_category_description_ip\n , s.default_ccsr_category_description_op\n , s.primary_taxonomy_code\n , s.primary_specialty_description\n , s.modality\n , s.bill_type_code\n , s.bill_type_description\n , d.source_model_name\n , s.data_source\nfrom service_category_2_deduplication d\ninner join cms_synthetic.dbt_tom.service_category__stg_medical_claim s on d.claim_id = s.claim_id\nand\nd.claim_line_number = s.claim_line_number\n--where duplicate_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_physical_therapy_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_physical_therapy_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_physical_therapy_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_physical_therapy_professional"], "alias": "service_category__outpatient_physical_therapy_professional", "checksum": {"name": "sha256", "checksum": "886b6fc5a2a63eeb80cd8eac6145ed741087e4e45929cc793cf3441ead3c2f49"}, "config": {"enabled": true, "alias": "service_category__outpatient_physical_therapy_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_physical_therapy_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.677909, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient pt/ot/st' as service_category_2\n, 'outpatient pt/ot/st' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (ccs_category in ('213','212','215')\nOR\nmed.primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nAND\nplace_of_service_code <> '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_physical_therapy_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient pt/ot/st' as service_category_2\n, 'outpatient pt/ot/st' as service_category_3\n, 'service_category__outpatient_physical_therapy_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (ccs_category in ('213','212','215')\nOR\nmed.primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nAND\nplace_of_service_code <> '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulatory_surgery_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__ambulatory_surgery_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__ambulatory_surgery_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__ambulatory_surgery_professional.sql", "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulatory_surgery_professional"], "alias": "_int_ambulatory_surgery_professional", "checksum": {"name": "sha256", "checksum": "b2cf4fd4b798a58d87d79c491bac73579fa6442be491cb63d539dd8862e61ecb"}, "config": {"enabled": true, "alias": "_int_ambulatory_surgery_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulatory_surgery_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.611349, "relation_name": "cms_synthetic.claims_preprocessing._int_ambulatory_surgery_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n, 'ambulatory surgery center' as service_category_2\n, 'ambulatory surgery center' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('24')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__ambulatory_surgery_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n, 'ambulatory surgery center' as service_category_2\n, 'ambulatory surgery center' as service_category_3\n, '_int_ambulatory_surgery_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('24')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__home_health_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__home_health_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__home_health_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__home_health_professional.sql", "unique_id": "model.the_tuva_project.service_category__home_health_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__home_health_professional"], "alias": "_int_home_health_professional", "checksum": {"name": "sha256", "checksum": "03f71a6c516843c3f3f1e67509abe71f9a9f0c008e8f9a8ccf47c64c6a3e38c3"}, "config": {"enabled": true, "alias": "_int_home_health_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_home_health_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6225338, "relation_name": "cms_synthetic.claims_preprocessing._int_home_health_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('12')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__home_health_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('12')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__urgent_care_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__urgent_care_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__urgent_care_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__urgent_care_professional.sql", "unique_id": "model.the_tuva_project.service_category__urgent_care_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__urgent_care_professional"], "alias": "_int_urgent_care_professional", "checksum": {"name": "sha256", "checksum": "50fff6f59c4996b1c9f56146326971cbda55ab63c39e50ea3866baf6bf29690a"}, "config": {"enabled": true, "alias": "_int_urgent_care_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_urgent_care_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.655306, "relation_name": "cms_synthetic.claims_preprocessing._int_urgent_care_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith multiple_source as (\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\n and place_of_service_code in ('20')\n\nunion all\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\nand hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,claim_line_number\n,claim_line_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_source", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__urgent_care_professional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_source as (\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('20')\n\nunion all\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\nand hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,claim_line_number\n,claim_line_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulatory_surgery_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__ambulatory_surgery_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__ambulatory_surgery_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__ambulatory_surgery_institutional.sql", "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulatory_surgery_institutional"], "alias": "_int_ambulatory_surgery_institutional", "checksum": {"name": "sha256", "checksum": "130ae039ef460e12dda266592602c89f4c08bb16bb7edb469bfa1d5d503fd0e7"}, "config": {"enabled": true, "alias": "_int_ambulatory_surgery_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulatory_surgery_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.661416, "relation_name": "cms_synthetic.claims_preprocessing._int_ambulatory_surgery_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0490','0499')\n\nunion all\n\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\n on med.claim_id = outpatient.claim_id\nwhere med.primary_taxonomy_code = '261QA1903X'\n)\n\nselect distinct claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__ambulatory_surgery_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0490','0499')\n\nunion all\n\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere med.primary_taxonomy_code = '261QA1903X'\n)\n\nselect distinct claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__dialysis_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__dialysis_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__dialysis_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__dialysis_professional.sql", "unique_id": "model.the_tuva_project.service_category__dialysis_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__dialysis_professional"], "alias": "_int_dialysis_professional", "checksum": {"name": "sha256", "checksum": "89ec2adceb5e5a9704796f4fdc84efab047b2ecb95810a0b6f6381f1ec84d51b"}, "config": {"enabled": true, "alias": "_int_dialysis_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_dialysis_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6145542, "relation_name": "cms_synthetic.claims_preprocessing._int_dialysis_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1 \n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_professional') }} as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('65')\n or med.ccs_category in ('91', '58', '57')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__dialysis_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1 \n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('65')\n or med.ccs_category in ('91', '58', '57')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_institutional_maternity", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_maternity.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_maternity.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_institutional_maternity"], "alias": "_int_acute_inpatient_institutional_maternity", "checksum": {"name": "sha256", "checksum": "1be609e314285de5e3794fab6232384be5f0a4bf46cd3afcc5bfa7e01e2c816d"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_institutional_maternity", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_institutional_maternity", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.658487, "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_maternity", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when s.ms_drg_code in ('768', '796', '797', '798', '805', '806', '807') then 'l/d - vaginal delivery'\n when s.ms_drg_code in ('783', '784', '785', '786', '787', '788') then 'l/d - cesarean delivery'\n when s.ms_drg_code = '795' then 'l/d - newborn'\n when s.ms_drg_code in ('789', '790', '791', '792', '793', '794') then 'l/d - newborn nicu'\n when s.revenue_center_code in ('0173', '0174') then 'l/d - newborn nicu'\n else 'l/d - other'\n end as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} as a\n on s.claim_id = a.claim_id\ninner join {{ ref('terminology__ms_drg') }} as m\n on s.ms_drg_code = m.ms_drg_code\nwhere \n m.mdc_code in ('MDC 14', 'MDC 15')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_maternity.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when s.ms_drg_code in ('768', '796', '797', '798', '805', '806', '807') then 'l/d - vaginal delivery'\n when s.ms_drg_code in ('783', '784', '785', '786', '787', '788') then 'l/d - cesarean delivery'\n when s.ms_drg_code = '795' then 'l/d - newborn'\n when s.ms_drg_code in ('789', '790', '791', '792', '793', '794') then 'l/d - newborn nicu'\n when s.revenue_center_code in ('0173', '0174') then 'l/d - newborn nicu'\n else 'l/d - other'\n end as service_category_3\n , '_int_acute_inpatient_institutional_maternity' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join cms_synthetic.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code\nwhere \n m.mdc_code in ('MDC 14', 'MDC 15')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__lab_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__lab_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__lab_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__lab_institutional.sql", "unique_id": "model.the_tuva_project.service_category__lab_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__lab_institutional"], "alias": "_int_lab_institutional", "checksum": {"name": "sha256", "checksum": "6de2d548d9609d9f0abe80cdbf8c2d9dca905970c1b9251068684187daada297"}, "config": {"enabled": true, "alias": "_int_lab_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_lab_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.639255, "relation_name": "cms_synthetic.claims_preprocessing._int_lab_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.bill_type_code, 1, 2) in ('14')\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__lab_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.bill_type_code, 1, 2) in ('14')\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_skilled_nursing_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_skilled_nursing_professional"], "alias": "_int_inpatient_skilled_nursing_professional", "checksum": {"name": "sha256", "checksum": "677ce2d71d347ba6823857d7fbc55e10fb2af4aec5604a64ec6264be0129fb90"}, "config": {"enabled": true, "alias": "_int_inpatient_skilled_nursing_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_skilled_nursing_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.652471, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n a.claim_id\n, a.claim_line_number\n, a.claim_line_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} a\nleft join {{ ref('service_category__dme_professional') }} b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\nwhere claim_type = 'professional'\n and place_of_service_code in ('31','32')\n and (b.claim_id is null and b.claim_line_number is null)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__dme_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__dme_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n, a.claim_line_number\n, a.claim_line_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nleft join cms_synthetic.claims_preprocessing._int_dme_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\nwhere claim_type = 'professional'\n and place_of_service_code in ('31','32')\n and (b.claim_id is null and b.claim_line_number is null)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_rehab_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_rehab_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_rehab_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_rehab_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_rehab_professional"], "alias": "_int_inpatient_rehab_professional", "checksum": {"name": "sha256", "checksum": "a57a07214933753f4bd5251994f7b360ee3fa615717f29395bdc33ff5f00d7a5"}, "config": {"enabled": true, "alias": "_int_inpatient_rehab_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_rehab_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.63561, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_rehab_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\n and place_of_service_code in ('61')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_rehab_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n,'_int_inpatient_rehab_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('61')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__dialysis_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__dialysis_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__dialysis_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__dialysis_institutional.sql", "unique_id": "model.the_tuva_project.service_category__dialysis_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__dialysis_institutional"], "alias": "_int_dialysis_institutional", "checksum": {"name": "sha256", "checksum": "3f311aea1defad8fe0aa87b8e6fc96811a6a92d66df71a1ede43c888b106ce56"}, "config": {"enabled": true, "alias": "_int_dialysis_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_dialysis_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6129332, "relation_name": "cms_synthetic.claims_preprocessing._int_dialysis_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('72')\n or med.primary_taxonomy_code in (\n '2472R0900X'\n , '163WD1100X'\n , '163WH0500X'\n , '261QE0700X'\n )\n or med.ccs_category in ('91', '58', '57')\n or substring(med.revenue_center_code, 1, 3) in ('082', '083', '084', '085', '088')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__dialysis_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('72')\n or med.primary_taxonomy_code in (\n '2472R0900X'\n , '163WD1100X'\n , '163WH0500X'\n , '261QE0700X'\n )\n or med.ccs_category in ('91', '58', '57')\n or substring(med.revenue_center_code, 1, 3) in ('082', '083', '084', '085', '088')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__dme_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__dme_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__dme_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__dme_professional.sql", "unique_id": "model.the_tuva_project.service_category__dme_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__dme_professional"], "alias": "_int_dme_professional", "checksum": {"name": "sha256", "checksum": "4050116f8ca94694f8ffad2abdbe99dd442463e2399c229f24953d3f8efb6263"}, "config": {"enabled": true, "alias": "_int_dme_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_dme_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6161358, "relation_name": "cms_synthetic.claims_preprocessing._int_dme_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'ancillary' as service_category_1\n, 'durable medical equipment' as service_category_2\n, 'durable medical equipment' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\n and hcpcs_code between 'E0100' and 'E8002'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__dme_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'ancillary' as service_category_1\n, 'durable medical equipment' as service_category_2\n, 'durable medical equipment' as service_category_3\n, '_int_dme_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and hcpcs_code between 'E0100' and 'E8002'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospice_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospice_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_hospice_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospice_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospice_institutional"], "alias": "_int_outpatient_hospice_institutional", "checksum": {"name": "sha256", "checksum": "afa310eb32f9464f8b6921cdd428116647a109d5a72ec10d4dc64fcc3dfa7aff"}, "config": {"enabled": true, "alias": "_int_outpatient_hospice_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospice_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.625715, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospice_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient hospice' as service_category_2\n , 'outpatient hospice' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('81')\n or (\n med.hcpcs_code in ('Q5001', 'Q5002', 'Q5003', 'Q5009')\n and substring(med.bill_type_code, 1, 2) not in ('31', '32', '33')\n )\n or med.revenue_center_code in ('0651', '0652')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospice_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient hospice' as service_category_2\n , 'outpatient hospice' as service_category_3\n , '_int_outpatient_hospice_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('81')\n or (\n med.hcpcs_code in ('Q5001', 'Q5002', 'Q5003', 'Q5009')\n and substring(med.bill_type_code, 1, 2) not in ('31', '32', '33')\n )\n or med.revenue_center_code in ('0651', '0652')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__home_health_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__home_health_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__home_health_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__home_health_institutional.sql", "unique_id": "model.the_tuva_project.service_category__home_health_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__home_health_institutional"], "alias": "_int_home_health_institutional", "checksum": {"name": "sha256", "checksum": "c096518fe3136c80a6c88c2194e624e059aaf05377c4456d336e52e151bcfe48"}, "config": {"enabled": true, "alias": "_int_home_health_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_home_health_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.620995, "relation_name": "cms_synthetic.claims_preprocessing._int_home_health_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n claim_id\n , 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('31','32','33')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__home_health_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n , 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('31','32','33')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__emergency_department_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__emergency_department_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__emergency_department_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__emergency_department_professional.sql", "unique_id": "model.the_tuva_project.service_category__emergency_department_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__emergency_department_professional"], "alias": "_int_emergency_department_professional", "checksum": {"name": "sha256", "checksum": "6d5cc9fcd192b2f4dffebb52a8d09af9320d8ca7ea21382587b8009dd1003da0"}, "config": {"enabled": true, "alias": "_int_emergency_department_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_emergency_department_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.619168, "relation_name": "cms_synthetic.claims_preprocessing._int_emergency_department_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'emergency department' as service_category_2\n, 'emergency department' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '23'\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__emergency_department_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'emergency department' as service_category_2\n, 'emergency department' as service_category_3\n, '_int_emergency_department_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '23'\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospice_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospice_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_hospice_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospice_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospice_professional"], "alias": "_int_outpatient_hospice_professional", "checksum": {"name": "sha256", "checksum": "0c92de07545e6153db7abcc77791af5520b05438556f813c251daf892255c133"}, "config": {"enabled": true, "alias": "_int_outpatient_hospice_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospice_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.627211, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospice_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient hospice' as service_category_2\n, 'outpatient hospice' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere \nmed.hcpcs_code in ('Q5001','Q5002','Q5003','Q5009')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospice_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient hospice' as service_category_2\n, 'outpatient hospice' as service_category_3\n, '_int_outpatient_hospice_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere \nmed.hcpcs_code in ('Q5001','Q5002','Q5003','Q5009')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_psychiatric_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_psychiatric_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_psychiatric_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_psychiatric_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_psychiatric_professional"], "alias": "_int_inpatient_psychiatric_professional", "checksum": {"name": "sha256", "checksum": "da607269b7f77571bbe1fd9aef6f593e12bb52da1d9d97ba017105c8f78a8876"}, "config": {"enabled": true, "alias": "_int_inpatient_psychiatric_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_psychiatric_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.630625, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \nclaim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\n and place_of_service_code in ('51','55','56')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_psychiatric_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \nclaim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n,'_int_inpatient_psychiatric_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('51','55','56')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_rehab_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_rehab_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_rehab_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_rehab_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_rehab_institutional"], "alias": "_int_inpatient_rehab_institutional", "checksum": {"name": "sha256", "checksum": "6354dda8276b9de61616d2705c0b5acb5dcaf8b537834010bd0fe72aafa6c958"}, "config": {"enabled": true, "alias": "_int_inpatient_rehab_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_rehab_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.637735, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_rehab_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n s.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283X00000X'\n ,'273Y00000X'\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_rehab_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n s.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n, '_int_inpatient_rehab_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283X00000X'\n ,'273Y00000X'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_substance_use_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_substance_use_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_substance_use_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_substance_use_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_substance_use_institutional"], "alias": "_int_inpatient_substance_use_institutional", "checksum": {"name": "sha256", "checksum": "25b56241af3594c5664232433e199fe4c60c17ff4380f26ac77767e8b284d31f"}, "config": {"enabled": true, "alias": "_int_inpatient_substance_use_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_substance_use_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.666384, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_substance_use_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'inpatient substance use' as service_category_2\n , 'inpatient substance use' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} as a\n on s.claim_id = a.claim_id\nwhere \n s.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )\n or s.default_ccsr_category_description_ip in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_substance_use_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'inpatient substance use' as service_category_2\n , 'inpatient substance use' as service_category_3\n , '_int_inpatient_substance_use_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\nwhere \n s.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )\n or s.default_ccsr_category_description_ip in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__pharmacy_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__pharmacy_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__pharmacy_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__pharmacy_professional.sql", "unique_id": "model.the_tuva_project.service_category__pharmacy_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__pharmacy_professional"], "alias": "service_category__pharmacy_professional", "checksum": {"name": "sha256", "checksum": "ec1f5e819d188f1d67cf8ab22c044ca31a71c91ddeb8dedd9cf065e209d8839b"}, "config": {"enabled": true, "alias": "service_category__pharmacy_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__pharmacy_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6749241, "relation_name": "cms_synthetic.claims_preprocessing.service_category__pharmacy_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , case when place_of_service_code = '11' then 'office-based' else 'outpatient' end as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n ,'{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\nccs_category = '240' --medications", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__pharmacy_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , case when place_of_service_code = '11' then 'office-based' else 'outpatient' end as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n ,'service_category__pharmacy_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\nccs_category = '240' --medications", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_physical_therapy_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_physical_therapy_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_physical_therapy_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_physical_therapy_institutional"], "alias": "service_category__outpatient_physical_therapy_institutional", "checksum": {"name": "sha256", "checksum": "07747f181e0c62d97fe1b8c8b285724c6035dea2db86d901bf3dba8ea6c7f41c"}, "config": {"enabled": true, "alias": "service_category__outpatient_physical_therapy_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_physical_therapy_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.67644, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n ,'outpatient' as service_category_1 \n , 'outpatient pt/ot/st' as service_category_2\n , 'outpatient pt/ot/st' as service_category_3\n ,'{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\nwhere ccs_category in ('213','212','215')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_physical_therapy_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n ,'outpatient' as service_category_1 \n , 'outpatient pt/ot/st' as service_category_2\n , 'outpatient pt/ot/st' as service_category_3\n ,'service_category__outpatient_physical_therapy_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere ccs_category in ('213','212','215')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__combined_institutional_line_level": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__combined_institutional_line_level", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__combined_institutional_line_level.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__combined_institutional_line_level.sql", "unique_id": "model.the_tuva_project.service_category__combined_institutional_line_level", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__combined_institutional_line_level"], "alias": "_int_combined_institutional_line_level", "checksum": {"name": "sha256", "checksum": "ec0bb0c3f6f6126cca8d2c6a0929c1438d03dd9c296e9874ba40561215362ec8"}, "config": {"enabled": true, "alias": "_int_combined_institutional_line_level", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_combined_institutional_line_level", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.604953, "relation_name": "cms_synthetic.claims_preprocessing._int_combined_institutional_line_level", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nWITH combine_line_models AS (\n {{ dbt_utils.union_relations(\n relations=[\n ref('service_category__pharmacy_institutional'),\n ref('service_category__outpatient_radiology_institutional'),\n ref('service_category__observation_institutional'),\n ref('service_category__ambulance_institutional'),\n ref('service_category__lab_institutional')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n)\n\nSELECT\n l.claim_id,\n l.claim_line_number,\n l.service_category_1,\n l.service_category_2,\n l.service_category_3,\n l.source_model_name\nFROM combine_line_models l", "language": "sql", "refs": [{"name": "service_category__pharmacy_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_radiology_institutional", "package": null, "version": null}, {"name": "service_category__observation_institutional", "package": null, "version": null}, {"name": "service_category__ambulance_institutional", "package": null, "version": null}, {"name": "service_category__lab_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.service_category__pharmacy_institutional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__observation_institutional", "model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__lab_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__combined_institutional_line_level.sql", "compiled": true, "compiled_code": "\n\nWITH combine_line_models AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__pharmacy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing.service_category__pharmacy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_observation_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing._int_observation_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulance_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing._int_ambulance_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_lab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing._int_lab_institutional\n\n \n )\n\n \n)\n\nSELECT\n l.claim_id,\n l.claim_line_number,\n l.service_category_1,\n l.service_category_2,\n l.service_category_3,\n l.source_model_name\nFROM combine_line_models l", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_surgery_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_surgery_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_surgery_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_surgery_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_surgery_institutional"], "alias": "service_category__outpatient_surgery_institutional", "checksum": {"name": "sha256", "checksum": "3528a0b1c087cf5977d3b86f7c9770dc90432fa21ac098c6079daf3b60e7e113"}, "config": {"enabled": true, "alias": "service_category__outpatient_surgery_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_surgery_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6848042, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id --claim level\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\nwhere\nccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_surgery_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id --claim level\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere\nccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_hospice_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_hospice_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_hospice_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_hospice_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_hospice_professional"], "alias": "_int_inpatient_hospice_professional", "checksum": {"name": "sha256", "checksum": "d8f50d3cceb0e0d107f2cbb6e99eeadbc52777750e26b50ca1217302712f82c2"}, "config": {"enabled": true, "alias": "_int_inpatient_hospice_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_hospice_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.629108, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_hospice_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code in ('34')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_hospice_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n,'_int_inpatient_hospice_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code in ('34')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_rehab_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_rehab_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_rehab_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_rehab_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_rehab_institutional"], "alias": "service_category__outpatient_rehab_institutional", "checksum": {"name": "sha256", "checksum": "24336e62933605ed2d4d7d37faad0e7241a7d50fcd7478456411be6625b7e8c4"}, "config": {"enabled": true, "alias": "service_category__outpatient_rehab_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "flagging outpatient claims for outpatient rehab service categories", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_rehab_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.687614, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_rehab_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient rehabilitation' as service_category_2\n , 'outpatient rehabilitation' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\n from {{ ref('service_category__stg_medical_claim') }} as m\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as i\n on m.claim_id = i.claim_id\n where \n m.primary_taxonomy_code in (\n '283X00000X'\n , '273Y00000X'\n , '261QR0400X'\n , '315D00000X'\n , '261QR0401X'\n , '208100000X'\n , '225400000X'\n , '324500000X'\n , '2278P1005X'\n , '261QR0405X'\n , '2081S0010X'\n , '261QR0404X'\n )\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_rehab_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient rehabilitation' as service_category_2\n , 'outpatient rehabilitation' as service_category_3\n , 'service_category__outpatient_rehab_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as m\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as i\n on m.claim_id = i.claim_id\n where \n m.primary_taxonomy_code in (\n '283X00000X'\n , '273Y00000X'\n , '261QR0400X'\n , '315D00000X'\n , '261QR0401X'\n , '208100000X'\n , '225400000X'\n , '324500000X'\n , '2278P1005X'\n , '261QR0405X'\n , '2081S0010X'\n , '261QR0404X'\n )\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__pharmacy_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__pharmacy_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__pharmacy_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__pharmacy_institutional.sql", "unique_id": "model.the_tuva_project.service_category__pharmacy_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__pharmacy_institutional"], "alias": "service_category__pharmacy_institutional", "checksum": {"name": "sha256", "checksum": "d5dbbd90f9c35967f82335824c75834928c5fd23461f18041180ac97c32b586d"}, "config": {"enabled": true, "alias": "service_category__pharmacy_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__pharmacy_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.673517, "relation_name": "cms_synthetic.claims_preprocessing.service_category__pharmacy_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\n from {{ ref('service_category__stg_medical_claim') }} as med\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547'\n or med.ccs_category = '240') -- medications\n\n union all\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'inpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\n from {{ ref('service_category__stg_medical_claim') }} as med\n inner join {{ ref('service_category__stg_inpatient_institutional') }} as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547')\n)\n\nselect \n claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__pharmacy_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547'\n or med.ccs_category = '240') -- medications\n\n union all\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'inpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\n inner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547')\n)\n\nselect \n claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospital_or_clinic_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_hospital_or_clinic_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospital_or_clinic_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospital_or_clinic_professional"], "alias": "_int_outpatient_hospital_or_clinic_professional", "checksum": {"name": "sha256", "checksum": "3fc99179c99f1e83125d86c9ff077d02e732d9f74770686ff31943147a7b0a80"}, "config": {"enabled": true, "alias": "_int_outpatient_hospital_or_clinic_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospital_or_clinic_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6446989, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_professional') }} as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('15', '17', '19', '22', '49', '50', '60', '71', '72')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospital_or_clinic_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('15', '17', '19', '22', '49', '50', '60', '71', '72')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_radiology": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__office_based_radiology", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__office_based_radiology.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__office_based_radiology.sql", "unique_id": "model.the_tuva_project.service_category__office_based_radiology", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_radiology"], "alias": "service_category__office_based_radiology", "checksum": {"name": "sha256", "checksum": "21b8a84627bf3554b1be0b8bebb081bf54c04316ad7f62418a026972182abb16"}, "config": {"enabled": true, "alias": "service_category__office_based_radiology", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_radiology", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.670767, "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_radiology", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based radiology' as service_category_2\n , case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n ,'{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_office_based') }} o on med.claim_id = o.claim_id\nand\nmed.claim_line_number = o.claim_line_number\nwhere \nmed.modality is not null\nand\nmed.place_of_service_code = '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__office_based_radiology.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based radiology' as service_category_2\n , case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n ,'service_category__office_based_radiology' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_office_based o on med.claim_id = o.claim_id\nand\nmed.claim_line_number = o.claim_line_number\nwhere \nmed.modality is not null\nand\nmed.place_of_service_code = '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_hospice_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_hospice_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_hospice_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_hospice_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_hospice_institutional"], "alias": "_int_inpatient_hospice_institutional", "checksum": {"name": "sha256", "checksum": "09128d7237fb77125edbb3bbbd655784696efd49031cc939b3d8ecc27c9d662a"}, "config": {"enabled": true, "alias": "_int_inpatient_hospice_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_hospice_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.624274, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_hospice_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} a on s.claim_id = a.claim_id\nwhere substring(s.bill_type_code, 1, 2) in ('82')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_hospice_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n, '_int_inpatient_hospice_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id\nwhere substring(s.bill_type_code, 1, 2) in ('82')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__lab_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__lab_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__lab_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__lab_professional.sql", "unique_id": "model.the_tuva_project.service_category__lab_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__lab_professional"], "alias": "_int_lab_professional", "checksum": {"name": "sha256", "checksum": "b735f1c1f198afc786216027862d06f82d8af249cc5c3e70120c60410bf7e43d"}, "config": {"enabled": true, "alias": "_int_lab_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_lab_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.640563, "relation_name": "cms_synthetic.claims_preprocessing._int_lab_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '81'\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__lab_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '81'\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__combined_institutional_header_level": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__combined_institutional_header_level", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__combined_institutional_header_level.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__combined_institutional_header_level.sql", "unique_id": "model.the_tuva_project.service_category__combined_institutional_header_level", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__combined_institutional_header_level"], "alias": "_int_combined_institutional_header_level", "checksum": {"name": "sha256", "checksum": "3c571387a4164b556be72e29a68521e0b8e31dd69291a3d089a79de79e8ee252"}, "config": {"enabled": true, "alias": "_int_combined_institutional_header_level", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_combined_institutional_header_level", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.603474, "relation_name": "cms_synthetic.claims_preprocessing._int_combined_institutional_header_level", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nWITH combine_header_models AS (\n {{ dbt_utils.union_relations(\n relations=[\n ref('service_category__acute_inpatient_institutional_other'),\n ref('service_category__acute_inpatient_institutional_maternity'),\n ref('service_category__acute_inpatient_institutional_med_surg'),\n ref('service_category__inpatient_substance_use_institutional'),\n ref('service_category__ambulatory_surgery_institutional'),\n ref('service_category__dialysis_institutional'),\n ref('service_category__emergency_department_institutional'),\n ref('service_category__home_health_institutional'),\n ref('service_category__inpatient_hospice_institutional'),\n ref('service_category__outpatient_hospice_institutional'),\n ref('service_category__outpatient_hospital_or_clinic_institutional'),\n ref('service_category__outpatient_physical_therapy_institutional'),\n ref('service_category__outpatient_psychiatric_institutional'),\n ref('service_category__inpatient_skilled_nursing_institutional'),\n ref('service_category__urgent_care_institutional'),\n ref('service_category__inpatient_psychiatric_institutional'),\n ref('service_category__inpatient_rehab_institutional'),\n ref('service_category__outpatient_rehab_institutional'),\n ref('service_category__outpatient_substance_use_institutional'),\n ref('service_category__outpatient_surgery_institutional')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n)\n\nSELECT\n h.claim_id,\n h.service_category_1,\n h.service_category_2,\n h.service_category_3,\n h.source_model_name\nFROM combine_header_models h", "language": "sql", "refs": [{"name": "service_category__acute_inpatient_institutional_other", "package": null, "version": null}, {"name": "service_category__acute_inpatient_institutional_maternity", "package": null, "version": null}, {"name": "service_category__acute_inpatient_institutional_med_surg", "package": null, "version": null}, {"name": "service_category__inpatient_substance_use_institutional", "package": null, "version": null}, {"name": "service_category__ambulatory_surgery_institutional", "package": null, "version": null}, {"name": "service_category__dialysis_institutional", "package": null, "version": null}, {"name": "service_category__emergency_department_institutional", "package": null, "version": null}, {"name": "service_category__home_health_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_hospice_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_hospice_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_hospital_or_clinic_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_physical_therapy_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_psychiatric_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_skilled_nursing_institutional", "package": null, "version": null}, {"name": "service_category__urgent_care_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_psychiatric_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_rehab_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_rehab_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_substance_use_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_surgery_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__home_health_institutional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "model.the_tuva_project.service_category__urgent_care_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_surgery_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__combined_institutional_header_level.sql", "compiled": true, "compiled_code": "\n\nWITH combine_header_models AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_other' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_other\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_maternity' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_maternity\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_med_surg' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_med_surg\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulatory_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_ambulatory_surgery_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_dialysis_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_dialysis_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_emergency_department_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_emergency_department_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_home_health_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_home_health_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_urgent_care_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_urgent_care_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_institutional\n\n \n )\n\n \n)\n\nSELECT\n h.claim_id,\n h.service_category_1,\n h.service_category_2,\n h.service_category_3,\n h.source_model_name\nFROM combine_header_models h", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__urgent_care_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__urgent_care_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__urgent_care_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__urgent_care_institutional.sql", "unique_id": "model.the_tuva_project.service_category__urgent_care_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__urgent_care_institutional"], "alias": "_int_urgent_care_institutional", "checksum": {"name": "sha256", "checksum": "42edb4103b8d6330eb74f55c42e18b68c56ae20913af546012c6b28db4a1af1f"}, "config": {"enabled": true, "alias": "_int_urgent_care_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_urgent_care_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.653903, "relation_name": "cms_synthetic.claims_preprocessing._int_urgent_care_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} a\nwhere claim_type = 'institutional'\n and revenue_center_code = '0456'\n and substring(bill_type_code, 1, 2) in ('13','71','73')\n \nunion all\n\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} a\nwhere claim_type = 'institutional'\n and hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__urgent_care_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and revenue_center_code = '0456'\n and substring(bill_type_code, 1, 2) in ('13','71','73')\n \nunion all\n\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_radiology_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_radiology_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_radiology_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_radiology_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_radiology_institutional"], "alias": "service_category__outpatient_radiology_institutional", "checksum": {"name": "sha256", "checksum": "6776bface46af828f7d849950b21993a91799962006453df109501006c3c54f8"}, "config": {"enabled": true, "alias": "service_category__outpatient_radiology_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_radiology_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6794019, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, '{{ this.name }}' as source_model_name \n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\nwhere med.modality is not null", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_radiology_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_institutional' as source_model_name \n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_radiology_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_radiology_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_radiology_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_radiology_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_radiology_professional"], "alias": "service_category__outpatient_radiology_professional", "checksum": {"name": "sha256", "checksum": "6b15c994af24a4c9241187a4eb36206a161680a632273ef11302d5e7f0f17267"}, "config": {"enabled": true, "alias": "service_category__outpatient_radiology_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_radiology_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6808262, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, '{{ this.name }}' as source_model_name \n, '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\nwhere med.modality is not null\nand\nplace_of_service_code <> '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_radiology_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_professional' as source_model_name \n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null\nand\nplace_of_service_code <> '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__combined_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__combined_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__combined_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__combined_professional.sql", "unique_id": "model.the_tuva_project.service_category__combined_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__combined_professional"], "alias": "_int_combined_professional", "checksum": {"name": "sha256", "checksum": "c64edd61c3d43884c833c505e4351e5771e04766ea7d4859d9c60bbae83a5b82"}, "config": {"enabled": true, "alias": "_int_combined_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_combined_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6019552, "relation_name": "cms_synthetic.claims_preprocessing._int_combined_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nWITH combined_professional_services AS (\n {{ dbt_utils.union_relations(\n relations=[\n ref('service_category__acute_inpatient_professional'),\n ref('service_category__ambulatory_surgery_professional'),\n ref('service_category__dialysis_professional'),\n ref('service_category__emergency_department_professional'),\n ref('service_category__home_health_professional'),\n ref('service_category__inpatient_hospice_professional'),\n ref('service_category__inpatient_psychiatric_professional'),\n ref('service_category__inpatient_rehab_professional'),\n ref('service_category__lab_professional'),\n ref('service_category__office_based_other_professional'),\n ref('service_category__office_based_physical_therapy_professional'),\n ref('service_category__office_based_radiology'),\n ref('service_category__office_based_surgery_professional'),\n ref('service_category__office_based_visit_professional'),\n ref('service_category__outpatient_hospital_or_clinic_professional'),\n ref('service_category__outpatient_psychiatric_professional'),\n ref('service_category__outpatient_rehab_professional'),\n ref('service_category__inpatient_skilled_nursing_professional'),\n ref('service_category__urgent_care_professional'),\n ref('service_category__outpatient_hospice_professional'),\n ref('service_category__pharmacy_professional'),\n ref('service_category__outpatient_substance_use_professional'),\n ref('service_category__outpatient_physical_therapy_professional'),\n ref('service_category__outpatient_radiology_professional'),\n ref('service_category__observation_professional'),\n ref('service_category__dme_professional'),\n ref('service_category__ambulance_professional'),\n ref('service_category__outpatient_surgery_professional')\n ],\n exclude=[\"_loaded_at\"]\n ) }}\n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.claim_line_id,\n p.service_category_1,\n p.service_category_2,\n p.service_category_3,\n p.tuva_last_run,\n p.source_model_name\nFROM combined_professional_services p", "language": "sql", "refs": [{"name": "service_category__acute_inpatient_professional", "package": null, "version": null}, {"name": "service_category__ambulatory_surgery_professional", "package": null, "version": null}, {"name": "service_category__dialysis_professional", "package": null, "version": null}, {"name": "service_category__emergency_department_professional", "package": null, "version": null}, {"name": "service_category__home_health_professional", "package": null, "version": null}, {"name": "service_category__inpatient_hospice_professional", "package": null, "version": null}, {"name": "service_category__inpatient_psychiatric_professional", "package": null, "version": null}, {"name": "service_category__inpatient_rehab_professional", "package": null, "version": null}, {"name": "service_category__lab_professional", "package": null, "version": null}, {"name": "service_category__office_based_other_professional", "package": null, "version": null}, {"name": "service_category__office_based_physical_therapy_professional", "package": null, "version": null}, {"name": "service_category__office_based_radiology", "package": null, "version": null}, {"name": "service_category__office_based_surgery_professional", "package": null, "version": null}, {"name": "service_category__office_based_visit_professional", "package": null, "version": null}, {"name": "service_category__outpatient_hospital_or_clinic_professional", "package": null, "version": null}, {"name": "service_category__outpatient_psychiatric_professional", "package": null, "version": null}, {"name": "service_category__outpatient_rehab_professional", "package": null, "version": null}, {"name": "service_category__inpatient_skilled_nursing_professional", "package": null, "version": null}, {"name": "service_category__urgent_care_professional", "package": null, "version": null}, {"name": "service_category__outpatient_hospice_professional", "package": null, "version": null}, {"name": "service_category__pharmacy_professional", "package": null, "version": null}, {"name": "service_category__outpatient_substance_use_professional", "package": null, "version": null}, {"name": "service_category__outpatient_physical_therapy_professional", "package": null, "version": null}, {"name": "service_category__outpatient_radiology_professional", "package": null, "version": null}, {"name": "service_category__observation_professional", "package": null, "version": null}, {"name": "service_category__dme_professional", "package": null, "version": null}, {"name": "service_category__ambulance_professional", "package": null, "version": null}, {"name": "service_category__outpatient_surgery_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.service_category__acute_inpatient_professional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "model.the_tuva_project.service_category__inpatient_rehab_professional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__office_based_other_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "model.the_tuva_project.service_category__outpatient_rehab_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "model.the_tuva_project.service_category__urgent_care_professional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__ambulance_professional", "model.the_tuva_project.service_category__outpatient_surgery_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__combined_professional.sql", "compiled": true, "compiled_code": "\n\nWITH combined_professional_services AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulatory_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_ambulatory_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_dialysis_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_dialysis_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_emergency_department_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_emergency_department_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_home_health_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_home_health_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_lab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_lab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_other_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_other_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_radiology' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_radiology\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_office_based_visit_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_office_based_visit_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_urgent_care_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_urgent_care_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__pharmacy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__pharmacy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_observation_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_observation_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_dme_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_dme_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulance_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_ambulance_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_professional\n\n \n )\n\n \n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.claim_line_id,\n p.service_category_1,\n p.service_category_2,\n p.service_category_3,\n p.tuva_last_run,\n p.source_model_name\nFROM combined_professional_services p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_institutional_med_surg", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_med_surg.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_med_surg.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_institutional_med_surg"], "alias": "_int_acute_inpatient_institutional_med_surg", "checksum": {"name": "sha256", "checksum": "9afbdc2364199500f1de12354eabc35a96587588898cf035243428b6e69c957b"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_institutional_med_surg", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_institutional_med_surg", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.656801, "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_med_surg", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when m.medical_surgical = 'M' then 'medical'\n when m.medical_surgical = 'P' then 'surgical'\n when m.medical_surgical = 'surgical' then 'surgical'\n else 'acute inpatient - other' \n end as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} as a\n on s.claim_id = a.claim_id\ninner join {{ ref('terminology__ms_drg') }} as m\n on s.ms_drg_code = m.ms_drg_code", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_med_surg.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when m.medical_surgical = 'M' then 'medical'\n when m.medical_surgical = 'P' then 'surgical'\n when m.medical_surgical = 'surgical' then 'surgical'\n else 'acute inpatient - other' \n end as service_category_3\n , '_int_acute_inpatient_institutional_med_surg' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join cms_synthetic.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_institutional_other": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_institutional_other", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_other.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_other.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_institutional_other"], "alias": "_int_acute_inpatient_institutional_other", "checksum": {"name": "sha256", "checksum": "1f7bc9a7c68fe095e880fc5b6224ca4948f431a87015e3d3666857391fb819ce"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_institutional_other", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_institutional_other", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.659895, "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_other", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\n--simplified by setting lowest priority instead of explicitly doing all the joins\nselect distinct \n a.claim_id\n , 'inpatient' as service_category_1\n, 'acute inpatient' as service_category_2\n, 'acute inpatient - other' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} a on s.claim_id = a.claim_id", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_institutional_other.sql", "compiled": true, "compiled_code": "\n\n\n--simplified by setting lowest priority instead of explicitly doing all the joins\nselect distinct \n a.claim_id\n , 'inpatient' as service_category_1\n, 'acute inpatient' as service_category_2\n, 'acute inpatient - other' as service_category_3\n, '_int_acute_inpatient_institutional_other' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulance_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__ambulance_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__ambulance_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__ambulance_professional.sql", "unique_id": "model.the_tuva_project.service_category__ambulance_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulance_professional"], "alias": "_int_ambulance_professional", "checksum": {"name": "sha256", "checksum": "de381af9f9b683410e26fa1c7b650e11304d8ecef479704958034b4962d36a4e"}, "config": {"enabled": true, "alias": "_int_ambulance_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulance_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6082492, "relation_name": "cms_synthetic.claims_preprocessing._int_ambulance_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere \n claim_type = 'professional'\n and (\n hcpcs_code between 'A0425' and 'A0436'\n or place_of_service_code in ('41', '42')\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__ambulance_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and (\n hcpcs_code between 'A0425' and 'A0436'\n or place_of_service_code in ('41', '42')\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_other_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__office_based_other_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__office_based_other_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__office_based_other_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_other_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_other_professional"], "alias": "service_category__office_based_other_professional", "checksum": {"name": "sha256", "checksum": "6dd204055f8ad24296a02fa962f9f1208365fd239172e4894bc5cebb52f1abac"}, "config": {"enabled": true, "alias": "service_category__office_based_other_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_other_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6679308, "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_other_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\n select distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'office-based' as service_category_1 \n, 'office-based other' as service_category_2\n, 'office-based other' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ ref('service_category__stg_office_based') }} med\n left join {{ ref('service_category__pharmacy_professional') }} pharm on med.claim_line_id = pharm.claim_line_id\n left join {{ ref('service_category__office_based_radiology') }} rad on med.claim_line_id = rad.claim_line_id\n left join {{ ref('service_category__office_based_visit_professional') }} visit on med.claim_line_id = visit.claim_line_id\n left join {{ ref('service_category__office_based_surgery_professional') }} surg on med.claim_line_id = surg.claim_line_id\n left join {{ ref('service_category__office_based_physical_therapy_professional') }} pt on med.claim_line_id = pt.claim_line_id\n where pharm.claim_line_id is null \n and rad.claim_line_id is null \n and visit.claim_line_id is null\n and surg.claim_line_id is null\n and pt.claim_line_id is null", "language": "sql", "refs": [{"name": "service_category__stg_office_based", "package": null, "version": null}, {"name": "service_category__pharmacy_professional", "package": null, "version": null}, {"name": "service_category__office_based_radiology", "package": null, "version": null}, {"name": "service_category__office_based_visit_professional", "package": null, "version": null}, {"name": "service_category__office_based_surgery_professional", "package": null, "version": null}, {"name": "service_category__office_based_physical_therapy_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_office_based", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__office_based_other_professional.sql", "compiled": true, "compiled_code": "\n\n\n select distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'office-based' as service_category_1 \n, 'office-based other' as service_category_2\n, 'office-based other' as service_category_3\n, 'service_category__office_based_other_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_office_based med\n left join cms_synthetic.claims_preprocessing.service_category__pharmacy_professional pharm on med.claim_line_id = pharm.claim_line_id\n left join cms_synthetic.claims_preprocessing.service_category__office_based_radiology rad on med.claim_line_id = rad.claim_line_id\n left join cms_synthetic.claims_preprocessing._int_office_based_visit_professional visit on med.claim_line_id = visit.claim_line_id\n left join cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional surg on med.claim_line_id = surg.claim_line_id\n left join cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional pt on med.claim_line_id = pt.claim_line_id\n where pharm.claim_line_id is null \n and rad.claim_line_id is null \n and visit.claim_line_id is null\n and surg.claim_line_id is null\n and pt.claim_line_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_substance_use_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_substance_use_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_substance_use_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_substance_use_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_substance_use_professional"], "alias": "service_category__outpatient_substance_use_professional", "checksum": {"name": "sha256", "checksum": "a32061f09cb5f6fcd8319911ed474a5943807c12f0af06de574a31de5a850c1d"}, "config": {"enabled": true, "alias": "service_category__outpatient_substance_use_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_substance_use_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.683393, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_professional') }} as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n and med.place_of_service_code <> '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_substance_use_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n and med.place_of_service_code <> '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_surgery_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__office_based_surgery_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__office_based_surgery_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__office_based_surgery_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_surgery_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_surgery_professional"], "alias": "service_category__office_based_surgery_professional", "checksum": {"name": "sha256", "checksum": "3c532731262206d5a8e83aaac7f2431de39c983a5c71d08282b9f3e6f91d8bde"}, "config": {"enabled": true, "alias": "service_category__office_based_surgery_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_surgery_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.672122, "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n{# Since HCPCS is a string, we need to exclude values that would fall in our comparison range for alphanumeric values #}\nwith numeric_hcpcs as (\n select *\n from {{ ref('service_category__stg_medical_claim') }} as med\n where {{ safe_cast('hcpcs_code', 'int')}} is not null\n)\n\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n ,'office-based' as service_category_1 \n , 'office-based surgery' as service_category_2\n , 'office-based surgery' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\n from numeric_hcpcs as med\n inner join {{ ref('service_category__stg_office_based') }} as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\n where \n (hcpcs_code between '10021' and '69999')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.safe_cast"], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__office_based_surgery_professional.sql", "compiled": true, "compiled_code": "\n\n\nwith numeric_hcpcs as (\n select *\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\n where \n \n try_cast(hcpcs_code as int)\n is not null\n)\n\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n ,'office-based' as service_category_1 \n , 'office-based surgery' as service_category_2\n , 'office-based surgery' as service_category_3\n , 'service_category__office_based_surgery_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from numeric_hcpcs as med\n inner join cms_synthetic.dbt_tom.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\n where \n (hcpcs_code between '10021' and '69999')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_psychiatric_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_psychiatric_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_psychiatric_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_psychiatric_institutional"], "alias": "_int_inpatient_psychiatric_institutional", "checksum": {"name": "sha256", "checksum": "ee32c9cf04597df3693179895bb67c5aa3cc559410bb9654fd4c86c80b866450"}, "config": {"enabled": true, "alias": "_int_inpatient_psychiatric_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_psychiatric_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6322932, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} s\ninner join {{ ref('service_category__stg_inpatient_institutional') }} i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_psychiatric_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n, '_int_inpatient_psychiatric_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulance_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__ambulance_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__ambulance_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__ambulance_institutional.sql", "unique_id": "model.the_tuva_project.service_category__ambulance_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulance_institutional"], "alias": "_int_ambulance_institutional", "checksum": {"name": "sha256", "checksum": "1d3e99785c3af0f7f5676c5804e9cf24ee6689821d14d422836468a8cf6af40a"}, "config": {"enabled": true, "alias": "_int_ambulance_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulance_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.609704, "relation_name": "cms_synthetic.claims_preprocessing._int_ambulance_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n (med.hcpcs_code between 'A0425' and 'A0436')\n or med.revenue_center_code = '0540'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__ambulance_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n (med.hcpcs_code between 'A0425' and 'A0436')\n or med.revenue_center_code = '0540'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_psychiatric_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_psychiatric_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_psychiatric_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_psychiatric_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_psychiatric_professional"], "alias": "_int_outpatient_psychiatric_professional", "checksum": {"name": "sha256", "checksum": "a3cebfcf3a8ce2f0e92ef88ec398df91ca524edc26f7d5606069a1f468101a75"}, "config": {"enabled": true, "alias": "_int_outpatient_psychiatric_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_psychiatric_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.647645, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\n and place_of_service_code in ('52','53','57','58')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_psychiatric_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n, '_int_outpatient_psychiatric_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('52','53','57','58')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_substance_use_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_substance_use_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_substance_use_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_substance_use_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_substance_use_institutional"], "alias": "service_category__outpatient_substance_use_institutional", "checksum": {"name": "sha256", "checksum": "b1c135b2182fe22344604ba2050c3ef5c3f525011a5ca6fef4cc38816ec3e9bd"}, "config": {"enabled": true, "alias": "service_category__outpatient_substance_use_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_substance_use_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.682137, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as o\n on med.claim_id = o.claim_id\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n or med.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_substance_use_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as o\n on med.claim_id = o.claim_id\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n or med.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__emergency_department_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__emergency_department_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__emergency_department_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__emergency_department_institutional.sql", "unique_id": "model.the_tuva_project.service_category__emergency_department_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__emergency_department_institutional"], "alias": "_int_emergency_department_institutional", "checksum": {"name": "sha256", "checksum": "694bd13ee40ea74df0f128f4010fd32d1db2485156a433c4fc2640061b854e17"}, "config": {"enabled": true, "alias": "_int_emergency_department_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_emergency_department_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6177979, "relation_name": "cms_synthetic.claims_preprocessing._int_emergency_department_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n , '{{ this.name }}' as source_model_name\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')\n \nunion all\n\n--Adding in inpatient claims for flagging encounters with ED \nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n , '{{ this.name }}' as source_model_name\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_inpatient_institutional') }} inp\n on med.claim_id = inp.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\n\n)\n\nselect claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,tuva_last_run\n,source_model_name\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__emergency_department_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')\n \nunion all\n\n--Adding in inpatient claims for flagging encounters with ED \nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional inp\n on med.claim_id = inp.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\n\n)\n\nselect claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,tuva_last_run\n,source_model_name\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_surgery_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_surgery_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_surgery_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_surgery_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_surgery_professional"], "alias": "service_category__outpatient_surgery_professional", "checksum": {"name": "sha256", "checksum": "41f7285dff0d13615c390382cf6bf1887ae03373b6098de4109de54652235336"}, "config": {"enabled": true, "alias": "service_category__outpatient_surgery_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_surgery_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.686096, "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\n(ccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244'))\nand\nplace_of_service_code in ('15','17','19','22','49','50','60','71','72')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_surgery_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\n(ccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244'))\nand\nplace_of_service_code in ('15','17','19','22','49','50','60','71','72')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospital_or_clinic_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_hospital_or_clinic_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospital_or_clinic_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospital_or_clinic_institutional"], "alias": "_int_outpatient_hospital_or_clinic_institutional", "checksum": {"name": "sha256", "checksum": "6ac8b3001d88bb951976ae4cc16183a10555c0d8d40230b92c17983bcebae752"}, "config": {"enabled": true, "alias": "_int_outpatient_hospital_or_clinic_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospital_or_clinic_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6432261, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\n from {{ ref('service_category__stg_medical_claim') }} as m\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as o\n on m.claim_id = o.claim_id\n where \n substring(m.bill_type_code, 1, 2) in ('13', '71', '73')\n\n union all\n\n select distinct\n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\n from {{ ref('service_category__stg_medical_claim') }} as m\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as o\n on m.claim_id = o.claim_id\n where \n m.ccs_category = '227' -- Consultation, evaluation, and preventative care\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_hospital_or_clinic_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as m\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n substring(m.bill_type_code, 1, 2) in ('13', '71', '73')\n\n union all\n\n select distinct\n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as m\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n m.ccs_category = '227' -- Consultation, evaluation, and preventative care\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_rehab_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_rehab_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_rehab_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_rehab_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_rehab_professional"], "alias": "_int_outpatient_rehab_professional", "checksum": {"name": "sha256", "checksum": "242be9814347785afcac265329b5908f2041896c1c5ff8c036a8d316339c2284"}, "config": {"enabled": true, "alias": "_int_outpatient_rehab_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_rehab_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6489952, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_rehab_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient rehabilitation' as service_category_2\n, 'outpatient rehabilitation' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'professional'\n and place_of_service_code in ('62')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_rehab_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient rehabilitation' as service_category_2\n, 'outpatient rehabilitation' as service_category_3\n,'_int_outpatient_rehab_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('62')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__outpatient_psychiatric_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__outpatient_psychiatric_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__outpatient_psychiatric_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_psychiatric_institutional"], "alias": "_int_outpatient_psychiatric_institutional", "checksum": {"name": "sha256", "checksum": "cdecdf6c29202d9033f3667c5d74fce51b8862ef4c1819780a7549bac7490441"}, "config": {"enabled": true, "alias": "_int_outpatient_psychiatric_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_psychiatric_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.646083, "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nwith multiple_sources as (\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} m\ninner join {{ ref('service_category__stg_outpatient_institutional') }} i on m.claim_id = i.claim_id\nwhere substring(m.bill_type_code, 1, 2) in ('52')\n\nunion all\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} m\ninner join {{ ref('service_category__stg_outpatient_institutional') }} i on m.claim_id = i.claim_id\nwhere m.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')\n)\n\nselect distinct claim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__outpatient_psychiatric_institutional.sql", "compiled": true, "compiled_code": "\nwith multiple_sources as (\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim m\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere substring(m.bill_type_code, 1, 2) in ('52')\n\nunion all\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim m\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere m.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')\n)\n\nselect distinct claim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__observation_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__observation_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__observation_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__observation_professional.sql", "unique_id": "model.the_tuva_project.service_category__observation_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__observation_professional"], "alias": "_int_observation_professional", "checksum": {"name": "sha256", "checksum": "01f21647ee7b57e60d6a5cfd65cc333e8df6d15924caa9b19a295d68eab7a466"}, "config": {"enabled": true, "alias": "_int_observation_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_observation_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6648588, "relation_name": "cms_synthetic.claims_preprocessing._int_observation_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'observation' as service_category_2\n , 'observation' as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_professional') }} as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.hcpcs_code in ('G0378', 'G0379')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__observation_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'observation' as service_category_2\n , 'observation' as service_category_3\n , '_int_observation_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.hcpcs_code in ('G0378', 'G0379')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_physical_therapy_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__office_based_physical_therapy_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__office_based_physical_therapy_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__office_based_physical_therapy_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_physical_therapy_professional"], "alias": "service_category__office_based_physical_therapy_professional", "checksum": {"name": "sha256", "checksum": "092f3e901a001dfc45f1bb627bcc6ce53a8baba6d3063cef66bced0bfc561d71"}, "config": {"enabled": true, "alias": "service_category__office_based_physical_therapy_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_physical_therapy_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.669433, "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based pt/ot/st' as service_category_2\n , 'office-based pt/ot/st' as service_category_3\n ,'{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\ninner join {{ ref('service_category__stg_office_based') }} prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (\nccs_category in ('213','212','215')\nOR\n med.rend_primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nand place_of_service_code = '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__office_based_physical_therapy_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based pt/ot/st' as service_category_2\n , 'office-based pt/ot/st' as service_category_3\n ,'service_category__office_based_physical_therapy_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_office_based prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (\nccs_category in ('213','212','215')\nOR\n med.rend_primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nand place_of_service_code = '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__observation_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__observation_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__observation_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__observation_institutional.sql", "unique_id": "model.the_tuva_project.service_category__observation_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__observation_institutional"], "alias": "_int_observation_institutional", "checksum": {"name": "sha256", "checksum": "11207f7152eabc3fcc80f2f0650480807ab4a4ed31f47fadc3c1be3bd6601393"}, "config": {"enabled": true, "alias": "_int_observation_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_observation_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.663394, "relation_name": "cms_synthetic.claims_preprocessing._int_observation_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1\n, 'observation' as service_category_2\n, 'observation' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} med\nwhere claim_type = 'institutional'\nand (revenue_center_code in ('0762')\nor hcpcs_code in ('G0378','G0379')\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__observation_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1\n, 'observation' as service_category_2\n, 'observation' as service_category_3\n, '_int_observation_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\nwhere claim_type = 'institutional'\nand (revenue_center_code in ('0762')\nor hcpcs_code in ('G0378','G0379')\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__inpatient_skilled_nursing_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_institutional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_skilled_nursing_institutional"], "alias": "_int_inpatient_skilled_nursing_institutional", "checksum": {"name": "sha256", "checksum": "bebbf1478b6e65491f205c6b456df2d3e3ca602882e213454c37ee7c8b40c575"}, "config": {"enabled": true, "alias": "_int_inpatient_skilled_nursing_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_skilled_nursing_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.650476, "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n claim_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '{{ this.name }}' as source_model_name\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('21','22')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('21','22')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_visit_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__office_based_visit_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__office_based_visit_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__office_based_visit_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_visit_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_visit_professional"], "alias": "_int_office_based_visit_professional", "checksum": {"name": "sha256", "checksum": "06f6c3b8b9ddf2955e9ca255f8b81606c2b4a90b2c9ea2cc4d8b0fbd42608ae6"}, "config": {"enabled": true, "alias": "_int_office_based_visit_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_office_based_visit_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.641953, "relation_name": "cms_synthetic.claims_preprocessing._int_office_based_visit_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_2\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }} as med\ninner join {{ ref('service_category__stg_office_based') }} as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n (med.place_of_service_code = '11' and med.ccs_category = '227') -- consultation eval and preventative care\n or med.place_of_service_code in ('02', '10') -- telehealth", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__office_based_visit_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_2\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_3\n , '_int_office_based_visit_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n (med.place_of_service_code = '11' and med.ccs_category = '227') -- consultation eval and preventative care\n or med.place_of_service_code in ('02', '10') -- telehealth", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_professional.sql", "original_file_path": "models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_professional.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_professional"], "alias": "_int_acute_inpatient_professional", "checksum": {"name": "sha256", "checksum": "deacedc96e4c95eece68a1bb65b2e6bfa54ccded21bfe2f537764c68f8cd40a1"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/service_category/service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.606563, "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when hcpcs_code in ('59400', '59409', '59410', '59610', '59612', '59614') then 'l/d - vaginal delivery'\n when hcpcs_code in ('59510', '59514', '59515', '59618', '59620', '59622') then 'l/d - cesarean delivery'\n else 'acute inpatient - other'\n end as service_category_3\n , '{{ this.name }}' as source_model_name\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('service_category__stg_medical_claim') }}\nwhere \n claim_type = 'professional'\n and place_of_service_code = '21'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/service_category/intermediate/service_category__acute_inpatient_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when hcpcs_code in ('59400', '59409', '59410', '59610', '59612', '59614') then 'l/d - vaginal delivery'\n when hcpcs_code in ('59510', '59514', '59515', '59618', '59620', '59622') then 'l/d - cesarean delivery'\n else 'acute inpatient - other'\n end as service_category_3\n , '_int_acute_inpatient_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and place_of_service_code = '21'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__patient_data_source_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__patient_data_source_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/staging/encounters__patient_data_source_id.sql", "original_file_path": "models/claims_preprocessing/encounters/staging/encounters__patient_data_source_id.sql", "unique_id": "model.the_tuva_project.encounters__patient_data_source_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__patient_data_source_id"], "alias": "encounters__patient_data_source_id", "checksum": {"name": "sha256", "checksum": "0b015a4233085095a8196d904be833715363dffe7f3bab9d416a6469065a52bf"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.869932, "relation_name": "cms_synthetic.claims_preprocessing.encounters__patient_data_source_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith multiple_sources as (\nselect distinct patient_id\n,data_source\nfrom {{ ref('normalized_input__medical_claim') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect distinct patient_id\n,data_source\nfrom {{ ref('normalized_input__eligibility')}}\n)\n\nselect\npatient_id\n,data_source\n,dense_rank() over (order by concat(patient_id,data_source)) as patient_data_source_id\nfrom multiple_sources", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.normalized_input__eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/staging/encounters__patient_data_source_id.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct patient_id\n,data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\n\n\nunion distinct\n\n\nselect distinct patient_id\n,data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\npatient_id\n,data_source\n,dense_rank() over (order by concat(patient_id,data_source)) as patient_data_source_id\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_professional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__stg_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/staging/encounters__stg_professional.sql", "original_file_path": "models/claims_preprocessing/encounters/staging/encounters__stg_professional.sql", "unique_id": "model.the_tuva_project.encounters__stg_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_professional"], "alias": "encounters__stg_professional", "checksum": {"name": "sha256", "checksum": "36e75e2869421bc9ca3e9d69847c7150e12fcbb594a4463795d7f66b80efaa4e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.867531, "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_professional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct \n claim_id\n, claim_line_number\n, claim_line_id\n, service_type\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_professional') }} a", "language": "sql", "refs": [{"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/staging/encounters__stg_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, claim_line_number\n, claim_line_id\n, service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_professional a", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_outpatient_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__stg_outpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/staging/encounters__stg_outpatient_institutional.sql", "original_file_path": "models/claims_preprocessing/encounters/staging/encounters__stg_outpatient_institutional.sql", "unique_id": "model.the_tuva_project.encounters__stg_outpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_outpatient_institutional"], "alias": "encounters__stg_outpatient_institutional", "checksum": {"name": "sha256", "checksum": "e02093edaa8c4c9a54f6bbd35f66ff5700b96f4881de8b9707273cad5bb7ab73"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8661702, "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_outpatient_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\nselect distinct \n claim_id\n, service_type\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_outpatient_institutional') }} a", "language": "sql", "refs": [{"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/staging/encounters__stg_outpatient_institutional.sql", "compiled": true, "compiled_code": "\n\n\nselect distinct \n claim_id\n, service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional a", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_medical_claim": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/staging/encounters__stg_medical_claim.sql", "original_file_path": "models/claims_preprocessing/encounters/staging/encounters__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.encounters__stg_medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_medical_claim"], "alias": "encounters__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "5911950b18fdef94c6f974b1e808d77be8b06872aa71a395c3e0be7856bc43e4"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Staging med claims for encounter grouper", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.863811, "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_medical_claim", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\nselect\n m.apr_drg_code\n , m.patient_id \n , d.patient_data_source_id\n , m.claim_id\n , m.claim_line_number\n , {{ dbt.concat([\"m.claim_id\",\"'|'\",\"cast(m.claim_line_number as \" ~ dbt.type_string() ~ \")\"]) }} as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , g.service_category_1\n , g.service_category_2\n , g.service_category_3\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , m.hcpcs_modifier_1\n , m.hcpcs_modifier_2\n , m.hcpcs_modifier_3\n , m.hcpcs_modifier_4\n , m.hcpcs_modifier_5\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.admit_source_code\n , m.admit_type_code\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_type\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , n.modality\n , m.billing_id\n , m.rendering_id\n , rend.primary_specialty_description as rend_primary_specialty_description\n , m.facility_id\n , m.discharge_disposition_code\n , m.paid_amount\n , m.charge_amount\n , m.allowed_amount\n , m.data_source\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('normalized_input__medical_claim') }} m\ninner join {{ ref('service_category__service_category_grouper') }} g on m.claim_id = g.claim_id\nand\nm.claim_line_number = g.claim_line_number\nand g.duplicate_row_number = 1\ninner join {{ ref('encounters__patient_data_source_id') }} d on m.patient_id = d.patient_id\nand\nm.data_source = d.data_source\nleft join {{ ref('ccsr__dxccsr_v2023_1_cleaned_map') }} dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join {{ ref('terminology__provider') }} p on m.facility_id = p.npi\nleft join {{ ref('terminology__ccs_services_procedures') }} c on m.hcpcs_code = c.hcpcs_code\nleft join {{ ref('terminology__nitos') }} n on m.hcpcs_code = n.hcpcs_code\nleft join {{ ref('terminology__ms_drg') }} drg on m.ms_drg_code = drg.ms_drg_code\nleft join {{ ref('terminology__revenue_center') }} r on m.revenue_center_code = r.revenue_center_code\nleft join {{ ref('terminology__place_of_service') }} pos on m.place_of_service_code = pos.place_of_service_code\nleft join {{ ref('terminology__bill_type') }} bt on m.bill_type_code = bt.bill_type_code\nleft join {{ ref('terminology__provider')}} rend on m.rendering_id = rend.npi", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "encounters__patient_data_source_id", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_cleaned_map", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__ccs_services_procedures", "package": null, "version": null}, {"name": "terminology__nitos", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.encounters__patient_data_source_id", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__revenue_center", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/staging/encounters__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nselect\n m.apr_drg_code\n , m.patient_id \n , d.patient_data_source_id\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , g.service_category_1\n , g.service_category_2\n , g.service_category_3\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , m.hcpcs_modifier_1\n , m.hcpcs_modifier_2\n , m.hcpcs_modifier_3\n , m.hcpcs_modifier_4\n , m.hcpcs_modifier_5\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.admit_source_code\n , m.admit_type_code\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_type\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , n.modality\n , m.billing_id\n , m.rendering_id\n , rend.primary_specialty_description as rend_primary_specialty_description\n , m.facility_id\n , m.discharge_disposition_code\n , m.paid_amount\n , m.charge_amount\n , m.allowed_amount\n , m.data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim m\ninner join cms_synthetic.claims_preprocessing.service_category_grouper g on m.claim_id = g.claim_id\nand\nm.claim_line_number = g.claim_line_number\nand g.duplicate_row_number = 1\ninner join cms_synthetic.claims_preprocessing.encounters__patient_data_source_id d on m.patient_id = d.patient_id\nand\nm.data_source = d.data_source\nleft join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join cms_synthetic.terminology.provider p on m.facility_id = p.npi\nleft join cms_synthetic.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join cms_synthetic.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join cms_synthetic.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join cms_synthetic.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join cms_synthetic.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join cms_synthetic.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join cms_synthetic.terminology.provider rend on m.rendering_id = rend.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_inpatient_institutional": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__stg_inpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/staging/encounters__stg_inpatient_institutional.sql", "original_file_path": "models/claims_preprocessing/encounters/staging/encounters__stg_inpatient_institutional.sql", "unique_id": "model.the_tuva_project.encounters__stg_inpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_inpatient_institutional"], "alias": "encounters__stg_inpatient_institutional", "checksum": {"name": "sha256", "checksum": "ad5df60cf550bf94c050b34f087cbd34d5cc112fec4c2f9731dde3c8c853a96a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.864933, "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_inpatient_institutional", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect \n claim_id\n, service_type\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('service_category__stg_inpatient_institutional') }} a", "language": "sql", "refs": [{"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/staging/encounters__stg_inpatient_institutional.sql", "compiled": true, "compiled_code": "\n\nselect \n claim_id\n, service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional a", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_eligibility": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/staging/encounters__stg_eligibility.sql", "original_file_path": "models/claims_preprocessing/encounters/staging/encounters__stg_eligibility.sql", "unique_id": "model.the_tuva_project.encounters__stg_eligibility", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_eligibility"], "alias": "encounters__stg_eligibility", "checksum": {"name": "sha256", "checksum": "a65c57fa001ea0af43753db963e78a25d617b780942e142e244edaf71578e01d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.868782, "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_eligibility", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n e.patient_id\n , e.birth_date\n , e.gender\n , e.race\n , d.patient_data_source_id\n , row_number() over (partition by d.patient_data_source_id order by e.enrollment_start_date desc) patient_row_num\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('normalized_input__eligibility') }} e\ninner join {{ ref('encounters__patient_data_source_id') }} d on e.patient_id = d.patient_id\nand\ne.data_source = d.data_source", "language": "sql", "refs": [{"name": "normalized_input__eligibility", "package": null, "version": null}, {"name": "encounters__patient_data_source_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__eligibility", "model.the_tuva_project.encounters__patient_data_source_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/staging/encounters__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\nselect\n e.patient_id\n , e.birth_date\n , e.gender\n , e.race\n , d.patient_data_source_id\n , row_number() over (partition by d.patient_data_source_id order by e.enrollment_start_date desc) patient_row_num\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_eligibility e\ninner join cms_synthetic.claims_preprocessing.encounters__patient_data_source_id d on e.patient_id = d.patient_id\nand\ne.data_source = d.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "ambulance__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/ambulance__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/ambulance__encounter_grain.sql", "unique_id": "model.the_tuva_project.ambulance__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "ambulance__encounter_grain"], "alias": "ambulance__encounter_grain", "checksum": {"name": "sha256", "checksum": "e9009be794e71259236e32f64e33a4b9f98f114577f04b09a67467814109ba35"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per ambulance encounter id summarizing encounter level metrics. ambulances will roll up to other encounters unless they appear on their own day with no other claims.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.753633, "relation_name": "cms_synthetic.claims_preprocessing.ambulance__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('ambulance__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulance - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type -- not changing grain, but bringing into final\n, encounter_group\n\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "ambulance__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/ambulance__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.ambulance__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulance - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type -- not changing grain, but bringing into final\n, encounter_group\n\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_substance_use__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/inpatient_substance_use__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/inpatient_substance_use__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_substance_use__encounter_grain"], "alias": "inpatient_substance_use__encounter_grain", "checksum": {"name": "sha256", "checksum": "262e6850c52269f88fc8d3ac4ab69e7b42fdd150472da91fd11b3fba5dfef82d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.707754, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('inpatient_substance_use__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('inpatient_substance_use__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_substance_use__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_substance_use__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_substance_use__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/inpatient_substance_use__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_surgery__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_surgery__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_surgery__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_surgery__encounter_grain"], "alias": "outpatient_surgery__encounter_grain", "checksum": {"name": "sha256", "checksum": "d7d94d0312a8c014ed1c3988a889a197def1c4d75dc2de77dbd03dc35d7bb08f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient rehab encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7250078, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_surgery__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient surgery'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_surgery__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_surgery__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_surgery__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_surgery__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient surgery'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dialysis__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/dialysis__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/dialysis__encounter_grain.sql", "unique_id": "model.the_tuva_project.dialysis__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "dialysis__encounter_grain"], "alias": "dialysis__encounter_grain", "checksum": {"name": "sha256", "checksum": "9018cb7e53a9fbd4a6b7882b32d50da6635cbe3a6f7b165ef70b99ea87ad69d8"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per dialysis encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7302, "relation_name": "cms_synthetic.claims_preprocessing.dialysis__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('dialysis__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dialysis'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "dialysis__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/dialysis__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.dialysis__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dialysis'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "acute_inpatient__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/acute_inpatient__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/acute_inpatient__encounter_grain.sql", "unique_id": "model.the_tuva_project.acute_inpatient__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "acute_inpatient__encounter_grain"], "alias": "acute_inpatient__encounter_grain", "checksum": {"name": "sha256", "checksum": "98b5f7e90793dbb3454a2d11567696443254d97c800117976dadd1386c353aed"}, "config": {"enabled": true, "alias": "acute_inpatient__encounter_grain", "schema": "claims_preprocessing", "database": null, "tags": ["acute_inpatient", "claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["acute_inpatient", "claims_preprocessing", "encounters"], "description": "This table pulls together all the data needed to perform acute inpatient analytics into a single table.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "acute_inpatient__encounter_grain", "tags": ["acute_inpatient", "claims_preprocessing", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.695429, "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'acute inpatient'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('acute_inpatient__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when d.service_category_3 in ( 'l/d - cesarean delivery', 'l/d - vaginal delivery') then 1 else 0 end ) as delivery_flag\n ,max(case when d.service_category_3 ='l/d - cesarean delivery' then 1 else 0 end ) as cesarean_delivery\n ,max(case when d.service_category_3 ='l/d - vaginal delivery' then 1 else 0 end ) as vaginal_delivery\n ,max(case when d.service_category_3 in ('l/d - newborn','l/d - newborn nicu') then 1 else 0 end ) as newborn_flag\n ,max(case when d.service_category_3 ='l/d - newborn nicu' then 1 else 0 end ) as nicu_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n,encounter_group\n)\n\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, sc.observation_flag\n, sc.ed_flag\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.delivery_flag\n, case when sc.cesarean_delivery = 1 then 'cesarean'\n when sc.vaginal_delivery = 1 then 'vaginal'\n else null end as delivery_type\n, sc.newborn_flag\n, sc.nicu_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('acute_inpatient__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "acute_inpatient__start_end_dates", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "acute_inpatient__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.encounters__stg_eligibility", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/acute_inpatient__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'acute inpatient'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when d.service_category_3 in ( 'l/d - cesarean delivery', 'l/d - vaginal delivery') then 1 else 0 end ) as delivery_flag\n ,max(case when d.service_category_3 ='l/d - cesarean delivery' then 1 else 0 end ) as cesarean_delivery\n ,max(case when d.service_category_3 ='l/d - vaginal delivery' then 1 else 0 end ) as vaginal_delivery\n ,max(case when d.service_category_3 in ('l/d - newborn','l/d - newborn nicu') then 1 else 0 end ) as newborn_flag\n ,max(case when d.service_category_3 ='l/d - newborn nicu' then 1 else 0 end ) as nicu_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n,encounter_group\n)\n\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, sc.observation_flag\n, sc.ed_flag\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.delivery_flag\n, case when sc.cesarean_delivery = 1 then 'cesarean'\n when sc.vaginal_delivery = 1 then 'vaginal'\n else null end as delivery_type\n, sc.newborn_flag\n, sc.nicu_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_rehab__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_rehab__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_rehab__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_rehab__encounter_grain"], "alias": "outpatient_rehab__encounter_grain", "checksum": {"name": "sha256", "checksum": "e69a2ea3a04be239d13c1c0e14355e68b04e177611768488042e293757d74c77"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient rehab encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7198489, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_rehab__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_rehab__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_rehab__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_rehab__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_rehab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "home_health__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/home_health__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/home_health__encounter_grain.sql", "unique_id": "model.the_tuva_project.home_health__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "home_health__encounter_grain"], "alias": "home_health__encounter_grain", "checksum": {"name": "sha256", "checksum": "ca289b401990d573d97e19ac62766487b62bd79a827219e6081149f31738043e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.735092, "relation_name": "cms_synthetic.claims_preprocessing.home_health__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('home_health__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'home health'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "home_health__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.home_health__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/home_health__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.home_health__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'home health'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.orphaned_claim__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "orphaned_claim__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/orphaned_claim__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/orphaned_claim__encounter_grain.sql", "unique_id": "model.the_tuva_project.orphaned_claim__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "orphaned_claim__encounter_grain"], "alias": "orphaned_claim__encounter_grain", "checksum": {"name": "sha256", "checksum": "9403c793fedbd201ed4c2938f3627cb56ca8f501d867f8ca80039133e95df748"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "orphaned claims (usually professional claims) that don't roll up to an anchor event, get assigned their own encounter id for completeness.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7558641, "relation_name": "cms_synthetic.claims_preprocessing.orphaned_claim__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select\n cli.encounter_id\n , min(stg.start_date) as encounter_start_date\n , max(stg.start_date) as encounter_end_date\n from {{ ref('encounters__stg_medical_claim') }} as stg\n inner join {{ ref('encounters__orphaned_claims') }} as cli\n on stg.claim_id = cli.claim_id\n and stg.claim_line_number = cli.claim_line_number\n group by\n cli.encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n ,d.encounter_end_date\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__orphaned_claims') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n inner join encounter_date d on cli.encounter_id = d.encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__orphaned_claims", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__orphaned_claims", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/orphaned_claim__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select\n cli.encounter_id\n , min(stg.start_date) as encounter_start_date\n , max(stg.start_date) as encounter_end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as stg\n inner join cms_synthetic.claims_preprocessing.encounters__orphaned_claims as cli\n on stg.claim_id = cli.claim_id\n and stg.claim_line_number = cli.claim_line_number\n group by\n cli.encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n ,d.encounter_end_date\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__orphaned_claims cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n inner join encounter_date d on cli.encounter_id = d.encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_ptotst__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_ptotst__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_ptotst__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_ptotst__encounter_grain"], "alias": "outpatient_ptotst__encounter_grain", "checksum": {"name": "sha256", "checksum": "fdef59d3bc790bb0478807daf33da97a1eeeb40d89c41b3abfb7bf52eb0f109f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.742306, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_ptotst__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient pt/ot/st'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_ptotst__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_ptotst__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_ptotst__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient pt/ot/st'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_radiology__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_radiology__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_radiology__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_radiology__encounter_grain"], "alias": "outpatient_radiology__encounter_grain", "checksum": {"name": "sha256", "checksum": "13f617a800869b8a7a0ed057f532b30ae0425183acb0a37ae5687e5698672db3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient radiology encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.744479, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_radiology__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient radiology'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,hcpcs_code as \n(\n select distinct hcpcs_code\n ,encounter_id\n from detail_values\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join hcpcs_code hcpc on d.encounter_id = hcpc.encounter_id\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_radiology__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_radiology__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_radiology__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_radiology__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient radiology'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,hcpcs_code as \n(\n select distinct hcpcs_code\n ,encounter_id\n from detail_values\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join hcpcs_code hcpc on d.encounter_id = hcpc.encounter_id\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "lab__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/lab__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/lab__encounter_grain.sql", "unique_id": "model.the_tuva_project.lab__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "lab__encounter_grain"], "alias": "lab__encounter_grain", "checksum": {"name": "sha256", "checksum": "f2ad40a2e4a1acd862d72623bc2b1e1a508f69ed9a9d7968db310b51e715fa5d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per lab encounter id summarizing encounter level metrics. labs will roll up to other encounters unless they appear on their own day with no other claims.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.748886, "relation_name": "cms_synthetic.claims_preprocessing.lab__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('lab__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'lab - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "lab__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.lab__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/lab__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.lab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'lab - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_psych__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_psych__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_psych__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_psych__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_psych__encounter_grain"], "alias": "outpatient_psych__encounter_grain", "checksum": {"name": "sha256", "checksum": "b88600ae33846f8a5bac96733c39d76ecd4bffefe7d75509e303e463835dadbd"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient psych encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.717569, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_psych__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_psych__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_psych__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_psych__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_psych__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "asc__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/asc__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/asc__encounter_grain.sql", "unique_id": "model.the_tuva_project.asc__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "asc__encounter_grain"], "alias": "asc__encounter_grain", "checksum": {"name": "sha256", "checksum": "71129764df0fc585aacda753b7686e5db5e2059c6a1069dab58ea72bfbab2e28"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per asc encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.727377, "relation_name": "cms_synthetic.claims_preprocessing.asc__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,ed.encounter_start_date \n ,ed.encounter_end_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulatory surgery center'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('asc__start_end_dates') }} ed on cli.old_encounter_id = ed.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, {{ dbt.datediff(\"d.encounter_start_date\",\"d.encounter_end_date\",\"day\")}} as length_of_stay\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "asc__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.asc__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/asc__encounter_grain.sql", "compiled": true, "compiled_code": "\n\n\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,ed.encounter_start_date \n ,ed.encounter_end_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulatory surgery center'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.asc__start_end_dates ed on cli.old_encounter_id = ed.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, datediff(\n day,\n d.encounter_start_date,\n d.encounter_end_date\n ) as length_of_stay\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_hospice__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/inpatient_hospice__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/inpatient_hospice__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_hospice__encounter_grain"], "alias": "inpatient_hospice__encounter_grain", "checksum": {"name": "sha256", "checksum": "b3a98a58bb99e25499b0915206fe4e6d9dcc721da00dc7b59b0f3cb6856a1a1d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.710382, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('inpatient_hospice__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n ,encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('inpatient_hospice__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_hospice__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_hospice__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_hospice__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/inpatient_hospice__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n ,encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospice__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_hospice__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_hospice__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_hospice__encounter_grain"], "alias": "outpatient_hospice__encounter_grain", "checksum": {"name": "sha256", "checksum": "2303a4489331bb1f691b6582174f65c00901170b392a214b681e66bc620a5ed4"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.732704, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_hospice__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_hospice__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_hospice__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_hospice__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_hospice__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "emergency_department__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/emergency_department__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/emergency_department__encounter_grain.sql", "unique_id": "model.the_tuva_project.emergency_department__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "emergency_department__encounter_grain"], "alias": "emergency_department__encounter_grain", "checksum": {"name": "sha256", "checksum": "a7208be77fb892964e7a834510e60c9d27fd890c2fc8169ed65b40e6eec9937c"}, "config": {"enabled": true, "alias": "emergency_department__encounter_grain", "schema": "claims_preprocessing", "database": null, "tags": ["emergency_department", "claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["emergency_department", "claims_preprocessing", "encounters"], "description": "This table pulls together all the data needed to perform acute inpatient analytics into a single table.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "emergency_department__encounter_grain", "tags": ["emergency_department", "claims_preprocessing", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.6980648, "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'emergency department'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('emergency_department__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n,encounter_header_values as (\n select distinct patient_data_source_id\n ,data_source\n ,encounter_id\n from detail_values\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n, encounter_group\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, ehv.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"a.encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, sc.observation_flag\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, ehv.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('emergency_department__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\ninner join encounter_header_values ehv on x.encounter_id = ehv.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "emergency_department__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "emergency_department__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/emergency_department__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'emergency department'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.emergency_department__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n,encounter_header_values as (\n select distinct patient_data_source_id\n ,data_source\n ,encounter_id\n from detail_values\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n, encounter_group\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, ehv.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n a.encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, sc.observation_flag\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, ehv.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.emergency_department__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\ninner join encounter_header_values ehv on x.encounter_id = ehv.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_injections__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_injections__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_injections__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_injections__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_injections__encounter_grain"], "alias": "outpatient_injections__encounter_grain", "checksum": {"name": "sha256", "checksum": "4583c670321359db1ad465fa926f8ecdbe0d50357b5d25e5069d4e253eaae321"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.737644, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_injections__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient injections'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where substring(hcpcs_code,1,1)='J'\n\n group by \n encounter_id\n , hcpcs_code\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_injections__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_injections__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_injections__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_injections__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient injections'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where substring(hcpcs_code,1,1)='J'\n\n group by \n encounter_id\n , hcpcs_code\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_psych__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/inpatient_psych__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/inpatient_psych__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_psych__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_psych__encounter_grain"], "alias": "inpatient_psych__encounter_grain", "checksum": {"name": "sha256", "checksum": "dcfd1cfc99c004a510682609592abab635fbff9643eef86d59d2f5a81cbbe737"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient psych. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.700589, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('inpatient_psych__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('inpatient_psych__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_psych__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_psych__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_psych__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/inpatient_psych__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_snf__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/inpatient_snf__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/inpatient_snf__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_snf__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_snf__encounter_grain"], "alias": "inpatient_snf__encounter_grain", "checksum": {"name": "sha256", "checksum": "a1d8f1de481583b22f0b950275fb75e810c4a8397594076477a2519f1db87624"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7053719, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient skilled nursing'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('inpatient_snf__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('inpatient_snf__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_snf__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_snf__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_snf__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/inpatient_snf__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient skilled nursing'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dme__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/dme__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/dme__encounter_grain.sql", "unique_id": "model.the_tuva_project.dme__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "dme__encounter_grain"], "alias": "dme__encounter_grain", "checksum": {"name": "sha256", "checksum": "e343e85f644b113f675ff5b70ac7f2ba66f8b9f886940ecdacbfd227763070ba"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per dme encounter id summarizing encounter level metrics. dmes will roll up to other encounters unless they appear on their own day with no other claims.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.75102, "relation_name": "cms_synthetic.claims_preprocessing.dme__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('dme__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dme - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "dme__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/dme__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.dme__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dme - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_hospital_or_clinic__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_hospital_or_clinic__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_hospital_or_clinic__encounter_grain"], "alias": "outpatient_hospital_or_clinic__encounter_grain", "checksum": {"name": "sha256", "checksum": "867634a05678c18600e4a7697636c2cf9997b5ba206047792329f9e259e4915d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient rehab encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.722107, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_hospital_or_clinic__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospital or clinic'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_hospital_or_clinic__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_hospital_or_clinic__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospital or clinic'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_substance_use__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/outpatient_substance_use__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/outpatient_substance_use__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_substance_use__encounter_grain"], "alias": "outpatient_substance_use__encounter_grain", "checksum": {"name": "sha256", "checksum": "8b94ef4069012f0ac79001cc05dd803c60167356a349e1660ff895827c9ac77b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.740087, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('outpatient_substance_use__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_substance_use__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/outpatient_substance_use__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_substance_use__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "urgent_care__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/urgent_care__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/urgent_care__encounter_grain.sql", "unique_id": "model.the_tuva_project.urgent_care__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "urgent_care__encounter_grain"], "alias": "urgent_care__encounter_grain", "checksum": {"name": "sha256", "checksum": "007bd76111ce813b3a266e968012bdbf7fb2c6c8bf84fe64fa10c7882cbdf9c3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per urgent care encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.715173, "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from {{ ref('urgent_care__generate_encounter_id') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'urgent care'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "urgent_care__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.urgent_care__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/urgent_care__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.urgent_care__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'urgent care'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visit__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visit__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/office_visit__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/office_visit__encounter_grain.sql", "unique_id": "model.the_tuva_project.office_visit__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "office_visit__encounter_grain"], "alias": "office_visit__encounter_grain", "checksum": {"name": "sha256", "checksum": "aaffec3706c561d602f0db57248340ee917ac996d23cb5ddf6a91da2b7e49461"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient office visit surgery encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.74683, "relation_name": "cms_synthetic.claims_preprocessing.office_visit__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit surgery' as encounter_type\n from {{ ref('office_visits__int_office_visits_surgery') }}\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit injections' as encounter_type\n from {{ ref('office_visits__int_office_visits_injections') }}\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit radiology' as encounter_type\n from {{ ref('office_visits__int_office_visits_radiology') }}\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit - other' as encounter_type\n from {{ ref('office_visits__int_office_visits') }}\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit' as encounter_type\n from {{ ref('office_visits__int_office_visits_em') }}\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'telehealth' as encounter_type\n from {{ ref('office_visits__int_office_visits_telehealth') }}\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit pt/ot/st' as encounter_type\n from {{ ref('office_visits__int_office_visits') }}\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_group = 'office based'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n and\n d.encounter_type = cli.encounter_type\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_physician as \n(\n select encounter_id\n , billing_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where billing_id is not null\n group by \n encounter_id\n , billing_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, phy.billing_id\n, {{ dbt.concat([\"b2.provider_first_name\", \"' '\", \"b2.provider_last_name\"]) }} as provider_name\n, b2.primary_specialty_description as provider_specialty\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, hcpc.ccs_category\n, hcpc.ccs_category_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_physician phy on d.encounter_id = phy.encounter_id\nand\nphy.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on hf.facility_id = b.npi\nleft join {{ ref('terminology__provider') }} b2\n on phy.billing_id = b2.npi\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_surgery", "package": null, "version": null}, {"name": "office_visits__int_office_visits_injections", "package": null, "version": null}, {"name": "office_visits__int_office_visits_radiology", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "office_visits__int_office_visits_em", "package": null, "version": null}, {"name": "office_visits__int_office_visits_telehealth", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/office_visit__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit surgery' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_surgery\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit injections' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_injections\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit radiology' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_radiology\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit - other' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_em\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'telehealth' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit pt/ot/st' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_group = 'office based'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n and\n d.encounter_type = cli.encounter_type\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_physician as \n(\n select encounter_id\n , billing_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where billing_id is not null\n group by \n encounter_id\n , billing_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, phy.billing_id\n, b2.provider_first_name || ' ' || b2.provider_last_name as provider_name\n, b2.primary_specialty_description as provider_specialty\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, hcpc.ccs_category\n, hcpc.ccs_category_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_physician phy on d.encounter_id = phy.encounter_id\nand\nphy.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.provider b2\n on phy.billing_id = b2.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__encounter_grain": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_rehab__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/final/inpatient_rehab__encounter_grain.sql", "original_file_path": "models/claims_preprocessing/encounters/final/inpatient_rehab__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_rehab__encounter_grain"], "alias": "inpatient_rehab__encounter_grain", "checksum": {"name": "sha256", "checksum": "db004de85e250d5669c2a2f29c01e8640d3c2b3b20a95e64a2a9bb10ea3264cf"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.703031, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__encounter_grain", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from {{ ref('encounters__stg_medical_claim') }} stg\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join {{ ref('inpatient_rehab__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from {{ ref('encounters__stg_eligibility') }}\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n, encounter_group\n ,encounter_type\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('inpatient_rehab__start_end_dates') }} a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join {{ ref('terminology__provider') }} b\n on c.facility_id = b.npi\nleft join {{ ref('terminology__discharge_disposition') }} g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join {{ ref('terminology__admit_source') }} h\n on c.admit_source_code = h.admit_source_code\nleft join {{ ref('terminology__admit_type') }} i\n on c.admit_type_code = i.admit_type_code\nleft join {{ ref('terminology__ms_drg') }} j\n on c.ms_drg_code = j.ms_drg_code\nleft join {{ ref('terminology__apr_drg') }} k\n on c.apr_drg_code = k.apr_drg_code\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_rehab__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_rehab__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_rehab__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/final/inpatient_rehab__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n, encounter_group\n ,encounter_type\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__combined_claim_line_crosswalk": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__combined_claim_line_crosswalk", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/encounters__combined_claim_line_crosswalk.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/encounters__combined_claim_line_crosswalk.sql", "unique_id": "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "encounters__combined_claim_line_crosswalk"], "alias": "encounters__combined_claim_line_crosswalk", "checksum": {"name": "sha256", "checksum": "9bda8a9393b0cfa8ef5a4fc60b850e09d3e5024064ed0f02a7b8232fbae4f3e6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "all claim lines that belong to an encounter", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7129002, "relation_name": "cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith cte as \n(\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'acute inpatient' as encounter_type\n ,'inpatient' as encounter_group\n ,0 as priority_number\nfrom {{ ref('acute_inpatient__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'acute inpatient' as encounter_type\n,'inpatient' as encounter_group\n,0 as priority_number\nfrom {{ ref('acute_inpatient__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom {{ ref('acute_inpatient__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'emergency department' as encounter_type\n,'outpatient' as encounter_group\n,1 as priority_number\nfrom {{ ref('emergency_department__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom {{ ref('emergency_department__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient hospice' as encounter_type\n,'inpatient' as encounter_group\n,1 as priority_number\nfrom {{ ref('inpatient_hospice__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom {{ ref('inpatient_psych__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom {{ ref('inpatient_psych__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom {{ ref('inpatient_rehab__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom {{ ref('inpatient_rehab__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom {{ ref('inpatient_snf__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom {{ ref('inpatient_snf__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom {{ ref('inpatient_substance_use__prof_claims') }}\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom {{ ref('inpatient_substance_use__generate_encounter_id') }} enc\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,9 as priority_number --priority set in combined office visit encounter ranking model\nfrom {{ ref('office_visits__int_office_visits_claim_line') }}\nwhere encounter_type = 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,10 as priority_number --priority set in combined office visit encounter ranking model\nfrom {{ ref('office_visits__int_office_visits_claim_line') }}\nwhere encounter_type <> 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'urgent care' as encounter_type\n,'outpatient' as encounter_group\n,11 as priority_number --urgent care needs to be lower than ed and inpatient\nfrom {{ ref('urgent_care__match_claims_to_anchor') }}\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient psych' as encounter_type\n,'outpatient' as encounter_group\n,12 as priority_number \nfrom {{ ref('outpatient_psych__match_claims_to_anchor') }}\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient rehabilitation' as encounter_type\n,'outpatient' as encounter_group\n,13 as priority_number \nfrom {{ ref('outpatient_rehab__match_claims_to_anchor') }}\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulatory surgery center' as encounter_type\n,'outpatient' as encounter_group\n,14 as priority_number \nfrom {{ ref('asc__match_claims_to_anchor') }}\n\nunion all\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospital or clinic' as encounter_type\n,'outpatient' as encounter_group\n,999 as priority_number \nfrom {{ ref('outpatient_hospital_or_clinic__match_claims_to_anchor') }} --lowest outpatient priority, roll up to more specific encounter type when available\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient surgery' as encounter_type\n,'outpatient' as encounter_group\n,18 as priority_number \nfrom {{ ref('outpatient_surgery__match_claims_to_anchor') }} \n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dialysis' as encounter_type\n,'outpatient' as encounter_group\n,15 as priority_number \nfrom {{ ref('dialysis__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospice' as encounter_type\n,'outpatient' as encounter_group\n,16 as priority_number \nfrom {{ ref('outpatient_hospice__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'home health' as encounter_type\n,'outpatient' as encounter_group\n,17 as priority_number \nfrom {{ ref('home_health__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient injections' as encounter_type\n,'outpatient' as encounter_group\n,19 as priority_number \nfrom {{ ref('outpatient_injections__match_claims_to_anchor') }}\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient pt/ot/st' as encounter_type\n,'outpatient' as encounter_group\n,20 as priority_number \nfrom {{ ref('outpatient_ptotst__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient substance use' as encounter_type\n,'outpatient' as encounter_group\n,21 as priority_number \nfrom {{ ref('outpatient_substance_use__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient radiology' as encounter_type\n,'outpatient' as encounter_group\n,22 as priority_number \nfrom {{ ref('outpatient_radiology__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'lab - orphaned' as encounter_type\n,'other' as encounter_group\n,1000000 as priority_number \nfrom {{ ref('lab__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dme - orphaned' as encounter_type\n,'other' as encounter_group\n,1000001 as priority_number \nfrom {{ ref('dme__match_claims_to_anchor') }} \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulance - orphaned' as encounter_type\n,'other' as encounter_group\n,1000002 as priority_number \nfrom {{ ref('ambulance__match_claims_to_anchor') }} \n\n)\n\n\nselect \n claim_id\n, claim_line_number\n, encounter_id as old_encounter_id\n, dense_rank() over (order by encounter_type, encounter_id) as encounter_id\n, encounter_type\n, encounter_group\n, priority_number\n, row_number() over (partition by claim_id , claim_line_number order by priority_number) as claim_line_attribution_number\nfrom cte", "language": "sql", "refs": [{"name": "acute_inpatient__prof_claims", "package": null, "version": null}, {"name": "acute_inpatient__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "acute_inpatient__prof_claims", "package": null, "version": null}, {"name": "emergency_department__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "emergency_department__prof_claims", "package": null, "version": null}, {"name": "inpatient_hospice__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_psych__prof_claims", "package": null, "version": null}, {"name": "inpatient_psych__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_rehab__prof_claims", "package": null, "version": null}, {"name": "inpatient_rehab__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_snf__prof_claims", "package": null, "version": null}, {"name": "inpatient_snf__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_substance_use__prof_claims", "package": null, "version": null}, {"name": "inpatient_substance_use__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "office_visits__int_office_visits_claim_line", "package": null, "version": null}, {"name": "office_visits__int_office_visits_claim_line", "package": null, "version": null}, {"name": "urgent_care__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_psych__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_rehab__match_claims_to_anchor", "package": null, "version": null}, {"name": "asc__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_surgery__match_claims_to_anchor", "package": null, "version": null}, {"name": "dialysis__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_hospice__match_claims_to_anchor", "package": null, "version": null}, {"name": "home_health__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_injections__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_ptotst__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_substance_use__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_radiology__match_claims_to_anchor", "package": null, "version": null}, {"name": "lab__match_claims_to_anchor", "package": null, "version": null}, {"name": "dme__match_claims_to_anchor", "package": null, "version": null}, {"name": "ambulance__match_claims_to_anchor", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.office_visits__int_office_visits_claim_line", "model.the_tuva_project.urgent_care__match_claims_to_anchor", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "model.the_tuva_project.asc__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "model.the_tuva_project.dialysis__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "model.the_tuva_project.home_health__match_claims_to_anchor", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "model.the_tuva_project.lab__match_claims_to_anchor", "model.the_tuva_project.dme__match_claims_to_anchor", "model.the_tuva_project.ambulance__match_claims_to_anchor"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/encounters__combined_claim_line_crosswalk.sql", "compiled": true, "compiled_code": "\n\nwith cte as \n(\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'acute inpatient' as encounter_type\n ,'inpatient' as encounter_group\n ,0 as priority_number\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'acute inpatient' as encounter_type\n,'inpatient' as encounter_group\n,0 as priority_number\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'emergency department' as encounter_type\n,'outpatient' as encounter_group\n,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.emergency_department__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient hospice' as encounter_type\n,'inpatient' as encounter_group\n,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,9 as priority_number --priority set in combined office visit encounter ranking model\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type = 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,10 as priority_number --priority set in combined office visit encounter ranking model\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type <> 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'urgent care' as encounter_type\n,'outpatient' as encounter_group\n,11 as priority_number --urgent care needs to be lower than ed and inpatient\nfrom cms_synthetic.claims_preprocessing.urgent_care__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient psych' as encounter_type\n,'outpatient' as encounter_group\n,12 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_psych__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient rehabilitation' as encounter_type\n,'outpatient' as encounter_group\n,13 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_rehab__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulatory surgery center' as encounter_type\n,'outpatient' as encounter_group\n,14 as priority_number \nfrom cms_synthetic.claims_preprocessing.asc__match_claims_to_anchor\n\nunion all\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospital or clinic' as encounter_type\n,'outpatient' as encounter_group\n,999 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor --lowest outpatient priority, roll up to more specific encounter type when available\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient surgery' as encounter_type\n,'outpatient' as encounter_group\n,18 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_surgery__match_claims_to_anchor \n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dialysis' as encounter_type\n,'outpatient' as encounter_group\n,15 as priority_number \nfrom cms_synthetic.claims_preprocessing.dialysis__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospice' as encounter_type\n,'outpatient' as encounter_group\n,16 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_hospice__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'home health' as encounter_type\n,'outpatient' as encounter_group\n,17 as priority_number \nfrom cms_synthetic.claims_preprocessing.home_health__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient injections' as encounter_type\n,'outpatient' as encounter_group\n,19 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_injections__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient pt/ot/st' as encounter_type\n,'outpatient' as encounter_group\n,20 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient substance use' as encounter_type\n,'outpatient' as encounter_group\n,21 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient radiology' as encounter_type\n,'outpatient' as encounter_group\n,22 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_radiology__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'lab - orphaned' as encounter_type\n,'other' as encounter_group\n,1000000 as priority_number \nfrom cms_synthetic.claims_preprocessing.lab__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dme - orphaned' as encounter_type\n,'other' as encounter_group\n,1000001 as priority_number \nfrom cms_synthetic.claims_preprocessing.dme__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulance - orphaned' as encounter_type\n,'other' as encounter_group\n,1000002 as priority_number \nfrom cms_synthetic.claims_preprocessing.ambulance__match_claims_to_anchor \n\n)\n\n\nselect \n claim_id\n, claim_line_number\n, encounter_id as old_encounter_id\n, dense_rank() over (order by encounter_type, encounter_id) as encounter_id\n, encounter_type\n, encounter_group\n, priority_number\n, row_number() over (partition by claim_id , claim_line_number order by priority_number) as claim_line_attribution_number\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__orphaned_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "encounters__orphaned_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/encounters__orphaned_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/encounters__orphaned_claims.sql", "unique_id": "model.the_tuva_project.encounters__orphaned_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "encounters__orphaned_claims"], "alias": "encounters__orphaned_claims", "checksum": {"name": "sha256", "checksum": "4cdf5695289d9502f2e373c5f6c12bed2637616a2580536fb3c208417073a23a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.858243, "relation_name": "cms_synthetic.claims_preprocessing.encounters__orphaned_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith cte as (\n select stg.claim_id\n ,stg.claim_line_number\n ,stg.service_category_1\n ,stg.service_category_2\n ,stg.service_category_3\n ,stg.claim_type\n ,stg.claim_start_date\n ,stg.claim_end_date\n ,stg.start_date\n ,stg.end_date\n ,stg.patient_data_source_id\n from {{ ref('encounters__stg_medical_claim') }} stg\n left join {{ ref('encounters__combined_claim_line_crosswalk') }} enc on stg.claim_id = enc.claim_id\n and\n stg.claim_line_number = enc.claim_line_number\n where enc.claim_id is null -- missing from encounter mapping table\n)\n\n,max_encounter as (\n select max(encounter_id) max_encounter_id\n from {{ ref('encounters__combined_claim_line_crosswalk') }}\n)\n\nselect \n claim_id\n, claim_line_number\n, dense_rank() over (order by patient_data_source_id, claim_id) + max_encounter.max_encounter_id as encounter_id\n, 'orphaned claim' as encounter_type\n, 'other' as encounter_group\nfrom cte\ncross join max_encounter", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/encounters__orphaned_claims.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select stg.claim_id\n ,stg.claim_line_number\n ,stg.service_category_1\n ,stg.service_category_2\n ,stg.service_category_3\n ,stg.claim_type\n ,stg.claim_start_date\n ,stg.claim_end_date\n ,stg.start_date\n ,stg.end_date\n ,stg.patient_data_source_id\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n left join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk enc on stg.claim_id = enc.claim_id\n and\n stg.claim_line_number = enc.claim_line_number\n where enc.claim_id is null -- missing from encounter mapping table\n)\n\n,max_encounter as (\n select max(encounter_id) max_encounter_id\n from cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk\n)\n\nselect \n claim_id\n, claim_line_number\n, dense_rank() over (order by patient_data_source_id, claim_id) + max_encounter.max_encounter_id as encounter_id\n, 'orphaned claim' as encounter_type\n, 'other' as encounter_group\nfrom cte\ncross join max_encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_substance_use__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_substance_use", "outpatient_substance_use__anchor_events"], "alias": "outpatient_substance_use__anchor_events", "checksum": {"name": "sha256", "checksum": "9b80021784e5ef50a3e253b2ccf23e79695c35df901f1b320ac00e974695382f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.838727, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'outpatient substance use'\n and claim_type = 'institutional'\n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient substance use'\n and claim_type = 'institutional'\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_substance_use__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_substance_use", "outpatient_substance_use__generate_encounter_id"], "alias": "outpatient_substance_use__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "e1cefdd3941d44285366f3cecf993132ce87ab3abc06631bcf9f3d7c34a67e41"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.840109, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_substance_use__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_substance_use__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__generate_encounter_id.sql", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_substance_use__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_substance_use__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_substance_use", "outpatient_substance_use__match_claims_to_anchor"], "alias": "outpatient_substance_use__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "0a52d01ee068e66996887cc2f0681255642126eab720cd478a31959a54b4fff6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8413172, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_substance_use__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_substance_use__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_substance_use/outpatient_substance_use__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_substance_use__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_rehab__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_rehab", "inpatient_rehab__generate_encounter_id"], "alias": "inpatient_rehab__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "72d63f2da5739554717cc2029a6fc9efe7a676e070006195f9478ad201dab246"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient rehab claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.768624, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient rehabilitation'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient rehabilitation'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_rehab__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_rehab", "inpatient_rehab__prof_claims"], "alias": "inpatient_rehab__prof_claims", "checksum": {"name": "sha256", "checksum": "09494c7b4a835455e7c5cb43dbb154c6a199b651d1e775a5322cf6d39fdfcf90"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7711859, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('inpatient_rehab__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('inpatient_rehab__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_rehab__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_rehab__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_rehab__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_rehab", "inpatient_rehab__start_end_dates"], "alias": "inpatient_rehab__start_end_dates", "checksum": {"name": "sha256", "checksum": "10cd2dfc13ec483de7310cad212330442a1bf0980192a6c471008a88bc03301e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.769832, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('inpatient_rehab__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_rehab__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_rehab__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "emergency_department__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.emergency_department__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "emergency_department", "emergency_department__generate_encounter_id"], "alias": "emergency_department__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "072ab0a681f956c99e5a162fab09ed2ef6ad1c0f17d91fc64261c558cdabdc0a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient psych claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.761081, "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'emergency department' --both inst and prof\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'emergency department' --both inst and prof\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "emergency_department__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__start_end_dates.sql", "unique_id": "model.the_tuva_project.emergency_department__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "emergency_department", "emergency_department__start_end_dates"], "alias": "emergency_department__start_end_dates", "checksum": {"name": "sha256", "checksum": "270aea7244f776b9469ecde752f8291c2b163bad1eefc19321a03a2ad9816699"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.76234, "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('emergency_department__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "emergency_department__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.emergency_department__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "emergency_department__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__prof_claims.sql", "unique_id": "model.the_tuva_project.emergency_department__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "emergency_department", "emergency_department__prof_claims"], "alias": "emergency_department__prof_claims", "checksum": {"name": "sha256", "checksum": "9bb1ea92091f995f44dcd5b15822d9820112ac9bf41316224861866adac13ced"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7635672, "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('emergency_department__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('emergency_department__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n\n-- ensuring each claim is only attributed to one encounter with claim_attribution_number\n,inst_and_prof as (\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date\n\nunion all \n\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,med.claim_id\n,med.claim_line_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_outpatient_institutional') }} inst on med.claim_id = inst.claim_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date \nwhere dat.claim_id <> med.claim_id\n)\n\nselect distinct encounter_id\n,encounter_start_date\n,encounter_end_date\n,claim_id\n,claim_line_number\n,row_number () over (partition by claim_id ,claim_line_number order by encounter_id) as claim_attribution_number\nfrom inst_and_prof", "language": "sql", "refs": [{"name": "emergency_department__generate_encounter_id", "package": null, "version": null}, {"name": "emergency_department__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.encounters__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/emergency_department/emergency_department__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.emergency_department__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n\n-- ensuring each claim is only attributed to one encounter with claim_attribution_number\n,inst_and_prof as (\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date\n\nunion all \n\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,med.claim_id\n,med.claim_line_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_outpatient_institutional inst on med.claim_id = inst.claim_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date \nwhere dat.claim_id <> med.claim_id\n)\n\nselect distinct encounter_id\n,encounter_start_date\n,encounter_end_date\n,claim_id\n,claim_line_number\n,row_number () over (partition by claim_id ,claim_line_number order by encounter_id) as claim_attribution_number\nfrom inst_and_prof", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "home_health__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/home_health/home_health__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/home_health/home_health__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.home_health__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "home_health", "home_health__generate_encounter_id"], "alias": "home_health__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "50a0f2c3bad1088eff8a4262cb99784cbb432b579d492016992d34d871f5629b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "home_health"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "home_health"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "home_health"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.827169, "relation_name": "cms_synthetic.claims_preprocessing.home_health__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('home_health__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "home_health__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/home_health/home_health__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.home_health__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "home_health__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/home_health/home_health__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/home_health/home_health__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.home_health__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "home_health", "home_health__match_claims_to_anchor"], "alias": "home_health__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "47c76e05b51b4fd94e9a3a86842a0b681bbb6bb07a073ccddd92b1472b80e2e9"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "home_health"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "home_health"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "home_health"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8287969, "relation_name": "cms_synthetic.claims_preprocessing.home_health__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('home_health__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "home_health__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/home_health/home_health__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.home_health__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "home_health__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/home_health/home_health__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/home_health/home_health__anchor_events.sql", "unique_id": "model.the_tuva_project.home_health__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "home_health", "home_health__anchor_events"], "alias": "home_health__anchor_events", "checksum": {"name": "sha256", "checksum": "aebd1c4690024c17629c7fafc45982e3cf98dba80092eb30ba98de1c175af4d8"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "home_health"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "home_health"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "home_health"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.826004, "relation_name": "cms_synthetic.claims_preprocessing.home_health__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'home health' -- both prof and inst as anchors\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/home_health/home_health__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'home health' -- both prof and inst as anchors\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_psych__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_psych__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_psych", "inpatient_psych__prof_claims"], "alias": "inpatient_psych__prof_claims", "checksum": {"name": "sha256", "checksum": "f7ed774f48ee0550425200bfdf3e288de7c083758d46e697b30574dddb269cdb"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.767221, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('inpatient_psych__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('inpatient_psych__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_psych__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_psych__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_psych__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_psych__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_psych", "inpatient_psych__generate_encounter_id"], "alias": "inpatient_psych__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1346bac99dafadbf28e1ce2c99984fed44df3da873cd7103c98bd36201fa04d4"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient psych claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.764765, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient psychiatric'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient psychiatric'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_psych__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_psych__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_psych", "inpatient_psych__start_end_dates"], "alias": "inpatient_psych__start_end_dates", "checksum": {"name": "sha256", "checksum": "389708e08859fcb05373145c7bfdc7d6c49177317c10e25f9034f5ccce8c3fe7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.76606, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('inpatient_psych__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_psych__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_psych__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "urgent_care__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.urgent_care__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "urgent_care", "urgent_care__match_claims_to_anchor"], "alias": "urgent_care__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "5b5bedceacf3704e34ae8abef06b1e68cf7b63488352b64c448fa6885fa99e1e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.800032, "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('urgent_care__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "urgent_care__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.urgent_care__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "urgent_care__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.urgent_care__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "urgent_care", "urgent_care__generate_encounter_id"], "alias": "urgent_care__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "b67915954f0368465744ef06031cb353e9376543b2927858b98ac0766ac8f35b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "urgent_care"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.798656, "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('urgent_care__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "urgent_care__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.urgent_care__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "urgent_care__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__anchor_events.sql", "unique_id": "model.the_tuva_project.urgent_care__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "urgent_care", "urgent_care__anchor_events"], "alias": "urgent_care__anchor_events", "checksum": {"name": "sha256", "checksum": "053efa5c434d02f8319e0282eb6bf866071f354107f518f5240a4ddc4881bc84"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "urgent_care"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.797468, "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n select distinct\n claim_id\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 in ('urgent care') --both inst and prof anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/urgent_care/urgent_care__anchor_events.sql", "compiled": true, "compiled_code": "\n\n select distinct\n claim_id\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('urgent care') --both inst and prof anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_injections__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_injections", "outpatient_injections__match_claims_to_anchor"], "alias": "outpatient_injections__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "23725aa679e7af5f89ae0e5910f01d4c57b63bf9a457dd54d45c65040a71400a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.832902, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_injections__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_injections__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_injections__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_injections__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_injections__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_injections__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_injections", "outpatient_injections__anchor_events"], "alias": "outpatient_injections__anchor_events", "checksum": {"name": "sha256", "checksum": "f5c1995d34336e767f2fb9481e19c7ed71b8cc82b9e511c899578ecf22b2d710"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.830501, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith multiple_sources as \n(\nselect distinct\n med.patient_data_source_id\n ,med.start_date\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_outpatient_institutional') }} outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.hcpcs_code,1,1) = 'J'\n)\n\n\nselect distinct \n patient_data_source_id\n ,start_date\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom multiple_sources", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_outpatient_institutional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as \n(\nselect distinct\n med.patient_data_source_id\n ,med.start_date\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.hcpcs_code,1,1) = 'J'\n)\n\n\nselect distinct \n patient_data_source_id\n ,start_date\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_injections__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_injections__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_injections", "outpatient_injections__generate_encounter_id"], "alias": "outpatient_injections__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "2f7713b6b5196047a25bd56a0bb8f5b6316a0d7a37a6592f369beb6c21d45eea"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8316622, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect patient_data_source_id\n,start_date\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom {{ ref('outpatient_injections__anchor_events') }}", "language": "sql", "refs": [{"name": "outpatient_injections__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.outpatient_injections__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_injections/outpatient_injections__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom cms_synthetic.claims_preprocessing.outpatient_injections__anchor_events", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dme__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/dme/dme__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/dme/dme__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.dme__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dme", "dme__match_claims_to_anchor"], "alias": "dme__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "6091501e101559930b29a8ae5ced928d2f8122ccbe433f62ac5891877baa9030"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dme"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dme"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dme"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.853091, "relation_name": "cms_synthetic.claims_preprocessing.dme__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('dme__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'durable medical equipment'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dme__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dme__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/dme/dme__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dme__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'durable medical equipment'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dme__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/dme/dme__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/dme/dme__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.dme__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dme", "dme__generate_encounter_id"], "alias": "dme__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "34b43af3b0791d3f21ca0c434fa7814469adc40c8af08525e5ac94d9aca7817c"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dme"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dme"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dme"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.851954, "relation_name": "cms_synthetic.claims_preprocessing.dme__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('dme__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dme__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dme__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/dme/dme__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dme__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dme__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/dme/dme__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/dme/dme__anchor_events.sql", "unique_id": "model.the_tuva_project.dme__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dme", "dme__anchor_events"], "alias": "dme__anchor_events", "checksum": {"name": "sha256", "checksum": "4ea451535d082c454eb6c43d2329e4c37deddd1e7857c619ca8165a2e5a9e950"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dme"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dme"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dme"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.850602, "relation_name": "cms_synthetic.claims_preprocessing.dme__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'durable medical equipment' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/dme/dme__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'durable medical equipment' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "lab__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/lab/lab__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/lab/lab__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.lab__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "lab", "lab__match_claims_to_anchor"], "alias": "lab__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "f53075be1262d37bc4d47913c4a27b7f6ab1a2c32922487a9538e92c15c099fe"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "lab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "lab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "lab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8491242, "relation_name": "cms_synthetic.claims_preprocessing.lab__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('lab__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'lab'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "lab__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/lab/lab__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.lab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'lab'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "lab__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/lab/lab__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/lab/lab__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.lab__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "lab", "lab__generate_encounter_id"], "alias": "lab__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "98c8f094daacfe8318c9a86425804ab28586dc4068d2cff26e3efdfc9ae00a5a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "lab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "lab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "lab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8479948, "relation_name": "cms_synthetic.claims_preprocessing.lab__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('lab__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "lab__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/lab/lab__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.lab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "lab__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/lab/lab__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/lab/lab__anchor_events.sql", "unique_id": "model.the_tuva_project.lab__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "lab", "lab__anchor_events"], "alias": "lab__anchor_events", "checksum": {"name": "sha256", "checksum": "86eafeae01d43bc05c0e5834562e25a6a4f93df468e8716f9e72605c2507640a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "lab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "lab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "lab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8468192, "relation_name": "cms_synthetic.claims_preprocessing.lab__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'lab' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/lab/lab__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'lab' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "ambulance__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulance/ambulance__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulance/ambulance__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.ambulance__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulance", "ambulance__match_claims_to_anchor"], "alias": "ambulance__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "e9c11c1e441bd91ea71b5207582c297ae7968441e4e990d65659d73fd485d6d1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "ambulance"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "ambulance"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "ambulance"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.857111, "relation_name": "cms_synthetic.claims_preprocessing.ambulance__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('ambulance__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'ambulance'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "ambulance__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.ambulance__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulance/ambulance__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.ambulance__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'ambulance'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "ambulance__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulance/ambulance__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulance/ambulance__anchor_events.sql", "unique_id": "model.the_tuva_project.ambulance__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulance", "ambulance__anchor_events"], "alias": "ambulance__anchor_events", "checksum": {"name": "sha256", "checksum": "c6963ce35bd69a2507d6734e5a69e11aafd02df8fbc2c8db418724ebf3bde9d0"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "ambulance"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "ambulance"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "ambulance"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8544488, "relation_name": "cms_synthetic.claims_preprocessing.ambulance__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'ambulance' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulance/ambulance__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulance' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "ambulance__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulance/ambulance__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulance/ambulance__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.ambulance__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulance", "ambulance__generate_encounter_id"], "alias": "ambulance__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "18d11b0b3f6901bca9203cae751a04bb77243e898ab7b5adf197a9c4915792ec"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "ambulance"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "ambulance"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "ambulance"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8559098, "relation_name": "cms_synthetic.claims_preprocessing.ambulance__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('ambulance__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "ambulance__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.ambulance__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulance/ambulance__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.ambulance__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_substance_use__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_substance_use", "inpatient_substance_use__start_end_dates"], "alias": "inpatient_substance_use__start_end_dates", "checksum": {"name": "sha256", "checksum": "3d2458ea2e4f0f65ad4699028a680d38d3238bb32fd1e88b9734b7e31b124d93"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.777556, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('inpatient_substance_use__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_substance_use__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_substance_use__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_substance_use__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_substance_use", "inpatient_substance_use__generate_encounter_id"], "alias": "inpatient_substance_use__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "bf6688fa7970e097c39540bf2c932639b1a4958aaaf8f118cbdabf7a89710b2b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient substance_use claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.776244, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient substance use'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient substance use'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_substance_use__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_substance_use", "inpatient_substance_use__prof_claims"], "alias": "inpatient_substance_use__prof_claims", "checksum": {"name": "sha256", "checksum": "06adb7d4c4bcff35aabd4abe34e7194a95cfcb412b132ee46f5de83ec2a6ae6f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.778995, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('inpatient_substance_use__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('inpatient_substance_use__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n-- ,med.start_date\n-- ,med.end_date\n-- ,med.place_of_service_code\n-- ,med.place_of_service_description\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_substance_use__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_substance_use__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n-- ,med.start_date\n-- ,med.end_date\n-- ,med.place_of_service_code\n-- ,med.place_of_service_description\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_radiology__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_radiology", "outpatient_radiology__anchor_events"], "alias": "outpatient_radiology__anchor_events", "checksum": {"name": "sha256", "checksum": "97a3b81cad877b1f604afd2debe292725be28f0f07fb1646fc9fd7856c0ca333"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.842593, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n patient_data_source_id\n , start_date\n , hcpcs_code\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'outpatient radiology' --both professional and inst\n)\n\nselect distinct \n patient_data_source_id\n , start_date\n , hcpcs_code\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n patient_data_source_id\n , start_date\n , hcpcs_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient radiology' --both professional and inst\n)\n\nselect distinct \n patient_data_source_id\n , start_date\n , hcpcs_code\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_radiology__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_radiology", "outpatient_radiology__match_claims_to_anchor"], "alias": "outpatient_radiology__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "c106943068a0a160a663ea8075a15c4164cc5091ed26c92a1d87cb8880885067"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.845469, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , m.hcpcs_code\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_radiology__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nand\nm.hcpcs_code = u.hcpcs_code", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_radiology__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_radiology__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , m.hcpcs_code\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_radiology__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nand\nm.hcpcs_code = u.hcpcs_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_radiology__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_radiology", "outpatient_radiology__generate_encounter_id"], "alias": "outpatient_radiology__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "577b3daf055833934f751d54c091749bdf597c0bc5fcedfc9556b32e1f81c90d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.843932, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect patient_data_source_id\n,start_date\n,hcpcs_code\n,dense_rank() over (order by patient_data_source_id, start_date, hcpcs_code) as old_encounter_id\nfrom {{ ref('outpatient_radiology__anchor_events') }}", "language": "sql", "refs": [{"name": "outpatient_radiology__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.outpatient_radiology__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_radiology/outpatient_radiology__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,hcpcs_code\n,dense_rank() over (order by patient_data_source_id, start_date, hcpcs_code) as old_encounter_id\nfrom cms_synthetic.claims_preprocessing.outpatient_radiology__anchor_events", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospital_or_clinic", "outpatient_hospital_or_clinic__match_claims_to_anchor"], "alias": "outpatient_hospital_or_clinic__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "4b34a1c71a2c4df8591d846f9c1df6242ab8f70e4513fe59ef3c7a5f026d6dbd"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.811538, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_hospital_or_clinic__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospital_or_clinic", "outpatient_hospital_or_clinic__generate_encounter_id"], "alias": "outpatient_hospital_or_clinic__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "5811251c28196c17c5da2bd63ea949fff98c9761ba3f1b107e3bbb8715f499a5"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8104188, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_hospital_or_clinic__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospital_or_clinic", "outpatient_hospital_or_clinic__anchor_events"], "alias": "outpatient_hospital_or_clinic__anchor_events", "checksum": {"name": "sha256", "checksum": "80d8feab49061f194d35a7efaaa6b71020e019a5901542508cacb28101fda16e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8092558, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where \n service_category_2 in (\n 'outpatient hospital or clinic' -- both prof and inst\n , 'observation' -- orphaned obs that didn't roll up to other encounter\n )\n)\n\nselect distinct \n claim_id\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_hospital_or_clinic/outpatient_hospital_or_clinic__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where \n service_category_2 in (\n 'outpatient hospital or clinic' -- both prof and inst\n , 'observation' -- orphaned obs that didn't roll up to other encounter\n )\n)\n\nselect distinct \n claim_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_surgery__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_surgery", "outpatient_surgery__generate_encounter_id"], "alias": "outpatient_surgery__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "c47635d7c83039acf9093b6b7318e715a9f71057e279499f9da094b9ceedb2dc"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.861227, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_surgery__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_surgery__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__generate_encounter_id.sql", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_surgery__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_surgery__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_surgery", "outpatient_surgery__match_claims_to_anchor"], "alias": "outpatient_surgery__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "9b3c9fbf006ce3401df114ae333d97b0195b69cb851713897dce80a396361007"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8626492, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_surgery__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_surgery__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_surgery__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_surgery__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_surgery", "outpatient_surgery__anchor_events"], "alias": "outpatient_surgery__anchor_events", "checksum": {"name": "sha256", "checksum": "3ee63e1fb05a70718b44f6d5ae76dbaad893414ff7a034a857fc91a900ea12f6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.859745, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 in ('outpatient surgery') --both inst and prof anchor\n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_surgery/outpatient_surgery__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('outpatient surgery') --both inst and prof anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "asc__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.asc__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__generate_encounter_id"], "alias": "asc__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "e42c37068f2d2ab21fb646f9f5cf99a944c022e2b11eaf5b3cb326decda1a188"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.814516, "relation_name": "cms_synthetic.claims_preprocessing.asc__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith base_data as (\n select distinct\n m.patient_data_source_id\n , m.start_date\n , m.end_date\n , m.claim_id\n from {{ ref('encounters__stg_medical_claim') }} as m\n inner join {{ ref('asc__anchor_events') }} as u\n on m.claim_id = u.claim_id\n)\n\n-- Determine Previous Maximum End Date\n, grouped_data as (\n select\n bd.*\n , max(end_date) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows between unbounded preceding and 1 preceding\n ) as previous_max_end_date\n from base_data as bd\n)\n\n-- Flag New Encounter Groups\n, flagged_data as (\n select\n gd.*\n , case \n when start_date > coalesce(previous_max_end_date, '1900-01-01') then 1 \n else 0 \n end as new_group_flag\n from grouped_data as gd\n)\n\n-- Assign Encounter Groups per Patient\n, numbered_data as (\n select\n fd.*\n , sum(new_group_flag) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows unbounded preceding\n ) as encounter_group\n from flagged_data as fd\n)\n\n-- Identify Unique Encounters\n, unique_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , min(start_date) as encounter_start_date\n from numbered_data\n group by\n patient_data_source_id\n , encounter_group\n)\n\n-- Assign asc encounter_id\n, numbered_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , row_number() over (\n order by patient_data_source_id, encounter_start_date\n ) as encounter_id\n from unique_encounters\n)\n\n-- Merge Encounters with Claims\nselect\n nd.patient_data_source_id\n , nd.start_date\n , nd.end_date\n , nd.claim_id\n , ne.encounter_id as old_encounter_id\nfrom numbered_data as nd\ninner join numbered_encounters as ne\n on nd.patient_data_source_id = ne.patient_data_source_id\n and nd.encounter_group = ne.encounter_group", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "asc__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.asc__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith base_data as (\n select distinct\n m.patient_data_source_id\n , m.start_date\n , m.end_date\n , m.claim_id\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as m\n inner join cms_synthetic.claims_preprocessing.asc__anchor_events as u\n on m.claim_id = u.claim_id\n)\n\n-- Determine Previous Maximum End Date\n, grouped_data as (\n select\n bd.*\n , max(end_date) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows between unbounded preceding and 1 preceding\n ) as previous_max_end_date\n from base_data as bd\n)\n\n-- Flag New Encounter Groups\n, flagged_data as (\n select\n gd.*\n , case \n when start_date > coalesce(previous_max_end_date, '1900-01-01') then 1 \n else 0 \n end as new_group_flag\n from grouped_data as gd\n)\n\n-- Assign Encounter Groups per Patient\n, numbered_data as (\n select\n fd.*\n , sum(new_group_flag) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows unbounded preceding\n ) as encounter_group\n from flagged_data as fd\n)\n\n-- Identify Unique Encounters\n, unique_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , min(start_date) as encounter_start_date\n from numbered_data\n group by\n patient_data_source_id\n , encounter_group\n)\n\n-- Assign asc encounter_id\n, numbered_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , row_number() over (\n order by patient_data_source_id, encounter_start_date\n ) as encounter_id\n from unique_encounters\n)\n\n-- Merge Encounters with Claims\nselect\n nd.patient_data_source_id\n , nd.start_date\n , nd.end_date\n , nd.claim_id\n , ne.encounter_id as old_encounter_id\nfrom numbered_data as nd\ninner join numbered_encounters as ne\n on nd.patient_data_source_id = ne.patient_data_source_id\n and nd.encounter_group = ne.encounter_group", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "asc__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__start_end_dates.sql", "unique_id": "model.the_tuva_project.asc__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__start_end_dates"], "alias": "asc__start_end_dates", "checksum": {"name": "sha256", "checksum": "91e57f319c79704c632429448c941eba349f7118fa5e6d1ebef13636ad46b701"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.816909, "relation_name": "cms_synthetic.claims_preprocessing.asc__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect\n patient_data_source_id\n , old_encounter_id\n , min(start_date) as encounter_start_date\n , max(end_date) as encounter_end_date\nfrom {{ ref('asc__generate_encounter_id') }}\ngroup by\n patient_data_source_id\n , old_encounter_id", "language": "sql", "refs": [{"name": "asc__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.asc__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_data_source_id\n , old_encounter_id\n , min(start_date) as encounter_start_date\n , max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.asc__generate_encounter_id\ngroup by\n patient_data_source_id\n , old_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "asc__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.asc__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__match_claims_to_anchor"], "alias": "asc__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "845ec56fada6cc41fa08b5dcc778a5d36ed9f18470bd6b5c28ae0245e0199767"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.815739, "relation_name": "cms_synthetic.claims_preprocessing.asc__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect\n dat.old_encounter_id\n , dat.encounter_start_date\n , dat.encounter_end_date\n , med.claim_id\n , med.claim_line_number\n , row_number() over (\n partition by med.claim_id, med.claim_line_number\n order by dat.old_encounter_id\n ) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} as med\ninner join {{ ref('asc__start_end_dates') }} as dat\n on med.patient_data_source_id = dat.patient_data_source_id\n and med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "asc__start_end_dates", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.asc__start_end_dates"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect\n dat.old_encounter_id\n , dat.encounter_start_date\n , dat.encounter_end_date\n , med.claim_id\n , med.claim_line_number\n , row_number() over (\n partition by med.claim_id, med.claim_line_number\n order by dat.old_encounter_id\n ) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as med\ninner join cms_synthetic.claims_preprocessing.asc__start_end_dates as dat\n on med.patient_data_source_id = dat.patient_data_source_id\n and med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "asc__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__anchor_events.sql", "unique_id": "model.the_tuva_project.asc__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__anchor_events"], "alias": "asc__anchor_events", "checksum": {"name": "sha256", "checksum": "4b427765f515210a9cee49bac6588cd8e5a203720c990da228dae047d5b98c42"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.813068, "relation_name": "cms_synthetic.claims_preprocessing.asc__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n , end_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'ambulatory surgery center' -- include both professional and institutional claims as anchor events\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/ambulatory_surgery_center/asc__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n , end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulatory surgery center' -- include both professional and institutional claims as anchor events\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_psych__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_psych__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_psych", "outpatient_psych__anchor_events"], "alias": "outpatient_psych__anchor_events", "checksum": {"name": "sha256", "checksum": "7b3424b00a933dd849089e56d9886cc17caf8012f7567f84c947a76d9d6e3c23"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.801366, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'outpatient psychiatric' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient psychiatric' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_psych__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_psych__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_psych", "outpatient_psych__generate_encounter_id"], "alias": "outpatient_psych__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "64bee509ab99e4a115a86b03fe4f61ef8ab13728ccbc4bc1fb9976d6c78189d6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.802628, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_psych__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_psych__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_psych__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_psych__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_psych", "outpatient_psych__match_claims_to_anchor"], "alias": "outpatient_psych__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "eebe43024a994a1c1184598681470a8b5f6de69053827edbb48c41662c851151"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.803765, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_psych__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_psych__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_psych/outpatient_psych__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_psych__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospice__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospice", "outpatient_hospice__generate_encounter_id"], "alias": "outpatient_hospice__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "ae754dd042cf5524e6145e2cb63e6bdf9271fc7a07fdcfe244b5c881088998d6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.823637, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_hospice__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospice__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospice__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospice__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospice", "outpatient_hospice__match_claims_to_anchor"], "alias": "outpatient_hospice__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "4646be24ae02737e08e56b36c74da8e770e458c1233e6907c7c295a87bed5049"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8247721, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_hospice__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospice__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospice__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_hospice__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospice", "outpatient_hospice__anchor_events"], "alias": "outpatient_hospice__anchor_events", "checksum": {"name": "sha256", "checksum": "3cad31f31472ae2da6276db1d9516b48f3c9638a35192df5065b5f1cc8956053"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.822353, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'outpatient hospice' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_hospice/outpatient_hospice__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient hospice' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_ptotst": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_ptotst", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_ptotst.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_ptotst.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_ptotst", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_ptotst"], "alias": "office_visits__int_office_visits_ptotst", "checksum": {"name": "sha256", "checksum": "148f55fa56dbf7e9966dd1a1b19cca08e2bb721a327065cd74f2cc046b9fdefb"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7854562, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_ptotst", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom {{ ref('office_visits__int_office_visits')}} ov\nwhere service_category_2 = 'office-based pt/ot/st'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_ptotst.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based pt/ot/st'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_radiology": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_radiology", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_radiology.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_radiology.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_radiology", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_radiology"], "alias": "office_visits__int_office_visits_radiology", "checksum": {"name": "sha256", "checksum": "fa5d1503c93834b8ecf7ac3063d5a28cd9c20125524f6811472a72a3b14e3162"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7867148, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_radiology", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith max_encounter as (\n select max(old_encounter_id) as max_encounter_id\n from {{ ref('office_visits__int_office_visits') }}\n)\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,mc.hcpcs_code\n ,dense_rank() over (order by ov.patient_data_source_id, ov.start_date, mc.hcpcs_code) + mx.max_encounter_id as old_encounter_id\nfrom {{ ref('office_visits__int_office_visits') }} ov\ncross join max_encounter mx\ninner join {{ ref('encounters__stg_medical_claim') }} mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\ninner join {{ ref('service_category__office_based_radiology')}} scrad on mc.claim_id = scrad.claim_id\n and mc.claim_line_number = scrad.claim_line_number", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__office_based_radiology", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__office_based_radiology"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_radiology.sql", "compiled": true, "compiled_code": "\n\nwith max_encounter as (\n select max(old_encounter_id) as max_encounter_id\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits\n)\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,mc.hcpcs_code\n ,dense_rank() over (order by ov.patient_data_source_id, ov.start_date, mc.hcpcs_code) + mx.max_encounter_id as old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\ncross join max_encounter mx\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\ninner join cms_synthetic.claims_preprocessing.service_category__office_based_radiology scrad on mc.claim_id = scrad.claim_id\n and mc.claim_line_number = scrad.claim_line_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits"], "alias": "office_visits__int_office_visits", "checksum": {"name": "sha256", "checksum": "e38dfe94eab65fd86bcc96af4daa1d6de5ef7128fc86746a0fff07637785698a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.791803, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith anchor as (\n select distinct\n mc.patient_data_source_id\n , mc.start_date\n , mc.claim_id\n , mc.claim_line_number\n , mc.service_category_1\n , mc.service_category_2\n , mc.service_category_3\n from {{ ref('encounters__stg_medical_claim') }} as mc\n inner join {{ ref('service_category__combined_professional') }} as p -- joining in all sc regardless of final priority\n on mc.claim_id = p.claim_id\n and mc.claim_line_number = p.claim_line_number\n where p.service_category_1 = 'office-based'\n)\n\nselect\n patient_data_source_id\n , start_date\n , claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__combined_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits.sql", "compiled": true, "compiled_code": "\n\nwith anchor as (\n select distinct\n mc.patient_data_source_id\n , mc.start_date\n , mc.claim_id\n , mc.claim_line_number\n , mc.service_category_1\n , mc.service_category_2\n , mc.service_category_3\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as mc\n inner join cms_synthetic.claims_preprocessing._int_combined_professional as p -- joining in all sc regardless of final priority\n on mc.claim_id = p.claim_id\n and mc.claim_line_number = p.claim_line_number\n where p.service_category_1 = 'office-based'\n)\n\nselect\n patient_data_source_id\n , start_date\n , claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_telehealth": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_telehealth", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_telehealth.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_telehealth.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_telehealth", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_telehealth"], "alias": "office_visits__int_office_visits_telehealth", "checksum": {"name": "sha256", "checksum": "9841d6a431963864c91935cad9224a5a210ae25e10152b2fd445274e040568cd"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.790144, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_telehealth", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom {{ ref('office_visits__int_office_visits')}} ov\nwhere service_category_2 = 'telehealth visit'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_telehealth.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'telehealth visit'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_encounter_ranking", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_encounter_ranking.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_encounter_ranking.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_encounter_ranking"], "alias": "office_visits__int_office_visits_encounter_ranking", "checksum": {"name": "sha256", "checksum": "fa84854e9ec5f45f458c940a63b83ed213f78a2ec4b18d8ef7a81d464ec20827"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.793279, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_encounter_ranking", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith rank_cte as (\nselect *\nfrom {{ ref('office_visits__int_office_visits_union')}}\n)\n\n,dist_encounter as (\nselect distinct old_encounter_id\n,encounter_type\n,priority_number\nfrom rank_cte\n)\n\nselect \nold_encounter_id\n,encounter_type\n,priority_number\n,row_number() over (partition by old_encounter_id order by priority_number) as relative_rank\nfrom dist_encounter", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_encounter_ranking.sql", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,dist_encounter as (\nselect distinct old_encounter_id\n,encounter_type\n,priority_number\nfrom rank_cte\n)\n\nselect \nold_encounter_id\n,encounter_type\n,priority_number\n,row_number() over (partition by old_encounter_id order by priority_number) as relative_rank\nfrom dist_encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_injections": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_injections", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_injections.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_injections.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_injections", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_injections"], "alias": "office_visits__int_office_visits_injections", "checksum": {"name": "sha256", "checksum": "18e228113ef7a8d84c61a7a26db038de27d5fa230d51899cfb38f52394704552"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.784286, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_injections", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom {{ ref('office_visits__int_office_visits')}} ov\ninner join {{ ref('encounters__stg_medical_claim')}} mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\nwhere substring(hcpcs_code,1,1) = 'J'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_injections.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\nwhere substring(hcpcs_code,1,1) = 'J'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_union": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_union", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_union.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_union.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_union", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_union"], "alias": "office_visits__int_office_visits_union", "checksum": {"name": "sha256", "checksum": "cf93f74f9b62531f4fcddeeaeaf87a19b97c08432ddad73992553c592d65548f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.795976, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_union", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit radiology' as encounter_type\n,0 as priority_number\nfrom {{ ref('office_visits__int_office_visits_radiology') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit surgery' as encounter_type\n,1 as priority_number\nfrom {{ ref('office_visits__int_office_visits_surgery') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit injections' as encounter_type\n,2 as priority_number\nfrom {{ ref('office_visits__int_office_visits_injections') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit pt/ot/st' as encounter_type\n,3 as priority_number\nfrom {{ ref('office_visits__int_office_visits_ptotst') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit' as encounter_type\n,4 as priority_number\nfrom {{ ref('office_visits__int_office_visits_em') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'telehealth' as encounter_type\n,5 as priority_number\nfrom {{ ref('office_visits__int_office_visits_telehealth') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit - other' as encounter_type\n,9999 as priority_number\nfrom {{ ref('office_visits__int_office_visits') }}", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_radiology", "package": null, "version": null}, {"name": "office_visits__int_office_visits_surgery", "package": null, "version": null}, {"name": "office_visits__int_office_visits_injections", "package": null, "version": null}, {"name": "office_visits__int_office_visits_ptotst", "package": null, "version": null}, {"name": "office_visits__int_office_visits_em", "package": null, "version": null}, {"name": "office_visits__int_office_visits_telehealth", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_ptotst", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_union.sql", "compiled": true, "compiled_code": "\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit radiology' as encounter_type\n,0 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_radiology\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit surgery' as encounter_type\n,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_surgery\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit injections' as encounter_type\n,2 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_injections\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit pt/ot/st' as encounter_type\n,3 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_ptotst\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit' as encounter_type\n,4 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_em\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'telehealth' as encounter_type\n,5 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit - other' as encounter_type\n,9999 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_em": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_em", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_em.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_em.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_em", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_em"], "alias": "office_visits__int_office_visits_em", "checksum": {"name": "sha256", "checksum": "59604b39e11c8bf37c44668f0b0e5932ae9df82cddf6dc128d85e2c40c026305"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.788949, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_em", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom {{ ref('office_visits__int_office_visits')}} ov\nwhere service_category_2 = 'office-based visit'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_em.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based visit'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_claim_line": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_claim_line", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_claim_line.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_claim_line.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_claim_line", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_claim_line"], "alias": "office_visits__int_office_visits_claim_line", "checksum": {"name": "sha256", "checksum": "d9968acf04845acdb3067204f872e10e74e180feb30c4b0048842b760ff3add6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7947168, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_claim_line", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith rank_cte as (\nselect *\nfrom {{ ref('office_visits__int_office_visits_union')}}\n)\n\n,crosswalk_cte as (\nselect old_encounter_id\n,encounter_type\nfrom {{ ref('office_visits__int_office_visits_encounter_ranking') }}\nwhere relative_rank = 1\n)\n\nselect r.claim_id\n, r.claim_line_number\n, r.old_encounter_id\n, x.encounter_type\nfrom rank_cte r\ninner join crosswalk_cte x on r.old_encounter_id = x.old_encounter_id", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_union", "package": null, "version": null}, {"name": "office_visits__int_office_visits_encounter_ranking", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_union", "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_claim_line.sql", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,crosswalk_cte as (\nselect old_encounter_id\n,encounter_type\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_encounter_ranking\nwhere relative_rank = 1\n)\n\nselect r.claim_id\n, r.claim_line_number\n, r.old_encounter_id\n, x.encounter_type\nfrom rank_cte r\ninner join crosswalk_cte x on r.old_encounter_id = x.old_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_surgery": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_surgery", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_surgery.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_surgery.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_surgery", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_surgery"], "alias": "office_visits__int_office_visits_surgery", "checksum": {"name": "sha256", "checksum": "fb9eca4a65da9b32305984796cdf2c58810910e783b75a8ad62b7e195372df33"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.787841, "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_surgery", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom {{ ref('office_visits__int_office_visits')}} ov\nwhere service_category_2 = 'office-based surgery'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/office_visits/office_visits__int_office_visits_surgery.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based surgery'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dialysis__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/dialysis/dialysis__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/dialysis/dialysis__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.dialysis__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dialysis", "dialysis__generate_encounter_id"], "alias": "dialysis__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1e695bdce49048736a1904231ed4f9972691f261d041448d9e647c7ddeff0ef4"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dialysis"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dialysis"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dialysis"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.819713, "relation_name": "cms_synthetic.claims_preprocessing.dialysis__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('dialysis__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dialysis__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dialysis__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/dialysis/dialysis__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dialysis__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dialysis__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/dialysis/dialysis__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/dialysis/dialysis__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.dialysis__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dialysis", "dialysis__match_claims_to_anchor"], "alias": "dialysis__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "67f62dc7c003282c1ac8977bfb75db3c4236416c0a292c65227ff3a428f9cc83"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dialysis"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dialysis"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dialysis"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.821056, "relation_name": "cms_synthetic.claims_preprocessing.dialysis__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('dialysis__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dialysis__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dialysis__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/dialysis/dialysis__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dialysis__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "dialysis__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/dialysis/dialysis__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/dialysis/dialysis__anchor_events.sql", "unique_id": "model.the_tuva_project.dialysis__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dialysis", "dialysis__anchor_events"], "alias": "dialysis__anchor_events", "checksum": {"name": "sha256", "checksum": "5162ec8e8040503f75dc01b4606b7cb12e0e8dd9fd649b27f23be05815577467"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dialysis"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dialysis"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dialysis"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.818447, "relation_name": "cms_synthetic.claims_preprocessing.dialysis__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'dialysis' --both inst and professional as anchor\n \n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/dialysis/dialysis__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'dialysis' --both inst and professional as anchor\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_snf__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_snf__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_snf", "inpatient_snf__prof_claims"], "alias": "inpatient_snf__prof_claims", "checksum": {"name": "sha256", "checksum": "fe90e05a35c1bbb42161e08e6cc7babd5a6808df4ddf33954b82a3c577f944e6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.774656, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('inpatient_snf__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('inpatient_snf__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_snf__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_snf__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_snf__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_snf__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_snf", "inpatient_snf__generate_encounter_id"], "alias": "inpatient_snf__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "bb0cea551a5fe6cd631151389e28b80a91c93925737142edaaa33a8e5c5dda75"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient snf claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.772369, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'skilled nursing'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b, \n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'skilled nursing'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b, \n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_snf__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_snf__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_snf", "inpatient_snf__start_end_dates"], "alias": "inpatient_snf__start_end_dates", "checksum": {"name": "sha256", "checksum": "320e449797cbece1287824e93858d532a356f219ab10230348421ddb3a0c641c"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.7735229, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('inpatient_snf__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_snf__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_snf__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "acute_inpatient__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__prof_claims.sql", "unique_id": "model.the_tuva_project.acute_inpatient__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "acute_inpatient", "acute_inpatient__prof_claims"], "alias": "acute_inpatient__prof_claims", "checksum": {"name": "sha256", "checksum": "d17ec08b8919f19cd3e5cf033f4bd916c47bd6da79a5f62ad92bfd136e100098"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.759417, "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('acute_inpatient__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('acute_inpatient__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "acute_inpatient__generate_encounter_id", "package": null, "version": null}, {"name": "acute_inpatient__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "acute_inpatient__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__start_end_dates.sql", "unique_id": "model.the_tuva_project.acute_inpatient__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "acute_inpatient", "acute_inpatient__start_end_dates"], "alias": "acute_inpatient__start_end_dates", "checksum": {"name": "sha256", "checksum": "ee993e042cd68ad9714fc3a11665f45e75bc8df9e83f3d72885417ec8e6f9aa6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.758215, "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('acute_inpatient__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "acute_inpatient__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.acute_inpatient__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "acute_inpatient__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.acute_inpatient__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "acute_inpatient", "acute_inpatient__generate_encounter_id"], "alias": "acute_inpatient__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "ef5dae4d2ce3bb64a23267f1475e626edda7c821be66c389d877639d87043855"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient psych claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.757077, "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\nselect claim_id\n,patient_data_source_id\n,min(start_date) as start_date\n,max(end_date) as end_date \n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id\n ,patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id\n , enc.patient_data_source_id\n , c.start_date\n , c.end_date\n , enc.facility_id\n , enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c on enc.claim_id = c.claim_id\n and\n c.patient_data_source_id = enc.patient_data_source_id\n where\n service_category_2 in ('acute inpatient')\n and claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id\n , aa.claim_id as claim_id_a\n , bb.claim_id as claim_id_b\n , aa.row_num as row_num_a\n , bb.row_num as row_num_b\n , case\n -- Claims with same end_date and same facility_id should be merged:\n when aa.end_date = bb.end_date\n and aa.facility_id = bb.facility_id then 1\n\n -- Claims with different end_date and start_date that are\n -- adjacent (i.e. separated by 1 day) should be merged:\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n\n -- Claims with different end_date \n -- should be merged if they overlap:\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n where aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\nselect claim_id\n,patient_data_source_id\n,min(start_date) as start_date\n,max(end_date) as end_date \n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id\n ,patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id\n , enc.patient_data_source_id\n , c.start_date\n , c.end_date\n , enc.facility_id\n , enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c on enc.claim_id = c.claim_id\n and\n c.patient_data_source_id = enc.patient_data_source_id\n where\n service_category_2 in ('acute inpatient')\n and claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id\n , aa.claim_id as claim_id_a\n , bb.claim_id as claim_id_b\n , aa.row_num as row_num_a\n , bb.row_num as row_num_b\n , case\n -- Claims with same end_date and same facility_id should be merged:\n when aa.end_date = bb.end_date\n and aa.facility_id = bb.facility_id then 1\n\n -- Claims with different end_date and start_date that are\n -- adjacent (i.e. separated by 1 day) should be merged:\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n\n -- Claims with different end_date \n -- should be merged if they overlap:\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n where aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_rehab__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_rehab", "outpatient_rehab__match_claims_to_anchor"], "alias": "outpatient_rehab__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "100d1299b20fe5399cad1092576c26ee34372347db404b560c8b7d667f4f7ca0"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.807946, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_rehab__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_rehab__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_rehab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_rehab__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_rehab", "outpatient_rehab__generate_encounter_id"], "alias": "outpatient_rehab__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "eb4340bf9d29d32cd78a5c392fce278fef6caf3f460ec08516989c0794693e50"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.806565, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_rehab__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_rehab__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_rehab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_rehab__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_rehab", "outpatient_rehab__anchor_events"], "alias": "outpatient_rehab__anchor_events", "checksum": {"name": "sha256", "checksum": "1b7375a2296e99ab05247774354b09093ab2ba294716b85e77e8563da16f1edf"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8051798, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'outpatient rehabilitation'\n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_rehab/outpatient_rehab__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient rehabilitation'\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_hospice__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_hospice", "inpatient_hospice__generate_encounter_id"], "alias": "inpatient_hospice__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "96b4d88dcded9b5ff269654bba8545617ba361f7ffd953e29dc41c8cfd355309"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient hospice claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.780236, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from {{ ref('encounters__stg_medical_claim') }}\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from {{ ref('encounters__stg_medical_claim') }} enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 in ('inpatient hospice')\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 in ('inpatient hospice')\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__start_end_dates": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_hospice__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__start_end_dates.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_hospice", "inpatient_hospice__start_end_dates"], "alias": "inpatient_hospice__start_end_dates", "checksum": {"name": "sha256", "checksum": "3daf582c626ebc93f432c48652dddba4a130e936de69cf62f081eae68ffb9181"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.781606, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom {{ ref('inpatient_hospice__generate_encounter_id') }}\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_hospice__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_hospice__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__prof_claims": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "inpatient_hospice__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__prof_claims.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_hospice", "inpatient_hospice__prof_claims"], "alias": "inpatient_hospice__prof_claims", "checksum": {"name": "sha256", "checksum": "99dbd4dee648b881e5f851fb03f54af5205cab6a071fdbb9259e26342af4ba98"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.782912, "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__prof_claims", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith first_claim as (\n select *\n from {{ ref('inpatient_hospice__generate_encounter_id') }}\n where encounter_claim_number = 1\n)\n\n, join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join {{ ref('inpatient_hospice__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom {{ ref('encounters__stg_medical_claim') }} med\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_hospice__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_hospice__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_hospice__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n, join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_ptotst__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__match_claims_to_anchor.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_ptotst", "outpatient_ptotst__match_claims_to_anchor"], "alias": "outpatient_ptotst__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "c30b4106867a68b67aaf437add2d05bbd79f204924cd6dee723b3d1f03d9fb1e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.837295, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_ptotst__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_ptotst__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_ptotst__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__anchor_events": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_ptotst__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__anchor_events.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_ptotst", "outpatient_ptotst__anchor_events"], "alias": "outpatient_ptotst__anchor_events", "checksum": {"name": "sha256", "checksum": "7fd28166a0eb7b75ddbb8c930ecc09791bddb8213802287692de7fa70a5dd21b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8343968, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__anchor_events", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from {{ ref('encounters__stg_medical_claim') }}\n where\n service_category_2 = 'outpatient pt/ot/st' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient pt/ot/st' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "outpatient_ptotst__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__generate_encounter_id.sql", "original_file_path": "models/claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_ptotst", "outpatient_ptotst__generate_encounter_id"], "alias": "outpatient_ptotst__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "76246171c5e710325f3fe952fbad41bdc000176f28b73b7127f50c663a9e8006"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/claims_preprocessing/encounters/encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.835556, "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__generate_encounter_id", "raw_code": "{{ config(\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom {{ ref('encounters__stg_medical_claim') }} m\ninner join {{ ref('outpatient_ptotst__anchor_events') }} u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_ptotst__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__anchor_events"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/encounters/intermediate/outpatient_ptotst/outpatient_ptotst__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_ptotst__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_medical_claim": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_medical_claim.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_medical_claim", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_medical_claim"], "alias": "_stg_medical_claim", "checksum": {"name": "sha256", "checksum": "af30368624872bc5ac87fc779098c13b7289d098f84500bc1d5fcca780e0be01"}, "config": {"enabled": true, "alias": "_stg_medical_claim", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging medical claims from the input layer. Creates an empty table if using clinical only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service": {"name": "place_of_service", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_medical_claim", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.035576, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medical_claim') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medical_claim') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as claim_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_start_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_end_date\n , cast(null as {{ dbt.type_string() }} ) as place_of_service_code\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_code\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_1\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_2\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_3\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_4\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_5\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n{% else %}\nselect\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as claim_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_start_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_end_date\n , cast(null as {{ dbt.type_string() }} ) as place_of_service_code\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_code\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_1\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_2\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_3\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_4\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_5\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__patient": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__patient.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__patient.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__patient", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__patient"], "alias": "_stg_patient", "checksum": {"name": "sha256", "checksum": "04d98a2a586df98c5c50d9d7310be020492901a8e51512fbdc1ab1bc6efa8710"}, "config": {"enabled": true, "alias": "_stg_patient", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging eligibility from the input layer.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_patient", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.032406, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__patient.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__observation": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__observation.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__observation.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__observation", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__observation"], "alias": "_stg_observation", "checksum": {"name": "sha256", "checksum": "4c9b44f6133e55d08e2aac3ba380ed30912c5c651c0e5ea1ca400798e09fe91c"}, "config": {"enabled": true, "alias": "_stg_observation", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging medications from core. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_observation", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0308852, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__observation') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__observation') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\n , cast(null as {{ dbt.type_string() }} ) as result\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n{% else %}\nselect\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\n , cast(null as {{ dbt.type_string() }} ) as result\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__observation.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__medication": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__medication.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__medication.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__medication", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__medication"], "alias": "_stg_medication", "checksum": {"name": "sha256", "checksum": "8c2ffc89995838091f8df7e18bc8bbf8a38a6d4b7b4281318810a1752e717934"}, "config": {"enabled": true, "alias": "_stg_medication", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging medications from core. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_date": {"name": "prescribing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_medication", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.029249, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medication') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medication') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as prescribing_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n{% else %}\nselect\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as prescribing_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__medication.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__condition": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__condition.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__condition.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__condition", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__condition"], "alias": "_stg_condition", "checksum": {"name": "sha256", "checksum": "28d95c7e34fcd9456b88c11de786edf1650d8628093ff51ea94cd3fb42b8b1cf"}, "config": {"enabled": true, "alias": "_stg_condition", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging conditions from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_condition", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.025983, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__condition.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__lab_result": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__lab_result.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__lab_result.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__lab_result"], "alias": "_stg_lab_result", "checksum": {"name": "sha256", "checksum": "1b7ac780eb7f700f05400a990a4563f9632ff04af0c7f0fef58ea01bb55ee6d6"}, "config": {"enabled": true, "alias": "_stg_lab_result", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging lab results from the input layer. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "collection_date": {"name": "collection_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_lab_result", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0386791, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__lab_result') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__lab_result') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as result\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as collection_date\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n{% else %}\n select\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as result\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as collection_date\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__lab_result.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_pharmacy_claim": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_pharmacy_claim.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_pharmacy_claim"], "alias": "_stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "ec3a5e757de748fafe6d99a3fa88a848ed3e0c624697a7564615696243f56196"}, "config": {"enabled": true, "alias": "_stg_pharmacy_claim", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging pharmacy claims from the input layer. Creates an empty table if using clinical only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_pharmacy_claim", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0370429, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__pharmacy_claim') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__pharmacy_claim') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_int() }} ) as days_supply\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n{% else %}\n select\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_int() }} ) as days_supply\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date \n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__procedure": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__procedure.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__procedure", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__procedure"], "alias": "_stg_procedure", "checksum": {"name": "sha256", "checksum": "258d3d97ab1f6ad50d14726160bf9c561710d20869d72dd6b6a56974fffe30d2"}, "config": {"enabled": true, "alias": "_stg_procedure", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging procedures from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date": {"name": "procedure_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_1": {"name": "modifier_1", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_2": {"name": "modifier_2", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_3": {"name": "modifier_3", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_4": {"name": "modifier_4", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_5": {"name": "modifier_5", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_procedure", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.034299, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__procedure.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__encounter": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__stg_core__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/staging/quality_measures__stg_core__encounter.sql", "original_file_path": "models/quality_measures/staging/quality_measures__stg_core__encounter.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__encounter", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__encounter"], "alias": "_stg_encounter", "checksum": {"name": "sha256", "checksum": "bbea1f0e2b9836fd6ad124d6f1958e954bed99bec4ed58141669803f17eb1b67"}, "config": {"enabled": true, "alias": "_stg_encounter", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging encounters from core. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_encounter", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0273678, "relation_name": null, "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__encounter') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__encounter') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_type\n , cast(null as {{dbt.type_numeric()}} ) as length_of_stay\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_start_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_end_date\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n{% else %}\n select\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\n , cast(null as {{ dbt.type_string() }} ) as encounter_type\n , cast(null as {{dbt.type_numeric()}} ) as length_of_stay\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_start_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_end_date\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/staging/quality_measures__stg_core__encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__summary_wide": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__summary_wide", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/final/quality_measures__summary_wide.sql", "original_file_path": "models/quality_measures/final/quality_measures__summary_wide.sql", "unique_id": "model.the_tuva_project.quality_measures__summary_wide", "fqn": ["the_tuva_project", "quality_measures", "final", "quality_measures__summary_wide"], "alias": "summary_wide", "checksum": {"name": "sha256", "checksum": "140139dbee33927f38f0ec62b5096afd3c8f4843f01113dc76876670f6e5c693"}, "config": {"enabled": true, "alias": "summary_wide", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Wide view of the results for the reporting version of all measures. This model pivots measures on the patient level (i.e. one row per patient with flags for each measure. The false flags can be treated as care gaps as exclusions have been included in the pivot logic.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_2372": {"name": "nqf_2372", "description": "Performance flag for NQF2372, Breast Cancer Screening. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0034": {"name": "nqf_0034", "description": "Performance flag for NQF0034, Colorectal Cancer Screening. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0059": {"name": "nqf_0059", "description": "Performance flag for NQF0059, Diabetes: Hemoglobin A1c (HbA1c) Poor Control (> 9%). A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_236": {"name": "cqm_236", "description": "Performance flag for CQM236, Controlling High Blood Pressure. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0053": {"name": "nqf_0053", "description": "Performance flag for NQF0053, Osteoporosis Management in Women Who Had a Fracture. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cbe_0055": {"name": "cbe_0055", "description": "Performance flag for CBE0055, Diabetes: Eye Exam. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0097": {"name": "nqf_0097", "description": "Performance flag for NQF0097, Medication Reconciliation Post-Discharge. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_438": {"name": "cqm_438", "description": "Performance flag for CQM438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0041": {"name": "nqf_0041", "description": "Performance flag for NQF0041, Influenza Immunization. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cbe_0101": {"name": "cbe_0101", "description": "Performance flag for CBE0101, Falls: Plan of Care. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_48": {"name": "cqm_48", "description": "Performance flag for CQM48, Urinary Incontinence: Assessment of Presence or Absence of Urinary Incontinence in Women Aged 65 Years and Older. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_130": {"name": "cqm_130", "description": "Performance flag for CQM130, Documentation of Current Medications in the Medical Record. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0420": {"name": "nqf_0420", "description": "Performance flag for NQF0420, Pain Assessment and Follow-Up. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adh_diabetes": {"name": "adh_diabetes", "description": "Performance flag for ADH-Diabetes, Medication Adherence for Diabetes Medications. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adh_ras": {"name": "adh_ras", "description": "Performance flag for ADH-RAS, Medication Adherence for Hypertension. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "summary_wide", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.880764, "relation_name": "cms_synthetic.quality_measures.summary_wide", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/*\n Each measure is pivoted into a boolean column by evaluating the\n denominator, numerator, and exclusion flags.\n*/\nwith measures_long as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , measure_id\n from {{ ref('quality_measures__summary_long') }}\n\n)\n\n, nqf_2372 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF2372'\n\n)\n\n, nqf_0034 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0034'\n\n)\n\n, nqf_0059 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0059'\n\n)\n\n, cqm_236 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM236'\n\n)\n\n, nqf_0053 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0053'\n\n)\n\n, cbe_0055 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0055'\n\n)\n\n, nqf_0097 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0097'\n\n)\n\n, cqm_438 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM438'\n\n)\n\n, nqf_0041 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0041'\n\n)\n\n, cbe_0101 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0101'\n\n)\n\n, cqm_48 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM48'\n\n)\n\n, cqm_130 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM130'\n\n)\n\n, nqf_0420 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0420'\n\n)\n\n, adh_diabetes as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-Diabetes'\n\n)\n\n, adh_ras as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-RAS'\n \n)\n\n, joined as (\n\n select\n measures_long.patient_id\n , max(nqf_2372.performance_flag) as nqf_2372\n , max(nqf_0034.performance_flag) as nqf_0034\n , max(nqf_0059.performance_flag) as nqf_0059\n , max(cqm_236.performance_flag) as cqm_236\n , max(nqf_0053.performance_flag) as nqf_0053\n , max(cbe_0055.performance_flag) as cbe_0055\n , max(nqf_0097.performance_flag) as nqf_0097\n , max(cqm_438.performance_flag) as cqm_438\n , max(nqf_0041.performance_flag) as nqf_0041\n , max(cbe_0101.performance_flag) as cbe_0101\n , max(cqm_48.performance_flag) as cqm_48\n , max(cqm_130.performance_flag) as cqm_130\n , max(nqf_0420.performance_flag) as nqf_0420\n , max(adh_diabetes.performance_flag) as adh_diabetes\n , max(adh_ras.performance_flag) as adh_ras\n from measures_long\n left join nqf_2372\n on measures_long.patient_id = nqf_2372.patient_id\n left join nqf_0034\n on measures_long.patient_id = nqf_0034.patient_id\n left join nqf_0059\n on measures_long.patient_id = nqf_0059.patient_id\n left join cqm_236\n on measures_long.patient_id = cqm_236.patient_id\n left join nqf_0053\n on measures_long.patient_id = nqf_0053.patient_id\n left join cbe_0055\n on measures_long.patient_id = cbe_0055.patient_id\n left join nqf_0097\n on measures_long.patient_id = nqf_0097.patient_id\n left join cqm_438\n on measures_long.patient_id = cqm_438.patient_id\n left join nqf_0041\n on measures_long.patient_id = nqf_0041.patient_id\n left join cbe_0101\n on measures_long.patient_id = cbe_0101.patient_id\n left join cqm_48\n on measures_long.patient_id = cqm_48.patient_id\n left join cqm_130\n on measures_long.patient_id = cqm_130.patient_id\n left join nqf_0420\n on measures_long.patient_id = nqf_0420.patient_id\n left join adh_diabetes\n on measures_long.patient_id = adh_diabetes.patient_id\n left join adh_ras\n on measures_long.patient_id = adh_ras.patient_id\n group by measures_long.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(nqf_2372 as integer) as nqf_2372\n , cast(nqf_0034 as integer) as nqf_0034\n , cast(nqf_0059 as integer) as nqf_0059\n , cast(cqm_236 as integer) as cqm_236\n , cast(nqf_0053 as integer) as nqf_0053\n , cast(cbe_0055 as integer) as cbe_0055\n , cast(nqf_0097 as integer) as nqf_0097\n , cast(cqm_438 as integer) as cqm_438 \n , cast(nqf_0041 as integer) as nqf_0041\n , cast(cbe_0101 as integer) as cbe_0101\n , cast(cqm_48 as integer) as cqm_48\n , cast(cqm_130 as integer) as cqm_130\n , cast(nqf_0420 as integer) as nqf_0420\n , cast(adh_diabetes as integer) as adh_diabetes\n , cast(adh_ras as integer) as adh_ras\n from joined\n\n)\n\nselect\n patient_id\n , nqf_2372\n , nqf_0034\n , nqf_0059\n , cqm_236\n , nqf_0053\n , cbe_0055\n , nqf_0097\n , cqm_438\n , nqf_0041\n , cbe_0101\n , cqm_48\n , cqm_130\n , nqf_0420\n , adh_diabetes\n , adh_ras\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__summary_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/final/quality_measures__summary_wide.sql", "compiled": true, "compiled_code": "\n\n/*\n Each measure is pivoted into a boolean column by evaluating the\n denominator, numerator, and exclusion flags.\n*/\nwith measures_long as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , measure_id\n from cms_synthetic.quality_measures.summary_long\n\n)\n\n, nqf_2372 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF2372'\n\n)\n\n, nqf_0034 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0034'\n\n)\n\n, nqf_0059 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0059'\n\n)\n\n, cqm_236 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM236'\n\n)\n\n, nqf_0053 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0053'\n\n)\n\n, cbe_0055 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0055'\n\n)\n\n, nqf_0097 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0097'\n\n)\n\n, cqm_438 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM438'\n\n)\n\n, nqf_0041 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0041'\n\n)\n\n, cbe_0101 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0101'\n\n)\n\n, cqm_48 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM48'\n\n)\n\n, cqm_130 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM130'\n\n)\n\n, nqf_0420 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0420'\n\n)\n\n, adh_diabetes as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-Diabetes'\n\n)\n\n, adh_ras as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-RAS'\n \n)\n\n, joined as (\n\n select\n measures_long.patient_id\n , max(nqf_2372.performance_flag) as nqf_2372\n , max(nqf_0034.performance_flag) as nqf_0034\n , max(nqf_0059.performance_flag) as nqf_0059\n , max(cqm_236.performance_flag) as cqm_236\n , max(nqf_0053.performance_flag) as nqf_0053\n , max(cbe_0055.performance_flag) as cbe_0055\n , max(nqf_0097.performance_flag) as nqf_0097\n , max(cqm_438.performance_flag) as cqm_438\n , max(nqf_0041.performance_flag) as nqf_0041\n , max(cbe_0101.performance_flag) as cbe_0101\n , max(cqm_48.performance_flag) as cqm_48\n , max(cqm_130.performance_flag) as cqm_130\n , max(nqf_0420.performance_flag) as nqf_0420\n , max(adh_diabetes.performance_flag) as adh_diabetes\n , max(adh_ras.performance_flag) as adh_ras\n from measures_long\n left join nqf_2372\n on measures_long.patient_id = nqf_2372.patient_id\n left join nqf_0034\n on measures_long.patient_id = nqf_0034.patient_id\n left join nqf_0059\n on measures_long.patient_id = nqf_0059.patient_id\n left join cqm_236\n on measures_long.patient_id = cqm_236.patient_id\n left join nqf_0053\n on measures_long.patient_id = nqf_0053.patient_id\n left join cbe_0055\n on measures_long.patient_id = cbe_0055.patient_id\n left join nqf_0097\n on measures_long.patient_id = nqf_0097.patient_id\n left join cqm_438\n on measures_long.patient_id = cqm_438.patient_id\n left join nqf_0041\n on measures_long.patient_id = nqf_0041.patient_id\n left join cbe_0101\n on measures_long.patient_id = cbe_0101.patient_id\n left join cqm_48\n on measures_long.patient_id = cqm_48.patient_id\n left join cqm_130\n on measures_long.patient_id = cqm_130.patient_id\n left join nqf_0420\n on measures_long.patient_id = nqf_0420.patient_id\n left join adh_diabetes\n on measures_long.patient_id = adh_diabetes.patient_id\n left join adh_ras\n on measures_long.patient_id = adh_ras.patient_id\n group by measures_long.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(nqf_2372 as integer) as nqf_2372\n , cast(nqf_0034 as integer) as nqf_0034\n , cast(nqf_0059 as integer) as nqf_0059\n , cast(cqm_236 as integer) as cqm_236\n , cast(nqf_0053 as integer) as nqf_0053\n , cast(cbe_0055 as integer) as cbe_0055\n , cast(nqf_0097 as integer) as nqf_0097\n , cast(cqm_438 as integer) as cqm_438 \n , cast(nqf_0041 as integer) as nqf_0041\n , cast(cbe_0101 as integer) as cbe_0101\n , cast(cqm_48 as integer) as cqm_48\n , cast(cqm_130 as integer) as cqm_130\n , cast(nqf_0420 as integer) as nqf_0420\n , cast(adh_diabetes as integer) as adh_diabetes\n , cast(adh_ras as integer) as adh_ras\n from joined\n\n)\n\nselect\n patient_id\n , nqf_2372\n , nqf_0034\n , nqf_0059\n , cqm_236\n , nqf_0053\n , cbe_0055\n , nqf_0097\n , cqm_438\n , nqf_0041\n , cbe_0101\n , cqm_48\n , cqm_130\n , nqf_0420\n , adh_diabetes\n , adh_ras\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__summary_counts": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__summary_counts", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/final/quality_measures__summary_counts.sql", "original_file_path": "models/quality_measures/final/quality_measures__summary_counts.sql", "unique_id": "model.the_tuva_project.quality_measures__summary_counts", "fqn": ["the_tuva_project", "quality_measures", "final", "quality_measures__summary_counts"], "alias": "summary_counts", "checksum": {"name": "sha256", "checksum": "877e17f23fc14d6fea5d36aca6aed1f850cae3cf6db85f4a0e28973587e2302d"}, "config": {"enabled": true, "alias": "summary_counts", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Reporting measure counts with performance rates.", "columns": {"measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_sum": {"name": "denominator_sum", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_sum": {"name": "numerator_sum", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved with exclusion logic applied.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_sum": {"name": "exclusion_sum", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_rate": {"name": "performance_rate", "description": "Calculated performance rate. The numerator sum divided by the denominator sum after exclusion logic applied and multiplied by 100.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "summary_counts", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.873327, "relation_name": "cms_synthetic.quality_measures.summary_counts", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith summary_long as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n from {{ ref('quality_measures__summary_long') }}\n where measure_id is not null\n\n)\n\n, calculate_performance_rate as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , sum(denominator_flag) as denominator_sum\n , sum(numerator_flag) as numerator_sum\n , sum(exclusion_flag) as exclusion_sum\n , (\n cast(sum(performance_flag) as {{ dbt.type_numeric() }}) /\n (cast(count(performance_flag) as {{ dbt.type_numeric() }}) )\n )*100 as performance_rate\n from summary_long\n group by\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(denominator_sum as integer) as denominator_sum\n , cast(numerator_sum as integer) as numerator_sum\n , cast(exclusion_sum as integer) as exclusion_sum\n , round(cast(performance_rate as {{ dbt.type_numeric() }}),3) as performance_rate\n from calculate_performance_rate\n\n)\n\nselect\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_sum\n , numerator_sum\n , exclusion_sum\n , performance_rate\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__summary_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/final/quality_measures__summary_counts.sql", "compiled": true, "compiled_code": "\n\nwith summary_long as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n from cms_synthetic.quality_measures.summary_long\n where measure_id is not null\n\n)\n\n, calculate_performance_rate as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , sum(denominator_flag) as denominator_sum\n , sum(numerator_flag) as numerator_sum\n , sum(exclusion_flag) as exclusion_sum\n , (\n cast(sum(performance_flag) as numeric(28,6)) /\n (cast(count(performance_flag) as numeric(28,6)) )\n )*100 as performance_rate\n from summary_long\n group by\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(denominator_sum as integer) as denominator_sum\n , cast(numerator_sum as integer) as numerator_sum\n , cast(exclusion_sum as integer) as exclusion_sum\n , round(cast(performance_rate as numeric(28,6)),3) as performance_rate\n from calculate_performance_rate\n\n)\n\nselect\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_sum\n , numerator_sum\n , exclusion_sum\n , performance_rate\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__summary_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__summary_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/final/quality_measures__summary_long.sql", "original_file_path": "models/quality_measures/final/quality_measures__summary_long.sql", "unique_id": "model.the_tuva_project.quality_measures__summary_long", "fqn": ["the_tuva_project", "quality_measures", "final", "quality_measures__summary_long"], "alias": "summary_long", "checksum": {"name": "sha256", "checksum": "4b6ac12efee35e62d06e865efc1267927e09ead19ef6ba4f4f87febe82cf1ab4"}, "config": {"enabled": true, "alias": "summary_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Long view of the results for the reporting version of all measures. Each row represents the results a measure per patient. A null for the denominator indicates that the patient was not eligible for that measure.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_flag": {"name": "performance_flag", "description": "Performance flag calculated by using exclusion, numerator, and denominator flags. When excluded from a measure the flag is null.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "summary_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.87659, "relation_name": "cms_synthetic.quality_measures.summary_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/* measures should already be at the full eligibility population grain */\nwith union_measures as (\n\n {{ dbt_utils.union_relations(\n\n relations=[\n ref('quality_measures__int_nqf2372_long')\n , ref('quality_measures__int_nqf0034_long')\n , ref('quality_measures__int_nqf0059_long')\n , ref('quality_measures__int_cqm236_long')\n , ref('quality_measures__int_nqf0053_long')\n , ref('quality_measures__int_cbe0055_long')\n , ref('quality_measures__int_nqf0097_long')\n , ref('quality_measures__int_cqm438_long')\n , ref('quality_measures__int_nqf0041_long')\n , ref('quality_measures__int_cbe0101_long')\n , ref('quality_measures__int_cqm48_long')\n , ref('quality_measures__int_cqm130_long')\n , ref('quality_measures__int_nqf0420_long')\n , ref('quality_measures__int_adh_diabetes_long')\n , ref('quality_measures__int_adhras_long')\n ]\n\n ) }}\n\n)\n\n, patient as (\n\n select distinct patient_id\n from {{ ref('quality_measures__stg_core__patient') }}\n\n)\n\n/* selecting the full patient population as the grain of this table */\n, joined as (\n\n select distinct\n patient.patient_id\n , union_measures.denominator_flag\n , union_measures.numerator_flag\n , union_measures.exclusion_flag\n , case\n when union_measures.exclusion_flag = 1 then null\n when union_measures.numerator_flag = 1 then 1\n when union_measures.denominator_flag = 1 then 0\n else null\n end as performance_flag\n , union_measures.evidence_date\n , union_measures.evidence_value\n , union_measures.exclusion_date\n , union_measures.exclusion_reason\n , union_measures.performance_period_begin\n , union_measures.performance_period_end\n , union_measures.measure_id\n , union_measures.measure_name\n , union_measures.measure_version\n from patient\n left join union_measures\n on patient.patient_id = union_measures.patient_id\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(performance_flag as integer) as performance_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from joined\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_long", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_long", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_long", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_long", "package": null, "version": null}, {"name": "quality_measures__int_adhras_long", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_long", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0059_long", "model.the_tuva_project.quality_measures__int_cqm236_long", "model.the_tuva_project.quality_measures__int_nqf0053_long", "model.the_tuva_project.quality_measures__int_cbe0055_long", "model.the_tuva_project.quality_measures__int_nqf0097_long", "model.the_tuva_project.quality_measures__int_cqm438_long", "model.the_tuva_project.quality_measures__int_nqf0041_long", "model.the_tuva_project.quality_measures__int_cbe0101_long", "model.the_tuva_project.quality_measures__int_cqm48_long", "model.the_tuva_project.quality_measures__int_cqm130_long", "model.the_tuva_project.quality_measures__int_nqf0420_long", "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "model.the_tuva_project.quality_measures__int_adhras_long", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/final/quality_measures__summary_long.sql", "compiled": true, "compiled_code": "\n\n/* measures should already be at the full eligibility population grain */\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), union_measures as (\n\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf2372_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf2372_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0034_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0034_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0059_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0059_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm236_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm236_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0053_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0053_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cbe0055_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cbe0055_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0097_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0097_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm438_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm438_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0041_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0041_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cbe0101_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cbe0101_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm48_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm48_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm130_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm130_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0420_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0420_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_adh_diabetes_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_adh_diabetes_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_adhras_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_adhras_long\n\n \n )\n\n \n\n)\n\n, patient as (\n\n select distinct patient_id\n from __dbt__cte___stg_patient\n\n)\n\n/* selecting the full patient population as the grain of this table */\n, joined as (\n\n select distinct\n patient.patient_id\n , union_measures.denominator_flag\n , union_measures.numerator_flag\n , union_measures.exclusion_flag\n , case\n when union_measures.exclusion_flag = 1 then null\n when union_measures.numerator_flag = 1 then 1\n when union_measures.denominator_flag = 1 then 0\n else null\n end as performance_flag\n , union_measures.evidence_date\n , union_measures.evidence_value\n , union_measures.exclusion_date\n , union_measures.exclusion_reason\n , union_measures.performance_period_begin\n , union_measures.performance_period_end\n , union_measures.measure_id\n , union_measures.measure_name\n , union_measures.measure_version\n from patient\n left join union_measures\n on patient.patient_id = union_measures.patient_id\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(performance_flag as integer) as performance_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from joined\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_denominator"], "alias": "_int_nqf0041_denominator", "checksum": {"name": "sha256", "checksum": "3d3aad14b1ad8223b6aa8e79c1880157426cbe2bf07ff8e05aa66cf148112a1c"}, "config": {"enabled": true, "alias": "_int_nqf0041_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Influenza Immunization\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.968661, "relation_name": "cms_synthetic.quality_measures._int_nqf0041_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'discharge services nursing facility'\n , 'hemodialysis'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'peritoneal dialysis'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services group counseling'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'preventive care services, initial office visit, 0 to 17'\n , 'preventive care, established office visit, 0 to 17'\n , 'online assessments'\n , 'patient provider interaction'\n , 'telephone visits'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ ref('quality_measures__stg_core__procedure') }} procedures\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , ({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as age_in_decimal_point\n , max_date\n , qualifying_types\n from {{ ref('quality_measures__stg_core__patient') }} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age_in_decimal_point as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join {{ ref('quality_measures__int_nqf0041__performance_period') }} pp\n where age_in_decimal_point >= 0.5 --filters patients aged 6 months or older\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , round(cast(age as {{ dbt.type_numeric() }}), 1) as age -- ensures age is seen in one decimal point\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff", "macro.dbt.type_numeric"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'discharge services nursing facility'\n , 'hemodialysis'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'peritoneal dialysis'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services group counseling'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'preventive care services, initial office visit, 0 to 17'\n , 'preventive care, established office visit, 0 to 17'\n , 'online assessments'\n , 'patient provider interaction'\n , 'telephone visits'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , (datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age_in_decimal_point\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age_in_decimal_point as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_nqf0041__performance_period pp\n where age_in_decimal_point >= 0.5 --filters patients aged 6 months or older\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(age as numeric(28,6)), 1) as age -- ensures age is seen in one decimal point\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_numerator"], "alias": "_int_nqf0041_numerator", "checksum": {"name": "sha256", "checksum": "b84ea0b75eeb981905e0dc38022152c6fa1291365f1832ae7280b6ff1fc73551"}, "config": {"enabled": true, "alias": "_int_nqf0041_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0041, Influenza Immunization\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.973516, "relation_name": "cms_synthetic.quality_measures._int_nqf0041_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_nqf0041_denominator') }}\n\n)\n\n, influenza_vaccination_code as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'influenza vaccination'\n , 'influenza vaccine'\n , 'influenza virus laiv immunization'\n , 'influenza virus laiv procedure'\n )\n\n)\n\n, procedure_vaccination as (\n\n select\n patient_id\n , procedure_date\n from {{ ref('quality_measures__stg_core__procedure') }} as procedures\n inner join influenza_vaccination_code\n on coalesce(procedures.normalized_code, procedures.source_code) = influenza_vaccination_code.code\n and coalesce(procedures.normalized_code_type, procedures.source_code_type) = influenza_vaccination_code.code_system\n\n)\n\n, claims_vaccination as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join influenza_vaccination_code\n on medical_claim.hcpcs_code = influenza_vaccination_code.code\n\n)\n\n, qualifying_procedures as (\n\n select\n procedure_vaccination.patient_id\n , procedure_vaccination.procedure_date as evidence_date\n from procedure_vaccination\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} pp\n on procedure_date between \n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualifying_claims as (\n\n select \n claims_vaccination.patient_id\n , claims_vaccination.max_date as evidence_date\n from claims_vaccination\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} pp\n on max_date between\n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualified_patients as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualified_patients.patient_id\n , qualified_patients.evidence_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , 1 as numerator_flag\n from qualified_patients\n inner join denominator\n on qualified_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0041_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__int_nqf0041__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0041_denominator\n\n)\n\n, influenza_vaccination_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza vaccination'\n , 'influenza vaccine'\n , 'influenza virus laiv immunization'\n , 'influenza virus laiv procedure'\n )\n\n)\n\n, procedure_vaccination as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procedures\n inner join influenza_vaccination_code\n on coalesce(procedures.normalized_code, procedures.source_code) = influenza_vaccination_code.code\n and coalesce(procedures.normalized_code_type, procedures.source_code_type) = influenza_vaccination_code.code_system\n\n)\n\n, claims_vaccination as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join influenza_vaccination_code\n on medical_claim.hcpcs_code = influenza_vaccination_code.code\n\n)\n\n, qualifying_procedures as (\n\n select\n procedure_vaccination.patient_id\n , procedure_vaccination.procedure_date as evidence_date\n from procedure_vaccination\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period pp\n on procedure_date between \n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualifying_claims as (\n\n select \n claims_vaccination.patient_id\n , claims_vaccination.max_date as evidence_date\n from claims_vaccination\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period pp\n on max_date between\n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualified_patients as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualified_patients.patient_id\n , qualified_patients.evidence_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , 1 as numerator_flag\n from qualified_patients\n inner join denominator\n on qualified_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_long"], "alias": "_int_nqf0041_long", "checksum": {"name": "sha256", "checksum": "add63325317278b6f3a8b7ef79169c0fa2ac1d20f706259c726ab2738fa1f023"}, "config": {"enabled": true, "alias": "_int_nqf0041_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0041, Influenza Immunization before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.971872, "relation_name": "cms_synthetic.quality_measures._int_nqf0041_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_nqf0041_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_nqf0041_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf0041_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0041_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0041_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0041_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0041_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0041__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041__performance_period"], "alias": "_int_nqf0041__performance_period", "checksum": {"name": "sha256", "checksum": "15a5f0ec0b2f5cc1c9bd2c790cb1ae679f3e4245c255038eaff7632c05494e8f"}, "config": {"enabled": true, "alias": "_int_nqf0041__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Influenza Immunization\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.966911, "relation_name": "cms_synthetic.quality_measures._int_nqf0041__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0041')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0041')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0041')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n - set quality_measures_period_end to december end for last quarter measurement period\r\n - set quality_measures_period_end to march end for first quarter measurement period \r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to following day of 3 months prior\r\n for visits in influenza season\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -3\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\n/*\r\n lookback_period for august of either current or previous year\r\n for immunization qualifying date\r\n*/\r\n, lookback_period as (\r\n\r\n select\r\n *\r\n , case\r\n when {{ date_part('month', 'performance_period_end') | as_number }} between 1 and 8\r\n then {{ dbt.concat([\r\n \"(cast(\" ~\r\n date_part('year', 'performance_period_end') ~\r\n \" as integer) - 1)\",\r\n \"'-08-01'\"\r\n ]) }}\r\n else {{ dbt.concat([\r\n date_part('year', 'performance_period_end'),\r\n \"'-08-01'\"\r\n ]) }}\r\n end as lookback_period_august\r\n from period_begin\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(lookback_period_august as date) as lookback_period_august\r\nfrom lookback_period", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n - set quality_measures_period_end to december end for last quarter measurement period\n - set quality_measures_period_end to march end for first quarter measurement period \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 3 months prior\n for visits in influenza season\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n month,\n -3,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n lookback_period for august of either current or previous year\n for immunization qualifying date\n*/\n, lookback_period as (\n\n select\n *\n , case\n when date_part('month', performance_period_end) between 1 and 8\n then (cast(date_part('year', performance_period_end) as integer) - 1) || '-08-01'\n else date_part('year', performance_period_end) || '-08-01'\n end as lookback_period_august\n from period_begin\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_august as date) as lookback_period_august\nfrom lookback_period", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_exclusions"], "alias": "_int_nqf0041_exclusions", "checksum": {"name": "sha256", "checksum": "552ea514acff2310f748d0b6c9ac1fa5b07e66c42286b953df44199ed0556452"}, "config": {"enabled": true, "alias": "_int_nqf0041_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0041, Influenza Immunization.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.970248, "relation_name": "cms_synthetic.quality_measures._int_nqf0041_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n\n select \n performance_period_begin\n from {{ ref('quality_measures__int_nqf0041__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n\n select \n performance_period_end\n from {{ ref('quality_measures__int_nqf0041__performance_period') }}\n\n)\n{%- endset -%}\n\nwith denominator as (\n \n select\n patient_id\n from {{ ref('quality_measures__int_nqf0041_denominator') }}\n\n)\n\n, exclusion_codes as (\n\n select \n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'influenza immunization not ordered or administered reason documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from hospice_palliative\n where exclusion_reason in (\n 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select\n valid_exclusions.patient_id\n , valid_exclusions.exclusion_date\n , valid_exclusions.exclusion_reason\n from valid_exclusions\n inner join denominator\n on valid_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0041_influenza_immunization/quality_measures__int_nqf0041_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0041_denominator\n\n)\n\n, exclusion_codes as (\n\n select \n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza immunization not ordered or administered reason documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from hospice_palliative\n where exclusion_reason in (\n 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select\n valid_exclusions.patient_id\n , valid_exclusions.exclusion_date\n , valid_exclusions.exclusion_reason\n from valid_exclusions\n inner join denominator\n on valid_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_exclude_mastectomy", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_exclude_mastectomy.sql", "original_file_path": "models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_exclude_mastectomy.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_exclude_mastectomy"], "alias": "_int_nqf2372_exclude_mastectomy", "checksum": {"name": "sha256", "checksum": "7c48d82611dc2dae097de5fabcf2e00ffd09811b7bd1014b43f4120ed2b1d404"}, "config": {"enabled": true, "alias": "_int_nqf2372_exclude_mastectomy", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with a mastectomy for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_exclude_mastectomy", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.892714, "relation_name": "cms_synthetic.quality_measures._int_nqf2372_exclude_mastectomy", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy or for whom there is evidence of a right and a left\n unilateral mastectomy\n*/\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n from {{ ref('quality_measures__int_nqf2372_denominator') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where concept_name in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n , 'Status Post Left Mastectomy'\n , 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Left'\n , 'Unilateral Mastectomy Right'\n , 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, all_mastectomy as (\n\n select\n denominator.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from denominator\n inner join condition_exclusions\n on denominator.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from denominator\n inner join observation_exclusions\n on denominator.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from denominator\n inner join procedure_exclusions\n on denominator.patient_id = procedure_exclusions.patient_id\n\n)\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy\n*/\n, bilateral_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n )\n\n)\n\n, right_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Right'\n )\n\n)\n\n, left_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Left Mastectomy'\n , 'Unilateral Mastectomy Left'\n )\n\n)\n\n, unspecified_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n/*\n Women for whom there is evidence of a right AND a left unilateral mastectomy\n or unspecific mastectomies on different dates\n*/\n, unilateral_mastectomy as (\n\n select\n right_mastectomy.patient_id\n , right_mastectomy.exclusion_date\n , right_mastectomy.exclusion_reason\n from right_mastectomy\n inner join left_mastectomy\n on right_mastectomy.patient_id = left_mastectomy.patient_id\n\n union all\n\n select\n unspecified_mastectomy.patient_id\n , unspecified_mastectomy.exclusion_date\n , unspecified_mastectomy.exclusion_reason\n from unspecified_mastectomy\n inner join unspecified_mastectomy as self_join\n on unspecified_mastectomy.patient_id = self_join.patient_id\n and unspecified_mastectomy.exclusion_date <> self_join.exclusion_date\n\n)\n\n, unioned as (\n\n select * from bilateral_mastectomy\n union all\n select * from unilateral_mastectomy\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom unioned", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_exclude_mastectomy.sql", "compiled": true, "compiled_code": "\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy or for whom there is evidence of a right and a left\n unilateral mastectomy\n*/\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n , 'Status Post Left Mastectomy'\n , 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Left'\n , 'Unilateral Mastectomy Right'\n , 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, all_mastectomy as (\n\n select\n denominator.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from denominator\n inner join condition_exclusions\n on denominator.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from denominator\n inner join observation_exclusions\n on denominator.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from denominator\n inner join procedure_exclusions\n on denominator.patient_id = procedure_exclusions.patient_id\n\n)\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy\n*/\n, bilateral_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n )\n\n)\n\n, right_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Right'\n )\n\n)\n\n, left_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Left Mastectomy'\n , 'Unilateral Mastectomy Left'\n )\n\n)\n\n, unspecified_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n/*\n Women for whom there is evidence of a right AND a left unilateral mastectomy\n or unspecific mastectomies on different dates\n*/\n, unilateral_mastectomy as (\n\n select\n right_mastectomy.patient_id\n , right_mastectomy.exclusion_date\n , right_mastectomy.exclusion_reason\n from right_mastectomy\n inner join left_mastectomy\n on right_mastectomy.patient_id = left_mastectomy.patient_id\n\n union all\n\n select\n unspecified_mastectomy.patient_id\n , unspecified_mastectomy.exclusion_date\n , unspecified_mastectomy.exclusion_reason\n from unspecified_mastectomy\n inner join unspecified_mastectomy as self_join\n on unspecified_mastectomy.patient_id = self_join.patient_id\n and unspecified_mastectomy.exclusion_date <> self_join.exclusion_date\n\n)\n\n, unioned as (\n\n select * from bilateral_mastectomy\n union all\n select * from unilateral_mastectomy\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf2372__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372__performance_period"], "alias": "_int_nqf2372__performance_period", "checksum": {"name": "sha256", "checksum": "250a86bbde61680e8fc5f86dba6f83d84d72d68010d8f18f7d693f6b6f42925e"}, "config": {"enabled": true, "alias": "_int_nqf2372__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Breast Cancer screening.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8893518, "relation_name": "cms_synthetic.quality_measures._int_nqf2372__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF2372')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF2372')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF2372')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback period to 27 months prior to the end of the\n performance period\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , {{ dbt.dateadd (\n datepart = \"month\"\n , interval = -27\n , from_date_or_timestamp = \"performance_period_end\"\n ) }} as performance_period_lookback\n from period_begin\n\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_lookback as date) as performance_period_lookback\nfrom period_lookback", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback period to 27 months prior to the end of the\n performance period\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n month,\n -27,\n performance_period_end\n )\n\n as performance_period_lookback\n from period_begin\n\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_version\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_lookback as date) as performance_period_lookback\nfrom period_lookback", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_numerator"], "alias": "_int_nqf2372_numerator", "checksum": {"name": "sha256", "checksum": "9b1cf65a8fac45cbe94adbdb716156bfc3a02ec5be08d909ab7da29029537c7f"}, "config": {"enabled": true, "alias": "_int_nqf2372_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8978229, "relation_name": "cms_synthetic.quality_measures._int_nqf2372_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/*\n Eligible population from the denominator model before exclusions\n*/\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_nqf2372_denominator') }}\n\n)\n\n, mammography_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where concept_name = 'Mammography'\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n from medical_claim\n inner join mammography_codes\n on medical_claim.hcpcs_code = mammography_codes.code\n where mammography_codes.code_system = 'hcpcs'\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n from observations\n inner join mammography_codes\n on observations.code = mammography_codes.code\n and observations.code_type = mammography_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join mammography_codes\n on procedures.code = mammography_codes.code\n and procedures.code_type = mammography_codes.code_system\n\n)\n\n/*\n Check if patients in the eligible population have had a screening,\n diagnostic, film, digital or digital breast tomosynthesis (3D)\n mammography results documented and reviewed.\n*/\n\n, patients_with_mammograms as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.performance_period_lookback\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_start_date\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_end_date\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_observations.observation_date\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_procedures.procedure_date\n else null\n end as evidence_date\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n else 0\n end as numerator_flag\n from denominator\n left join qualifying_claims\n on denominator.patient_id = qualifying_claims.patient_id\n left join qualifying_observations\n on denominator.patient_id = qualifying_observations.patient_id\n left join qualifying_procedures\n on denominator.patient_id = qualifying_procedures.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(numerator_flag as integer) as numerator_flag\n from patients_with_mammograms\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_numerator.sql", "compiled": true, "compiled_code": "\n\n/*\n Eligible population from the denominator model before exclusions\n*/\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf2372_denominator\n\n)\n\n, mammography_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name = 'Mammography'\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n from medical_claim\n inner join mammography_codes\n on medical_claim.hcpcs_code = mammography_codes.code\n where mammography_codes.code_system = 'hcpcs'\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n from observations\n inner join mammography_codes\n on observations.code = mammography_codes.code\n and observations.code_type = mammography_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join mammography_codes\n on procedures.code = mammography_codes.code\n and procedures.code_type = mammography_codes.code_system\n\n)\n\n/*\n Check if patients in the eligible population have had a screening,\n diagnostic, film, digital or digital breast tomosynthesis (3D)\n mammography results documented and reviewed.\n*/\n\n, patients_with_mammograms as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.performance_period_lookback\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_start_date\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_end_date\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_observations.observation_date\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_procedures.procedure_date\n else null\n end as evidence_date\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n else 0\n end as numerator_flag\n from denominator\n left join qualifying_claims\n on denominator.patient_id = qualifying_claims.patient_id\n left join qualifying_observations\n on denominator.patient_id = qualifying_observations.patient_id\n left join qualifying_procedures\n on denominator.patient_id = qualifying_procedures.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(numerator_flag as integer) as numerator_flag\n from patients_with_mammograms\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_long"], "alias": "_int_nqf2372_long", "checksum": {"name": "sha256", "checksum": "51bc837bc7595d9170923bc49805e87e31d3252789cd9d4dc832b08af00f07fb"}, "config": {"enabled": true, "alias": "_int_nqf2372_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 2372, Breast Cancer Screening before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8961432, "relation_name": "cms_synthetic.quality_measures._int_nqf2372_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_nqf2372_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , numerator_flag\n from {{ ref('quality_measures__int_nqf2372_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n from {{ ref('quality_measures__int_nqf2372_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then denominator.denominator_flag\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null\n then numerator.numerator_flag\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null\n then exclusions.exclusion_flag\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf2372_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , numerator_flag\n from cms_synthetic.quality_measures._int_nqf2372_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n from cms_synthetic.quality_measures._int_nqf2372_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then denominator.denominator_flag\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null\n then numerator.numerator_flag\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null\n then exclusions.exclusion_flag\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_exclusions"], "alias": "_int_nqf2372_exclusions", "checksum": {"name": "sha256", "checksum": "4ff6c12007edf61f34d92f0461179db3e47156ee30b1978a7a0dcfa761a26ce1"}, "config": {"enabled": true, "alias": "_int_nqf2372_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.894461, "relation_name": "cms_synthetic.quality_measures._int_nqf2372_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_nqf2372__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_nqf2372__performance_period') }}\n\n)\n{%- endset -%}\n\nwith frailty as (\n\n select\n *\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_mastectomy_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf2372_exclude_mastectomy') }}\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n and\n exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n or source.paid_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\n and {{ performance_period_end }}\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n)\n-- advanced illness end\n\n, valid_mastectomy_patients_with_exclusion_type as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'mastectomy_performed' as exclusion_type\n from valid_mastectomy_patients\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join {{ ref('quality_measures__int_nqf2372_denominator') }} denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type != 'hospice_palliative' \n and age >= 66\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, valid_exclusions_with_mastectomy as (\n\n select *\n from valid_exclusions\n\n union all\n\n select *\n from valid_mastectomy_patients_with_exclusion_type\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions_with_mastectomy\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_exclude_mastectomy", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_nqf2372_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_mastectomy_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf2372_exclude_mastectomy\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n and\n exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n)\n-- advanced illness end\n\n, valid_mastectomy_patients_with_exclusion_type as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'mastectomy_performed' as exclusion_type\n from valid_mastectomy_patients\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join cms_synthetic.quality_measures._int_nqf2372_denominator denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type != 'hospice_palliative' \n and age >= 66\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, valid_exclusions_with_mastectomy as (\n\n select *\n from valid_exclusions\n\n union all\n\n select *\n from valid_mastectomy_patients_with_exclusion_type\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions_with_mastectomy\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_denominator"], "alias": "_int_nqf2372_denominator", "checksum": {"name": "sha256", "checksum": "bd8b17372132539b49b6dc13cc4626b098e6b94b09ffe0040bc7fe1da2a5b670"}, "config": {"enabled": true, "alias": "_int_nqf2372_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age as of the performance_period_begin date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_lookback": {"name": "performance_period_lookback", "description": "Lookback period of NQF2372.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8911428, "relation_name": "cms_synthetic.quality_measures._int_nqf2372_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n , performance_period_lookback\n from {{ ref('quality_measures__int_nqf2372__performance_period') }}\n\n)\n\n, patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , death_date\n from {{ ref('quality_measures__stg_core__patient') }}\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n from {{ ref('quality_measures__stg_core__encounter') }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where concept_name in (\n 'Office Visit'\n , 'Home Healthcare Services'\n , 'Preventive Care Services Established Office Visit, 18 and Up'\n , 'Preventive Care Services Initial Office Visit, 18 and Up'\n , 'Annual Wellness Visit'\n , 'Telephone Visits'\n , 'Online Assessments'\n )\n\n)\n\n, patient_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , patient.birth_date\n , patient.death_date\n , performance_period.measure_id\n , performance_period.measure_name\n , performance_period.measure_version\n , performance_period.performance_period_begin\n , performance_period.performance_period_end\n , performance_period.performance_period_lookback\n , floor({{ datediff('patient.birth_date', 'performance_period.performance_period_begin', 'hour') }} / 8760.0) as age -- 365*24 hours in a year\n from patient\n cross join performance_period\n\n)\n\n/*\n Filter patient to living women 51 - 74 years of age\n at the beginning of the measurement period\n*/\n, patient_filtered as (\n\n select\n patient_id\n , age\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , 1 as denominator_flag\n from patient_with_age\n where lower(sex) = 'female'\n and age between 51 and 74\n and death_date is null\n\n)\n\n/*\n Filter to qualifying visit types by claim procedures\n*/\n, visit_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n from medical_claim\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n where visit_codes.code_system = 'hcpcs'\n\n)\n\n/*\n Filter encounters to qualifying visit type\n*/\n, visit_encounters as (\n\n select\n patient_id\n , encounter_start_date\n from encounters\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n/*\n Filter to qualifying visit types by procedure\n*/\n, visit_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n/*\n Filter to final eligible population/denominator before exclusions\n with a qualifying visit during the measurement period\n*/\n, eligible_population as (\n\n select\n patient_filtered.patient_id\n , patient_filtered.age\n , patient_filtered.measure_id\n , patient_filtered.measure_name\n , patient_filtered.measure_version\n , patient_filtered.performance_period_begin\n , patient_filtered.performance_period_end\n , performance_period_lookback\n , patient_filtered.denominator_flag\n from patient_filtered\n left join visit_claims\n on patient_filtered.patient_id = visit_claims.patient_id\n left join visit_procedures\n on patient_filtered.patient_id = visit_procedures.patient_id\n left join visit_encounters\n on patient_filtered.patient_id = visit_encounters.patient_id\n where (\n visit_claims.claim_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_claims.claim_end_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_procedures.procedure_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_encounters.encounter_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n )\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_lookback as date) as performance_period_lookback\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from eligible_population\n\n)\n\n select distinct\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf2372_breast_cancer_screening/quality_measures__int_nqf2372_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n , performance_period_lookback\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n, patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n from __dbt__cte___stg_encounter\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name in (\n 'Office Visit'\n , 'Home Healthcare Services'\n , 'Preventive Care Services Established Office Visit, 18 and Up'\n , 'Preventive Care Services Initial Office Visit, 18 and Up'\n , 'Annual Wellness Visit'\n , 'Telephone Visits'\n , 'Online Assessments'\n )\n\n)\n\n, patient_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , patient.birth_date\n , patient.death_date\n , performance_period.measure_id\n , performance_period.measure_name\n , performance_period.measure_version\n , performance_period.performance_period_begin\n , performance_period.performance_period_end\n , performance_period.performance_period_lookback\n , floor(datediff(\n hour,\n patient.birth_date,\n performance_period.performance_period_begin\n ) / 8760.0) as age -- 365*24 hours in a year\n from patient\n cross join performance_period\n\n)\n\n/*\n Filter patient to living women 51 - 74 years of age\n at the beginning of the measurement period\n*/\n, patient_filtered as (\n\n select\n patient_id\n , age\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , 1 as denominator_flag\n from patient_with_age\n where lower(sex) = 'female'\n and age between 51 and 74\n and death_date is null\n\n)\n\n/*\n Filter to qualifying visit types by claim procedures\n*/\n, visit_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n from medical_claim\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n where visit_codes.code_system = 'hcpcs'\n\n)\n\n/*\n Filter encounters to qualifying visit type\n*/\n, visit_encounters as (\n\n select\n patient_id\n , encounter_start_date\n from encounters\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n/*\n Filter to qualifying visit types by procedure\n*/\n, visit_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n/*\n Filter to final eligible population/denominator before exclusions\n with a qualifying visit during the measurement period\n*/\n, eligible_population as (\n\n select\n patient_filtered.patient_id\n , patient_filtered.age\n , patient_filtered.measure_id\n , patient_filtered.measure_name\n , patient_filtered.measure_version\n , patient_filtered.performance_period_begin\n , patient_filtered.performance_period_end\n , performance_period_lookback\n , patient_filtered.denominator_flag\n from patient_filtered\n left join visit_claims\n on patient_filtered.patient_id = visit_claims.patient_id\n left join visit_procedures\n on patient_filtered.patient_id = visit_procedures.patient_id\n left join visit_encounters\n on patient_filtered.patient_id = visit_encounters.patient_id\n where (\n visit_claims.claim_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_claims.claim_end_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_procedures.procedure_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_encounters.encounter_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n )\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_lookback as date) as performance_period_lookback\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from eligible_population\n\n)\n\n select distinct\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_exclusions"], "alias": "_int_nqf0097_exclusions", "checksum": {"name": "sha256", "checksum": "e02a76034ca95729aed77d527c3aa0bf2858fd822468a7dc9514e114fa056fe2"}, "config": {"enabled": true, "alias": "_int_nqf0097_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0097, Medication Reconciliation Post-Discharge.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.94817, "relation_name": "cms_synthetic.quality_measures._int_nqf0097_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_nqf0097__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_nqf0097__performance_period') }}\n\n)\n{%- endset -%}\n\nwith valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select \n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n , valid_hospice_exclusions.exclusion_type\n from valid_hospice_exclusions\n inner join {{ref('quality_measures__int_nqf0097_denominator')}} as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_nqf0097_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_exclusions.sql", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0097__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0097__performance_period\n\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select \n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n , valid_hospice_exclusions.exclusion_type\n from valid_hospice_exclusions\n inner join cms_synthetic.quality_measures._int_nqf0097_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0097__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097__performance_period"], "alias": "_int_nqf0097__performance_period", "checksum": {"name": "sha256", "checksum": "150cfe2c4226b2a1c1857322d567b34f70b94f105e5e8a771b95e59fb2e90e8d"}, "config": {"enabled": true, "alias": "_int_nqf0097__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Medication Reconciliation Post-Discharge\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9527712, "relation_name": "cms_synthetic.quality_measures._int_nqf0097__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0097')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0097')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0097')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_long"], "alias": "_int_nqf0097_long", "checksum": {"name": "sha256", "checksum": "f28e0dfcde6e1bb110f7c8a02d5834f4e4445116b5033ed0409516a4bcc0cfad"}, "config": {"enabled": true, "alias": "_int_nqf0097_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0097, Medication Reconciliation Post-Discharge before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.949682, "relation_name": "cms_synthetic.quality_measures._int_nqf0097_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/* selecting the full patient population as the grain of this table */\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_nqf0097_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_nqf0097_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf0097_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0097_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_long.sql", "compiled": true, "compiled_code": "\n\n/* selecting the full patient population as the grain of this table */\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0097_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0097_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0097_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_numerator"], "alias": "_int_nqf0097_numerator", "checksum": {"name": "sha256", "checksum": "0d6ac7097effe8c7771c2aa8713207e3b885440428445ba3d51ff9fe690f0ebe"}, "config": {"enabled": true, "alias": "_int_nqf0097_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0097, Medication Reconciliation Post-Discharge.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9511008, "relation_name": "cms_synthetic.quality_measures._int_nqf0097_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n from {{ ref('quality_measures__int_nqf0097_denominator') }}\n\n)\n\n, reconciliation_codes as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'medication reconciliation post discharge'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, reconciliation_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join reconciliation_codes\n on procedures.code = reconciliation_codes.code\n and procedures.code_type = reconciliation_codes.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , reconciliation_procedures.procedure_date as evidence_date\n , 1 as numerator_flag\n from denominator\n inner join reconciliation_procedures\n on denominator.patient_id = reconciliation_procedures.patient_id\n where {{ datediff('denominator.discharge_date', 'reconciliation_procedures.procedure_date', 'day') }} between 0 and 30\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0097_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n from cms_synthetic.quality_measures._int_nqf0097_denominator\n\n)\n\n, reconciliation_codes as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medication reconciliation post discharge'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, reconciliation_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join reconciliation_codes\n on procedures.code = reconciliation_codes.code\n and procedures.code_type = reconciliation_codes.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , reconciliation_procedures.procedure_date as evidence_date\n , 1 as numerator_flag\n from denominator\n inner join reconciliation_procedures\n on denominator.patient_id = reconciliation_procedures.patient_id\n where datediff(\n day,\n denominator.discharge_date,\n reconciliation_procedures.procedure_date\n ) between 0 and 30\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_denominator"], "alias": "_int_nqf0097_denominator", "checksum": {"name": "sha256", "checksum": "b61ab540bfd8ffe383dd565b81469d0e65084a7e53b1454e3b014484abf36e34"}, "config": {"enabled": true, "alias": "_int_nqf0097_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Medication Reconciliation Post-Discharge\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Inpatient discharged date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9466932, "relation_name": "cms_synthetic.quality_measures._int_nqf0097_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n\n)\n\n, valid_concepts as (\n\n select\n concept_name\n from {{ ref('quality_measures__concepts') }}\n where concept_name in (\n 'annual wellness visit'\n , 'care services in long term residential facility'\n , 'encounter to document medications'\n , 'home healthcare services'\n , 'office visit'\n , 'outpatient'\n , 'psychoanalysis'\n )\n\n)\n\n, valid_visit_codes as (\n\n select\n visit_codes.concept_name\n , visit_codes.code\n , visit_codes.code_system\n from visit_codes\n inner join valid_concepts\n on visit_codes.concept_name = valid_concepts.concept_name\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , length_of_stay\n , encounter.encounter_end_date\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ref('quality_measures__stg_core__encounter')}} encounter\n inner join {{ref('quality_measures__int_nqf0097__performance_period')}} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n -- all encounter types considered; inpatient encounters are filtered by length of stay being more than 0 days\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ref('quality_measures__stg_core__procedure')}} procs\n\n inner join {{ref('quality_measures__int_nqf0097__performance_period')}} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join valid_visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = valid_visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\n inner join {{ref('quality_measures__int_nqf0097__performance_period')}} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join valid_visit_codes\n on medical_claim.hcpcs_code= valid_visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc\n , cast(null as {{ dbt.type_string() }}) as proc_enc\n , cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select\n patient_id\n , min_date\n , max_date\n , cast(null as {{ dbt.type_string() }}) as visit_enc\n , 'p' as proc_enc\n , cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select\n patient_id\n , min_date\n , max_date\n , cast(null as {{ dbt.type_string() }}) as visit_enc\n , cast(null as {{ dbt.type_string() }}) as proc_enc\n , 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\n , max_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\n , qualifying_types\n from {{ref('quality_measures__stg_core__patient')}} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , visits_encounters.encounter_end_date as discharge_date\n , 1 as denominator_flag\n from patients_with_age\n cross join {{ref('quality_measures__int_nqf0097__performance_period')}} pp\n inner join visits_encounters\n on patients_with_age.patient_id = visits_encounters.patient_id\n where max_age >= 18\n and visits_encounters.length_of_stay > 0 --ensures inpatient\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(discharge_date as date) as discharge_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__concepts", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "seed.the_tuva_project.quality_measures__concepts", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf_0097_medication_reconciliation_post_discharge/quality_measures__int_nqf0097_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n\n)\n\n, valid_concepts as (\n\n select\n concept_name\n from cms_synthetic.quality_measures._value_set_concepts\n where concept_name in (\n 'annual wellness visit'\n , 'care services in long term residential facility'\n , 'encounter to document medications'\n , 'home healthcare services'\n , 'office visit'\n , 'outpatient'\n , 'psychoanalysis'\n )\n\n)\n\n, valid_visit_codes as (\n\n select\n visit_codes.concept_name\n , visit_codes.code\n , visit_codes.code_system\n from visit_codes\n inner join valid_concepts\n on visit_codes.concept_name = valid_concepts.concept_name\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , length_of_stay\n , encounter.encounter_end_date\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0097__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n -- all encounter types considered; inpatient encounters are filtered by length of stay being more than 0 days\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n\n inner join cms_synthetic.quality_measures._int_nqf0097__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join valid_visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = valid_visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0097__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join valid_visit_codes\n on medical_claim.hcpcs_code= valid_visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc\n , cast(null as TEXT) as proc_enc\n , cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , 'p' as proc_enc\n , cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , cast(null as TEXT) as proc_enc\n , 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , visits_encounters.encounter_end_date as discharge_date\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_nqf0097__performance_period pp\n inner join visits_encounters\n on patients_with_age.patient_id = visits_encounters.patient_id\n where max_age >= 18\n and visits_encounters.length_of_stay > 0 --ensures inpatient\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(discharge_date as date) as discharge_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438__performance_period"], "alias": "_int_cqm438__performance_period", "checksum": {"name": "sha256", "checksum": "66f3181221e8ab333b6586d989214f06c50db2d4765bf8860c08db28be828c25"}, "config": {"enabled": true, "alias": "_int_cqm438__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9541209, "relation_name": "cms_synthetic.quality_measures._int_cqm438__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM438')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM438')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM438')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_exclusions"], "alias": "_int_cqm438_exclusions", "checksum": {"name": "sha256", "checksum": "a37aebecdf1a5e5342dde199d6fc92485b00938216e97d67549e8fcdddcbd063"}, "config": {"enabled": true, "alias": "_int_cqm438_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.962125, "relation_name": "cms_synthetic.quality_measures._int_cqm438_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_cqm438__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_cqm438__performance_period') }}\n\n)\n{%- endset -%}\n\nwith exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'rhabdomyolysis'\n , 'breastfeeding'\n , 'liver disease'\n , 'hepatitis a'\n , 'hepatitis b'\n , 'documentation of medical reason for no statin therapy'\n , 'statin allergen'\n , 'end stage renal disease'\n , 'statin associated muscle symptoms'\n , 'medical reason'\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n where recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n where observation_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, medications as (\n \n select\n patient_id\n , coalesce(prescribing_date, dispensing_date) as exclusion_date\n , source_code\n , source_code_type\n from {{ ref('quality_measures__stg_core__medication') }}\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from {{ ref('quality_measures__stg_pharmacy_claim') }} \n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.exclusion_date\n , exclusion_codes.concept_name as concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claims_exclusions as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , exclusion_codes.concept_name as concept_name\n from pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and lower(exclusion_codes.code_system) = 'ndc'\n\n)\n\n, patients_with_exclusions as(\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select \n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from medication_exclusions\n\n union all\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from pharmacy_claims_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join {{ ref('quality_measures__int_cqm438_denominator') }} as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__int_cqm438_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'rhabdomyolysis'\n , 'breastfeeding'\n , 'liver disease'\n , 'hepatitis a'\n , 'hepatitis b'\n , 'documentation of medical reason for no statin therapy'\n , 'statin allergen'\n , 'end stage renal disease'\n , 'statin associated muscle symptoms'\n , 'medical reason'\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n where observation_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medications as (\n \n select\n patient_id\n , coalesce(prescribing_date, dispensing_date) as exclusion_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim \n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.exclusion_date\n , exclusion_codes.concept_name as concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claims_exclusions as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , exclusion_codes.concept_name as concept_name\n from pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and lower(exclusion_codes.code_system) = 'ndc'\n\n)\n\n, patients_with_exclusions as(\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select \n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from medication_exclusions\n\n union all\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from pharmacy_claims_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join cms_synthetic.quality_measures._int_cqm438_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator"], "alias": "_int_cqm438_denominator", "checksum": {"name": "sha256", "checksum": "81fcf07995e0642c684d975dafd64d0c252baa241c7448bf1dd9bbaa8bbecd29"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for submission of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age as of performance_period_begin date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9604878, "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith patients_with_ascvd as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as criteria\n from {{ ref('quality_measures__int_cqm438_denominator_criteria1') }}\n\n)\n\n, patients_with_cholesterol as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 2 as criteria\n from {{ ref('quality_measures__int_cqm438_denominator_criteria2') }}\n\n)\n\n, patients_with_diabetes as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 3 as criteria\n from {{ ref('quality_measures__int_cqm438_denominator_criteria3') }}\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }} \n where lower(concept_name) in (\n 'annual wellness visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'outpatient encounters for preventive care'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ ref('quality_measures__stg_core__procedure') }} procedures\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor({{ datediff('birth_date', 'performance_period_begin', 'hour') }} / 8760.0) as age\n from {{ ref('quality_measures__stg_core__patient') }} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n and p.death_date is null\n cross join {{ ref('quality_measures__int_cqm438__performance_period') }}\n\n)\n\n, qualifying_patients_from_criteria1 as (\n\n select\n distinct\n patients_with_ascvd.patient_id\n , patients_with_age.age as age\n , patients_with_ascvd.performance_period_begin\n , patients_with_ascvd.performance_period_end\n , patients_with_ascvd.measure_id\n , patients_with_ascvd.measure_name\n , patients_with_ascvd.measure_version\n , 1 as denominator_flag\n from patients_with_ascvd\n left join patients_with_age\n on patients_with_ascvd.patient_id = patients_with_age.patient_id\n where age is not null\n\n)\n\n, qualifying_patients_from_criteria2 as (\n\n select\n distinct\n patients_with_cholesterol.patient_id\n , patients_with_age.age as age\n , patients_with_cholesterol.performance_period_begin\n , patients_with_cholesterol.performance_period_end\n , patients_with_cholesterol.measure_id\n , patients_with_cholesterol.measure_name\n , patients_with_cholesterol.measure_version\n , 1 as denominator_flag\n from patients_with_cholesterol\n left join patients_with_age\n on patients_with_cholesterol.patient_id = patients_with_age.patient_id\n where age between 20 and 75\n\n)\n\n, qualifying_patients_from_criteria3 as (\n\n select\n distinct\n patients_with_diabetes.patient_id\n , patients_with_age.age as age\n , patients_with_diabetes.performance_period_begin\n , patients_with_diabetes.performance_period_end\n , patients_with_diabetes.measure_id\n , patients_with_diabetes.measure_name\n , patients_with_diabetes.measure_version\n , 1 as denominator_flag\n from patients_with_diabetes\n left join patients_with_age\n on patients_with_diabetes.patient_id = patients_with_age.patient_id\n where age between 40 and 75\n\n)\n\n, final_denominator as (\n \n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria1\n\n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria2\n \n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria3\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from final_denominator\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438_denominator_criteria1", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_denominator_criteria2", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_denominator_criteria3", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), patients_with_ascvd as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as criteria\n from cms_synthetic.quality_measures._int_cqm438_denominator_criteria1\n\n)\n\n, patients_with_cholesterol as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 2 as criteria\n from cms_synthetic.quality_measures._int_cqm438_denominator_criteria2\n\n)\n\n, patients_with_diabetes as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 3 as criteria\n from cms_synthetic.quality_measures._int_cqm438_denominator_criteria3\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes \n where lower(concept_name) in (\n 'annual wellness visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'outpatient encounters for preventive care'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n performance_period_begin\n ) / 8760.0) as age\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n and p.death_date is null\n cross join cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n, qualifying_patients_from_criteria1 as (\n\n select\n distinct\n patients_with_ascvd.patient_id\n , patients_with_age.age as age\n , patients_with_ascvd.performance_period_begin\n , patients_with_ascvd.performance_period_end\n , patients_with_ascvd.measure_id\n , patients_with_ascvd.measure_name\n , patients_with_ascvd.measure_version\n , 1 as denominator_flag\n from patients_with_ascvd\n left join patients_with_age\n on patients_with_ascvd.patient_id = patients_with_age.patient_id\n where age is not null\n\n)\n\n, qualifying_patients_from_criteria2 as (\n\n select\n distinct\n patients_with_cholesterol.patient_id\n , patients_with_age.age as age\n , patients_with_cholesterol.performance_period_begin\n , patients_with_cholesterol.performance_period_end\n , patients_with_cholesterol.measure_id\n , patients_with_cholesterol.measure_name\n , patients_with_cholesterol.measure_version\n , 1 as denominator_flag\n from patients_with_cholesterol\n left join patients_with_age\n on patients_with_cholesterol.patient_id = patients_with_age.patient_id\n where age between 20 and 75\n\n)\n\n, qualifying_patients_from_criteria3 as (\n\n select\n distinct\n patients_with_diabetes.patient_id\n , patients_with_age.age as age\n , patients_with_diabetes.performance_period_begin\n , patients_with_diabetes.performance_period_end\n , patients_with_diabetes.measure_id\n , patients_with_diabetes.measure_name\n , patients_with_diabetes.measure_version\n , 1 as denominator_flag\n from patients_with_diabetes\n left join patients_with_age\n on patients_with_diabetes.patient_id = patients_with_age.patient_id\n where age between 40 and 75\n\n)\n\n, final_denominator as (\n \n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria1\n\n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria2\n \n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria3\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from final_denominator\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator_criteria1", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria1.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria1.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator_criteria1"], "alias": "_int_cqm438_denominator_criteria1", "checksum": {"name": "sha256", "checksum": "3fcaf317d01abdbf26b1691ac8cfdff71fc650b50a4738d3c560e4796304ca0c"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator_criteria1", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Subset of denominator logic for submission of criteria 1 of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator_criteria1", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.955712, "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator_criteria1", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith ascvd_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'atherosclerosis and peripheral arterial disease'\n , 'myocardial infarction'\n , 'pci'\n , 'stable and unstable angina'\n , 'cabg or pci procedure'\n , 'cabg surgeries'\n , 'cerebrovascular disease stroke or tia'\n , 'ischemic heart disease or related diagnoses'\n , 'carotid intervention'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition')}}\n\n)\n\n, ascvd_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join ascvd_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = ascvd_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = ascvd_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, ascvd_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join ascvd_codes\n on procedures.code = ascvd_codes.code\n and procedures.code_type = ascvd_codes.code_system\n\n)\n\n, historical_ascvd as (\n\n select\n ascvd_conditions.patient_id\n , ascvd_conditions.evidence_date\n from ascvd_conditions\n\n union all\n\n select\n ascvd_procedures.patient_id\n , ascvd_procedures.evidence_date\n from ascvd_procedures\n\n)\n\n, patients_with_ascvd as (\n\n select\n distinct\n historical_ascvd.patient_id\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from historical_ascvd\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from patients_with_ascvd\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__int_cqm438__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria1.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), ascvd_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'atherosclerosis and peripheral arterial disease'\n , 'myocardial infarction'\n , 'pci'\n , 'stable and unstable angina'\n , 'cabg or pci procedure'\n , 'cabg surgeries'\n , 'cerebrovascular disease stroke or tia'\n , 'ischemic heart disease or related diagnoses'\n , 'carotid intervention'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, ascvd_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join ascvd_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = ascvd_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = ascvd_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, ascvd_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join ascvd_codes\n on procedures.code = ascvd_codes.code\n and procedures.code_type = ascvd_codes.code_system\n\n)\n\n, historical_ascvd as (\n\n select\n ascvd_conditions.patient_id\n , ascvd_conditions.evidence_date\n from ascvd_conditions\n\n union all\n\n select\n ascvd_procedures.patient_id\n , ascvd_procedures.evidence_date\n from ascvd_procedures\n\n)\n\n, patients_with_ascvd as (\n\n select\n distinct\n historical_ascvd.patient_id\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from historical_ascvd\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_ascvd\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator_criteria2", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria2.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria2.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator_criteria2"], "alias": "_int_cqm438_denominator_criteria2", "checksum": {"name": "sha256", "checksum": "dae2a211d34234332d175b9006ab8248afd8f602c4281e8e7a5a9270fcc446b9"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator_criteria2", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Subset of denominator logic for submission of criteria 2 of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator_criteria2", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.957226, "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator_criteria2", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith cholesterol_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'ldl cholesterol'\n , 'familial hypercholesterolemia'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, cholesterol_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join cholesterol_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = cholesterol_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = cholesterol_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, cholesterol_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cholesterol_codes\n on procedures.code = cholesterol_codes.code\n and procedures.code_type = cholesterol_codes.code_system\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from {{ ref('quality_measures__stg_core__lab_result') }}\n\n)\n\n, cholesterol_tests_with_result as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date, result_date) as evidence_date\n , cholesterol_codes.concept_name\n , row_number() over(partition by labs.patient_id order by\n labs.result desc\n , result_date desc) as rn\n from labs\n inner join cholesterol_codes\n on coalesce(labs.normalized_code, labs.source_code) = cholesterol_codes.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = cholesterol_codes.code_system\n {% if target.type == 'fabric' %}\n WHERE result LIKE '%.%' OR result LIKE '%[0-9]%'\n AND result NOT LIKE '%[^0-9.]%'\n {% else %}\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\n {% endif %}\n\n)\n\n, cholesterol_labs as (\n\n select\n patient_id\n , evidence_date\n from cholesterol_tests_with_result\n where rn= 1\n and cast(evidence_value as {{ dbt.type_numeric() }}) >= 190\n\n)\n\n, all_patients_with_cholesterol as (\n\n select\n cholesterol_conditions.patient_id\n , cholesterol_conditions.evidence_date\n from cholesterol_conditions\n\n union all\n\n select\n cholesterol_procedures.patient_id\n , cholesterol_procedures.evidence_date\n from cholesterol_procedures\n\n union all\n\n select\n cholesterol_labs.patient_id\n , cholesterol_labs.evidence_date\n from cholesterol_labs\n\n)\n\n, patients_with_cholesterol as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from all_patients_with_cholesterol\n inner join {{ref('quality_measures__int_cqm438__performance_period')}} pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from patients_with_cholesterol\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.apply_regex", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__int_cqm438__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria2.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), cholesterol_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'ldl cholesterol'\n , 'familial hypercholesterolemia'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, cholesterol_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join cholesterol_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = cholesterol_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = cholesterol_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, cholesterol_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cholesterol_codes\n on procedures.code = cholesterol_codes.code\n and procedures.code_type = cholesterol_codes.code_system\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, cholesterol_tests_with_result as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date, result_date) as evidence_date\n , cholesterol_codes.concept_name\n , row_number() over(partition by labs.patient_id order by\n labs.result desc\n , result_date desc) as rn\n from labs\n inner join cholesterol_codes\n on coalesce(labs.normalized_code, labs.source_code) = cholesterol_codes.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = cholesterol_codes.code_system\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, cholesterol_labs as (\n\n select\n patient_id\n , evidence_date\n from cholesterol_tests_with_result\n where rn= 1\n and cast(evidence_value as numeric(28,6)) >= 190\n\n)\n\n, all_patients_with_cholesterol as (\n\n select\n cholesterol_conditions.patient_id\n , cholesterol_conditions.evidence_date\n from cholesterol_conditions\n\n union all\n\n select\n cholesterol_procedures.patient_id\n , cholesterol_procedures.evidence_date\n from cholesterol_procedures\n\n union all\n\n select\n cholesterol_labs.patient_id\n , cholesterol_labs.evidence_date\n from cholesterol_labs\n\n)\n\n, patients_with_cholesterol as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from all_patients_with_cholesterol\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_cholesterol\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator_criteria3", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria3.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria3.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator_criteria3"], "alias": "_int_cqm438_denominator_criteria3", "checksum": {"name": "sha256", "checksum": "ff18538f08cdbc29326cf1ff621feab51732a9b67604c28da4929d1149251ec0"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator_criteria3", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Subset of denominator logic for submission of criteria 3 of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator_criteria3", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9586, "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator_criteria3", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith diabetes_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, diabetes_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join diabetes_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetes_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetes_codes.code\n\n)\n\n, patients_with_diabetes as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version \n from diabetes_conditions\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from patients_with_diabetes\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__int_cqm438__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_denominator_criteria3.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), diabetes_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetes_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join diabetes_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetes_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetes_codes.code\n\n)\n\n, patients_with_diabetes as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version \n from diabetes_conditions\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_diabetes\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_numerator.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_numerator"], "alias": "_int_cqm438_numerator", "checksum": {"name": "sha256", "checksum": "5620ce32cdd3343702b030451d071602d4becfff23e68ed11baf8834c461c77b"}, "config": {"enabled": true, "alias": "_int_cqm438_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9655612, "relation_name": "cms_synthetic.quality_measures._int_cqm438_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_cqm438_denominator') }}\n\n)\n\n, statin_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'high intensity statin therapy'\n , 'low intensity statin therapy'\n , 'moderate intensity statin therapy'\n , 'statin therapy'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, procedure_statin_related as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join statin_codes\n on procedures.code = statin_codes.code\n and procedures.code_type = statin_codes.code_system\n\n)\n\n, pharmacy_claims_statin_related as (\n\n select\n patient_id\n , dispensing_date as evidence_date\n , ndc_code\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claims\n inner join statin_codes\n on pharmacy_claims.ndc_code = statin_codes.code\n and lower(statin_codes.code_system) = 'ndc'\n\n)\n\n, medication_statin_related as (\n\n select\n patient_id\n , coalesce(dispensing_date, prescribing_date) as evidence_date\n , source_code\n , source_code_type\n from {{ ref('quality_measures__stg_core__medication') }} as medications\n inner join statin_codes\n on medications.source_code = statin_codes.code\n and medications.source_code_type = statin_codes.code_system\n \n)\n\n, qualifying_patients as (\n\n select\n procedure_statin_related.patient_id\n , procedure_statin_related.evidence_date\n from procedure_statin_related\n\n union all\n\n select\n pharmacy_claims_statin_related.patient_id\n , pharmacy_claims_statin_related.evidence_date\n from pharmacy_claims_statin_related\n\n union all\n\n select\n medication_statin_related.patient_id\n , medication_statin_related.evidence_date\n from medication_statin_related\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n and evidence_date between \n denominator.performance_period_begin and \n denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cqm438_denominator\n\n)\n\n, statin_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'high intensity statin therapy'\n , 'low intensity statin therapy'\n , 'moderate intensity statin therapy'\n , 'statin therapy'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, procedure_statin_related as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join statin_codes\n on procedures.code = statin_codes.code\n and procedures.code_type = statin_codes.code_system\n\n)\n\n, pharmacy_claims_statin_related as (\n\n select\n patient_id\n , dispensing_date as evidence_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join statin_codes\n on pharmacy_claims.ndc_code = statin_codes.code\n and lower(statin_codes.code_system) = 'ndc'\n\n)\n\n, medication_statin_related as (\n\n select\n patient_id\n , coalesce(dispensing_date, prescribing_date) as evidence_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication as medications\n inner join statin_codes\n on medications.source_code = statin_codes.code\n and medications.source_code_type = statin_codes.code_system\n \n)\n\n, qualifying_patients as (\n\n select\n procedure_statin_related.patient_id\n , procedure_statin_related.evidence_date\n from procedure_statin_related\n\n union all\n\n select\n pharmacy_claims_statin_related.patient_id\n , pharmacy_claims_statin_related.evidence_date\n from pharmacy_claims_statin_related\n\n union all\n\n select\n medication_statin_related.patient_id\n , medication_statin_related.evidence_date\n from medication_statin_related\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n and evidence_date between \n denominator.performance_period_begin and \n denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm438_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_long.sql", "original_file_path": "models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_long"], "alias": "_int_cqm438_long", "checksum": {"name": "sha256", "checksum": "8fb5ac9ec15285f8ad924e0e7ccc587f97de6dd7a30a2d59dad706bb99abc0a0"}, "config": {"enabled": true, "alias": "_int_cqm438_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9638982, "relation_name": "cms_synthetic.quality_measures._int_cqm438_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_cqm438_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_cqm438_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_cqm438_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm438_statin_therapy_for_patients_with_cardiovascular_disease/quality_measures__int_cqm438_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm438_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cqm438_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm438_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm48_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_denominator.sql", "original_file_path": "models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_denominator"], "alias": "_int_cqm48_denominator", "checksum": {"name": "sha256", "checksum": "d3b7569ea5dbc02ff376f33e62e6eff0f65e0da02f7e494515fa7e16c7e1829f"}, "config": {"enabled": true, "alias": "_int_cqm48_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Urinary Incontinence.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_date": {"name": "encounter_date", "description": "Patient's date of encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.984812, "relation_name": "cms_synthetic.quality_measures._int_cqm48_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'occupational therapy evaluation'\n , 'office visit'\n , 'outpatient'\n , 'physical therapy evaluation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_cqm48__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join {{ ref('quality_measures__int_cqm48__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join {{ ref('quality_measures__int_cqm48__performance_period') }} as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as age\n , max_date\n , qualifying_types\n from {{ ref('quality_measures__stg_core__patient') }} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.sex = 'female'\n and p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age\n , patients_with_age.max_date as encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join {{ ref('quality_measures__int_cqm48__performance_period') }} pp\n where age >= 65\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'occupational therapy evaluation'\n , 'office visit'\n , 'outpatient'\n , 'physical therapy evaluation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm48__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join cms_synthetic.quality_measures._int_cqm48__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join cms_synthetic.quality_measures._int_cqm48__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.sex = 'female'\n and p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age\n , patients_with_age.max_date as encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_cqm48__performance_period pp\n where age >= 65\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm48__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48__performance_period"], "alias": "_int_cqm48__performance_period", "checksum": {"name": "sha256", "checksum": "2d69be4ba1c56e08e53884ef77999a893baf963c3a1c4401a772443f5b44ee09"}, "config": {"enabled": true, "alias": "_int_cqm48__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Urinary Incontinence.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.983228, "relation_name": "cms_synthetic.quality_measures._int_cqm48__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM48')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM48')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM48')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm48_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_long.sql", "original_file_path": "models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_long"], "alias": "_int_cqm48_long", "checksum": {"name": "sha256", "checksum": "94a3764e558940c8933480f964867c02cc41127c692ed3d7a94925f341fc6302"}, "config": {"enabled": true, "alias": "_int_cqm48_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 48, Urinary Incontinence before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.987906, "relation_name": "cms_synthetic.quality_measures._int_cqm48_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_cqm48_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_cqm48_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_cqm48_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm48_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_cqm48_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm48_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cqm48_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm48_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm48_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_numerator.sql", "original_file_path": "models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_numerator"], "alias": "_int_cqm48_numerator", "checksum": {"name": "sha256", "checksum": "b5aef3bb72eeac7c1f05466b2b25b1921c14c08b72d813803f8263976160a25f"}, "config": {"enabled": true, "alias": "_int_cqm48_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 48, Urinary Incontinence.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.98943, "relation_name": "cms_synthetic.quality_measures._int_cqm48_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_cqm48_denominator') }}\n\n)\n\n, involuntary_urination_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'presence or absence of urinary incontinence assessed'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join involuntary_urination_codes\n on procedures.code = involuntary_urination_codes.code\n and procedures.code_type = involuntary_urination_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join involuntary_urination_codes\n on medical_claim.hcpcs_code = involuntary_urination_codes.code\n and lower(involuntary_urination_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n {{ dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"denominator.encounter_date\"\n )\n }}\n and \n denominator.encounter_date -- within last 12 months of visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm48_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cqm48_denominator\n\n)\n\n, involuntary_urination_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'presence or absence of urinary incontinence assessed'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join involuntary_urination_codes\n on procedures.code = involuntary_urination_codes.code\n and procedures.code_type = involuntary_urination_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join involuntary_urination_codes\n on medical_claim.hcpcs_code = involuntary_urination_codes.code\n and lower(involuntary_urination_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm48_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_exclusions"], "alias": "_int_cqm48_exclusions", "checksum": {"name": "sha256", "checksum": "5d6056573d3c291f632fec2d1d3aa1edbdbfc57a140662bf80893f753c4ebe3e"}, "config": {"enabled": true, "alias": "_int_cqm48_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 48, Urinary Incontinence.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.986318, "relation_name": "cms_synthetic.quality_measures._int_cqm48_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_cqm48__performance_period') }}\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_cqm48__performance_period') }}\n)\n{%- endset -%}\n\nwith valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select\n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n from valid_hospice_exclusions\n inner join {{ ref('quality_measures__int_cqm48_denominator') }} as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_cqm48_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm48_urinary_incontinence/quality_measures__int_cqm48_exclusions.sql", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm48__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm48__performance_period\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select\n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n from valid_hospice_exclusions\n inner join cms_synthetic.quality_measures._int_cqm48_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_numerator"], "alias": "_int_nqf0420_numerator", "checksum": {"name": "sha256", "checksum": "aa236d50b9c7ab439524e500960718297d8d548bee7614976c5a6010c8418af6"}, "config": {"enabled": true, "alias": "_int_nqf0420_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0420, Pain Assessment and Follow-Up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.005175, "relation_name": "cms_synthetic.quality_measures._int_nqf0420_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_nqf0420_denominator') }}\n\n)\n\n, pain_assessment_code as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'pain assessment documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, pain_assessment_procedures as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join pain_assessment_code\n on procedures.code = pain_assessment_code.code\n and procedures.code_type = pain_assessment_code.code_system\n\n)\n\n, pain_assessment_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join pain_assessment_code\n on medical_claim.hcpcs_code = pain_assessment_code.code\n and lower(pain_assessment_code.code_system) = 'hcpcs'\n\n)\n\n, time_unbounded_qualifying_patients as (\n\n select\n patient_id\n , evidence_date\n from pain_assessment_procedures\n \n union all\n\n select\n patient_id\n , evidence_date\n from pain_assessment_claims\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n time_unbounded_qualifying_patients.patient_id\n , time_unbounded_qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from time_unbounded_qualifying_patients\n inner join denominator\n on time_unbounded_qualifying_patients.patient_id = denominator.patient_id\n and time_unbounded_qualifying_patients.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0420_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0420_denominator\n\n)\n\n, pain_assessment_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pain assessment documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pain_assessment_procedures as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join pain_assessment_code\n on procedures.code = pain_assessment_code.code\n and procedures.code_type = pain_assessment_code.code_system\n\n)\n\n, pain_assessment_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join pain_assessment_code\n on medical_claim.hcpcs_code = pain_assessment_code.code\n and lower(pain_assessment_code.code_system) = 'hcpcs'\n\n)\n\n, time_unbounded_qualifying_patients as (\n\n select\n patient_id\n , evidence_date\n from pain_assessment_procedures\n \n union all\n\n select\n patient_id\n , evidence_date\n from pain_assessment_claims\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n time_unbounded_qualifying_patients.patient_id\n , time_unbounded_qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from time_unbounded_qualifying_patients\n inner join denominator\n on time_unbounded_qualifying_patients.patient_id = denominator.patient_id\n and time_unbounded_qualifying_patients.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0420__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420__performance_period"], "alias": "_int_nqf0420__performance_period", "checksum": {"name": "sha256", "checksum": "d0cdd525971ce03f0d981bd5d2d0128585450efb3e135f7495a91933e09f10dc"}, "config": {"enabled": true, "alias": "_int_nqf0420__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Pain Assessment and Follow-Up.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.99925, "relation_name": "cms_synthetic.quality_measures._int_nqf0420__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0420')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0420')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0420')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_long"], "alias": "_int_nqf0420_long", "checksum": {"name": "sha256", "checksum": "db82a64c59c71501dcd32be67e39b01733b56f2a830d5410c10ba9afa0cbea7f"}, "config": {"enabled": true, "alias": "_int_nqf0420_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0420, Pain Assessment and Follow-Up before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.003695, "relation_name": "cms_synthetic.quality_measures._int_nqf0420_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_nqf0420_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_nqf0420_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf0420_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0420_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0420_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0420_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0420_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_exclusions"], "alias": "_int_nqf0420_exclusions", "checksum": {"name": "sha256", "checksum": "629d0edf61feeeb87d7a18130d074ee03c8d3c880cb0505cefbe4e04ce36e20d"}, "config": {"enabled": true, "alias": "_int_nqf0420_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0420, Pain Assessment and Follow-Up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.00208, "relation_name": "cms_synthetic.quality_measures._int_nqf0420_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_nqf0420__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_nqf0420__performance_period') }}\n\n)\n{%- endset -%}\n\nwith denominator as (\n \n select\n patient_id\n from {{ ref('quality_measures__int_nqf0420_denominator') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'patient is not eligible for a pain assessment'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as(\n \n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0420_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'patient is not eligible for a pain assessment'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as(\n \n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_denominator"], "alias": "_int_nqf0420_denominator", "checksum": {"name": "sha256", "checksum": "ce970244d33be829606326256c672d7f67c7cf31eaacbd3fa9aa63393c3cab6b"}, "config": {"enabled": true, "alias": "_int_nqf0420_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0420, Pain Assessment and Follow-Up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during latest encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0006552, "relation_name": "cms_synthetic.quality_measures._int_nqf0420_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'home healthcare services'\n , 'office visit'\n , 'encounter to document medications'\n , 'psychological and/or neuropsychological test administration'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date, encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date, encounter.encounter_start_date) as max_date\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_nqf0420__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date, encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date, encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n where coalesce(modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_5, '') not in ('GQ', 'GT', '95')\n\n)\n\n, claims as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n where coalesce(hcpcs_modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_5, '') not in ('GQ', 'GT', '95')\n and coalesce(place_of_service_code, '') not in ('02')\n \n)\n\n, procedure_encounters as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as min_date\n , procedures.procedure_date as max_date\n from procedures\n inner join {{ ref('quality_measures__int_nqf0420__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n claims.patient_id\n , claims.min_date\n , claims.max_date\n from claims\n inner join {{ ref('quality_measures__int_nqf0420__performance_period') }} as pp \n on claims.max_date >= pp.performance_period_begin\n and claims.min_date <= pp.performance_period_end\n inner join visit_codes\n on claims.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select \n patient_id\n , max(max_date) max_date\n , {{ dbt.concat([\n \"coalesce(min(visit_enc), '')\"\n , \"coalesce(min(proc_enc), '')\"\n , \"coalesce(min(claim_enc), '')\"\n ]) }} as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\n , qualifying_types\n from {{ ref('quality_measures__stg_core__patient') }} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patient_id\n , max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join {{ ref('quality_measures__int_nqf0420__performance_period') }} pp\n where max_age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0420_pain_assessment_and_follow_up/quality_measures__int_nqf0420_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'home healthcare services'\n , 'office visit'\n , 'encounter to document medications'\n , 'psychological and/or neuropsychological test administration'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date, encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date, encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0420__performance_period as pp\n on coalesce(encounter.encounter_end_date, encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date, encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where coalesce(modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_5, '') not in ('GQ', 'GT', '95')\n\n)\n\n, claims as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(hcpcs_modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_5, '') not in ('GQ', 'GT', '95')\n and coalesce(place_of_service_code, '') not in ('02')\n \n)\n\n, procedure_encounters as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as min_date\n , procedures.procedure_date as max_date\n from procedures\n inner join cms_synthetic.quality_measures._int_nqf0420__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n claims.patient_id\n , claims.min_date\n , claims.max_date\n from claims\n inner join cms_synthetic.quality_measures._int_nqf0420__performance_period as pp \n on claims.max_date >= pp.performance_period_begin\n and claims.min_date <= pp.performance_period_end\n inner join visit_codes\n on claims.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select \n patient_id\n , max(max_date) max_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patient_id\n , max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_nqf0420__performance_period pp\n where max_age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_institutional_snp", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_institutional_snp.sql", "original_file_path": "models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_institutional_snp.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_institutional_snp"], "alias": "_int_shared_exclusions_institutional_snp", "checksum": {"name": "sha256", "checksum": "87a38049784d77c3f610d7b124e2f250c3833265c8f26f3366adcd79a91ab16d"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_institutional_snp", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients staying in an institution for the reporting for entire patient population. \n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_institutional_snp", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.888061, "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false)))) | as_bool\n )\n}}\n\n/*\n patients in institutional special needs plans (snp)\n or residing in long term care\n\n while referencing this model, patients greater or equal than 66 years of age should be taken\n\n filtering out age from this model has been stripped out as different measures calculate age varingly\n\n future enhancement: group claims into encounters\n*/\n\nwith patients as (\n\n select\n patient_id\n from {{ ref('quality_measures__stg_core__patient') }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, exclusions as (\n\n select\n patients.patient_id\n , coalesce(\n medical_claim.claim_start_date\n , medical_claim.claim_end_date\n ) as exclusion_date\n , 'institutional or long term care' as exclusion_reason\n from patients\n inner join medical_claim\n on patients.patient_id = medical_claim.patient_id\n where place_of_service_code in ('32', '33', '34', '54', '56')\n and {{ datediff('medical_claim.claim_start_date', 'medical_claim.claim_end_date', 'day') }} >= 90\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'institutional_snp' as exclusion_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom exclusions", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_institutional_snp.sql", "compiled": true, "compiled_code": "\n\n/*\n patients in institutional special needs plans (snp)\n or residing in long term care\n\n while referencing this model, patients greater or equal than 66 years of age should be taken\n\n filtering out age from this model has been stripped out as different measures calculate age varingly\n\n future enhancement: group claims into encounters\n*/\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, exclusions as (\n\n select\n patients.patient_id\n , coalesce(\n medical_claim.claim_start_date\n , medical_claim.claim_end_date\n ) as exclusion_date\n , 'institutional or long term care' as exclusion_reason\n from patients\n inner join medical_claim\n on patients.patient_id = medical_claim.patient_id\n where place_of_service_code in ('32', '33', '34', '54', '56')\n and datediff(\n day,\n medical_claim.claim_start_date,\n medical_claim.claim_end_date\n ) >= 90\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'institutional_snp' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_frailty", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_frailty.sql", "original_file_path": "models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_frailty.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_frailty"], "alias": "_int_shared_exclusions_frailty", "checksum": {"name": "sha256", "checksum": "4d5663512a26964a98ab2dfcc408b1e4be9e1dc47e4867dcbad999667d1a51ee"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_frailty", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty used by other exclusion models.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_frailty", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.882316, "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_frailty", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith patients as (\n\n select\n patient_id\n from {{ ref('quality_measures__stg_core__patient') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'frailty device'\n , 'frailty diagnosis'\n , 'frailty encounter'\n , 'frailty symptom'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_frailty as (\n\n select\n patients.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from patients\n inner join condition_exclusions\n on patients.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , med_claim_exclusions.concept_name as exclusion_reason\n from patients\n inner join med_claim_exclusions\n on patients.patient_id = med_claim_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from patients\n inner join observation_exclusions\n on patients.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from patients\n inner join procedure_exclusions\n on patients.patient_id = procedure_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom patients_with_frailty", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_frailty.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'frailty device'\n , 'frailty diagnosis'\n , 'frailty encounter'\n , 'frailty symptom'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_frailty as (\n\n select\n patients.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from patients\n inner join condition_exclusions\n on patients.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , med_claim_exclusions.concept_name as exclusion_reason\n from patients\n inner join med_claim_exclusions\n on patients.patient_id = med_claim_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from patients\n inner join observation_exclusions\n on patients.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from patients\n inner join procedure_exclusions\n on patients.patient_id = procedure_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom patients_with_frailty", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_advanced_illness", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_advanced_illness.sql", "original_file_path": "models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_advanced_illness.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_advanced_illness"], "alias": "_int_shared_exclusions_advanced_illness", "checksum": {"name": "sha256", "checksum": "c82b8b1084d3192f4172145b3d7a34057f7dc4ed31fa77aec7779eb4a1e51ddb"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_advanced_illness", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty and advanced illness for entire patient population.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_advanced_illness", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8838432, "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false)))) | as_bool\n )\n}}\n\nwith patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'advanced illness'\n , 'acute inpatient'\n , 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n where lower(exclusion_codes.concept_name) = 'advanced illness'\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, acute_inpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , {{ dbt.concat([\n \"patients_with_frailty.exclusion_reason\",\n \"' with '\",\n \"med_claim_exclusions.concept_name\",\n \"' and '\",\n \"condition_exclusions.concept_name\"\n ]) }} as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) = 'acute inpatient'\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , {{ dbt.concat([\n \"patients_with_frailty.exclusion_reason\",\n \"' with '\",\n \"procedure_exclusions.concept_name\",\n \"' and '\",\n \"condition_exclusions.concept_name\"\n ]) }} as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) = 'acute inpatient'\n\n)\n\n, nonacute_outpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , {{ dbt.concat([\n \"patients_with_frailty.exclusion_reason\",\n \"' with '\",\n \"med_claim_exclusions.concept_name\",\n \"' and '\",\n \"condition_exclusions.concept_name\"\n ]) }} as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , {{ dbt.concat([\n \"patients_with_frailty.exclusion_reason\",\n \"' with '\",\n \"procedure_exclusions.concept_name\",\n \"' and '\",\n \"condition_exclusions.concept_name\"\n ]) }} as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, exclusions_unioned as (\n\n select\n acute_inpatient.patient_id\n , acute_inpatient.exclusion_date\n , acute_inpatient.exclusion_reason\n , acute_inpatient.claim_start_date\n , acute_inpatient.claim_end_date\n , acute_inpatient.procedure_date\n , 'acute_inpatient' as patient_type\n from acute_inpatient\n\n union all\n\n select\n nonacute_outpatient.patient_id\n , nonacute_outpatient.exclusion_date\n , nonacute_outpatient.exclusion_reason\n , nonacute_outpatient.claim_start_date\n , nonacute_outpatient.claim_end_date\n , nonacute_outpatient.procedure_date\n , 'nonacute_outpatient' as patient_type\n from nonacute_outpatient\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'advanced_illness' as exclusion_type\n , claim_start_date\n , claim_end_date\n , procedure_date\n , patient_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom exclusions_unioned", "language": "sql", "refs": [{"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_advanced_illness.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'advanced illness'\n , 'acute inpatient'\n , 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n where lower(exclusion_codes.concept_name) = 'advanced illness'\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, acute_inpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) = 'acute inpatient'\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) = 'acute inpatient'\n\n)\n\n, nonacute_outpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, exclusions_unioned as (\n\n select\n acute_inpatient.patient_id\n , acute_inpatient.exclusion_date\n , acute_inpatient.exclusion_reason\n , acute_inpatient.claim_start_date\n , acute_inpatient.claim_end_date\n , acute_inpatient.procedure_date\n , 'acute_inpatient' as patient_type\n from acute_inpatient\n\n union all\n\n select\n nonacute_outpatient.patient_id\n , nonacute_outpatient.exclusion_date\n , nonacute_outpatient.exclusion_reason\n , nonacute_outpatient.claim_start_date\n , nonacute_outpatient.claim_end_date\n , nonacute_outpatient.procedure_date\n , 'nonacute_outpatient' as patient_type\n from nonacute_outpatient\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'advanced_illness' as exclusion_type\n , claim_start_date\n , claim_end_date\n , procedure_date\n , patient_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions_unioned", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_hospice_palliative", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_hospice_palliative.sql", "original_file_path": "models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_hospice_palliative.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_hospice_palliative"], "alias": "_int_shared_exclusions_hospice_palliative", "checksum": {"name": "sha256", "checksum": "b92877ac516ae2a0e22a9e22a650799bae771f81a57e26508b4ec10ed259fc8a"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_hospice_palliative", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients using hospice or palliative services for the reporting for entire patient population.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_hospice_palliative", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.8865101, "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatient was provided hospice services any time during the measurement period: G9687\n*/\n\n\nwith exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n From {{ref('quality_measures__value_sets')}}\n where lower(concept_name) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n , 'palliative care encounter'\n , 'palliative care diagnosis'\n , 'palliative care intervention'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }} \n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n \n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'hospice_palliative' as exclusion_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom patients_with_exclusions", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_hospice_palliative.sql", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatient was provided hospice services any time during the measurement period: G9687\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n From cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n , 'palliative care encounter'\n , 'palliative care diagnosis'\n , 'palliative care intervention'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition \n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n \n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'hospice_palliative' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom patients_with_exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_dementia", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_dementia.sql", "original_file_path": "models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_dementia.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_dementia"], "alias": "_int_shared_exclusions_dementia", "checksum": {"name": "sha256", "checksum": "f02237e35f924621d60277dd24f050e82b5422dac65644eff5229f86e6d02ce0"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_dementia", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty and taking dementia medications for entire patient population.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_dementia", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.885159, "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_dementia", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false))))\n | as_bool\n )\n}}\n\nwith patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'dementia medications'\n )\n\n)\n\n, medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n from {{ ref('quality_measures__stg_core__medication') }}\n\n)\n\n, pharmacy_claim as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n from {{ ref('quality_measures__stg_pharmacy_claim') }}\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.rxnorm_code = exclusion_codes.code\n where exclusion_codes.code_system = 'rxnorm'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claim_exclusions as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date\n , pharmacy_claim.ndc_code\n , pharmacy_claim.paid_date\n , exclusion_codes.concept_name\n from pharmacy_claim\n inner join exclusion_codes\n on pharmacy_claim.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n)\n\n, frailty_with_dementia as (\n\n select\n patients_with_frailty.patient_id\n , patients_with_frailty.exclusion_date\n , {{ dbt.concat([\n \"patients_with_frailty.exclusion_reason\",\n \"' with '\",\n \"pharmacy_claim_exclusions.concept_name\"\n ]) }} as exclusion_reason\n , pharmacy_claim_exclusions.dispensing_date\n , pharmacy_claim_exclusions.paid_date\n from patients_with_frailty\n inner join pharmacy_claim_exclusions\n on patients_with_frailty.patient_id = pharmacy_claim_exclusions.patient_id\n\n union all\n\n select\n patients_with_frailty.patient_id\n , medication_exclusions.dispensing_date as exclusion_date\n , {{ dbt.concat([\n \"patients_with_frailty.exclusion_reason\",\n \"' with '\",\n \"medication_exclusions.concept_name\"\n ]) }} as exclusion_reason\n , medication_exclusions.dispensing_date\n , null as paid_date\n from patients_with_frailty\n inner join medication_exclusions\n on patients_with_frailty.patient_id = medication_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'dementia' as exclusion_type\n , dispensing_date\n , paid_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom frailty_with_dementia", "language": "sql", "refs": [{"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/shared_exclusions/quality_measures__int_shared_exclusions_dementia.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dementia medications'\n )\n\n)\n\n, medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claim as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.rxnorm_code = exclusion_codes.code\n where exclusion_codes.code_system = 'rxnorm'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claim_exclusions as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date\n , pharmacy_claim.ndc_code\n , pharmacy_claim.paid_date\n , exclusion_codes.concept_name\n from pharmacy_claim\n inner join exclusion_codes\n on pharmacy_claim.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n)\n\n, frailty_with_dementia as (\n\n select\n patients_with_frailty.patient_id\n , patients_with_frailty.exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || pharmacy_claim_exclusions.concept_name as exclusion_reason\n , pharmacy_claim_exclusions.dispensing_date\n , pharmacy_claim_exclusions.paid_date\n from patients_with_frailty\n inner join pharmacy_claim_exclusions\n on patients_with_frailty.patient_id = pharmacy_claim_exclusions.patient_id\n\n union all\n\n select\n patients_with_frailty.patient_id\n , medication_exclusions.dispensing_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || medication_exclusions.concept_name as exclusion_reason\n , medication_exclusions.dispensing_date\n , null as paid_date\n from patients_with_frailty\n inner join medication_exclusions\n on patients_with_frailty.patient_id = medication_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'dementia' as exclusion_type\n , dispensing_date\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom frailty_with_dementia", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_denominator"], "alias": "_int_nqf0034_denominator", "checksum": {"name": "sha256", "checksum": "93b65b4ad4f71f86403e46fbf2bc31031dc4d51f5adc231e6283a6a8b6364da7"}, "config": {"enabled": true, "alias": "_int_nqf0034_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0034, Colorectal Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "min_age": {"name": "min_age", "description": "Patient's minumum age during encounter as of the performance_period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "max_age": {"name": "max_age", "description": "Patient's maximum age during encounter as of the performance_period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "qualifying_types": {"name": "qualifying_types", "description": "Indicative letter of patient's type of encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.899979, "relation_name": "cms_synthetic.quality_measures._int_nqf0034_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/*\nDENOMINATOR:\nPatients 45-75 years of age with a visit during the measurement period\nDENOMINATOR NOTE: To assess the age for exclusions, the patient\u2019s age on the date of the encounter\nshould be used\n*Signifies that this CPT Category I code is a non-covered service under the Medicare Part B Physician Fee\nSchedule (PFS). These non-covered services should be counted in the denominator population for MIPS\nCQMs.\nDenominator Criteria (Eligible Cases):\nPatients 45 to 75 years of age on date of encounter\nAND\nPatient encounter during the performance period (CPT or HCPCS): 99202, 99203, 99204, 99205,\n99212, 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350, 99386*, 99387*,\n99396*, 99397*, G0438, G0439\n*/\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'online assessments'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_nqf0034__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where encounter_type in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ ref('quality_measures__stg_core__procedure') }} procs\n inner join {{ ref('quality_measures__int_nqf0034__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\n inner join {{ref('quality_measures__int_nqf0034__performance_period')}} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8766.0) as min_age\n , max_date\n ,floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8766.0) as max_age\n , qualifying_types\n from {{ref('quality_measures__stg_core__patient')}} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null -- ensures deceased patients are not included\n\n)\n\nselect \n patient_id\n , min_age\n , max_age\n , qualifying_types\nfrom patients_with_age\nwhere max_age >= 45 and min_age <= 75", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_denominator.sql", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR:\nPatients 45-75 years of age with a visit during the measurement period\nDENOMINATOR NOTE: To assess the age for exclusions, the patient\u2019s age on the date of the encounter\nshould be used\n*Signifies that this CPT Category I code is a non-covered service under the Medicare Part B Physician Fee\nSchedule (PFS). These non-covered services should be counted in the denominator population for MIPS\nCQMs.\nDenominator Criteria (Eligible Cases):\nPatients 45 to 75 years of age on date of encounter\nAND\nPatient encounter during the performance period (CPT or HCPCS): 99202, 99203, 99204, 99205,\n99212, 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350, 99386*, 99387*,\n99396*, 99397*, G0438, G0439\n*/\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'online assessments'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where encounter_type in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8766.0) as min_age\n , max_date\n ,floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8766.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null -- ensures deceased patients are not included\n\n)\n\nselect \n patient_id\n , min_age\n , max_age\n , qualifying_types\nfrom patients_with_age\nwhere max_age >= 45 and min_age <= 75", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_long"], "alias": "_int_nqf0034_long", "checksum": {"name": "sha256", "checksum": "1f39c86eb569e5993f0a514650d385006e59c8d2aa775f44b3d184faa29358d9"}, "config": {"enabled": true, "alias": "_int_nqf0034_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0034, Colorectal Cancer Screening before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.90506, "relation_name": "cms_synthetic.quality_measures._int_nqf0034_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n\n{%- set measure_id -%}\n(\n select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0034'\n )\n{%- endset -%}\n\n{%- set measure_name -%}\n(\n\n select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0034'\n\n )\n{%- endset -%}\n\n{%- set measure_version -%}\n(\n select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'NQF0034'\n\n )\n{%- endset -%}\n\n\n\nwith denominator as (\n\n select\n patient_id\n from {{ ref('quality_measures__int_nqf0034_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n from {{ ref('quality_measures__int_nqf0034_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf0034_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , pp.performance_period_begin\n , pp.performance_period_end\n , {{ measure_id }} as measure_id\n , {{ measure_name }} as measure_name\n , {{ measure_version }} as measure_version\n from denominator\n inner join {{ref('quality_measures__int_nqf0034__performance_period')}} pp\n on 1 = 1\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_exclusions", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_long.sql", "compiled": true, "compiled_code": "with denominator as (\n\n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0034_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n from cms_synthetic.quality_measures._int_nqf0034_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0034_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , pp.performance_period_begin\n , pp.performance_period_end\n , (\n select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n ) as measure_id\n , (\n\n select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_name\n , (\n select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_version\n from denominator\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0034__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034__performance_period"], "alias": "_int_nqf0034__performance_period", "checksum": {"name": "sha256", "checksum": "157c89574ceacbd20670c31125de54434d76354b5b71456b6e0d1ad96a344008"}, "config": {"enabled": true, "alias": "_int_nqf0034__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for NQF 0034 Colorectal Cancer screening.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.90801, "relation_name": "cms_synthetic.quality_measures._int_nqf0034__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback periods for each type of test\n\n during the measurement period:\n - Fecal occult blood test (FOBT) during the measurement period\n\n during the measurement period or the two years prior:\n - Fecal immunochemical DNA test (FIT-DNA)\n\n during the measurement period or the four years prior:\n - Flexible sigmoidoscopy\n - Computed tomography (CT) colonography\n\n during the measurement period or the nine years prior:\n - Colonoscopy\n\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , {{ dbt.dateadd(\n datepart = \"year\"\n , interval = -2\n , from_date_or_timestamp = \"performance_period_end\"\n ) }} as performance_period_begin_1yp\n , {{ dbt.dateadd(\n datepart = \"year\"\n , interval = -3\n , from_date_or_timestamp = \"performance_period_end\"\n ) }} as performance_period_begin_2yp\n , {{ dbt.dateadd(\n datepart = \"year\"\n , interval = -5\n , from_date_or_timestamp = \"performance_period_end\"\n ) }} as performance_period_begin_4yp\n , {{ dbt.dateadd(\n datepart = \"year\"\n , interval = -10\n , from_date_or_timestamp = \"performance_period_end\"\n ) }} as performance_period_begin_9yp\n from period_begin\n\n)\n\nselect\n cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin_1yp as date) as performance_period_begin_1yp\n , cast(performance_period_begin_2yp as date) as performance_period_begin_2yp\n , cast(performance_period_begin_4yp as date) as performance_period_begin_4yp\n , cast(performance_period_begin_9yp as date) as performance_period_begin_9yp\nfrom period_lookback", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd"], "nodes": []}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034__performance_period.sql", "compiled": true, "compiled_code": "\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback periods for each type of test\n\n during the measurement period:\n - Fecal occult blood test (FOBT) during the measurement period\n\n during the measurement period or the two years prior:\n - Fecal immunochemical DNA test (FIT-DNA)\n\n during the measurement period or the four years prior:\n - Flexible sigmoidoscopy\n - Computed tomography (CT) colonography\n\n during the measurement period or the nine years prior:\n - Colonoscopy\n\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n year,\n -2,\n performance_period_end\n )\n\n as performance_period_begin_1yp\n , \n\n dateadd(\n year,\n -3,\n performance_period_end\n )\n\n as performance_period_begin_2yp\n , \n\n dateadd(\n year,\n -5,\n performance_period_end\n )\n\n as performance_period_begin_4yp\n , \n\n dateadd(\n year,\n -10,\n performance_period_end\n )\n\n as performance_period_begin_9yp\n from period_begin\n\n)\n\nselect\n cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin_1yp as date) as performance_period_begin_1yp\n , cast(performance_period_begin_2yp as date) as performance_period_begin_2yp\n , cast(performance_period_begin_4yp as date) as performance_period_begin_4yp\n , cast(performance_period_begin_9yp as date) as performance_period_begin_9yp\nfrom period_lookback", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_exclusions"], "alias": "_int_nqf0034_exclusions", "checksum": {"name": "sha256", "checksum": "0d5005a10d81fc5e66db1626974fd13812171bf8ef209f312b56cda208440680"}, "config": {"enabled": true, "alias": "_int_nqf0034_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0034, Colorectal Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9033952, "relation_name": "cms_synthetic.quality_measures._int_nqf0034_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_nqf0034__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_nqf0034__performance_period') }}\n\n)\n{%- endset -%}\n\nwith frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, denominator as (\n\n select\n patient_id\n , max_age as age\n from {{ref('quality_measures__int_nqf0034_denominator')}}\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\n and {{ performance_period_end }}\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n or source.paid_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n and lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, measure_specific_colectomy_colorectal_cancer_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_nqf0034_exclude_colectomy_cancer')}}\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from measure_specific_colectomy_colorectal_cancer_exclusion\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type not in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n and age >= 66\n\n union all\n\n select * from combined_exclusions --age irrelvant exclusions\n where exclusion_type in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_denominator", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_exclude_colectomy_cancer", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , max_age as age\n from cms_synthetic.quality_measures._int_nqf0034_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n and lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, measure_specific_colectomy_colorectal_cancer_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_nqf0034_exclude_colectomy_cancer\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from measure_specific_colectomy_colorectal_cancer_exclusion\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type not in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n and age >= 66\n\n union all\n\n select * from combined_exclusions --age irrelvant exclusions\n where exclusion_type in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_exclude_colectomy_cancer", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_exclude_colectomy_cancer.sql", "original_file_path": "models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_exclude_colectomy_cancer.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_exclude_colectomy_cancer"], "alias": "_int_nqf0034_exclude_colectomy_cancer", "checksum": {"name": "sha256", "checksum": "8a1039572f4d38014a88b199d32e5ccd324f1d154697124eeea093e1a1648984"}, "config": {"enabled": true, "alias": "_int_nqf0034_exclude_colectomy_cancer", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty and advanced illness for the reporting version of NQF 0034, Colorectal Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_type": {"name": "exclusion_type", "description": "Measure specific exclusion for historical record of colectomy cancer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "desciption": "The date and timestamp of the dbt run."}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_exclude_colectomy_cancer", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.901898, "relation_name": "cms_synthetic.quality_measures._int_nqf0034_exclude_colectomy_cancer", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatients with a diagnosis or past history of total colectomy or colorectal cancer: G9711\n*/\n\n\nwith exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n From {{ref('quality_measures__value_sets')}}\n where lower(concept_name) in (\n 'malignant neoplasm of colon'\n , 'total colectomy'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for historical record of colectomy cancer' as exclusion_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom patients_with_exclusions", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_exclude_colectomy_cancer.sql", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatients with a diagnosis or past history of total colectomy or colorectal cancer: G9711\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n From cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'malignant neoplasm of colon'\n , 'total colectomy'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for historical record of colectomy cancer' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom patients_with_exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_numerator"], "alias": "_int_nqf0034_numerator", "checksum": {"name": "sha256", "checksum": "00c56829a45219d2c8295e3cfdb6fdbc0bba711b68384fb2e95fe9e913ba7824"}, "config": {"enabled": true, "alias": "_int_nqf0034_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0034, Colorectal Cancer Screening\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence": {"name": "evidence", "description": "Reason (usually the value set concept name) that includes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9067361, "relation_name": "cms_synthetic.quality_measures._int_nqf0034_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n\n/*\nPatients with one or more screenings for colorectal cancer. Appropriate screenings are defined by any one of the\nfollowing criteria:\n- Fecal occult blood test (FOBT) during the measurement period\n- Flexible sigmoidoscopy during the measurement period or the four years prior to the measurement period\n- Colonoscopy during the measurement period or the nine years prior to the measurement period\n- Computed tomography (CT) colonography during the measurement period or the four years prior to the\nmeasurement period.\n- Fecal immunochemical DNA test (FIT-DNA) during the measurement period or the two years prior to the\nmeasurement period.\n\n*/\n\nwith denominator as (\n\n select\n patient_id\n from {{ ref('quality_measures__int_nqf0034_denominator') }}\n\n)\n\n, screening_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n from {{ref('quality_measures__value_sets')}}\n where lower(concept_name) in (\n 'fecal occult blood test (fobt)' -- mp\n , 'flexible sigmoidoscopy' --mp+4\n , 'colonoscopy' -- mp+9\n , 'ct colonography' -- mp+4\n , 'sdna fit test' -- mp+2\n )\n\n)\n\n, screening_periods as (\n\n select \n code\n , code_system\n , concept_name\n , case concept_name\n when 'Fecal Occult Blood Test (FOBT)' then pp.performance_period_begin --mp\n when 'Flexible Sigmoidoscopy' then pp.performance_period_begin_4yp --mp+4\n when 'Colonoscopy' then pp.performance_period_begin_9yp -- mp+9\n when 'CT Colonography' then pp.performance_period_begin_4yp -- mp+4\n when 'sDNA FIT Test' then pp.performance_period_begin_2yp -- mp+2\n else pp.performance_period_begin \n end as effective_performance_period_begin\n , performance_period_end\n from screening_codes\n inner join {{ref('quality_measures__int_nqf0034__performance_period')}} pp\n on 1 = 1\n \n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__observation') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from {{ ref('quality_measures__stg_core__lab_result')}}\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , coalesce( medical_claim.claim_start_date, medical_claim.claim_end_date) as claim_date\n , screening_codes.concept_name\n from medical_claim\n inner join screening_periods\n on medical_claim.claim_start_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n or medical_claim.claim_end_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on medical_claim.hcpcs_code = screening_codes.code\n where screening_codes.code_system in ('hcpcs', 'cpt' )\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n , screening_codes.concept_name\n from observations\n inner join screening_periods\n on observations.observation_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on observations.code = screening_codes.code\n and observations.code_type = screening_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , screening_codes.concept_name\n from procedures\n inner join screening_periods\n on procedures.procedure_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on procedures.code = screening_codes.code\n and procedures.code_type = screening_codes.code_system\n\n)\n\n, normalized_code_labs as (\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.normalized_code = screening_codes.code\n and labs.normalized_code_type = screening_codes.code_system\n)\n\n, source_code_labs as (\n\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.source_code = screening_codes.code\n and labs.source_code_type = screening_codes.code_system\n\n)\n\n, qualifying_labs_union as (\n\n select \n patient_id\n , lab_date\n , concept_name\n from normalized_code_labs\n\n union all\n\n select \n patient_id\n , lab_date\n , concept_name\n from source_code_labs\n\n)\n\n, qualifying_labs as (\n\n select distinct\n patient_id\n , lab_date\n , concept_name\n from qualifying_labs_union\n\n)\n\n, qualifying_events as (\n\n select\n patient_id\n , claim_date as evidence_date\n , concept_name as evidence\n from qualifying_claims\n\n union all\n\n select\n patient_id\n , observation_date as evidence_date\n , concept_name as evidence\n from qualifying_observations\n\n union all\n\n select\n patient_id\n , procedure_date as evidence_date\n , concept_name as evidence\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , lab_date as evidence_date\n , concept_name as evidence\n from qualifying_labs\n\n)\n\nselect\n cast( qualifying_events.patient_id as {{ dbt.type_string() }}) as patient_id\n , cast( evidence_date as date) as evidence_date\n , cast( evidence as {{ dbt.type_string() }}) as evidence\nfrom qualifying_events\ninner join denominator\n on qualifying_events.patient_id = denominator.patient_id", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0034_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0034_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0034_colorectal_cancer_screening/quality_measures__int_nqf0034_numerator.sql", "compiled": true, "compiled_code": "\n\n\n/*\nPatients with one or more screenings for colorectal cancer. Appropriate screenings are defined by any one of the\nfollowing criteria:\n- Fecal occult blood test (FOBT) during the measurement period\n- Flexible sigmoidoscopy during the measurement period or the four years prior to the measurement period\n- Colonoscopy during the measurement period or the nine years prior to the measurement period\n- Computed tomography (CT) colonography during the measurement period or the four years prior to the\nmeasurement period.\n- Fecal immunochemical DNA test (FIT-DNA) during the measurement period or the two years prior to the\nmeasurement period.\n\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0034_denominator\n\n)\n\n, screening_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'fecal occult blood test (fobt)' -- mp\n , 'flexible sigmoidoscopy' --mp+4\n , 'colonoscopy' -- mp+9\n , 'ct colonography' -- mp+4\n , 'sdna fit test' -- mp+2\n )\n\n)\n\n, screening_periods as (\n\n select \n code\n , code_system\n , concept_name\n , case concept_name\n when 'Fecal Occult Blood Test (FOBT)' then pp.performance_period_begin --mp\n when 'Flexible Sigmoidoscopy' then pp.performance_period_begin_4yp --mp+4\n when 'Colonoscopy' then pp.performance_period_begin_9yp -- mp+9\n when 'CT Colonography' then pp.performance_period_begin_4yp -- mp+4\n when 'sDNA FIT Test' then pp.performance_period_begin_2yp -- mp+2\n else pp.performance_period_begin \n end as effective_performance_period_begin\n , performance_period_end\n from screening_codes\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n \n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , coalesce( medical_claim.claim_start_date, medical_claim.claim_end_date) as claim_date\n , screening_codes.concept_name\n from medical_claim\n inner join screening_periods\n on medical_claim.claim_start_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n or medical_claim.claim_end_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on medical_claim.hcpcs_code = screening_codes.code\n where screening_codes.code_system in ('hcpcs', 'cpt' )\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n , screening_codes.concept_name\n from observations\n inner join screening_periods\n on observations.observation_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on observations.code = screening_codes.code\n and observations.code_type = screening_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , screening_codes.concept_name\n from procedures\n inner join screening_periods\n on procedures.procedure_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on procedures.code = screening_codes.code\n and procedures.code_type = screening_codes.code_system\n\n)\n\n, normalized_code_labs as (\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.normalized_code = screening_codes.code\n and labs.normalized_code_type = screening_codes.code_system\n)\n\n, source_code_labs as (\n\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.source_code = screening_codes.code\n and labs.source_code_type = screening_codes.code_system\n\n)\n\n, qualifying_labs_union as (\n\n select \n patient_id\n , lab_date\n , concept_name\n from normalized_code_labs\n\n union all\n\n select \n patient_id\n , lab_date\n , concept_name\n from source_code_labs\n\n)\n\n, qualifying_labs as (\n\n select distinct\n patient_id\n , lab_date\n , concept_name\n from qualifying_labs_union\n\n)\n\n, qualifying_events as (\n\n select\n patient_id\n , claim_date as evidence_date\n , concept_name as evidence\n from qualifying_claims\n\n union all\n\n select\n patient_id\n , observation_date as evidence_date\n , concept_name as evidence\n from qualifying_observations\n\n union all\n\n select\n patient_id\n , procedure_date as evidence_date\n , concept_name as evidence\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , lab_date as evidence_date\n , concept_name as evidence\n from qualifying_labs\n\n)\n\nselect\n cast( qualifying_events.patient_id as TEXT) as patient_id\n , cast( evidence_date as date) as evidence_date\n , cast( evidence as TEXT) as evidence\nfrom qualifying_events\ninner join denominator\n on qualifying_events.patient_id = denominator.patient_id", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_exclusions"], "alias": "_int_cbe0055_exclusions", "checksum": {"name": "sha256", "checksum": "2c40a83edba3f37c14ca0a376c7a1f9562e6df079655f0daab9e798852d82ba2"}, "config": {"enabled": true, "alias": "_int_cbe0055_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CBE 0055, Diabetes: Eye Exam.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.943121, "relation_name": "cms_synthetic.quality_measures._int_cbe0055_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_cbe0055__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_cbe0055__performance_period') }}\n\n)\n{%- endset -%}\n\nwith frailty as (\n\n select\n *\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n or source.paid_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\n and {{ performance_period_end }}\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join {{ref('quality_measures__int_cbe0055_denominator')}} as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_cbe0055_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join cms_synthetic.quality_measures._int_cbe0055_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0055__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055__performance_period"], "alias": "_int_cbe0055__performance_period", "checksum": {"name": "sha256", "checksum": "04554404f293f3843142f0920e2e2982d9da1a57a2a6cd581d43b97c1ea6f169"}, "config": {"enabled": true, "alias": "_int_cbe0055__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Diabetes: Eye Exam\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.938393, "relation_name": "cms_synthetic.quality_measures._int_cbe0055__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CBE0055')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CBE0055')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CBE0055')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_numerator.sql", "original_file_path": "models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_numerator"], "alias": "_int_cbe0055_numerator", "checksum": {"name": "sha256", "checksum": "eb84d90ebb95e0de229414db416824330681c50166d8a90c3dacbec6c499d160"}, "config": {"enabled": true, "alias": "_int_cbe0055_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CBE 0055, Diabetes: Eye Exam\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9417028, "relation_name": "cms_synthetic.quality_measures._int_cbe0055_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_cbe0055_denominator') }}\n\n)\n\n, retina_test_code as (\n\n select\n code\n , code_system\n , concept_name\n from {{ref('quality_measures__value_sets')}}\n where lower(concept_name) in (\n 'diabetic retinal eye exam met'\n , 'retinal or dilated eye exam'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, qualifying_patients as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join {{ ref('quality_measures__int_cbe0055__performance_period') }} pp\n on procedure_date between\n performance_period_begin and performance_period_end\n inner join retina_test_code\n on procedures.code = retina_test_code.code\n and procedures.code_type = retina_test_code.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast('1' as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0055_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__int_cbe0055__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cbe0055_denominator\n\n)\n\n, retina_test_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetic retinal eye exam met'\n , 'retinal or dilated eye exam'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_patients as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period pp\n on procedure_date between\n performance_period_begin and performance_period_end\n inner join retina_test_code\n on procedures.code = retina_test_code.code\n and procedures.code_type = retina_test_code.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast('1' as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_denominator.sql", "original_file_path": "models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_denominator"], "alias": "_int_cbe0055_denominator", "checksum": {"name": "sha256", "checksum": "8801066cfbbfec4db4501dea44a6011e417090475ac907603f345400ee2b6183"}, "config": {"enabled": true, "alias": "_int_cbe0055_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Diabetes: Eye Exam\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9399931, "relation_name": "cms_synthetic.quality_measures._int_cbe0055_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up' \n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'outpatient'\n , 'observation'\n , 'diabetes visit'\n , 'ophthalmological services'\n , 'diabetic retinopathy'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ref('quality_measures__stg_core__encounter')}} encounter\n inner join {{ref('quality_measures__int_cbe0055__performance_period')}} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ref('quality_measures__stg_core__procedure')}} procs\n inner join {{ref('quality_measures__int_cbe0055__performance_period')}} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\n inner join {{ref('quality_measures__int_cbe0055__performance_period')}} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition')}}\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\n , max_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\n , qualifying_types\n from {{ref('quality_measures__stg_core__patient')}} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join {{ref('quality_measures__int_cbe0055__performance_period')}} pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up' \n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'outpatient'\n , 'observation'\n , 'diabetes visit'\n , 'ophthalmological services'\n , 'diabetic retinopathy'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_cbe0055__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_long.sql", "original_file_path": "models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_long"], "alias": "_int_cbe0055_long", "checksum": {"name": "sha256", "checksum": "8c4098a4c773149c7d7f15054cb34f110e38033b0aae8c049c9bfa4b15a06cf9"}, "config": {"enabled": true, "alias": "_int_cbe0055_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CBE 0055, Diabetes: Eye Exam before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.945166, "relation_name": "cms_synthetic.quality_measures._int_cbe0055_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_cbe0055_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_cbe0055_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_cbe0055_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0055_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0055_diabetes_eye_exam/quality_measures__int_cbe0055_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cbe0055_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cbe0055_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cbe0055_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_long.sql", "original_file_path": "models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_long"], "alias": "_int_cbe0101_long", "checksum": {"name": "sha256", "checksum": "83b422db852a643326b932c3dd5c95a68c3f842b76a2d68f6942d8d92f7b9117"}, "config": {"enabled": true, "alias": "_int_cbe0101_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CBE 0101, Falls: Plan of Care before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9799528, "relation_name": "cms_synthetic.quality_measures._int_cbe0101_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_cbe0101_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_cbe0101_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_cbe0101_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0101_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cbe0101_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cbe0101_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cbe0101_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_denominator.sql", "original_file_path": "models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_denominator"], "alias": "_int_cbe0101_denominator", "checksum": {"name": "sha256", "checksum": "8e78c49aafe782415dd9438487c0ce28853f962b3cceb85dcecc66ddb4bf672f"}, "config": {"enabled": true, "alias": "_int_cbe0101_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Falls: Plan of Care.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_date": {"name": "encounter_date", "description": "Patient's date of encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.976568, "relation_name": "cms_synthetic.quality_measures._int_cbe0101_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'audiology visit'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'occupational therapy evaluation'\n , 'office visit'\n , 'physical therapy evaluation'\n , 'online assessments'\n , 'telephone visits' \n , 'care services in long term residential facility'\n , 'discharge services nursing facility'\n , 'encounter inpatient'\n , 'ophthalmological services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as age\n , max_date\n , qualifying_types\n from {{ ref('quality_measures__stg_core__patient') }} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, falls_screening_code as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where code = '1100F'\n /* \n Patient screened for future fall risk; documentation of two or more falls in the past year \n or any fall with injury in the past year\n */\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join falls_screening_code\n on procedures.code = falls_screening_code.code\n and procedures.code_type = falls_screening_code.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from medical_claim\n inner join falls_screening_code\n on medical_claim.hcpcs_code = falls_screening_code.code\n and lower(falls_screening_code.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, qualifying_cares_past_year as (\n\n select\n patient_id\n , evidence_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from qualifying_cares\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} pp\n on evidence_date between pp.performance_period_begin and pp.performance_period_end \n /* \n code 1100F is reported if there are two or more falls in the last year itself,\n so if it's reported in performance year, it indicates the falls in the last year\n */\n\n)\n\n, qualifying_patients as (\n\n select\n qualifying_cares_past_year.patient_id\n , patients_with_age.age\n , max_date as encounter_date\n , qualifying_cares_past_year.performance_period_begin\n , qualifying_cares_past_year.performance_period_end\n , qualifying_cares_past_year.measure_id\n , qualifying_cares_past_year.measure_name\n , qualifying_cares_past_year.measure_version\n , 1 as denominator_flag\n from qualifying_cares_past_year\n left join patients_with_age\n on qualifying_cares_past_year.patient_id = patients_with_age.patient_id\n where age >= 65\n\n)\n\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'audiology visit'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'occupational therapy evaluation'\n , 'office visit'\n , 'physical therapy evaluation'\n , 'online assessments'\n , 'telephone visits' \n , 'care services in long term residential facility'\n , 'discharge services nursing facility'\n , 'encounter inpatient'\n , 'ophthalmological services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, falls_screening_code as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where code = '1100F'\n /* \n Patient screened for future fall risk; documentation of two or more falls in the past year \n or any fall with injury in the past year\n */\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join falls_screening_code\n on procedures.code = falls_screening_code.code\n and procedures.code_type = falls_screening_code.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from medical_claim\n inner join falls_screening_code\n on medical_claim.hcpcs_code = falls_screening_code.code\n and lower(falls_screening_code.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, qualifying_cares_past_year as (\n\n select\n patient_id\n , evidence_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from qualifying_cares\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period pp\n on evidence_date between pp.performance_period_begin and pp.performance_period_end \n /* \n code 1100F is reported if there are two or more falls in the last year itself,\n so if it's reported in performance year, it indicates the falls in the last year\n */\n\n)\n\n, qualifying_patients as (\n\n select\n qualifying_cares_past_year.patient_id\n , patients_with_age.age\n , max_date as encounter_date\n , qualifying_cares_past_year.performance_period_begin\n , qualifying_cares_past_year.performance_period_end\n , qualifying_cares_past_year.measure_id\n , qualifying_cares_past_year.measure_name\n , qualifying_cares_past_year.measure_version\n , 1 as denominator_flag\n from qualifying_cares_past_year\n left join patients_with_age\n on qualifying_cares_past_year.patient_id = patients_with_age.patient_id\n where age >= 65\n\n)\n\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_numerator.sql", "original_file_path": "models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_numerator"], "alias": "_int_cbe0101_numerator", "checksum": {"name": "sha256", "checksum": "ea9d30625965db6b1637345a71dab2ced2cb5aaa13434c561bdf698af29cf252"}, "config": {"enabled": true, "alias": "_int_cbe0101_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CBE 0101, Falls: Plan of Care.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9818702, "relation_name": "cms_synthetic.quality_measures._int_cbe0101_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_cbe0101_denominator') }}\n\n)\n\n, fallcare_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where code = '0518F' -- Falls plan of care documented\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join fallcare_codes\n on procedures.code = fallcare_codes.code\n and procedures.code_type = fallcare_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join fallcare_codes\n on medical_claim.hcpcs_code = fallcare_codes.code\n and lower(fallcare_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n {{ dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"denominator.encounter_date\"\n )\n }}\n and \n denominator.encounter_date -- within last 12 months of falls screening visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0101_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cbe0101_denominator\n\n)\n\n, fallcare_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where code = '0518F' -- Falls plan of care documented\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join fallcare_codes\n on procedures.code = fallcare_codes.code\n and procedures.code_type = fallcare_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join fallcare_codes\n on medical_claim.hcpcs_code = fallcare_codes.code\n and lower(fallcare_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of falls screening visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_exclusions"], "alias": "_int_cbe0101_exclusions", "checksum": {"name": "sha256", "checksum": "95413305c489903c5d98ba4d0f66fda45c215b7f9e6ae4a2297b3b0f01ea1d7c"}, "config": {"enabled": true, "alias": "_int_cbe0101_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CBE 0101, Falls: Plan of Care.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9782221, "relation_name": "cms_synthetic.quality_measures._int_cbe0101_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n\n select \n performance_period_begin\n from {{ ref('quality_measures__int_cbe0101__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n\n select \n performance_period_end\n from {{ ref('quality_measures__int_cbe0101__performance_period') }}\n\n)\n{%- endset -%}\n\nwith denominator as (\n \n select\n patient_id\n from {{ ref('quality_measures__int_cbe0101_denominator') }}\n\n)\n\n, exclusion_code as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where code = '0518F'\n -- further 1P modifier are only excluded\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, exclusion_procedures as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , 'Limited Mobility' as exclusion_reason\n from procedures\n inner join exclusion_code\n on procedures.code = exclusion_code.code\n and procedures.code_type = exclusion_code.code_system\n where '1P' in (modifier_1, modifier_2, modifier_3, modifier_4, modifier_5)\n \n)\n\n, exclusion_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , 'Limited mobility' as exclusion_reason\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join exclusion_code\n on medical_claim.hcpcs_code = exclusion_code.code\n and lower(exclusion_code.code_system) = 'hcpcs'\n where '1P' in (hcpcs_modifier_1, hcpcs_modifier_2, hcpcs_modifier_3, hcpcs_modifier_4, hcpcs_modifier_5)\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_procedures\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_claims\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_cbe0101_denominator\n\n)\n\n, exclusion_code as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where code = '0518F'\n -- further 1P modifier are only excluded\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0101__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0101__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_procedures as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , 'Limited Mobility' as exclusion_reason\n from procedures\n inner join exclusion_code\n on procedures.code = exclusion_code.code\n and procedures.code_type = exclusion_code.code_system\n where '1P' in (modifier_1, modifier_2, modifier_3, modifier_4, modifier_5)\n \n)\n\n, exclusion_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , 'Limited mobility' as exclusion_reason\n from __dbt__cte___stg_medical_claim medical_claim\n inner join exclusion_code\n on medical_claim.hcpcs_code = exclusion_code.code\n and lower(exclusion_code.code_system) = 'hcpcs'\n where '1P' in (hcpcs_modifier_1, hcpcs_modifier_2, hcpcs_modifier_3, hcpcs_modifier_4, hcpcs_modifier_5)\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_procedures\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_claims\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cbe0101__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101__performance_period"], "alias": "_int_cbe0101__performance_period", "checksum": {"name": "sha256", "checksum": "35ee6ccf32f4ef56c9e9e5c9b04b55e5b9c91034d0301848d95dcb11f4879524"}, "config": {"enabled": true, "alias": "_int_cbe0101__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Falls: Plan of Care.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.975011, "relation_name": "cms_synthetic.quality_measures._int_cbe0101__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0101')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0101')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0101')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided \r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to following day of 1 year prior\r\n*/\r\n\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cbe0101_falls_plan_of_care/quality_measures__int_cbe0101__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm236__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236__performance_period"], "alias": "_int_cqm236__performance_period", "checksum": {"name": "sha256", "checksum": "e2ee095509aaf2c417a5c66fe8d77244e9911c07663ba4b7ca001e171e0c30e5"}, "config": {"enabled": true, "alias": "_int_cqm236__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Controlling Blood Pressure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.917502, "relation_name": "cms_synthetic.quality_measures._int_cqm236__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM236')\n\n{%- endset -%}\n\n{%- set measure_name -%}\n\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM236')\n\n{%- endset -%}\n\n{%- set measure_version -%}\n\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM236')\n\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm236_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_denominator.sql", "original_file_path": "models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_denominator"], "alias": "_int_cqm236_denominator", "checksum": {"name": "sha256", "checksum": "39b98c55364b341723432daf6caf06c9cbb686cd8e56667c4a9d489c759ed9c4"}, "config": {"enabled": true, "alias": "_int_cqm236_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of CQM 236, Controlling Blood Pressure\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.919085, "relation_name": "cms_synthetic.quality_measures._int_cqm236_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'emergency department evaluation and management visit'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ref('quality_measures__stg_core__encounter')}} encounter\n inner join {{ref('quality_measures__int_cqm236__performance_period')}} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'outpatient'\n , 'nonacute inpatient'\n , 'encounter inpatient'\n , 'acute_inpatient'\n , 'emergency_department'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ref('quality_measures__stg_core__procedure')}} procs\n inner join {{ref('quality_measures__int_cqm236__performance_period')}} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\n inner join {{ref('quality_measures__int_cqm236__performance_period')}} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, hypertension_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'essential hypertension'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition')}}\n\n)\n\n, hypertension_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join hypertension_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = hypertension_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = hypertension_codes.code\n\n)\n\n, patients_with_age as (\n \n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\n , max_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\n , qualifying_types\n from {{ref('quality_measures__stg_core__patient')}} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n-- Patients 18-85 years of age who had a visit and diagnosis of essential hypertension starting before and continuing into, or starting during the first six months of the measurement period.\n, qualifying_patients as (\n\n select\n distinct\n hypertension_conditions.patient_id\n , hypertension_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from hypertension_conditions\n left join patients_with_age\n on hypertension_conditions.patient_id = patients_with_age.patient_id\n cross join {{ref('quality_measures__int_cqm236__performance_period')}} pp\n where max_age >= 18 and min_age <= 85\n and hypertension_conditions.recorded_date between\n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = -12\n , from_date_or_timestamp = \"performance_period_begin\"\n )\n }}\n and \n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = +6\n , from_date_or_timestamp = \"performance_period_begin\"\n )}}\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff", "macro.dbt.dateadd"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'emergency department evaluation and management visit'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm236__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'outpatient'\n , 'nonacute inpatient'\n , 'encounter inpatient'\n , 'acute_inpatient'\n , 'emergency_department'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_cqm236__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cqm236__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, hypertension_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'essential hypertension'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, hypertension_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join hypertension_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = hypertension_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = hypertension_codes.code\n\n)\n\n, patients_with_age as (\n \n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n-- Patients 18-85 years of age who had a visit and diagnosis of essential hypertension starting before and continuing into, or starting during the first six months of the measurement period.\n, qualifying_patients as (\n\n select\n distinct\n hypertension_conditions.patient_id\n , hypertension_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from hypertension_conditions\n left join patients_with_age\n on hypertension_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_cqm236__performance_period pp\n where max_age >= 18 and min_age <= 85\n and hypertension_conditions.recorded_date between\n \n\n dateadd(\n month,\n -12,\n performance_period_begin\n )\n\n\n and \n \n\n dateadd(\n month,\n 6,\n performance_period_begin\n )\n\n\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm236_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_numerator.sql", "original_file_path": "models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_numerator"], "alias": "_int_cqm236_numerator", "checksum": {"name": "sha256", "checksum": "e8ce767318bb3b0b062a975c80cf0ca28bad6c27f3cb4256b95ab5dd619255fb"}, "config": {"enabled": true, "alias": "_int_cqm236_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 236, Controlling Blood Pressure.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9238331, "relation_name": "cms_synthetic.quality_measures._int_cqm236_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith controlled_bp_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'most recent systolic blood pressure < 140 mmhg' --G8752 hcpcs\n , 'most recent diastolic blood pressure < 90 mmhg' --G8754 hcpcs\n )\n \n)\n\n, denominator as (\n\n select\n patient_id\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from {{ ref('quality_measures__int_cqm236_denominator') }}\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n , encounter_end_date\n from {{ ref('quality_measures__stg_core__encounter') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , normalized_code\n , normalized_description\n , result\n from {{ ref('quality_measures__stg_core__observation') }}\n where lower(normalized_description) in \n (\n 'systolic blood pressure'\n , 'diastolic blood pressure'\n )\n and normalized_code not in (\n '99473' -- Self-measured blood pressure using a device validated for clinical accuracy; patient education/training and device calibration\n , '99474' -- Separate self-measurements of two readings one minute apart, twice daily over a 30-day period (minimum of 12 readings), collection of data reported by the patient and/or caregiver to the physician or other qualified health care professional, with report of average systolic and diastolic pressures and subsequent communication of a treatment plan to the patient\n )\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , result\n , normalized_code\n from {{ref('quality_measures__stg_core__lab_result')}}\n where normalized_code in \n ('8480-6' --systolic\n ,'8462-4') --diastolic\n and\n normalized_code_type = 'loinc'\n\n)\n\n, all_procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, all_medical_claims as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n\n)\n\n, controlled_bp_procedures as (\n\n select\n all_procedures.patient_id\n , all_procedures.procedure_date as evidence_date\n , controlled_bp_codes.code\n from all_procedures\n inner join controlled_bp_codes\n on all_procedures.code_type = controlled_bp_codes.code_system\n and all_procedures.code = controlled_bp_codes.code\n\n)\n\n, controlled_bp_medical_claims as (\n\n select\n all_medical_claims.patient_id\n , coalesce(all_medical_claims.claim_end_date, all_medical_claims.claim_start_date) as evidence_date\n , controlled_bp_codes.code\n from all_medical_claims\n inner join controlled_bp_codes\n on all_medical_claims.hcpcs_code = controlled_bp_codes.code\n and controlled_bp_codes.code_system = 'hcpcs'\n\n)\n\n, controlled_bp_patients_proc_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_procedures\n\n union all\n \n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_medical_claims\n\n)\n\n, controlled_bp_within_range_proc_claims as (\n\n select\n controlled_bp_patients_proc_claims.patient_id\n , controlled_bp_patients_proc_claims.evidence_date\n , controlled_bp_patients_proc_claims.code\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from controlled_bp_patients_proc_claims\n inner join denominator\n on controlled_bp_patients_proc_claims.patient_id = denominator.patient_id\n and controlled_bp_patients_proc_claims.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, procedure_claims_w_encounters as (\n\n select\n controlled_bp_within_range_proc_claims.patient_id\n , controlled_bp_within_range_proc_claims.evidence_date\n , controlled_bp_within_range_proc_claims.code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_procedure_claims\n , controlled_bp_within_range_proc_claims.measure_id\n , controlled_bp_within_range_proc_claims.measure_name\n , controlled_bp_within_range_proc_claims.measure_version\n , controlled_bp_within_range_proc_claims.performance_period_begin\n , controlled_bp_within_range_proc_claims.performance_period_end\n from controlled_bp_within_range_proc_claims\n left join encounters\n on controlled_bp_within_range_proc_claims.patient_id = encounters.patient_id\n and controlled_bp_within_range_proc_claims.evidence_date between \n encounters.encounter_start_date and encounters.encounter_end_date \n \n)\n\n, valid_procedures_and_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from procedure_claims_w_encounters\n where is_valid_procedure_claims = 1\n\n)\n\n, systolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from valid_procedures_and_claims\n where code = 'G8752' --systolic\n\n)\n\n, diastolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n from valid_procedures_and_claims\n where code = 'G8754' --diastolic\n\n)\n\n, qualifying_controlled_bp_proc_claims as (\n\n select\n systolic_bp_from_procedure_claims.patient_id\n , systolic_bp_from_procedure_claims.evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp_from_procedure_claims\n inner join diastolic_bp_from_procedure_claims\n on systolic_bp_from_procedure_claims.patient_id = diastolic_bp_from_procedure_claims.patient_id\n and systolic_bp_from_procedure_claims.evidence_date = diastolic_bp_from_procedure_claims.evidence_date\n\n)\n\n, observations_within_range as (\n\n select\n observations.patient_id\n , observations.observation_date\n , observations.normalized_code\n , observations.normalized_description\n , observations.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from observations\n inner join denominator\n on observations.patient_id = denominator.patient_id\n and observations.observation_date between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, labs_within_range as (\n\n select\n labs.patient_id\n , labs.normalized_code\n , coalesce(labs.result_date, labs.collection_date) as observation_date\n , labs.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from labs\n inner join denominator\n on labs.patient_id = denominator.patient_id\n and coalesce(labs.result_date,labs.collection_date) between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, observations_with_encounters as (\n\n select\n observations_within_range.patient_id\n , observations_within_range.observation_date\n , observations_within_range.normalized_description\n , observations_within_range.result\n , observations_within_range.normalized_code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_observation\n , observations_within_range.measure_id\n , observations_within_range.measure_name\n , observations_within_range.measure_version\n , observations_within_range.performance_period_begin\n , observations_within_range.performance_period_end\n from observations_within_range\n left join encounters\n on observations_within_range.patient_id = encounters.patient_id\n and observations_within_range.observation_date between \n encounters.encounter_start_date and encounters.encounter_end_date\n\n)\n\n, labs_with_encounters as (\n\n select\n labs_within_range.patient_id\n , labs_within_range.normalized_code\n , labs_within_range.observation_date\n , labs_within_range.result\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_labs\n , labs_within_range.measure_id\n , labs_within_range.measure_name\n , labs_within_range.measure_version\n , labs_within_range.performance_period_begin\n , labs_within_range.performance_period_end\n from labs_within_range\n left join encounters\n on labs_within_range.patient_id = encounters.patient_id\n and labs_within_range.observation_date between\n encounters.encounter_start_date and encounters.encounter_end_date\n \n)\n\n, obs_and_labs as (\n\n select\n patient_id\n , observation_date\n {% if target.type == 'fabric' %}\n , try_cast(result as {{ dbt.type_float() }}) as bp_reading\n {% else %}\n , cast(result as {{ dbt.type_float() }}) as bp_reading\n {% endif %}\n , normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from observations_with_encounters\n where is_valid_encounter_observation = 1\n\n union all\n\n select\n patient_id\n , observation_date\n {% if target.type == 'fabric' %}\n , try_cast(result as {{ dbt.type_float() }}) as bp_reading\n {% else %}\n , cast(result as {{ dbt.type_float() }}) as bp_reading\n {% endif %}\n , cast(null as {{ dbt.type_string() }}) as normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from labs_with_encounters labs\n where is_valid_encounter_labs = 1\n\n)\n\n, systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'systolic blood pressure'\n or\n normalized_code = '8480-6'\n\n)\n\n, diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'diastolic blood pressure'\n or\n normalized_code = '8462-4'\n\n)\n\n, least_recent_systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as systolic_bp\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp\n where rn = 1\n\n)\n\n, least_recent_diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as diastolic_bp\n from diastolic_bp\n where rn = 1\n\n)\n\n, patients_with_bp_readings as (\n\n select\n least_recent_systolic_bp.patient_id\n , least_recent_systolic_bp.systolic_bp\n , least_recent_diastolic_bp.diastolic_bp\n , least_recent_systolic_bp.observation_date\n , least_recent_systolic_bp.measure_id\n , least_recent_systolic_bp.measure_name\n , least_recent_systolic_bp.measure_version\n , least_recent_systolic_bp.performance_period_begin\n , least_recent_systolic_bp.performance_period_end\n from least_recent_systolic_bp\n inner join least_recent_diastolic_bp\n on least_recent_systolic_bp.patient_id = least_recent_diastolic_bp.patient_id\n and least_recent_systolic_bp.observation_date = least_recent_diastolic_bp.observation_date\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , case\n when systolic_bp < 140.0 and diastolic_bp < 90.0\n then 1\n else 0\n end as numerator_flag\n from patients_with_bp_readings\n\n union all\n\n select\n patient_id\n , evidence_date as observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as numerator_flag\n from qualifying_controlled_bp_proc_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(observation_date as date) as observation_date\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , observation_date\n , numerator_flag\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_float", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), controlled_bp_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'most recent systolic blood pressure < 140 mmhg' --G8752 hcpcs\n , 'most recent diastolic blood pressure < 90 mmhg' --G8754 hcpcs\n )\n \n)\n\n, denominator as (\n\n select\n patient_id\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n , encounter_end_date\n from __dbt__cte___stg_encounter\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , normalized_code\n , normalized_description\n , result\n from __dbt__cte___stg_observation\n where lower(normalized_description) in \n (\n 'systolic blood pressure'\n , 'diastolic blood pressure'\n )\n and normalized_code not in (\n '99473' -- Self-measured blood pressure using a device validated for clinical accuracy; patient education/training and device calibration\n , '99474' -- Separate self-measurements of two readings one minute apart, twice daily over a 30-day period (minimum of 12 readings), collection of data reported by the patient and/or caregiver to the physician or other qualified health care professional, with report of average systolic and diastolic pressures and subsequent communication of a treatment plan to the patient\n )\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , result\n , normalized_code\n from __dbt__cte___stg_lab_result\n where normalized_code in \n ('8480-6' --systolic\n ,'8462-4') --diastolic\n and\n normalized_code_type = 'loinc'\n\n)\n\n, all_procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, all_medical_claims as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, controlled_bp_procedures as (\n\n select\n all_procedures.patient_id\n , all_procedures.procedure_date as evidence_date\n , controlled_bp_codes.code\n from all_procedures\n inner join controlled_bp_codes\n on all_procedures.code_type = controlled_bp_codes.code_system\n and all_procedures.code = controlled_bp_codes.code\n\n)\n\n, controlled_bp_medical_claims as (\n\n select\n all_medical_claims.patient_id\n , coalesce(all_medical_claims.claim_end_date, all_medical_claims.claim_start_date) as evidence_date\n , controlled_bp_codes.code\n from all_medical_claims\n inner join controlled_bp_codes\n on all_medical_claims.hcpcs_code = controlled_bp_codes.code\n and controlled_bp_codes.code_system = 'hcpcs'\n\n)\n\n, controlled_bp_patients_proc_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_procedures\n\n union all\n \n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_medical_claims\n\n)\n\n, controlled_bp_within_range_proc_claims as (\n\n select\n controlled_bp_patients_proc_claims.patient_id\n , controlled_bp_patients_proc_claims.evidence_date\n , controlled_bp_patients_proc_claims.code\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from controlled_bp_patients_proc_claims\n inner join denominator\n on controlled_bp_patients_proc_claims.patient_id = denominator.patient_id\n and controlled_bp_patients_proc_claims.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, procedure_claims_w_encounters as (\n\n select\n controlled_bp_within_range_proc_claims.patient_id\n , controlled_bp_within_range_proc_claims.evidence_date\n , controlled_bp_within_range_proc_claims.code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_procedure_claims\n , controlled_bp_within_range_proc_claims.measure_id\n , controlled_bp_within_range_proc_claims.measure_name\n , controlled_bp_within_range_proc_claims.measure_version\n , controlled_bp_within_range_proc_claims.performance_period_begin\n , controlled_bp_within_range_proc_claims.performance_period_end\n from controlled_bp_within_range_proc_claims\n left join encounters\n on controlled_bp_within_range_proc_claims.patient_id = encounters.patient_id\n and controlled_bp_within_range_proc_claims.evidence_date between \n encounters.encounter_start_date and encounters.encounter_end_date \n \n)\n\n, valid_procedures_and_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from procedure_claims_w_encounters\n where is_valid_procedure_claims = 1\n\n)\n\n, systolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from valid_procedures_and_claims\n where code = 'G8752' --systolic\n\n)\n\n, diastolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n from valid_procedures_and_claims\n where code = 'G8754' --diastolic\n\n)\n\n, qualifying_controlled_bp_proc_claims as (\n\n select\n systolic_bp_from_procedure_claims.patient_id\n , systolic_bp_from_procedure_claims.evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp_from_procedure_claims\n inner join diastolic_bp_from_procedure_claims\n on systolic_bp_from_procedure_claims.patient_id = diastolic_bp_from_procedure_claims.patient_id\n and systolic_bp_from_procedure_claims.evidence_date = diastolic_bp_from_procedure_claims.evidence_date\n\n)\n\n, observations_within_range as (\n\n select\n observations.patient_id\n , observations.observation_date\n , observations.normalized_code\n , observations.normalized_description\n , observations.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from observations\n inner join denominator\n on observations.patient_id = denominator.patient_id\n and observations.observation_date between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, labs_within_range as (\n\n select\n labs.patient_id\n , labs.normalized_code\n , coalesce(labs.result_date, labs.collection_date) as observation_date\n , labs.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from labs\n inner join denominator\n on labs.patient_id = denominator.patient_id\n and coalesce(labs.result_date,labs.collection_date) between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, observations_with_encounters as (\n\n select\n observations_within_range.patient_id\n , observations_within_range.observation_date\n , observations_within_range.normalized_description\n , observations_within_range.result\n , observations_within_range.normalized_code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_observation\n , observations_within_range.measure_id\n , observations_within_range.measure_name\n , observations_within_range.measure_version\n , observations_within_range.performance_period_begin\n , observations_within_range.performance_period_end\n from observations_within_range\n left join encounters\n on observations_within_range.patient_id = encounters.patient_id\n and observations_within_range.observation_date between \n encounters.encounter_start_date and encounters.encounter_end_date\n\n)\n\n, labs_with_encounters as (\n\n select\n labs_within_range.patient_id\n , labs_within_range.normalized_code\n , labs_within_range.observation_date\n , labs_within_range.result\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_labs\n , labs_within_range.measure_id\n , labs_within_range.measure_name\n , labs_within_range.measure_version\n , labs_within_range.performance_period_begin\n , labs_within_range.performance_period_end\n from labs_within_range\n left join encounters\n on labs_within_range.patient_id = encounters.patient_id\n and labs_within_range.observation_date between\n encounters.encounter_start_date and encounters.encounter_end_date\n \n)\n\n, obs_and_labs as (\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from observations_with_encounters\n where is_valid_encounter_observation = 1\n\n union all\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , cast(null as TEXT) as normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from labs_with_encounters labs\n where is_valid_encounter_labs = 1\n\n)\n\n, systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'systolic blood pressure'\n or\n normalized_code = '8480-6'\n\n)\n\n, diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'diastolic blood pressure'\n or\n normalized_code = '8462-4'\n\n)\n\n, least_recent_systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as systolic_bp\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp\n where rn = 1\n\n)\n\n, least_recent_diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as diastolic_bp\n from diastolic_bp\n where rn = 1\n\n)\n\n, patients_with_bp_readings as (\n\n select\n least_recent_systolic_bp.patient_id\n , least_recent_systolic_bp.systolic_bp\n , least_recent_diastolic_bp.diastolic_bp\n , least_recent_systolic_bp.observation_date\n , least_recent_systolic_bp.measure_id\n , least_recent_systolic_bp.measure_name\n , least_recent_systolic_bp.measure_version\n , least_recent_systolic_bp.performance_period_begin\n , least_recent_systolic_bp.performance_period_end\n from least_recent_systolic_bp\n inner join least_recent_diastolic_bp\n on least_recent_systolic_bp.patient_id = least_recent_diastolic_bp.patient_id\n and least_recent_systolic_bp.observation_date = least_recent_diastolic_bp.observation_date\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , case\n when systolic_bp < 140.0 and diastolic_bp < 90.0\n then 1\n else 0\n end as numerator_flag\n from patients_with_bp_readings\n\n union all\n\n select\n patient_id\n , evidence_date as observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as numerator_flag\n from qualifying_controlled_bp_proc_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(observation_date as date) as observation_date\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , observation_date\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm236_exclude_procedures_observations", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_exclude_procedures_observations.sql", "original_file_path": "models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_exclude_procedures_observations.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_exclude_procedures_observations"], "alias": "_int_cqm236_exclude_procedures_observations", "checksum": {"name": "sha256", "checksum": "cb82cd8e98e6c8e777e644b8b9748f709f3088f50e521e4d1015c18b0e65586e"}, "config": {"enabled": true, "alias": "_int_cqm236_exclude_procedures_observations", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with certain observations and procedures for the reporting version of CQM 236, Controlling Blood Pressure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_exclude_procedures_observations", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9205399, "relation_name": "cms_synthetic.quality_measures._int_cqm236_exclude_procedures_observations", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n from {{ ref('quality_measures__int_cqm236_denominator') }}\n\n)\n\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets')}}\n where lower(concept_name) in (\n 'dialysis services'\n , 'end stage renal disease'\n , 'esrd monthly outpatient services'\n , 'kidney transplant'\n , 'kidney transplant recipient'\n , 'pregnancy'\n )\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, exclusions_unioned as (\n\n select\n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, excluded_patients as (\n\n select\n exclusions_unioned.patient_id\n , exclusions_unioned.exclusion_date\n , exclusions_unioned.exclusion_reason\n , case\n when exclusion_reason = 'pregnancy' then 1\n else 0\n end as is_pregnant\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.age\n from exclusions_unioned\n inner join denominator\n on exclusions_unioned.patient_id = denominator.patient_id\n\n)\n\n, exclusions_filtered as (\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 1\n and exclusion_date between performance_period_begin and performance_period_end\n \n union all\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 0\n and exclusion_date between performance_period_begin and performance_period_end\n or (exclusion_date between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=\"performance_period_begin\") }}\n and performance_period_end)\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , age\n , 'measure specific exclusion for observation procedure' as exclusion_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom\n exclusions_filtered", "language": "sql", "refs": [{"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_exclude_procedures_observations.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dialysis services'\n , 'end stage renal disease'\n , 'esrd monthly outpatient services'\n , 'kidney transplant'\n , 'kidney transplant recipient'\n , 'pregnancy'\n )\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, exclusions_unioned as (\n\n select\n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, excluded_patients as (\n\n select\n exclusions_unioned.patient_id\n , exclusions_unioned.exclusion_date\n , exclusions_unioned.exclusion_reason\n , case\n when exclusion_reason = 'pregnancy' then 1\n else 0\n end as is_pregnant\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.age\n from exclusions_unioned\n inner join denominator\n on exclusions_unioned.patient_id = denominator.patient_id\n\n)\n\n, exclusions_filtered as (\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 1\n and exclusion_date between performance_period_begin and performance_period_end\n \n union all\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 0\n and exclusion_date between performance_period_begin and performance_period_end\n or (exclusion_date between \n\n dateadd(\n year,\n -1,\n performance_period_begin\n )\n\n\n and performance_period_end)\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , age\n , 'measure specific exclusion for observation procedure' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n exclusions_filtered", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm236_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_exclusions"], "alias": "_int_cqm236_exclusions", "checksum": {"name": "sha256", "checksum": "fd09192ac66eb56b069399da53b2cc7fe260caa3ff093471e61fabe4b9174b7a"}, "config": {"enabled": true, "alias": "_int_cqm236_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 236, Controlling Blood Pressure.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9222, "relation_name": "cms_synthetic.quality_measures._int_cqm236_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_cqm236__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_cqm236__performance_period') }}\n\n)\n{%- endset -%}\n\nwith frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n from {{ref('quality_measures__int_cqm236_denominator')}}\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\n and {{ performance_period_end }}\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n or source.paid_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, measure_specific_procedure_observation_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n , age\n from {{ref('quality_measures__int_cqm236_exclude_procedures_observations')}}\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, frailty_exclusion_older_than_80 as (\n\n select\n frailty.patient_id\n , frailty.exclusion_date\n , frailty.exclusion_reason\n , 'measure specific exclusion for patients older than 80' as exclusion_type\n , denominator.age\n from frailty\n inner join denominator\n on frailty.patient_id = denominator.patient_id\n where denominator.age >= 81\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select * from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n union all\n\n select * from frailty_exclusion_older_than_80\n\n union all\n\n select * from measure_specific_procedure_observation_exclusion\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_exclude_procedures_observations", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, measure_specific_procedure_observation_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n , age\n from cms_synthetic.quality_measures._int_cqm236_exclude_procedures_observations\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, frailty_exclusion_older_than_80 as (\n\n select\n frailty.patient_id\n , frailty.exclusion_date\n , frailty.exclusion_reason\n , 'measure specific exclusion for patients older than 80' as exclusion_type\n , denominator.age\n from frailty\n inner join denominator\n on frailty.patient_id = denominator.patient_id\n where denominator.age >= 81\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select * from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n union all\n\n select * from frailty_exclusion_older_than_80\n\n union all\n\n select * from measure_specific_procedure_observation_exclusion\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm236_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_long.sql", "original_file_path": "models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_long"], "alias": "_int_cqm236_long", "checksum": {"name": "sha256", "checksum": "3aa668481da26e96d3f9e8639850422e38e4e891ac2582b9f1e45c03cd701900"}, "config": {"enabled": true, "alias": "_int_cqm236_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 236,Controlling Blood Pressure before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9254122, "relation_name": "cms_synthetic.quality_measures._int_cqm236_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_cqm236_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n from {{ ref('quality_measures__int_cqm236_numerator') }}\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_cqm236_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.observation_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.observation_date is null then 1 else 0 end,\n numerator.observation_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , observation_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(observation_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm236_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm236_controlling_blood_pressure/quality_measures__int_cqm236_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n from cms_synthetic.quality_measures._int_cqm236_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm236_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.observation_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.observation_date is null then 1 else 0 end,\n numerator.observation_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , observation_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(observation_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053__performance_period"], "alias": "_int_nqf0053__performance_period", "checksum": {"name": "sha256", "checksum": "ac54ce769e4046bee490051fafe922f3f68f8db08a3da120dccc2e6240df5ca6"}, "config": {"enabled": true, "alias": "_int_nqf0053__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Osteoporosis Management in women who had a fracture\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9268339, "relation_name": "cms_synthetic.quality_measures._int_nqf0053__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0053')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0053')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0053')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\n-- lookback_period for last june 30 and december 31\r\n, lookback_period as (\r\n\r\nSELECT\r\n *\r\n , case\r\n when performance_period_end >= cast(({{ dbt.concat([date_part('year', 'performance_period_end'), \"'-06-30'\"]) }}) as date)\r\n then {{ dbt.concat([date_part('year', 'performance_period_end'), \"'-06-30'\"]) }}\r\n else {{ dbt.concat([date_part('year', 'performance_period_begin'), \"'-06-30'\"]) }}\r\n end as lookback_period_june\r\n , case\r\n when performance_period_end >= cast(({{ dbt.concat([date_part('year', 'performance_period_end'), \"'-12-31'\"]) }}) as date)\r\n then {{ dbt.concat([date_part('year', 'performance_period_end'), \"'-12-31'\"]) }}\r\n else {{ dbt.concat([date_part('year', 'performance_period_begin'), \"'-12-31'\"]) }}\r\n end as lookback_period_december\r\nFROM period_begin\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(lookback_period_june as date) as lookback_period_june\r\n , cast(lookback_period_december as date) as lookback_period_december\r\nfrom lookback_period", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n-- lookback_period for last june 30 and december 31\n, lookback_period as (\n\nSELECT\n *\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-06-30') as date)\n then date_part('year', performance_period_end) || '-06-30'\n else date_part('year', performance_period_begin) || '-06-30'\n end as lookback_period_june\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-12-31') as date)\n then date_part('year', performance_period_end) || '-12-31'\n else date_part('year', performance_period_begin) || '-12-31'\n end as lookback_period_december\nFROM period_begin\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_june as date) as lookback_period_june\n , cast(lookback_period_december as date) as lookback_period_december\nfrom lookback_period", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_exclude_procedures_medications", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclude_procedures_medications.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclude_procedures_medications.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_exclude_procedures_medications"], "alias": "_int_nqf0053_exclude_procedures_medications", "checksum": {"name": "sha256", "checksum": "8d63d1d3abcdcfb32693a25a2a715702bef660f1c38210b0251461d66a8c5d91"}, "config": {"enabled": true, "alias": "_int_nqf0053_exclude_procedures_medications", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with certain procedures and medicatons for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_type": {"name": "exclusion_type", "description": "measure specific exclusion for procedure medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "desciption": "The date and timestamp of the dbt run."}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_exclude_procedures_medications", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.935296, "relation_name": "cms_synthetic.quality_measures._int_nqf0053_exclude_procedures_medications", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n from {{ ref('quality_measures__int_nqf0053_denominator')}}\n\n)\n\n, value_sets as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('quality_measures__value_sets')}}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from {{ ref('quality_measures__stg_pharmacy_claim') }}\n\n)\n\n, medications as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n from {{ ref('quality_measures__stg_core__medication') }}\n\n)\n\n, bone_density_test_codes as (\n\n select\n concept_name\n , code\n , code_system\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests hcpcs'\n , 'bone mineral density tests icd10pcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n )\n\n)\n\n, osteoporosis_medication_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, bone_density_test_procedures as (\n\n select\n procedures.*\n , bone_density_test_codes.concept_name\n from procedures\n inner join bone_density_test_codes\n on procedures.code = bone_density_test_codes.code\n and procedures.code_type = bone_density_test_codes.code_system\n\n)\n\n, osteoporosis_pharmacy_claims as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , pharmacy_claims.ndc_code\n , osteoporosis_medication_codes.concept_name\n from pharmacy_claims\n inner join osteoporosis_medication_codes\n on pharmacy_claims.ndc_code = osteoporosis_medication_codes.code\n and lower(osteoporosis_medication_codes.code_system) = 'ndc'\n \n)\n\n, osteoporosis_medications as (\n\n select\n medications.patient_id\n , medications.encounter_id\n , medications.prescribing_date\n , medications.dispensing_date\n , medications.source_code\n , medications.source_code_type\n , osteoporosis_medication_codes.concept_name\n from medications\n inner join osteoporosis_medication_codes\n on medications.source_code = osteoporosis_medication_codes.code\n and medications.source_code_type = osteoporosis_medication_codes.code_system\n\n)\n\n, valid_osteoporosis_medications_procedures as (\n\n select\n denominator.patient_id\n , osteoporosis_pharmacy_claims.concept_name as exclusion_reason\n , osteoporosis_pharmacy_claims.dispensing_date as exclusion_date\n from denominator\n inner join osteoporosis_pharmacy_claims\n on denominator.patient_id = osteoporosis_pharmacy_claims.patient_id\n where osteoporosis_pharmacy_claims.dispensing_date\n between\n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = -12\n , from_date_or_timestamp = \"denominator.performance_period_begin\"\n )}}\n and denominator.performance_period_begin\n \n union all\n\n select\n denominator.patient_id\n , osteoporosis_medications.concept_name as exclusion_reason\n , coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date) as exclusion_date\n from denominator\n inner join osteoporosis_medications\n on denominator.patient_id = osteoporosis_medications.patient_id\n and coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date)\n between\n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = -12\n , from_date_or_timestamp = \"denominator.performance_period_begin\"\n )}}\n and denominator.performance_period_begin\n\n)\n\n, valid_tests_performed as (\n\n select\n denominator.patient_id\n , bone_density_test_procedures.concept_name as exclusion_reason\n , procedure_date as exclusion_date\n from denominator\n inner join bone_density_test_procedures\n on denominator.patient_id = bone_density_test_procedures.patient_id\n where bone_density_test_procedures.procedure_date\n between \n {{ dbt.dateadd (\n datepart = \"year\"\n , interval = -2\n , from_date_or_timestamp = \"denominator.performance_period_begin\"\n )}}\n and denominator.performance_period_begin\n\n)\n\n, valid_exclusions as (\n\n select * from valid_tests_performed\n\n union all\n\n select * from valid_osteoporosis_medications_procedures\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for procedure medication' as exclusion_type\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom\n valid_exclusions", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclude_procedures_medications.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medications as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, bone_density_test_codes as (\n\n select\n concept_name\n , code\n , code_system\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests hcpcs'\n , 'bone mineral density tests icd10pcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n )\n\n)\n\n, osteoporosis_medication_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, bone_density_test_procedures as (\n\n select\n procedures.*\n , bone_density_test_codes.concept_name\n from procedures\n inner join bone_density_test_codes\n on procedures.code = bone_density_test_codes.code\n and procedures.code_type = bone_density_test_codes.code_system\n\n)\n\n, osteoporosis_pharmacy_claims as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , pharmacy_claims.ndc_code\n , osteoporosis_medication_codes.concept_name\n from pharmacy_claims\n inner join osteoporosis_medication_codes\n on pharmacy_claims.ndc_code = osteoporosis_medication_codes.code\n and lower(osteoporosis_medication_codes.code_system) = 'ndc'\n \n)\n\n, osteoporosis_medications as (\n\n select\n medications.patient_id\n , medications.encounter_id\n , medications.prescribing_date\n , medications.dispensing_date\n , medications.source_code\n , medications.source_code_type\n , osteoporosis_medication_codes.concept_name\n from medications\n inner join osteoporosis_medication_codes\n on medications.source_code = osteoporosis_medication_codes.code\n and medications.source_code_type = osteoporosis_medication_codes.code_system\n\n)\n\n, valid_osteoporosis_medications_procedures as (\n\n select\n denominator.patient_id\n , osteoporosis_pharmacy_claims.concept_name as exclusion_reason\n , osteoporosis_pharmacy_claims.dispensing_date as exclusion_date\n from denominator\n inner join osteoporosis_pharmacy_claims\n on denominator.patient_id = osteoporosis_pharmacy_claims.patient_id\n where osteoporosis_pharmacy_claims.dispensing_date\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n \n union all\n\n select\n denominator.patient_id\n , osteoporosis_medications.concept_name as exclusion_reason\n , coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date) as exclusion_date\n from denominator\n inner join osteoporosis_medications\n on denominator.patient_id = osteoporosis_medications.patient_id\n and coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date)\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_tests_performed as (\n\n select\n denominator.patient_id\n , bone_density_test_procedures.concept_name as exclusion_reason\n , procedure_date as exclusion_date\n from denominator\n inner join bone_density_test_procedures\n on denominator.patient_id = bone_density_test_procedures.patient_id\n where bone_density_test_procedures.procedure_date\n between \n \n\n dateadd(\n year,\n -2,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_exclusions as (\n\n select * from valid_tests_performed\n\n union all\n\n select * from valid_osteoporosis_medications_procedures\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for procedure medication' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n valid_exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_denominator"], "alias": "_int_nqf0053_denominator", "checksum": {"name": "sha256", "checksum": "e75edec5f85bab55433b98a8d301a0a0ac4459e1b2c5a4ee8f608165ce5d9756"}, "config": {"enabled": true, "alias": "_int_nqf0053_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date of incident/fracture recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.928633, "relation_name": "cms_synthetic.quality_measures._int_nqf0053_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }} as value_sets\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n , encounter_type\n from {{ref('quality_measures__stg_core__encounter')}} as encounter\n inner join {{ ref('quality_measures__int_nqf0053__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ref('quality_measures__stg_core__procedure')}} procs\n inner join {{ref('quality_measures__int_nqf0053__performance_period')}} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , place_of_service_code\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\n inner join {{ref('quality_measures__int_nqf0053__performance_period')}} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, bone_fracture_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) = 'fracture diagnoses'\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition')}}\n\n)\n\n, bone_fracture_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join bone_fracture_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = bone_fracture_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = bone_fracture_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , min_date\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\n , max_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\n , qualifying_types\n from {{ref('quality_measures__stg_core__patient')}} patient\n inner join encounters_by_patient e\n on patient.patient_id = e.patient_id\n where patient.death_date is null\n\n)\n\n, qualifying_patients_w_fractures as (\n\n select\n distinct\n bone_fracture_conditions.patient_id\n , bone_fracture_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from bone_fracture_conditions\n left join patients_with_age\n on bone_fracture_conditions.patient_id = patients_with_age.patient_id\n cross join {{ref('quality_measures__int_nqf0053__performance_period')}} pp\n where max_age >= 50 and min_age <= 85\n and bone_fracture_conditions.recorded_date between\n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = -6\n , from_date_or_timestamp = \"performance_period_begin\"\n )\n }}\n and\n pp.lookback_period_june\n and lower(patients_with_age.sex) = 'female'\n\n)\n\n, fracture_procedures as (\n\n select\n procedures.*\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n inner join {{ ref('quality_measures__int_nqf0053__performance_period') }} as pp\n on procedures.procedure_date \n between pp.performance_period_begin and pp.performance_period_end\n where lower(visit_codes.concept_name) = 'fracture procedures'\n\n)\n\n, qualifying_patients_w_encounter as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join visits_encounters\n on qualifying_patients_w_fractures.patient_id = visits_encounters.patient_id\n where \n lower(visits_encounters.encounter_type) in (\n 'acute inpatient'\n , 'annual wellness visit'\n , 'emergency department visit'\n , 'emergency department'\n , 'home healthcare services'\n , 'office visit'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'emergency department evaluation and management visit'\n , 'outpatient'\n )\n)\n\n, qualifying_patients_w_procedure as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join fracture_procedures\n on qualifying_patients_w_fractures.patient_id = fracture_procedures.patient_id\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n qualifying_patients_w_encounter.*\n from qualifying_patients_w_encounter\n left join qualifying_patients_w_procedure\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n left join claims_encounters\n on qualifying_patients_w_encounter.patient_id = claims_encounters.patient_id\n where (cast(claims_encounters.place_of_service_code as {{ dbt.type_string() }}) not in ('21')\n or claims_encounters.patient_id is null)\n\n union all\n\n select\n distinct\n qualifying_patients_w_procedure.*\n from qualifying_patients_w_procedure\n left join qualifying_patients_w_encounter\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n where qualifying_patients_w_encounter.patient_id is null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , recorded_date \n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff", "macro.dbt.dateadd"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes as value_sets\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n , encounter_type\n from __dbt__cte___stg_encounter as encounter\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , place_of_service_code\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, bone_fracture_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) = 'fracture diagnoses'\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, bone_fracture_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join bone_fracture_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = bone_fracture_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = bone_fracture_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient patient\n inner join encounters_by_patient e\n on patient.patient_id = e.patient_id\n where patient.death_date is null\n\n)\n\n, qualifying_patients_w_fractures as (\n\n select\n distinct\n bone_fracture_conditions.patient_id\n , bone_fracture_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from bone_fracture_conditions\n left join patients_with_age\n on bone_fracture_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_nqf0053__performance_period pp\n where max_age >= 50 and min_age <= 85\n and bone_fracture_conditions.recorded_date between\n \n\n dateadd(\n month,\n -6,\n performance_period_begin\n )\n\n\n and\n pp.lookback_period_june\n and lower(patients_with_age.sex) = 'female'\n\n)\n\n, fracture_procedures as (\n\n select\n procedures.*\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp\n on procedures.procedure_date \n between pp.performance_period_begin and pp.performance_period_end\n where lower(visit_codes.concept_name) = 'fracture procedures'\n\n)\n\n, qualifying_patients_w_encounter as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join visits_encounters\n on qualifying_patients_w_fractures.patient_id = visits_encounters.patient_id\n where \n lower(visits_encounters.encounter_type) in (\n 'acute inpatient'\n , 'annual wellness visit'\n , 'emergency department visit'\n , 'emergency department'\n , 'home healthcare services'\n , 'office visit'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'emergency department evaluation and management visit'\n , 'outpatient'\n )\n)\n\n, qualifying_patients_w_procedure as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join fracture_procedures\n on qualifying_patients_w_fractures.patient_id = fracture_procedures.patient_id\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n qualifying_patients_w_encounter.*\n from qualifying_patients_w_encounter\n left join qualifying_patients_w_procedure\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n left join claims_encounters\n on qualifying_patients_w_encounter.patient_id = claims_encounters.patient_id\n where (cast(claims_encounters.place_of_service_code as TEXT) not in ('21')\n or claims_encounters.patient_id is null)\n\n union all\n\n select\n distinct\n qualifying_patients_w_procedure.*\n from qualifying_patients_w_procedure\n left join qualifying_patients_w_encounter\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n where qualifying_patients_w_encounter.patient_id is null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , recorded_date \n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_exclusions_stage_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclusions_stage_1.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclusions_stage_1.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_exclusions_stage_1"], "alias": "_int_nqf0053_exclusions_stage_1", "checksum": {"name": "sha256", "checksum": "b18b8061598e919de4d354511ad459469f7c4f554b6f7d2439845e705d10d4d7"}, "config": {"enabled": true, "alias": "_int_nqf0053_exclusions_stage_1", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture. First stage of final exclusion logic.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_type": {"name": "exclusion_type", "description": "Type of exclusion from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_exclusions_stage_1", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9323509, "relation_name": "cms_synthetic.quality_measures._int_nqf0053_exclusions_stage_1", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select\n performance_period_begin\n from {{ ref('quality_measures__int_nqf0053__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select\n performance_period_end\n from {{ ref('quality_measures__int_nqf0053__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set lookback_period_december -%}\n(\n select\n lookback_period_december\n from {{ ref('quality_measures__int_nqf0053__performance_period') }}\n\n)\n{%- endset -%}\n\n\nwith frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, frailty_within_defined_window as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between\n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = -6\n , from_date_or_timestamp = performance_period_begin\n )\n }}\n and {{ lookback_period_december }}\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, exclusion_procedure_and_medication as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_nqf0053_exclude_procedures_medications')}}\n\n)\n\n, valid_institutional_snp as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\n where exclusion_date between\n {{dbt.dateadd(\n datepart = \"month\"\n , interval = -6\n , from_date_or_timestamp = performance_period_begin\n )\n }}\n\n and {{ lookback_period_december }}\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n or source.paid_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\n and {{ performance_period_end }}\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, frailty_patients_within_defined_window as (\n\n select\n frailty_within_defined_window.patient_id\n , frailty_within_defined_window.exclusion_date\n , frailty_within_defined_window.exclusion_reason\n , 'measure specific exclusion for defined window' as exclusion_type\n from frailty_within_defined_window\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n union all\n\n select * from exclusion_procedure_and_medication\n\n union all\n\n select * from frailty_patients_within_defined_window\n\n)\n\nselect\n *\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom exclusions", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_exclude_procedures_medications", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclusions_stage_1.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, frailty_within_defined_window as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n lookback_period_december\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, exclusion_procedure_and_medication as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_nqf0053_exclude_procedures_medications\n\n)\n\n, valid_institutional_snp as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n\n and (\n select\n lookback_period_december\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, frailty_patients_within_defined_window as (\n\n select\n frailty_within_defined_window.patient_id\n , frailty_within_defined_window.exclusion_date\n , frailty_within_defined_window.exclusion_reason\n , 'measure specific exclusion for defined window' as exclusion_type\n from frailty_within_defined_window\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n union all\n\n select * from exclusion_procedure_and_medication\n\n union all\n\n select * from frailty_patients_within_defined_window\n\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_long"], "alias": "_int_nqf0053_long", "checksum": {"name": "sha256", "checksum": "9f8dfaad68914cbb5b8f68481cfa6102b1a6d6a4ffa2ad8395f4b4e78bf2f990"}, "config": {"enabled": true, "alias": "_int_nqf0053_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.937103, "relation_name": "cms_synthetic.quality_measures._int_nqf0053_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_nqf0053_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_nqf0053_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf0053_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0053_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0053_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0053_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_numerator"], "alias": "_int_nqf0053_numerator", "checksum": {"name": "sha256", "checksum": "ad95f2684ea7adf098f1af9f1cb2951e797a377643e03e4e0b76e2d5c4f2ead7"}, "config": {"enabled": true, "alias": "_int_nqf0053_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.93049, "relation_name": "cms_synthetic.quality_measures._int_nqf0053_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , recorded_date\n , measure_id\n , measure_name\n , measure_version\n from {{ref('quality_measures__int_nqf0053_denominator')}}\n\n)\n\n, value_sets as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n \n)\n\n, osteo_procedure_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests icd10pcs'\n , 'bone mineral density tests hcpcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n , 'central dual energy x-ray absorptiometry (dxa)'\n , 'spinal densitometry x-ray' \n , 'ultrasonography for densitometry' \n , 'ct bone density axial'\n , 'peripheral dual-energy x-ray absorptiometry (dxa)'\n , 'osteoporosis medication'\n )\n\n)\n\n, procedures_osteo_related as (\n\n select\n patient_id\n , procedure_date\n from {{ref('quality_measures__stg_core__procedure')}} as procs\n inner join osteo_procedure_codes\n on coalesce(procs.normalized_code, procs.source_code) = osteo_procedure_codes.code\n and coalesce(procs.normalized_code_type, procs.source_code_type) = osteo_procedure_codes.code_system\n\n)\n\n, qualifying_procedures as (\n\n select\n procedures_osteo_related.patient_id\n , procedures_osteo_related.procedure_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from procedures_osteo_related\n inner join denominator\n on procedures_osteo_related.patient_id = denominator.patient_id\n and \n procedures_osteo_related.procedure_date between\n denominator.recorded_date \n and\n {{dbt.dateadd (\n datepart = \"month\"\n , interval = +6\n , from_date_or_timestamp = \"denominator.recorded_date\"\n )\n }} \n\n)\n\n, denominator_patients_disqualified_from_procedure as (\n \n select \n denominator.patient_id\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end \n from denominator\n left join qualifying_procedures \n on denominator.patient_id = qualifying_procedures.patient_id\n where qualifying_procedures.patient_id is null\n\n)\n\n-- pharmacy_claim begin\n\n, osteo_rx_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) \n in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, pharmacy_claims_osteo_related as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code \n from {{ref('quality_measures__stg_pharmacy_claim')}} as pharmacy_claims\n inner join osteo_rx_codes\n on pharmacy_claims.ndc_code = osteo_rx_codes.code\n and lower(osteo_rx_codes.code_system) = 'ndc'\n\n)\n\n, qualifying_pharmacy_claims as (\n\n select \n pharmacy_claims_osteo_related.patient_id\n , pharmacy_claims_osteo_related.dispensing_date\n , pharmacy_claims_osteo_related.ndc_code\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from pharmacy_claims_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on pharmacy_claims_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and pharmacy_claims_osteo_related.dispensing_date \n between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = +6\n , from_date_or_timestamp = \"denominator_patients_disqualified_from_procedure.recorded_date\"\n )\n }}\n)\n\n-- medication begin\n\n, medication_osteo_related as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n from {{ref('quality_measures__stg_core__medication')}} as medications\n inner join osteo_rx_codes\n on medications.source_code = osteo_rx_codes.code\n and medications.source_code_type = osteo_rx_codes.code_system\n\n)\n\n, qualifying_medications as (\n\n select\n medication_osteo_related.patient_id\n , medication_osteo_related.encounter_id\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from medication_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on medication_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and coalesce(medication_osteo_related.prescribing_date, medication_osteo_related.dispensing_date) between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n {{ dbt.dateadd (\n datepart = \"month\"\n , interval = +6\n , from_date_or_timestamp = \"denominator_patients_disqualified_from_procedure.recorded_date\"\n )\n }}\n\n)\n\n, numerator as (\n\n select\n qualifying_procedures.patient_id\n , qualifying_procedures.performance_period_begin\n , qualifying_procedures.performance_period_end\n , qualifying_procedures.measure_id\n , qualifying_procedures.measure_name\n , qualifying_procedures.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_procedures\n\n union all\n\n select \n qualifying_pharmacy_claims.patient_id\n , qualifying_pharmacy_claims.performance_period_begin\n , qualifying_pharmacy_claims.performance_period_end\n , qualifying_pharmacy_claims.measure_id\n , qualifying_pharmacy_claims.measure_name\n , qualifying_pharmacy_claims.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_pharmacy_claims\n\n union all\n\n select \n qualifying_medications.patient_id\n , qualifying_medications.performance_period_begin\n , qualifying_medications.performance_period_end\n , qualifying_medications.measure_id\n , qualifying_medications.measure_name\n , qualifying_medications.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_medications\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , recorded_date\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n \n)\n\n, osteo_procedure_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests icd10pcs'\n , 'bone mineral density tests hcpcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n , 'central dual energy x-ray absorptiometry (dxa)'\n , 'spinal densitometry x-ray' \n , 'ultrasonography for densitometry' \n , 'ct bone density axial'\n , 'peripheral dual-energy x-ray absorptiometry (dxa)'\n , 'osteoporosis medication'\n )\n\n)\n\n, procedures_osteo_related as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procs\n inner join osteo_procedure_codes\n on coalesce(procs.normalized_code, procs.source_code) = osteo_procedure_codes.code\n and coalesce(procs.normalized_code_type, procs.source_code_type) = osteo_procedure_codes.code_system\n\n)\n\n, qualifying_procedures as (\n\n select\n procedures_osteo_related.patient_id\n , procedures_osteo_related.procedure_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from procedures_osteo_related\n inner join denominator\n on procedures_osteo_related.patient_id = denominator.patient_id\n and \n procedures_osteo_related.procedure_date between\n denominator.recorded_date \n and\n \n\n dateadd(\n month,\n 6,\n denominator.recorded_date\n )\n\n \n\n)\n\n, denominator_patients_disqualified_from_procedure as (\n \n select \n denominator.patient_id\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end \n from denominator\n left join qualifying_procedures \n on denominator.patient_id = qualifying_procedures.patient_id\n where qualifying_procedures.patient_id is null\n\n)\n\n-- pharmacy_claim begin\n\n, osteo_rx_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) \n in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, pharmacy_claims_osteo_related as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code \n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join osteo_rx_codes\n on pharmacy_claims.ndc_code = osteo_rx_codes.code\n and lower(osteo_rx_codes.code_system) = 'ndc'\n\n)\n\n, qualifying_pharmacy_claims as (\n\n select \n pharmacy_claims_osteo_related.patient_id\n , pharmacy_claims_osteo_related.dispensing_date\n , pharmacy_claims_osteo_related.ndc_code\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from pharmacy_claims_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on pharmacy_claims_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and pharmacy_claims_osteo_related.dispensing_date \n between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n)\n\n-- medication begin\n\n, medication_osteo_related as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication as medications\n inner join osteo_rx_codes\n on medications.source_code = osteo_rx_codes.code\n and medications.source_code_type = osteo_rx_codes.code_system\n\n)\n\n, qualifying_medications as (\n\n select\n medication_osteo_related.patient_id\n , medication_osteo_related.encounter_id\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from medication_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on medication_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and coalesce(medication_osteo_related.prescribing_date, medication_osteo_related.dispensing_date) between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n\n)\n\n, numerator as (\n\n select\n qualifying_procedures.patient_id\n , qualifying_procedures.performance_period_begin\n , qualifying_procedures.performance_period_end\n , qualifying_procedures.measure_id\n , qualifying_procedures.measure_name\n , qualifying_procedures.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_procedures\n\n union all\n\n select \n qualifying_pharmacy_claims.patient_id\n , qualifying_pharmacy_claims.performance_period_begin\n , qualifying_pharmacy_claims.performance_period_end\n , qualifying_pharmacy_claims.measure_id\n , qualifying_pharmacy_claims.measure_name\n , qualifying_pharmacy_claims.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_pharmacy_claims\n\n union all\n\n select \n qualifying_medications.patient_id\n , qualifying_medications.performance_period_begin\n , qualifying_medications.performance_period_end\n , qualifying_medications.measure_id\n , qualifying_medications.measure_name\n , qualifying_medications.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_medications\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_exclusions"], "alias": "_int_nqf0053_exclusions", "checksum": {"name": "sha256", "checksum": "5d7142eb4add55b0f85850bba81637430ce395d30883df744aaaab21f0f6f3dd"}, "config": {"enabled": true, "alias": "_int_nqf0053_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.933771, "relation_name": "cms_synthetic.quality_measures._int_nqf0053_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith\n\ncombined_exclusions as (\n\n select\n exclusions.*\n , denominator.age\n from {{ ref('quality_measures__int_nqf0053_exclusions_stage_1') }} as exclusions\n inner join {{ref('quality_measures__int_nqf0053_denominator')}} as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'institutional_snp'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'advanced_illness'\n , 'dementia'\n )\n and age between 66 and 80\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'measure specific exclusion for defined window'\n and age >= 81\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'measure specific exclusion for procedure medication'\n , 'hospice_palliative'\n )\n\n)\n\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_exclusions_stage_1", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0053_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0053_osteoporosis_management_in_women_who_had_a_fracture/quality_measures__int_nqf0053_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith\n\ncombined_exclusions as (\n\n select\n exclusions.*\n , denominator.age\n from cms_synthetic.quality_measures._int_nqf0053_exclusions_stage_1 as exclusions\n inner join cms_synthetic.quality_measures._int_nqf0053_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'institutional_snp'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'advanced_illness'\n , 'dementia'\n )\n and age between 66 and 80\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'measure specific exclusion for defined window'\n and age >= 81\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'measure specific exclusion for procedure medication'\n , 'hospice_palliative'\n )\n\n)\n\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_numerator.sql", "original_file_path": "models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_numerator"], "alias": "_int_adh_diabetes_numerator", "checksum": {"name": "sha256", "checksum": "7d0d7e386411c95aca3ef9c7fa4daecc35a26573d406a4464070c7adfa5d30cb"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adherence": {"name": "adherence", "description": "The degree to which the person behaviour corresponds with taking a medicine optimally in percentage.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.016431, "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_adh_diabetes_denominator') }}\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from {{ ref('quality_measures__int_adh_diabetes__performance_period') }}\n\n)\n\n/*\n The below 3 cte identifies periods of continuous medication use for each patient by:\n 1. Assigning a row number and tracking the previous medication per patient.\n 2. Flagging when a medication change occurs.\n 3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dr\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dr\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dr \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\n The ctes below calculates adjusted medication fill dates,\n groups fills by continuous periods of use and ensures accurate start and end dates based \n on previous fills and the performance period.\n*/\n\n, fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = -1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"day\"\n , interval = \"days_supply\"\n , from_date_or_timestamp = \"dispensing_date\"\n )\n ) }} as theoretical_end_date\n from final_groups\n\n)\n\n, previous_fill_end_date as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_end_date\n from fills\n\n)\n\n, adjusted_fills as (\n \n /* Adjust start dates based on the previous fill's end date + 1,\n or use the current rx_fill_date */\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp = \"previous_end_date\"\n ) }}\n )\n , dispensing_date\n ) as adjusted_start_date\n from previous_fill_end_date\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , least(\n {{ dbt.dateadd (\n datepart = \"day\"\n , interval = -1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"day\"\n , interval = \"days_supply\"\n , from_date_or_timestamp = \"adjusted_start_date\"\n )\n ) }}\n , performance_period_end\n ) as final_end_date\n from adjusted_fills\n inner join performance_end\n on adjusted_fills.adjusted_start_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , min(adjusted_start_date) over(partition by patient_id, group_id) as first_disp_date\n , max(adjusted_start_date) over(partition by patient_id, group_id) as last_disp_date\n from final_fills\n\n)\n\n, last_med_end_groupwise as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , first_disp_date\n , last_disp_date\n , max(\n case\n when adjusted_start_date = last_disp_date\n then days_supply\n else null\n end) over (partition by patient_id, group_id) as last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n 1. Calculates the total covered days per medication group per patient\n 2. Then calculates the overlap between groups of medication per patient\n 3. Finally calculates the actual total covered days for each patient\n*/\n\n, covered_days_per_group as (\n \n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n , sum( 1 + {{ dbt.datediff (\n datepart = 'day'\n , first_date = 'adjusted_start_date'\n , second_date = 'final_end_date'\n )\n }} ) as covered_days\n from last_med_end_groupwise\n group by \n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n\n)\n\n, final_with_lag as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag(last_disp_date) over(partition by patient_id order by first_disp_date) as lag_date\n , lag(last_days_supply) over(partition by patient_id order by first_disp_date) as lag_days_supply\n from covered_days_per_group\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag_date\n , case\n when first_disp_date < \n {{ dbt.dateadd (\n datepart = \"day\"\n , interval = \"lag_days_supply\"\n , from_date_or_timestamp = \"lag_date\" \n ) }}\n then\n {{ dbt.datediff (\n datepart = 'day'\n , first_date = \"first_disp_date\"\n , second_date = \n dbt.dateadd (\n datepart = \"day\"\n , interval = \"lag_days_supply\"\n , from_date_or_timestamp = \"lag_date\" \n )\n ) }}\n else 0\n end as overlap\n from final_with_lag\n\n)\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, relevant_patients_from_deno as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days / days_in_treatment_period as {{ dbt.type_numeric() }}), 4) as adherence\n , dispensing_date as evidence_date\n , days_supply as evidence_value\n from final_covered_days\n inner join denominator\n on final_covered_days.patient_id = denominator.patient_id\n \n)\n\n, numerator as (\n\n select\n patient_id\n , adherence * 100 as adherence --percent conversion\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from relevant_patients_from_deno\n where adherence >= 0.8\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(adherence as {{ dbt.type_numeric() }}) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adh_diabetes_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.datediff", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_numerator.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n/*\n The below 3 cte identifies periods of continuous medication use for each patient by:\n 1. Assigning a row number and tracking the previous medication per patient.\n 2. Flagging when a medication change occurs.\n 3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dr\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dr\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dr \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\n The ctes below calculates adjusted medication fill dates,\n groups fills by continuous periods of use and ensures accurate start and end dates based \n on previous fills and the performance period.\n*/\n\n, fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n, previous_fill_end_date as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_end_date\n from fills\n\n)\n\n, adjusted_fills as (\n \n /* Adjust start dates based on the previous fill's end date + 1,\n or use the current rx_fill_date */\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_start_date\n from previous_fill_end_date\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_start_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as final_end_date\n from adjusted_fills\n inner join performance_end\n on adjusted_fills.adjusted_start_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , min(adjusted_start_date) over(partition by patient_id, group_id) as first_disp_date\n , max(adjusted_start_date) over(partition by patient_id, group_id) as last_disp_date\n from final_fills\n\n)\n\n, last_med_end_groupwise as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , first_disp_date\n , last_disp_date\n , max(\n case\n when adjusted_start_date = last_disp_date\n then days_supply\n else null\n end) over (partition by patient_id, group_id) as last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n 1. Calculates the total covered days per medication group per patient\n 2. Then calculates the overlap between groups of medication per patient\n 3. Finally calculates the actual total covered days for each patient\n*/\n\n, covered_days_per_group as (\n \n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_start_date,\n final_end_date\n ) ) as covered_days\n from last_med_end_groupwise\n group by \n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n\n)\n\n, final_with_lag as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag(last_disp_date) over(partition by patient_id order by first_disp_date) as lag_date\n , lag(last_days_supply) over(partition by patient_id order by first_disp_date) as lag_days_supply\n from covered_days_per_group\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag_date\n , case\n when first_disp_date < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n first_disp_date,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from final_with_lag\n\n)\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, relevant_patients_from_deno as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days / days_in_treatment_period as numeric(28,6)), 4) as adherence\n , dispensing_date as evidence_date\n , days_supply as evidence_value\n from final_covered_days\n inner join denominator\n on final_covered_days.patient_id = denominator.patient_id\n \n)\n\n, numerator as (\n\n select\n patient_id\n , adherence * 100 as adherence --percent conversion\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from relevant_patients_from_deno\n where adherence >= 0.8\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_denominator.sql", "original_file_path": "models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_denominator"], "alias": "_int_adh_diabetes_denominator", "checksum": {"name": "sha256", "checksum": "e44750a13cc55e36ebd6d3549ffd732645acba95a97da6fd5e61a475b57bcd4b"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during latest encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days the filled medication lasts for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_in_treatment_period": {"name": "days_in_treatment_period", "description": "Number of days from first dispensing_date to performance_period_end in the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.010876, "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith diabetics_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'pqa diabetes medications'\n )\n\n)\n\n, rx_diabetes as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claims\n inner join diabetics_codes\n on pharmacy_claims.ndc_code = diabetics_codes.code\n and lower(diabetics_codes.code_system) = 'ndc'\n\n)\n\n, rx_diabetes_in_measurement_period as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , performance_period_end -- to use in latter cte for days in treatment period calculation\n from rx_diabetes\n inner join {{ ref('quality_measures__int_adh_diabetes__performance_period') }} pp\n on dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, rx_fill_order as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n , dense_rank() over (\n partition by \n patient_id\n , performance_period_end\n order by dispensing_date\n ) as dr\n from rx_diabetes_in_measurement_period\n\n)\n\n, rx_first_fill as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n from rx_fill_order\n where dr = 1\n \n)\n\n, timely_fill_check as (\n\n select\n patient_id\n , ( 1 + {{ dbt.datediff (\n datepart = 'day'\n , first_date = 'dispensing_date'\n , second_date = 'performance_period_end'\n )\n }} )\n as days_in_treatment_period\n /* \n Performance Period end minus dispensing date results in \n second_date non-inclusive difference, so to include both of these days\n 1 day is added\n */\n from rx_first_fill\n\n)\n\n, first_check_passed_patients as (\n\n select\n patient_id\n , days_in_treatment_period\n from timely_fill_check\n where days_in_treatment_period > 90\n\n)\n\n, second_check_passed_patients as (\n\n select\n patient_id\n from rx_fill_order\n where dr = 2\n\n)\n\n, qualifying_patients as (\n\n select\n first_check_passed_patients.patient_id\n , first_check_passed_patients.days_in_treatment_period\n from first_check_passed_patients\n inner join second_check_passed_patients\n on first_check_passed_patients.patient_id = second_check_passed_patients.patient_id \n\n)\n\n, qualifying_patients_with_age as (\n \n select\n patients.patient_id\n , floor({{ datediff('birth_date', 'pp.performance_period_begin', 'hour') }} / 8760.0) as age\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__stg_core__patient') }} patients\n inner join qualifying_patients\n on patients.patient_id = qualifying_patients.patient_id\n cross join {{ ref('quality_measures__int_adh_diabetes__performance_period') }} pp\n where patients.death_date is null\n\n)\n/*\n Extracting related fields like dispensing_date, ndc_code and days_supply of qualified patients\n to avoid redundant computations in numerator model\n*/\n\n, qualifying_patients_all_claim_info as (\n\n select\n qualifying_patients_with_age.patient_id\n , qualifying_patients_with_age.age\n , rx_diabetes_in_measurement_period.dispensing_date\n , rx_diabetes_in_measurement_period.ndc_code\n , rx_diabetes_in_measurement_period.days_supply\n , qualifying_patients_with_age.days_in_treatment_period\n , qualifying_patients_with_age.performance_period_begin\n , qualifying_patients_with_age.performance_period_end\n , qualifying_patients_with_age.measure_id\n , qualifying_patients_with_age.measure_name\n , qualifying_patients_with_age.measure_version\n from qualifying_patients_with_age\n inner join rx_diabetes_in_measurement_period\n on qualifying_patients_with_age.patient_id = rx_diabetes_in_measurement_period.patient_id\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from qualifying_patients_all_claim_info\n where age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(dispensing_date as date) as dispensing_date\n , cast(ndc_code as {{ dbt.type_string() }}) as ndc_code\n , cast(days_supply as integer) as days_supply\n , cast(days_in_treatment_period as integer) as days_in_treatment_period\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from denominator\n\n)\n\nselect\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), diabetics_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa diabetes medications'\n )\n\n)\n\n, rx_diabetes as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join diabetics_codes\n on pharmacy_claims.ndc_code = diabetics_codes.code\n and lower(diabetics_codes.code_system) = 'ndc'\n\n)\n\n, rx_diabetes_in_measurement_period as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , performance_period_end -- to use in latter cte for days in treatment period calculation\n from rx_diabetes\n inner join cms_synthetic.quality_measures._int_adh_diabetes__performance_period pp\n on dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, rx_fill_order as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n , dense_rank() over (\n partition by \n patient_id\n , performance_period_end\n order by dispensing_date\n ) as dr\n from rx_diabetes_in_measurement_period\n\n)\n\n, rx_first_fill as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n from rx_fill_order\n where dr = 1\n \n)\n\n, timely_fill_check as (\n\n select\n patient_id\n , ( 1 + datediff(\n day,\n dispensing_date,\n performance_period_end\n ) )\n as days_in_treatment_period\n /* \n Performance Period end minus dispensing date results in \n second_date non-inclusive difference, so to include both of these days\n 1 day is added\n */\n from rx_first_fill\n\n)\n\n, first_check_passed_patients as (\n\n select\n patient_id\n , days_in_treatment_period\n from timely_fill_check\n where days_in_treatment_period > 90\n\n)\n\n, second_check_passed_patients as (\n\n select\n patient_id\n from rx_fill_order\n where dr = 2\n\n)\n\n, qualifying_patients as (\n\n select\n first_check_passed_patients.patient_id\n , first_check_passed_patients.days_in_treatment_period\n from first_check_passed_patients\n inner join second_check_passed_patients\n on first_check_passed_patients.patient_id = second_check_passed_patients.patient_id \n\n)\n\n, qualifying_patients_with_age as (\n \n select\n patients.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from __dbt__cte___stg_patient patients\n inner join qualifying_patients\n on patients.patient_id = qualifying_patients.patient_id\n cross join cms_synthetic.quality_measures._int_adh_diabetes__performance_period pp\n where patients.death_date is null\n\n)\n/*\n Extracting related fields like dispensing_date, ndc_code and days_supply of qualified patients\n to avoid redundant computations in numerator model\n*/\n\n, qualifying_patients_all_claim_info as (\n\n select\n qualifying_patients_with_age.patient_id\n , qualifying_patients_with_age.age\n , rx_diabetes_in_measurement_period.dispensing_date\n , rx_diabetes_in_measurement_period.ndc_code\n , rx_diabetes_in_measurement_period.days_supply\n , qualifying_patients_with_age.days_in_treatment_period\n , qualifying_patients_with_age.performance_period_begin\n , qualifying_patients_with_age.performance_period_end\n , qualifying_patients_with_age.measure_id\n , qualifying_patients_with_age.measure_name\n , qualifying_patients_with_age.measure_version\n from qualifying_patients_with_age\n inner join rx_diabetes_in_measurement_period\n on qualifying_patients_with_age.patient_id = rx_diabetes_in_measurement_period.patient_id\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from qualifying_patients_all_claim_info\n where age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(dispensing_date as date) as dispensing_date\n , cast(ndc_code as TEXT) as ndc_code\n , cast(days_supply as integer) as days_supply\n , cast(days_in_treatment_period as integer) as days_in_treatment_period\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from denominator\n\n)\n\nselect\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_long.sql", "original_file_path": "models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_long"], "alias": "_int_adh_diabetes_long", "checksum": {"name": "sha256", "checksum": "adce1029f51dd544dc2c7562ff184b16530508179982170a606f53bd40df9d43"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.014466, "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_adh_diabetes_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_adh_diabetes_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_adh_diabetes_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adh_diabetes_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_numerator", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_adh_diabetes_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_adh_diabetes_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes__performance_period"], "alias": "_int_adh_diabetes__performance_period", "checksum": {"name": "sha256", "checksum": "b29f3f10306e00ca4cfcc0bb888e6b7ce3c1f67e743a92ce6c93107522ba6075"}, "config": {"enabled": true, "alias": "_int_adh_diabetes__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Medication Adherence for Diabetes Medications.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0072691, "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'ADH-Diabetes')\n{%- endset -%}\n\n{%- set measure_name -%}\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'ADH-Diabetes')\n{%- endset -%}\n\n{%- set measure_version -%}\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'ADH-Diabetes')\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_exclusions"], "alias": "_int_adh_diabetes_exclusions", "checksum": {"name": "sha256", "checksum": "57470d7b5760faf9b9f2a759bf133349cddfc0ca00769c64928beed1b5302584"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.012735, "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n\n select \n performance_period_begin\n from {{ ref('quality_measures__int_adh_diabetes__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n\n select \n performance_period_end\n from {{ ref('quality_measures__int_adh_diabetes__performance_period') }}\n\n)\n{%- endset -%}\n\nwith denominator as (\n \n select\n patient_id\n from {{ ref('quality_measures__int_adh_diabetes_denominator') }}\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'pqa esrd'\n , 'pqa insulin medications'\n )\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n where recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as exclusion_date\n , exclusion_codes.concept_name as exclusion_reason\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_exclusions as (\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and exclusion_codes.code_system = 'ndc'\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from pharmacy_exclusions\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh_diabetes/quality_measures__int_adh_diabetes_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa esrd'\n , 'pqa insulin medications'\n )\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as exclusion_date\n , exclusion_codes.concept_name as exclusion_reason\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_exclusions as (\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and exclusion_codes.code_system = 'ndc'\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from pharmacy_exclusions\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adhras__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras__performance_period"], "alias": "_int_adhras__performance_period", "checksum": {"name": "sha256", "checksum": "e158d71f762d561cfbf2b0002e9b78390db9052c95625b076b1a18d0980d14bb"}, "config": {"enabled": true, "alias": "_int_adhras__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Medication Adherence for Hypertension\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0179908, "relation_name": "cms_synthetic.quality_measures._int_adhras__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n\n(\n select id\n from {{ ref('quality_measures__measures') }}\n where id = 'ADH-RAS'\n)\n\n{%- endset -%}\n\n{%- set measure_name -%}\n\n(\n select name\n from {{ ref('quality_measures__measures') }}\n where id = 'ADH-RAS'\n)\n\n{%- endset -%}\n\n{%- set measure_version -%}\n\n(\n select version\n from {{ ref('quality_measures__measures') }}\n where id = 'ADH-RAS'\n)\n\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((\n select id\n from cms_synthetic.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_id\n , cast((\n select name\n from cms_synthetic.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_name\n , cast((\n select version\n from cms_synthetic.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adhras_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_long.sql", "original_file_path": "models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_long"], "alias": "_int_adhras_long", "checksum": {"name": "sha256", "checksum": "9866989c447ad52f065bc46772f89de63f31977f3b907026666861058e5a7020"}, "config": {"enabled": true, "alias": "_int_adhras_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of ADH-RAS, Medication Adherence for Hypertension before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0228212, "relation_name": "cms_synthetic.quality_measures._int_adhras_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_adhras_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_adhras_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_adhras_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adhras_numerator", "package": null, "version": null}, {"name": "quality_measures__int_adhras_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_numerator", "model.the_tuva_project.quality_measures__int_adhras_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_adhras_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_adhras_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_adhras_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adhras_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_denominator.sql", "original_file_path": "models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_denominator"], "alias": "_int_adhras_denominator", "checksum": {"name": "sha256", "checksum": "40fce4386299093117f96d2e14567e90dae90745cb5d8f2f5261032b885949a7"}, "config": {"enabled": true, "alias": "_int_adhras_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of ADH-RAS, Medication Adherence for Hypertension\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_dispensing_date": {"name": "first_dispensing_date", "description": "Date the first prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days supply.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.019777, "relation_name": "cms_synthetic.quality_measures._int_adhras_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n from {{ ref('quality_measures__int_adhras__performance_period') }}\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) = 'pqa rasa medications'\n\n)\n\n, pharmacy_claim as (\n\n select \n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from {{ ref('quality_measures__stg_pharmacy_claim') }}\n\n)\n\n, patient_with_claim as (\n\n select\n pharmacy_claim.patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n from pharmacy_claim \n inner join visit_codes\n on pharmacy_claim.ndc_code = visit_codes.code\n \n)\n\n, patient_within_performance_period as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n from patient_with_claim as claim_patient\n inner join performance_period as pp\n on claim_patient.dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, patient_with_rank as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n from patient_within_performance_period\n\n)\n\n, patient_with_first_dispensing_date as (\n\n select\n patient_id\n , dispensing_date as first_dispensing_date\n from patient_with_rank\n where dense_rank = 1\n\n)\n\n/*\ntreatment period days is abbreviated as tpd\n*/\n\n, patient_with_tpd as (\n\n select\n patients1.patient_id\n , patients1.dispensing_date\n , patients2.first_dispensing_date\n , patients1.days_supply\n , {{ datediff('first_dispensing_date', 'performance_period_end', 'day') }} as tpd\n from patient_within_performance_period as patients1\n inner join patient_with_first_dispensing_date as patients2\n on patients1.patient_id = patients2.patient_id\n\n)\n\n, first_check_patient as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n from patient_with_tpd\n where tpd > 89\n \n)\n\n, second_check_patient as (\n\n select\n patient_id\n , ndc_code\n from patient_with_rank\n where dense_rank = 2\n\n)\n\n, both_check_patient as (\n\n select\n valid_patients1.patient_id\n , valid_patients1.dispensing_date\n , valid_patients1.first_dispensing_date\n , valid_patients1.days_supply\n , valid_patients2.ndc_code\n from first_check_patient as valid_patients1\n inner join second_check_patient as valid_patients2\n on valid_patients1.patient_id = valid_patients2.patient_id\n \n)\n\n, patient_with_age as (\n\n select\n valid_patients1.patient_id\n , floor({{ datediff('birth_date', 'pp.performance_period_begin', 'hour') }} / 8760.0) as age\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from {{ ref('quality_measures__stg_core__patient') }} as patient\n inner join both_check_patient as valid_patients1\n on patient.patient_id = valid_patients1.patient_id\n cross join performance_period as pp\n where patient.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from patient_with_age \n where age > 17\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(first_dispensing_date as date) as first_dispensing_date\n , cast(days_supply as integer) as days_supply\n , cast(ndc_code as {{ dbt.type_string() }}) as ndc_code\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) = 'pqa rasa medications'\n\n)\n\n, pharmacy_claim as (\n\n select \n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, patient_with_claim as (\n\n select\n pharmacy_claim.patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n from pharmacy_claim \n inner join visit_codes\n on pharmacy_claim.ndc_code = visit_codes.code\n \n)\n\n, patient_within_performance_period as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n from patient_with_claim as claim_patient\n inner join performance_period as pp\n on claim_patient.dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, patient_with_rank as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n from patient_within_performance_period\n\n)\n\n, patient_with_first_dispensing_date as (\n\n select\n patient_id\n , dispensing_date as first_dispensing_date\n from patient_with_rank\n where dense_rank = 1\n\n)\n\n/*\ntreatment period days is abbreviated as tpd\n*/\n\n, patient_with_tpd as (\n\n select\n patients1.patient_id\n , patients1.dispensing_date\n , patients2.first_dispensing_date\n , patients1.days_supply\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as tpd\n from patient_within_performance_period as patients1\n inner join patient_with_first_dispensing_date as patients2\n on patients1.patient_id = patients2.patient_id\n\n)\n\n, first_check_patient as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n from patient_with_tpd\n where tpd > 89\n \n)\n\n, second_check_patient as (\n\n select\n patient_id\n , ndc_code\n from patient_with_rank\n where dense_rank = 2\n\n)\n\n, both_check_patient as (\n\n select\n valid_patients1.patient_id\n , valid_patients1.dispensing_date\n , valid_patients1.first_dispensing_date\n , valid_patients1.days_supply\n , valid_patients2.ndc_code\n from first_check_patient as valid_patients1\n inner join second_check_patient as valid_patients2\n on valid_patients1.patient_id = valid_patients2.patient_id\n \n)\n\n, patient_with_age as (\n\n select\n valid_patients1.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from __dbt__cte___stg_patient as patient\n inner join both_check_patient as valid_patients1\n on patient.patient_id = valid_patients1.patient_id\n cross join performance_period as pp\n where patient.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from patient_with_age \n where age > 17\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(first_dispensing_date as date) as first_dispensing_date\n , cast(days_supply as integer) as days_supply\n , cast(ndc_code as TEXT) as ndc_code\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adhras_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_numerator.sql", "original_file_path": "models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_numerator"], "alias": "_int_adhras_numerator", "checksum": {"name": "sha256", "checksum": "54aa90c43b6eb88245c1ca6e7ceaa9a693f5953e12e878a84dcb20a1254a839f"}, "config": {"enabled": true, "alias": "_int_adhras_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of ADH-RAS, Medication Adherence for Hypertension\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adherence": {"name": "adherence", "description": "The extent to which a person's behaviour corresponds with taking a medicine optimally.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.024504, "relation_name": "cms_synthetic.quality_measures._int_adhras_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_adhras_denominator') }}\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from {{ ref('quality_measures__int_adhras__performance_period') }}\n\n)\n\n/*\nThe below 3 cte identifies periods of continuous medication use for each patient by:\n1. Assigning a row number and tracking the previous medication per patient.\n2. Flagging when a medication change occurs.\n3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dense_rank \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\nThis cte theoretical_end_dates to final_fills calculates adjusted medication fill dates, \ngroups fills by continuous periods of use and ensures accurate start and end dates based \non previous fills and the performance period.\n*/\n\n, theoretical_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = -1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"day\"\n , interval = \"days_supply\"\n , from_date_or_timestamp = \"dispensing_date\"\n )\n ) }} as theoretical_end_date\n from final_groups\n\n)\n\n/* \nAdjust start dates based on the previous fill's end date + 1,\nor use the current rx_fill_date \n*/\n\n, previous_fill_end_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_fill_end_date\n from theoretical_end_dates\n\n)\n\n, adjusted_fill_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp = \"previous_fill_end_date\"\n ) }}\n )\n , dispensing_date\n ) as adjusted_fill_date\n from previous_fill_end_dates\n\n)\n\n\n, actual_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , least(\n {{ dbt.dateadd (\n datepart = \"day\"\n , interval = -1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"day\"\n , interval = \"days_supply\"\n , from_date_or_timestamp = \"adjusted_fill_date\"\n )\n ) }}\n , performance_period_end\n ) as actual_end_date\n from adjusted_fill_dates\n inner join performance_end\n on adjusted_fill_dates.adjusted_fill_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , min(adjusted_fill_date) over(partition by patient_id, group_id) as group_first\n , max(adjusted_fill_date) over(partition by patient_id, group_id) as group_last\n from actual_end_dates\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , group_first\n , group_last\n , max(\n case\n when adjusted_fill_date = group_last\n then days_supply\n else 0\n end) over (partition by patient_id, group_id) as group_last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n1. Calculates the total covered days per every medication group per patient\n2. Then, calculates the overlap between groups of medication per patient.\n3. Then, calculates the actual total covered days for each patient.\n*/\n\n, covered_days_per_groups as (\n \n select\n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n , sum( 1 + {{ dbt.datediff (\n datepart = 'day'\n , first_date = 'adjusted_fill_date'\n , second_date = 'actual_end_date'\n )\n }} ) as covered_days_per_group\n from final_fills\n group by \n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n\n)\n\n, with_lag as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag(group_last) over(partition by patient_id order by group_first) as lag_date\n , lag(group_last_days_supply) over(partition by patient_id order by group_first) as lag_days_supply\n from covered_days_per_groups\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag_date\n , case\n when group_first < \n {{ dbt.dateadd (\n datepart = \"day\"\n , interval = \"lag_days_supply\"\n , from_date_or_timestamp = \"lag_date\" \n ) }}\n then\n {{ dbt.datediff (\n datepart = 'day'\n , first_date = \"group_first\"\n , second_date = \n dbt.dateadd (\n datepart = \"day\"\n , interval = \"lag_days_supply\"\n , from_date_or_timestamp = \"lag_date\" \n )\n ) }}\n else 0\n end as overlap\n from with_lag\n\n)\n\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days_per_group) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, patient_with_treatment_period_days as (\n select\n patient_id\n , {{ datediff('first_dispensing_date', 'performance_period_end', 'day') }} as treatment_period_days\n from denominator\n\n)\n\n, patient_with_pdc as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days * 100 / treatment_period_days as {{ dbt.type_numeric() }}), 4) as adherence\n from final_covered_days\n inner join patient_with_treatment_period_days \n on final_covered_days.patient_id = patient_with_treatment_period_days.patient_id\n\n)\n\n/*\nSelects only the patient whose pdc is greater than 80%.\n*/\n\n, valid_patients as (\n\n select \n patient_with_pdc.patient_id\n , adherence\n , denominator.dispensing_date as evidence_date\n , denominator.days_supply as evidence_value\n , 1 as numerator_flag\n from patient_with_pdc \n inner join denominator\n on patient_with_pdc.patient_id = denominator.patient_id \n where patient_with_pdc.adherence >= 80.00 \n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(adherence as {{ dbt.type_numeric() }}) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from valid_patients\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.datediff", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras__performance_period"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_numerator.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_adhras_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n/*\nThe below 3 cte identifies periods of continuous medication use for each patient by:\n1. Assigning a row number and tracking the previous medication per patient.\n2. Flagging when a medication change occurs.\n3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dense_rank \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\nThis cte theoretical_end_dates to final_fills calculates adjusted medication fill dates, \ngroups fills by continuous periods of use and ensures accurate start and end dates based \non previous fills and the performance period.\n*/\n\n, theoretical_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n/* \nAdjust start dates based on the previous fill's end date + 1,\nor use the current rx_fill_date \n*/\n\n, previous_fill_end_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_fill_end_date\n from theoretical_end_dates\n\n)\n\n, adjusted_fill_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_fill_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_fill_date\n from previous_fill_end_dates\n\n)\n\n\n, actual_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_fill_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as actual_end_date\n from adjusted_fill_dates\n inner join performance_end\n on adjusted_fill_dates.adjusted_fill_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , min(adjusted_fill_date) over(partition by patient_id, group_id) as group_first\n , max(adjusted_fill_date) over(partition by patient_id, group_id) as group_last\n from actual_end_dates\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , group_first\n , group_last\n , max(\n case\n when adjusted_fill_date = group_last\n then days_supply\n else 0\n end) over (partition by patient_id, group_id) as group_last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n1. Calculates the total covered days per every medication group per patient\n2. Then, calculates the overlap between groups of medication per patient.\n3. Then, calculates the actual total covered days for each patient.\n*/\n\n, covered_days_per_groups as (\n \n select\n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_fill_date,\n actual_end_date\n ) ) as covered_days_per_group\n from final_fills\n group by \n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n\n)\n\n, with_lag as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag(group_last) over(partition by patient_id order by group_first) as lag_date\n , lag(group_last_days_supply) over(partition by patient_id order by group_first) as lag_days_supply\n from covered_days_per_groups\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag_date\n , case\n when group_first < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n group_first,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from with_lag\n\n)\n\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days_per_group) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, patient_with_treatment_period_days as (\n select\n patient_id\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as treatment_period_days\n from denominator\n\n)\n\n, patient_with_pdc as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days * 100 / treatment_period_days as numeric(28,6)), 4) as adherence\n from final_covered_days\n inner join patient_with_treatment_period_days \n on final_covered_days.patient_id = patient_with_treatment_period_days.patient_id\n\n)\n\n/*\nSelects only the patient whose pdc is greater than 80%.\n*/\n\n, valid_patients as (\n\n select \n patient_with_pdc.patient_id\n , adherence\n , denominator.dispensing_date as evidence_date\n , denominator.days_supply as evidence_value\n , 1 as numerator_flag\n from patient_with_pdc \n inner join denominator\n on patient_with_pdc.patient_id = denominator.patient_id \n where patient_with_pdc.adherence >= 80.00 \n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from valid_patients\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_adhras_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_exclusions"], "alias": "_int_adhras_exclusions", "checksum": {"name": "sha256", "checksum": "15c95ed1ccd0fc2274982f97527a7c916309f966a55d9599ea19b399b68fc0e5"}, "config": {"enabled": true, "alias": "_int_adhras_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of ADH-RAS, Medication Adherence for Hypertension\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.021276, "relation_name": "cms_synthetic.quality_measures._int_adhras_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_adhras__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_adhras__performance_period') }}\n\n)\n{%- endset -%}\n\nwith denominator as (\n\n select\n patient_id\n from {{ ref('quality_measures__int_adhras_denominator')}}\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where concept_name in (\n 'PQA ESRD'\n , 'PQA Sacubitril Valsartan Medications'\n )\n\n)\n\n, valid_esrd as (\n\n select\n condition.patient_id\n , condition.recorded_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from {{ ref('quality_measures__stg_core__condition') }} as condition\n inner join codes \n on coalesce(condition.normalized_code, condition.source_code) = codes.code \n and coalesce(condition.normalized_code_type, condition.source_code_type) = codes.code_system\n where condition.recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, sacubitril_pharmacy_claim as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claim\n inner join codes\n on pharmacy_claim.ndc_code = codes.code \n where pharmacy_claim.dispensing_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, exclusions as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_esrd\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason \n from sacubitril_pharmacy_claim\n\n)\n\n, measure_exclusions as (\n\n select \n exclusions.patient_id\n , exclusion_date\n , exclusion_reason\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from measure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run \nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adhras_denominator", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/adh-ras_medication_adherence_for_hypertension/quality_measures__int_adhras_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), denominator as (\n\n select\n patient_id\n from cms_synthetic.quality_measures._int_adhras_denominator\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name in (\n 'PQA ESRD'\n , 'PQA Sacubitril Valsartan Medications'\n )\n\n)\n\n, valid_esrd as (\n\n select\n condition.patient_id\n , condition.recorded_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_condition as condition\n inner join codes \n on coalesce(condition.normalized_code, condition.source_code) = codes.code \n and coalesce(condition.normalized_code_type, condition.source_code_type) = codes.code_system\n where condition.recorded_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, sacubitril_pharmacy_claim as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claim\n inner join codes\n on pharmacy_claim.ndc_code = codes.code \n where pharmacy_claim.dispensing_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_esrd\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason \n from sacubitril_pharmacy_claim\n\n)\n\n, measure_exclusions as (\n\n select \n exclusions.patient_id\n , exclusion_date\n , exclusion_reason\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from measure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run \nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_denominator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_denominator"], "alias": "_int_nqf0059_denominator", "checksum": {"name": "sha256", "checksum": "2945380e2b8f1b382464b955f21915ba417baa5edc6009fd1ae76f2f80054ff9"}, "config": {"enabled": true, "alias": "_int_nqf0059_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0059, Diabetes Hemoglobin a1c.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.910936, "relation_name": "cms_synthetic.quality_measures._int_nqf0059_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'nutrition services'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from {{ref('quality_measures__stg_core__encounter')}} encounter\n inner join {{ref('quality_measures__int_nqf0059__performance_period')}} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from {{ref('quality_measures__stg_core__procedure')}} procs\n inner join {{ref('quality_measures__int_nqf0059__performance_period')}} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\n inner join {{ref('quality_measures__int_nqf0059__performance_period')}} as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n)\n\n, encounters_by_patient as (\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'diabetes'\n , 'hba1c laboratory test'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from {{ ref('quality_measures__stg_core__condition') }}\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n select\n p.patient_id\n , min_date\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\n , max_date\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\n , qualifying_types\n from {{ref('quality_measures__stg_core__patient')}} p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join {{ref('quality_measures__int_nqf0059__performance_period')}} pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'nutrition services'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0059__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_nqf0059__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0059__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n)\n\n, encounters_by_patient as (\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n , 'hba1c laboratory test'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_nqf0059__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_exclusions"], "alias": "_int_nqf0059_exclusions", "checksum": {"name": "sha256", "checksum": "91bfce0739c69ac1978040df4597ffcb2c7dac64a769e7e34e0c8d674ebdc40b"}, "config": {"enabled": true, "alias": "_int_nqf0059_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0059, Diabetes Hemoglobin a1c.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.912642, "relation_name": "cms_synthetic.quality_measures._int_nqf0059_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_nqf0059__performance_period') }}\n\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_nqf0059__performance_period') }}\n\n)\n{%- endset -%}\n\nwith frailty as (\n\n select\n *\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\n and {{ performance_period_end }}\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n or source.paid_date\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\n and {{ performance_period_end }}\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join {{ref('quality_measures__int_nqf0059_denominator')}} as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_nqf0059_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join cms_synthetic.quality_measures._int_nqf0059_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_numerator.sql", "original_file_path": "models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_numerator"], "alias": "_int_nqf0059_numerator", "checksum": {"name": "sha256", "checksum": "8aea64f76e02a0bf2dec9098858f4c74bd080c0ebbd3d9993fb756440ce84dff"}, "config": {"enabled": true, "alias": "_int_nqf0059_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0059, Diabetes Hemoglobin a1c.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.916171, "relation_name": "cms_synthetic.quality_measures._int_nqf0059_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_nqf0059_denominator') }}\n\n)\n\n, hba1c_test_code as (\n\n select\n code\n , code_system\n , concept_name\n From {{ref('quality_measures__value_sets')}}\n where lower(concept_name) in (\n 'hba1c laboratory test'\n )\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from {{ ref('quality_measures__stg_core__lab_result')}}\n\n)\n\n, qualifying_labs as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date,result_date) as evidence_date\n , hba1c_test_code.concept_name\n , row_number() over(partition by labs.patient_id order by coalesce(collection_date,result_date) desc) as rn\n from labs\n inner join hba1c_test_code\n on coalesce(labs.normalized_code, labs.source_code) = hba1c_test_code.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = hba1c_test_code.code_system\n left join denominator\n on labs.patient_id = denominator.patient_id\n where coalesce(collection_date,result_date) <= denominator.performance_period_end\n {% if target.type == 'fabric' %}\n and result LIKE '%.%' OR result LIKE '%[0-9]%'\n AND result NOT LIKE '%[^0-9.]%'\n {% else %}\n and {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\n {% endif %}\n\n)\n\n, recent_readings as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from qualifying_labs\n where rn = 1\n\n)\n\n, qualifying_patients as (\n\n select\n denominator.*\n , recent_readings.evidence_date\n , recent_readings.evidence_value\n from denominator\n left join recent_readings\n on denominator.patient_id = recent_readings.patient_id\n\n)\n\n, test_not_performed as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from qualifying_patients\n where\n (evidence_date not between performance_period_begin and performance_period_end)\n or evidence_date is null\n\n)\n\n, valid_patients as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , case\n when cast(evidence_value as {{ dbt.type_numeric() }}) > 9.0 then 1\n else 0\n end as numerator_flag\n from qualifying_patients\n where evidence_date between performance_period_begin and performance_period_end\n\n)\n\n, numerator as (\n\n select * from valid_patients\n\n union all\n\n select * from test_not_performed\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0059_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.apply_regex", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0059_denominator\n\n)\n\n, hba1c_test_code as (\n\n select\n code\n , code_system\n , concept_name\n From cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hba1c laboratory test'\n )\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_labs as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date,result_date) as evidence_date\n , hba1c_test_code.concept_name\n , row_number() over(partition by labs.patient_id order by coalesce(collection_date,result_date) desc) as rn\n from labs\n inner join hba1c_test_code\n on coalesce(labs.normalized_code, labs.source_code) = hba1c_test_code.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = hba1c_test_code.code_system\n left join denominator\n on labs.patient_id = denominator.patient_id\n where coalesce(collection_date,result_date) <= denominator.performance_period_end\n \n and regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, recent_readings as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from qualifying_labs\n where rn = 1\n\n)\n\n, qualifying_patients as (\n\n select\n denominator.*\n , recent_readings.evidence_date\n , recent_readings.evidence_value\n from denominator\n left join recent_readings\n on denominator.patient_id = recent_readings.patient_id\n\n)\n\n, test_not_performed as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from qualifying_patients\n where\n (evidence_date not between performance_period_begin and performance_period_end)\n or evidence_date is null\n\n)\n\n, valid_patients as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , case\n when cast(evidence_value as numeric(28,6)) > 9.0 then 1\n else 0\n end as numerator_flag\n from qualifying_patients\n where evidence_date between performance_period_begin and performance_period_end\n\n)\n\n, numerator as (\n\n select * from valid_patients\n\n union all\n\n select * from test_not_performed\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0059__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059__performance_period"], "alias": "_int_nqf0059__performance_period", "checksum": {"name": "sha256", "checksum": "f13d1c4bf53ca57e3a1841574bb22dcef8a630be9a41d57290d3f6981797c0a0"}, "config": {"enabled": true, "alias": "_int_nqf0059__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Diabetes Hemoglobin a1c.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9092531, "relation_name": "cms_synthetic.quality_measures._int_nqf0059__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r | as_bool\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0059')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0059')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0059')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_long.sql", "original_file_path": "models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_long"], "alias": "_int_nqf0059_long", "checksum": {"name": "sha256", "checksum": "a09dfc6a249d2fe92ad03389f27719f673fd34c05edf4d584cb193e6c4c40465"}, "config": {"enabled": true, "alias": "_int_nqf0059_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0059,Diabetes Hemoglobin a1c before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.9145558, "relation_name": "cms_synthetic.quality_measures._int_nqf0059_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_nqf0059_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_nqf0059_numerator') }}\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_nqf0059_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0059_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/nqf0059_diabetes_hemoglobin_a1c/quality_measures__int_nqf0059_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0059_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0059_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0059_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_exclusions": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm130_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_exclusions.sql", "original_file_path": "models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_exclusions"], "alias": "_int_cqm130_exclusions", "checksum": {"name": "sha256", "checksum": "bb4a96e2336ebde55de7ae6bf3c00b31a543d8770b239e9f7cd1898eafb54754"}, "config": {"enabled": true, "alias": "_int_cqm130_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 130, Documentation of Current Medications in the Medical Record.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.994582, "relation_name": "cms_synthetic.quality_measures._int_cqm130_exclusions", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{%- set performance_period_begin -%}\n(\n select \n performance_period_begin\n from {{ ref('quality_measures__int_cqm130__performance_period') }}\n)\n{%- endset -%}\n\n{%- set performance_period_end -%}\n(\n select \n performance_period_end\n from {{ ref('quality_measures__int_cqm130__performance_period') }}\n)\n{%- endset -%}\n\nwith exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'medical reason'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__condition') }}\n where recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from {{ ref('quality_measures__stg_medical_claim') }}\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as (\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join {{ ref('quality_measures__int_cqm130_denominator') }} as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm130__performance_period", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__int_cqm130_denominator"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medical reason'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as (\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join cms_synthetic.quality_measures._int_cqm130_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130__performance_period": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm130__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130__performance_period.sql", "original_file_path": "models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130__performance_period"], "alias": "_int_cqm130__performance_period", "checksum": {"name": "sha256", "checksum": "b6181e892c460cd909dc25524681edc2fe9581861504550c5bb69b0df354b3bf"}, "config": {"enabled": true, "alias": "_int_cqm130__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Documentation of Current Medications in the Medical Record.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.990939, "relation_name": "cms_synthetic.quality_measures._int_cqm130__performance_period", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\n{%- set measure_id -%}\n\n(select id\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM130')\n\n{%- endset -%}\n\n{%- set measure_name -%}\n\n(select name\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM130')\n\n{%- endset -%}\n\n{%- set measure_version -%}\n\n(select version\nfrom {{ ref('quality_measures__measures') }}\nwhere id = 'CQM130')\n\n{%- endset -%}\n\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n {% if var('quality_measures_period_end',False) == False -%}\n {{ last_day(dbt.current_timestamp(), 'year') }}\n {% else -%}\n cast('{{ var('quality_measures_period_end') }}' as date)\n {%- endif %}\n as performance_period_end\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , {{ dbt.dateadd (\n datepart = \"day\"\n , interval = +1\n , from_date_or_timestamp =\n dbt.dateadd (\n datepart = \"year\"\n , interval = -1\n , from_date_or_timestamp = \"performance_period_end\"\n )\n ) }} as performance_period_begin\n from period_end\n\n)\n\nselect\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_long": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm130_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_long.sql", "original_file_path": "models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_long"], "alias": "_int_cqm130_long", "checksum": {"name": "sha256", "checksum": "97acdce03f702c7ae4d08e6d516c5be57ee16b8d98602c9d226cd579b4cbbdd8"}, "config": {"enabled": true, "alias": "_int_cqm130_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 130, Documentation of Current Medications in the Medical Record before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.996299, "relation_name": "cms_synthetic.quality_measures._int_cqm130_long", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from {{ ref('quality_measures__int_cqm130_denominator') }}\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from {{ ref('quality_measures__int_cqm130_numerator') }}\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from {{ ref('quality_measures__int_cqm130_exclusions') }}\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm130_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm130_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cqm130_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm130_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_denominator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm130_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_denominator.sql", "original_file_path": "models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_denominator"], "alias": "_int_cqm130_denominator", "checksum": {"name": "sha256", "checksum": "4b18bfd612e1bd119c6833ec3a9aab4665ee1ddc91987be3259c848ec3164d23"}, "config": {"enabled": true, "alias": "_int_cqm130_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Documentation of Current Medications in the Medical Record.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during latest encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_encounter_date": {"name": "procedure_encounter_date", "description": "Patient's date of encounter in the performance period for procedures.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claims_encounter_date": {"name": "claims_encounter_date", "description": "Patient's date of encounter in the performance period for medical claims.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.992852, "relation_name": "cms_synthetic.quality_measures._int_cqm130_denominator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\n | as_bool\n )\n}}\n\nwith visit_codes as (\n\n select\n code\n , code_system\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'encounter to document medications'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as procedure_encounter_date -- alias only to enable union later\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as claims_encounter_date -- alias only to enable union later\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\n inner join {{ ref('quality_measures__int_cqm130__performance_period') }} as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as procedure_encounter_date\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claims_encounter_date\n from {{ ref('quality_measures__stg_core__procedure') }} procs\n inner join {{ ref('quality_measures__int_cqm130__performance_period') }} as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as procedure_encounter_date\n , coalesce(claim_end_date,claim_start_date) as claims_encounter_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join {{ ref('quality_measures__int_cqm130__performance_period') }} as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, multiple_encounters_by_patient as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , case when procedure_encounter_date >= claims_encounter_date\n then procedure_encounter_date\n else claims_encounter_date\n end as max_encounter_date\n , {{ dbt.concat([\n \"coalesce(min(visit_enc), '')\"\n , \"coalesce(min(proc_enc), '')\"\n , \"coalesce(min(claim_enc), '')\"\n ]) }} as qualifying_types\n from all_encounters\n group by patient_id, procedure_encounter_date, claims_encounter_date\n\n)\n\n, max_encounter_dates_by_patient as (\n\n\tselect\n\t\t patient_id\n\t\t, max(max_encounter_date) as max_encounter_date\n\tfrom multiple_encounters_by_patient\n\tgroup by patient_id\n\n)\n\n, latest_patient_encounters as (\n\t\n\tselect\n\t\t max_encounter_dates_by_patient.patient_id\n\t\t, max_encounter_dates_by_patient.max_encounter_date\n\t\t, procedure_encounter_date\n\t\t, claims_encounter_date\n\tfrom max_encounter_dates_by_patient\n\tinner join multiple_encounters_by_patient\n\t\ton max_encounter_dates_by_patient.patient_id = multiple_encounters_by_patient.patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , floor({{ datediff('birth_date', 'e.max_encounter_date', 'hour') }} / 8760.0) as max_age\n from {{ ref('quality_measures__stg_core__patient') }} p\n inner join latest_patient_encounters e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , patients_with_age.procedure_encounter_date\n , patients_with_age.claims_encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join {{ ref('quality_measures__int_cqm130__performance_period') }} pp\n where max_age >= 18\n \n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(procedure_encounter_date as date) as procedure_encounter_date\n , cast(claims_encounter_date as date) as claims_encounter_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'encounter to document medications'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as procedure_encounter_date -- alias only to enable union later\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as claims_encounter_date -- alias only to enable union later\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm130__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as procedure_encounter_date\n , try_cast( null as date ) as claims_encounter_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_cqm130__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , try_cast( null as date ) as procedure_encounter_date\n , coalesce(claim_end_date,claim_start_date) as claims_encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cqm130__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, multiple_encounters_by_patient as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , case when procedure_encounter_date >= claims_encounter_date\n then procedure_encounter_date\n else claims_encounter_date\n end as max_encounter_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id, procedure_encounter_date, claims_encounter_date\n\n)\n\n, max_encounter_dates_by_patient as (\n\n\tselect\n\t\t patient_id\n\t\t, max(max_encounter_date) as max_encounter_date\n\tfrom multiple_encounters_by_patient\n\tgroup by patient_id\n\n)\n\n, latest_patient_encounters as (\n\t\n\tselect\n\t\t max_encounter_dates_by_patient.patient_id\n\t\t, max_encounter_dates_by_patient.max_encounter_date\n\t\t, procedure_encounter_date\n\t\t, claims_encounter_date\n\tfrom max_encounter_dates_by_patient\n\tinner join multiple_encounters_by_patient\n\t\ton max_encounter_dates_by_patient.patient_id = multiple_encounters_by_patient.patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_encounter_date\n ) / 8760.0) as max_age\n from __dbt__cte___stg_patient p\n inner join latest_patient_encounters e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , patients_with_age.procedure_encounter_date\n , patients_with_age.claims_encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_cqm130__performance_period pp\n where max_age >= 18\n \n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(procedure_encounter_date as date) as procedure_encounter_date\n , cast(claims_encounter_date as date) as claims_encounter_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_numerator": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__int_cqm130_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_numerator.sql", "original_file_path": "models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_numerator"], "alias": "_int_cqm130_numerator", "checksum": {"name": "sha256", "checksum": "72023288987cbff15f55318a6bf6146c1aaf9ee8f2a0e8a1ffb8e7cc861f39fa"}, "config": {"enabled": true, "alias": "_int_cqm130_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 130, Documentation of Current Medications in the Medical Record.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/quality_measures/quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.997889, "relation_name": "cms_synthetic.quality_measures._int_cqm130_numerator", "raw_code": "{{ config(\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith denominator as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from {{ ref('quality_measures__int_cqm130_denominator') }}\n\n)\n\n, medication_code as (\n\n select\n code\n , code_system\n , concept_name\n from {{ ref('quality_measures__value_sets') }}\n where lower(concept_name) in (\n 'eligible clinician attests to documenting current medications'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from {{ ref('quality_measures__stg_core__procedure') }}\n\n)\n\n, documenting_meds_procedures as (\n\n select\n patient_id\n , procedure_date\n from procedures\n inner join medication_code\n on procedures.code = medication_code.code\n and procedures.code_type = medication_code.code_system\n\n)\n\n, documenting_meds_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date,claim_start_date) as encounter_date\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\n inner join medication_code\n on medical_claim.hcpcs_code = medication_code.code\n and medication_code.code_system = 'hcpcs'\n\n)\n\n, qualifying_procedure as (\n\n select \n documenting_meds_procedures.patient_id\n , documenting_meds_procedures.procedure_date as encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_procedures\n inner join denominator\n on documenting_meds_procedures.patient_id = denominator.patient_id\n and documenting_meds_procedures.procedure_date = denominator.procedure_encounter_date\n\n)\n\n, qualifying_claims as (\n \n select \n documenting_meds_claims.patient_id\n , documenting_meds_claims.encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_claims\n inner join denominator\n on documenting_meds_claims.patient_id = denominator.patient_id\n and documenting_meds_claims.encounter_date = denominator.claims_encounter_date\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_procedure\n\n union all\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\n , cast(encounter_date as date) as evidence_date\n , cast(null as {{ dbt.type_string() }}) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_cares\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm130_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/intermediate/cqm130_documentation_of_current_medications_in_the_medical_record/quality_measures__int_cqm130_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cqm130_denominator\n\n)\n\n, medication_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'eligible clinician attests to documenting current medications'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, documenting_meds_procedures as (\n\n select\n patient_id\n , procedure_date\n from procedures\n inner join medication_code\n on procedures.code = medication_code.code\n and procedures.code_type = medication_code.code_system\n\n)\n\n, documenting_meds_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date,claim_start_date) as encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join medication_code\n on medical_claim.hcpcs_code = medication_code.code\n and medication_code.code_system = 'hcpcs'\n\n)\n\n, qualifying_procedure as (\n\n select \n documenting_meds_procedures.patient_id\n , documenting_meds_procedures.procedure_date as encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_procedures\n inner join denominator\n on documenting_meds_procedures.patient_id = denominator.patient_id\n and documenting_meds_procedures.procedure_date = denominator.procedure_encounter_date\n\n)\n\n, qualifying_claims as (\n \n select \n documenting_meds_claims.patient_id\n , documenting_meds_claims.encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_claims\n inner join denominator\n on documenting_meds_claims.patient_id = denominator.patient_id\n and documenting_meds_claims.encounter_date = denominator.claims_encounter_date\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_procedure\n\n union all\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(encounter_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_cares\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_inpatient_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_inpatient_encounter.sql", "original_file_path": "models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_inpatient_encounter.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_inpatient_encounter"], "alias": "_stg_pqi_inpatient_encounter", "checksum": {"name": "sha256", "checksum": "166118b77e0bda58722cba90bfd02d65ab325a5c5bad261da37afbb3aca23f36"}, "config": {"enabled": true, "alias": "_stg_pqi_inpatient_encounter", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI inpatient encounters, serving as the basis for further PQI measure calculations.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_inpatient_encounter", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.114401, "relation_name": "cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect \n encounter_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , admit_source_code\n , encounter_start_date\n , encounter_end_date\n , length_of_stay\n , primary_diagnosis_code\n , patient_id\n , facility_id\n , paid_amount\n , {{ date_part('year', 'encounter_start_date') }} as year_number\nfrom\n {{ ref('core__encounter') }}\nwhere \n encounter_type = 'acute inpatient'", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part"], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_inpatient_encounter.sql", "compiled": true, "compiled_code": "\n\nselect \n encounter_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , admit_source_code\n , encounter_start_date\n , encounter_end_date\n , length_of_stay\n , primary_diagnosis_code\n , patient_id\n , facility_id\n , paid_amount\n , date_part('year', encounter_start_date) as year_number\nfrom\n cms_synthetic.core.encounter\nwhere \n encounter_type = 'acute inpatient'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_member_months.sql", "original_file_path": "models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_member_months.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_member_months"], "alias": "_stg_pqi_member_months", "checksum": {"name": "sha256", "checksum": "ee7d73a74718c3707b9c965d2ed964e387e001daa3a8cd160578f640da1be662"}, "config": {"enabled": true, "alias": "_stg_pqi_member_months", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI member months, from financial_pmpm__member_months.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_member_months", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1174998, "relation_name": "cms_synthetic.ahrq_measures._stg_pqi_member_months", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith\n\ndate_int as (\n select distinct\n replace(year_month,'-','') yyyymm\n , first_day_of_month\n from {{ ref('reference_data__calendar') }} as c\n)\n\nselect \n data_source\n , patient_id\n , first_day_of_month\n , d.yyyymm as year_month\n\nfrom \n {{ ref('core__member_months') }} mm\ninner join date_int d on mm.year_month = d.yyyymm", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__member_months"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_member_months.sql", "compiled": true, "compiled_code": "\n\nwith\n\ndate_int as (\n select distinct\n replace(year_month,'-','') yyyymm\n , first_day_of_month\n from cms_synthetic.reference_data.calendar as c\n)\n\nselect \n data_source\n , patient_id\n , first_day_of_month\n , d.yyyymm as year_month\n\nfrom \n cms_synthetic.core.member_months mm\ninner join date_int d on mm.year_month = d.yyyymm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_patient": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_patient.sql", "original_file_path": "models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_patient.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_patient"], "alias": "_stg_pqi_patient", "checksum": {"name": "sha256", "checksum": "4ebc6aea330970803d2fcce21c4919fb28b3395fe249b8283dac90057a05dbdb"}, "config": {"enabled": true, "alias": "_stg_pqi_patient", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI patient, from core.patient.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_patient", "tags": ["ahrq_measures", "pqi"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1188538, "relation_name": null, "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_patient.sql", "compiled": true, "compiled_code": "\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_condition": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_condition.sql", "original_file_path": "models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_condition.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_condition"], "alias": "_stg_pqi_condition", "checksum": {"name": "sha256", "checksum": "52e7441330cb7189c6f723c54eb6d834ecc220eb54b837766ae6e95c1d4a33fc"}, "config": {"enabled": true, "alias": "_stg_pqi_condition", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI condition, from core.condition.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_condition", "tags": ["ahrq_measures", "pqi"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.115977, "relation_name": null, "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_condition.sql", "compiled": true, "compiled_code": "\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_procedure": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_procedure.sql", "original_file_path": "models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_procedure.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_procedure"], "alias": "_stg_pqi_procedure", "checksum": {"name": "sha256", "checksum": "b445bb71116aaa0f002a53a4bfc261eb28238c80c0adc79149a02cfb28cdcdd1"}, "config": {"enabled": true, "alias": "_stg_pqi_procedure", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI condition, from core.procedure.", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_procedure", "tags": ["ahrq_measures", "pqi"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.120121, "relation_name": null, "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/staging/ahrq_measures__stg_pqi_procedure.sql", "compiled": true, "compiled_code": "\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_num_long": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_num_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/final/ahrq_measures__pqi_num_long.sql", "original_file_path": "models/ahrq_measures/pqi/final/ahrq_measures__pqi_num_long.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_num_long", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_num_long"], "alias": "pqi_num_long", "checksum": {"name": "sha256", "checksum": "af19f1edb49450eb025b4e5c5b7243554dccaa7b54ed8559ffd81d4e9373ed20"}, "config": {"enabled": true, "alias": "pqi_num_long", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Long table that unions the numerator for all the PQI measures.\n", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding numerator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_number": {"name": "exclusion_number", "description": "for a given encounter and pqi measure, the number of exclusion it qualifies for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_num_long", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.055595, "relation_name": "cms_synthetic.ahrq_measures.pqi_num_long", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '01' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_01_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '03' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_03_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '05' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_05_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '07' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_07_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '08' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_08_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '11' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_11_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '12' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_12_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '14' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_14_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '15' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_15_num') }} as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '16' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_16_num') }} as n", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_01_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_num", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/final/ahrq_measures__pqi_num_long.sql", "compiled": true, "compiled_code": "\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '01' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_01_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '03' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_03_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '05' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_05_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '07' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_07_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '08' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_08_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '11' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_11_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '12' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_12_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '14' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_14_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '15' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_15_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '16' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_16_num as n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_denom_long": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_denom_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/final/ahrq_measures__pqi_denom_long.sql", "original_file_path": "models/ahrq_measures/pqi/final/ahrq_measures__pqi_denom_long.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_denom_long", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_denom_long"], "alias": "pqi_denom_long", "checksum": {"name": "sha256", "checksum": "5bc9e190d7c9d2dae9b8e667048e60abbbcf3608ba1e4b944df1283065245a70"}, "config": {"enabled": true, "alias": "pqi_denom_long", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Long table that unions the denominator for all the PQI measures.\n", "columns": {"year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding denominator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_denom_long", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0520372, "relation_name": "cms_synthetic.ahrq_measures.pqi_denom_long", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '01' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_01_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '03' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_03_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '05' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_05_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '07' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_07_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '08' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_08_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '11' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_11_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '12' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_12_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '14' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_14_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '15' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_15_denom') }} as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '16' as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_16_denom') }} as d", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_01_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_denom", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/final/ahrq_measures__pqi_denom_long.sql", "compiled": true, "compiled_code": "\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '01' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_01_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '03' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_03_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '05' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_05_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '07' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_07_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '08' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_08_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '11' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_11_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '12' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_12_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '14' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_14_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '15' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_15_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '16' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_16_denom as d", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_summary": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/final/ahrq_measures__pqi_summary.sql", "original_file_path": "models/ahrq_measures/pqi/final/ahrq_measures__pqi_summary.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_summary", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_summary"], "alias": "pqi_summary", "checksum": {"name": "sha256", "checksum": "9a21ae4fa399946ed6cb1bb53b466a89e1f77f30a16c3a2c3e7b7b1979afcaa1"}, "config": {"enabled": true, "alias": "pqi_summary", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Summary table for pqi numerators that bring in encounter details for analytics reporting.\n", "columns": {"pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_name": {"name": "pqi_name", "description": "the name of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding numerator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the encounter (typically represents the facility where services were performed). \n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid for the encounter by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_summary", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.059315, "relation_name": "cms_synthetic.ahrq_measures.pqi_summary", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect p.pqi_number\n , m.pqi_name\n , e.year_number\n , e.encounter_id\n , e.data_source\n , e.patient_id\n , e.facility_id\n , e.ms_drg_code\n , e.ms_drg_description\n , e.encounter_start_date\n , e.encounter_end_date\n , e.length_of_stay\n , e.paid_amount\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ref('ahrq_measures__pqi_num_long')}} p \ninner join {{ref('ahrq_measures__stg_pqi_inpatient_encounter')}} e\n on p.encounter_id = e.encounter_id\n and p.data_source = e.data_source\ninner join {{ ref('pqi__measures') }} m on cast(p.pqi_number as {{ dbt.type_string() }}) = m.pqi_number", "language": "sql", "refs": [{"name": "ahrq_measures__pqi_num_long", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.ahrq_measures__pqi_num_long", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__measures"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/final/ahrq_measures__pqi_summary.sql", "compiled": true, "compiled_code": "\n\nselect p.pqi_number\n , m.pqi_name\n , e.year_number\n , e.encounter_id\n , e.data_source\n , e.patient_id\n , e.facility_id\n , e.ms_drg_code\n , e.ms_drg_description\n , e.encounter_start_date\n , e.encounter_end_date\n , e.length_of_stay\n , e.paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures.pqi_num_long p \ninner join cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter e\n on p.encounter_id = e.encounter_id\n and p.data_source = e.data_source\ninner join cms_synthetic.ahrq_measures._value_set_pqi_measures m on cast(p.pqi_number as TEXT) = m.pqi_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_rate": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_rate", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/final/ahrq_measures__pqi_rate.sql", "original_file_path": "models/ahrq_measures/pqi/final/ahrq_measures__pqi_rate.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_rate", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_rate"], "alias": "pqi_rate", "checksum": {"name": "sha256", "checksum": "4b16f85a3924c24d6542253adb13ffc60dcf35eb14fcefc8d898b2b30179883c"}, "config": {"enabled": true, "alias": "pqi_rate", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Table that combines numerator and denominator and calculates a rate per 100k\n", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding numerator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denom_count": {"name": "denom_count", "description": "the count of patients that qualified for the denominator of the corresponding year and pqi number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "num_count": {"name": "num_count", "description": "the count of patients that qualified for the numerator of the corresponding year and pqi number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rate_per_100_thousand": {"name": "rate_per_100_thousand", "description": "the calculated rate per 100 thousand (numerator divided by denominator, multiplied by 100000)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_rate", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0575428, "relation_name": "cms_synthetic.ahrq_measures.pqi_rate", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith num as (\n select\n data_source\n , year_number\n , pqi_number\n , count(encounter_id) as num_count\n from {{ ref('ahrq_measures__pqi_num_long') }}\n group by\n data_source\n , year_number\n , pqi_number\n)\n\n, denom as (\n select\n data_source\n , year_number\n , pqi_number\n , count(patient_id) as denom_count\n from {{ ref('ahrq_measures__pqi_denom_long') }} as d\n group by\n data_source\n , year_number\n , pqi_number\n)\n\nselect\n d.data_source\n , d.year_number\n , d.pqi_number\n , d.denom_count\n , coalesce(num.num_count, 0) as num_count\n , coalesce(num.num_count, 0) / d.denom_count * 100000 as rate_per_100_thousand\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom denom as d\nleft join num\n on d.pqi_number = num.pqi_number\n and d.year_number = num.year_number\n and d.data_source = num.data_source", "language": "sql", "refs": [{"name": "ahrq_measures__pqi_num_long", "package": null, "version": null}, {"name": "ahrq_measures__pqi_denom_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__pqi_num_long", "model.the_tuva_project.ahrq_measures__pqi_denom_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/final/ahrq_measures__pqi_rate.sql", "compiled": true, "compiled_code": "\n\nwith num as (\n select\n data_source\n , year_number\n , pqi_number\n , count(encounter_id) as num_count\n from cms_synthetic.ahrq_measures.pqi_num_long\n group by\n data_source\n , year_number\n , pqi_number\n)\n\n, denom as (\n select\n data_source\n , year_number\n , pqi_number\n , count(patient_id) as denom_count\n from cms_synthetic.ahrq_measures.pqi_denom_long as d\n group by\n data_source\n , year_number\n , pqi_number\n)\n\nselect\n d.data_source\n , d.year_number\n , d.pqi_number\n , d.denom_count\n , coalesce(num.num_count, 0) as num_count\n , coalesce(num.num_count, 0) / d.denom_count * 100000 as rate_per_100_thousand\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom denom as d\nleft join num\n on d.pqi_number = num.pqi_number\n and d.year_number = num.year_number\n and d.data_source = num.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_exclusion_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/final/ahrq_measures__pqi_exclusion_long.sql", "original_file_path": "models/ahrq_measures/pqi/final/ahrq_measures__pqi_exclusion_long.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_exclusion_long", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_exclusion_long"], "alias": "pqi_exclusion_long", "checksum": {"name": "sha256", "checksum": "57e868f0e2a0b00798e3fb82c9fe7bb1ea7d84fb515990d32cc2a6cd398b103d"}, "config": {"enabled": true, "alias": "pqi_exclusion_long", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Long table that unions the exclusions for all the PQI measures.\n", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "description of the reason the encounter was excluded", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_number": {"name": "exclusion_number", "description": "for a given encounter and pqi measure, the number of exclusion it qualifies for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_exclusion_long", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0536, "relation_name": "cms_synthetic.ahrq_measures.pqi_exclusion_long", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 1 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_01_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 3 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_03_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 5 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_05_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 7 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_07_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 8 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_08_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 11 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_11_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 12 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_12_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 14 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_14_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 15 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_15_exclusions') }} as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 16 as pqi_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_16_exclusions') }} as e", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_01_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/final/ahrq_measures__pqi_exclusion_long.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 1 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_01_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 3 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_03_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 5 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_05_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 7 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_07_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 8 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_08_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 11 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_11_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 12 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_12_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 14 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_14_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 15 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_15_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 16 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_16_exclusions as e", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_15_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_15_exclusions"], "alias": "_int_pqi_15_exclusions", "checksum": {"name": "sha256", "checksum": "bb64e53366ac3fa222ba42aae28313eb30ab11f873db542aebc5f9b0ff99c6eb"}, "config": {"enabled": true, "alias": "_int_pqi_15_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 15 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_15_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.096999, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_15_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system_diagnosis_codes'\n and pqi.pqi_number = '15'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system_diagnosis_codes'\n and pqi.pqi_number = '15'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_12_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_12_denom"], "alias": "_int_pqi_12_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_12_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 12 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_12_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0863922, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_12_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_08_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_08_exclusions"], "alias": "_int_pqi_08_exclusions", "checksum": {"name": "sha256", "checksum": "a1b2886c09fabdbe320749152e6d3f96272fd908ba66c852baf1cf17180ade4b"}, "config": {"enabled": true, "alias": "_int_pqi_08_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 08 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_08_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.079179, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_08_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi.pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi.pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_16_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_16_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_16_num"], "alias": "_int_pqi_16_num", "checksum": {"name": "sha256", "checksum": "527ef3ac7c47557ee83c0768f36952189a2ee92094b799deb515c99ccbcd94f9"}, "config": {"enabled": true, "alias": "_int_pqi_16_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 16 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_16_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.103084, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_16_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith diagnosis as (\n select distinct\n c.encounter_id\n , c.data_source\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'diabetes_diagnosis_codes'\n and pqi_number = '16'\n where c.encounter_id is not null\n),\n\n\nprocedures as (\n select distinct\n p.encounter_id\n , p.data_source\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as p\n inner join diagnosis as d \n on p.encounter_id = d.encounter_id\n and d.data_source = p.data_source\n inner join {{ ref('pqi__value_sets') }} as pqi\n on p.normalized_code = pqi.code\n and p.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'lower-extremity_amputation_procedure_codes'\n and pqi_number = '16'\n)\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('ahrq_measures__int_pqi_16_denom') }} as denom \n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\n inner join procedures as p\n on e.encounter_id = p.encounter_id\n and e.data_source = p.data_source\nleft join {{ ref('ahrq_measures__int_pqi_16_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_num.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), diagnosis as (\n select distinct\n c.encounter_id\n , c.data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'diabetes_diagnosis_codes'\n and pqi_number = '16'\n where c.encounter_id is not null\n),\n\n\nprocedures as (\n select distinct\n p.encounter_id\n , p.data_source\n from __dbt__cte___stg_pqi_procedure as p\n inner join diagnosis as d \n on p.encounter_id = d.encounter_id\n and d.data_source = p.data_source\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on p.normalized_code = pqi.code\n and p.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'lower-extremity_amputation_procedure_codes'\n and pqi_number = '16'\n)\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._int_pqi_16_denom as denom \n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\n inner join procedures as p\n on e.encounter_id = p.encounter_id\n and e.data_source = p.data_source\nleft join cms_synthetic.ahrq_measures._int_pqi_16_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_12_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_12_exclusions"], "alias": "_int_pqi_12_exclusions", "checksum": {"name": "sha256", "checksum": "e43a93f86ffe7ce4fe29e2719644ba1ce51b848f02d9bb210deb61dd3b744f3e"}, "config": {"enabled": true, "alias": "_int_pqi_12_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 12 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_12_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.087884, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_12_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith kidney as (\n select distinct\n encounter_id\n , data_source\n , 'kidney' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'kidney_or_urinary_tract_disorder_diagnosis_codes'\n and pqi.pqi_number = '12'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from kidney\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), kidney as (\n select distinct\n encounter_id\n , data_source\n , 'kidney' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'kidney_or_urinary_tract_disorder_diagnosis_codes'\n and pqi.pqi_number = '12'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from kidney\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_07_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_07_exclusions"], "alias": "_int_pqi_07_exclusions", "checksum": {"name": "sha256", "checksum": "f4edbd030c673d6b4705211faade25ba8f8849d11ef8b78e43c8c36a036abb28"}, "config": {"enabled": true, "alias": "_int_pqi_07_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 07 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_07_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.074925, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_07_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nckd as (\n select distinct\n encounter_id\n , data_source\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'exclusion_kidney_disease_diagnosis_codes'\n and pqi_number = '07'\n where c.encounter_id is not null\n),\n\naccess as (\n select distinct\n encounter_id\n , data_source\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'exclusion_dialysis_access_procedure_codes'\n and pqi.pqi_number = '07'\n where c.encounter_id is not null\n),\n\ncombine as (\n select\n c.encounter_id\n , c.data_source\n , 'ckd' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join ckd \n on c.encounter_id = ckd.encounter_id\n and c.data_source = ckd.data_source\n inner join access as a \n on c.encounter_id = a.encounter_id\n and c.data_source = a.data_source\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from combine\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nckd as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'exclusion_kidney_disease_diagnosis_codes'\n and pqi_number = '07'\n where c.encounter_id is not null\n),\n\naccess as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'exclusion_dialysis_access_procedure_codes'\n and pqi.pqi_number = '07'\n where c.encounter_id is not null\n),\n\ncombine as (\n select\n c.encounter_id\n , c.data_source\n , 'ckd' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join ckd \n on c.encounter_id = ckd.encounter_id\n and c.data_source = ckd.data_source\n inner join access as a \n on c.encounter_id = a.encounter_id\n and c.data_source = a.data_source\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from combine\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_union", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_union.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_union.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_union"], "alias": "_int_pqi_shared_exclusion_union", "checksum": {"name": "sha256", "checksum": "8b6094d06781b319344b0344ecd2c5b0435c0a172edbb898d99d24952c14b555"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_union", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Union of all exclusion criteria used across PQI measures for consistent exclusion logic.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_union", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.113009, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n-- Missing Age Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing age' as exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_age') }} as age\n on denom.patient_id = age.patient_id\n and denom.data_source = age.data_source\n\nunion all\n\n-- Missing Gender Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing gender' as exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_gender') }} as gender\n on denom.patient_id = gender.patient_id\n and denom.data_source = gender.data_source\n\nunion all\n\n-- Missing Dates Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing dates' as exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_dates') }} as dates\n on denom.encounter_id = dates.encounter_id\n and denom.data_source = dates.data_source\n\nunion all\n\n-- Missing Primary Diagnosis Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing primary diagnosis' as exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx') }} as dx\n on denom.encounter_id = dx.encounter_id\n and denom.data_source = dx.data_source\n\nunion all\n\n-- Transfer Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'transfer' as exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_transfer') }} as tx\n on denom.encounter_id = tx.encounter_id\n and denom.data_source = tx.data_source\n\nunion all\n\n-- Ungroupable DRG Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'ungroupable DRG' as exclusion_reason\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg') }} as drg\n on denom.encounter_id = drg.encounter_id\n and denom.data_source = drg.data_source", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_age", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_gender", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_dates", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_transfer", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_union.sql", "compiled": true, "compiled_code": "\n\n-- Missing Age Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing age' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusions_missing_age as age\n on denom.patient_id = age.patient_id\n and denom.data_source = age.data_source\n\nunion all\n\n-- Missing Gender Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing gender' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_gender as gender\n on denom.patient_id = gender.patient_id\n and denom.data_source = gender.data_source\n\nunion all\n\n-- Missing Dates Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing dates' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_dates as dates\n on denom.encounter_id = dates.encounter_id\n and denom.data_source = dates.data_source\n\nunion all\n\n-- Missing Primary Diagnosis Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing primary diagnosis' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx as dx\n on denom.encounter_id = dx.encounter_id\n and denom.data_source = dx.data_source\n\nunion all\n\n-- Transfer Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'transfer' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_transfer as tx\n on denom.encounter_id = tx.encounter_id\n and denom.data_source = tx.data_source\n\nunion all\n\n-- Ungroupable DRG Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'ungroupable DRG' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg as drg\n on denom.encounter_id = drg.encounter_id\n and denom.data_source = drg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_age", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_age.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_age.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_age"], "alias": "_int_pqi_shared_exclusions_missing_age", "checksum": {"name": "sha256", "checksum": "dd40b4ecf0af2092bb81fffabbc9afa98523863884e528c69d162193b0009817"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusions_missing_age", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic for patients without an age\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusions_missing_age", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1043699, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusions_missing_age", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n/* Exclude patients with missing age */\nselect \n data_source\n , patient_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_patient') }}\nwhere birth_date is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_age.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) /* Exclude patients with missing age */\nselect \n data_source\n , patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere birth_date is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_gender", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_gender.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_gender.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_gender"], "alias": "_int_pqi_shared_exclusion_missing_gender", "checksum": {"name": "sha256", "checksum": "e4fb822ffb6ccd9d6d5154f55850ff536e180325eaded4b8a3ce54e74d4d506a"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_missing_gender", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Handles missing gender information for PQI measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_missing_gender", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.107051, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_gender", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n-- Exclude patients with undefined or missing gender\nselect \n data_source\n , patient_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_patient') }}\nwhere \n sex not in ('male', 'female')", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_gender.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) -- Exclude patients with undefined or missing gender\nselect \n data_source\n , patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere \n sex not in ('male', 'female')", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_transfer", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_transfer.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_transfer.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_transfer"], "alias": "_int_pqi_shared_exclusion_transfer", "checksum": {"name": "sha256", "checksum": "cd90a93c6bbd5a95d96530ecac26930668f8a522d1e8bd8673d310bd17b4dab1"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_transfer", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Excludes transferred patients from PQI calculations.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_transfer", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.109766, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_transfer", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n-- Exclude transfers from hospital, SNF, or other healthcare facility\nselect \n encounter_id\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\nwhere \n admit_source_code in ('4', '5', '6')", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_transfer.sql", "compiled": true, "compiled_code": "\n\n-- Exclude transfers from hospital, SNF, or other healthcare facility\nselect \n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n admit_source_code in ('4', '5', '6')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_14_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_14_denom"], "alias": "_int_pqi_14_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_14_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 14 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_14_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.09072, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_14_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_14_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_14_exclusions"], "alias": "_int_pqi_14_exclusions", "checksum": {"name": "sha256", "checksum": "2479fa14f9fdf4932df59c739a89f05bc8ad839b78495ffc7b9a4315c55cfff2"}, "config": {"enabled": true, "alias": "_int_pqi_14_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 14 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_14_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.092009, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_14_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_exclusions.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_01_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_01_exclusions"], "alias": "_int_pqi_01_exclusions", "checksum": {"name": "sha256", "checksum": "2479fa14f9fdf4932df59c739a89f05bc8ad839b78495ffc7b9a4315c55cfff2"}, "config": {"enabled": true, "alias": "_int_pqi_01_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 01 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_01_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.062428, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_01_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_exclusions.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_07_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_07_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_07_num"], "alias": "_int_pqi_07_num", "checksum": {"name": "sha256", "checksum": "69c741d1559e03b669806fac29ee371835fa27aa32eed8beeca98956dd7ca1c5"}, "config": {"enabled": true, "alias": "_int_pqi_07_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 07 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_07_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.076166, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_07_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'hypertension_diagnosis_codes'\n and hyp.pqi_number = '07'\ninner join {{ ref('ahrq_measures__int_pqi_07_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_07_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'hypertension_diagnosis_codes'\n and hyp.pqi_number = '07'\ninner join cms_synthetic.ahrq_measures._int_pqi_07_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_07_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_07_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_07_denom"], "alias": "_int_pqi_07_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_07_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 07 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_07_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0736692, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_07_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_07_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_16_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_16_exclusions"], "alias": "_int_pqi_16_exclusions", "checksum": {"name": "sha256", "checksum": "1a0670d95eb76862305e050ba71ac15d1707778effed009f75708644232345bc"}, "config": {"enabled": true, "alias": "_int_pqi_16_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 16 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_16_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1017442, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_16_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith amputation as (\n select distinct\n encounter_id\n , data_source\n , 'amputation' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'traumatic_amputation_of_the_lower_extremity_diagnosis_codes'\n and pqi.pqi_number = '16'\n where c.encounter_id is not null\n),\n\npregnancy as (\n select distinct\n encounter_id\n , data_source\n , 'pregnancy' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'mdc_14_principal_diagnosis_codes'\n and pqi.pqi_number = 'appendix_f'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from amputation\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from pregnancy\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), amputation as (\n select distinct\n encounter_id\n , data_source\n , 'amputation' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'traumatic_amputation_of_the_lower_extremity_diagnosis_codes'\n and pqi.pqi_number = '16'\n where c.encounter_id is not null\n),\n\npregnancy as (\n select distinct\n encounter_id\n , data_source\n , 'pregnancy' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'mdc_14_principal_diagnosis_codes'\n and pqi.pqi_number = 'appendix_f'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from amputation\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from pregnancy\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_03_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_03_exclusions"], "alias": "_int_pqi_03_exclusions", "checksum": {"name": "sha256", "checksum": "2479fa14f9fdf4932df59c739a89f05bc8ad839b78495ffc7b9a4315c55cfff2"}, "config": {"enabled": true, "alias": "_int_pqi_03_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 03 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_03_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0667078, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_03_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_exclusions.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_15_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_15_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_15_num"], "alias": "_int_pqi_15_num", "checksum": {"name": "sha256", "checksum": "9a6821bfbfb4fc3641fdc2c761815f8c6e6b9c1ab8a1af9ebf521f165b02b980"}, "config": {"enabled": true, "alias": "_int_pqi_15_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 15 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_15_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.098402, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_15_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'asthma_diagnosis_codes'\n and hyp.pqi_number = '15'\ninner join {{ ref('ahrq_measures__int_pqi_15_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_15_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'asthma_diagnosis_codes'\n and hyp.pqi_number = '15'\ninner join cms_synthetic.ahrq_measures._int_pqi_15_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_15_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_05_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_05_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_05_num"], "alias": "_int_pqi_05_num", "checksum": {"name": "sha256", "checksum": "80da2cc5bc74f39de6d96af77a43e96ca826c366dbabf16b39efd39505fb2984"}, "config": {"enabled": true, "alias": "_int_pqi_05_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 05 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_05_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.072294, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_05_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('ahrq_measures__int_pqi_05_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('pqi__value_sets') }} as copd\n on e.primary_diagnosis_code = copd.code\n and copd.value_set_name = 'chronic_obstructive_pulmonary_disorder'\n and copd.pqi_number = '05'\nleft join {{ ref('pqi__value_sets') }} asthma\n on e.primary_diagnosis_code = asthma.code\n and asthma.value_set_name = 'asthma'\n and asthma.pqi_number = '05'\nleft join {{ ref('ahrq_measures__int_pqi_05_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null\n and (\n asthma.code is not null \n or copd.code is not null\n )", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_denom", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._int_pqi_05_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._value_set_pqi as copd\n on e.primary_diagnosis_code = copd.code\n and copd.value_set_name = 'chronic_obstructive_pulmonary_disorder'\n and copd.pqi_number = '05'\nleft join cms_synthetic.ahrq_measures._value_set_pqi asthma\n on e.primary_diagnosis_code = asthma.code\n and asthma.value_set_name = 'asthma'\n and asthma.pqi_number = '05'\nleft join cms_synthetic.ahrq_measures._int_pqi_05_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null\n and (\n asthma.code is not null \n or copd.code is not null\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_11_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_11_exclusions"], "alias": "_int_pqi_11_exclusions", "checksum": {"name": "sha256", "checksum": "85c25d353024d2bf3bd7746249b81dbecced520e9ed66b978eddd95be9a0145c"}, "config": {"enabled": true, "alias": "_int_pqi_11_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 11 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_11_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.083298, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_11_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith sickle_cell as (\n select distinct\n encounter_id\n , data_source\n , 'sickle cell' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'sickle_cell_anemia_or_hb-s_disease_diagnosis_codes'\n and pqi.pqi_number = '11'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from sickle_cell\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), sickle_cell as (\n select distinct\n encounter_id\n , data_source\n , 'sickle cell' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'sickle_cell_anemia_or_hb-s_disease_diagnosis_codes'\n and pqi.pqi_number = '11'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from sickle_cell\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx"], "alias": "_int_pqi_shared_exclusion_missing_primary_dx", "checksum": {"name": "sha256", "checksum": "67bf665852fbfd645d553f4638975ce2b2ae6375a7ee74cb5afdbcc33bf990fb"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_missing_primary_dx", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Handles cases with missing primary diagnosis in PQI measure calculations.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_missing_primary_dx", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.108505, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n-- Exclude encounters with missing primary diagnosis code\nselect \n encounter_id\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\nwhere \n primary_diagnosis_code is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx.sql", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with missing primary diagnosis code\nselect \n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n primary_diagnosis_code is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_05_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_exclusions.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_05_exclusions"], "alias": "_int_pqi_05_exclusions", "checksum": {"name": "sha256", "checksum": "bf4b26beafe7e73e25a6e5f3b95c088b89b646b8806f2e00721358793f16c286"}, "config": {"enabled": true, "alias": "_int_pqi_05_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 05 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_05_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.070991, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_05_exclusions", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nwith resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\n inner join {{ ref('pqi__value_sets') }} as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system'\n and pqi_number = '05'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system'\n and pqi_number = '05'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_15_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_15_denom"], "alias": "_int_pqi_15_denom", "checksum": {"name": "sha256", "checksum": "12d2abfd0e710a34b679f26e3bdbe5272759c44df18411faf570f8a4a7ce2b57"}, "config": {"enabled": true, "alias": "_int_pqi_15_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 15 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_15_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0955572, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_15_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18\n and\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} <= 39", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_15_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18\n and\n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) <= 39", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_14_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_14_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_14_num"], "alias": "_int_pqi_14_num", "checksum": {"name": "sha256", "checksum": "356dc6ed072cec481cb52537ac340def1be25054d8fa6ae0b3659fa63ab1603e"}, "config": {"enabled": true, "alias": "_int_pqi_14_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 14 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_14_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.09346, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_14_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'uncontrolled_diabetes_diagnosis_codes'\n and hyp.pqi_number = '14'\ninner join {{ ref('ahrq_measures__int_pqi_14_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_14_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_14_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'uncontrolled_diabetes_diagnosis_codes'\n and hyp.pqi_number = '14'\ninner join cms_synthetic.ahrq_measures._int_pqi_14_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_14_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_01_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_01_denom"], "alias": "_int_pqi_01_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_01_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 01 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_01_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.060866, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_01_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_dates.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_dates.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_dates"], "alias": "_int_pqi_shared_exclusion_missing_dates", "checksum": {"name": "sha256", "checksum": "ca589b4a87c3b099b3839bd1a45557177180b9ca6d2c1799fc79bf61bffda662"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_missing_dates", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Handles missing date fields across various PQI measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_missing_dates", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.105761, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_dates", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n-- Exclude encounters with missing start dates\nselect\n encounter_id\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\nwhere \n encounter_start_date is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_missing_dates.sql", "compiled": true, "compiled_code": "\n-- Exclude encounters with missing start dates\nselect\n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n encounter_start_date is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_08_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_08_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_08_num"], "alias": "_int_pqi_08_num", "checksum": {"name": "sha256", "checksum": "1b8eefdf2801c11dc36d149f2d73e248366a7867f00f79f1819f3a696339f5d9"}, "config": {"enabled": true, "alias": "_int_pqi_08_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 08 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_08_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.080665, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_08_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'heart_failure_diagnosis_codes'\n and hyp.pqi_number = '08'\ninner join {{ ref('ahrq_measures__int_pqi_08_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_08_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'heart_failure_diagnosis_codes'\n and hyp.pqi_number = '08'\ninner join cms_synthetic.ahrq_measures._int_pqi_08_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_08_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_11_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_11_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_11_num"], "alias": "_int_pqi_11_num", "checksum": {"name": "sha256", "checksum": "6291d04119ee713f3e0c3f9d76b76515aed26074e8d5aba3c6e6c9f2466caf1d"}, "config": {"enabled": true, "alias": "_int_pqi_11_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 11 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_11_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0850072, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_11_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'community_acquired_bacterial_pneumonia_diagnosis_codes'\n and hyp.pqi_number = '11'\ninner join {{ ref('ahrq_measures__int_pqi_11_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_11_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'community_acquired_bacterial_pneumonia_diagnosis_codes'\n and hyp.pqi_number = '11'\ninner join cms_synthetic.ahrq_measures._int_pqi_11_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_11_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_01_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_01_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_01_num"], "alias": "_int_pqi_01_num", "checksum": {"name": "sha256", "checksum": "1b779524f0b089fbd0589a167c4502dd3a847f7f142d28be7c79552e3b2f90ea"}, "config": {"enabled": true, "alias": "_int_pqi_01_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 01 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_01_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.063974, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_01_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_short-term_complications_diagnosis_codes'\n and pqi.pqi_number = '01'\ninner join {{ ref('ahrq_measures__int_pqi_01_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_01_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_01_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_01_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_01_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_short-term_complications_diagnosis_codes'\n and pqi.pqi_number = '01'\ninner join cms_synthetic.ahrq_measures._int_pqi_01_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_01_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_16_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_16_denom"], "alias": "_int_pqi_16_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_16_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 16 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_16_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.099879, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_16_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_16_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_12_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_12_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_12_num"], "alias": "_int_pqi_12_num", "checksum": {"name": "sha256", "checksum": "2cb8dba7bc68decfbc9786e34267041c0ae2c30aa9a93bff981a5c9c78d789d6"}, "config": {"enabled": true, "alias": "_int_pqi_12_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 12 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_12_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0893881, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_12_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'urinary_tract_infection_diagnosis_codes'\n and hyp.pqi_number = '12'\ninner join {{ ref('ahrq_measures__int_pqi_12_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_12_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_12_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'urinary_tract_infection_diagnosis_codes'\n and hyp.pqi_number = '12'\ninner join cms_synthetic.ahrq_measures._int_pqi_12_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_12_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_11_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_11_denom"], "alias": "_int_pqi_11_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_11_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 11 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_11_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.0819688, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_11_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_11_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_05_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_05_denom"], "alias": "_int_pqi_05_denom", "checksum": {"name": "sha256", "checksum": "aa0f1909eea2f506905ea661e4e8efe35b3e6658d885f07c968d8d6aee2962ce"}, "config": {"enabled": true, "alias": "_int_pqi_05_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 05 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_05_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.069464, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_05_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 40", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_05_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 40", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg"], "alias": "_int_pqi_shared_exclusion_ungroupable_drg", "checksum": {"name": "sha256", "checksum": "197c6d7336ceaa9fd4e6ad61389b0a17ac73d540dec02b4a03011504752c2191"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_ungroupable_drg", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Excludes patients with ungroupable DRGs from PQI measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_ungroupable_drg", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.111403, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\n-- Exclude encounters with ungroupable DRG\nselect \n encounter_id\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\nwhere \n ms_drg_code = '999'", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg.sql", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with ungroupable DRG\nselect \n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n ms_drg_code = '999'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_08_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_08_denom"], "alias": "_int_pqi_08_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_08_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 08 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_08_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.077615, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_08_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_08_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_03_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_denom.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_03_denom"], "alias": "_int_pqi_03_denom", "checksum": {"name": "sha256", "checksum": "b678c5428f7ed39e0b0289a30accba92898aa78980fbc26acdad6efdf6c1f83d"}, "config": {"enabled": true, "alias": "_int_pqi_03_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 03 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_03_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.06538, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_03_denom", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_03_num": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_03_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_num.sql", "original_file_path": "models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_03_num"], "alias": "_int_pqi_03_num", "checksum": {"name": "sha256", "checksum": "f06d99a2967e6cbfaa1ddf1a1bbc34655b421a39da577c8bf930c5c02d59515a"}, "config": {"enabled": true, "alias": "_int_pqi_03_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 03 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ahrq_measures/pqi/pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_03_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.067988, "relation_name": "cms_synthetic.ahrq_measures._int_pqi_03_num", "raw_code": "{{ config(\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n) }}\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\ninner join {{ ref('pqi__value_sets') }} as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_long-term_complications_diagnosis_codes'\n and pqi.pqi_number = '03'\ninner join {{ ref('ahrq_measures__int_pqi_03_denom') }} as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join {{ ref('ahrq_measures__int_pqi_03_exclusions') }} as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ahrq_measures/pqi/intermediate/ahrq_measures__int_pqi_03_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_long-term_complications_diagnosis_codes'\n and pqi.pqi_number = '03'\ninner join cms_synthetic.ahrq_measures._int_pqi_03_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_03_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__stg_core__condition": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "ccsr__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/staging/ccsr__stg_core__condition.sql", "original_file_path": "models/ccsr/staging/ccsr__stg_core__condition.sql", "unique_id": "model.the_tuva_project.ccsr__stg_core__condition", "fqn": ["the_tuva_project", "ccsr", "staging", "ccsr__stg_core__condition"], "alias": "ccsr__stg_core__condition", "checksum": {"name": "sha256", "checksum": "9e1b4ab52ed8fea485de2be98a03ce8ae3f06e79b1ae7361ceb9d374fd9709bf"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "", "columns": {"encounter_id": {"name": "encounter_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"tags": ["ccsr"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.131271, "relation_name": null, "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__condition') }}\nwhere normalized_code_type = 'icd-10-cm'", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/staging/ccsr__stg_core__condition.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere normalized_code_type = 'icd-10-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__stg_core__procedure": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "ccsr__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/staging/ccsr__stg_core__procedure.sql", "original_file_path": "models/ccsr/staging/ccsr__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.ccsr__stg_core__procedure", "fqn": ["the_tuva_project", "ccsr", "staging", "ccsr__stg_core__procedure"], "alias": "ccsr__stg_core__procedure", "checksum": {"name": "sha256", "checksum": "58fe3c2ec44e0be5f9511bc08c1f2e70ad85540ea473528ad55bd8d685ed15cf"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "", "columns": {"encounter_id": {"name": "encounter_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"tags": ["ccsr"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.132138, "relation_name": null, "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/staging/ccsr__stg_core__procedure.sql", "compiled": true, "compiled_code": "\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__singular_condition_category": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__singular_condition_category", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/final/ccsr__singular_condition_category.sql", "original_file_path": "models/ccsr/final/ccsr__singular_condition_category.sql", "unique_id": "model.the_tuva_project.ccsr__singular_condition_category", "fqn": ["the_tuva_project", "ccsr", "final", "ccsr__singular_condition_category"], "alias": "singular_condition_category", "checksum": {"name": "sha256", "checksum": "e723f1d1ff3e5e2577f8bda636960879211699a3c4b2a6ed0df0bbad465da265"}, "config": {"enabled": true, "alias": "singular_condition_category", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This model contains only the CCSR's default category assignment for the ICD-10 code, and only for the first-listed ICD-10 code (`diagnosis_code = 1`).\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for an encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique claim_id for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "body_system": {"name": "body_system", "description": "The body system to which each parent category belongs. The 22 body systems generally follow the structure of the ICD-10-CM diagnosis chapters. Note that the procedure tables don't have this column, but a conceptually related field in procedure models is `clinical_domain`.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category code for each CCSR category. In practice, this is the three letter prefix to the category code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_category_description": {"name": "parent_category_description", "description": "A description of the parent category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "A CCSR category for the ICD-10-CM code. One ICD-10-CM code may have up 6 CCSR categories associated, ordinally ranked by the ccsr_category_rank. Will be null if a record has a `code` that isn't referenced in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "The human readable description of the `ccsr_category`.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dxccsr_version": {"name": "dxccsr_version", "description": "The version number of the CCSR program from which the dbt model was derived.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "singular_condition_category", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.124605, "relation_name": "cms_synthetic.ccsr.singular_condition_category", "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nselect \n encounter_id,\n claim_id,\n patient_id,\n ccsr_category,\n ccsr_category_description,\n ccsr_parent_category,\n parent_category_description,\n body_system,\n {{ var('dxccsr_version') }} as dxccsr_version,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ref('ccsr__long_condition_category')}}\nwhere\n is_{{ var('record_type', 'ip') }}_default_category = 1\n and condition_rank = 1", "language": "sql", "refs": [{"name": "ccsr__long_condition_category", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ccsr__long_condition_category"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/final/ccsr__singular_condition_category.sql", "compiled": true, "compiled_code": "\n\nselect \n encounter_id,\n claim_id,\n patient_id,\n ccsr_category,\n ccsr_category_description,\n ccsr_parent_category,\n parent_category_description,\n body_system,\n '2023.1' as dxccsr_version,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ccsr.long_condition_category\nwhere\n is_ip_default_category = 1\n and condition_rank = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__long_condition_category": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__long_condition_category", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/final/ccsr__long_condition_category.sql", "original_file_path": "models/ccsr/final/ccsr__long_condition_category.sql", "unique_id": "model.the_tuva_project.ccsr__long_condition_category", "fqn": ["the_tuva_project", "ccsr", "final", "ccsr__long_condition_category"], "alias": "long_condition_category", "checksum": {"name": "sha256", "checksum": "d4ca404201da7ebe79de49e4e3616f6cd5c93984123e37d5a7982a14684a5b50"}, "config": {"enabled": true, "alias": "long_condition_category", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This model contains a mapping of individual condition ICD-10-CM diagnosis codes to the CCSR's clinically meaningful diagnosis categories. Each row represents a mapping of an ICD-10 code to a CCSR category. As each ICD-10 code may be mapped to up to 6 categories, it's expected that this table will output as many or more rows than the TUVA condition model. The model is equivalent to the CCSR's Output Option 1 - Vertical File Output.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The ICD-10-CM code for the diagnosis.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The ICD-10-CM code description provided in the CCSR CSV seed file.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "The numerical ranking of a diagnosis code in a claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "body_system": {"name": "body_system", "description": "The body system to which each parent category belongs. The 22 body systems generally follow the structure of the ICD-10-CM diagnosis chapters. Note that the procedure tables don't have this column, but a conceptually related field in procedure models is `clinical_domain`.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category code for each CCSR category. In practice, this is the three letter prefix to the category code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_category_description": {"name": "parent_category_description", "description": "A description of the parent category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "A CCSR category for the ICD-10-CM code. One ICD-10-CM code may have up 6 CCSR categories associated, ordinally ranked by the ccsr_category_rank. Will be null if a record has a `code` that isn't referenced in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "The description of the CCSR category as provided in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_rank": {"name": "ccsr_category_rank", "description": "The ordinal rank of a given CCSR category mapped to an ICD-10-CM code. The CCSR seed CSV has the order of categories assigned to each ICD-10-CM code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_ip_default_category": {"name": "is_ip_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an inpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_op_default_category": {"name": "is_op_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an outpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dxccsr_version": {"name": "dxccsr_version", "description": "The version number of the CCSR program from which the dbt model was derived.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "long_condition_category", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.122695, "relation_name": "cms_synthetic.ccsr.long_condition_category", "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith ccsr__dx_vertical_pivot as (\n \n select * from {{ ref('ccsr__dx_vertical_pivot') }} \n\n), condition as (\n \n select * from {{ ref('ccsr__stg_core__condition') }}\n\n), dxccsr_body_systems as (\n\n select * from {{ ref('ccsr__dxccsr_v2023_1_body_systems') }}\n\n)\n\nselect \n condition.encounter_id,\n condition.claim_id,\n condition.patient_id,\n condition.normalized_code,\n ccsr__dx_vertical_pivot.code_description,\n condition.condition_rank,\n ccsr__dx_vertical_pivot.ccsr_parent_category,\n dxccsr_body_systems.body_system,\n dxccsr_body_systems.parent_category_description,\n ccsr__dx_vertical_pivot.ccsr_category,\n ccsr__dx_vertical_pivot.ccsr_category_description,\n ccsr__dx_vertical_pivot.ccsr_category_rank,\n ccsr__dx_vertical_pivot.is_ip_default_category,\n ccsr__dx_vertical_pivot.is_op_default_category,\n {{ var('dxccsr_version') }} as dxccsr_version,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom condition\nleft join ccsr__dx_vertical_pivot\n on condition.normalized_code = ccsr__dx_vertical_pivot.code\nleft join dxccsr_body_systems on ccsr__dx_vertical_pivot.ccsr_parent_category = dxccsr_body_systems.ccsr_parent_category", "language": "sql", "refs": [{"name": "ccsr__dx_vertical_pivot", "package": null, "version": null}, {"name": "ccsr__stg_core__condition", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_body_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.ccsr__stg_core__condition", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/final/ccsr__long_condition_category.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__condition as (\n\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere normalized_code_type = 'icd-10-cm'\n), ccsr__dx_vertical_pivot as (\n \n select * from cms_synthetic.ccsr.dx_vertical_pivot \n\n), condition as (\n \n select * from __dbt__cte__ccsr__stg_core__condition\n\n), dxccsr_body_systems as (\n\n select * from cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems\n\n)\n\nselect \n condition.encounter_id,\n condition.claim_id,\n condition.patient_id,\n condition.normalized_code,\n ccsr__dx_vertical_pivot.code_description,\n condition.condition_rank,\n ccsr__dx_vertical_pivot.ccsr_parent_category,\n dxccsr_body_systems.body_system,\n dxccsr_body_systems.parent_category_description,\n ccsr__dx_vertical_pivot.ccsr_category,\n ccsr__dx_vertical_pivot.ccsr_category_description,\n ccsr__dx_vertical_pivot.ccsr_category_rank,\n ccsr__dx_vertical_pivot.is_ip_default_category,\n ccsr__dx_vertical_pivot.is_op_default_category,\n '2023.1' as dxccsr_version,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom condition\nleft join ccsr__dx_vertical_pivot\n on condition.normalized_code = ccsr__dx_vertical_pivot.code\nleft join dxccsr_body_systems on ccsr__dx_vertical_pivot.ccsr_parent_category = dxccsr_body_systems.ccsr_parent_category", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ccsr__stg_core__condition", "sql": " __dbt__cte__ccsr__stg_core__condition as (\n\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere normalized_code_type = 'icd-10-cm'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__long_procedure_category": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__long_procedure_category", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/final/ccsr__long_procedure_category.sql", "original_file_path": "models/ccsr/final/ccsr__long_procedure_category.sql", "unique_id": "model.the_tuva_project.ccsr__long_procedure_category", "fqn": ["the_tuva_project", "ccsr", "final", "ccsr__long_procedure_category"], "alias": "long_procedure_category", "checksum": {"name": "sha256", "checksum": "8f3593bf7baaf7b6200496a07e5a524945b9e59810c9c74dca76b27dc895c22b"}, "config": {"enabled": true, "alias": "long_procedure_category", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This model contains a mapping of individual condition ICD-10-PCS procedure codes to the CCSR's clinically meaningful procedure categories. Each row represents a mapping of an ICD-10 code to a CCSR category. The model is equivalent to the CCSR's Output Option 1 - Vertical File Output.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "The encounter_id for the encounter where this procedure was performed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The ICD-10-PCS code for the procedure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The ICD-10-PCS code description provided in the CCSR CSV seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category code for each CCSR category. In practice, this is the three letter prefix to the category code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "clinical_domain": {"name": "clinical_domain", "description": "The ICD-10-PCS Clinical Domain that the CCSR parent category belongs to. Note that the condition models don't have this column, but the `body_system` is a conceptually related column in the condition tables.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "A description of the clinical domain.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "The CCSR category mapped to the ICD-10-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prccsr_version": {"name": "prccsr_version", "description": "The version number of the CCSR program from which the dbt model was derived.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "long_procedure_category", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1266072, "relation_name": "cms_synthetic.ccsr.long_procedure_category", "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith procedures as (\n\n select * from {{ ref('ccsr__stg_core__procedure') }}\n\n)\n\n, ccsr__procedure_category_map as (\n\n select * from {{ ref ('ccsr__procedure_category_map') }}\n\n)\n\nselect distinct\n procedures.encounter_id\n , procedures.claim_id\n , procedures.patient_id\n , procedures.normalized_code\n , ccsr__procedure_category_map.code_description\n , ccsr__procedure_category_map.ccsr_parent_category\n , ccsr__procedure_category_map.ccsr_category\n , ccsr__procedure_category_map.ccsr_category_description\n , ccsr__procedure_category_map.clinical_domain\n , {{ var('prccsr_version') }} as prccsr_version\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom procedures\nleft join ccsr__procedure_category_map\n on procedures.normalized_code = ccsr__procedure_category_map.code", "language": "sql", "refs": [{"name": "ccsr__stg_core__procedure", "package": null, "version": null}, {"name": "ccsr__procedure_category_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ccsr__stg_core__procedure", "model.the_tuva_project.ccsr__procedure_category_map"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/final/ccsr__long_procedure_category.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__procedure as (\n\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), procedures as (\n\n select * from __dbt__cte__ccsr__stg_core__procedure\n\n)\n\n, ccsr__procedure_category_map as (\n\n select * from cms_synthetic.ccsr.procedure_category_map\n\n)\n\nselect distinct\n procedures.encounter_id\n , procedures.claim_id\n , procedures.patient_id\n , procedures.normalized_code\n , ccsr__procedure_category_map.code_description\n , ccsr__procedure_category_map.ccsr_parent_category\n , ccsr__procedure_category_map.ccsr_category\n , ccsr__procedure_category_map.ccsr_category_description\n , ccsr__procedure_category_map.clinical_domain\n , '2023.1' as prccsr_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom procedures\nleft join ccsr__procedure_category_map\n on procedures.normalized_code = ccsr__procedure_category_map.code", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ccsr__stg_core__procedure", "sql": " __dbt__cte__ccsr__stg_core__procedure as (\n\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__dx_vertical_pivot": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__dx_vertical_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/intermediate/ccsr__dx_vertical_pivot.sql", "original_file_path": "models/ccsr/intermediate/ccsr__dx_vertical_pivot.sql", "unique_id": "model.the_tuva_project.ccsr__dx_vertical_pivot", "fqn": ["the_tuva_project", "ccsr", "intermediate", "ccsr__dx_vertical_pivot"], "alias": "dx_vertical_pivot", "checksum": {"name": "sha256", "checksum": "8f6010aca62c26b4df6cb87a9a2fd8479a1c9511cf65e1a93e6bc3b6ba001708"}, "config": {"enabled": true, "alias": "dx_vertical_pivot", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This is an intermediate model that pivots the DXCCSR's wide-format mapping CSV into a long format table. While the seed uses 6 columns to represent the 6 CCSR codes that may be present, this generates one row for each CCSR category per ICD code, so up to 6 rows per code. \nThis model includes details and descriptions of the CCSR parent category and body systems that are inherited by the final models.\nThis model may also be useful in looking up CCSR condition category, body system, and parent category information.\n", "columns": {"code": {"name": "code", "description": "The ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The description of the ICD-10-CM code included in the seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "A CCSR category for the ICD-10-CM code. One ICD-10-CM code may have up 6 CCSR categories associated, ordinally ranked by the ccsr_category_rank. Will be null if a record has a `code` that isn't referenced in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_rank": {"name": "ccsr_category_rank", "description": "The ordinal rank of a given CCSR category mapped to an ICD-10-CM code. The CCSR seed CSV has the order of categories assigned to each ICD-10-CM code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "The human readable description of the `ccsr_category`.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The CCSR parent category - the three letter prefix for each alphanumeric category.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_ip_default_category": {"name": "is_ip_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an inpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_op_default_category": {"name": "is_op_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an outpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "dx_vertical_pivot", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.128651, "relation_name": "cms_synthetic.ccsr.dx_vertical_pivot", "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith codes as (\n \n select\n icd_10_cm_code as code, \n icd_10_cm_code_description as code_description,\n -- loop to generate columns for CCSR categories 1-6\n {%- for i in range(1,7) %}\n ccsr_category_{{ i }},\n ccsr_category_{{ i }}_description,\n {%- endfor %}\n default_ccsr_category_ip,\n default_ccsr_category_op\n from {{ ref('ccsr__dxccsr_v2023_1_cleaned_map') }}\n\n), long_union as (\n -- generate select & union statements to pivot category columns to rows\n {% for i in range(1,7,1) %}\n select \n code,\n code_description,\n substring(ccsr_category_{{ i }}, 1, 3) as ccsr_parent_category,\n ccsr_category_{{ i }} as ccsr_category,\n ccsr_category_{{ i }}_description as ccsr_category_description,\n {{ i }} as ccsr_category_rank,\n CASE WHEN ccsr_category_{{ i }} = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_{{ i }} = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n {{ \"union all\" if not loop.last else \"\" }}\n {%- endfor %}\n\n)\n\nselect distinct\n *,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom long_union\n-- as not all diagnosis codes have multiple categories, we can discard nulls\nwhere ccsr_category is not null", "language": "sql", "refs": [{"name": "ccsr__dxccsr_v2023_1_cleaned_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/intermediate/ccsr__dx_vertical_pivot.sql", "compiled": true, "compiled_code": "\n\nwith codes as (\n \n select\n icd_10_cm_code as code, \n icd_10_cm_code_description as code_description,\n -- loop to generate columns for CCSR categories 1-6\n ccsr_category_1,\n ccsr_category_1_description,\n ccsr_category_2,\n ccsr_category_2_description,\n ccsr_category_3,\n ccsr_category_3_description,\n ccsr_category_4,\n ccsr_category_4_description,\n ccsr_category_5,\n ccsr_category_5_description,\n ccsr_category_6,\n ccsr_category_6_description,\n default_ccsr_category_ip,\n default_ccsr_category_op\n from cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map\n\n), long_union as (\n -- generate select & union statements to pivot category columns to rows\n \n select \n code,\n code_description,\n substring(ccsr_category_1, 1, 3) as ccsr_parent_category,\n ccsr_category_1 as ccsr_category,\n ccsr_category_1_description as ccsr_category_description,\n 1 as ccsr_category_rank,\n CASE WHEN ccsr_category_1 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_1 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_2, 1, 3) as ccsr_parent_category,\n ccsr_category_2 as ccsr_category,\n ccsr_category_2_description as ccsr_category_description,\n 2 as ccsr_category_rank,\n CASE WHEN ccsr_category_2 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_2 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_3, 1, 3) as ccsr_parent_category,\n ccsr_category_3 as ccsr_category,\n ccsr_category_3_description as ccsr_category_description,\n 3 as ccsr_category_rank,\n CASE WHEN ccsr_category_3 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_3 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_4, 1, 3) as ccsr_parent_category,\n ccsr_category_4 as ccsr_category,\n ccsr_category_4_description as ccsr_category_description,\n 4 as ccsr_category_rank,\n CASE WHEN ccsr_category_4 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_4 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_5, 1, 3) as ccsr_parent_category,\n ccsr_category_5 as ccsr_category,\n ccsr_category_5_description as ccsr_category_description,\n 5 as ccsr_category_rank,\n CASE WHEN ccsr_category_5 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_5 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_6, 1, 3) as ccsr_parent_category,\n ccsr_category_6 as ccsr_category,\n ccsr_category_6_description as ccsr_category_description,\n 6 as ccsr_category_rank,\n CASE WHEN ccsr_category_6 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_6 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n \n\n)\n\nselect distinct\n *,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom long_union\n-- as not all diagnosis codes have multiple categories, we can discard nulls\nwhere ccsr_category is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__procedure_category_map": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__procedure_category_map", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr/intermediate/ccsr__procedure_category_map.sql", "original_file_path": "models/ccsr/intermediate/ccsr__procedure_category_map.sql", "unique_id": "model.the_tuva_project.ccsr__procedure_category_map", "fqn": ["the_tuva_project", "ccsr", "intermediate", "ccsr__procedure_category_map"], "alias": "procedure_category_map", "checksum": {"name": "sha256", "checksum": "bcc339668dd954f887c5618c0f7761d8bcdf93a7e29ab532cdc9dd1da3491c38"}, "config": {"enabled": true, "alias": "procedure_category_map", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This is an intermediate model that renames some PRCCSR columns to align with other TUVA models as well as the `ccsr__dx_vertical_pivot` model.\n", "columns": {"code": {"name": "code", "description": "The ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The description of the ICD-10-PCS code included in the seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "The CCSR category to which the ICD-10 code is mapped.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "A description of the CCSR category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "clinical_domain": {"name": "clinical_domain", "description": "The clinical domain to which the CCSR code belongs. Note that the condition models don't have this column, but the `body_system` is a conceptually related column in the condition tables.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The CCSR parent category - the three letter prefix for each alphanumeric category.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/ccsr/ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "procedure_category_map", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.130222, "relation_name": "cms_synthetic.ccsr.procedure_category_map", "raw_code": "{{ config(\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nselect \n icd_10_pcs as code,\n icd_10_pcs_description as code_description,\n prccsr as ccsr_category,\n substring(prccsr, 1, 3) as ccsr_parent_category,\n prccsr_description as ccsr_category_description,\n clinical_domain,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('ccsr__prccsr_v2023_1_cleaned_map')}}", "language": "sql", "refs": [{"name": "ccsr__prccsr_v2023_1_cleaned_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map"]}, "compiled_path": "../target/compiled/the_tuva_project/models/ccsr/intermediate/ccsr__procedure_category_map.sql", "compiled": true, "compiled_code": "\n\nselect \n icd_10_pcs as code,\n icd_10_pcs_description as code_description,\n prccsr as ccsr_category,\n substring(prccsr, 1, 3) as ccsr_parent_category,\n prccsr_description as ccsr_category_description,\n clinical_domain,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ccsr._value_set_prccsr_v2023_1_cleaned_map", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_provider_attribution": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "financial_pmpm__stg_provider_attribution", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/staging/financial_pmpm__stg_provider_attribution.sql", "original_file_path": "models/financial_pmpm/staging/financial_pmpm__stg_provider_attribution.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_provider_attribution", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_provider_attribution"], "alias": "financial_pmpm__stg_provider_attribution", "checksum": {"name": "sha256", "checksum": "135ea404e3caedc1047d5d58fbba115f47088746d80566f0061c39ebaafbdb79"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": "financial_pmpm", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.157136, "relation_name": null, "raw_code": "{{ config(\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\n )\n}}\n\n{% if var('provider_attribution_enabled',False) == true -%}\n\n\nselect\n cast(patient_id as {{ dbt.type_string() }} ) as patient_id\n , cast(year_month as {{ dbt.type_string() }} ) as year_month\n , cast(payer as {{ dbt.type_string() }} ) as payer\n , {{ quote_column('plan') }}\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\n \n , cast(payer_attributed_provider as {{ dbt.type_string() }} )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as {{ dbt.type_string() }} )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as {{ dbt.type_string() }} )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as {{ dbt.type_string() }} )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as {{ dbt.type_string() }} )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as {{ dbt.type_string() }} )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as {{ dbt.type_string() }} )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as {{ dbt.type_string() }} )\n as custom_attributed_provider_lob\n\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n \nfrom {{ ref('provider_attribution') }}\n\n\n\n{%- else %}\n\n\nselect\n cast(null as {{ dbt.type_string() }} ) patient_id\n , cast(null as {{ dbt.type_string() }} ) as year_month\n , cast(null as {{ dbt.type_string() }} ) as payer\n , cast(null as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\n , cast(null as {{ dbt.type_string() }} ) as data_source\n \n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider_practice\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider_organization\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider_lob\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider_practice\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider_organization\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider_lob\n , cast(null as {{ dbt.type_string() }} ) as tuva_last_run\n\nlimit 0\n\n{%- endif %}", "language": "sql", "refs": [{"name": "provider_attribution", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.provider_attribution"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/staging/financial_pmpm__stg_provider_attribution.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_eligibility": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "financial_pmpm__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/staging/financial_pmpm__stg_eligibility.sql", "original_file_path": "models/financial_pmpm/staging/financial_pmpm__stg_eligibility.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_eligibility", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_eligibility"], "alias": "financial_pmpm__stg_eligibility", "checksum": {"name": "sha256", "checksum": "af874b19f7fc54399938f15a14256523f64b69ab2fd0eaee785fbd3ccf0ce888"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": ["financial_pmpm"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1549811, "relation_name": null, "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , {{ quote_column('plan') }}\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__eligibility') }}", "language": "sql", "refs": [{"name": "core__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/staging/financial_pmpm__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_medical_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "financial_pmpm__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/staging/financial_pmpm__stg_medical_claim.sql", "original_file_path": "models/financial_pmpm/staging/financial_pmpm__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_medical_claim", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_medical_claim"], "alias": "financial_pmpm__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "8526675e6961aa47ece72283025c473eec734e6583b9989425897248d1922619"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": "financial_pmpm", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.155815, "relation_name": null, "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , {{ quote_column('plan') }}\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medical_claim') }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/staging/financial_pmpm__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "financial_pmpm__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/staging/financial_pmpm__stg_pharmacy_claim.sql", "original_file_path": "models/financial_pmpm/staging/financial_pmpm__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_pharmacy_claim"], "alias": "financial_pmpm__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "eceb36ac9689359bfd68b15263f0cd5bf76b6c4cc3a35b0911c0a3163ff20ac8"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": "financial_pmpm", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.156495, "relation_name": null, "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , {{ quote_column('plan') }}\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__pharmacy_claim') }}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/staging/financial_pmpm__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__pmpm_payer": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__pmpm_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/final/financial_pmpm__pmpm_payer.sql", "original_file_path": "models/financial_pmpm/final/financial_pmpm__pmpm_payer.sql", "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer", "fqn": ["the_tuva_project", "financial_pmpm", "final", "financial_pmpm__pmpm_payer"], "alias": "pmpm_payer", "checksum": {"name": "sha256", "checksum": "37eaee88d8b3d43766f93e14b8d1a06be897df330294c47627a8552ed65a8206"}, "config": {"enabled": true, "alias": "pmpm_payer", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Computes per member per month statistics for every service category by aggregating across patients from pmpm_prep. This version of the table computes at the payer grain.\n", "columns": {"year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "The sum of member months.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid": {"name": "total_paid", "description": "Total paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid": {"name": "medical_paid", "description": "Total medical paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_paid": {"name": "inpatient_paid", "description": "Total inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_paid": {"name": "outpatient_paid", "description": "Total outpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid": {"name": "office_visit_paid", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_paid": {"name": "ancillary_paid", "description": "Total ancillary paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid": {"name": "pharmacy_paid", "description": "Total pharmacy paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_paid": {"name": "other_paid", "description": "Total other paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_paid": {"name": "acute_inpatient_paid", "description": "Total acute inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_paid": {"name": "ambulance_paid", "description": "Total ambulance paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_paid": {"name": "ambulatory_surgery_paid", "description": "Total ambulatory surgery paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_paid": {"name": "dialysis_paid", "description": "Total dialysis paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_paid": {"name": "durable_medical_equipment_paid", "description": "Total durable medical equipment paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_paid": {"name": "emergency_department_paid", "description": "Total emergency department paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_paid": {"name": "home_health_paid", "description": "Total home health paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_paid": {"name": "hospice_paid", "description": "Total hospice paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_paid": {"name": "inpatient_psychiatric_paid", "description": "Total inpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_paid": {"name": "inpatient_rehabilitation_paid", "description": "Total inpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_paid": {"name": "lab_paid", "description": "Total lab paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid_2": {"name": "office_visit_paid_2", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_paid": {"name": "outpatient_hospital_or_clinic_paid", "description": "Total outpatient hospital or clinic paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_paid": {"name": "outpatient_psychiatric_paid", "description": "Total outpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_paid": {"name": "outpatient_rehabilitation_paid", "description": "Total outpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_paid": {"name": "skilled_nursing_paid", "description": "Total skilled nursing paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_paid": {"name": "urgent_care_paid", "description": "Total urgent care paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed": {"name": "total_allowed", "description": "Total allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_allowed": {"name": "medical_allowed", "description": "Total medical allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_allowed": {"name": "inpatient_allowed", "description": "Total inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_allowed": {"name": "outpatient_allowed", "description": "Total outpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed": {"name": "office_visit_allowed", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_allowed": {"name": "ancillary_allowed", "description": "Total ancillary allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_allowed": {"name": "pharmacy_allowed", "description": "Total pharmacy allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_allowed": {"name": "other_allowed", "description": "Total other allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_allowed": {"name": "acute_inpatient_allowed", "description": "Total acute inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_allowed": {"name": "ambulance_allowed", "description": "Total ambulance allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_allowed": {"name": "ambulatory_surgery_allowed", "description": "Total ambulatory surgery allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_allowed": {"name": "dialysis_allowed", "description": "Total dialysis allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_allowed": {"name": "durable_medical_equipment_allowed", "description": "Total durable medical equipment allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_allowed": {"name": "emergency_department_allowed", "description": "Total emergency department allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_allowed": {"name": "home_health_allowed", "description": "Total home health allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_allowed": {"name": "hospice_allowed", "description": "Total hospice allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_allowed": {"name": "inpatient_psychiatric_allowed", "description": "Total inpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_allowed": {"name": "inpatient_rehabilitation_allowed", "description": "Total inpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_allowed": {"name": "lab_allowed", "description": "Total lab allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed_2": {"name": "office_visit_allowed_2", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_allowed": {"name": "outpatient_hospital_or_clinic_allowed", "description": "Total outpatient hospital or clinic allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_allowed": {"name": "outpatient_psychiatric_allowed", "description": "Total outpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_allowed": {"name": "outpatient_rehabilitation_allowed", "description": "Total outpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_allowed": {"name": "skilled_nursing_allowed", "description": "Total skilled nursing allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_allowed": {"name": "urgent_care_allowed", "description": "Total urgent care allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "pmpm_payer", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.14748, "relation_name": "cms_synthetic.financial_pmpm.pmpm_payer", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n)}}\n\nselect\n year_month\n , payer\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom {{ ref('financial_pmpm__pmpm_prep') }} a\ngroup by\n year_month\n, payer\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/final/financial_pmpm__pmpm_payer.sql", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n, payer\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__pmpm_prep": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__pmpm_prep", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/final/financial_pmpm__pmpm_prep.sql", "original_file_path": "models/financial_pmpm/final/financial_pmpm__pmpm_prep.sql", "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_prep", "fqn": ["the_tuva_project", "financial_pmpm", "final", "financial_pmpm__pmpm_prep"], "alias": "pmpm_prep", "checksum": {"name": "sha256", "checksum": "c373c76ca869cabee7c1c3d2523ac8869fac1c97a8b2fbcc233adeca9c93f491"}, "config": {"enabled": true, "alias": "pmpm_prep", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Computes all the paid and allowed statistics for every patient_id and year_month combination.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider": {"name": "payer_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the payer.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "description": "Name of the practice for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "description": "Name of the organization for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "description": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider": {"name": "custom_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "description": "Name of the practice for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "description": "Name of the organization for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "description": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_paid": {"name": "inpatient_paid", "description": "Total inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_paid": {"name": "outpatient_paid", "description": "Total outpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid": {"name": "office_visit_paid", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_paid": {"name": "ancillary_paid", "description": "Total ancillary paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid": {"name": "pharmacy_paid", "description": "Total pharmacy paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_paid": {"name": "other_paid", "description": "Total other paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_paid": {"name": "acute_inpatient_paid", "description": "Total acute inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_paid": {"name": "ambulance_paid", "description": "Total ambulance paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_paid": {"name": "ambulatory_surgery_paid", "description": "Total ambulatory surgery paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_paid": {"name": "dialysis_paid", "description": "Total dialysis paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_paid": {"name": "durable_medical_equipment_paid", "description": "Total durable medical equipment paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_paid": {"name": "emergency_department_paid", "description": "Total emergency department paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_paid": {"name": "home_health_paid", "description": "Total home health paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_paid": {"name": "hospice_paid", "description": "Total hospice paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_paid": {"name": "inpatient_psychiatric_paid", "description": "Total inpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_paid": {"name": "inpatient_rehabilitation_paid", "description": "Total inpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_paid": {"name": "lab_paid", "description": "Total lab paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid_2": {"name": "office_visit_paid_2", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_paid": {"name": "outpatient_hospital_or_clinic_paid", "description": "Total outpatient hospital or clinic paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_paid": {"name": "outpatient_psychiatric_paid", "description": "Total outpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_paid": {"name": "outpatient_rehabilitation_paid", "description": "Total outpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_paid": {"name": "skilled_nursing_paid", "description": "Total skilled nursing paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_paid": {"name": "urgent_care_paid", "description": "Total urgent care paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_allowed": {"name": "inpatient_allowed", "description": "Total inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_allowed": {"name": "outpatient_allowed", "description": "Total outpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed": {"name": "office_visit_allowed", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_allowed": {"name": "ancillary_allowed", "description": "Total ancillary allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_allowed": {"name": "pharmacy_allowed", "description": "Total pharmacy allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_allowed": {"name": "other_allowed", "description": "Total other allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_allowed": {"name": "acute_inpatient_allowed", "description": "Total acute inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_allowed": {"name": "ambulance_allowed", "description": "Total ambulance allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_allowed": {"name": "ambulatory_surgery_allowed", "description": "Total ambulatory surgery allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_allowed": {"name": "dialysis_allowed", "description": "Total dialysis allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_allowed": {"name": "durable_medical_equipment_allowed", "description": "Total durable medical equipment allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_allowed": {"name": "emergency_department_allowed", "description": "Total emergency department allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_allowed": {"name": "home_health_allowed", "description": "Total home health allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_allowed": {"name": "hospice_allowed", "description": "Total hospice allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_allowed": {"name": "inpatient_psychiatric_allowed", "description": "Total inpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_allowed": {"name": "inpatient_rehabilitation_allowed", "description": "Total inpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_allowed": {"name": "lab_allowed", "description": "Total lab allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed_2": {"name": "office_visit_allowed_2", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_allowed": {"name": "outpatient_hospital_or_clinic_allowed", "description": "Total outpatient hospital or clinic allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_allowed": {"name": "outpatient_psychiatric_allowed", "description": "Total outpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_allowed": {"name": "outpatient_rehabilitation_allowed", "description": "Total outpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_allowed": {"name": "skilled_nursing_allowed", "description": "Total skilled nursing allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_allowed": {"name": "urgent_care_allowed", "description": "Total urgent care allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid": {"name": "total_paid", "description": "Total paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid": {"name": "medical_paid", "description": "Total medical paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed": {"name": "total_allowed", "description": "Total allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_allowed": {"name": "medical_allowed", "description": "Total medical allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "pmpm_prep", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.142022, "relation_name": "cms_synthetic.financial_pmpm.pmpm_prep", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\n )\n}}\n\nwith combine as (\n select\n a.patient_id\n , a.year_month\n , a.payer\n , a.{{ quote_column('plan') }}\n , a.data_source\n , a.payer_attributed_provider\n , a.payer_attributed_provider_practice\n , a.payer_attributed_provider_organization\n , a.payer_attributed_provider_lob\n , a.custom_attributed_provider\n , a.custom_attributed_provider_practice\n , a.custom_attributed_provider_organization\n , a.custom_attributed_provider_lob\n\n -- service cat 1 paid\n , coalesce(b.inpatient_paid, 0) as inpatient_paid\n , coalesce(b.outpatient_paid, 0) as outpatient_paid\n , coalesce(b.office_based_paid, 0) as office_based_paid\n , coalesce(b.ancillary_paid, 0) as ancillary_paid\n , coalesce(b.other_paid, 0) as other_paid\n , coalesce(b.pharmacy_paid, 0) as pharmacy_paid\n\n -- service cat 2 paid\n , coalesce(c.acute_inpatient_paid, 0) as acute_inpatient_paid\n , coalesce(c.ambulance_paid, 0) as ambulance_paid\n , coalesce(c.ambulatory_surgery_center_paid, 0) as ambulatory_surgery_center_paid\n , coalesce(c.dialysis_paid, 0) as dialysis_paid\n , coalesce(c.durable_medical_equipment_paid, 0) as durable_medical_equipment_paid\n , coalesce(c.emergency_department_paid, 0) as emergency_department_paid\n , coalesce(c.home_health_paid, 0) as home_health_paid\n , coalesce(c.inpatient_hospice_paid, 0) as inpatient_hospice_paid\n , coalesce(c.inpatient_psychiatric_paid, 0) as inpatient_psychiatric_paid\n , coalesce(c.inpatient_rehabilitation_paid, 0) as inpatient_rehabilitation_paid\n , coalesce(c.lab_paid, 0) as lab_paid\n , coalesce(c.observation_paid, 0) as observation_paid\n , coalesce(c.office_based_other_paid, 0) as office_based_other_paid\n , coalesce(c.office_based_ptotst_paid, 0) as office_based_pt_ot_st_paid\n , coalesce(c.office_based_radiology_paid, 0) as office_based_radiology_paid\n , coalesce(c.office_based_surgery_paid, 0) as office_based_surgery_paid\n , coalesce(c.office_based_visit_paid, 0) as office_based_visit_paid\n , coalesce(c.other_paid, 0) as other_paid_2\n , coalesce(c.outpatient_hospice_paid, 0) as outpatient_hospice_paid\n , coalesce(c.outpatient_hospital_or_clinic_paid, 0) as outpatient_hospital_or_clinic_paid\n , coalesce(c.outpatient_ptotst_paid, 0) as outpatient_pt_ot_st_paid\n , coalesce(c.outpatient_psychiatric_paid, 0) as outpatient_psychiatric_paid\n , coalesce(c.outpatient_radiology_paid, 0) as outpatient_radiology_paid\n , coalesce(c.outpatient_rehabilitation_paid, 0) as outpatient_rehabilitation_paid\n , coalesce(c.outpatient_surgery_paid, 0) as outpatient_surgery_paid\n , coalesce(c.pharmacy_paid, 0) as pharmacy_paid_2\n , coalesce(c.skilled_nursing_paid, 0) as skilled_nursing_paid\n , coalesce(c.telehealth_visit_paid, 0) as telehealth_visit_paid\n , coalesce(c.urgent_care_paid, 0) as urgent_care_paid\n\n -- service cat 1 allowed\n , coalesce(d.inpatient_allowed, 0) as inpatient_allowed\n , coalesce(d.outpatient_allowed, 0) as outpatient_allowed\n , coalesce(d.office_based_allowed, 0) as office_based_allowed\n , coalesce(d.ancillary_allowed, 0) as ancillary_allowed\n , coalesce(d.other_allowed, 0) as other_allowed\n , coalesce(d.pharmacy_allowed, 0) as pharmacy_allowed\n\n -- service cat 2 allowed\n , coalesce(e.acute_inpatient_allowed, 0) as acute_inpatient_allowed\n , coalesce(e.ambulance_allowed, 0) as ambulance_allowed\n , coalesce(e.ambulatory_surgery_center_allowed, 0) as ambulatory_surgery_center_allowed\n , coalesce(e.dialysis_allowed, 0) as dialysis_allowed\n , coalesce(e.durable_medical_equipment_allowed, 0) as durable_medical_equipment_allowed\n , coalesce(e.emergency_department_allowed, 0) as emergency_department_allowed\n , coalesce(e.home_health_allowed, 0) as home_health_allowed\n , coalesce(e.inpatient_hospice_allowed, 0) as inpatient_hospice_allowed\n , coalesce(e.inpatient_psychiatric_allowed, 0) as inpatient_psychiatric_allowed\n , coalesce(e.inpatient_rehabilitation_allowed, 0) as inpatient_rehabilitation_allowed\n , coalesce(e.lab_allowed, 0) as lab_allowed\n , coalesce(e.observation_allowed, 0) as observation_allowed\n , coalesce(e.office_based_other_allowed, 0) as office_based_other_allowed\n , coalesce(e.office_based_ptotst_allowed, 0) as office_based_pt_ot_st_allowed\n , coalesce(e.office_based_radiology_allowed, 0) as office_based_radiology_allowed\n , coalesce(e.office_based_surgery_allowed, 0) as office_based_surgery_allowed\n , coalesce(e.office_based_visit_allowed, 0) as office_based_visit_allowed\n , coalesce(e.other_allowed, 0) as other_allowed_2\n , coalesce(e.outpatient_hospice_allowed, 0) as outpatient_hospice_allowed\n , coalesce(e.outpatient_hospital_or_clinic_allowed, 0) as outpatient_hospital_or_clinic_allowed\n , coalesce(e.outpatient_ptotst_allowed, 0) as outpatient_pt_ot_st_allowed\n , coalesce(e.outpatient_psychiatric_allowed, 0) as outpatient_psychiatric_allowed\n , coalesce(e.outpatient_radiology_allowed, 0) as outpatient_radiology_allowed\n , coalesce(e.outpatient_rehabilitation_allowed, 0) as outpatient_rehabilitation_allowed\n , coalesce(e.outpatient_surgery_allowed, 0) as outpatient_surgery_allowed\n , coalesce(e.pharmacy_allowed, 0) as pharmacy_allowed_2\n , coalesce(e.skilled_nursing_allowed, 0) as skilled_nursing_allowed\n , coalesce(e.telehealth_visit_allowed, 0) as telehealth_visit_allowed\n , coalesce(e.urgent_care_allowed, 0) as urgent_care_allowed\n\n from {{ ref('core__member_months') }} as a\n left join {{ ref('financial_pmpm__service_category_1_paid_pivot') }} as b\n on a.patient_id = b.patient_id\n and a.year_month = b.year_month\n and a.payer = b.payer\n and a.{{ quote_column('plan') }} = b.{{ quote_column('plan') }}\n left join {{ ref('financial_pmpm__service_category_2_paid_pivot') }} as c\n on a.patient_id = c.patient_id\n and a.year_month = c.year_month\n and a.payer = c.payer\n and a.{{ quote_column('plan') }} = c.{{ quote_column('plan') }}\n left join {{ ref('financial_pmpm__service_category_1_allowed_pivot') }} as d\n on a.patient_id = d.patient_id\n and a.year_month = d.year_month\n and a.payer = d.payer\n and a.{{ quote_column('plan') }} = d.{{ quote_column('plan') }}\n left join {{ ref('financial_pmpm__service_category_2_allowed_pivot') }} as e\n on a.patient_id = e.patient_id\n and a.year_month = e.year_month\n and a.payer = e.payer\n and a.{{ quote_column('plan') }} = e.{{ quote_column('plan') }}\n)\n\nselect\n *\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid + pharmacy_paid as total_paid\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid as medical_paid\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed + pharmacy_allowed as total_allowed\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed as medical_allowed\n , '{{ var('tuva_last_run') }}' as tuva_last_run\nfrom combine", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "financial_pmpm__service_category_1_paid_pivot", "package": null, "version": null}, {"name": "financial_pmpm__service_category_2_paid_pivot", "package": null, "version": null}, {"name": "financial_pmpm__service_category_1_allowed_pivot", "package": null, "version": null}, {"name": "financial_pmpm__service_category_2_allowed_pivot", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/final/financial_pmpm__pmpm_prep.sql", "compiled": true, "compiled_code": "\n\nwith combine as (\n select\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.payer_attributed_provider\n , a.payer_attributed_provider_practice\n , a.payer_attributed_provider_organization\n , a.payer_attributed_provider_lob\n , a.custom_attributed_provider\n , a.custom_attributed_provider_practice\n , a.custom_attributed_provider_organization\n , a.custom_attributed_provider_lob\n\n -- service cat 1 paid\n , coalesce(b.inpatient_paid, 0) as inpatient_paid\n , coalesce(b.outpatient_paid, 0) as outpatient_paid\n , coalesce(b.office_based_paid, 0) as office_based_paid\n , coalesce(b.ancillary_paid, 0) as ancillary_paid\n , coalesce(b.other_paid, 0) as other_paid\n , coalesce(b.pharmacy_paid, 0) as pharmacy_paid\n\n -- service cat 2 paid\n , coalesce(c.acute_inpatient_paid, 0) as acute_inpatient_paid\n , coalesce(c.ambulance_paid, 0) as ambulance_paid\n , coalesce(c.ambulatory_surgery_center_paid, 0) as ambulatory_surgery_center_paid\n , coalesce(c.dialysis_paid, 0) as dialysis_paid\n , coalesce(c.durable_medical_equipment_paid, 0) as durable_medical_equipment_paid\n , coalesce(c.emergency_department_paid, 0) as emergency_department_paid\n , coalesce(c.home_health_paid, 0) as home_health_paid\n , coalesce(c.inpatient_hospice_paid, 0) as inpatient_hospice_paid\n , coalesce(c.inpatient_psychiatric_paid, 0) as inpatient_psychiatric_paid\n , coalesce(c.inpatient_rehabilitation_paid, 0) as inpatient_rehabilitation_paid\n , coalesce(c.lab_paid, 0) as lab_paid\n , coalesce(c.observation_paid, 0) as observation_paid\n , coalesce(c.office_based_other_paid, 0) as office_based_other_paid\n , coalesce(c.office_based_ptotst_paid, 0) as office_based_pt_ot_st_paid\n , coalesce(c.office_based_radiology_paid, 0) as office_based_radiology_paid\n , coalesce(c.office_based_surgery_paid, 0) as office_based_surgery_paid\n , coalesce(c.office_based_visit_paid, 0) as office_based_visit_paid\n , coalesce(c.other_paid, 0) as other_paid_2\n , coalesce(c.outpatient_hospice_paid, 0) as outpatient_hospice_paid\n , coalesce(c.outpatient_hospital_or_clinic_paid, 0) as outpatient_hospital_or_clinic_paid\n , coalesce(c.outpatient_ptotst_paid, 0) as outpatient_pt_ot_st_paid\n , coalesce(c.outpatient_psychiatric_paid, 0) as outpatient_psychiatric_paid\n , coalesce(c.outpatient_radiology_paid, 0) as outpatient_radiology_paid\n , coalesce(c.outpatient_rehabilitation_paid, 0) as outpatient_rehabilitation_paid\n , coalesce(c.outpatient_surgery_paid, 0) as outpatient_surgery_paid\n , coalesce(c.pharmacy_paid, 0) as pharmacy_paid_2\n , coalesce(c.skilled_nursing_paid, 0) as skilled_nursing_paid\n , coalesce(c.telehealth_visit_paid, 0) as telehealth_visit_paid\n , coalesce(c.urgent_care_paid, 0) as urgent_care_paid\n\n -- service cat 1 allowed\n , coalesce(d.inpatient_allowed, 0) as inpatient_allowed\n , coalesce(d.outpatient_allowed, 0) as outpatient_allowed\n , coalesce(d.office_based_allowed, 0) as office_based_allowed\n , coalesce(d.ancillary_allowed, 0) as ancillary_allowed\n , coalesce(d.other_allowed, 0) as other_allowed\n , coalesce(d.pharmacy_allowed, 0) as pharmacy_allowed\n\n -- service cat 2 allowed\n , coalesce(e.acute_inpatient_allowed, 0) as acute_inpatient_allowed\n , coalesce(e.ambulance_allowed, 0) as ambulance_allowed\n , coalesce(e.ambulatory_surgery_center_allowed, 0) as ambulatory_surgery_center_allowed\n , coalesce(e.dialysis_allowed, 0) as dialysis_allowed\n , coalesce(e.durable_medical_equipment_allowed, 0) as durable_medical_equipment_allowed\n , coalesce(e.emergency_department_allowed, 0) as emergency_department_allowed\n , coalesce(e.home_health_allowed, 0) as home_health_allowed\n , coalesce(e.inpatient_hospice_allowed, 0) as inpatient_hospice_allowed\n , coalesce(e.inpatient_psychiatric_allowed, 0) as inpatient_psychiatric_allowed\n , coalesce(e.inpatient_rehabilitation_allowed, 0) as inpatient_rehabilitation_allowed\n , coalesce(e.lab_allowed, 0) as lab_allowed\n , coalesce(e.observation_allowed, 0) as observation_allowed\n , coalesce(e.office_based_other_allowed, 0) as office_based_other_allowed\n , coalesce(e.office_based_ptotst_allowed, 0) as office_based_pt_ot_st_allowed\n , coalesce(e.office_based_radiology_allowed, 0) as office_based_radiology_allowed\n , coalesce(e.office_based_surgery_allowed, 0) as office_based_surgery_allowed\n , coalesce(e.office_based_visit_allowed, 0) as office_based_visit_allowed\n , coalesce(e.other_allowed, 0) as other_allowed_2\n , coalesce(e.outpatient_hospice_allowed, 0) as outpatient_hospice_allowed\n , coalesce(e.outpatient_hospital_or_clinic_allowed, 0) as outpatient_hospital_or_clinic_allowed\n , coalesce(e.outpatient_ptotst_allowed, 0) as outpatient_pt_ot_st_allowed\n , coalesce(e.outpatient_psychiatric_allowed, 0) as outpatient_psychiatric_allowed\n , coalesce(e.outpatient_radiology_allowed, 0) as outpatient_radiology_allowed\n , coalesce(e.outpatient_rehabilitation_allowed, 0) as outpatient_rehabilitation_allowed\n , coalesce(e.outpatient_surgery_allowed, 0) as outpatient_surgery_allowed\n , coalesce(e.pharmacy_allowed, 0) as pharmacy_allowed_2\n , coalesce(e.skilled_nursing_allowed, 0) as skilled_nursing_allowed\n , coalesce(e.telehealth_visit_allowed, 0) as telehealth_visit_allowed\n , coalesce(e.urgent_care_allowed, 0) as urgent_care_allowed\n\n from cms_synthetic.core.member_months as a\n left join cms_synthetic.financial_pmpm._int_service_category_1_paid_pivot as b\n on a.patient_id = b.patient_id\n and a.year_month = b.year_month\n and a.payer = b.payer\n and a.plan = b.plan\n left join cms_synthetic.financial_pmpm._int_service_category_2_paid_pivot as c\n on a.patient_id = c.patient_id\n and a.year_month = c.year_month\n and a.payer = c.payer\n and a.plan = c.plan\n left join cms_synthetic.financial_pmpm._int_service_category_1_allowed_pivot as d\n on a.patient_id = d.patient_id\n and a.year_month = d.year_month\n and a.payer = d.payer\n and a.plan = d.plan\n left join cms_synthetic.financial_pmpm._int_service_category_2_allowed_pivot as e\n on a.patient_id = e.patient_id\n and a.year_month = e.year_month\n and a.payer = e.payer\n and a.plan = e.plan\n)\n\nselect\n *\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid + pharmacy_paid as total_paid\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid as medical_paid\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed + pharmacy_allowed as total_allowed\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed as medical_allowed\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom combine", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__pmpm_payer_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/final/financial_pmpm__pmpm_payer_plan.sql", "original_file_path": "models/financial_pmpm/final/financial_pmpm__pmpm_payer_plan.sql", "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer_plan", "fqn": ["the_tuva_project", "financial_pmpm", "final", "financial_pmpm__pmpm_payer_plan"], "alias": "pmpm_payer_plan", "checksum": {"name": "sha256", "checksum": "f99bffab6a1b69e6a00d58c48264498c25f37b38543b4f80c240104f2c59d497"}, "config": {"enabled": true, "alias": "pmpm_payer_plan", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Computes per member per month statistics for every service category by aggregating across patients from pmpm_prep. This version of the table computes at the payer and plan grain.\n", "columns": {"year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "The sum of member months.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid": {"name": "total_paid", "description": "Total paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid": {"name": "medical_paid", "description": "Total medical paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_paid": {"name": "inpatient_paid", "description": "Total inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_paid": {"name": "outpatient_paid", "description": "Total outpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid": {"name": "office_visit_paid", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_paid": {"name": "ancillary_paid", "description": "Total ancillary paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid": {"name": "pharmacy_paid", "description": "Total pharmacy paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_paid": {"name": "other_paid", "description": "Total other paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_paid": {"name": "acute_inpatient_paid", "description": "Total acute inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_paid": {"name": "ambulance_paid", "description": "Total ambulance paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_paid": {"name": "ambulatory_surgery_paid", "description": "Total ambulatory surgery paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_paid": {"name": "dialysis_paid", "description": "Total dialysis paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_paid": {"name": "durable_medical_equipment_paid", "description": "Total durable medical equipment paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_paid": {"name": "emergency_department_paid", "description": "Total emergency department paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_paid": {"name": "home_health_paid", "description": "Total home health paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_paid": {"name": "hospice_paid", "description": "Total hospice paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_paid": {"name": "inpatient_psychiatric_paid", "description": "Total inpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_paid": {"name": "inpatient_rehabilitation_paid", "description": "Total inpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_paid": {"name": "lab_paid", "description": "Total lab paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid_2": {"name": "office_visit_paid_2", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_paid": {"name": "outpatient_hospital_or_clinic_paid", "description": "Total outpatient hospital or clinic paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_paid": {"name": "outpatient_psychiatric_paid", "description": "Total outpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_paid": {"name": "outpatient_rehabilitation_paid", "description": "Total outpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_paid": {"name": "skilled_nursing_paid", "description": "Total skilled nursing paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_paid": {"name": "urgent_care_paid", "description": "Total urgent care paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed": {"name": "total_allowed", "description": "Total allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_allowed": {"name": "medical_allowed", "description": "Total medical allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_allowed": {"name": "inpatient_allowed", "description": "Total inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_allowed": {"name": "outpatient_allowed", "description": "Total outpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed": {"name": "office_visit_allowed", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_allowed": {"name": "ancillary_allowed", "description": "Total ancillary allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_allowed": {"name": "pharmacy_allowed", "description": "Total pharmacy allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_allowed": {"name": "other_allowed", "description": "Total other allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_allowed": {"name": "acute_inpatient_allowed", "description": "Total acute inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_allowed": {"name": "ambulance_allowed", "description": "Total ambulance allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_allowed": {"name": "ambulatory_surgery_allowed", "description": "Total ambulatory surgery allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_allowed": {"name": "dialysis_allowed", "description": "Total dialysis allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_allowed": {"name": "durable_medical_equipment_allowed", "description": "Total durable medical equipment allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_allowed": {"name": "emergency_department_allowed", "description": "Total emergency department allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_allowed": {"name": "home_health_allowed", "description": "Total home health allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_allowed": {"name": "hospice_allowed", "description": "Total hospice allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_allowed": {"name": "inpatient_psychiatric_allowed", "description": "Total inpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_allowed": {"name": "inpatient_rehabilitation_allowed", "description": "Total inpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_allowed": {"name": "lab_allowed", "description": "Total lab allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed_2": {"name": "office_visit_allowed_2", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_allowed": {"name": "outpatient_hospital_or_clinic_allowed", "description": "Total outpatient hospital or clinic allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_allowed": {"name": "outpatient_psychiatric_allowed", "description": "Total outpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_allowed": {"name": "outpatient_rehabilitation_allowed", "description": "Total outpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_allowed": {"name": "skilled_nursing_allowed", "description": "Total skilled nursing allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_allowed": {"name": "urgent_care_allowed", "description": "Total urgent care allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "pmpm_payer_plan", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1445801, "relation_name": "cms_synthetic.financial_pmpm.pmpm_payer_plan", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n)}}\n\nselect\n year_month\n , payer\n , {{ quote_column('plan') }}\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('financial_pmpm__pmpm_prep') }} a\ngroup by\n year_month\n , payer\n , {{ quote_column('plan') }}\n , data_source", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/final/financial_pmpm__pmpm_payer_plan.sql", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , plan\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n , payer\n , plan\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_1_paid_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/intermediate/financial_pmpm__service_category_1_paid_pivot.sql", "original_file_path": "models/financial_pmpm/intermediate/financial_pmpm__service_category_1_paid_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_1_paid_pivot"], "alias": "_int_service_category_1_paid_pivot", "checksum": {"name": "sha256", "checksum": "9027ec4b7c1c4d078d634516156e71dd21f55ee9d6c83dfffb389c1b639993aa"}, "config": {"enabled": true, "alias": "_int_service_category_1_paid_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out paid amounts into columns by service category level 1.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_1_paid_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.152881, "relation_name": "cms_synthetic.financial_pmpm._int_service_category_1_paid_pivot", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , data_source\n , sum(total_paid) as total_paid\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\n group by\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source\n, {{ dbt_utils.pivot(\n column='service_category_1'\n , values=('inpatient','outpatient','office-based','ancillary','other','pharmacy')\n , agg='sum'\n , then_value='total_paid'\n , else_value= 0\n , quote_identifiers = False\n , suffix='_paid'\n ) }}\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/intermediate/financial_pmpm__service_category_1_paid_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_paid) as total_paid\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_paid\n else 0\n end\n )\n \n \n as ancillary_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_2_paid_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/intermediate/financial_pmpm__service_category_2_paid_pivot.sql", "original_file_path": "models/financial_pmpm/intermediate/financial_pmpm__service_category_2_paid_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_2_paid_pivot"], "alias": "_int_service_category_2_paid_pivot", "checksum": {"name": "sha256", "checksum": "da48b7ac34baa0b05b965ac0e15fd67bf40744fa5841ac01603582077e5791f8"}, "config": {"enabled": true, "alias": "_int_service_category_2_paid_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out paid amounts into columns by service category level 2.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_2_paid_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.15434, "relation_name": "cms_synthetic.financial_pmpm._int_service_category_2_paid_pivot", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_2\n , data_source\n , sum(total_paid) as total_paid\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\n group by\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source\n, {{ dbt_utils.pivot(\n column='service_category_2'\n , values=(\n 'acute inpatient', \n 'ambulance', \n 'ambulatory surgery center', \n 'dialysis', \n 'durable medical equipment', \n 'emergency department', \n 'home health', \n 'inpatient hospice', \n 'inpatient psychiatric', \n 'inpatient rehabilitation', \n 'lab', \n 'observation', \n 'office-based other', \n 'office-based pt/ot/st', \n 'office-based radiology', \n 'office-based surgery', \n 'office-based visit', \n 'other', \n 'outpatient hospice', \n 'outpatient hospital or clinic', \n 'outpatient pt/ot/st', \n 'outpatient psychiatric', \n 'outpatient radiology', \n 'outpatient rehabilitation', \n 'outpatient surgery', \n 'pharmacy', \n 'skilled nursing', \n 'telehealth visit', \n 'urgent care'\n )\n , agg='sum'\n , then_value='total_paid'\n , else_value= 0\n , quote_identifiers = False\n , suffix='_paid'\n ) }}\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/intermediate/financial_pmpm__service_category_2_paid_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_paid) as total_paid\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as acute_inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_paid\n else 0\n end\n )\n \n \n as ambulance_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_paid\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_paid\n else 0\n end\n )\n \n \n as dialysis_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_paid\n else 0\n end\n )\n \n \n as durable_medical_equipment_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_paid\n else 0\n end\n )\n \n \n as emergency_department_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_paid\n else 0\n end\n )\n \n \n as home_health_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_paid\n else 0\n end\n )\n \n \n as lab_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_paid\n else 0\n end\n )\n \n \n as observation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_paid\n else 0\n end\n )\n \n \n as skilled_nursing_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_paid\n else 0\n end\n )\n \n \n as telehealth_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_paid\n else 0\n end\n )\n \n \n as urgent_care_paid\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__patient_spend_with_service_categories", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/intermediate/financial_pmpm__patient_spend_with_service_categories.sql", "original_file_path": "models/financial_pmpm/intermediate/financial_pmpm__patient_spend_with_service_categories.sql", "unique_id": "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__patient_spend_with_service_categories"], "alias": "_int_patient_spend_with_service_categories", "checksum": {"name": "sha256", "checksum": "ee99beca70d173d1b699dc085fbff77a13704587768337173f0fedc64ac16292"}, "config": {"enabled": true, "alias": "_int_patient_spend_with_service_categories", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Adds service categories to claims and sums paid and allowed amounts to the year-month level.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_patient_spend_with_service_categories", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.148951, "relation_name": "cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith claims_with_service_categories as (\n select\n patient_id\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , service_category_2\n , coalesce(claim_start_date,claim_end_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from {{ ref('financial_pmpm__stg_medical_claim') }}\n)\n\n, medical_claims_year_month as (\n select\n patient_id\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , service_category_2\n , {{ dbt.concat([date_part('year', 'claim_date'),\n dbt.right(\n dbt.concat([\"'0'\", date_part('month', 'claim_date')])\n , 2)]) }} as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from claims_with_service_categories\n)\n\n, rx_claims as (\n select\n patient_id\n , payer\n , {{ quote_column('plan') }}\n , 'pharmacy' as service_category_1\n , cast(null as {{ dbt.type_string() }}) as service_category_2\n , coalesce(dispensing_date, paid_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from {{ ref('financial_pmpm__stg_pharmacy_claim') }}\n)\n\n, rx_claims_year_month as (\n select\n patient_id\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , service_category_2\n , {{ dbt.concat([date_part('year', 'claim_date'),\n dbt.right(\n dbt.concat([\"'0'\", date_part('month', 'claim_date')])\n , 2)]) }} as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from rx_claims\n)\n\n, combine_medical_and_rx as (\nselect *\nfrom medical_claims_year_month\n\nunion all\n\nselect *\nfrom rx_claims_year_month\n)\n\nselect\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , service_category_2\n , sum(paid_amount) as total_paid\n , sum(allowed_amount) as total_allowed\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from combine_medical_and_rx\ngroup by\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , service_category_2\n , data_source", "language": "sql", "refs": [{"name": "financial_pmpm__stg_medical_claim", "package": null, "version": null}, {"name": "financial_pmpm__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.right", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.financial_pmpm__stg_medical_claim", "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/intermediate/financial_pmpm__patient_spend_with_service_categories.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__financial_pmpm__stg_medical_claim as (\n\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), __dbt__cte__financial_pmpm__stg_pharmacy_claim as (\n\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n), claims_with_service_categories as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , coalesce(claim_start_date,claim_end_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_medical_claim\n)\n\n, medical_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from claims_with_service_categories\n)\n\n, rx_claims as (\n select\n patient_id\n , payer\n , plan\n , 'pharmacy' as service_category_1\n , cast(null as TEXT) as service_category_2\n , coalesce(dispensing_date, paid_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_pharmacy_claim\n)\n\n, rx_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from rx_claims\n)\n\n, combine_medical_and_rx as (\nselect *\nfrom medical_claims_year_month\n\nunion all\n\nselect *\nfrom rx_claims_year_month\n)\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , sum(paid_amount) as total_paid\n , sum(allowed_amount) as total_allowed\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from combine_medical_and_rx\ngroup by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.financial_pmpm__stg_medical_claim", "sql": " __dbt__cte__financial_pmpm__stg_medical_claim as (\n\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n)"}, {"id": "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim", "sql": " __dbt__cte__financial_pmpm__stg_pharmacy_claim as (\n\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_1_allowed_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/intermediate/financial_pmpm__service_category_1_allowed_pivot.sql", "original_file_path": "models/financial_pmpm/intermediate/financial_pmpm__service_category_1_allowed_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_1_allowed_pivot"], "alias": "_int_service_category_1_allowed_pivot", "checksum": {"name": "sha256", "checksum": "35bc9742605df04981e20c1e6570f349add9842cbb2d6339358c73229c462d49"}, "config": {"enabled": true, "alias": "_int_service_category_1_allowed_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out allowed amounts into columns by service category level 1.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_1_allowed_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.150249, "relation_name": "cms_synthetic.financial_pmpm._int_service_category_1_allowed_pivot", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , data_source\n , sum(total_allowed) as total_allowed\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\n group by\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source\n, {{ dbt_utils.pivot(\n column='service_category_1'\n , values=('inpatient','outpatient','office-based','ancillary','other','pharmacy')\n , agg='sum'\n , then_value='total_allowed'\n , else_value= 0\n , quote_identifiers = False\n , suffix='_allowed'\n ) }}\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/intermediate/financial_pmpm__service_category_1_allowed_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_allowed) as total_allowed\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_allowed\n else 0\n end\n )\n \n \n as ancillary_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": {"database": "cms_synthetic", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_2_allowed_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm/intermediate/financial_pmpm__service_category_2_allowed_pivot.sql", "original_file_path": "models/financial_pmpm/intermediate/financial_pmpm__service_category_2_allowed_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_2_allowed_pivot"], "alias": "_int_service_category_2_allowed_pivot", "checksum": {"name": "sha256", "checksum": "d3de9ec0698d6b7b24700315bde15208803d16fb3c1b1b12aa1af76f7a10ed64"}, "config": {"enabled": true, "alias": "_int_service_category_2_allowed_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out allowed amounts into columns by service category level 2.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/financial_pmpm/financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_2_allowed_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.151631, "relation_name": "cms_synthetic.financial_pmpm._int_service_category_2_allowed_pivot", "raw_code": "{{ config(\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_2\n , data_source\n , sum(total_allowed) as total_allowed\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\n group by\n patient_id\n , year_month\n , payer\n , {{ quote_column('plan') }}\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source\n, {{ dbt_utils.pivot(\n column='service_category_2'\n , values=(\n 'acute inpatient', \n 'ambulance', \n 'ambulatory surgery center', \n 'dialysis', \n 'durable medical equipment', \n 'emergency department', \n 'home health', \n 'inpatient hospice', \n 'inpatient psychiatric', \n 'inpatient rehabilitation', \n 'lab', \n 'observation', \n 'office-based other', \n 'office-based pt/ot/st', \n 'office-based radiology', \n 'office-based surgery', \n 'office-based visit', \n 'other', \n 'outpatient hospice', \n 'outpatient hospital or clinic', \n 'outpatient pt/ot/st', \n 'outpatient psychiatric', \n 'outpatient radiology', \n 'outpatient rehabilitation', \n 'outpatient surgery', \n 'pharmacy', \n 'skilled nursing', \n 'telehealth visit', \n 'urgent care'\n )\n , agg='sum'\n , then_value='total_allowed'\n , else_value= 0\n , quote_identifiers = False\n , suffix='_allowed'\n) }}\n, '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, {{ quote_column('plan') }}\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/intermediate/financial_pmpm__service_category_2_allowed_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_allowed) as total_allowed\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as acute_inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulance_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_allowed\n else 0\n end\n )\n \n \n as dialysis_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_allowed\n else 0\n end\n )\n \n \n as durable_medical_equipment_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_allowed\n else 0\n end\n )\n \n \n as emergency_department_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_allowed\n else 0\n end\n )\n \n \n as home_health_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_allowed\n else 0\n end\n )\n \n \n as lab_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_allowed\n else 0\n end\n )\n \n \n as observation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_allowed\n else 0\n end\n )\n \n \n as skilled_nursing_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_allowed\n else 0\n end\n )\n \n \n as telehealth_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_allowed\n else 0\n end\n )\n \n \n as urgent_care_allowed\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__medication": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/staging/hcc_suspecting__stg_core__medication.sql", "original_file_path": "models/hcc_suspecting/staging/hcc_suspecting__stg_core__medication.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__medication", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__medication"], "alias": "_stg_medication", "checksum": {"name": "sha256", "checksum": "3b7799322f039939e8e6994fe70e0274f5cb137a43f0777599b8b904edcda7b0"}, "config": {"enabled": true, "alias": "_stg_medication", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging medications from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_medication", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.187649, "relation_name": null, "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom {{ ref('core__medication') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom {{ ref('core__medication') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\n , cast(null as {{ dbt.type_string() }} ) as data_source\n{% else %}\nselect\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as source_code\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\n , cast(null as {{ dbt.type_string() }} ) as data_source\n limit 0\n{% endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/staging/hcc_suspecting__stg_core__medication.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom cms_synthetic.core.medication\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__observation": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/staging/hcc_suspecting__stg_core__observation.sql", "original_file_path": "models/hcc_suspecting/staging/hcc_suspecting__stg_core__observation.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__observation", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__observation"], "alias": "_stg_observation", "checksum": {"name": "sha256", "checksum": "dfadf15ddda35473cc2bdd0ad7e27e05afe32e568d373e54ca1eea1684670d58"}, "config": {"enabled": true, "alias": "_stg_observation", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging observations from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_observation", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.189098, "relation_name": null, "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom {{ ref('core__observation') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom {{ ref('core__observation') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\n , cast(null as {{ dbt.type_string() }} ) as result\n , cast(null as {{ dbt.type_string() }} ) as code_type\n , cast(null as {{ dbt.type_string() }} ) as code\n , cast(null as {{ dbt.type_string() }} ) as data_source\n{% else %}\n select\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\n , cast(null as {{ dbt.type_string() }} ) as result\n , cast(null as {{ dbt.type_string() }} ) as code_type\n , cast(null as {{ dbt.type_string() }} ) as code\n , cast(null as {{ dbt.type_string() }} ) as data_source\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/staging/hcc_suspecting__stg_core__observation.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom cms_synthetic.core.observation\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__condition": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/staging/hcc_suspecting__stg_core__condition.sql", "original_file_path": "models/hcc_suspecting/staging/hcc_suspecting__stg_core__condition.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__condition", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__condition"], "alias": "_stg_condition", "checksum": {"name": "sha256", "checksum": "a46ee73752e5f3334db4b72d9aaa510eef31330a75589f98a209a5877bf5d4ce"}, "config": {"enabled": true, "alias": "_stg_condition", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging conditions from core.", "columns": {"claim_id": {"name": "claim_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_condition", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.184869, "relation_name": null, "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/staging/hcc_suspecting__stg_core__condition.sql", "compiled": true, "compiled_code": "\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom cms_synthetic.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/staging/hcc_suspecting__stg_core__pharmacy_claim.sql", "original_file_path": "models/hcc_suspecting/staging/hcc_suspecting__stg_core__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__pharmacy_claim"], "alias": "_stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "900c56f699307a230fd4e74c6c4e00483bb83fb8a28e45ce3d1f773a7036f159"}, "config": {"enabled": true, "alias": "_stg_pharmacy_claim", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging pharmacy claims from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_pharmacy_claim", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.191684, "relation_name": null, "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom {{ ref('core__pharmacy_claim') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom {{ ref('core__pharmacy_claim') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date\n , cast(null as {{ dbt.type_string() }} ) as data_source\n{% else %}\n select\n cast(null as {{ dbt.type_string() }} ) as patient_id\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date\n , cast(null as {{ dbt.type_string() }} ) as data_source\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/staging/hcc_suspecting__stg_core__pharmacy_claim.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom cms_synthetic.core.pharmacy_claim\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__lab_result": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/staging/hcc_suspecting__stg_core__lab_result.sql", "original_file_path": "models/hcc_suspecting/staging/hcc_suspecting__stg_core__lab_result.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__lab_result"], "alias": "_stg_lab_result", "checksum": {"name": "sha256", "checksum": "7293c5ffebe5c1d4baad0ef2fac2e15afa1f418a71b304d9cf50d15961c01f3d"}, "config": {"enabled": true, "alias": "_stg_lab_result", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging conditions from core.", "columns": {"lab_result_id": {"name": "lab_result_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_lab_result", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.186307, "relation_name": null, "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom {{ ref('core__lab_result') }}\n\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom {{ ref('core__lab_result') }}\n\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\n\n{% if target.type == 'fabric' %}\n select top 0\n cast(null as {{ dbt.type_string() }} ) as lab_result_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as code_type\n , cast(null as {{ dbt.type_string() }} ) as code\n , cast(null as {{ dbt.type_string() }} ) as status\n , cast(null as {{ dbt.type_string() }} ) as result\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\n , cast(null as {{ dbt.type_string() }} ) as data_source\n{% else %}\n select\n cast(null as {{ dbt.type_string() }} ) as lab_result_id\n , cast(null as {{ dbt.type_string() }} ) as patient_id\n , cast(null as {{ dbt.type_string() }} ) as code_type\n , cast(null as {{ dbt.type_string() }} ) as code\n , cast(null as {{ dbt.type_string() }} ) as status\n , cast(null as {{ dbt.type_string() }} ) as result\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\n , cast(null as {{ dbt.type_string() }} ) as data_source\n limit 0\n{%- endif %}\n\n{%- endif %}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/staging/hcc_suspecting__stg_core__lab_result.sql", "compiled": true, "compiled_code": "\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom cms_synthetic.core.lab_result\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__patient": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/staging/hcc_suspecting__stg_core__patient.sql", "original_file_path": "models/hcc_suspecting/staging/hcc_suspecting__stg_core__patient.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__patient", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__patient"], "alias": "_stg_patient", "checksum": {"name": "sha256", "checksum": "5c39ca4347411cda02a58f4ec83699c383386316ecb13757de4343c4c87560a9"}, "config": {"enabled": true, "alias": "_stg_patient", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging patients from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_patient", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.190357, "relation_name": null, "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/staging/hcc_suspecting__stg_core__patient.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__list": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__list", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/final/hcc_suspecting__list.sql", "original_file_path": "models/hcc_suspecting/final/hcc_suspecting__list.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__list", "fqn": ["the_tuva_project", "hcc_suspecting", "final", "hcc_suspecting__list"], "alias": "list", "checksum": {"name": "sha256", "checksum": "c2f9bcb4bfe44b1267550227da385e1ca545c28a8480871600b3da4574ac7415"}, "config": {"enabled": true, "alias": "list", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This final model displays the list of suspecting conditions per patient, data_source, hcc, and diagnosis code with the reason and contributing factors.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting condition, observation, result, etc. was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "list", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.162147, "relation_name": "cms_synthetic.hcc_suspecting.list", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith hcc_history_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\n {% if target.type == 'fabric' %}\n where (current_year_billed = 0\n or current_year_billed is null)\n {% else %}\n where (current_year_billed = false\n or current_year_billed is null)\n {% endif %}\n\n)\n\n, comorbidity_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from {{ ref('hcc_suspecting__int_comorbidity_suspects') }}\n {% if target.type == 'fabric' %}\n where (current_year_billed = 0\n or current_year_billed is null)\n {% else %}\n where (current_year_billed = false\n or current_year_billed is null)\n {% endif %}\n\n)\n\n, observation_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from {{ ref('hcc_suspecting__int_observation_suspects') }}\n {% if target.type == 'fabric' %}\n where (current_year_billed = 0\n or current_year_billed is null)\n {% else %}\n where (current_year_billed = false\n or current_year_billed is null)\n {% endif %}\n\n)\n\n, lab_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from {{ ref('hcc_suspecting__int_lab_suspects') }}\n {% if target.type == 'fabric' %}\n where (current_year_billed = 0\n or current_year_billed is null)\n {% else %}\n where (current_year_billed = false\n or current_year_billed is null)\n {% endif %}\n\n)\n\n, medication_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from {{ ref('hcc_suspecting__int_medication_suspects') }}\n {% if target.type == 'fabric' %}\n where (current_year_billed = 0\n or current_year_billed is null)\n {% else %}\n where (current_year_billed = false\n or current_year_billed is null)\n {% endif %}\n\n)\n\n, unioned as (\n\n select * from hcc_history_suspects\n union all\n select * from comorbidity_suspects\n union all\n select * from observation_suspects\n union all\n select * from lab_suspects\n union all\n select * from medication_suspects\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from unioned\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}, {"name": "hcc_suspecting__int_comorbidity_suspects", "package": null, "version": null}, {"name": "hcc_suspecting__int_observation_suspects", "package": null, "version": null}, {"name": "hcc_suspecting__int_lab_suspects", "package": null, "version": null}, {"name": "hcc_suspecting__int_medication_suspects", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/final/hcc_suspecting__list.sql", "compiled": true, "compiled_code": "\n\nwith hcc_history_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, comorbidity_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_comorbidity_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, observation_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_observation_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, lab_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_lab_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, medication_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_medication_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, unioned as (\n\n select * from hcc_history_suspects\n union all\n select * from comorbidity_suspects\n union all\n select * from observation_suspects\n union all\n select * from lab_suspects\n union all\n select * from medication_suspects\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from unioned\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__summary": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/final/hcc_suspecting__summary.sql", "original_file_path": "models/hcc_suspecting/final/hcc_suspecting__summary.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__summary", "fqn": ["the_tuva_project", "hcc_suspecting", "final", "hcc_suspecting__summary"], "alias": "summary", "checksum": {"name": "sha256", "checksum": "08e6569f1ce7a33c7880f60de24ccc751bc38331ddf1cc73fe646cd50c0430d4"}, "config": {"enabled": true, "alias": "summary", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This final model displays a rollup of suspecting conditions per patient.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_sex": {"name": "patient_sex", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_birth_date": {"name": "patient_birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_age": {"name": "patient_age", "description": "The patient's current age.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspecting_gaps": {"name": "suspecting_gaps", "description": "Count of suspecting conditions.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "summary", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.165813, "relation_name": "cms_synthetic.hcc_suspecting.summary", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith patients as (\n\n select\n patient_id\n , sex\n , birth_date\n {% if target.type == 'fabric' %}\n , floor({{ datediff('birth_date', 'GETDATE()', 'hour') }} / 8766.0) as age\n {% else %}\n , floor({{ datediff('birth_date', 'current_date', 'hour') }} / 8766.0) as age\n {% endif %}\n from {{ ref('hcc_suspecting__stg_core__patient') }}\n where death_date is null\n\n)\n\n, suspecting_list as (\n\n select\n patient_id\n , count(*) as gaps\n from {{ ref('hcc_suspecting__list') }}\n group by patient_id\n\n)\n\n, joined as (\n\n select\n patients.patient_id\n , patients.sex\n , patients.birth_date\n , patients.age\n , suspecting_list.gaps\n from patients\n inner join suspecting_list\n on patients.patient_id = suspecting_list.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(sex as {{ dbt.type_string() }}) as patient_sex\n , cast(birth_date as date) as patient_birth_date\n , cast(age as integer) as patient_age\n , cast(gaps as integer) as suspecting_gaps\n from joined\n\n)\n\nselect\n patient_id\n , patient_sex\n , patient_birth_date\n , patient_age\n , suspecting_gaps\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__patient", "package": null, "version": null}, {"name": "hcc_suspecting__list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__patient", "model.the_tuva_project.hcc_suspecting__list"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/final/hcc_suspecting__summary.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom cms_synthetic.core.patient\n), patients as (\n\n select\n patient_id\n , sex\n , birth_date\n \n , floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8766.0) as age\n \n from __dbt__cte___stg_patient\n where death_date is null\n\n)\n\n, suspecting_list as (\n\n select\n patient_id\n , count(*) as gaps\n from cms_synthetic.hcc_suspecting.list\n group by patient_id\n\n)\n\n, joined as (\n\n select\n patients.patient_id\n , patients.sex\n , patients.birth_date\n , patients.age\n , suspecting_list.gaps\n from patients\n inner join suspecting_list\n on patients.patient_id = suspecting_list.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(sex as TEXT) as patient_sex\n , cast(birth_date as date) as patient_birth_date\n , cast(age as integer) as patient_age\n , cast(gaps as integer) as suspecting_gaps\n from joined\n\n)\n\nselect\n patient_id\n , patient_sex\n , patient_birth_date\n , patient_age\n , suspecting_gaps\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__list_rollup": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__list_rollup", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/final/hcc_suspecting__list_rollup.sql", "original_file_path": "models/hcc_suspecting/final/hcc_suspecting__list_rollup.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__list_rollup", "fqn": ["the_tuva_project", "hcc_suspecting", "final", "hcc_suspecting__list_rollup"], "alias": "list_rollup", "checksum": {"name": "sha256", "checksum": "eff6bdc30cc09a424cf899c22e5b8d7eb27f748008a2e128bb18484b4bad2018"}, "config": {"enabled": true, "alias": "list_rollup", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This final model displays the list of suspecting conditions per patient and hcc with the latest contributing factor rolled up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latest_suspect_date": {"name": "latest_suspect_date", "description": "Latest date when the suspecting condition, observation, result, etc. was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "list_rollup", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.164154, "relation_name": "cms_synthetic.hcc_suspecting.list_rollup", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith list as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , row_number() over (\n partition by\n patient_id\n , hcc_code\n order by suspect_date desc\n ) as row_num\n from {{ ref('hcc_suspecting__list') }}\n\n)\n\n, list_dedupe as (\n\n select\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date as latest_suspect_date\n from list\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(latest_suspect_date as date) as latest_suspect_date\n from list_dedupe\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , latest_suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__list"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/final/hcc_suspecting__list_rollup.sql", "compiled": true, "compiled_code": "\n\nwith list as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , row_number() over (\n partition by\n patient_id\n , hcc_code\n order by suspect_date desc\n ) as row_num\n from cms_synthetic.hcc_suspecting.list\n\n)\n\n, list_dedupe as (\n\n select\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date as latest_suspect_date\n from list\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(latest_suspect_date as date) as latest_suspect_date\n from list_dedupe\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , latest_suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_patient_hcc_history", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_patient_hcc_history.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_patient_hcc_history.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_patient_hcc_history"], "alias": "_int_patient_hcc_history", "checksum": {"name": "sha256", "checksum": "b7800534032c97c19631f2530764bb1e5304f1738a6993c569e30ea5106621ff"}, "config": {"enabled": true, "alias": "_int_patient_hcc_history", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This intermediate model displays the full history of a patient's recorded HCCs with a flag for recorded during the current year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the ICD-10-CM condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code": {"name": "icd_10_cm_code", "description": "The ICD-10-CM condition code.", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__icd_10_cm_mappings.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_recorded": {"name": "first_recorded", "description": "Date the HCC was first recorded in the patient's record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_recorded": {"name": "last_recorded", "description": "Date the HCC was last recorded in the patient's record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_billed": {"name": "last_billed", "description": "Date the HCC was last billed in the patient's record (where condition_type <> 'problem').\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting condition was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_patient_hcc_history", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.180404, "relation_name": "cms_synthetic.hcc_suspecting._int_patient_hcc_history", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith all_conditions as (\n\n select\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n from {{ ref('hcc_suspecting__int_all_conditions') }}\n where hcc_code is not null\n\n)\n\n, hcc_grouped as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , min(recorded_date) as first_recorded\n , max(recorded_date) as last_recorded\n from all_conditions\n where hcc_code is not null\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, hcc_billed as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , max(recorded_date) as last_billed\n from all_conditions\n where hcc_code is not null\n and lower(condition_type) <> 'problem'\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, add_flag as (\n\n select\n hcc_grouped.patient_id\n , hcc_grouped.data_source\n , hcc_grouped.hcc_code\n , hcc_grouped.hcc_description\n , hcc_grouped.first_recorded\n , hcc_grouped.last_recorded\n , hcc_billed.last_billed\n , case\n when {{ date_part('year', 'hcc_billed.last_billed') }} = {{ date_part('year', dbt.current_timestamp()) }}\n then 1\n else 0\n end as current_year_billed\n\n from hcc_grouped\n left join hcc_billed\n on hcc_grouped.patient_id = hcc_billed.patient_id\n and hcc_grouped.hcc_code = hcc_billed.hcc_code\n and hcc_grouped.data_source = hcc_billed.data_source\n\n)\n\n, all_conditions_with_flag as (\n\n select distinct\n all_conditions.patient_id\n , all_conditions.data_source\n , all_conditions.recorded_date\n , all_conditions.condition_type\n , all_conditions.icd_10_cm_code\n , all_conditions.hcc_code\n , all_conditions.hcc_description\n , add_flag.first_recorded\n , add_flag.last_recorded\n , add_flag.last_billed\n , add_flag.current_year_billed\n , cast('Prior coding history' as {{ dbt.type_string() }}) as reason\n , {{ dbt.concat([\n \"icd_10_cm_code\",\n \"case\"\n \" when last_billed is not null then \" ~\n dbt.concat([\"' last billed on '\", \"last_billed\"]) ~\n \" when last_billed is null and last_recorded is not null then \" ~\n dbt.concat([\"' last recorded on '\", \"last_recorded\"]) ~\n \" else ' (missing recorded and billing dates) '\"\n \" end\"\n ]) }} as contributing_factor\n , coalesce(last_billed, last_recorded) as condition_date\n from all_conditions\n left join add_flag\n on all_conditions.patient_id = add_flag.patient_id\n and all_conditions.hcc_code = add_flag.hcc_code\n and all_conditions.data_source = add_flag.data_source\n\n)\n\n, add_standard_fields as (\n\n select distinct\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , 'Prior coding history' as reason\n , {{ dbt.concat([\n \"icd_10_cm_code\",\n \"case\"\n \" when last_billed is not null then \" ~\n dbt.concat([\"' last billed on '\", \"last_billed\"]) ~\n \" when last_billed is null and last_recorded is not null then \" ~\n dbt.concat([\"' last recorded on '\", \"last_recorded\"]) ~\n \" else ' (missing recorded and billing dates) '\"\n \" end\"\n ]) }} as contributing_factor\n , coalesce(last_billed, last_recorded) as suspect_date\n from all_conditions_with_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as {{ dbt.type_string() }}) as condition_type\n , cast(icd_10_cm_code as {{ dbt.type_string() }}) as icd_10_cm_code\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n , cast(first_recorded as date) as first_recorded\n , cast(last_recorded as date) as last_recorded\n , cast(last_billed as date) as last_billed\n {% if target.type == 'fabric' %}\n , cast(current_year_billed as bit) as current_year_billed\n {% else %}\n , cast(current_year_billed as boolean) as current_year_billed\n {% endif %}\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_all_conditions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.current_timestamp", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_all_conditions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_patient_hcc_history.sql", "compiled": true, "compiled_code": "\n\nwith all_conditions as (\n\n select\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._int_all_conditions\n where hcc_code is not null\n\n)\n\n, hcc_grouped as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , min(recorded_date) as first_recorded\n , max(recorded_date) as last_recorded\n from all_conditions\n where hcc_code is not null\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, hcc_billed as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , max(recorded_date) as last_billed\n from all_conditions\n where hcc_code is not null\n and lower(condition_type) <> 'problem'\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, add_flag as (\n\n select\n hcc_grouped.patient_id\n , hcc_grouped.data_source\n , hcc_grouped.hcc_code\n , hcc_grouped.hcc_description\n , hcc_grouped.first_recorded\n , hcc_grouped.last_recorded\n , hcc_billed.last_billed\n , case\n when date_part('year', hcc_billed.last_billed) = date_part('year', convert_timezone('UTC', current_timestamp()))\n then 1\n else 0\n end as current_year_billed\n\n from hcc_grouped\n left join hcc_billed\n on hcc_grouped.patient_id = hcc_billed.patient_id\n and hcc_grouped.hcc_code = hcc_billed.hcc_code\n and hcc_grouped.data_source = hcc_billed.data_source\n\n)\n\n, all_conditions_with_flag as (\n\n select distinct\n all_conditions.patient_id\n , all_conditions.data_source\n , all_conditions.recorded_date\n , all_conditions.condition_type\n , all_conditions.icd_10_cm_code\n , all_conditions.hcc_code\n , all_conditions.hcc_description\n , add_flag.first_recorded\n , add_flag.last_recorded\n , add_flag.last_billed\n , add_flag.current_year_billed\n , cast('Prior coding history' as TEXT) as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as condition_date\n from all_conditions\n left join add_flag\n on all_conditions.patient_id = add_flag.patient_id\n and all_conditions.hcc_code = add_flag.hcc_code\n and all_conditions.data_source = add_flag.data_source\n\n)\n\n, add_standard_fields as (\n\n select distinct\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , 'Prior coding history' as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as suspect_date\n from all_conditions_with_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(icd_10_cm_code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(first_recorded as date) as first_recorded\n , cast(last_recorded as date) as last_recorded\n , cast(last_billed as date) as last_billed\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_observation_suspects": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_observation_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_observation_suspects.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_observation_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_observation_suspects"], "alias": "_int_observation_suspects", "checksum": {"name": "sha256", "checksum": "e3441f40a1440fa21f674f092be2f4055bfbadd2dc33e772e04155b3eb8e57e4"}, "config": {"enabled": true, "alias": "_int_observation_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting observation conditions.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "Date the observation was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_result": {"name": "observation_result", "description": "The result of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_code": {"name": "condition_code", "description": "The code for the comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_date": {"name": "condition_date", "description": "Recorded date for the condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_concept_name": {"name": "condition_concept_name", "description": "Clinical concept name for the comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting observation was recorded.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_observation_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.177912, "relation_name": "cms_synthetic.hcc_suspecting._int_observation_suspects", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from {{ ref('hcc_suspecting__int_prep_conditions') }}\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , result\n , code_type\n , code\n , data_source\n from {{ ref('hcc_suspecting__stg_core__observation') }}\n\n)\n\n, numeric_observations as (\n\n select\n patient_id\n , observation_date\n {% if target.type == 'fabric' %}\n , TRY_CAST(result AS {{ dbt.type_numeric() }}) AS result\n {% else %}\n , CAST(result AS {{ dbt.type_numeric() }}) AS result\n {% endif %}\n , code_type\n , code\n , data_source\n from observations\n {% if target.type == 'fabric' %}\n WHERE result LIKE '%.%' OR result LIKE '%[0-9]%'\n AND result NOT LIKE '%[^0-9.]%'\n {% else %}\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\n {% endif %}\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('hcc_suspecting__clinical_concepts') }}\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\n\n)\n\n, depression_assessment as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.observation_date\n , numeric_observations.result\n , numeric_observations.code_type\n , numeric_observations.code\n , numeric_observations.data_source\n , seed_clinical_concepts.concept_name\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'depression assessment (phq-9)'\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n\n)\n\n, hypertension as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'essential hypertension'\n\n)\n\n, obstructive_sleep_apnea as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'obstructive sleep apnea'\n\n)\n\n/* BEGIN HCC 48 logic (Morbid Obesity) */\n, bmi_over_30_with_osa as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , obstructive_sleep_apnea.code as condition_code\n , obstructive_sleep_apnea.recorded_date as condition_date\n , obstructive_sleep_apnea.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join obstructive_sleep_apnea\n on numeric_observations.patient_id = obstructive_sleep_apnea.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and {{ date_part('year', 'numeric_observations.observation_date') }} = {{ date_part('year', 'obstructive_sleep_apnea.recorded_date') }}\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 30\n\n)\n\n, bmi_over_35_with_diabetes as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , diabetes.code as condition_code\n , diabetes.recorded_date as condition_date\n , diabetes.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join diabetes\n on numeric_observations.patient_id = diabetes.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and {{ date_part('year', 'numeric_observations.observation_date') }} = {{ date_part('year', 'diabetes.recorded_date') }}\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_35_with_hypertension as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , hypertension.code as condition_code\n , hypertension.recorded_date as condition_date\n , hypertension.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join hypertension\n on numeric_observations.patient_id = hypertension.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and {{ date_part('year', 'numeric_observations.observation_date') }} = {{ date_part('year', 'hypertension.recorded_date') }}\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_40 as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , cast(null as {{ dbt.type_string() }}) as condition_code\n , cast(null as date) as condition_date\n , cast(null as {{ dbt.type_string() }}) as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 40\n\n)\n\n, hcc_48_unioned as (\n\n select * from bmi_over_30_with_osa\n union all\n select * from bmi_over_35_with_diabetes\n union all\n select * from bmi_over_35_with_hypertension\n union all\n select * from bmi_over_40\n\n)\n\n, hcc_48_suspect as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , {{ dbt.concat([\n \"'BMI result '\",\n \"observation_result\",\n \"case\"\n \" when condition_code is null then '' \"\n \" else \" ~\n dbt.concat([\"' with '\",\n \"condition_concept_name\",\n \"'('\",\n \"condition_code\",\n \"' on '\",\n \"condition_date\",\n \"')'\"]) ~\n \" end\"\n ]) }} as contributing_factor\n from hcc_48_unioned\n\n)\n/* END HCC 48 logic */\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n to determine a positive PHQ-9 assessment, we look at the past 3 screenings\n for a patient and take the highest result\n*/\n, eligible_depression_assessments as (\n\n select\n depression_assessment.patient_id\n , depression_assessment.observation_date\n , depression_assessment.result\n , depression_assessment.code_type\n , depression_assessment.code\n , depression_assessment.data_source\n , depression_assessment.concept_name\n , row_number() over (\n partition by\n depression_assessment.patient_id\n , depression_assessment.data_source\n order by\n case when depression_assessment.observation_date is null then 1 else 0 end,\n depression_assessment.observation_date desc\n ) assessment_order\n from depression_assessment\n\n)\n\n, depression_assessments_ordered as (\n\n select\n patient_id\n , observation_date\n , code_type\n , code\n , data_source\n , concept_name\n , result\n , row_number() over (\n partition by\n patient_id\n , data_source\n --order by result desc nulls last\n order by\n case when result is null then 1 else 0 end,\n result desc\n ) as result_order --order the last three assessments by result value\n from eligible_depression_assessments\n where assessment_order <= 3\n\n)\n\n, hcc_155_suspect as (\n\n select\n depression_assessments_ordered.patient_id\n , depression_assessments_ordered.data_source\n , depression_assessments_ordered.observation_date\n , depression_assessments_ordered.result as observation_result\n , cast(null as {{ dbt.type_string() }}) as condition_code\n , cast(null as date) as condition_date\n , depression_assessments_ordered.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , {{ dbt.concat([\n \"'PHQ-9 result '\",\n \"depression_assessments_ordered.result\",\n \"' on '\",\n \"depression_assessments_ordered.observation_date\"]) }} as contributing_factor\n from depression_assessments_ordered\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where result_order = 1\n and result >= 15\n\n)\n\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_48_suspect\n union all\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.observation_date\n , unioned.observation_result\n , unioned.condition_code\n , unioned.condition_date\n , unioned.condition_concept_name\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.contributing_factor\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Observation suspect' as {{ dbt.type_string() }}) as reason\n , observation_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(observation_date as date) as observation_date\n , cast(observation_result as {{ dbt.type_string() }}) as observation_result\n , cast(condition_code as {{ dbt.type_string() }}) as condition_code\n , cast(condition_date as date) as condition_date\n , cast(condition_concept_name as {{ dbt.type_string() }}) as condition_concept_name\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n {% if target.type == 'fabric' %}\n , cast(current_year_billed as bit) as current_year_billed\n {% else %}\n , cast(current_year_billed as boolean) as current_year_billed\n {% endif %}\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_conditions", "package": null, "version": null}, {"name": "hcc_suspecting__stg_core__observation", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.the_tuva_project.apply_regex", "macro.the_tuva_project.date_part", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "model.the_tuva_project.hcc_suspecting__stg_core__observation", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_observation_suspects.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom cms_synthetic.core.observation\n\n\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from cms_synthetic.hcc_suspecting._int_prep_conditions\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , result\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_observation\n\n)\n\n, numeric_observations as (\n\n select\n patient_id\n , observation_date\n \n , CAST(result AS numeric(28,6)) AS result\n \n , code_type\n , code\n , data_source\n from observations\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n, depression_assessment as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.observation_date\n , numeric_observations.result\n , numeric_observations.code_type\n , numeric_observations.code\n , numeric_observations.data_source\n , seed_clinical_concepts.concept_name\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'depression assessment (phq-9)'\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n\n)\n\n, hypertension as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'essential hypertension'\n\n)\n\n, obstructive_sleep_apnea as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'obstructive sleep apnea'\n\n)\n\n/* BEGIN HCC 48 logic (Morbid Obesity) */\n, bmi_over_30_with_osa as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , obstructive_sleep_apnea.code as condition_code\n , obstructive_sleep_apnea.recorded_date as condition_date\n , obstructive_sleep_apnea.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join obstructive_sleep_apnea\n on numeric_observations.patient_id = obstructive_sleep_apnea.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', obstructive_sleep_apnea.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 30\n\n)\n\n, bmi_over_35_with_diabetes as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , diabetes.code as condition_code\n , diabetes.recorded_date as condition_date\n , diabetes.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join diabetes\n on numeric_observations.patient_id = diabetes.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', diabetes.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_35_with_hypertension as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , hypertension.code as condition_code\n , hypertension.recorded_date as condition_date\n , hypertension.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join hypertension\n on numeric_observations.patient_id = hypertension.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', hypertension.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_40 as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , cast(null as TEXT) as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 40\n\n)\n\n, hcc_48_unioned as (\n\n select * from bmi_over_30_with_osa\n union all\n select * from bmi_over_35_with_diabetes\n union all\n select * from bmi_over_35_with_hypertension\n union all\n select * from bmi_over_40\n\n)\n\n, hcc_48_suspect as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , 'BMI result ' || observation_result || case when condition_code is null then '' else ' with ' || condition_concept_name || '(' || condition_code || ' on ' || condition_date || ')' end as contributing_factor\n from hcc_48_unioned\n\n)\n/* END HCC 48 logic */\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n to determine a positive PHQ-9 assessment, we look at the past 3 screenings\n for a patient and take the highest result\n*/\n, eligible_depression_assessments as (\n\n select\n depression_assessment.patient_id\n , depression_assessment.observation_date\n , depression_assessment.result\n , depression_assessment.code_type\n , depression_assessment.code\n , depression_assessment.data_source\n , depression_assessment.concept_name\n , row_number() over (\n partition by\n depression_assessment.patient_id\n , depression_assessment.data_source\n order by\n case when depression_assessment.observation_date is null then 1 else 0 end,\n depression_assessment.observation_date desc\n ) assessment_order\n from depression_assessment\n\n)\n\n, depression_assessments_ordered as (\n\n select\n patient_id\n , observation_date\n , code_type\n , code\n , data_source\n , concept_name\n , result\n , row_number() over (\n partition by\n patient_id\n , data_source\n --order by result desc nulls last\n order by\n case when result is null then 1 else 0 end,\n result desc\n ) as result_order --order the last three assessments by result value\n from eligible_depression_assessments\n where assessment_order <= 3\n\n)\n\n, hcc_155_suspect as (\n\n select\n depression_assessments_ordered.patient_id\n , depression_assessments_ordered.data_source\n , depression_assessments_ordered.observation_date\n , depression_assessments_ordered.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , depression_assessments_ordered.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , 'PHQ-9 result ' || depression_assessments_ordered.result || ' on ' || depression_assessments_ordered.observation_date as contributing_factor\n from depression_assessments_ordered\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where result_order = 1\n and result >= 15\n\n)\n\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_48_suspect\n union all\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.observation_date\n , unioned.observation_result\n , unioned.condition_code\n , unioned.condition_date\n , unioned.condition_concept_name\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.contributing_factor\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Observation suspect' as TEXT) as reason\n , observation_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(observation_date as date) as observation_date\n , cast(observation_result as TEXT) as observation_result\n , cast(condition_code as TEXT) as condition_code\n , cast(condition_date as date) as condition_date\n , cast(condition_concept_name as TEXT) as condition_concept_name\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom cms_synthetic.core.observation\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_medication_suspects": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_medication_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_medication_suspects.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_medication_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_medication_suspects"], "alias": "_int_medication_suspects", "checksum": {"name": "sha256", "checksum": "5dace554f7995e1ebf900dbe2e34df3c4fbf1686eb5971104bdb5102f7870599"}, "config": {"enabled": true, "alias": "_int_medication_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting conditions based on medications.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed or paid date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug_code": {"name": "drug_code", "description": "NDC or rxnorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting medication was dispensed or paid.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_medication_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.175555, "relation_name": "cms_synthetic.hcc_suspecting._int_medication_suspects", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith all_medications as (\n\n select\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n from {{ ref('hcc_suspecting__int_all_medications') }}\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('hcc_suspecting__clinical_concepts') }}\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\n\n)\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n antidepressant medication taken within the past five years\n*/\n, hcc_155_suspect as (\n\n select\n all_medications.patient_id\n , all_medications.dispensing_date\n , all_medications.drug_code\n , all_medications.code_system\n , all_medications.data_source\n , seed_clinical_concepts.concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from all_medications\n inner join seed_clinical_concepts\n on all_medications.code_system = seed_clinical_concepts.code_system\n and all_medications.drug_code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where lower(seed_clinical_concepts.concept_name) = 'antidepressant medication'\n and all_medications.dispensing_date >= {{ dbt.dateadd (\n datepart = \"year\"\n , interval = -5\n , from_date_or_timestamp = dbt.current_timestamp()\n ) }}\n\n)\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.concept_name\n , unioned.dispensing_date\n , unioned.drug_code\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , cast('Medication suspect' as {{ dbt.type_string() }}) as reason\n , {{ dbt.concat([\n \"concept_name\",\n \"drug_code\",\n \"') dispensed on '\",\n \"dispensing_date\" ]) }} as contributing_factor\n , dispensing_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as {{ dbt.type_string() }}) as drug_code\n {% if target.type == 'fabric' %}\n , cast(current_year_billed as bit) as current_year_billed\n {% else %}\n , cast(current_year_billed as boolean) as current_year_billed\n {% endif %}\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_all_medications", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.dateadd", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_all_medications", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_medication_suspects.sql", "compiled": true, "compiled_code": "\n\nwith all_medications as (\n\n select\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n from cms_synthetic.hcc_suspecting._int_all_medications\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n antidepressant medication taken within the past five years\n*/\n, hcc_155_suspect as (\n\n select\n all_medications.patient_id\n , all_medications.dispensing_date\n , all_medications.drug_code\n , all_medications.code_system\n , all_medications.data_source\n , seed_clinical_concepts.concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from all_medications\n inner join seed_clinical_concepts\n on all_medications.code_system = seed_clinical_concepts.code_system\n and all_medications.drug_code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where lower(seed_clinical_concepts.concept_name) = 'antidepressant medication'\n and all_medications.dispensing_date >= \n\n dateadd(\n year,\n -5,\n convert_timezone('UTC', current_timestamp())\n )\n\n\n\n)\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.concept_name\n , unioned.dispensing_date\n , unioned.drug_code\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , cast('Medication suspect' as TEXT) as reason\n , concept_name || drug_code || ') dispensed on ' || dispensing_date as contributing_factor\n , dispensing_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_lab_suspects": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_lab_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_lab_suspects.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_lab_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_lab_suspects"], "alias": "_int_lab_suspects", "checksum": {"name": "sha256", "checksum": "8ac7453d699663eb853da240afa36a49c48bdefa2cc6237151a2d53c992f7af9"}, "config": {"enabled": true, "alias": "_int_lab_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting conditions based on labs.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "Cleaned numeric result of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_code": {"name": "lab_code", "description": "The normalized code or source code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting lab result was recorded.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_lab_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.17393, "relation_name": "cms_synthetic.hcc_suspecting._int_lab_suspects", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from {{ ref('hcc_suspecting__int_prep_egfr_labs') }}\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\n\n)\n\n/* BEGIN CKD logic */\n\n/*\n Find a patient\u2019s two most recent eGFR lab results that are spaced by at\n least 90 days.\n*/\n, max_lab_date as (\n\n select\n patient_id\n , data_source\n , max(result_date) as max_result_date\n from egfr_labs\n group by\n patient_id\n , data_source\n\n)\n\n, lab_lookback as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n , max(egfr_labs.result_date) as lookback_result_date\n from egfr_labs\n left join max_lab_date\n on egfr_labs.patient_id = max_lab_date.patient_id\n and egfr_labs.data_source = max_lab_date.data_source\n where egfr_labs.result_date <= {{ dateadd('day', -90, 'max_result_date') }}\n group by\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n\n)\n\n/*\n Take the highest eGFR result that occurred between the date range.\n*/\n, eligible_labs as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , egfr_labs.code_type\n , egfr_labs.code\n , egfr_labs.result_date\n , egfr_labs.result\n , row_number() over (\n partition by\n egfr_labs.patient_id\n , egfr_labs.data_source\n order by egfr_labs.result desc\n ) as row_num\n from egfr_labs\n inner join lab_lookback\n on egfr_labs.patient_id = lab_lookback.patient_id\n and egfr_labs.data_source = lab_lookback.data_source\n where egfr_labs.result_date >= lab_lookback.lookback_result_date\n\n)\n\n/*\n Assign a patient's kidney disease stage based on the highest eGFR based on\n the following range:\n\n CKD 3a: eGFR in the range (45-59)\n CKD 3b: eGFR in the range (30-44)\n CKD 4: eGFR in the range (15-29)\n CKD 5: eGFR in the range (0-14)\n*/\n, ckd_suspects as (\n\n select\n patient_id\n , data_source\n , code_type\n , code as lab_code\n , result_date\n , result\n , case\n when result between 0 and 14 then '326'\n when result between 15 and 29 then '327'\n when result between 30 and 44 then '328'\n when result between 45 and 59 then '329'\n end as hcc_code\n , {{ dbt.concat([\n \"'eGFR ('\",\n \"code\",\n \"') result '\",\n \"result\",\n \"' on '\",\n \"result_date\"\n ]) }} as contributing_factor\n from eligible_labs\n where row_num = 1\n\n)\n/* END CKD logic */\n\n, unioned as (\n\n select * from ckd_suspects\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.result_date\n , unioned.result\n , unioned.lab_code\n , unioned.hcc_code\n , unioned.contributing_factor\n , seed_hcc_descriptions.hcc_description\n , billed_hccs.current_year_billed\n from unioned\n inner join seed_hcc_descriptions\n on unioned.hcc_code = seed_hcc_descriptions.hcc_code\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Lab result suspect' as {{ dbt.type_string() }}) as reason\n , result_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(result_date as date) as result_date\n , cast(result as {{ dbt.type_numeric() }}) as result\n , cast(lab_code as {{ dbt.type_string() }}) as lab_code\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n {% if target.type == 'fabric' %}\n , cast(current_year_billed as bit) as current_year_billed\n {% else %}\n , cast(current_year_billed as boolean) as current_year_billed\n {% endif %}\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_egfr_labs", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.concat", "macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_lab_suspects.sql", "compiled": true, "compiled_code": "\n\nwith egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from cms_synthetic.hcc_suspecting._int_prep_egfr_labs\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN CKD logic */\n\n/*\n Find a patient\u2019s two most recent eGFR lab results that are spaced by at\n least 90 days.\n*/\n, max_lab_date as (\n\n select\n patient_id\n , data_source\n , max(result_date) as max_result_date\n from egfr_labs\n group by\n patient_id\n , data_source\n\n)\n\n, lab_lookback as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n , max(egfr_labs.result_date) as lookback_result_date\n from egfr_labs\n left join max_lab_date\n on egfr_labs.patient_id = max_lab_date.patient_id\n and egfr_labs.data_source = max_lab_date.data_source\n where egfr_labs.result_date <= \n\n dateadd(\n day,\n -90,\n max_result_date\n )\n\n\n group by\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n\n)\n\n/*\n Take the highest eGFR result that occurred between the date range.\n*/\n, eligible_labs as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , egfr_labs.code_type\n , egfr_labs.code\n , egfr_labs.result_date\n , egfr_labs.result\n , row_number() over (\n partition by\n egfr_labs.patient_id\n , egfr_labs.data_source\n order by egfr_labs.result desc\n ) as row_num\n from egfr_labs\n inner join lab_lookback\n on egfr_labs.patient_id = lab_lookback.patient_id\n and egfr_labs.data_source = lab_lookback.data_source\n where egfr_labs.result_date >= lab_lookback.lookback_result_date\n\n)\n\n/*\n Assign a patient's kidney disease stage based on the highest eGFR based on\n the following range:\n\n CKD 3a: eGFR in the range (45-59)\n CKD 3b: eGFR in the range (30-44)\n CKD 4: eGFR in the range (15-29)\n CKD 5: eGFR in the range (0-14)\n*/\n, ckd_suspects as (\n\n select\n patient_id\n , data_source\n , code_type\n , code as lab_code\n , result_date\n , result\n , case\n when result between 0 and 14 then '326'\n when result between 15 and 29 then '327'\n when result between 30 and 44 then '328'\n when result between 45 and 59 then '329'\n end as hcc_code\n , 'eGFR (' || code || ') result ' || result || ' on ' || result_date as contributing_factor\n from eligible_labs\n where row_num = 1\n\n)\n/* END CKD logic */\n\n, unioned as (\n\n select * from ckd_suspects\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.result_date\n , unioned.result\n , unioned.lab_code\n , unioned.hcc_code\n , unioned.contributing_factor\n , seed_hcc_descriptions.hcc_description\n , billed_hccs.current_year_billed\n from unioned\n inner join seed_hcc_descriptions\n on unioned.hcc_code = seed_hcc_descriptions.hcc_code\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Lab result suspect' as TEXT) as reason\n , result_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n , cast(lab_code as TEXT) as lab_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_prep_egfr_labs", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_prep_egfr_labs.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_prep_egfr_labs.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_prep_egfr_labs"], "alias": "_int_prep_egfr_labs", "checksum": {"name": "sha256", "checksum": "6dcbc749edbb3941f07fa388f3da5b431693b2ada8cb55cafd5d458ffcb87ca4"}, "config": {"enabled": true, "alias": "_int_prep_egfr_labs", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Preparing eGFR labs with clean numeric results.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "The normalized code type or source code type.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "The normalized code or source code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "Cleaned numeric result of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_prep_egfr_labs", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.1834948, "relation_name": "cms_synthetic.hcc_suspecting._int_prep_egfr_labs", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith lab_result as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , status\n , result\n , result_date\n from {{ ref('hcc_suspecting__stg_core__lab_result') }}\n\n)\n\n, seed_egfr_codes as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('hcc_suspecting__clinical_concepts') }}\n where lower(concept_name) = 'estimated glomerular filtration rate'\n\n)\n\n, egfr_labs as (\n\n select distinct\n lab_result.patient_id\n , lab_result.data_source\n , lab_result.code_type\n , lab_result.code\n , lab_result.result_date\n , lab_result.result\n from lab_result\n inner join seed_egfr_codes\n on lab_result.code = seed_egfr_codes.code\n and lab_result.code_type = seed_egfr_codes.code_system\n where lab_result.result is not null\n and lower(lab_result.status) not in ('cancelled', 'entered-in-error')\n\n)\n\n, numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , cast(result as {{ dbt.type_numeric() }}) as result\n from egfr_labs\n {% if target.type == 'fabric' %}\n WHERE result LIKE '%.%' OR result LIKE '%[0-9]%'\n AND result NOT LIKE '%[^0-9.]%'\n {% else %}\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\n {% endif %}\n\n)\n\n, clean_non_numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , cast(case\n when lower(result) like '%unsatisfactory specimen%' then null\n when result like '%>%' then null\n when result like '%<%' then null\n when result like '%@%' then trim(replace(result,'@',''))\n when result like '%mL/min/1.73m2%' then trim(replace(result,'mL/min/1.73m2',''))\n else null\n end as {{ dbt.type_numeric() }}) as clean_result\n from egfr_labs\n {% if target.type == 'fabric' %}\n WHERE NOT (result LIKE '%.%' OR result LIKE '%[0-9]%'\n AND result NOT LIKE '%[^0-9.]%')\n {% else %}\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }} = False\n {% endif %}\n\n)\n\n, unioned_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from numeric_egfr_labs\n\n union all\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , clean_result as result\n from clean_non_numeric_egfr_labs\n where clean_result is not null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(code_type as {{ dbt.type_string() }}) as code_type\n , cast(code as {{ dbt.type_string() }}) as code\n , cast(result_date as date) as result_date\n , cast(result as {{ dbt.type_numeric() }}) as result\n from unioned_labs\n\n)\n\nselect\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__lab_result", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.the_tuva_project.apply_regex", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "seed.the_tuva_project.hcc_suspecting__clinical_concepts"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_prep_egfr_labs.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom cms_synthetic.core.lab_result\n\n\n), lab_result as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , status\n , result\n , result_date\n from __dbt__cte___stg_lab_result\n\n)\n\n, seed_egfr_codes as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n where lower(concept_name) = 'estimated glomerular filtration rate'\n\n)\n\n, egfr_labs as (\n\n select distinct\n lab_result.patient_id\n , lab_result.data_source\n , lab_result.code_type\n , lab_result.code\n , lab_result.result_date\n , lab_result.result\n from lab_result\n inner join seed_egfr_codes\n on lab_result.code = seed_egfr_codes.code\n and lab_result.code_type = seed_egfr_codes.code_system\n where lab_result.result is not null\n and lower(lab_result.status) not in ('cancelled', 'entered-in-error')\n\n)\n\n, numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , cast(result as numeric(28,6)) as result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, clean_non_numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , cast(case\n when lower(result) like '%unsatisfactory specimen%' then null\n when result like '%>%' then null\n when result like '%<%' then null\n when result like '%@%' then trim(replace(result,'@',''))\n when result like '%mL/min/1.73m2%' then trim(replace(result,'mL/min/1.73m2',''))\n else null\n end as numeric(28,6)) as clean_result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$') = False\n \n\n)\n\n, unioned_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from numeric_egfr_labs\n\n union all\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , clean_result as result\n from clean_non_numeric_egfr_labs\n where clean_result is not null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n from unioned_labs\n\n)\n\nselect\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom cms_synthetic.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_all_conditions": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_all_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_all_conditions.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_all_conditions.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_conditions", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_all_conditions"], "alias": "_int_all_conditions", "checksum": {"name": "sha256", "checksum": "5e36a0e7b90be4e6e858a2d9517270709c4d913fe88a1a2b2050a4dc78b49bcf"}, "config": {"enabled": true, "alias": "_int_all_conditions", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "All historical conditions mapped to HCCs.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code": {"name": "icd_10_cm_code", "description": "The ICD-10-CM condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_all_conditions", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.167316, "relation_name": "cms_synthetic.hcc_suspecting._int_all_conditions", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from {{ ref('hcc_suspecting__int_prep_conditions') }}\n\n)\n\n, seed_hcc_mapping as (\n\n select\n diagnosis_code\n , cms_hcc_v28 as hcc_code\n from {{ ref('hcc_suspecting__icd_10_cm_mappings') }}\n where cms_hcc_v28 is not null\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\n\n)\n\n, joined as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code\n , conditions.data_source\n , seed_hcc_mapping.hcc_code\n , seed_hcc_descriptions.hcc_description\n from conditions\n left join seed_hcc_mapping\n on conditions.code = seed_hcc_mapping.diagnosis_code\n left join seed_hcc_descriptions\n on seed_hcc_mapping.hcc_code = seed_hcc_descriptions.hcc_code\n where conditions.code_type = 'icd-10-cm'\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as {{ dbt.type_string() }}) as condition_type\n , cast(code as {{ dbt.type_string() }}) as icd_10_cm_code\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n from joined\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_conditions", "package": null, "version": null}, {"name": "hcc_suspecting__icd_10_cm_mappings", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_all_conditions.sql", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from cms_synthetic.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n diagnosis_code\n , cms_hcc_v28 as hcc_code\n from cms_synthetic.hcc_suspecting._value_set_icd_10_cm_mappings\n where cms_hcc_v28 is not null\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, joined as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code\n , conditions.data_source\n , seed_hcc_mapping.hcc_code\n , seed_hcc_descriptions.hcc_description\n from conditions\n left join seed_hcc_mapping\n on conditions.code = seed_hcc_mapping.diagnosis_code\n left join seed_hcc_descriptions\n on seed_hcc_mapping.hcc_code = seed_hcc_descriptions.hcc_code\n where conditions.code_type = 'icd-10-cm'\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(data_source as TEXT) as data_source\n from joined\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_comorbidity_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_comorbidity_suspects.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_comorbidity_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_comorbidity_suspects"], "alias": "_int_comorbidity_suspects", "checksum": {"name": "sha256", "checksum": "3fb175fde9b797b0fc2cb861bf7c700e9d364f209dce12c9f14054f26b083534"}, "config": {"enabled": true, "alias": "_int_comorbidity_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting comorbidities.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_1_concept_name": {"name": "condition_1_concept_name", "description": "Clinical concept name for the first comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_1_code": {"name": "condition_1_code", "description": "Condition code for the first comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_1_recorded_date": {"name": "condition_1_recorded_date", "description": "Recorded date for the first comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_2_concept_name": {"name": "condition_2_concept_name", "description": "Clinical concept name for the second comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_2_code": {"name": "condition_2_code", "description": "Condition code for the second comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_2_recorded_date": {"name": "condition_2_recorded_date", "description": "Recorded date for the second comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting condition was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_comorbidity_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.172054, "relation_name": "cms_synthetic.hcc_suspecting._int_comorbidity_suspects", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from {{ ref('hcc_suspecting__int_prep_conditions') }}\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from {{ ref('hcc_suspecting__clinical_concepts') }}\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\n\n)\n\n/* BEGIN HCC 37 logic */\n, ckd_stage_1_or_2 as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) in (\n 'chronic kidney disease, stage 1'\n , 'chronic kidney disease, stage 2'\n )\n\n)\n\n, ckd_stage_1_or_2_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from ckd_stage_1_or_2\n where row_num = 1\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n)\n\n, diabetes_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from diabetes\n where row_num = 1\n\n)\n\n, hcc_37_suspect as (\n\n select\n diabetes_dedupe.patient_id\n , diabetes_dedupe.data_source\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , diabetes_dedupe.concept_name as condition_1_concept_name\n , diabetes_dedupe.code as condition_1_code\n , diabetes_dedupe.recorded_date as condition_1_recorded_date\n , ckd_stage_1_or_2_dedupe.concept_name as condition_2_concept_name\n , ckd_stage_1_or_2_dedupe.code as condition_2_code\n , ckd_stage_1_or_2_dedupe.recorded_date as condition_2_recorded_date\n from diabetes_dedupe\n inner join ckd_stage_1_or_2_dedupe\n on diabetes_dedupe.patient_id = ckd_stage_1_or_2_dedupe.patient_id\n and diabetes_dedupe.data_source = ckd_stage_1_or_2_dedupe.data_source\n /* ensure conditions overlap in the same year */\n and {{ date_part('year', 'diabetes_dedupe.recorded_date') }} = {{ date_part('year', 'ckd_stage_1_or_2_dedupe.recorded_date') }}\n inner join seed_hcc_descriptions\n on hcc_code = '37'\n\n)\n/* END HCC 37 logic */\n\n, unioned as (\n\n select * from hcc_37_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.condition_1_concept_name\n , unioned.condition_1_code\n , unioned.condition_1_recorded_date\n , unioned.condition_2_concept_name\n , unioned.condition_2_code\n , unioned.condition_2_recorded_date\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , cast('Comorbidity suspect' as {{ dbt.type_string() }}) as reason\n , {{ dbt.concat([\n \"condition_1_concept_name\",\n \"' ('\",\n \"condition_1_code\",\n \"') on '\",\n \"condition_1_recorded_date\",\n \"') and '\",\n \"condition_2_concept_name\",\n \"' ('\",\n \"condition_2_code\",\n \"') on '\",\n \"condition_2_recorded_date\"\n ]) }} as contributing_factor\n , condition_1_recorded_date as suspect_date\n from add_billed_flag\n\n)\n\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\n , cast(condition_1_concept_name as {{ dbt.type_string() }}) as condition_1_concept_name\n , cast(condition_1_code as {{ dbt.type_string() }}) as condition_1_code\n , cast(condition_1_recorded_date as date) as condition_1_recorded_date\n , cast(condition_2_concept_name as {{ dbt.type_string() }}) as condition_2_concept_name\n , cast(condition_2_code as {{ dbt.type_string() }}) as condition_2_code\n , cast(condition_2_recorded_date as date) as condition_2_recorded_date\n {% if target.type == 'fabric' %}\n , cast(current_year_billed as bit) as current_year_billed\n {% else %}\n , cast(current_year_billed as boolean) as current_year_billed\n {% endif %}\n , cast(reason as {{ dbt.type_string() }}) as reason\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_conditions", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_comorbidity_suspects.sql", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from cms_synthetic.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 37 logic */\n, ckd_stage_1_or_2 as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) in (\n 'chronic kidney disease, stage 1'\n , 'chronic kidney disease, stage 2'\n )\n\n)\n\n, ckd_stage_1_or_2_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from ckd_stage_1_or_2\n where row_num = 1\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n)\n\n, diabetes_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from diabetes\n where row_num = 1\n\n)\n\n, hcc_37_suspect as (\n\n select\n diabetes_dedupe.patient_id\n , diabetes_dedupe.data_source\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , diabetes_dedupe.concept_name as condition_1_concept_name\n , diabetes_dedupe.code as condition_1_code\n , diabetes_dedupe.recorded_date as condition_1_recorded_date\n , ckd_stage_1_or_2_dedupe.concept_name as condition_2_concept_name\n , ckd_stage_1_or_2_dedupe.code as condition_2_code\n , ckd_stage_1_or_2_dedupe.recorded_date as condition_2_recorded_date\n from diabetes_dedupe\n inner join ckd_stage_1_or_2_dedupe\n on diabetes_dedupe.patient_id = ckd_stage_1_or_2_dedupe.patient_id\n and diabetes_dedupe.data_source = ckd_stage_1_or_2_dedupe.data_source\n /* ensure conditions overlap in the same year */\n and date_part('year', diabetes_dedupe.recorded_date) = date_part('year', ckd_stage_1_or_2_dedupe.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '37'\n\n)\n/* END HCC 37 logic */\n\n, unioned as (\n\n select * from hcc_37_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.condition_1_concept_name\n , unioned.condition_1_code\n , unioned.condition_1_recorded_date\n , unioned.condition_2_concept_name\n , unioned.condition_2_code\n , unioned.condition_2_recorded_date\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , cast('Comorbidity suspect' as TEXT) as reason\n , condition_1_concept_name || ' (' || condition_1_code || ') on ' || condition_1_recorded_date || ') and ' || condition_2_concept_name || ' (' || condition_2_code || ') on ' || condition_2_recorded_date as contributing_factor\n , condition_1_recorded_date as suspect_date\n from add_billed_flag\n\n)\n\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(condition_1_concept_name as TEXT) as condition_1_concept_name\n , cast(condition_1_code as TEXT) as condition_1_code\n , cast(condition_1_recorded_date as date) as condition_1_recorded_date\n , cast(condition_2_concept_name as TEXT) as condition_2_concept_name\n , cast(condition_2_code as TEXT) as condition_2_code\n , cast(condition_2_recorded_date as date) as condition_2_recorded_date\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_all_medications": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_all_medications", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_all_medications.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_all_medications.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_medications", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_all_medications"], "alias": "_int_all_medications", "checksum": {"name": "sha256", "checksum": "a9095f0bebc1273093d3c1afed7f997632b67e828cf12cec615d2e6a456b6d48"}, "config": {"enabled": true, "alias": "_int_all_medications", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Union of medications and pharmacy claims.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed or paid date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug_code": {"name": "drug_code", "description": "NDC or rxnorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "The type of drug code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_all_medications", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.169198, "relation_name": "cms_synthetic.hcc_suspecting._int_all_medications", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\n from {{ ref('hcc_suspecting__stg_core__medication') }}\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , coalesce(dispensing_date, paid_date) as dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from {{ ref('hcc_suspecting__stg_core__pharmacy_claim') }}\n\n)\n\n, ndc_medications as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where ndc_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'ndc'\n\n)\n\n, rxnorm_medications as (\n\n select\n patient_id\n , dispensing_date\n , rxnorm_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where rxnorm_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'rxnorm'\n\n)\n\n, unioned as (\n\n select * from pharmacy_claims\n union all\n select * from ndc_medications\n union all\n select * from rxnorm_medications\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as {{ dbt.type_string() }}) as drug_code\n , cast(code_system as {{ dbt.type_string() }}) as code_system\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n from unioned\n\n)\n\nselect\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__medication", "package": null, "version": null}, {"name": "hcc_suspecting__stg_core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__medication", "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_all_medications.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom cms_synthetic.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , coalesce(dispensing_date, paid_date) as dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, ndc_medications as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where ndc_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'ndc'\n\n)\n\n, rxnorm_medications as (\n\n select\n patient_id\n , dispensing_date\n , rxnorm_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where rxnorm_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'rxnorm'\n\n)\n\n, unioned as (\n\n select * from pharmacy_claims\n union all\n select * from ndc_medications\n union all\n select * from rxnorm_medications\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n , cast(code_system as TEXT) as code_system\n , cast(data_source as TEXT) as data_source\n from unioned\n\n)\n\nselect\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom cms_synthetic.core.medication\n\n\n)"}, {"id": "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom cms_synthetic.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_prep_conditions": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_prep_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting/intermediate/hcc_suspecting__int_prep_conditions.sql", "original_file_path": "models/hcc_suspecting/intermediate/hcc_suspecting__int_prep_conditions.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_prep_conditions"], "alias": "_int_prep_conditions", "checksum": {"name": "sha256", "checksum": "ce8ef8f8d931e4f5abde2dcfcb45d4edc3e464de597bb1f58d2a0eda7fe86f1e"}, "config": {"enabled": true, "alias": "_int_prep_conditions", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Preparing conditions; mapping snomed-ct conditions to icd-10-cm.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "The condition code in the source system e.g. the ICD-10 code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/hcc_suspecting/hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_prep_conditions", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.181932, "relation_name": "cms_synthetic.hcc_suspecting._int_prep_conditions", "raw_code": "{{ config(\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from {{ ref('hcc_suspecting__stg_core__condition') }}\n\n)\n\n/*\n Default mapping guidance: Most map groups terminate with an unconditional\n rule \u2013 a rule whose predicate is \u201cTRUE\u201d or, equivalently, \u201cOTHERWISE TRUE\u201d.\n This rule is considered a \u201cdefault\u201d because it should be applied if\n nothing further is known about the patient\u2019s condition.\n*/\n, seed_snomed_icd_10_map as (\n\n select\n referenced_component_id as snomed_code\n , map_target as icd_10_code\n from {{ ref('terminology__snomed_icd_10_map') }}\n where lower(map_rule) in ('true', 'otherwise true')\n and map_group = '1'\n\n)\n\n, snomed_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , 'icd-10-cm' as code_type\n , icd_10_code as code\n , data_source\n from conditions\n inner join seed_snomed_icd_10_map\n on conditions.code = seed_snomed_icd_10_map.snomed_code\n where conditions.code_type = 'snomed-ct'\n\n)\n\n, other_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from conditions\n where conditions.code_type <> 'snomed-ct'\n\n)\n\n, union_conditions as (\n\n select * from snomed_conditions\n union all\n select * from other_conditions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as {{ dbt.type_string() }}) as condition_type\n , cast(code_type as {{ dbt.type_string() }}) as code_type\n , cast(code as {{ dbt.type_string() }}) as code\n , cast(data_source as {{ dbt.type_string() }}) as data_source\n from union_conditions\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__condition", "package": null, "version": null}, {"name": "terminology__snomed_icd_10_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__condition", "seed.the_tuva_project.terminology__snomed_icd_10_map"]}, "compiled_path": "../target/compiled/the_tuva_project/models/hcc_suspecting/intermediate/hcc_suspecting__int_prep_conditions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom cms_synthetic.core.condition\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_condition\n\n)\n\n/*\n Default mapping guidance: Most map groups terminate with an unconditional\n rule \u2013 a rule whose predicate is \u201cTRUE\u201d or, equivalently, \u201cOTHERWISE TRUE\u201d.\n This rule is considered a \u201cdefault\u201d because it should be applied if\n nothing further is known about the patient\u2019s condition.\n*/\n, seed_snomed_icd_10_map as (\n\n select\n referenced_component_id as snomed_code\n , map_target as icd_10_code\n from cms_synthetic.terminology.snomed_icd_10_map\n where lower(map_rule) in ('true', 'otherwise true')\n and map_group = '1'\n\n)\n\n, snomed_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , 'icd-10-cm' as code_type\n , icd_10_code as code\n , data_source\n from conditions\n inner join seed_snomed_icd_10_map\n on conditions.code = seed_snomed_icd_10_map.snomed_code\n where conditions.code_type = 'snomed-ct'\n\n)\n\n, other_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from conditions\n where conditions.code_type <> 'snomed-ct'\n\n)\n\n, union_conditions as (\n\n select * from snomed_conditions\n union all\n select * from other_conditions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(data_source as TEXT) as data_source\n from union_conditions\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "tuva_chronic_conditions__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/tuva_chronic_conditions__stg_core__patient.sql", "original_file_path": "models/chronic_conditions/staging/tuva_chronic_conditions__stg_core__patient.sql", "unique_id": "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "tuva_chronic_conditions__stg_core__patient"], "alias": "tuva_chronic_conditions__stg_core__patient", "checksum": {"name": "sha256", "checksum": "a1dafa4081bee88b3fbb968f24e25b44ac5a94648630a663006182fe8ec981cb"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["tuva_chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": "tuva_chronic_conditions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.251806, "relation_name": null, "raw_code": "{{ config(\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nselect \n patient_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/tuva_chronic_conditions__stg_core__patient.sql", "compiled": true, "compiled_code": "\n\nselect \n patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "cms_chronic_conditions__stg_core__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/cms_chronic_conditions__stg_core__pharmacy_claim.sql", "original_file_path": "models/chronic_conditions/staging/cms_chronic_conditions__stg_core__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__pharmacy_claim"], "alias": "cms_chronic_conditions__stg_core__pharmacy_claim", "checksum": {"name": "sha256", "checksum": "42fc23412d1dd3b050b5a40223b9081aa70c07ed632fe4cb12e66fd7a1620ca7"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.2181172, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__pharmacy_claim') }}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/cms_chronic_conditions__stg_core__pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "cms_chronic_conditions__stg_core__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/cms_chronic_conditions__stg_core__medical_claim.sql", "original_file_path": "models/chronic_conditions/staging/cms_chronic_conditions__stg_core__medical_claim.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__medical_claim"], "alias": "cms_chronic_conditions__stg_core__medical_claim", "checksum": {"name": "sha256", "checksum": "80cee1c66032fc01b0b75bf88810ec8020169a8d2eeaa97be6a17af2026487f8"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.21741, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__medical_claim') }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/cms_chronic_conditions__stg_core__medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "cms_chronic_conditions__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/cms_chronic_conditions__stg_core__procedure.sql", "original_file_path": "models/chronic_conditions/staging/cms_chronic_conditions__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__procedure"], "alias": "cms_chronic_conditions__stg_core__procedure", "checksum": {"name": "sha256", "checksum": "0b05835f7894c168042518f99fa1f9550e7a8e2e55938db107463014ae64418a"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.216495, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__procedure') }}\nwhere claim_id is not null", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/cms_chronic_conditions__stg_core__procedure.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "tuva_chronic_conditions__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/tuva_chronic_conditions__stg_core__condition.sql", "original_file_path": "models/chronic_conditions/staging/tuva_chronic_conditions__stg_core__condition.sql", "unique_id": "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "tuva_chronic_conditions__stg_core__condition"], "alias": "tuva_chronic_conditions__stg_core__condition", "checksum": {"name": "sha256", "checksum": "c87abe3e519b5f3cb32a1faf45b22fffbb7ec245a8f04481298ca5619f992f64"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["tuva_chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": "tuva_chronic_conditions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.2507231, "relation_name": null, "raw_code": "{{ config(\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__condition')}}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/tuva_chronic_conditions__stg_core__condition.sql", "compiled": true, "compiled_code": "\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__patient": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "cms_chronic_conditions__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/cms_chronic_conditions__stg_core__patient.sql", "original_file_path": "models/chronic_conditions/staging/cms_chronic_conditions__stg_core__patient.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__patient"], "alias": "cms_chronic_conditions__stg_core__patient", "checksum": {"name": "sha256", "checksum": "951c72c9b10935f4435b59c2f1a46879ce03e6628098413eb99e7a4228c17715"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.21575, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect \n patient_id\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/cms_chronic_conditions__stg_core__patient.sql", "compiled": true, "compiled_code": "\n\nselect \n patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__condition": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "cms_chronic_conditions__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/staging/cms_chronic_conditions__stg_core__condition.sql", "original_file_path": "models/chronic_conditions/staging/cms_chronic_conditions__stg_core__condition.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__condition"], "alias": "cms_chronic_conditions__stg_core__condition", "checksum": {"name": "sha256", "checksum": "183902aa49dd41b0c979bcb59f7d079f48ae0e36d40d4f7e5c52cc43d486d624"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.214993, "relation_name": null, "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('core__condition') }}\nwhere claim_id is not null", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/staging/cms_chronic_conditions__stg_core__condition.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__tuva_chronic_conditions_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/final/chronic_conditions__tuva_chronic_conditions_long.sql", "original_file_path": "models/chronic_conditions/final/chronic_conditions__tuva_chronic_conditions_long.sql", "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__tuva_chronic_conditions_long"], "alias": "tuva_chronic_conditions_long", "checksum": {"name": "sha256", "checksum": "8ef168bf4b898ff7e662aa948ec2e6cf6370dd446cc1775d25e8f91e630a5e4c"}, "config": {"enabled": true, "alias": "tuva_chronic_conditions_long", "schema": "chronic_conditions", "database": null, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "description": "This model creates one record per patient per condition using the tuva chronic conditions hierarchy as the grouper. The model pulls in the first and last date of the diagnosis that flagged the patient for this condition group.\n", "columns": {"patient_id": {"name": "patient_id", "description": "The unique identifier for a patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the condition that each diagnosis code rolls up to\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__tuva_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_diagnosis_date": {"name": "first_diagnosis_date", "description": "The first date when a diagnosis code that rolls up to this condition was coded to this patient\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_diagnosis_date": {"name": "last_diagnosis_date", "description": "The last date when a diagnosis code that rolls up to this condition was coded to this patient\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "tuva_chronic_conditions_long", "tags": ["tuva_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.238761, "relation_name": "cms_synthetic.chronic_conditions.tuva_chronic_conditions_long", "raw_code": "{{ config(\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith all_conditions as (\nselect \n patient_id,\n normalized_code,\n recorded_date\n from {{ ref('tuva_chronic_conditions__stg_core__condition') }}\n),\n\n\nconditions_with_first_and_last_diagnosis_date as (\nselect \n patient_id,\n normalized_code as icd_10_cm,\n min(recorded_date) as first_diagnosis_date,\n max(recorded_date) as last_diagnosis_date\nfrom all_conditions\ngroup by patient_id, normalized_code\n\n)\n\n\nselect\n aa.patient_id,\n bb.concept_name as condition,\n min(first_diagnosis_date) as first_diagnosis_date,\n max(last_diagnosis_date) as last_diagnosis_date,\n '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom conditions_with_first_and_last_diagnosis_date aa\ninner join {{ ref('clinical_concept_library__value_set_member_relevant_fields') }} bb\non aa.icd_10_cm = bb.code\ngroup by aa.patient_id, bb.concept_name", "language": "sql", "refs": [{"name": "tuva_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "clinical_concept_library__value_set_member_relevant_fields", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/final/chronic_conditions__tuva_chronic_conditions_long.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__tuva_chronic_conditions__stg_core__condition as (\n\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), all_conditions as (\nselect \n patient_id,\n normalized_code,\n recorded_date\n from __dbt__cte__tuva_chronic_conditions__stg_core__condition\n),\n\n\nconditions_with_first_and_last_diagnosis_date as (\nselect \n patient_id,\n normalized_code as icd_10_cm,\n min(recorded_date) as first_diagnosis_date,\n max(recorded_date) as last_diagnosis_date\nfrom all_conditions\ngroup by patient_id, normalized_code\n\n)\n\n\nselect\n aa.patient_id,\n bb.concept_name as condition,\n min(first_diagnosis_date) as first_diagnosis_date,\n max(last_diagnosis_date) as last_diagnosis_date,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom conditions_with_first_and_last_diagnosis_date aa\ninner join cms_synthetic.clinical_concept_library.value_set_member_relevant_fields bb\non aa.icd_10_cm = bb.code\ngroup by aa.patient_id, bb.concept_name", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__tuva_chronic_conditions__stg_core__condition as (\n\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_wide", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/final/chronic_conditions__cms_chronic_conditions_wide.sql", "original_file_path": "models/chronic_conditions/final/chronic_conditions__cms_chronic_conditions_wide.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__cms_chronic_conditions_wide"], "alias": "cms_chronic_conditions_wide", "checksum": {"name": "sha256", "checksum": "04c54137c63264ae9c13854d505d856827d93fcd08113a96b4194a7a0a7671b9"}, "config": {"enabled": true, "alias": "cms_chronic_conditions_wide", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model pivots conditions on the patient level (i.e. one record per patient) with flags for each chronic condition.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_myocardial_infarction": {"name": "acute_myocardial_infarction", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "adhd_conduct_disorders_and_hyperkinetic_syndrome": {"name": "adhd_conduct_disorders_and_hyperkinetic_syndrome", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "alcohol_use_disorders": {"name": "alcohol_use_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "alzheimers_disease": {"name": "alzheimers_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "anemia": {"name": "anemia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "anxiety_disorders": {"name": "anxiety_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "asthma": {"name": "asthma", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "atrial_fibrillation_and_flutter": {"name": "atrial_fibrillation_and_flutter", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "autism_spectrum_disorders": {"name": "autism_spectrum_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "benign_prostatic_hyperplasia": {"name": "benign_prostatic_hyperplasia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "bipolar_disorder": {"name": "bipolar_disorder", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_breast": {"name": "cancer_breast", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_colorectal": {"name": "cancer_colorectal", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_endometrial": {"name": "cancer_endometrial", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_lung": {"name": "cancer_lung", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_prostate": {"name": "cancer_prostate", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_urologic_kidney_renal_pelvis_and_ureter": {"name": "cancer_urologic_kidney_renal_pelvis_and_ureter", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cataract": {"name": "cataract", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cerebral_palsy": {"name": "cerebral_palsy", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "chronic_kidney_disease": {"name": "chronic_kidney_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "chronic_obstructive_pulmonary_disease": {"name": "chronic_obstructive_pulmonary_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cystic_fibrosis_and_other_metabolic_developmental_disorders": {"name": "cystic_fibrosis_and_other_metabolic_developmental_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "depression_bipolar_or_other_depressive_mood_disorders": {"name": "depression_bipolar_or_other_depressive_mood_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "depressive_disorders": {"name": "depressive_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "diabetes": {"name": "diabetes", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "drug_use_disorders": {"name": "drug_use_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "epilepsy": {"name": "epilepsy", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "fibromyalgia_and_chronic_pain_and_fatigue": {"name": "fibromyalgia_and_chronic_pain_and_fatigue", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "glaucoma": {"name": "glaucoma", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "heart_failure_and_non_ischemic_heart_disease": {"name": "heart_failure_and_non_ischemic_heart_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_a": {"name": "hepatitis_a", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_b_acute_or_unspecified": {"name": "hepatitis_b_acute_or_unspecified", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_b_chronic": {"name": "hepatitis_b_chronic", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_c_acute": {"name": "hepatitis_c_acute", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_c_chronic": {"name": "hepatitis_c_chronic", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_c_unspecified": {"name": "hepatitis_c_unspecified", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_d": {"name": "hepatitis_d", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_e": {"name": "hepatitis_e", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hip_pelvic_fracture": {"name": "hip_pelvic_fracture", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids": {"name": "human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hyperlipidemia": {"name": "hyperlipidemia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hypertension": {"name": "hypertension", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hypothyroidism": {"name": "hypothyroidism", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "intellectual_disabilities_and_related_conditions": {"name": "intellectual_disabilities_and_related_conditions", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "ischemic_heart_disease": {"name": "ischemic_heart_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "learning_disabilities": {"name": "learning_disabilities", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "leukemias_and_lymphomas": {"name": "leukemias_and_lymphomas", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis": {"name": "liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "migraine_and_chronic_headache": {"name": "migraine_and_chronic_headache", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "mobility_impairments": {"name": "mobility_impairments", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "multiple_sclerosis_and_transverse_myelitis": {"name": "multiple_sclerosis_and_transverse_myelitis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "muscular_dystrophy": {"name": "muscular_dystrophy", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "non_alzheimers_dementia": {"name": "non_alzheimers_dementia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "obesity": {"name": "obesity", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "opioid_use_disorder_oud": {"name": "opioid_use_disorder_oud", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "osteoporosis_with_or_without_pathological_fracture": {"name": "osteoporosis_with_or_without_pathological_fracture", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "other_developmental_delays": {"name": "other_developmental_delays", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "parkinsons_disease_and_secondary_parkinsonism": {"name": "parkinsons_disease_and_secondary_parkinsonism", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "peripheral_vascular_disease_pvd": {"name": "peripheral_vascular_disease_pvd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "personality_disorders": {"name": "personality_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "pneumonia_all_cause": {"name": "pneumonia_all_cause", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "post_traumatic_stress_disorder_ptsd": {"name": "post_traumatic_stress_disorder_ptsd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "pressure_and_chronic_ulcers": {"name": "pressure_and_chronic_ulcers", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "rheumatoid_arthritis_osteoarthritis": {"name": "rheumatoid_arthritis_osteoarthritis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "schizophrenia": {"name": "schizophrenia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "schizophrenia_and_other_psychotic_disorders": {"name": "schizophrenia_and_other_psychotic_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "sensory_blindness_and_visual_impairment": {"name": "sensory_blindness_and_visual_impairment", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "sensory_deafness_and_hearing_impairment": {"name": "sensory_deafness_and_hearing_impairment", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "sickle_cell_disease": {"name": "sickle_cell_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "spina_bifida_and_other_congenital_anomalies_of_the_nervous_system": {"name": "spina_bifida_and_other_congenital_anomalies_of_the_nervous_system", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "spinal_cord_injury": {"name": "spinal_cord_injury", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "stroke_transient_ischemic_attack": {"name": "stroke_transient_ischemic_attack", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "tobacco_use": {"name": "tobacco_use", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage": {"name": "traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "viral_hepatitis_general": {"name": "viral_hepatitis_general", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "cms_chronic_conditions_wide", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.206622, "relation_name": "cms_synthetic.chronic_conditions.cms_chronic_conditions_wide", "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith chronic_conditions as (\n\n select distinct\n condition\n , condition_column_name\n from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\n\n)\n\n, conditions as (\n\n select\n chronic_conditions_unioned.patient_id\n , chronic_conditions.condition_column_name\n , 1 as condition_count\n from {{ ref('chronic_conditions__cms_chronic_conditions_long') }} as chronic_conditions_unioned\n inner join chronic_conditions as chronic_conditions\n on chronic_conditions_unioned.condition = chronic_conditions.condition\n\n)\n\nselect\n p.patient_id\n , {{ dbt_utils.pivot(\n column='condition_column_name'\n , values=dbt_utils.get_column_values(\n ref ('chronic_conditions__cms_chronic_conditions_hierarchy')\n , 'condition_column_name'\n , order_by= 'condition_column_name'\n )\n , agg='max'\n , then_value= 1\n , else_value= 0\n , quote_identifiers = False\n ) }}\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom {{ ref('cms_chronic_conditions__stg_core__patient') }} p\n left join conditions\n on p.patient_id = conditions.patient_id\ngroup by\n p.patient_id", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.get_column_values", "macro.dbt_utils.pivot"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.cms_chronic_conditions__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/final/chronic_conditions__cms_chronic_conditions_wide.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__patient as (\n\n\nselect \n patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), chronic_conditions as (\n\n select distinct\n condition\n , condition_column_name\n from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, conditions as (\n\n select\n chronic_conditions_unioned.patient_id\n , chronic_conditions.condition_column_name\n , 1 as condition_count\n from cms_synthetic.chronic_conditions.cms_chronic_conditions_long as chronic_conditions_unioned\n inner join chronic_conditions as chronic_conditions\n on chronic_conditions_unioned.condition = chronic_conditions.condition\n\n)\n\nselect\n p.patient_id\n , \n \n max(\n \n case\n when condition_column_name = 'acute_myocardial_infarction'\n then 1\n else 0\n end\n )\n \n \n as acute_myocardial_infarction\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'adhd_conduct_disorders_and_hyperkinetic_syndrome'\n then 1\n else 0\n end\n )\n \n \n as adhd_conduct_disorders_and_hyperkinetic_syndrome\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alcohol_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as alcohol_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alzheimers_disease'\n then 1\n else 0\n end\n )\n \n \n as alzheimers_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anemia'\n then 1\n else 0\n end\n )\n \n \n as anemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anxiety_disorders'\n then 1\n else 0\n end\n )\n \n \n as anxiety_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'asthma'\n then 1\n else 0\n end\n )\n \n \n as asthma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'atrial_fibrillation_and_flutter'\n then 1\n else 0\n end\n )\n \n \n as atrial_fibrillation_and_flutter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'autism_spectrum_disorders'\n then 1\n else 0\n end\n )\n \n \n as autism_spectrum_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'benign_prostatic_hyperplasia'\n then 1\n else 0\n end\n )\n \n \n as benign_prostatic_hyperplasia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'bipolar_disorder'\n then 1\n else 0\n end\n )\n \n \n as bipolar_disorder\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_breast'\n then 1\n else 0\n end\n )\n \n \n as cancer_breast\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_colorectal'\n then 1\n else 0\n end\n )\n \n \n as cancer_colorectal\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_endometrial'\n then 1\n else 0\n end\n )\n \n \n as cancer_endometrial\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_lung'\n then 1\n else 0\n end\n )\n \n \n as cancer_lung\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_prostate'\n then 1\n else 0\n end\n )\n \n \n as cancer_prostate\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_urologic_kidney_renal_pelvis_and_ureter'\n then 1\n else 0\n end\n )\n \n \n as cancer_urologic_kidney_renal_pelvis_and_ureter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cataract'\n then 1\n else 0\n end\n )\n \n \n as cataract\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cerebral_palsy'\n then 1\n else 0\n end\n )\n \n \n as cerebral_palsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_kidney_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_kidney_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_obstructive_pulmonary_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_obstructive_pulmonary_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cystic_fibrosis_and_other_metabolic_developmental_disorders'\n then 1\n else 0\n end\n )\n \n \n as cystic_fibrosis_and_other_metabolic_developmental_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depression_bipolar_or_other_depressive_mood_disorders'\n then 1\n else 0\n end\n )\n \n \n as depression_bipolar_or_other_depressive_mood_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depressive_disorders'\n then 1\n else 0\n end\n )\n \n \n as depressive_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'diabetes'\n then 1\n else 0\n end\n )\n \n \n as diabetes\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'drug_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as drug_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'epilepsy'\n then 1\n else 0\n end\n )\n \n \n as epilepsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'fibromyalgia_and_chronic_pain_and_fatigue'\n then 1\n else 0\n end\n )\n \n \n as fibromyalgia_and_chronic_pain_and_fatigue\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'glaucoma'\n then 1\n else 0\n end\n )\n \n \n as glaucoma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'heart_failure_and_non_ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as heart_failure_and_non_ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_a'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_a\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_acute_or_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_acute_or_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_acute'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_acute\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_d'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_d\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_e'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_e\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hip_pelvic_fracture'\n then 1\n else 0\n end\n )\n \n \n as hip_pelvic_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids'\n then 1\n else 0\n end\n )\n \n \n as human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hyperlipidemia'\n then 1\n else 0\n end\n )\n \n \n as hyperlipidemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypertension'\n then 1\n else 0\n end\n )\n \n \n as hypertension\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypothyroidism'\n then 1\n else 0\n end\n )\n \n \n as hypothyroidism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'intellectual_disabilities_and_related_conditions'\n then 1\n else 0\n end\n )\n \n \n as intellectual_disabilities_and_related_conditions\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'learning_disabilities'\n then 1\n else 0\n end\n )\n \n \n as learning_disabilities\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'leukemias_and_lymphomas'\n then 1\n else 0\n end\n )\n \n \n as leukemias_and_lymphomas\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis'\n then 1\n else 0\n end\n )\n \n \n as liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'migraine_and_chronic_headache'\n then 1\n else 0\n end\n )\n \n \n as migraine_and_chronic_headache\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'mobility_impairments'\n then 1\n else 0\n end\n )\n \n \n as mobility_impairments\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'multiple_sclerosis_and_transverse_myelitis'\n then 1\n else 0\n end\n )\n \n \n as multiple_sclerosis_and_transverse_myelitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'muscular_dystrophy'\n then 1\n else 0\n end\n )\n \n \n as muscular_dystrophy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'non_alzheimers_dementia'\n then 1\n else 0\n end\n )\n \n \n as non_alzheimers_dementia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'obesity'\n then 1\n else 0\n end\n )\n \n \n as obesity\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'opioid_use_disorder_oud'\n then 1\n else 0\n end\n )\n \n \n as opioid_use_disorder_oud\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'osteoporosis_with_or_without_pathological_fracture'\n then 1\n else 0\n end\n )\n \n \n as osteoporosis_with_or_without_pathological_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'other_developmental_delays'\n then 1\n else 0\n end\n )\n \n \n as other_developmental_delays\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'parkinsons_disease_and_secondary_parkinsonism'\n then 1\n else 0\n end\n )\n \n \n as parkinsons_disease_and_secondary_parkinsonism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'peripheral_vascular_disease_pvd'\n then 1\n else 0\n end\n )\n \n \n as peripheral_vascular_disease_pvd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'personality_disorders'\n then 1\n else 0\n end\n )\n \n \n as personality_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pneumonia_all_cause'\n then 1\n else 0\n end\n )\n \n \n as pneumonia_all_cause\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'post_traumatic_stress_disorder_ptsd'\n then 1\n else 0\n end\n )\n \n \n as post_traumatic_stress_disorder_ptsd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pressure_and_chronic_ulcers'\n then 1\n else 0\n end\n )\n \n \n as pressure_and_chronic_ulcers\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'rheumatoid_arthritis_osteoarthritis'\n then 1\n else 0\n end\n )\n \n \n as rheumatoid_arthritis_osteoarthritis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia_and_other_psychotic_disorders'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia_and_other_psychotic_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_blindness_and_visual_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_blindness_and_visual_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_deafness_and_hearing_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_deafness_and_hearing_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sickle_cell_disease'\n then 1\n else 0\n end\n )\n \n \n as sickle_cell_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spina_bifida_and_other_congenital_anomalies_of_the_nervous_system'\n then 1\n else 0\n end\n )\n \n \n as spina_bifida_and_other_congenital_anomalies_of_the_nervous_system\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spinal_cord_injury'\n then 1\n else 0\n end\n )\n \n \n as spinal_cord_injury\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'stroke_transient_ischemic_attack'\n then 1\n else 0\n end\n )\n \n \n as stroke_transient_ischemic_attack\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'tobacco_use'\n then 1\n else 0\n end\n )\n \n \n as tobacco_use\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage'\n then 1\n else 0\n end\n )\n \n \n as traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'viral_hepatitis_general'\n then 1\n else 0\n end\n )\n \n \n as viral_hepatitis_general\n \n \n \n \n\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__cms_chronic_conditions__stg_core__patient p\n left join conditions\n on p.patient_id = conditions.patient_id\ngroup by\n p.patient_id", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__patient as (\n\n\nselect \n patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__tuva_chronic_conditions_wide", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/final/chronic_conditions__tuva_chronic_conditions_wide.sql", "original_file_path": "models/chronic_conditions/final/chronic_conditions__tuva_chronic_conditions_wide.sql", "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__tuva_chronic_conditions_wide"], "alias": "tuva_chronic_conditions_wide", "checksum": {"name": "sha256", "checksum": "91c7ae23822f30bf52f1b2f32f9fd238cc421e0007e723e5cf6f3151fa0f4477"}, "config": {"enabled": true, "alias": "tuva_chronic_conditions_wide", "schema": "chronic_conditions", "database": null, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "description": "This model creates one record per patient with flags for all the conditions in the tuva chronic conditions hierarchy. A patient will have a 1 in the column for a certain condition if they have every been coded with a diagnosis that rolls up to that condition and a 0 if not.\n", "columns": {"patient_id": {"name": "patient_id", "description": "ID of the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "obesity": {"name": "obesity", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "osteoarthritis": {"name": "osteoarthritis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copd": {"name": "copd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "anxiety_disorders": {"name": "anxiety_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ckd": {"name": "ckd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "t2d": {"name": "t2d", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cll": {"name": "cll", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dysplipidemias": {"name": "dysplipidemias", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hypertension": {"name": "hypertension", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atherosclerosis": {"name": "atherosclerosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dementia": {"name": "dementia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rheumatoid_arthritis": {"name": "rheumatoid_arthritis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "celiac": {"name": "celiac", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hip_fracture": {"name": "hip_fracture", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "immunodeficiencies_and_white_blood_cell_disorders": {"name": "immunodeficiencies_and_white_blood_cell_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "asthma": {"name": "asthma", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "t1d": {"name": "t1d", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ulcerative_colitis": {"name": "ulcerative_colitis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chrohns": {"name": "chrohns", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "holicobacter": {"name": "holicobacter", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bipolar": {"name": "bipolar", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "heart_failure": {"name": "heart_failure", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tabacco": {"name": "tabacco", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lyme": {"name": "lyme", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "breast_cancer": {"name": "breast_cancer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "osteoporosis": {"name": "osteoporosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pulmonary_embolism": {"name": "pulmonary_embolism", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "schizophrenia": {"name": "schizophrenia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atrial_fibrillation": {"name": "atrial_fibrillation", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "colorectal_cancer": {"name": "colorectal_cancer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "depression": {"name": "depression", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deep_vein_thrombosis": {"name": "deep_vein_thrombosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alzheimer": {"name": "alzheimer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "stroke": {"name": "stroke", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "myocardial_infraction": {"name": "myocardial_infraction", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "opiod_use_disorder": {"name": "opiod_use_disorder", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lung_cancer": {"name": "lung_cancer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "herpes": {"name": "herpes", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rickettsiosis": {"name": "rickettsiosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms": {"name": "ms", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alchohol": {"name": "alchohol", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adhd": {"name": "adhd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hiv": {"name": "hiv", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ptsd": {"name": "ptsd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lupus": {"name": "lupus", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "tuva_chronic_conditions_wide", "tags": ["tuva_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.249289, "relation_name": "cms_synthetic.chronic_conditions.tuva_chronic_conditions_wide", "raw_code": "{{ config(\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\n )\n}}\n\nwith patients as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\n),\n\nobesity as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Obesity'\n),\n\n\nosteoarthritis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Osteoarthritis'\n),\n\ncopd as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Chronic Obstructive Pulmonary Disease'\n),\n\nanxiety_disorders as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Anxiety Disorders'\n),\n\nckd as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Chronic Kidney Disease'\n),\n\nt2d as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Type 2 Diabetes Mellitus'\n),\n\ncll as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Chronic Lymphocytic Leukemia'\n),\n\ndysplipidemias as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Dyslipidemias'\n),\n\nhypertension as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Hypertension'\n),\n\natherosclerosis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Atherosclerosis'\n),\n\ndementia as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Dementia'\n),\n\nrheumatoid_arthritis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Rheumatoid Arthritis'\n),\n\nceliac as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Celiac Disease'\n),\n\nhip_fracture as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Hip Fracture'\n),\n\nimmunodeficiencies_and_white_blood_cell_disorders as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Specified Immunodeficiencies and White Blood Cell Disorders (HCC v28 concept #115)'\n),\n\nasthma as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Asthma'\n),\n\nt1d as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Type 1 Diabetes Mellitus'\n),\n\nulcerative_colitis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Ulcerative colitis'\n),\n\nchrohns as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Crohns Disease'\n),\n\nholicobacter as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Helicobacter pylori Infection'\n),\n\nbipolar as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Bipolar Affective Disorder'\n),\n\nheart_failure as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Heart Failure'\n),\n\ntabacco as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Tobacco Use'\n),\n\nlyme as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Lyme Disease'\n),\n\nbreast_cancer as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Breast Cancer'\n),\n\nosteoporosis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Osteoporosis'\n),\n\npulmonary_embolism as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Pulmonary Embolism, Thrombotic or Unspecified'\n),\n\nschizophrenia as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Schizophrenia'\n),\n\natrial_fibrillation as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Atrial Fibrillation'\n),\n\ncolorectal_cancer as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Colorectal Cancer'\n),\n\ndepression as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Major Depressive Disorder'\n),\n\ndeep_vein_thrombosis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Deep Vein Thrombosis of Extremities or Central Veins'\n),\n\nalzheimer as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Alzheimer Disease'\n),\n\nstroke as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Stroke'\n),\n\nmyocardial_infraction as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Myocardial Infarction'\n),\n\nopiod_use_disorder as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Opioid Use Disorder'\n),\n\nlung_cancer as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Lung cancer, primary or unspecified'\n),\n\nherpes as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Herpes Simplex Infection'\n),\n\nrickettsiosis as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Rickettsiosis'\n),\n\nms as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Multiple Sclerosis'\n),\n\nalchohol as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Alcohol Use Disorder'\n),\n\nadhd as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Attention Deficit-Hyperactivity Disorder'\n),\n\nhiv as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'HIV/AIDS (HCC v28 concept #1)'\n),\n\nptsd as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Post-Traumatic Stress Disorder'\n),\n\nlupus as (\nselect distinct patient_id\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\nwhere condition = 'Systemic Lupus Erythematosus'\n)\n\n\n\n\nselect\n patient_id,\n case when patient_id in (select * from obesity) then 1\n else 0\n end as obesity,\n case when patient_id in (select * from osteoarthritis) then 1\n else 0\n end as osteoarthritis,\n case when patient_id in (select * from copd) then 1\n else 0\n end as copd,\n case when patient_id in (select * from anxiety_disorders) then 1\n else 0\n end as anxiety_disorders,\n case when patient_id in (select * from ckd) then 1\n else 0\n end as ckd,\n case when patient_id in (select * from t2d) then 1\n else 0\n end as t2d,\n case when patient_id in (select * from cll) then 1\n else 0\n end as cll,\n case when patient_id in (select * from dysplipidemias) then 1\n else 0\n end as dysplipidemias,\n case when patient_id in (select * from hypertension) then 1\n else 0\n end as hypertension,\n case when patient_id in (select * from atherosclerosis) then 1\n else 0\n end as atherosclerosis,\n case when patient_id in (select * from dementia) then 1\n else 0\n end as dementia,\n case when patient_id in (select * from rheumatoid_arthritis) then 1\n else 0\n end as rheumatoid_arthritis,\n case when patient_id in (select * from celiac) then 1\n else 0\n end as celiac,\n case when patient_id in (select * from hip_fracture) then 1\n else 0\n end as hip_fracture,\n case when patient_id in (select * from immunodeficiencies_and_white_blood_cell_disorders) then 1\n else 0\n end as immunodeficiencies_and_white_blood_cell_disorders,\n case when patient_id in (select * from asthma) then 1\n else 0\n end asthma,\n case when patient_id in (select * from t1d) then 1\n else 0\n end as t1d,\n case when patient_id in (select * from ulcerative_colitis) then 1\n else 0\n end as ulcerative_colitis,\n case when patient_id in (select * from chrohns) then 1\n else 0\n end as chrohns,\n case when patient_id in (select * from holicobacter) then 1\n else 0\n end as holicobacter,\n case when patient_id in (select * from bipolar) then 1\n else 0\n end as bipolar,\n case when patient_id in (select * from heart_failure) then 1\n else 0\n end as heart_failure,\n case when patient_id in (select * from tabacco) then 1\n else 0\n end as tabacco,\n case when patient_id in (select * from lyme) then 1\n else 0\n end as lyme,\n case when patient_id in (select * from breast_cancer) then 1\n else 0\n end as breast_cancer,\n case when patient_id in (select * from osteoporosis) then 1\n else 0\n end as osteoporosis,\n case when patient_id in (select * from pulmonary_embolism) then 1\n else 0\n end as pulmonary_embolism,\n case when patient_id in (select * from schizophrenia) then 1\n else 0\n end as schizophrenia,\n case when patient_id in (select * from atrial_fibrillation) then 1\n else 0\n end as atrial_fibrillation,\n case when patient_id in (select * from colorectal_cancer) then 1\n else 0\n end as colorectal_cancer,\n case when patient_id in (select * from depression) then 1\n else 0\n end as depression,\n case when patient_id in (select * from deep_vein_thrombosis) then 1\n else 0\n end as deep_vein_thrombosis,\n case when patient_id in (select * from alzheimer) then 1\n else 0\n end as alzheimer,\n case when patient_id in (select * from stroke) then 1\n else 0\n end as stroke,\n case when patient_id in (select * from myocardial_infraction) then 1\n else 0\n end as myocardial_infraction,\n case when patient_id in (select * from opiod_use_disorder) then 1\n else 0\n end as opiod_use_disorder,\n case when patient_id in (select * from lung_cancer) then 1\n else 0\n end as lung_cancer,\n case when patient_id in (select * from herpes) then 1\n else 0\n end as herpes,\n case when patient_id in (select * from rickettsiosis) then 1\n else 0\n end as rickettsiosis,\n case when patient_id in (select * from ms) then 1\n else 0\n end as ms,\n case when patient_id in (select * from alchohol) then 1\n else 0\n end as alchohol,\n case when patient_id in (select * from adhd) then 1\n else 0\n end as adhd,\n case when patient_id in (select * from hiv) then 1\n else 0\n end as hiv,\n case when patient_id in (select * from ptsd) then 1\n else 0\n end as ptsd,\n case when patient_id in (select * from lupus) then 1\n else 0\n end as lupus,\n '{{ var('tuva_last_run')}}' as tuva_last_run\n\nfrom patients", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/final/chronic_conditions__tuva_chronic_conditions_wide.sql", "compiled": true, "compiled_code": "\n\nwith patients as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n),\n\nobesity as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Obesity'\n),\n\n\nosteoarthritis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoarthritis'\n),\n\ncopd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Obstructive Pulmonary Disease'\n),\n\nanxiety_disorders as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Anxiety Disorders'\n),\n\nckd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Kidney Disease'\n),\n\nt2d as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 2 Diabetes Mellitus'\n),\n\ncll as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Lymphocytic Leukemia'\n),\n\ndysplipidemias as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dyslipidemias'\n),\n\nhypertension as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hypertension'\n),\n\natherosclerosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atherosclerosis'\n),\n\ndementia as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dementia'\n),\n\nrheumatoid_arthritis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rheumatoid Arthritis'\n),\n\nceliac as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Celiac Disease'\n),\n\nhip_fracture as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hip Fracture'\n),\n\nimmunodeficiencies_and_white_blood_cell_disorders as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Specified Immunodeficiencies and White Blood Cell Disorders (HCC v28 concept #115)'\n),\n\nasthma as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Asthma'\n),\n\nt1d as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 1 Diabetes Mellitus'\n),\n\nulcerative_colitis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Ulcerative colitis'\n),\n\nchrohns as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Crohns Disease'\n),\n\nholicobacter as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Helicobacter pylori Infection'\n),\n\nbipolar as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Bipolar Affective Disorder'\n),\n\nheart_failure as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Heart Failure'\n),\n\ntabacco as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Tobacco Use'\n),\n\nlyme as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lyme Disease'\n),\n\nbreast_cancer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Breast Cancer'\n),\n\nosteoporosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoporosis'\n),\n\npulmonary_embolism as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Pulmonary Embolism, Thrombotic or Unspecified'\n),\n\nschizophrenia as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Schizophrenia'\n),\n\natrial_fibrillation as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atrial Fibrillation'\n),\n\ncolorectal_cancer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Colorectal Cancer'\n),\n\ndepression as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Major Depressive Disorder'\n),\n\ndeep_vein_thrombosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Deep Vein Thrombosis of Extremities or Central Veins'\n),\n\nalzheimer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alzheimer Disease'\n),\n\nstroke as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Stroke'\n),\n\nmyocardial_infraction as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Myocardial Infarction'\n),\n\nopiod_use_disorder as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Opioid Use Disorder'\n),\n\nlung_cancer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lung cancer, primary or unspecified'\n),\n\nherpes as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Herpes Simplex Infection'\n),\n\nrickettsiosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rickettsiosis'\n),\n\nms as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Multiple Sclerosis'\n),\n\nalchohol as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alcohol Use Disorder'\n),\n\nadhd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Attention Deficit-Hyperactivity Disorder'\n),\n\nhiv as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'HIV/AIDS (HCC v28 concept #1)'\n),\n\nptsd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Post-Traumatic Stress Disorder'\n),\n\nlupus as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Systemic Lupus Erythematosus'\n)\n\n\n\n\nselect\n patient_id,\n case when patient_id in (select * from obesity) then 1\n else 0\n end as obesity,\n case when patient_id in (select * from osteoarthritis) then 1\n else 0\n end as osteoarthritis,\n case when patient_id in (select * from copd) then 1\n else 0\n end as copd,\n case when patient_id in (select * from anxiety_disorders) then 1\n else 0\n end as anxiety_disorders,\n case when patient_id in (select * from ckd) then 1\n else 0\n end as ckd,\n case when patient_id in (select * from t2d) then 1\n else 0\n end as t2d,\n case when patient_id in (select * from cll) then 1\n else 0\n end as cll,\n case when patient_id in (select * from dysplipidemias) then 1\n else 0\n end as dysplipidemias,\n case when patient_id in (select * from hypertension) then 1\n else 0\n end as hypertension,\n case when patient_id in (select * from atherosclerosis) then 1\n else 0\n end as atherosclerosis,\n case when patient_id in (select * from dementia) then 1\n else 0\n end as dementia,\n case when patient_id in (select * from rheumatoid_arthritis) then 1\n else 0\n end as rheumatoid_arthritis,\n case when patient_id in (select * from celiac) then 1\n else 0\n end as celiac,\n case when patient_id in (select * from hip_fracture) then 1\n else 0\n end as hip_fracture,\n case when patient_id in (select * from immunodeficiencies_and_white_blood_cell_disorders) then 1\n else 0\n end as immunodeficiencies_and_white_blood_cell_disorders,\n case when patient_id in (select * from asthma) then 1\n else 0\n end asthma,\n case when patient_id in (select * from t1d) then 1\n else 0\n end as t1d,\n case when patient_id in (select * from ulcerative_colitis) then 1\n else 0\n end as ulcerative_colitis,\n case when patient_id in (select * from chrohns) then 1\n else 0\n end as chrohns,\n case when patient_id in (select * from holicobacter) then 1\n else 0\n end as holicobacter,\n case when patient_id in (select * from bipolar) then 1\n else 0\n end as bipolar,\n case when patient_id in (select * from heart_failure) then 1\n else 0\n end as heart_failure,\n case when patient_id in (select * from tabacco) then 1\n else 0\n end as tabacco,\n case when patient_id in (select * from lyme) then 1\n else 0\n end as lyme,\n case when patient_id in (select * from breast_cancer) then 1\n else 0\n end as breast_cancer,\n case when patient_id in (select * from osteoporosis) then 1\n else 0\n end as osteoporosis,\n case when patient_id in (select * from pulmonary_embolism) then 1\n else 0\n end as pulmonary_embolism,\n case when patient_id in (select * from schizophrenia) then 1\n else 0\n end as schizophrenia,\n case when patient_id in (select * from atrial_fibrillation) then 1\n else 0\n end as atrial_fibrillation,\n case when patient_id in (select * from colorectal_cancer) then 1\n else 0\n end as colorectal_cancer,\n case when patient_id in (select * from depression) then 1\n else 0\n end as depression,\n case when patient_id in (select * from deep_vein_thrombosis) then 1\n else 0\n end as deep_vein_thrombosis,\n case when patient_id in (select * from alzheimer) then 1\n else 0\n end as alzheimer,\n case when patient_id in (select * from stroke) then 1\n else 0\n end as stroke,\n case when patient_id in (select * from myocardial_infraction) then 1\n else 0\n end as myocardial_infraction,\n case when patient_id in (select * from opiod_use_disorder) then 1\n else 0\n end as opiod_use_disorder,\n case when patient_id in (select * from lung_cancer) then 1\n else 0\n end as lung_cancer,\n case when patient_id in (select * from herpes) then 1\n else 0\n end as herpes,\n case when patient_id in (select * from rickettsiosis) then 1\n else 0\n end as rickettsiosis,\n case when patient_id in (select * from ms) then 1\n else 0\n end as ms,\n case when patient_id in (select * from alchohol) then 1\n else 0\n end as alchohol,\n case when patient_id in (select * from adhd) then 1\n else 0\n end as adhd,\n case when patient_id in (select * from hiv) then 1\n else 0\n end as hiv,\n case when patient_id in (select * from ptsd) then 1\n else 0\n end as ptsd,\n case when patient_id in (select * from lupus) then 1\n else 0\n end as lupus,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n\nfrom patients", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/final/chronic_conditions__cms_chronic_conditions_long.sql", "original_file_path": "models/chronic_conditions/final/chronic_conditions__cms_chronic_conditions_long.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__cms_chronic_conditions_long"], "alias": "cms_chronic_conditions_long", "checksum": {"name": "sha256", "checksum": "bba36906a41db32aea25e5c7405825cd580372787de0b877163e1c5971cad64a"}, "config": {"enabled": true, "alias": "cms_chronic_conditions_long", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model unions condition flags from the 3 upstream stage models that calculate them.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Cardiovascular Disease).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "cms_chronic_conditions_long", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.208687, "relation_name": "cms_synthetic.chronic_conditions.cms_chronic_conditions_long", "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n{% if target.type == 'fabric' %}\nwith conditions_unioned as (\n\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_all') }}\n union\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hiv_aids') }}\n union\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_oud') }}\n\n)\n{% else %}\nwith conditions_unioned as (\n\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_all') }}\n union distinct\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hiv_aids') }}\n union distinct\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_oud') }}\n\n)\n{% endif %}\n\nselect\n patient_id\n , claim_id\n , start_date\n , chronic_condition_type\n , condition_category\n , condition\n , data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom conditions_unioned", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/final/chronic_conditions__cms_chronic_conditions_long.sql", "compiled": true, "compiled_code": "\n\n\nwith conditions_unioned as (\n\n select * from cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\n union distinct\n select * from cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\n union distinct\n select * from cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\n\n)\n\n\nselect\n patient_id\n , claim_id\n , start_date\n , chronic_condition_type\n , condition_category\n , condition\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom conditions_unioned", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_hiv_aids.sql", "original_file_path": "models/chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_hiv_aids.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "fqn": ["the_tuva_project", "chronic_conditions", "intermediate", "chronic_conditions__cms_chronic_conditions_hiv_aids"], "alias": "_int_cms_chronic_condition_hiv_aids", "checksum": {"name": "sha256", "checksum": "4f9412d519141630654d58012836a8201f08648a5a325296b8cffc2acf0ba14a"}, "config": {"enabled": true, "alias": "_int_cms_chronic_condition_hiv_aids", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model contains logic for the chronic condition Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS). This model maps ICD-10-CM diagnosis codes and MS DRG codes to the chronic condition.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Other).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "_int_cms_chronic_condition_hiv_aids", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.212471, "relation_name": "cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids", "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n{%- set condition_filter = 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)' -%}\n\nwith chronic_conditions as (\n\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\n where condition = '{{ condition_filter }}'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__condition') }}\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__medical_claim') }}\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE excludes encounters with the exception code. Those encounters\n will be evaluated separately.\n*/\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code <> 'R75'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE includes encounters with the exception code only where that\n patient has another encounter that is not R75.\n*/\n, exception_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n inner join inclusions_diagnosis\n on patient_conditions.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code = 'R75'\n\n)\n\n{% if target.type == 'fabric' %}\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union\n select * from inclusions_ms_drg\n union\n select * from exception_diagnosis\n\n)\n{% else %}\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_ms_drg\n union distinct\n select * from exception_diagnosis\n\n)\n{% endif %}\n\nselect distinct\n cast(inclusions_unioned.patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(inclusions_unioned.claim_id as {{ dbt.type_string() }}) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as {{ dbt.type_string() }}) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as {{ dbt.type_string() }}) as condition_category\n , cast(inclusions_unioned.condition as {{ dbt.type_string() }}) as condition\n , cast(inclusions_unioned.data_source as {{ dbt.type_string() }}) as data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom inclusions_unioned", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_hiv_aids.sql", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), chronic_conditions as (\n\n select * from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE excludes encounters with the exception code. Those encounters\n will be evaluated separately.\n*/\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code <> 'R75'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE includes encounters with the exception code only where that\n patient has another encounter that is not R75.\n*/\n, exception_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n inner join inclusions_diagnosis\n on patient_conditions.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code = 'R75'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_ms_drg\n union distinct\n select * from exception_diagnosis\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom inclusions_unioned", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_oud", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_oud.sql", "original_file_path": "models/chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_oud.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "fqn": ["the_tuva_project", "chronic_conditions", "intermediate", "chronic_conditions__cms_chronic_conditions_oud"], "alias": "_int_cms_chronic_condition_oud", "checksum": {"name": "sha256", "checksum": "38ad9a84fe530ac318ee6626940d3fda6e443e8543b00ee6e5dc23ef487d7f9d"}, "config": {"enabled": true, "alias": "_int_cms_chronic_condition_oud", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model contains logic for the chronic condition Opioid Use Disorder (OUD). This model maps ICD-10-CM diagnosis codes, ICD-10-PCS procedure codes, HCPCS codes, and NDC codes to the chronic condition.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Substance Abuse).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "_int_cms_chronic_condition_oud", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.214157, "relation_name": "cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud", "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\n{%- set condition_filter = 'Opioid Use Disorder (OUD)' -%}\n\n{%- set naltrexone_ndcs = (\n '00056001122', '00056001130', '00056001170', '00056007950', '00056008050',\n '00185003901', '00185003930', '00406009201', '00406009203', '00406117001',\n '00406117003', '00555090201', '00555090202', '00904703604', '16729008101',\n '16729008110', '42291063230', '43063059115', '47335032683', '47335032688',\n '50090286600', '50436010501', '51224020630', '51224020650', '51285027501',\n '51285027502', '52152010502', '52152010504', '52152010530', '54868557400',\n '63459030042', '63629104601', '63629104701', '65694010003', '65694010010',\n '65757030001', '65757030202', '68084029111', '68084029121', '68094085362',\n '68115068030'\n )\n-%}\n\nwith chronic_conditions as (\n\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\n where condition = '{{ condition_filter }}'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__condition') }}\n\n)\n\n, patient_medications as (\n\n select\n patient_id\n , claim_id\n , paid_date as start_date\n , replace(ndc_code,'.','') as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__pharmacy_claim') }}\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__procedure') }}\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE excludes medication encounters with the exception codes for\n Naltrexone. Those encounters will be evaluated separately.\n*/\n, inclusions_medication as (\n\n select\n patient_medications.patient_id\n , patient_medications.claim_id\n , patient_medications.start_date\n , patient_medications.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code not in {{ naltrexone_ndcs }}\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE includes patients with evidence of the chronic conditions Alcohol\n Use Disorders or Drug Use Disorders.\n*/\n, exclusions_other_chronic_conditions as (\n\n select distinct patient_id\n from {{ ref('chronic_conditions__cms_chronic_conditions_all') }}\n where condition in (\n 'Alcohol Use Disorders'\n , 'Drug Use Disorders'\n )\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE creates the exclusion list which consists of patients with\n medication encounters for Naltrexone having Alcohol Use Disorder or Drug\n Use Disorder and missing the Opioid Use Disorder diagnosis codes.\n*/\n, exclusions_medication as (\n select distinct\n patient_medications.patient_id\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n inner join exclusions_other_chronic_conditions\n on patient_medications.patient_id = exclusions_other_chronic_conditions.patient_id\n left join inclusions_diagnosis\n on patient_medications.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code in {{ naltrexone_ndcs }}\n and inclusions_diagnosis.patient_id is null\n\n)\n\n{% if target.type == 'fabric' %}\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union\n select * from inclusions_procedure\n union\n select * from inclusions_medication\n\n)\n{% else %}\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_medication\n\n)\n{% endif %}\n\nselect distinct\n cast(inclusions_unioned.patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(inclusions_unioned.claim_id as {{ dbt.type_string() }}) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as {{ dbt.type_string() }}) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as {{ dbt.type_string() }}) as condition_category\n , cast(inclusions_unioned.condition as {{ dbt.type_string() }}) as condition\n , cast(inclusions_unioned.data_source as {{ dbt.type_string() }}) as data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_medication\n on inclusions_unioned.patient_id = exclusions_medication.patient_id\nwhere exclusions_medication.patient_id is null", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__pharmacy_claim", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__procedure", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_oud.sql", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim as (\n\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Opioid Use Disorder (OUD)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_medications as (\n\n select\n patient_id\n , claim_id\n , paid_date as start_date\n , replace(ndc_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE excludes medication encounters with the exception codes for\n Naltrexone. Those encounters will be evaluated separately.\n*/\n, inclusions_medication as (\n\n select\n patient_medications.patient_id\n , patient_medications.claim_id\n , patient_medications.start_date\n , patient_medications.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code not in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE includes patients with evidence of the chronic conditions Alcohol\n Use Disorders or Drug Use Disorders.\n*/\n, exclusions_other_chronic_conditions as (\n\n select distinct patient_id\n from cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\n where condition in (\n 'Alcohol Use Disorders'\n , 'Drug Use Disorders'\n )\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE creates the exclusion list which consists of patients with\n medication encounters for Naltrexone having Alcohol Use Disorder or Drug\n Use Disorder and missing the Opioid Use Disorder diagnosis codes.\n*/\n, exclusions_medication as (\n select distinct\n patient_medications.patient_id\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n inner join exclusions_other_chronic_conditions\n on patient_medications.patient_id = exclusions_other_chronic_conditions.patient_id\n left join inclusions_diagnosis\n on patient_medications.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n and inclusions_diagnosis.patient_id is null\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_medication\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_medication\n on inclusions_unioned.patient_id = exclusions_medication.patient_id\nwhere exclusions_medication.patient_id is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim as (\n\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_all", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_all.sql", "original_file_path": "models/chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_all.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "fqn": ["the_tuva_project", "chronic_conditions", "intermediate", "chronic_conditions__cms_chronic_conditions_all"], "alias": "_int_cms_chronic_condition_all", "checksum": {"name": "sha256", "checksum": "9f1ef71a64fd54936b74ba13a79b30351446bee31f284e21fda9c4354c3b11be"}, "config": {"enabled": true, "alias": "_int_cms_chronic_condition_all", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model contains logic for all chronic conditions where additional_logic is not 'None'. This model includes standard exclusions and maps ICD-10-CM diagnosis codes, ICD-10-PCS procedure codes, HCPCS codes, and MS DRG codes to chronic conditions.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Cardiovascular Disease).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/chronic_conditions/cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "_int_cms_chronic_condition_all", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623959.2106318, "relation_name": "cms_synthetic.chronic_conditions._int_cms_chronic_condition_all", "raw_code": "{{ config(\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\n )\n}}\n\nwith chronic_conditions as (\n\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__condition') }}\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__medical_claim') }}\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from {{ ref('cms_chronic_conditions__stg_core__procedure') }}\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, exclusions_diagnosis as (\n\n select distinct\n patient_conditions.claim_id\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Exclude'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n{% if target.type == 'fabric' %}\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union\n select * from inclusions_procedure\n union\n select * from inclusions_ms_drg\n\n)\n{% else %}\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_ms_drg\n\n)\n{% endif %}\n\nselect distinct\n cast(inclusions_unioned.patient_id as {{ dbt.type_string() }}) as patient_id\n , cast(inclusions_unioned.claim_id as {{ dbt.type_string() }}) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as {{ dbt.type_string() }}) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as {{ dbt.type_string() }}) as condition_category\n , cast(inclusions_unioned.condition as {{ dbt.type_string() }}) as condition\n , cast(inclusions_unioned.data_source as {{ dbt.type_string() }}) as data_source\n , '{{ var('tuva_last_run')}}' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_diagnosis\n on inclusions_unioned.claim_id = exclusions_diagnosis.claim_id\n and inclusions_unioned.condition = exclusions_diagnosis.condition\nwhere exclusions_diagnosis.claim_id is null", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__medical_claim", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/intermediate/chronic_conditions__cms_chronic_conditions_all.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, exclusions_diagnosis as (\n\n select distinct\n patient_conditions.claim_id\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Exclude'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_ms_drg\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_diagnosis\n on inclusions_unioned.claim_id = exclusions_diagnosis.claim_id\n and inclusions_unioned.condition = exclusions_diagnosis.condition\nwhere exclusions_diagnosis.claim_id is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "seed.the_tuva_project.terminology__admit_type": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__admit_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__admit_type.csv", "original_file_path": "seeds/terminology/terminology__admit_type.csv", "unique_id": "seed.the_tuva_project.terminology__admit_type", "fqn": ["the_tuva_project", "terminology", "terminology__admit_type"], "alias": "admit_type", "checksum": {"name": "sha256", "checksum": "8fd4b52317db368c0e056c2d0682234f2ba7017161f67dcc055b33738608f14c"}, "config": {"enabled": true, "alias": "admit_type", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','admit_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"admit_type_code": "varchar(256)", "admit_type_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing NUBC admission types and descriptions.", "columns": {"admit_type_code": {"name": "admit_type_code", "description": "The code representing the type of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "A description of the admission type.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','admit_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "admit_type", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"admit_type_code": "varchar(256)", "admit_type_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.188073, "relation_name": "cms_synthetic.terminology.admit_type", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__medicare_orec": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__medicare_orec", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__medicare_orec.csv", "original_file_path": "seeds/terminology/terminology__medicare_orec.csv", "unique_id": "seed.the_tuva_project.terminology__medicare_orec", "fqn": ["the_tuva_project", "terminology", "terminology__medicare_orec"], "alias": "medicare_orec", "checksum": {"name": "sha256", "checksum": "91af2feb419d4ab1b82f88a165db27a2ded30c3e3b221081dc0bebee6c9c44ed"}, "config": {"enabled": true, "alias": "medicare_orec", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_orec.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"original_reason_entitlement_code": "varchar(256)", "original_reason_entitlement_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing Medicare original reason for entitlement (OREC) codes and descriptions.", "columns": {"original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "The code representing the original reason for Medicare entitlement.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_description": {"name": "original_reason_entitlement_description", "description": "A description of the original reason for Medicare entitlement.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_orec.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "medicare_orec", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"original_reason_entitlement_code": "varchar(256)", "original_reason_entitlement_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.2806451, "relation_name": "cms_synthetic.terminology.medicare_orec", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__gender": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__gender", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__gender.csv", "original_file_path": "seeds/terminology/terminology__gender.csv", "unique_id": "seed.the_tuva_project.terminology__gender", "fqn": ["the_tuva_project", "terminology", "terminology__gender"], "alias": "gender", "checksum": {"name": "sha256", "checksum": "de9feaea8b66f7ba74845ee5fc156cdd22e8e4533de13ca76d71ac495da358ff"}, "config": {"enabled": true, "alias": "gender", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','gender.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"gender": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing gender codes and descriptions.", "columns": {"gender": {"name": "gender", "description": "The gender code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','gender.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "gender", "tags": ["terminology", "data_profiling"], "column_types": {"gender": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.215828, "relation_name": "cms_synthetic.terminology.gender", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ethnicity": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__ethnicity", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__ethnicity.csv", "original_file_path": "seeds/terminology/terminology__ethnicity.csv", "unique_id": "seed.the_tuva_project.terminology__ethnicity", "fqn": ["the_tuva_project", "terminology", "terminology__ethnicity"], "alias": "ethnicity", "checksum": {"name": "sha256", "checksum": "bcfd53e2a625f5953eddc7252d70dadd8a688413415a52484c604d7233d52dd6"}, "config": {"enabled": true, "alias": "ethnicity", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ethnicity.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing ethnicity codes and descriptions.", "columns": {"code": {"name": "code", "description": "The code representing the ethnicity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "A description of the ethnicity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ethnicity.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ethnicity", "tags": "terminology", "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.211387, "relation_name": "cms_synthetic.terminology.ethnicity", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ccs_services_procedures": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__ccs_services_procedures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__ccs_services_procedures.csv", "original_file_path": "seeds/terminology/terminology__ccs_services_procedures.csv", "unique_id": "seed.the_tuva_project.terminology__ccs_services_procedures", "fqn": ["the_tuva_project", "terminology", "terminology__ccs_services_procedures"], "alias": "ccs_services_procedures", "checksum": {"name": "sha256", "checksum": "8f104023cc661ebf3eb34a6900a8c2e0b008cc631bf27e1db53950a883323dfe"}, "config": {"enabled": true, "alias": "ccs_services_procedures", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ccs_services_procedures.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs_code": "varchar(5)", "ccs_category": "varchar(3)", "ccs_category_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ccs_services_procedures.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ccs_services_procedures", "tags": ["terminology"], "column_types": {"hcpcs_code": "varchar(5)", "ccs_category": "varchar(3)", "ccs_category_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.384684, "relation_name": "cms_synthetic.terminology.ccs_services_procedures", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ms_drg": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__ms_drg", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__ms_drg.csv", "original_file_path": "seeds/terminology/terminology__ms_drg.csv", "unique_id": "seed.the_tuva_project.terminology__ms_drg", "fqn": ["the_tuva_project", "terminology", "terminology__ms_drg"], "alias": "ms_drg", "checksum": {"name": "sha256", "checksum": "d551fa50b60ab14efddee46089274d432d11570f3216db9aa6868074ace94ca2"}, "config": {"enabled": true, "alias": "ms_drg", "schema": "terminology", "database": null, "tags": ["terminology", "readmissions", "data_profiling", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ms_drg.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ms_drg_code": "varchar(256)", "mdc_code": "varchar(256)", "medical_surgical": "varchar(256)", "ms_drg_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "readmissions", "data_profiling", "claims_preprocessing"], "description": "Seed containing Medicare Severity Diagnosis Related Groups (MS-DRG) codes and descriptions.", "columns": {"ms_drg_code": {"name": "ms_drg_code", "description": "The Medicare Severity Diagnosis Related Group (MS-DRG) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc_code": {"name": "mdc_code", "description": "The Major Diagnostic Category (MDC) code associated with the MS-DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "Indicates whether the DRG is medical or surgical.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "The description of the Medicare Severity Diagnosis Related Group (MS-DRG).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated": {"name": "deprecated", "description": "Indicates if the MS-DRG code is deprecated (1) or not (0).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated_date": {"name": "deprecated_date", "description": "The date when the MS-DRG code was deprecated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ms_drg.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ms_drg", "tags": ["terminology", "readmissions", "data_profiling", "claims_preprocessing"], "column_types": {"ms_drg_code": "varchar(256)", "mdc_code": "varchar(256)", "medical_surgical": "varchar(256)", "ms_drg_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.298348, "relation_name": "cms_synthetic.terminology.ms_drg", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__hcpcs_to_rbcs": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__hcpcs_to_rbcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__hcpcs_to_rbcs.csv", "original_file_path": "seeds/terminology/terminology__hcpcs_to_rbcs.csv", "unique_id": "seed.the_tuva_project.terminology__hcpcs_to_rbcs", "fqn": ["the_tuva_project", "terminology", "terminology__hcpcs_to_rbcs"], "alias": "hcpcs_to_rbcs", "checksum": {"name": "sha256", "checksum": "d77822a411a96ed720cb2b94ffda8e51f1522a508ad2bb286ea24d90057aa02c"}, "config": {"enabled": true, "alias": "hcpcs_to_rbcs", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','hcpcs_to_rbcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs_cd": "varchar(256)", "rbcs_id": "varchar(256)", "rbcs_cat": "varchar(256)", "rbcs_cat_desc": "varchar(256)", "rbcs_cat_subcat": "varchar(256)", "rbcs_subcat_desc": "varchar(256)", "rbcs_famnumb": "numeric", "rbcs_family_desc": "varchar(256)", "rbcs_major_ind": "varchar(256)", "hcpcs_cd_add_dt": "date", "hcpcs_cd_end_dt": "date", "rbcs_assignment_eff_dt": "date", "current_flag": "numeric"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "HCPCS to RBCS crosswalk.", "columns": {"hcpcs_cd": {"name": "hcpcs_cd", "description": "HCPCS or CPT code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_id": {"name": "rbcs_id", "description": "RBCS identifier which is comprised of 6 characters. The first \ncharacter identifies the category; the second character identifies\nthe subcategory; the third, fourth, and fifth characters identify\nthe family, and the sixth character identifies whether the service\nis a major procedure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_cat": {"name": "rbcs_cat", "description": "First character for the RBCS taxonomy ID, which represents the RBCS ID category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_cat_desc": {"name": "rbcs_cat_desc", "description": "Category description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_cat_subcat": {"name": "rbcs_cat_subcat", "description": "First 2 characters for the RBCS taxonomy ID, which represents the RBCS ID's category and subcategory.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_subcat_desc": {"name": "rbcs_subcat_desc", "description": "Subcategory description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_famnumb": {"name": "rbcs_famnumb", "description": "Third, fourth, and fifth characters, which represents the RBCS family number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_family_desc": {"name": "rbcs_family_desc", "description": "Family description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_major_ind": {"name": "rbcs_major_ind", "description": "Sixth character for the RBCS taxonomy ID, which identifies whether\nthe HCPCS code is a Major procedure (M), Other (O), or non-procedure\ncode (N).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_cd_add_dt": {"name": "hcpcs_cd_add_dt", "description": "HCPCS Code Effective Date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_cd_end_dt": {"name": "hcpcs_cd_end_dt", "description": "HCPCS Code End Date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_assignment_eff_dt": {"name": "rbcs_assignment_eff_dt", "description": "Provides users with the earliest date that the RBCS ID is effective.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_flag": {"name": "current_flag", "description": "Flag where 1 = the current version of the RBCS for that particular HCPCS_CD, 0 = old version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','hcpcs_to_rbcs.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "hcpcs_to_rbcs", "tags": "terminology", "enabled": true, "column_types": {"hcpcs_cd": "varchar(256)", "rbcs_id": "varchar(256)", "rbcs_cat": "varchar(256)", "rbcs_cat_desc": "varchar(256)", "rbcs_cat_subcat": "varchar(256)", "rbcs_subcat_desc": "varchar(256)", "rbcs_famnumb": "numeric", "rbcs_family_desc": "varchar(256)", "rbcs_major_ind": "varchar(256)", "hcpcs_cd_add_dt": "date", "hcpcs_cd_end_dt": "date", "rbcs_assignment_eff_dt": "date", "current_flag": "numeric"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.23178, "relation_name": "cms_synthetic.terminology.hcpcs_to_rbcs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__revenue_center": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__revenue_center", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__revenue_center.csv", "original_file_path": "seeds/terminology/terminology__revenue_center.csv", "unique_id": "seed.the_tuva_project.terminology__revenue_center", "fqn": ["the_tuva_project", "terminology", "terminology__revenue_center"], "alias": "revenue_center", "checksum": {"name": "sha256", "checksum": "58bde54ea73aaaa50a0342bb8a28da19fe865ca82d3997c3297c9ad616ca9eb1"}, "config": {"enabled": true, "alias": "revenue_center", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','revenue_center.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"revenue_center_code": "varchar(256)", "revenue_center_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing revenue center codes and descriptions.", "columns": {"revenue_center_code": {"name": "revenue_center_code", "description": "The code representing the revenue center.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_description": {"name": "revenue_center_description", "description": "A description of the revenue center.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','revenue_center.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "revenue_center", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"revenue_center_code": "varchar(256)", "revenue_center_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.3401442, "relation_name": "cms_synthetic.terminology.revenue_center", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_9_cm": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__icd_9_cm", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__icd_9_cm.csv", "original_file_path": "seeds/terminology/terminology__icd_9_cm.csv", "unique_id": "seed.the_tuva_project.terminology__icd_9_cm", "fqn": ["the_tuva_project", "terminology", "terminology__icd_9_cm"], "alias": "icd_9_cm", "checksum": {"name": "sha256", "checksum": "ed4c7e9c312522e20df88cb21837ea0953be63016bbd49c48a44f215e55353db"}, "config": {"enabled": true, "alias": "icd_9_cm", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_9_cm.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_9_cm": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "description": "Seed containing ICD-9-CM codes and descriptions.", "columns": {"icd_9_cm": {"name": "icd_9_cm", "description": "The ICD-9-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the ICD-9-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the ICD-9-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_9_cm.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_9_cm", "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "column_types": {"icd_9_cm": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.2362509, "relation_name": "cms_synthetic.terminology.icd_9_cm", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__snomed_ct_transitive_closures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__snomed_ct_transitive_closures.csv", "original_file_path": "seeds/terminology/terminology__snomed_ct_transitive_closures.csv", "unique_id": "seed.the_tuva_project.terminology__snomed_ct_transitive_closures", "fqn": ["the_tuva_project", "terminology", "terminology__snomed_ct_transitive_closures"], "alias": "snomed_ct_transitive_closures", "checksum": {"name": "sha256", "checksum": "8b4906f98be3058e45aee7a8c557623623beeeaca290ca922146f1541ff85c7b"}, "config": {"enabled": true, "alias": "snomed_ct_transitive_closures", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_ct_transitive_closures.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"parent_snomed_code": "varchar(256)", "parent_description": "varchar(256)", "child_snomed_code": "varchar(256)", "child_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing SNOMED CT transitive closures.", "columns": {"parent_snomed_code": {"name": "parent_snomed_code", "description": "The SNOMED code of the parent concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_description": {"name": "parent_description", "description": "The description of the parent SNOMED concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "child_snomed_code": {"name": "child_snomed_code", "description": "The SNOMED code of the child concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "child_description": {"name": "child_description", "description": "The description of the child SNOMED concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_ct_transitive_closures.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "snomed_ct_transitive_closures", "tags": ["terminology"], "column_types": {"parent_snomed_code": "varchar(256)", "parent_description": "varchar(256)", "child_snomed_code": "varchar(256)", "child_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.373172, "relation_name": "cms_synthetic.terminology.snomed_ct_transitive_closures", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__race": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__race", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__race.csv", "original_file_path": "seeds/terminology/terminology__race.csv", "unique_id": "seed.the_tuva_project.terminology__race", "fqn": ["the_tuva_project", "terminology", "terminology__race"], "alias": "race", "checksum": {"name": "sha256", "checksum": "bcfd53e2a625f5953eddc7252d70dadd8a688413415a52484c604d7233d52dd6"}, "config": {"enabled": true, "alias": "race", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','race.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing race codes and descriptions.", "columns": {"code": {"name": "code", "description": "The code representing the race.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "A description of the race.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','race.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "race", "tags": ["terminology", "data_profiling"], "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.336092, "relation_name": "cms_synthetic.terminology.race", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__rxnorm_to_atc": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__rxnorm_to_atc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__rxnorm_to_atc.csv", "original_file_path": "seeds/terminology/terminology__rxnorm_to_atc.csv", "unique_id": "seed.the_tuva_project.terminology__rxnorm_to_atc", "fqn": ["the_tuva_project", "terminology", "terminology__rxnorm_to_atc"], "alias": "rxnorm_to_atc", "checksum": {"name": "sha256", "checksum": "3817989c76e5142e5e0e6827d61b00cab45c17a94b77f923898d844f9807ad4c"}, "config": {"enabled": true, "alias": "rxnorm_to_atc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','rxnorm_to_atc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "atc_1_code": "varchar(256)", "atc_1_name": "varchar(256)", "atc_2_code": "varchar(256)", "atc_2_name": "varchar(256)", "atc_3_code": "varchar(256)", "atc_3_name": "varchar(256)", "atc_4_code": "varchar(256)", "atc_4_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "This file maps ATC classes to RxCUI. The file is maintained by [CodeRX](https://coderx.io/) in partnership with Tuva Health.", "columns": {"rxcui": {"name": "rxcui", "description": "The RxNorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "Description of the RxNorm concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_1_code": {"name": "atc_1_code", "description": "The ATC level 1 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_1_name": {"name": "atc_1_name", "description": "The name of the ATC level 1 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_2_code": {"name": "atc_2_code", "description": "The ATC level 2 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_2_name": {"name": "atc_2_name", "description": "The name of the ATC level 2 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_3_code": {"name": "atc_3_code", "description": "The ATC level 3 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_3_name": {"name": "atc_3_name", "description": "The name of the ATC level 3 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_4_code": {"name": "atc_4_code", "description": "The ATC level 4 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_4_name": {"name": "atc_4_name", "description": "The name of the ATC level 4 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','rxnorm_to_atc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "rxnorm_to_atc", "tags": ["terminology"], "column_types": {"rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "atc_1_code": "varchar(256)", "atc_1_name": "varchar(256)", "atc_2_code": "varchar(256)", "atc_2_name": "varchar(256)", "atc_3_code": "varchar(256)", "atc_3_name": "varchar(256)", "atc_4_code": "varchar(256)", "atc_4_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.3510752, "relation_name": "cms_synthetic.terminology.rxnorm_to_atc", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__medicare_status": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__medicare_status", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__medicare_status.csv", "original_file_path": "seeds/terminology/terminology__medicare_status.csv", "unique_id": "seed.the_tuva_project.terminology__medicare_status", "fqn": ["the_tuva_project", "terminology", "terminology__medicare_status"], "alias": "medicare_status", "checksum": {"name": "sha256", "checksum": "c9d34774cf96cec7e8b301c8a965bdf320c0a03e65ffb96ba745ac3f161a2656"}, "config": {"enabled": true, "alias": "medicare_status", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_status.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"medicare_status_code": "varchar(256)", "medicare_status_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing Medicare status codes and descriptions.", "columns": {"medicare_status_code": {"name": "medicare_status_code", "description": "The code representing the Medicare status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_description": {"name": "medicare_status_description", "description": "A description of the Medicare status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_status.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "medicare_status", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"medicare_status_code": "varchar(256)", "medicare_status_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.28571, "relation_name": "cms_synthetic.terminology.medicare_status", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__loinc_deprecated_mapping": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__loinc_deprecated_mapping", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__loinc_deprecated_mapping.csv", "original_file_path": "seeds/terminology/terminology__loinc_deprecated_mapping.csv", "unique_id": "seed.the_tuva_project.terminology__loinc_deprecated_mapping", "fqn": ["the_tuva_project", "terminology", "terminology__loinc_deprecated_mapping"], "alias": "loinc_deprecated_mapping", "checksum": {"name": "sha256", "checksum": "eecd52c3944bc1abd373c557a286ee386438733c6daf2fbb844e86623f7af119"}, "config": {"enabled": true, "alias": "loinc_deprecated_mapping", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','loinc_deprecated_mapping.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"loinc": "varchar(256)", "map_to": "varchar(256)", "comment": "varchar(256)", "final_map_to": "varchar(256)", "all_comments": "varchar(256)", "depth": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing deprecated LOINC codes and their replacements.", "columns": {"loinc": {"name": "loinc", "description": "The deprecated term to which the replacement term(s) apply.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_to": {"name": "map_to", "description": "A replacement term that is to be used in place of the deprecated or discouraged term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "comment": {"name": "comment", "description": "Narrative text that explains the rationale for using the recommended replacement term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "final_map_to": {"name": "final_map_to", "description": "If there are multiple steps of deprecated codes, this is the final (active) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "all_comments": {"name": "all_comments", "description": "An aggregation of comments for any mapping steps between the deprecated code and the active code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "depth": {"name": "depth", "description": "How many steps this mapping is to the active code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','loinc_deprecated_mapping.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "loinc_deprecated_mapping", "tags": ["terminology"], "column_types": {"loinc": "varchar(256)", "map_to": "varchar(256)", "comment": "varchar(256)", "final_map_to": "varchar(256)", "all_comments": "varchar(256)", "depth": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.269037, "relation_name": "cms_synthetic.terminology.loinc_deprecated_mapping", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__place_of_service": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__place_of_service", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__place_of_service.csv", "original_file_path": "seeds/terminology/terminology__place_of_service.csv", "unique_id": "seed.the_tuva_project.terminology__place_of_service", "fqn": ["the_tuva_project", "terminology", "terminology__place_of_service"], "alias": "place_of_service", "checksum": {"name": "sha256", "checksum": "73979f823fbd58b0591864b102c9fbaea4459a05cc2aa4dcd3231c6a33c7ebb7"}, "config": {"enabled": true, "alias": "place_of_service", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','place_of_service.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"place_of_service_code": "varchar(256)", "place_of_service_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing place of service codes and descriptions.", "columns": {"place_of_service_code": {"name": "place_of_service_code", "description": "The code representing the place of service.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_description": {"name": "place_of_service_description", "description": "A description of the place of service.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','place_of_service.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "place_of_service", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"place_of_service_code": "varchar(256)", "place_of_service_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.31707, "relation_name": "cms_synthetic.terminology.place_of_service", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__discharge_disposition": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__discharge_disposition", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__discharge_disposition.csv", "original_file_path": "seeds/terminology/terminology__discharge_disposition.csv", "unique_id": "seed.the_tuva_project.terminology__discharge_disposition", "fqn": ["the_tuva_project", "terminology", "terminology__discharge_disposition"], "alias": "discharge_disposition", "checksum": {"name": "sha256", "checksum": "a76af528d7f867c651a809fdc4147595eb3a4e67f813b03f856f76f86a0b585c"}, "config": {"enabled": true, "alias": "discharge_disposition", "schema": "terminology", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','discharge_disposition.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"discharge_disposition_code": "varchar(256)", "discharge_disposition_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Seed containing NUBC discharge disposition codes and descriptions.", "columns": {"discharge_disposition_code": {"name": "discharge_disposition_code", "description": "The code representing the discharge disposition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "A description of the discharge disposition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','discharge_disposition.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "discharge_disposition", "column_types": {"discharge_disposition_code": "varchar(256)", "discharge_disposition_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.203982, "relation_name": "cms_synthetic.terminology.discharge_disposition", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_9_pcs": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__icd_9_pcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__icd_9_pcs.csv", "original_file_path": "seeds/terminology/terminology__icd_9_pcs.csv", "unique_id": "seed.the_tuva_project.terminology__icd_9_pcs", "fqn": ["the_tuva_project", "terminology", "terminology__icd_9_pcs"], "alias": "icd_9_pcs", "checksum": {"name": "sha256", "checksum": "97258446a8c069119ada9e71632dd8a3f73135968cfdb38ba09109003915b525"}, "config": {"enabled": true, "alias": "icd_9_pcs", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_9_pcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_9_pcs": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "description": "Seed containing ICD-9-PCS codes and descriptions.", "columns": {"icd_9_pcs": {"name": "icd_9_pcs", "description": "The ICD-9-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the ICD-9-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the ICD-9-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_9_pcs.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_9_pcs", "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "column_types": {"icd_9_pcs": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.240353, "relation_name": "cms_synthetic.terminology.icd_9_pcs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__present_on_admission": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__present_on_admission", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__present_on_admission.csv", "original_file_path": "seeds/terminology/terminology__present_on_admission.csv", "unique_id": "seed.the_tuva_project.terminology__present_on_admission", "fqn": ["the_tuva_project", "terminology", "terminology__present_on_admission"], "alias": "present_on_admission", "checksum": {"name": "sha256", "checksum": "1f17dd2ef1ccf1f8cb156ac0d4be3cf5e7e96b56bfcb97b5113d0de8aabace48"}, "config": {"enabled": true, "alias": "present_on_admission", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','present_on_admission.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"present_on_admit_code": "varchar(256)", "present_on_admit_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "description": "Seed containing present on admission (POA) indicator codes and descriptions.", "columns": {"present_on_admit_code": {"name": "present_on_admit_code", "description": "The code representing if the condition was present on admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "present_on_admit_description": {"name": "present_on_admit_description", "description": "A description of the present on admission (POA) indicator.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','present_on_admission.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "present_on_admission", "tags": ["terminology", "data_profiling", "claims_preprocessing"], "column_types": {"present_on_admit_code": "varchar(256)", "present_on_admit_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.320853, "relation_name": "cms_synthetic.terminology.present_on_admission", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__mdc": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__mdc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__mdc.csv", "original_file_path": "seeds/terminology/terminology__mdc.csv", "unique_id": "seed.the_tuva_project.terminology__mdc", "fqn": ["the_tuva_project", "terminology", "terminology__mdc"], "alias": "mdc", "checksum": {"name": "sha256", "checksum": "ff8bd52323887788765f3602e13e6083ecebee26d5b9466d118f531d46a445e3"}, "config": {"enabled": true, "alias": "mdc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','mdc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"mdc_code": "varchar(256)", "mdc_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing Major Diagnostic Categories (MDC) codes and descriptions.", "columns": {"mdc_code": {"name": "mdc_code", "description": "The Major Diagnostic Category (MDC) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc_description": {"name": "mdc_description", "description": "The description of the Major Diagnostic Category (MDC).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','mdc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "mdc", "tags": "terminology", "column_types": {"mdc_code": "varchar(256)", "mdc_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.2728078, "relation_name": "cms_synthetic.terminology.mdc", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__admit_source": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__admit_source", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__admit_source.csv", "original_file_path": "seeds/terminology/terminology__admit_source.csv", "unique_id": "seed.the_tuva_project.terminology__admit_source", "fqn": ["the_tuva_project", "terminology", "terminology__admit_source"], "alias": "admit_source", "checksum": {"name": "sha256", "checksum": "7068c87e74a237a6908ab4e7709afe8cfca181ad74d3e91ff9955926dc0e92ff"}, "config": {"enabled": true, "alias": "admit_source", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','admit_source.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"admit_source_code": "varchar(256)", "admit_source_description": "varchar(256)", "newborn_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "NUBC Admit Sources", "columns": {"admit_source_code": {"name": "admit_source_code", "description": "The code representing the source of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "A description of the admission source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_description": {"name": "newborn_description", "description": "Description related to newborn admission. For use when admit type code = 4 (Newborn)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','admit_source.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "admit_source", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"admit_source_code": "varchar(256)", "admit_source_description": "varchar(256)", "newborn_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.184296, "relation_name": "cms_synthetic.terminology.admit_source", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__rxnorm_brand_generic": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__rxnorm_brand_generic", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__rxnorm_brand_generic.csv", "original_file_path": "seeds/terminology/terminology__rxnorm_brand_generic.csv", "unique_id": "seed.the_tuva_project.terminology__rxnorm_brand_generic", "fqn": ["the_tuva_project", "terminology", "terminology__rxnorm_brand_generic"], "alias": "rxnorm_brand_generic", "checksum": {"name": "sha256", "checksum": "5300a2b3b0d164174be2fb0fb4c3eb1cef581ddc8f8f21e47c5803e22304f8e6"}, "config": {"enabled": true, "alias": "rxnorm_brand_generic", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','rxnorm_brand_generic.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "product_tty": "varchar(256)", "brand_vs_generic": "varchar(256)", "brand_name": "varchar(1000)", "clinical_product_rxcui": "varchar(256)", "clinical_product_name": "varchar(3000)", "clinical_product_tty": "varchar(256)", "ingredient_name": "varchar(3000)", "dose_form_name": "varchar(3000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','rxnorm_brand_generic.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "rxnorm_brand_generic", "tags": ["terminology"], "column_types": {"product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "product_tty": "varchar(256)", "brand_vs_generic": "varchar(256)", "brand_name": "varchar(1000)", "clinical_product_rxcui": "varchar(256)", "clinical_product_name": "varchar(3000)", "clinical_product_tty": "varchar(256)", "ingredient_name": "varchar(3000)", "dose_form_name": "varchar(3000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.38012, "relation_name": "cms_synthetic.terminology.rxnorm_brand_generic", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__other_provider_taxonomy": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__other_provider_taxonomy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__other_provider_taxonomy.csv", "original_file_path": "seeds/terminology/terminology__other_provider_taxonomy.csv", "unique_id": "seed.the_tuva_project.terminology__other_provider_taxonomy", "fqn": ["the_tuva_project", "terminology", "terminology__other_provider_taxonomy"], "alias": "other_provider_taxonomy", "checksum": {"name": "sha256", "checksum": "ea344ae188db60f0f75e52a39114af49b7828fe050d3f761db03d4d07039cccf"}, "config": {"enabled": true, "alias": "other_provider_taxonomy", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.1','other_provider_taxonomy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"npi": "varchar(35)", "taxonomy_code": "varchar(35)", "medicare_specialty_code": "varchar(173)", "description": "varchar(101)", "primary_flag": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing"], "description": "Seed containing other provider taxonomy codes and descriptions.", "columns": {"npi": {"name": "npi", "description": "The National Provider Identifier (NPI).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "taxonomy_code": {"name": "taxonomy_code", "description": "The provider taxonomy code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_specialty_code": {"name": "medicare_specialty_code", "description": "The Medicare specialty code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the provider taxonomy.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_flag": {"name": "primary_flag", "description": "Indicates if this is the primary taxonomy (1) or not (0).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.1','other_provider_taxonomy.csv',compression=true,null_marker=true) }}", "schema": "terminology", "tags": ["terminology", "claims_preprocessing"], "alias": "other_provider_taxonomy", "column_types": {"npi": "varchar(35)", "taxonomy_code": "varchar(35)", "medicare_specialty_code": "varchar(173)", "description": "varchar(101)", "primary_flag": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.308199, "relation_name": "cms_synthetic.terminology.other_provider_taxonomy", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_10_cm": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__icd_10_cm", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__icd_10_cm.csv", "original_file_path": "seeds/terminology/terminology__icd_10_cm.csv", "unique_id": "seed.the_tuva_project.terminology__icd_10_cm", "fqn": ["the_tuva_project", "terminology", "terminology__icd_10_cm"], "alias": "icd_10_cm", "checksum": {"name": "sha256", "checksum": "26bd81ab956f24c68160aadcef4bb75551ffb125b0ecadf437f6eb0e343099fb"}, "config": {"enabled": true, "alias": "icd_10_cm", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_10_cm.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "header_flag": "varchar(256)", "short_description": "varchar(256)", "long_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "description": "Seed containing ICD-10-CM codes and descriptions.", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "The ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "header_flag": {"name": "header_flag", "description": "Flag indicating if the code is a header.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_10_cm.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_10_cm", "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "column_types": {"icd_10_cm": "varchar(256)", "header_flag": "varchar(256)", "short_description": "varchar(256)", "long_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.245306, "relation_name": "cms_synthetic.terminology.icd_10_cm", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__claim_type": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__claim_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__claim_type.csv", "original_file_path": "seeds/terminology/terminology__claim_type.csv", "unique_id": "seed.the_tuva_project.terminology__claim_type", "fqn": ["the_tuva_project", "terminology", "terminology__claim_type"], "alias": "claim_type", "checksum": {"name": "sha256", "checksum": "5e72668475091f682d6782ae0d708213ddb0a1c5c1f4e3c457132e739ceb7cb5"}, "config": {"enabled": true, "alias": "claim_type", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','claim_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"claim_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing claim types.", "columns": {"claim_type": {"name": "claim_type", "description": "The type of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','claim_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "claim_type", "tags": ["terminology", "data_profiling"], "column_types": {"claim_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.200486, "relation_name": "cms_synthetic.terminology.claim_type", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__hcpcs_level_2": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__hcpcs_level_2", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__hcpcs_level_2.csv", "original_file_path": "seeds/terminology/terminology__hcpcs_level_2.csv", "unique_id": "seed.the_tuva_project.terminology__hcpcs_level_2", "fqn": ["the_tuva_project", "terminology", "terminology__hcpcs_level_2"], "alias": "hcpcs_level_2", "checksum": {"name": "sha256", "checksum": "7c204c5d21b38f16be4dfdea1167634ccb992fac1b91699e94fc4180dd902d09"}, "config": {"enabled": true, "alias": "hcpcs_level_2", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','hcpcs_level_2.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs": "varchar(256)", "seqnum": "varchar(256)", "recid": "varchar(256)", "long_description": "varchar(2000)", "short_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing HCPCS Level II codes and descriptions.", "columns": {"hcpcs": {"name": "hcpcs", "description": "The HCPCS Level II code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "seqnum": {"name": "seqnum", "description": "The sequence number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recid": {"name": "recid", "description": "The record identifier.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the HCPCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the HCPCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','hcpcs_level_2.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "hcpcs_level_2", "tags": "terminology", "column_types": {"hcpcs": "varchar(256)", "seqnum": "varchar(256)", "recid": "varchar(256)", "long_description": "varchar(2000)", "short_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.221332, "relation_name": "cms_synthetic.terminology.hcpcs_level_2", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ndc": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__ndc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__ndc.csv", "original_file_path": "seeds/terminology/terminology__ndc.csv", "unique_id": "seed.the_tuva_project.terminology__ndc", "fqn": ["the_tuva_project", "terminology", "terminology__ndc"], "alias": "ndc", "checksum": {"name": "sha256", "checksum": "d53a75e4c3a87004c8cb4b4bf2368eada76e2ce9e60ad2d330420327d8fd30f2"}, "config": {"enabled": true, "alias": "ndc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ndc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ndc": "varchar(256)", "rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "fda_description": "varchar(3000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "This file collects all NDCs collected by the FDA and RxNorm, and compiles them into one list. The file is maintained by [CodeRX](https://coderx.io/) in partnership with Tuva Health.", "columns": {"ndc": {"name": "ndc", "description": "The National Drug Code (NDC).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxcui": {"name": "rxcui", "description": "The RxCUI identifier associated with the NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "The description of the RxNorm concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fda_description": {"name": "fda_description", "description": "The FDA description of the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ndc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ndc", "tags": ["terminology"], "column_types": {"ndc": "varchar(256)", "rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "fda_description": "varchar(3000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.303178, "relation_name": "cms_synthetic.terminology.ndc", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__encounter_type": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__encounter_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__encounter_type.csv", "original_file_path": "seeds/terminology/terminology__encounter_type.csv", "unique_id": "seed.the_tuva_project.terminology__encounter_type", "fqn": ["the_tuva_project", "terminology", "terminology__encounter_type"], "alias": "encounter_type", "checksum": {"name": "sha256", "checksum": "a8d2626a7aa8401d6b2c32eed1226abd92f4e3967986c9ba66006e68cfbd927d"}, "config": {"enabled": true, "alias": "encounter_type", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','encounter_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"encounter_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing"], "description": "Seed containing Tuva maintained encounter types.", "columns": {"encounter_type": {"name": "encounter_type", "description": "The type of the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','encounter_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "encounter_type", "tags": ["terminology", "claims_preprocessing"], "column_types": {"encounter_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.207243, "relation_name": "cms_synthetic.terminology.encounter_type", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__snomed_ct": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__snomed_ct", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__snomed_ct.csv", "original_file_path": "seeds/terminology/terminology__snomed_ct.csv", "unique_id": "seed.the_tuva_project.terminology__snomed_ct", "fqn": ["the_tuva_project", "terminology", "terminology__snomed_ct"], "alias": "snomed_ct", "checksum": {"name": "sha256", "checksum": "b43378e55ac19ee1113d5b863784f7c8f5c5198d129d37c860bc43d311b5e00f"}, "config": {"enabled": true, "alias": "snomed_ct", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_ct.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"snomed_ct": "varchar(256)", "description": "varchar(256)", "is_active": "varchar(256)", "created": "date", "last_updated": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing SNOMED CT codes and descriptions.", "columns": {"snomed_ct": {"name": "snomed_ct", "description": "The SNOMED CT code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "The description of the SNOMED CT code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_active": {"name": "is_active", "description": "Indicates if the SNOMED CT code is active.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "created": {"name": "created", "description": "The date when the SNOMED CT code was created.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_updated": {"name": "last_updated", "description": "The date when the SNOMED CT code was last updated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_ct.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "snomed_ct", "tags": ["terminology"], "column_types": {"snomed_ct": "varchar(256)", "description": "varchar(256)", "is_active": "varchar(256)", "created": "date", "last_updated": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.3680599, "relation_name": "cms_synthetic.terminology.snomed_ct", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__provider": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__provider", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__provider.csv", "original_file_path": "seeds/terminology/terminology__provider.csv", "unique_id": "seed.the_tuva_project.terminology__provider", "fqn": ["the_tuva_project", "terminology", "terminology__provider"], "alias": "provider", "checksum": {"name": "sha256", "checksum": "f88950a046cf237eda0f4b60cd8284961c4b9c59742960a8e63f7305fe89ed05"}, "config": {"enabled": true, "alias": "provider", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.1','provider.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"npi": "varchar(35)", "entity_type_code": "varchar(26)", "entity_type_description": "varchar(37)", "primary_taxonomy_code": "varchar(35)", "primary_specialty_description": "varchar(173)", "provider_first_name": "varchar(95)", "provider_last_name": "varchar(95)", "provider_organization_name": "varchar(95)", "parent_organization_name": "varchar(95)", "practice_address_line_1": "varchar(80)", "practice_address_line_2": "varchar(80)", "practice_city": "varchar(65)", "practice_state": "varchar(65)", "practice_zip_code": "varchar(42)", "last_updated": "date", "deactivation_date": "date", "deactivation_flag": "varchar(80)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing"], "description": "Seed containing provider information.", "columns": {"npi": {"name": "npi", "description": "The National Provider Identifier (NPI).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "entity_type_code": {"name": "entity_type_code", "description": "The entity type code of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "entity_type_description": {"name": "entity_type_description", "description": "The entity type description of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_taxonomy_code": {"name": "primary_taxonomy_code", "description": "The primary taxonomy code of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_specialty_description": {"name": "primary_specialty_description", "description": "The primary specialty description of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_organization_name": {"name": "provider_organization_name", "description": "The organization name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_organization_name": {"name": "parent_organization_name", "description": "The parent organization name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_address_line_1": {"name": "practice_address_line_1", "description": "The first line of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_address_line_2": {"name": "practice_address_line_2", "description": "The second line of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_city": {"name": "practice_city", "description": "The city of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_state": {"name": "practice_state", "description": "The state of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_zip_code": {"name": "practice_zip_code", "description": "The ZIP code of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_updated": {"name": "last_updated", "description": "The date when the provider information was last updated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deactivation_date": {"name": "deactivation_date", "description": "The date when the provider was deactivated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deactivation_flag": {"name": "deactivation_flag", "description": "Flag indicating if the provider is deactivated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.1','provider.csv',compression=true,null_marker=true) }}", "schema": "terminology", "tags": ["terminology", "claims_preprocessing"], "alias": "provider", "column_types": {"npi": "varchar(35)", "entity_type_code": "varchar(26)", "entity_type_description": "varchar(37)", "primary_taxonomy_code": "varchar(35)", "primary_specialty_description": "varchar(173)", "provider_first_name": "varchar(95)", "provider_last_name": "varchar(95)", "provider_organization_name": "varchar(95)", "parent_organization_name": "varchar(95)", "practice_address_line_1": "varchar(80)", "practice_address_line_2": "varchar(80)", "practice_city": "varchar(65)", "practice_state": "varchar(65)", "practice_zip_code": "varchar(42)", "last_updated": "date", "deactivation_date": "date", "deactivation_flag": "varchar(80)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.332486, "relation_name": "cms_synthetic.terminology.provider", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__payer_type": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__payer_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__payer_type.csv", "original_file_path": "seeds/terminology/terminology__payer_type.csv", "unique_id": "seed.the_tuva_project.terminology__payer_type", "fqn": ["the_tuva_project", "terminology", "terminology__payer_type"], "alias": "payer_type", "checksum": {"name": "sha256", "checksum": "282a78d9af16774f2afddfd20b98c6b5cb9fedb632a5dea1a887f0e15bafade0"}, "config": {"enabled": true, "alias": "payer_type", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','payer_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"payer_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing payer types.", "columns": {"payer_type": {"name": "payer_type", "description": "The type of payer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','payer_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "payer_type", "tags": ["terminology", "data_profiling"], "column_types": {"payer_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.311517, "relation_name": "cms_synthetic.terminology.payer_type", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ms_drg_weights_los": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__ms_drg_weights_los", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__ms_drg_weights_los.csv", "original_file_path": "seeds/terminology/terminology__ms_drg_weights_los.csv", "unique_id": "seed.the_tuva_project.terminology__ms_drg_weights_los", "fqn": ["the_tuva_project", "terminology", "terminology__ms_drg_weights_los"], "alias": "ms_drg_weights_los", "checksum": {"name": "sha256", "checksum": "599ee0b04a743ea1ab18f6f6bb6ee78bd767beef01aad6bcf872ef367520bc51"}, "config": {"enabled": true, "alias": "ms_drg_weights_los", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ms_drg_weights_los.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ms_drg": "varchar(256)", "fy_2024_final_post_acute_drg": "varchar(256)", "fy_2024_final_special_pay_drg": "varchar(256)", "mdc": "varchar(256)", "type": "varchar(256)", "ms_drg_title": "varchar(256)", "drg_weight_raw": "numeric(18,4)", "drg_weight": "numeric(18,4)", "geometric_mean_los": "numeric(18,2)", "arithmetic_mean_los": "numeric(18,2)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "description": "Seed containing Medicare Severity Diagnosis Related Groups (MS-DRG) weights and benchmark length of stay values from CMS.", "columns": {"ms_drg": {"name": "ms_drg", "description": "The Medicare Severity Diagnosis Related Group (MS-DRG) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fy_2024_final_post_acute_drg": {"name": "fy_2024_final_post_acute_drg", "description": "Indicates if this is a FY 2024 final post-acute DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fy_2024_final_special_pay_drg": {"name": "fy_2024_final_special_pay_drg", "description": "Indicates if this is a FY 2024 final special pay DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc": {"name": "mdc", "description": "The Major Diagnostic Category (MDC) code associated with the MS-DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "type": {"name": "type", "description": "The type of the DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_title": {"name": "ms_drg_title", "description": "The title of the Medicare Severity Diagnosis Related Group (MS-DRG).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drg_weight_raw": {"name": "drg_weight_raw", "description": "The raw DRG weight.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drg_weight": {"name": "drg_weight", "description": "The adjusted DRG weight.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "geometric_mean_los": {"name": "geometric_mean_los", "description": "The geometric mean length of stay for this DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "arithmetic_mean_los": {"name": "arithmetic_mean_los", "description": "The arithmetic mean length of stay for this DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ms_drg_weights_los.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ms_drg_weights_los", "tags": ["terminology", "data_profiling", "claims_preprocessing"], "column_types": {"ms_drg": "varchar(256)", "fy_2024_final_post_acute_drg": "varchar(256)", "fy_2024_final_special_pay_drg": "varchar(256)", "mdc": "varchar(256)", "type": "varchar(256)", "ms_drg_title": "varchar(256)", "drg_weight_raw": "numeric(18,4)", "drg_weight": "numeric(18,4)", "geometric_mean_los": "numeric(18,2)", "arithmetic_mean_los": "numeric(18,2)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.293972, "relation_name": "cms_synthetic.terminology.ms_drg_weights_los", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__apr_drg": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__apr_drg", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__apr_drg.csv", "original_file_path": "seeds/terminology/terminology__apr_drg.csv", "unique_id": "seed.the_tuva_project.terminology__apr_drg", "fqn": ["the_tuva_project", "terminology", "terminology__apr_drg"], "alias": "apr_drg", "checksum": {"name": "sha256", "checksum": "09eb60b322cc83936cee0e221fdb694a6ab8e3dd8016c275885e126b58cb55b6"}, "config": {"enabled": true, "alias": "apr_drg", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','apr_drg.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"apr_drg_code": "varchar(256)", "medical_surgical": "varchar(256)", "mdc_code": "varchar(256)", "apr_drg_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing All Patient Refined Diagnosis Related Groups (APR-DRG) codes and descriptions.", "columns": {"apr_drg_code": {"name": "apr_drg_code", "description": "The All Patient Refined Diagnosis Related Group (APR-DRG) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "Indicates whether the DRG is medical or surgical.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc_code": {"name": "mdc_code", "description": "The Major Diagnostic Category (MDC) code associated with the APR-DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "The description of the All Patient Refined Diagnosis Related Group (APR-DRG).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','apr_drg.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "apr_drg", "tags": ["terminology", "data_profiling"], "column_types": {"apr_drg_code": "varchar(256)", "medical_surgical": "varchar(256)", "mdc_code": "varchar(256)", "apr_drg_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.19287, "relation_name": "cms_synthetic.terminology.apr_drg", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_10_pcs": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__icd_10_pcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__icd_10_pcs.csv", "original_file_path": "seeds/terminology/terminology__icd_10_pcs.csv", "unique_id": "seed.the_tuva_project.terminology__icd_10_pcs", "fqn": ["the_tuva_project", "terminology", "terminology__icd_10_pcs"], "alias": "icd_10_pcs", "checksum": {"name": "sha256", "checksum": "1d18cafa0d405e60cd1be1e039fbfb2dfa9591a1cef6a441b60c26a61de41ad3"}, "config": {"enabled": true, "alias": "icd_10_pcs", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_10_pcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions"], "description": "Seed containing ICD-10-PCS codes and descriptions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "The ICD-10-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "The description of the ICD-10-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','icd_10_pcs.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_10_pcs", "tags": ["terminology", "claims_preprocessing", "readmissions"], "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.25021, "relation_name": "cms_synthetic.terminology.icd_10_pcs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__nitos": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__nitos", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__nitos.csv", "original_file_path": "seeds/terminology/terminology__nitos.csv", "unique_id": "seed.the_tuva_project.terminology__nitos", "fqn": ["the_tuva_project", "terminology", "terminology__nitos"], "alias": "nitos", "checksum": {"name": "sha256", "checksum": "91f2354f390ee9ee2c22d71c7303028fdde8f0ed38d9899f15e61bb285b3f91b"}, "config": {"enabled": true, "alias": "nitos", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','nitos.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs_code": "varchar(5)", "nitos_code": "varchar(5)", "nitos_description": "varchar(1000)", "invasive_non_invasive_flag": "varchar(50)", "modality": "varchar(50)", "body_region": "varchar(50)", "focus_area": "varchar(50)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','nitos.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "nitos", "tags": ["terminology"], "column_types": {"hcpcs_code": "varchar(5)", "nitos_code": "varchar(5)", "nitos_description": "varchar(1000)", "invasive_non_invasive_flag": "varchar(50)", "modality": "varchar(50)", "body_region": "varchar(50)", "focus_area": "varchar(50)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.390173, "relation_name": "cms_synthetic.terminology.nitos", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__medicare_dual_eligibility": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__medicare_dual_eligibility", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__medicare_dual_eligibility.csv", "original_file_path": "seeds/terminology/terminology__medicare_dual_eligibility.csv", "unique_id": "seed.the_tuva_project.terminology__medicare_dual_eligibility", "fqn": ["the_tuva_project", "terminology", "terminology__medicare_dual_eligibility"], "alias": "medicare_dual_eligibility", "checksum": {"name": "sha256", "checksum": "520243cb81b0f298c80fe446ea6c3d7b5f78d66d8caa6594e028073045210091"}, "config": {"enabled": true, "alias": "medicare_dual_eligibility", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_dual_eligibility.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"dual_status_code": "varchar(256)", "dual_status_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing Medicare dual eligibility status codes and descriptions.", "columns": {"dual_status_code": {"name": "dual_status_code", "description": "The code representing dual eligibility status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_description": {"name": "dual_status_description", "description": "A description of the dual eligibility status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','medicare_dual_eligibility.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "medicare_dual_eligibility", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"dual_status_code": "varchar(256)", "dual_status_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.276479, "relation_name": "cms_synthetic.terminology.medicare_dual_eligibility", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__bill_type": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__bill_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__bill_type.csv", "original_file_path": "seeds/terminology/terminology__bill_type.csv", "unique_id": "seed.the_tuva_project.terminology__bill_type", "fqn": ["the_tuva_project", "terminology", "terminology__bill_type"], "alias": "bill_type", "checksum": {"name": "sha256", "checksum": "398d806848f4a65fafccb3c4ad84b18f90ca269945d0121c4b81fe1b923d1627"}, "config": {"enabled": true, "alias": "bill_type", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','bill_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"bill_type_code": "varchar(256)", "bill_type_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing NUBC billing types and descriptions.", "columns": {"bill_type_code": {"name": "bill_type_code", "description": "The code representing the type of bill.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_description": {"name": "bill_type_description", "description": "A description of the billing type.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated": {"name": "deprecated", "description": "Indicates if the billing type is deprecated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated_date": {"name": "deprecated_date", "description": "The date when the billing type code was deprecated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','bill_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "bill_type", "tags": ["terminology", "data_profiling"], "column_types": {"bill_type_code": "varchar(256)", "bill_type_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.197258, "relation_name": "cms_synthetic.terminology.bill_type", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__loinc": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__loinc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__loinc.csv", "original_file_path": "seeds/terminology/terminology__loinc.csv", "unique_id": "seed.the_tuva_project.terminology__loinc", "fqn": ["the_tuva_project", "terminology", "terminology__loinc"], "alias": "loinc", "checksum": {"name": "sha256", "checksum": "374101e8b4e4fd5038c5bcae0dca2e5fcf2992883068619e2cbadad7ea3a8e7b"}, "config": {"enabled": true, "alias": "loinc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','loinc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"loinc": "varchar(256)", "short_name": "varchar(256)", "long_common_name": "varchar(256)", "component": "varchar(256)", "property": "varchar(256)", "time_aspect": "varchar(256)", "system": "varchar(256)", "scale_type": "varchar(256)", "method_type": "varchar(256)", "class_code": "varchar(256)", "class_description": "varchar(256)", "class_type_code": "varchar(256)", "class_type_description": "varchar(256)", "external_copyright_notice": "varchar(3000)", "status": "varchar(256)", "version_first_released": "varchar(256)", "version_last_changed": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing LOINC codes and descriptions.", "columns": {"loinc": {"name": "loinc", "description": "The LOINC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_name": {"name": "short_name", "description": "If exists, the short human-readable version of the LOINC description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_common_name": {"name": "long_common_name", "description": "Clinician-friendly full LOINC description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "component": {"name": "component", "description": "The substance or entity being measured or observed. Also called the Analyte. The first of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "property": {"name": "property", "description": "The characteristic or attribute of the analyte. The second of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "time_aspect": {"name": "time_aspect", "description": "The interval of time over which an observation was made. The third of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "system": {"name": "system", "description": "The thing upon which the observation was made. Also called specimen for laboratory tests. The fourth of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "scale_type": {"name": "scale_type", "description": "How the observation value is quantified or expressed (e.g. quantitative, ordinal, nominal, etc.). The fifth of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "method_type": {"name": "method_type", "description": "A high-level classification of how the observation was made. Optional; only needed when the technique affects the clinical interpretation of the results. The sixth of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_code": {"name": "class_code", "description": "A code representing the general category of the LOINC term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_description": {"name": "class_description", "description": "The general category of the LOINC term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_type_code": {"name": "class_type_code", "description": "A code representing the top-level category for the test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_type_description": {"name": "class_type_description", "description": "The top-level category for the test; Laboratory, Clinical, Claims attachments, or Surveys.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "external_copyright_notice": {"name": "external_copyright_notice", "description": "External copyright holder's copyright notice for this LOINC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "The status of the LOINC code concept. Active, Trial (experimental), Discouraged (not recommended), or Deprecated (should not be used).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "version_first_released": {"name": "version_first_released", "description": "The first release version of LOINC that included this code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "version_last_changed": {"name": "version_last_changed", "description": "The last LOINC version in which this record was changed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','loinc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "loinc", "tags": ["terminology"], "column_types": {"loinc": "varchar(256)", "short_name": "varchar(256)", "long_common_name": "varchar(256)", "component": "varchar(256)", "property": "varchar(256)", "time_aspect": "varchar(256)", "system": "varchar(256)", "scale_type": "varchar(256)", "method_type": "varchar(256)", "class_code": "varchar(256)", "class_description": "varchar(256)", "class_type_code": "varchar(256)", "class_type_description": "varchar(256)", "external_copyright_notice": "varchar(3000)", "status": "varchar(256)", "version_first_released": "varchar(256)", "version_last_changed": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.262657, "relation_name": "cms_synthetic.terminology.loinc", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__snomed_icd_10_map": {"database": "cms_synthetic", "schema": "terminology", "name": "terminology__snomed_icd_10_map", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology/terminology__snomed_icd_10_map.csv", "original_file_path": "seeds/terminology/terminology__snomed_icd_10_map.csv", "unique_id": "seed.the_tuva_project.terminology__snomed_icd_10_map", "fqn": ["the_tuva_project", "terminology", "terminology__snomed_icd_10_map"], "alias": "snomed_icd_10_map", "checksum": {"name": "sha256", "checksum": "a9e5ce05b4fe9149571f87cfe6a77ef63f0f697da4f7e31a537bdc83927ee593"}, "config": {"enabled": true, "alias": "snomed_icd_10_map", "schema": "terminology", "database": null, "tags": ["terminology", "hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_icd_10_map.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"id": "varchar(256)", "effective_time": "varchar(256)", "active": "varchar(256)", "module_id": "varchar(256)", "ref_set_id": "varchar(256)", "referenced_component_id": "varchar(256)", "referenced_component_name": "varchar(256)", "map_group": "varchar(256)", "map_priority": "varchar(256)", "map_rule": "varchar(500)", "map_advice": "varchar(500)", "map_target": "varchar(256)", "map_target_name": "varchar(256)", "correlation_id": "varchar(256)", "map_category_id": "varchar(256)", "map_category_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "hcc_suspecting"], "description": "Seed containing mappings between SNOMED CT and ICD-10 codes.", "columns": {"id": {"name": "id", "description": "The unique identifier for the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "effective_time": {"name": "effective_time", "description": "The effective time of the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "active": {"name": "active", "description": "Indicates if the mapping is active.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "module_id": {"name": "module_id", "description": "The module ID associated with the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ref_set_id": {"name": "ref_set_id", "description": "The reference set ID associated with the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "referenced_component_id": {"name": "referenced_component_id", "description": "The referenced component ID.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "referenced_component_name": {"name": "referenced_component_name", "description": "The name of the referenced component.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_group": {"name": "map_group", "description": "The map group.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_priority": {"name": "map_priority", "description": "The map priority.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_rule": {"name": "map_rule", "description": "The map rule.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_advice": {"name": "map_advice", "description": "Advice related to the map.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_target": {"name": "map_target", "description": "The map target.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_target_name": {"name": "map_target_name", "description": "The name of the map target.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "correlation_id": {"name": "correlation_id", "description": "The correlation ID associated with the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_category_id": {"name": "map_category_id", "description": "The map category ID.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_category_name": {"name": "map_category_name", "description": "The name of the map category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/terminology/terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','snomed_icd_10_map.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "snomed_icd_10_map", "tags": ["terminology", "hcc_suspecting"], "column_types": {"id": "varchar(256)", "effective_time": "varchar(256)", "active": "varchar(256)", "module_id": "varchar(256)", "ref_set_id": "varchar(256)", "referenced_component_id": "varchar(256)", "referenced_component_name": "varchar(256)", "map_group": "varchar(256)", "map_priority": "varchar(256)", "map_rule": "varchar(500)", "map_advice": "varchar(500)", "map_target": "varchar(256)", "map_target_name": "varchar(256)", "correlation_id": "varchar(256)", "map_category_id": "varchar(256)", "map_category_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.363615, "relation_name": "cms_synthetic.terminology.snomed_icd_10_map", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.clinical_concept_library__value_set_members": {"database": "cms_synthetic", "schema": "clinical_concept_library", "name": "clinical_concept_library__value_set_members", "resource_type": "seed", "package_name": "the_tuva_project", "path": "clinical_concept_library/clinical_concept_library__value_set_members.csv", "original_file_path": "seeds/clinical_concept_library/clinical_concept_library__value_set_members.csv", "unique_id": "seed.the_tuva_project.clinical_concept_library__value_set_members", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__value_set_members"], "alias": "value_set_members", "checksum": {"name": "sha256", "checksum": "066f2f31496a1d94f83040789f89b512753bda8edc902a24a183ddadfcc305df"}, "config": {"enabled": true, "alias": "value_set_members", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_value_set_members.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"value_set_member_id": "varchar(256)", "concept_id": "varchar(256)", "status": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "code": "varchar(256)", "code_description": "varchar(2000)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)", "include_descendants": "varchar(256)", "comment": "varchar(2000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["clinical_concept_library"], "description": "", "columns": {"value_set_member_id": {"name": "value_set_member_id", "description": "Primary key for the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_id": {"name": "concept_id", "description": "Foreign key to concept table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of this individual value_set_members record. Options = \u201cactive\u201d and \u201cinactive\u201d, others to be added as needed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_date": {"name": "last_update_date", "description": "Date of last update of this row, formatted as YYYY-MM-DD.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_note": {"name": "last_update_note", "description": "Relevant details regarding the nature and reasons for the most recent update.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Standardized code that is a member of the value set for the concept referenced in concept_id", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "Description for the code in the \"code\" column.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_id": {"name": "coding_system_id", "description": "Coding system ID for code in the \"code\" column. Foreign key to coding_systems", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_version": {"name": "coding_system_version", "description": "Version of the coding system used. For now, editorial conventions and/or business logic will be required to establish a consistent format for coding version for each coding system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "include_descendants": {"name": "include_descendants", "description": "Indicates whether the value set should include descendants of the specified code. If \u201ctrue\u201d, include the specified code and all of its descendants. If \u201cfalse\u201d, include only the specified code. Applies only to coding systems for which Tuva has implemented this feature.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "comment": {"name": "comment", "description": "In some cases it may be helpful to provide some explanatory context for inclusion of a particular code, e.g., insights into the intended meaning of the code that aren\u2019t implicit in the code description but are implied by other aspects of the coding system e.g., ICD-10-CM coding guidance.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/clinical_concept_library/clinical_concept_library_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_value_set_members.csv',compression=true,null_marker=true) }}", "schema": "clinical_concept_library", "alias": "value_set_members", "tags": "clinical_concept_library", "column_types": {"value_set_member_id": "varchar(256)", "concept_id": "varchar(256)", "status": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "code": "varchar(256)", "code_description": "varchar(2000)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)", "include_descendants": "varchar(256)", "comment": "varchar(2000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.409638, "relation_name": "cms_synthetic.clinical_concept_library.value_set_members", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.clinical_concept_library__coding_systems": {"database": "cms_synthetic", "schema": "clinical_concept_library", "name": "clinical_concept_library__coding_systems", "resource_type": "seed", "package_name": "the_tuva_project", "path": "clinical_concept_library/clinical_concept_library__coding_systems.csv", "original_file_path": "seeds/clinical_concept_library/clinical_concept_library__coding_systems.csv", "unique_id": "seed.the_tuva_project.clinical_concept_library__coding_systems", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__coding_systems"], "alias": "coding_systems", "checksum": {"name": "sha256", "checksum": "2468b8aad4f2ee3fe8043f55d2cfde2203aefb7fa7d959b9e63d138361bdafae"}, "config": {"enabled": true, "alias": "coding_systems", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_coding_systems.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"coding_system_id": "varchar(256)", "coding_system_name": "varchar(256)", "coding_system_uri": "varchar(256)", "coding_system_oid": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["clinical_concept_library"], "description": "", "columns": {"coding_system_id": {"name": "coding_system_id", "description": "Primary key for the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_name": {"name": "coding_system_name", "description": "Name of the coding system, e.g. \u201cSNOMED CT US Edition\u201d", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_uri": {"name": "coding_system_uri", "description": "URI as used in FHIR to represent coding system. This provides an unambiguous identifier for the coding system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_oid": {"name": "coding_system_oid", "description": "OID for the coding system. This provides another unambiguous identifier for the coding system (along with uri).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/clinical_concept_library/clinical_concept_library_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_coding_systems.csv',compression=true,null_marker=true) }}", "schema": "clinical_concept_library", "alias": "coding_systems", "tags": "clinical_concept_library", "column_types": {"coding_system_id": "varchar(256)", "coding_system_name": "varchar(256)", "coding_system_uri": "varchar(256)", "coding_system_oid": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.4149241, "relation_name": "cms_synthetic.clinical_concept_library.coding_systems", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.clinical_concept_library__clinical_concepts": {"database": "cms_synthetic", "schema": "clinical_concept_library", "name": "clinical_concept_library__clinical_concepts", "resource_type": "seed", "package_name": "the_tuva_project", "path": "clinical_concept_library/clinical_concept_library__clinical_concepts.csv", "original_file_path": "seeds/clinical_concept_library/clinical_concept_library__clinical_concepts.csv", "unique_id": "seed.the_tuva_project.clinical_concept_library__clinical_concepts", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__clinical_concepts"], "alias": "clinical_concepts", "checksum": {"name": "sha256", "checksum": "28904352227711d78b2ffd3f5b674269b3f16f92e5eba2a8f83b8749500ea30d"}, "config": {"enabled": true, "alias": "clinical_concepts", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_clinical_concepts.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_id": "varchar(256)", "concept_name": "varchar(256)", "status": "varchar(256)", "concept_oid": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "concept_type": "varchar(256)", "content_source": "varchar(3000)", "external_source_detail": "varchar(3000)", "concept_scope": "varchar(3000)", "value_set_search_notes": "varchar(3000)", "code": "varchar(256)", "code_description": "varchar(256)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["clinical_concept_library"], "description": "", "columns": {"concept_id": {"name": "concept_id", "description": "Primary key for the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_name": {"name": "concept_name", "description": "Human-readable term for the concept. Should include spaces as needed, and casing per titlecase conventions, e.g. \u201cMyocardial Infarction\u201d.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of this concept and the completeness of the links to value_set_members. Values include \u201cin progress\u201d, \u201cready for review\u201d, \u201creviewed\u201d, \u201cinactive\u201d, others to be added as needed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID for the concept; Added since some clinical concepts used in standardized quality measures have OIDs.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_date": {"name": "last_update_date", "description": "Date of last update of this row (formatted as YYYY-MM-DD) and/or addition, removal, or changes to any of its linked value_set_members rows.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_note": {"name": "last_update_note", "description": "Relevant details regarding the nature and reasons for the most recent update.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_type": {"name": "concept_type", "description": "Clinical type of the concept. Potential values: \u201ccondition\u201d, \u201ctherapy\u201d, \u201cdiagnostic test\u201d, others TBD.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "content_source": {"name": "content_source", "description": "Indicates whether the clinical concept definition and associated value set content was developed by Tuva or from some other public source. Values will be \u201cTuva-developed\u201d or \u201cexternal\u201d.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "external_source_detail": {"name": "external_source_detail", "description": "For concepts for which the definition and associated value set content was not developed by Tuva, this provides details on the source of the concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_scope": {"name": "concept_scope", "description": "Narrative text that defines the semantic scope of the clinical concept, including specific inclusions and exclusions, to ensure consistency in value set construction and clarity in use. May be up to several paragraphs in length.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "value_set_search_notes": {"name": "value_set_search_notes", "description": "Narrative text that describes the approach taken for identifying candidate codes for human review. May include text search terms, code ranges or hierarchical assertions. Will facilitate consistency when periodic value set maintenance is performed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Standardized code that represents the concept, to facilitate searching for clinical concepts by standardized code. Not to be confused with value set member codes, this is meant to be synonymous with the concept or, if a synonymous code isn\u2019t available, the closest subsuming code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "Description for the code in concept_coding_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_id": {"name": "coding_system_id", "description": "Coding system for code in concept_coding_code. Foreign key to coding_systems.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_version": {"name": "coding_system_version", "description": "Version of the coding system used. For now, editorial conventions and/or business logic will be required to establish a consistent format for coding version for each coding system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/clinical_concept_library/clinical_concept_library_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_clinical_concepts.csv',compression=true,null_marker=true) }}", "schema": "clinical_concept_library", "alias": "clinical_concepts", "tags": "clinical_concept_library", "column_types": {"concept_id": "varchar(256)", "concept_name": "varchar(256)", "status": "varchar(256)", "concept_oid": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "concept_type": "varchar(256)", "content_source": "varchar(3000)", "external_source_detail": "varchar(3000)", "concept_scope": "varchar(3000)", "value_set_search_notes": "varchar(3000)", "code": "varchar(256)", "code_description": "varchar(256)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.402386, "relation_name": "cms_synthetic.clinical_concept_library.clinical_concepts", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.pharmacy__rxnorm_generic_available": {"database": "cms_synthetic", "schema": "pharmacy", "name": "pharmacy__rxnorm_generic_available", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/pharmacy/pharmacy__rxnorm_generic_available.csv", "original_file_path": "seeds/value_sets/pharmacy/pharmacy__rxnorm_generic_available.csv", "unique_id": "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "fqn": ["the_tuva_project", "value_sets", "pharmacy", "pharmacy__rxnorm_generic_available"], "alias": "rxnorm_generic_available", "checksum": {"name": "sha256", "checksum": "ba766e1c3ca581e309af4aa0ae15b9f2a6bff5fb116280c6d408e949ebde2f04"}, "config": {"enabled": true, "alias": "rxnorm_generic_available", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','rxnorm_generic_available.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"product_tty": "varchar(256)", "product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "ndc_product_tty": "varchar(256)", "ndc_product_rxcui": "varchar(256)", "ndc_product_name": "varchar(3000)", "ndc": "varchar(256)", "product_startmarketingdate": "date", "package_startmarketingdate": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["pharmacy"], "description": "brand rxcuis from rxnorm with some additional columns added in", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/pharmacy/pharmacy__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','rxnorm_generic_available.csv',compression=true,null_marker=true) }}", "schema": "pharmacy", "alias": "rxnorm_generic_available", "tags": ["pharmacy"], "enabled": true, "column_types": {"product_tty": "varchar(256)", "product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "ndc_product_tty": "varchar(256)", "ndc_product_rxcui": "varchar(256)", "ndc_product_name": "varchar(3000)", "ndc": "varchar(256)", "product_startmarketingdate": "date", "package_startmarketingdate": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.4212322, "relation_name": "cms_synthetic.pharmacy.rxnorm_generic_available", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__crosswalk_field_to_mart", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/data_quality/data_quality__crosswalk_field_to_mart.csv", "original_file_path": "seeds/value_sets/data_quality/data_quality__crosswalk_field_to_mart.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_to_mart", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_field_to_mart"], "alias": "_value_set_crosswalk_field_to_mart", "checksum": {"name": "sha256", "checksum": "80e5215c48dc51ea0e4ce834d4006f7649e62cd60b0fcb278d83cfbdc4abacda"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_field_to_mart", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_field_to_mart.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "mart_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Crosswalk table that defines which fields impact the ability for marts to run.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/data_quality/data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_field_to_mart.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_field_to_mart", "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "mart_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.430656, "relation_name": "cms_synthetic.data_quality._value_set_crosswalk_field_to_mart", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__crosswalk_measure_reasonable_ranges", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/data_quality/data_quality__crosswalk_measure_reasonable_ranges.csv", "original_file_path": "seeds/value_sets/data_quality/data_quality__crosswalk_measure_reasonable_ranges.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_measure_reasonable_ranges"], "alias": "_value_set_crosswalk_measure_reasonable_ranges", "checksum": {"name": "sha256", "checksum": "02fafa4757f16c3134b2d5f622eff335102ca1397547eba27d67b6042fba299d"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_measure_reasonable_ranges", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_measure_reasonable_ranges.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"measure_name": "varchar(256)", "payer_type": "varchar(256)", "lower_bound": "float", "upper_bound": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Crosswalk table that sets reasonable ranges for outcome measures\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/data_quality/data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_measure_reasonable_ranges.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_measure_reasonable_ranges", "column_types": {"measure_name": "varchar(256)", "payer_type": "varchar(256)", "lower_bound": "float", "upper_bound": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.4397938, "relation_name": "cms_synthetic.data_quality._value_set_crosswalk_measure_reasonable_ranges", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_field_info": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__crosswalk_field_info", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/data_quality/data_quality__crosswalk_field_info.csv", "original_file_path": "seeds/value_sets/data_quality/data_quality__crosswalk_field_info.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_info", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_field_info"], "alias": "_value_set_crosswalk_field_info", "checksum": {"name": "sha256", "checksum": "49018f7f640ba18033abb593294b72b1ed3a7bf4f648481dbc62316427cf842c"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_field_info", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_field_info.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "red": "integer", "green": "integer", "unique_values_expected_flag": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Target thresholds at the field level determining red, yellow, and green values in the Data Quality dashboard.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/data_quality/data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_field_info.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_field_info", "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "red": "integer", "green": "integer", "unique_values_expected_flag": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.4257689, "relation_name": "cms_synthetic.data_quality._value_set_crosswalk_field_info", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__crosswalk_mart_to_outcome_measure", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/data_quality/data_quality__crosswalk_mart_to_outcome_measure.csv", "original_file_path": "seeds/value_sets/data_quality/data_quality__crosswalk_mart_to_outcome_measure.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_mart_to_outcome_measure"], "alias": "_value_set_crosswalk_mart_to_outcome_measure", "checksum": {"name": "sha256", "checksum": "dc42970571b546b1577e4abe46411e2a3b49b8c30d099b0f2c89adb1c133e45d"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_mart_to_outcome_measure", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_mart_to_outcome_measure.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"mart_name": "varchar(256)", "measure_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Crosswalk table that defines which marts impact which outcome measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/data_quality/data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_crosswalk_mart_to_outcome_measure.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_mart_to_outcome_measure", "column_types": {"mart_name": "varchar(256)", "measure_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.4345999, "relation_name": "cms_synthetic.data_quality._value_set_crosswalk_mart_to_outcome_measure", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__reference_mart_analytics": {"database": "cms_synthetic", "schema": "data_quality", "name": "data_quality__reference_mart_analytics", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/data_quality/data_quality__reference_mart_analytics.csv", "original_file_path": "seeds/value_sets/data_quality/data_quality__reference_mart_analytics.csv", "unique_id": "seed.the_tuva_project.data_quality__reference_mart_analytics", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__reference_mart_analytics"], "alias": "_value_set_reference_mart_analytics", "checksum": {"name": "sha256", "checksum": "a75ae350862f59242b8a5097b4806caa5c1f780e60da7ec7d12701be0393174e"}, "config": {"enabled": true, "alias": "_value_set_reference_mart_analytics", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_reference_mart_analytics.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"analytics_concept": "varchar(256)", "analytics_measure": "varchar(256)", "analytics_value": "varchar(256)", "value_rank": "integer", "payer_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["data_quality_audit"], "description": "reference values for analytics checks from various benchmark sources\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/data_quality/data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','data_quality_reference_mart_analytics.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_reference_mart_analytics", "column_types": {"analytics_concept": "varchar(256)", "analytics_measure": "varchar(256)", "analytics_value": "varchar(256)", "value_rank": "integer", "payer_type": "varchar(256)"}, "tags": ["data_quality_audit"], "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.444876, "relation_name": "cms_synthetic.data_quality._value_set_reference_mart_analytics", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.service_category__service_categories": {"database": "cms_synthetic", "schema": "claims_preprocessing", "name": "service_category__service_categories", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/service_categories/service_category__service_categories.csv", "original_file_path": "seeds/value_sets/service_categories/service_category__service_categories.csv", "unique_id": "seed.the_tuva_project.service_category__service_categories", "fqn": ["the_tuva_project", "value_sets", "service_categories", "service_category__service_categories"], "alias": "service_category__service_categories", "checksum": {"name": "sha256", "checksum": "5a2d78ef839e5da2ad7a3b17c589b6ca58c5a87ec11340daa84ac5a29c89d9d7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','service_category__service_categories.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"service_category_1": "varchar(50)", "service_category_2": "varchar(50)", "service_category_3": "varchar(50)", "priority": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Heirarchy and ranking of Tuva service category logic\n", "columns": {"service_category_1": {"name": "service_category_1", "description": "service category 1 in the Tuva model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_2": {"name": "service_category_2", "description": "service category 2 in the Tuva model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_3": {"name": "service_category_3", "description": "service category 3 in the Tuva model, only populated for a group of the service category 2 values.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "priority": {"name": "priority", "description": "priority ranking of the service categories that will be used if a claim qualifies under multiple logic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/service_categories/service_category__service_categories.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','service_category__service_categories.csv',compression=true,null_marker=true) }}", "schema": "claims_preprocessing", "column_types": {"service_category_1": "varchar(50)", "service_category_2": "varchar(50)", "service_category_3": "varchar(50)", "priority": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.449835, "relation_name": "cms_synthetic.claims_preprocessing.service_category__service_categories", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__johnston_icd9": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__johnston_icd9", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ed_classification/ed_classification__johnston_icd9.csv", "original_file_path": "seeds/value_sets/ed_classification/ed_classification__johnston_icd9.csv", "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd9", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__johnston_icd9"], "alias": "_value_set_johnston_icd9", "checksum": {"name": "sha256", "checksum": "77255f5ce0469f045a941b092e3ec84002afb0d3dabfc3d24acb0cfe29d90829"}, "config": {"enabled": true, "alias": "_value_set_johnston_icd9", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','johnston_icd9.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd9": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "epct": "varchar(256)", "noner": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A probabilistic mapping of ICD-9 codes to ED classification categories", "columns": {"icd9": {"name": "icd9", "description": "ICD-9 code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_9_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnnpa": {"name": "edcnnpa", "description": "ED CNNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnpa": {"name": "edcnpa", "description": "ED CNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "epct": {"name": "epct", "description": "EPCT category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "noner": {"name": "noner", "description": "Non-ER category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "injury": {"name": "injury", "description": "Injury category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "psych": {"name": "psych", "description": "Psych category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alcohol": {"name": "alcohol", "description": "Alcohol category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug": {"name": "drug", "description": "Drug category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ed_classification/ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','johnston_icd9.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_johnston_icd9", "tags": "ed_classification", "enabled": true, "column_types": {"icd9": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "epct": "varchar(256)", "noner": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.469793, "relation_name": "cms_synthetic.ed_classification._value_set_johnston_icd9", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__icd_10_cm_to_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ed_classification/ed_classification__icd_10_cm_to_ccs.csv", "original_file_path": "seeds/value_sets/ed_classification/ed_classification__icd_10_cm_to_ccs.csv", "unique_id": "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__icd_10_cm_to_ccs"], "alias": "_value_set_icd_10_cm_to_ccs", "checksum": {"name": "sha256", "checksum": "0f2119b159a22eeb902b925b2eb98357b33bbc09bae3b7fceb04de71cf041476"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_to_ccs", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A mapping of ICD-10-CM codes to CCS categories", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/ed_classification/ed_classification__categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_description": {"name": "ccs_description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ed_classification/ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_icd_10_cm_to_ccs", "tags": "ed_classification", "enabled": true, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.461341, "relation_name": "cms_synthetic.ed_classification._value_set_icd_10_cm_to_ccs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__johnston_icd10": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__johnston_icd10", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ed_classification/ed_classification__johnston_icd10.csv", "original_file_path": "seeds/value_sets/ed_classification/ed_classification__johnston_icd10.csv", "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd10", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__johnston_icd10"], "alias": "_value_set_johnston_icd10", "checksum": {"name": "sha256", "checksum": "86d77b4087f009aa80ba4a6ea7e1977c1230d6067ef4538b3a5cc0249e65657b"}, "config": {"enabled": true, "alias": "_value_set_johnston_icd10", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','johnston_icd10.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd10": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "noner": "varchar(256)", "epct": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A probabilistic mapping of ICD-10 codes to ED classification categories", "columns": {"icd10": {"name": "icd10", "description": "ICD-10 code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnnpa": {"name": "edcnnpa", "description": "ED CNNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnpa": {"name": "edcnpa", "description": "ED CNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "epct": {"name": "epct", "description": "EPCT category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "noner": {"name": "noner", "description": "Non-ER category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "injury": {"name": "injury", "description": "Injury category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "psych": {"name": "psych", "description": "Psych category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alcohol": {"name": "alcohol", "description": "Alcohol category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug": {"name": "drug", "description": "Drug category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ed_classification/ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','johnston_icd10.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_johnston_icd10", "tags": "ed_classification", "enabled": true, "column_types": {"icd10": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "noner": "varchar(256)", "epct": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.477965, "relation_name": "cms_synthetic.ed_classification._value_set_johnston_icd10", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__categories": {"database": "cms_synthetic", "schema": "ed_classification", "name": "ed_classification__categories", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ed_classification/ed_classification__categories.csv", "original_file_path": "seeds/value_sets/ed_classification/ed_classification__categories.csv", "unique_id": "seed.the_tuva_project.ed_classification__categories", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__categories"], "alias": "_value_set_categories", "checksum": {"name": "sha256", "checksum": "cf0576acd61cdf96595d8efb636ca9fa6812aa88ea934ab70f7cffe1241f4c2f"}, "config": {"enabled": true, "alias": "_value_set_categories", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','ed_classification_categories.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"classification": "varchar(256)", "classification_name": "varchar(256)", "classification_order": "varchar(256)", "classification_column": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A mapping of ED Classifications to human-readable names", "columns": {"classification": {"name": "classification", "description": "ED classification code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "classification_name": {"name": "classification_name", "description": "Human-readable name for the ED classification", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "classification_order": {"name": "classification_order", "description": "Order of the ED classification", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "classification_column": {"name": "classification_column", "description": "Column name for the ED classification", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ed_classification/ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','ed_classification_categories.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_categories", "tags": "ed_classification", "enabled": true, "column_types": {"classification": "varchar(256)", "classification_name": "varchar(256)", "classification_order": "varchar(256)", "classification_column": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.455404, "relation_name": "cms_synthetic.ed_classification._value_set_categories", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__potentially_planned_ccs_procedure_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__potentially_planned_ccs_procedure_category.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__potentially_planned_ccs_procedure_category.csv", "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__potentially_planned_ccs_procedure_category"], "alias": "_value_set_potentially_planned_ccs_procedure_category", "checksum": {"name": "sha256", "checksum": "d46cf571e714e7ddb997c7be419b496c51d9e7ce0342d72be61d06fc0bf55669"}, "config": {"enabled": true, "alias": "_value_set_potentially_planned_ccs_procedure_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','potentially_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Potentially planned CCS procedure categories for readmissions.", "columns": {"ccs_procedure_category": {"name": "ccs_procedure_category", "description": "CCS procedure category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS procedure category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','potentially_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_potentially_planned_ccs_procedure_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.559318, "relation_name": "cms_synthetic.readmissions._value_set_potentially_planned_ccs_procedure_category", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__icd_10_cm_to_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__icd_10_cm_to_ccs.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__icd_10_cm_to_ccs.csv", "unique_id": "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__icd_10_cm_to_ccs"], "alias": "_value_set_icd_10_cm_to_ccs", "checksum": {"name": "sha256", "checksum": "0f2119b159a22eeb902b925b2eb98357b33bbc09bae3b7fceb04de71cf041476"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_to_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Mapping of ICD-10-CM codes to CCS diagnosis categories for readmissions.", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_description": {"name": "ccs_description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_icd_10_cm_to_ccs", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.550346, "relation_name": "cms_synthetic.readmissions._value_set_icd_10_cm_to_ccs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__potentially_planned_icd_10_pcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__potentially_planned_icd_10_pcs.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__potentially_planned_icd_10_pcs.csv", "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__potentially_planned_icd_10_pcs"], "alias": "_value_set_potentially_planned_icd_10_pcs", "checksum": {"name": "sha256", "checksum": "1d18cafa0d405e60cd1be1e039fbfb2dfa9591a1cef6a441b60c26a61de41ad3"}, "config": {"enabled": true, "alias": "_value_set_potentially_planned_icd_10_pcs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','potentially_planned_icd_10_pcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Potentially planned ICD-10-PCS codes for readmissions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','potentially_planned_icd_10_pcs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_potentially_planned_icd_10_pcs", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.563467, "relation_name": "cms_synthetic.readmissions._value_set_potentially_planned_icd_10_pcs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__acute_diagnosis_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv", "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_ccs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__acute_diagnosis_ccs"], "alias": "_value_set_acute_diagnosis_ccs", "checksum": {"name": "sha256", "checksum": "e947ff0e7faffc92d8c129ee41271241fb9e43c5f3249f18403fe20faa9be669"}, "config": {"enabled": true, "alias": "_value_set_acute_diagnosis_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','acute_diagnosis_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Acute diagnosis CCS categories for readmissions.", "columns": {"ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','acute_diagnosis_ccs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_acute_diagnosis_ccs", "tags": "readmissions", "enabled": true, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.52611, "relation_name": "cms_synthetic.readmissions._value_set_acute_diagnosis_ccs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__specialty_cohort": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__specialty_cohort", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__specialty_cohort.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__specialty_cohort.csv", "unique_id": "seed.the_tuva_project.readmissions__specialty_cohort", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__specialty_cohort"], "alias": "_value_set_specialty_cohort", "checksum": {"name": "sha256", "checksum": "c1d715929a890fd44e1d5ad4aa89785523f221ce8f5ae8765c11a0e524426a45"}, "config": {"enabled": true, "alias": "_value_set_specialty_cohort", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','specialty_cohort.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs": "varchar(256)", "description": "varchar(256)", "specialty_cohort": "varchar(256)", "procedure_or_diagnosis": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Specialty cohorts for readmissions.", "columns": {"ccs": {"name": "ccs", "description": "CCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_or_diagnosis": {"name": "procedure_or_diagnosis", "description": "Indicates whether it is a procedure or diagnosis", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','specialty_cohort.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_specialty_cohort", "tags": "readmissions", "enabled": true, "column_types": {"ccs": "varchar(256)", "description": "varchar(256)", "specialty_cohort": "varchar(256)", "procedure_or_diagnosis": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.568796, "relation_name": "cms_synthetic.readmissions._value_set_specialty_cohort", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__exclusion_ccs_diagnosis_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__exclusion_ccs_diagnosis_category.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__exclusion_ccs_diagnosis_category.csv", "unique_id": "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__exclusion_ccs_diagnosis_category"], "alias": "_value_set_exclusion_ccs_diagnosis_category", "checksum": {"name": "sha256", "checksum": "ed6c92b04b1d9b79a34ed80022e4192f2394510f57fd0b4121a8e31a30198d70"}, "config": {"enabled": true, "alias": "_value_set_exclusion_ccs_diagnosis_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','exclusion_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)", "exclusion_category": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Exclusion CCS diagnosis categories for readmissions.", "columns": {"ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_category": {"name": "exclusion_category", "description": "Exclusion category for the CCS diagnosis", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','exclusion_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_exclusion_ccs_diagnosis_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)", "exclusion_category": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.545419, "relation_name": "cms_synthetic.readmissions._value_set_exclusion_ccs_diagnosis_category", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__acute_diagnosis_icd_10_cm", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__acute_diagnosis_icd_10_cm.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__acute_diagnosis_icd_10_cm.csv", "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__acute_diagnosis_icd_10_cm"], "alias": "_value_set_acute_diagnosis_icd_10_cm", "checksum": {"name": "sha256", "checksum": "08903dd5b951cfdd2dc1e2d92406571ab08c2fa401c2f951a6190b38af1dbf61"}, "config": {"enabled": true, "alias": "_value_set_acute_diagnosis_icd_10_cm", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','acute_diagnosis_icd_10_cm.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Acute diagnosis ICD-10-CM codes for readmissions.", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','acute_diagnosis_icd_10_cm.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_acute_diagnosis_icd_10_cm", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.530617, "relation_name": "cms_synthetic.readmissions._value_set_acute_diagnosis_icd_10_cm", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__surgery_gynecology_cohort", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__surgery_gynecology_cohort.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__surgery_gynecology_cohort.csv", "unique_id": "seed.the_tuva_project.readmissions__surgery_gynecology_cohort", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__surgery_gynecology_cohort"], "alias": "_value_set_surgery_gynecology_cohort", "checksum": {"name": "sha256", "checksum": "ba95843249cbc3167b4887251bf4efbecb2418fe086791e2c428d5748b0e4167"}, "config": {"enabled": true, "alias": "_value_set_surgery_gynecology_cohort", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','surgery_gynecology_cohort.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_code_and_description": "varchar(256)", "specialty_cohort": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Surgery and gynecology cohort for readmissions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_code_and_description": {"name": "ccs_code_and_description", "description": "CCS code and description", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','surgery_gynecology_cohort.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_surgery_gynecology_cohort", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_code_and_description": "varchar(256)", "specialty_cohort": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.574846, "relation_name": "cms_synthetic.readmissions._value_set_surgery_gynecology_cohort", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__always_planned_ccs_procedure_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__always_planned_ccs_procedure_category.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__always_planned_ccs_procedure_category.csv", "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__always_planned_ccs_procedure_category"], "alias": "_value_set_always_planned_ccs_procedure_category", "checksum": {"name": "sha256", "checksum": "cfb84522da7baa39ff06dd37fbab4677b01ef87969039775a9708f70353a99b3"}, "config": {"enabled": true, "alias": "_value_set_always_planned_ccs_procedure_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','always_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Always planned CCS procedure categories for readmissions.", "columns": {"ccs_procedure_category": {"name": "ccs_procedure_category", "description": "CCS procedure category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS procedure category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','always_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_always_planned_ccs_procedure_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.54043, "relation_name": "cms_synthetic.readmissions._value_set_always_planned_ccs_procedure_category", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__icd_10_pcs_to_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__icd_10_pcs_to_ccs.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__icd_10_pcs_to_ccs.csv", "unique_id": "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__icd_10_pcs_to_ccs"], "alias": "_value_set_icd_10_pcs_to_ccs", "checksum": {"name": "sha256", "checksum": "b152259e1a13057a37cf15ae765f61c7c9559340b5469fa93909ad910929fd0e"}, "config": {"enabled": true, "alias": "_value_set_icd_10_pcs_to_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_pcs_to_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_procedure_category": "varchar(256)", "ccs_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Mapping of ICD-10-PCS codes to CCS procedure categories for readmissions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_procedure_category": {"name": "ccs_procedure_category", "description": "CCS procedure category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_description": {"name": "ccs_description", "description": "Description of the CCS procedure category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','icd_10_pcs_to_ccs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_icd_10_pcs_to_ccs", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_procedure_category": "varchar(256)", "ccs_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.5550451, "relation_name": "cms_synthetic.readmissions._value_set_icd_10_pcs_to_ccs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": {"database": "cms_synthetic", "schema": "readmissions", "name": "readmissions__always_planned_ccs_diagnosis_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/readmissions/readmissions__always_planned_ccs_diagnosis_category.csv", "original_file_path": "seeds/value_sets/readmissions/readmissions__always_planned_ccs_diagnosis_category.csv", "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__always_planned_ccs_diagnosis_category"], "alias": "_value_set_always_planned_ccs_diagnosis_category", "checksum": {"name": "sha256", "checksum": "1bfbe31c1b65d38e97936d54fa477faf6b189e69e7659499bce52ab8e85fa82e"}, "config": {"enabled": true, "alias": "_value_set_always_planned_ccs_diagnosis_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','always_planned_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Always planned CCS diagnosis categories for readmissions.", "columns": {"ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/readmissions/readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','always_planned_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_always_planned_ccs_diagnosis_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.534931, "relation_name": "cms_synthetic.readmissions._value_set_always_planned_ccs_diagnosis_category", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__disabled_interaction_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__disabled_interaction_factors.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__disabled_interaction_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disabled_interaction_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disabled_interaction_factors"], "alias": "_value_set_disabled_interaction_factors", "checksum": {"name": "sha256", "checksum": "b2e6ac06c8ef6087ff21d9aa2b868cdddca29fda8fc8346563c81a56f0e97f2a"}, "config": {"enabled": true, "alias": "_value_set_disabled_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disabled_interaction_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease and disabled interaction factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_name": {"name": "short_name", "description": "Short name of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disabled_interaction_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disabled_interaction_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.6002188, "relation_name": "cms_synthetic.cms_hcc._value_set_disabled_interaction_factors", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disease_hierarchy": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__disease_hierarchy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__disease_hierarchy.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__disease_hierarchy.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disease_hierarchy", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disease_hierarchy"], "alias": "_value_set_disease_hierarchy", "checksum": {"name": "sha256", "checksum": "48982402067756cdefe3729778775b1868734dacdc88f44407971aa120586468"}, "config": {"enabled": true, "alias": "_value_set_disease_hierarchy", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_hierarchy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "hccs_to_exclude": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease hierarchies by model version. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disease hierarchy", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hccs_to_exclude": {"name": "hccs_to_exclude", "description": "HCC codes to exclude from the hierarchy", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_hierarchy.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disease_hierarchy", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "hccs_to_exclude": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.613837, "relation_name": "cms_synthetic.cms_hcc._value_set_disease_hierarchy", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__icd_10_cm_mappings", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__icd_10_cm_mappings.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__icd_10_cm_mappings.csv", "unique_id": "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__icd_10_cm_mappings"], "alias": "_value_set_icd_10_cm_mappings", "checksum": {"name": "sha256", "checksum": "03dda989fc2f10b3741665515d73d2352b52061d605ddf7fef318b53b1a24a57"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_mappings", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"payment_year": "integer", "diagnosis_code": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v24_flag": "varchar(256)", "cms_hcc_v28": "varchar(256)", "cms_hcc_v28_flag": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "ICD-10 to HCC mapping by payment year and model version. Combined and cleaned version of code files on cms.gov.\n", "columns": {"payment_year": {"name": "payment_year", "description": "The year for which the ICD-10 to HCC mapping is applicable", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code": {"name": "diagnosis_code", "description": "ICD-10 diagnosis code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v24": {"name": "cms_hcc_v24", "description": "CMS-HCC version 24 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v24_flag": {"name": "cms_hcc_v24_flag", "description": "Flag indicating inclusion in CMS-HCC version 24", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v28": {"name": "cms_hcc_v28", "description": "CMS-HCC version 28 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v28_flag": {"name": "cms_hcc_v28_flag", "description": "Flag indicating inclusion in CMS-HCC version 28", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_icd_10_cm_mappings", "tags": "cms_hcc", "enabled": true, "column_types": {"payment_year": "integer", "diagnosis_code": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v24_flag": "varchar(256)", "cms_hcc_v28": "varchar(256)", "cms_hcc_v28_flag": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.6355572, "relation_name": "cms_synthetic.cms_hcc._value_set_icd_10_cm_mappings", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disease_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__disease_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__disease_factors.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__disease_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disease_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disease_factors"], "alias": "_value_set_disease_factors", "checksum": {"name": "sha256", "checksum": "64c15ace094f384cb6a38b0a0c67a0216f8eb2ef0e00cd8fc7537e9fd1a85f7f"}, "config": {"enabled": true, "alias": "_value_set_disease_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of disease factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disease factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the disease factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disease_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.607523, "relation_name": "cms_synthetic.cms_hcc._value_set_disease_factors", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disease_interaction_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__disease_interaction_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__disease_interaction_factors.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__disease_interaction_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disease_interaction_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disease_interaction_factors"], "alias": "_value_set_disease_interaction_factors", "checksum": {"name": "sha256", "checksum": "a2f6c69a63ed5c43e250b356ea308285effbb38643d732404f8e4277fe649a00"}, "config": {"enabled": true, "alias": "_value_set_disease_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_interaction_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code_1": "varchar(256)", "hcc_code_2": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease interaction factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_name": {"name": "short_name", "description": "Short name of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_1": {"name": "hcc_code_1", "description": "First Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_2": {"name": "hcc_code_2", "description": "Second Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_disease_interaction_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disease_interaction_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code_1": "varchar(256)", "hcc_code_2": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.6219819, "relation_name": "cms_synthetic.cms_hcc._value_set_disease_interaction_factors", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__cpt_hcpcs": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__cpt_hcpcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__cpt_hcpcs.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__cpt_hcpcs.csv", "unique_id": "seed.the_tuva_project.cms_hcc__cpt_hcpcs", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__cpt_hcpcs"], "alias": "_value_set_cpt_hcpcs", "checksum": {"name": "sha256", "checksum": "511389c6e0558d00efb8c3cae2123a46f97e616d26bdf7b8a331670f857b1ac8"}, "config": {"enabled": true, "alias": "_value_set_cpt_hcpcs", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_cpt_hcpcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"payment_year": "integer", "hcpcs_cpt_code": "varchar(256)", "included_flag": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "CPT/HCPCS encounter filtering included list by payment year. Combined and cleaned version of code files on cms.gov.\n", "columns": {"payment_year": {"name": "payment_year", "description": "The year for which the CPT/HCPCS codes are applicable", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_cpt_code": {"name": "hcpcs_cpt_code", "description": "The CPT or HCPCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "included_flag": {"name": "included_flag", "description": "Flag indicating whether the code is included in the filtering", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_cpt_hcpcs.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_cpt_hcpcs", "tags": "cms_hcc", "enabled": true, "column_types": {"payment_year": "integer", "hcpcs_cpt_code": "varchar(256)", "included_flag": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.5844538, "relation_name": "cms_synthetic.cms_hcc._value_set_cpt_hcpcs", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__adjustment_rates": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__adjustment_rates", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__adjustment_rates.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__adjustment_rates.csv", "unique_id": "seed.the_tuva_project.cms_hcc__adjustment_rates", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__adjustment_rates"], "alias": "_value_set_adjustment_rates", "checksum": {"name": "sha256", "checksum": "51bc7577f57c9638cdc72ca40f108301756eb831a01345b7763c38bfbb869b4a"}, "config": {"enabled": true, "alias": "_value_set_adjustment_rates", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_adjustment_rates.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "payment_year": "integer", "normalization_factor": "float", "ma_coding_pattern_adjustment": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Adjustment rates by payment year. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The year for which the adjustment rates are applicable", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalization_factor": {"name": "normalization_factor", "description": "The normalization factor applied", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ma_coding_pattern_adjustment": {"name": "ma_coding_pattern_adjustment", "description": "The Medicare Advantage coding pattern adjustment factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_adjustment_rates.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_adjustment_rates", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "payment_year": "integer", "normalization_factor": "float", "ma_coding_pattern_adjustment": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.580228, "relation_name": "cms_synthetic.cms_hcc._value_set_adjustment_rates", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__enrollment_interaction_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__enrollment_interaction_factors.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__enrollment_interaction_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__enrollment_interaction_factors"], "alias": "_value_set_enrollment_interaction_factors", "checksum": {"name": "sha256", "checksum": "8ff088e57fc620bde58a0e1707097011e249e3b2c65f1b1754da0cb6a0c3fa09"}, "config": {"enabled": true, "alias": "_value_set_enrollment_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_enrollment_interaction_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "gender": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "institutional_status": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Enrollment interaction factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of enrollment interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Gender of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the enrollment interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the enrollment interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_enrollment_interaction_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_enrollment_interaction_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "gender": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "institutional_status": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.62921, "relation_name": "cms_synthetic.cms_hcc._value_set_enrollment_interaction_factors", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__payment_hcc_count_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__payment_hcc_count_factors.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__payment_hcc_count_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__payment_hcc_count_factors"], "alias": "_value_set_payment_hcc_count_factors", "checksum": {"name": "sha256", "checksum": "bf87f7657286107fa26c903a7ed24a2e8d39ca5fbd8869ee778adecb91bb2431"}, "config": {"enabled": true, "alias": "_value_set_payment_hcc_count_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_payment_hcc_count_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "payment_hcc_count": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Payment HCC count factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of HCC count factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_hcc_count": {"name": "payment_hcc_count", "description": "Count of HCCs for payment adjustment", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the HCC count factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the HCC count factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_payment_hcc_count_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_payment_hcc_count_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "payment_hcc_count": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.642856, "relation_name": "cms_synthetic.cms_hcc._value_set_payment_hcc_count_factors", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__demographic_factors": {"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__demographic_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/cms_hcc/cms_hcc__demographic_factors.csv", "original_file_path": "seeds/value_sets/cms_hcc/cms_hcc__demographic_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__demographic_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__demographic_factors"], "alias": "_value_set_demographic_factors", "checksum": {"name": "sha256", "checksum": "b3bbcb21143941da7dc41c5ca2f68d4cbe180920e344ea1dded30722b7193c84"}, "config": {"enabled": true, "alias": "_value_set_demographic_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_demographic_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "plan_segment": "varchar(256)", "gender": "varchar(256)", "age_group": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Demographic factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of demographic factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan_segment": {"name": "plan_segment", "description": "Plan segment of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Gender of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "Age group of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the demographic factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/cms_hcc/cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_hcc_demographic_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_demographic_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "plan_segment": "varchar(256)", "gender": "varchar(256)", "age_group": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.593529, "relation_name": "cms_synthetic.cms_hcc._value_set_demographic_factors", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.quality_measures__value_sets": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__value_sets", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/quality_measures/quality_measures__value_sets.csv", "original_file_path": "seeds/value_sets/quality_measures/quality_measures__value_sets.csv", "unique_id": "seed.the_tuva_project.quality_measures__value_sets", "fqn": ["the_tuva_project", "value_sets", "quality_measures", "quality_measures__value_sets"], "alias": "_value_set_codes", "checksum": {"name": "sha256", "checksum": "e130e1696ce203c3c7faec7efadfc972c4e7502553190544a2077b4c2817ac75"}, "config": {"enabled": true, "alias": "_value_set_codes", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_value_set_codes.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["quality_measures"], "description": "Concepts to value sets crosswalk. List of codes in each concept.", "columns": {"concept_name": {"name": "concept_name", "description": "Name of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Code representing the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "System used for the code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/quality_measures/quality_measures_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_value_set_codes.csv',compression=true,null_marker=true) }}", "schema": "quality_measures", "alias": "_value_set_codes", "tags": "quality_measures", "enabled": true, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.660322, "relation_name": "cms_synthetic.quality_measures._value_set_codes", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.quality_measures__measures": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__measures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/quality_measures/quality_measures__measures.csv", "original_file_path": "seeds/value_sets/quality_measures/quality_measures__measures.csv", "unique_id": "seed.the_tuva_project.quality_measures__measures", "fqn": ["the_tuva_project", "value_sets", "quality_measures", "quality_measures__measures"], "alias": "_value_set_measures", "checksum": {"name": "sha256", "checksum": "ffba1ed18ece6d32fe634f279e2833b355b51c66691ef06db717ee4ebb257992"}, "config": {"enabled": true, "alias": "_value_set_measures", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_measures.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"id": "varchar(256)", "name": "varchar(256)", "description": "varchar(3000)", "version": "varchar(256)", "steward": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["quality_measures"], "description": "Overview of reporting measures.", "columns": {"id": {"name": "id", "description": "Identifier for the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "name": {"name": "name", "description": "Name of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "version": {"name": "version", "description": "Version of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "steward": {"name": "steward", "description": "Steward of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/quality_measures/quality_measures_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_measures.csv',compression=true,null_marker=true) }}", "schema": "quality_measures", "alias": "_value_set_measures", "tags": "quality_measures", "enabled": true, "column_types": {"id": "varchar(256)", "name": "varchar(256)", "description": "varchar(3000)", "version": "varchar(256)", "steward": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.655086, "relation_name": "cms_synthetic.quality_measures._value_set_measures", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.quality_measures__concepts": {"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__concepts", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/quality_measures/quality_measures__concepts.csv", "original_file_path": "seeds/value_sets/quality_measures/quality_measures__concepts.csv", "unique_id": "seed.the_tuva_project.quality_measures__concepts", "fqn": ["the_tuva_project", "value_sets", "quality_measures", "quality_measures__concepts"], "alias": "_value_set_concepts", "checksum": {"name": "sha256", "checksum": "327c96bdd4582e91ea0c6f7f2b9641eba1e3973dab46402760c175af6e3987a8"}, "config": {"enabled": true, "alias": "_value_set_concepts", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_concepts.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "measure_id": "varchar(256)", "measure_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["quality_measures"], "description": "Measures to concepts crosswalk. List of concepts used in each reporting measure.", "columns": {"concept_name": {"name": "concept_name", "description": "Name of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Identifier for the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/quality_measures/quality_measures_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','quality_measures_concepts.csv',compression=true,null_marker=true) }}", "schema": "quality_measures", "alias": "_value_set_concepts", "tags": "quality_measures", "enabled": true, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "measure_id": "varchar(256)", "measure_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.648627, "relation_name": "cms_synthetic.quality_measures._value_set_concepts", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.pqi__measures": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "pqi__measures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ahrq_measures/pqi__measures.csv", "original_file_path": "seeds/value_sets/ahrq_measures/pqi__measures.csv", "unique_id": "seed.the_tuva_project.pqi__measures", "fqn": ["the_tuva_project", "value_sets", "ahrq_measures", "pqi__measures"], "alias": "_value_set_pqi_measures", "checksum": {"name": "sha256", "checksum": "07d8a05ef568cd5091c79212bf6158d416e9eb3010e274cf70354b168014fb79"}, "config": {"enabled": true, "alias": "_value_set_pqi_measures", "schema": "ahrq_measures", "database": null, "tags": ["pqi"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"pqi_number": "varchar(256)", "pqi_name": "varchar(256)", "pqi_description": "varchar(1000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["pqi"], "description": "Names and descriptions of each of the PQI measures", "columns": {"pqi_number": {"name": "pqi_number", "description": "Number of the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_name": {"name": "pqi_name", "description": "Name of the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_description": {"name": "pqi_description", "description": "Description of the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ahrq_measures/pqi__seeds.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_value_set_pqi_measures", "tags": ["pqi"], "enabled": true, "column_types": {"pqi_number": "varchar(256)", "pqi_name": "varchar(256)", "pqi_description": "varchar(1000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.6678321, "relation_name": "cms_synthetic.ahrq_measures._value_set_pqi_measures", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": []}}, "seed.the_tuva_project.pqi__value_sets": {"database": "cms_synthetic", "schema": "ahrq_measures", "name": "pqi__value_sets", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ahrq_measures/pqi__value_sets.csv", "original_file_path": "seeds/value_sets/ahrq_measures/pqi__value_sets.csv", "unique_id": "seed.the_tuva_project.pqi__value_sets", "fqn": ["the_tuva_project", "value_sets", "ahrq_measures", "pqi__value_sets"], "alias": "_value_set_pqi", "checksum": {"name": "sha256", "checksum": "e30827bbf37051ce03553929a7ec59b959e0e6c0b655aa7951d9aea3b38b605b"}, "config": {"enabled": true, "alias": "_value_set_pqi", "schema": "ahrq_measures", "database": null, "tags": ["pqi"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"code": "varchar(256)", "value_set_name": "varchar(256)", "pqi_number": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["pqi"], "description": "Value sets from AHRQ for each of the published PQI measures", "columns": {"code": {"name": "code", "description": "Code associated with the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "value_set_name": {"name": "value_set_name", "description": "Name of the value set", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "Number of the PQI measure", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/ahrq_measures/pqi__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ahrq_measures/pqi__seeds.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_value_set_pqi", "tags": ["pqi"], "enabled": true, "column_types": {"code": "varchar(256)", "value_set_name": "varchar(256)", "pqi_number": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.664474, "relation_name": "cms_synthetic.ahrq_measures._value_set_pqi", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": []}}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__dxccsr_v2023_1_cleaned_map", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ccsr/ccsr__dxccsr_v2023_1_cleaned_map.csv", "original_file_path": "seeds/value_sets/ccsr/ccsr__dxccsr_v2023_1_cleaned_map.csv", "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "fqn": ["the_tuva_project", "value_sets", "ccsr", "ccsr__dxccsr_v2023_1_cleaned_map"], "alias": "_value_set_dxccsr_v2023_1_cleaned_map", "checksum": {"name": "sha256", "checksum": "cce1c4661615e89299e601fb26d3e3060b140864507858e5d0e8b61ea9b70c12"}, "config": {"enabled": true, "alias": "_value_set_dxccsr_v2023_1_cleaned_map", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','dxccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm_code": "varchar(256)", "icd_10_cm_code_description": "varchar(256)", "default_ccsr_category_ip": "varchar(256)", "default_ccsr_category_description_ip": "varchar(256)", "default_ccsr_category_op": "varchar(256)", "default_ccsr_category_description_op": "varchar(256)", "ccsr_category_1": "varchar(256)", "ccsr_category_1_description": "varchar(256)", "ccsr_category_2": "varchar(256)", "ccsr_category_2_description": "varchar(256)", "ccsr_category_3": "varchar(256)", "ccsr_category_3_description": "varchar(256)", "ccsr_category_4": "varchar(256)", "ccsr_category_4_description": "varchar(256)", "ccsr_category_5": "varchar(256)", "ccsr_category_5_description": "varchar(256)", "ccsr_category_6": "varchar(256)", "ccsr_category_6_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ccsr"], "description": "A table containing the CSV mapping file included with the DXCCSR SAS program.\nThe original CSV was not natively seedable, and the file was transformed with the coded included in the README.\nFor each ICD-10-CM code, the table contains up to six CCSR category codes and a default CCSR category code.\n", "columns": {"icd_10_cm_code": {"name": "icd_10_cm_code", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code_description": {"name": "icd_10_cm_code_description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_ip": {"name": "default_ccsr_category_ip", "description": "Default CCSR category for inpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_ip": {"name": "default_ccsr_category_description_ip", "description": "Description of the default CCSR category for inpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_op": {"name": "default_ccsr_category_op", "description": "Default CCSR category for outpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_op": {"name": "default_ccsr_category_description_op", "description": "Description of the default CCSR category for outpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_1": {"name": "ccsr_category_1", "description": "First CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_1_description": {"name": "ccsr_category_1_description", "description": "Description of the first CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_2": {"name": "ccsr_category_2", "description": "Second CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_2_description": {"name": "ccsr_category_2_description", "description": "Description of the second CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_3": {"name": "ccsr_category_3", "description": "Third CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_3_description": {"name": "ccsr_category_3_description", "description": "Description of the third CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_4": {"name": "ccsr_category_4", "description": "Fourth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_4_description": {"name": "ccsr_category_4_description", "description": "Description of the fourth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_5": {"name": "ccsr_category_5", "description": "Fifth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_5_description": {"name": "ccsr_category_5_description", "description": "Description of the fifth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_6": {"name": "ccsr_category_6", "description": "Sixth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_6_description": {"name": "ccsr_category_6_description", "description": "Description of the sixth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ccsr/ccsr_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','dxccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "schema": "ccsr", "alias": "_value_set_dxccsr_v2023_1_cleaned_map", "tags": ["ccsr"], "enabled": true, "column_types": {"icd_10_cm_code": "varchar(256)", "icd_10_cm_code_description": "varchar(256)", "default_ccsr_category_ip": "varchar(256)", "default_ccsr_category_description_ip": "varchar(256)", "default_ccsr_category_op": "varchar(256)", "default_ccsr_category_description_op": "varchar(256)", "ccsr_category_1": "varchar(256)", "ccsr_category_1_description": "varchar(256)", "ccsr_category_2": "varchar(256)", "ccsr_category_2_description": "varchar(256)", "ccsr_category_3": "varchar(256)", "ccsr_category_3_description": "varchar(256)", "ccsr_category_4": "varchar(256)", "ccsr_category_4_description": "varchar(256)", "ccsr_category_5": "varchar(256)", "ccsr_category_5_description": "varchar(256)", "ccsr_category_6": "varchar(256)", "ccsr_category_6_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.6864069, "relation_name": "cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__prccsr_v2023_1_cleaned_map", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ccsr/ccsr__prccsr_v2023_1_cleaned_map.csv", "original_file_path": "seeds/value_sets/ccsr/ccsr__prccsr_v2023_1_cleaned_map.csv", "unique_id": "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map", "fqn": ["the_tuva_project", "value_sets", "ccsr", "ccsr__prccsr_v2023_1_cleaned_map"], "alias": "_value_set_prccsr_v2023_1_cleaned_map", "checksum": {"name": "sha256", "checksum": "fd84423264c0174b1fc1e2ba23f1ac7957ef4fa7aaefcb2c45932f587b59fedf"}, "config": {"enabled": true, "alias": "_value_set_prccsr_v2023_1_cleaned_map", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','prccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "icd_10_pcs_description": "varchar(256)", "prccsr": "varchar(256)", "prccsr_description": "varchar(256)", "clinical_domain": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ccsr"], "description": "A table containing the CSV mapping file included with the PRCCSR SAS program.\nThe original CSV was not natively seedable, and the file was transformed with the coded included in the README.\n", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_pcs_description": {"name": "icd_10_pcs_description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prccsr": {"name": "prccsr", "description": "PRCCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prccsr_description": {"name": "prccsr_description", "description": "Description of the PRCCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "clinical_domain": {"name": "clinical_domain", "description": "Clinical domain associated with the PRCCSR category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ccsr/ccsr_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','prccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "schema": "ccsr", "alias": "_value_set_prccsr_v2023_1_cleaned_map", "tags": ["ccsr"], "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "icd_10_pcs_description": "varchar(256)", "prccsr": "varchar(256)", "prccsr_description": "varchar(256)", "clinical_domain": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.692864, "relation_name": "cms_synthetic.ccsr._value_set_prccsr_v2023_1_cleaned_map", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": {"database": "cms_synthetic", "schema": "ccsr", "name": "ccsr__dxccsr_v2023_1_body_systems", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/ccsr/ccsr__dxccsr_v2023_1_body_systems.csv", "original_file_path": "seeds/value_sets/ccsr/ccsr__dxccsr_v2023_1_body_systems.csv", "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems", "fqn": ["the_tuva_project", "value_sets", "ccsr", "ccsr__dxccsr_v2023_1_body_systems"], "alias": "_value_set_dxccsr_v2023_1_body_systems", "checksum": {"name": "sha256", "checksum": "7697bf1b376e5db2c79b42edf944e29332b40b534eeaf0f379ff17439b4fb440"}, "config": {"enabled": true, "alias": "_value_set_dxccsr_v2023_1_body_systems", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','dxccsr_v2023_1_body_systems.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"body_system": "varchar(256)", "ccsr_parent_category": "varchar(256)", "parent_category_description": "varchar(3000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ccsr"], "description": "A table containing descriptions of the top level categories used in the CCSR condition mapper.\nThis was manually extracted from the User Guide PDF included with the DXCCSR SAS program.\n", "columns": {"body_system": {"name": "body_system", "description": "The body system associated with the CCSR parent category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category in the CCSR condition mapper.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_category_description": {"name": "parent_category_description", "description": "Description of the parent category in the CCSR condition mapper.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/ccsr/ccsr_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','dxccsr_v2023_1_body_systems.csv',compression=true,null_marker=true) }}", "schema": "ccsr", "alias": "_value_set_dxccsr_v2023_1_body_systems", "tags": ["ccsr"], "enabled": true, "column_types": {"body_system": "varchar(256)", "ccsr_parent_category": "varchar(256)", "parent_category_description": "varchar(3000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.673082, "relation_name": "cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.hcc_suspecting__clinical_concepts": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__clinical_concepts", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/hcc_suspecting/hcc_suspecting__clinical_concepts.csv", "original_file_path": "seeds/value_sets/hcc_suspecting/hcc_suspecting__clinical_concepts.csv", "unique_id": "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "fqn": ["the_tuva_project", "value_sets", "hcc_suspecting", "hcc_suspecting__clinical_concepts"], "alias": "_value_set_clinical_concepts", "checksum": {"name": "sha256", "checksum": "e130e1696ce203c3c7faec7efadfc972c4e7502553190544a2077b4c2817ac75"}, "config": {"enabled": true, "alias": "_value_set_clinical_concepts", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_clinical_concepts.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["hcc_suspecting"], "description": "Value sets for clinical concepts.", "columns": {"concept_name": {"name": "concept_name", "description": "Name of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Code representing the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "Code system used for the code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/hcc_suspecting/hcc_suspecting_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_clinical_concepts.csv',compression=true,null_marker=true) }}", "schema": "hcc_suspecting", "alias": "_value_set_clinical_concepts", "tags": "hcc_suspecting", "enabled": true, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.699059, "relation_name": "cms_synthetic.hcc_suspecting._value_set_clinical_concepts", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__icd_10_cm_mappings", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/hcc_suspecting/hcc_suspecting__icd_10_cm_mappings.csv", "original_file_path": "seeds/value_sets/hcc_suspecting/hcc_suspecting__icd_10_cm_mappings.csv", "unique_id": "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings", "fqn": ["the_tuva_project", "value_sets", "hcc_suspecting", "hcc_suspecting__icd_10_cm_mappings"], "alias": "_value_set_icd_10_cm_mappings", "checksum": {"name": "sha256", "checksum": "2d5d504da80762d6e23c1d61b5ba3ad0d50ab964d5dd914af92570aa536104a9"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_mappings", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"diagnosis_code": "varchar(256)", "cms_hcc_esrd_v21": "varchar(256)", "cms_hcc_esrd_v24": "varchar(256)", "cms_hcc_v22": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v28": "varchar(256)", "rx_hcc_v05": "varchar(256)", "rx_hcc_v08": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["hcc_suspecting"], "description": "ICD-10 to HCC mapping by payment year and model version. Combined and cleaned version of code files on cms.gov.\n", "columns": {"diagnosis_code": {"name": "diagnosis_code", "description": "ICD-10 diagnosis code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_esrd_v21": {"name": "cms_hcc_esrd_v21", "description": "CMS-HCC ESRD version 21 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_esrd_v24": {"name": "cms_hcc_esrd_v24", "description": "CMS-HCC ESRD version 24 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v22": {"name": "cms_hcc_v22", "description": "CMS-HCC version 22 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v24": {"name": "cms_hcc_v24", "description": "CMS-HCC version 24 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v28": {"name": "cms_hcc_v28", "description": "CMS-HCC version 28 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rx_hcc_v05": {"name": "rx_hcc_v05", "description": "Rx-HCC version 05 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rx_hcc_v08": {"name": "rx_hcc_v08", "description": "Rx-HCC version 08 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/hcc_suspecting/hcc_suspecting_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "schema": "hcc_suspecting", "alias": "_value_set_icd_10_cm_mappings", "tags": "hcc_suspecting", "enabled": true, "column_types": {"diagnosis_code": "varchar(256)", "cms_hcc_esrd_v21": "varchar(256)", "cms_hcc_esrd_v24": "varchar(256)", "cms_hcc_v22": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v28": "varchar(256)", "rx_hcc_v05": "varchar(256)", "rx_hcc_v08": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7106571, "relation_name": "cms_synthetic.hcc_suspecting._value_set_icd_10_cm_mappings", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": {"database": "cms_synthetic", "schema": "hcc_suspecting", "name": "hcc_suspecting__hcc_descriptions", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv", "original_file_path": "seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv", "unique_id": "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "fqn": ["the_tuva_project", "value_sets", "hcc_suspecting", "hcc_suspecting__hcc_descriptions"], "alias": "_value_set_hcc_descriptions", "checksum": {"name": "sha256", "checksum": "7e7ac940d8a7da977e3e33e93d6690af3d6b36c8791fb14a10f06beb8f3f779f"}, "config": {"enabled": true, "alias": "_value_set_hcc_descriptions", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_descriptions.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcc_code": "varchar(256)", "hcc_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["hcc_suspecting"], "description": "Disease factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "Description of the HCC code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/hcc_suspecting/hcc_suspecting_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','hcc_suspecting_descriptions.csv',compression=true,null_marker=true) }}", "schema": "hcc_suspecting", "alias": "_value_set_hcc_descriptions", "tags": "hcc_suspecting", "enabled": true, "column_types": {"hcc_code": "varchar(256)", "hcc_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.70332, "relation_name": "cms_synthetic.hcc_suspecting._value_set_hcc_descriptions", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__tuva_chronic_conditions_hierarchy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/chronic_conditions/chronic_conditions__tuva_chronic_conditions_hierarchy.csv", "original_file_path": "seeds/value_sets/chronic_conditions/chronic_conditions__tuva_chronic_conditions_hierarchy.csv", "unique_id": "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy", "fqn": ["the_tuva_project", "value_sets", "chronic_conditions", "chronic_conditions__tuva_chronic_conditions_hierarchy"], "alias": "_value_set_tuva_chronic_conditions_hierarchy", "checksum": {"name": "sha256", "checksum": "b379c992888d52f3b13270d7e804e5c5d0d1314d1039123674e6122884c37ce3"}, "config": {"enabled": true, "alias": "_value_set_tuva_chronic_conditions_hierarchy", "schema": "chronic_conditions", "database": null, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"condition_family": "varchar(256)", "condition": "varchar(256)", "icd_10_cm_code": "varchar(256)", "icd_10_cm_description": "varchar(256)", "condition_column_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "description": "A list of the diagnoses codes and their long and short names along with grouping logic classifying each code into a condition group and a condition family group.", "columns": {"condition_family": {"name": "condition_family", "description": "Family group of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "Name of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code": {"name": "icd_10_cm_code", "description": "ICD-10-CM code for the chronic condition", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_description": {"name": "icd_10_cm_description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_column_name": {"name": "condition_column_name", "description": "Column name for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/chronic_conditions/tuva_chronic_conditions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','tuva_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "schema": "chronic_conditions", "alias": "_value_set_tuva_chronic_conditions_hierarchy", "tags": ["tuva_chronic_conditions", "chronic_conditions"], "enabled": true, "column_types": {"condition_family": "varchar(256)", "condition": "varchar(256)", "icd_10_cm_code": "varchar(256)", "icd_10_cm_description": "varchar(256)", "condition_column_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.717186, "relation_name": "cms_synthetic.chronic_conditions._value_set_tuva_chronic_conditions_hierarchy", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": {"database": "cms_synthetic", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_hierarchy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv", "original_file_path": "seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv", "unique_id": "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "fqn": ["the_tuva_project", "value_sets", "chronic_conditions", "chronic_conditions__cms_chronic_conditions_hierarchy"], "alias": "_value_set_cms_chronic_conditions_hierarchy", "checksum": {"name": "sha256", "checksum": "3328c63a1bcb8d0813bb98a61739cb69306aa2726082b042baa377c4fb761302"}, "config": {"enabled": true, "alias": "_value_set_cms_chronic_conditions_hierarchy", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"condition_id": "varchar(256)", "condition": "varchar(256)", "condition_column_name": "varchar(256)", "chronic_condition_type": "varchar(256)", "condition_category": "varchar(256)", "additional_logic": "varchar(256)", "claims_qualification": "varchar(1024)", "inclusion_type": "varchar(256)", "code_system": "varchar(256)", "code": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "CMS generated grouping of ICD 10 codes into chronic conditions groups", "columns": {"condition_id": {"name": "condition_id", "description": "Identifier for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "Name of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_column_name": {"name": "condition_column_name", "description": "Column name for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "Type of chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "Category of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "additional_logic": {"name": "additional_logic", "description": "Additional logic for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claims_qualification": {"name": "claims_qualification", "description": "Claims qualification criteria for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inclusion_type": {"name": "inclusion_type", "description": "Type of inclusion for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "Code system used for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Code for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/value_sets/chronic_conditions/cms_chronic_conditions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.1','cms_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "schema": "chronic_conditions", "alias": "_value_set_cms_chronic_conditions_hierarchy", "tags": ["cms_chronic_conditions", "chronic_conditions"], "enabled": true, "column_types": {"condition_id": "varchar(256)", "condition": "varchar(256)", "condition_column_name": "varchar(256)", "chronic_condition_type": "varchar(256)", "condition_category": "varchar(256)", "additional_logic": "varchar(256)", "claims_qualification": "varchar(1024)", "inclusion_type": "varchar(256)", "code_system": "varchar(256)", "code": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7253, "relation_name": "cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__fips_county": {"database": "cms_synthetic", "schema": "reference_data", "name": "reference_data__fips_county", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data/reference_data__fips_county.csv", "original_file_path": "seeds/reference_data/reference_data__fips_county.csv", "unique_id": "seed.the_tuva_project.reference_data__fips_county", "fqn": ["the_tuva_project", "reference_data", "reference_data__fips_county"], "alias": "fips_county", "checksum": {"name": "sha256", "checksum": "206c5df28096e19cfc225b0cc29b1aed721a971d84007ace9f9a839dac378080"}, "config": {"enabled": true, "alias": "fips_county", "schema": "reference_data", "database": null, "tags": ["terminology", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','fips_county.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"fips_code": "varchar(256)", "county": "varchar(256)", "state": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "reference_data"], "description": "Seed containing FIPS county codes and names.", "columns": {"fips_code": {"name": "fips_code", "description": "The FIPS code for the county.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "county": {"name": "county", "description": "The name of the county.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state where the county is located.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/reference_data/reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','fips_county.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "fips_county", "tags": ["terminology", "reference_data"], "column_types": {"fips_code": "varchar(256)", "county": "varchar(256)", "state": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7456121, "relation_name": "cms_synthetic.reference_data.fips_county", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__calendar": {"database": "cms_synthetic", "schema": "reference_data", "name": "reference_data__calendar", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data/reference_data__calendar.csv", "original_file_path": "seeds/reference_data/reference_data__calendar.csv", "unique_id": "seed.the_tuva_project.reference_data__calendar", "fqn": ["the_tuva_project", "reference_data", "reference_data__calendar"], "alias": "calendar", "checksum": {"name": "sha256", "checksum": "0b05d002a395c589a2bd33f0c3a551d2a4642fcc9ebcd63e0a61c16e6d62bc2e"}, "config": {"enabled": true, "alias": "calendar", "schema": "reference_data", "database": null, "tags": ["terminology", "pmpm", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','calendar.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"full_date": "date", "year": "integer", "month": "integer", "day": "integer", "month_name": "varchar(256)", "day_of_week_number": "integer", "day_of_week_name": "varchar(256)", "week_of_year": "integer", "day_of_year": "integer", "year_month": "varchar(256)", "first_day_of_month": "date", "last_day_of_month": "date", "year_month_int": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "pmpm", "reference_data"], "description": "Seed containing calendar dates and related attributes.", "columns": {"full_date": {"name": "full_date", "description": "The complete date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year": {"name": "year", "description": "The year part of the date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "month": {"name": "month", "description": "The month part of the date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day": {"name": "day", "description": "The day part of the date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "month_name": {"name": "month_name", "description": "The name of the month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day_of_week_number": {"name": "day_of_week_number", "description": "The number of the day in the week.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day_of_week_name": {"name": "day_of_week_name", "description": "The name of the day in the week.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "week_of_year": {"name": "week_of_year", "description": "The week number in the year.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day_of_year": {"name": "day_of_year", "description": "The day number in the year.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "The year and month in YYYY-MM format.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_day_of_month": {"name": "first_day_of_month", "description": "The first day of the month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_day_of_month": {"name": "last_day_of_month", "description": "The last day of the month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/reference_data/reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','calendar.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "calendar", "tags": ["terminology", "pmpm", "reference_data"], "column_types": {"full_date": "date", "year": "integer", "month": "integer", "day": "integer", "month_name": "varchar(256)", "day_of_week_number": "integer", "day_of_week_name": "varchar(256)", "week_of_year": "integer", "day_of_year": "integer", "year_month": "varchar(256)", "first_day_of_month": "date", "last_day_of_month": "date", "year_month_int": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7374709, "relation_name": "cms_synthetic.reference_data.calendar", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__ssa_fips_state": {"database": "cms_synthetic", "schema": "reference_data", "name": "reference_data__ssa_fips_state", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data/reference_data__ssa_fips_state.csv", "original_file_path": "seeds/reference_data/reference_data__ssa_fips_state.csv", "unique_id": "seed.the_tuva_project.reference_data__ssa_fips_state", "fqn": ["the_tuva_project", "reference_data", "reference_data__ssa_fips_state"], "alias": "ssa_fips_state", "checksum": {"name": "sha256", "checksum": "79a3093e6af928b718e6ac895e2b0f94fecd19d083227846626cd88ddea299f7"}, "config": {"enabled": true, "alias": "ssa_fips_state", "schema": "reference_data", "database": null, "tags": ["terminology", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ssa_fips_state.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ssa_fips_state_code": "varchar(256)", "ssa_fips_state_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "reference_data"], "description": "Seed containing SSA FIPS state codes and names.", "columns": {"ssa_fips_state_code": {"name": "ssa_fips_state_code", "description": "The SSA FIPS state code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ssa_fips_state_name": {"name": "ssa_fips_state_name", "description": "The name of the SSA FIPS state.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/reference_data/reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ssa_fips_state.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "ssa_fips_state", "tags": ["terminology", "reference_data"], "column_types": {"ssa_fips_state_code": "varchar(256)", "ssa_fips_state_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7499049, "relation_name": "cms_synthetic.reference_data.ssa_fips_state", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__ansi_fips_state": {"database": "cms_synthetic", "schema": "reference_data", "name": "reference_data__ansi_fips_state", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data/reference_data__ansi_fips_state.csv", "original_file_path": "seeds/reference_data/reference_data__ansi_fips_state.csv", "unique_id": "seed.the_tuva_project.reference_data__ansi_fips_state", "fqn": ["the_tuva_project", "reference_data", "reference_data__ansi_fips_state"], "alias": "ansi_fips_state", "checksum": {"name": "sha256", "checksum": "8b9ed6a3c0deef5889027408e19e785820305639d8185cbc6ff0a660266633d5"}, "config": {"enabled": true, "alias": "ansi_fips_state", "schema": "reference_data", "database": null, "tags": ["terminology", "medicare_cclf_connector", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ansi_fips_state.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ansi_fips_state_code": "varchar(256)", "ansi_fips_state_abbreviation": "varchar(256)", "ansi_fips_state_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "medicare_cclf_connector", "reference_data"], "description": "Seed containing ANSI FIPS state codes and names.", "columns": {"ansi_fips_state_code": {"name": "ansi_fips_state_code", "description": "The unique ANSI FIPS state code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ansi_fips_state_abbreviation": {"name": "ansi_fips_state_abbreviation", "description": "The abbreviation of the ANSI FIPS state.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ansi_fips_state_name": {"name": "ansi_fips_state_name", "description": "The full name of the ANSI FIPS state.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/reference_data/reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','ansi_fips_state.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "ansi_fips_state", "tags": ["terminology", "medicare_cclf_connector", "reference_data"], "column_types": {"ansi_fips_state_code": "varchar(256)", "ansi_fips_state_abbreviation": "varchar(256)", "ansi_fips_state_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7305448, "relation_name": "cms_synthetic.reference_data.ansi_fips_state", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__code_type": {"database": "cms_synthetic", "schema": "reference_data", "name": "reference_data__code_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data/reference_data__code_type.csv", "original_file_path": "seeds/reference_data/reference_data__code_type.csv", "unique_id": "seed.the_tuva_project.reference_data__code_type", "fqn": ["the_tuva_project", "reference_data", "reference_data__code_type"], "alias": "code_type", "checksum": {"name": "sha256", "checksum": "3a94151ece0a448f49b110851a7dd224fdd59207faa27d61aebe5fd5d39c51b4"}, "config": {"enabled": true, "alias": "code_type", "schema": "reference_data", "database": null, "tags": ["terminology", "data_profiling", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','code_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"code_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling", "reference_data"], "description": "Seed containing code types.", "columns": {"code_type": {"name": "code_type", "description": "The type of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds/reference_data/reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.1','code_type.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "code_type", "tags": ["terminology", "data_profiling", "reference_data"], "column_types": {"code_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729623957.7410078, "relation_name": "cms_synthetic.reference_data.code_type", "raw_code": "", "root_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/dbt_packages/the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "operation.the_tuva_project.the_tuva_project-on-run-end-0": {"database": "cms_synthetic", "schema": "dbt_tom", "name": "the_tuva_project-on-run-end-0", "resource_type": "operation", "package_name": "the_tuva_project", "path": "hooks/the_tuva_project-on-run-end-0.sql", "original_file_path": "./dbt_project.yml", "unique_id": "operation.the_tuva_project.the_tuva_project-on-run-end-0", "fqn": ["the_tuva_project", "hooks", "the_tuva_project-on-run-end-0"], "alias": "the_tuva_project-on-run-end-0", "checksum": {"name": "sha256", "checksum": "57dba6d8492a2936add95a96af1b65bff48584cafe5771be0727efb195dd860c"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "bind": false}, "tags": ["on-run-end"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": null, "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623956.967979, "relation_name": null, "raw_code": "{{ log_warning_for_seeds() }}", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.log_warning_for_seeds"], "nodes": []}, "compiled_path": "../target/compiled/the_tuva_project/./dbt_project.yml/hooks/the_tuva_project-on-run-end-0.sql", "compiled": true, "compiled_code": "\n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "index": 0}, "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_ed_classification__johnston_icd9_icd9", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_ed_classification__johnston_icd9_icd9.sql", "original_file_path": "seeds/value_sets/ed_classification/ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "unique_ed_classification__johnston_icd9_icd9"], "alias": "unique_ed_classification__johnston_icd9_icd9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623957.5187562, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd9", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd9"]}, "compiled_path": "../target/compiled/the_tuva_project/seeds/value_sets/ed_classification/ed_classification_seeds.yml/unique_ed_classification__johnston_icd9_icd9.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd9 as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.ed_classification._value_set_johnston_icd9\nwhere icd9 is not null\ngroup by icd9\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd9", "file_key_name": "seeds.ed_classification__johnston_icd9", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd9", "test_metadata": {"name": "unique", "kwargs": {"column_name": "icd9", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd9')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_ed_classification__johnston_icd9_icd9", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_ed_classification__johnston_icd9_icd9.sql", "original_file_path": "seeds/value_sets/ed_classification/ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "not_null_ed_classification__johnston_icd9_icd9"], "alias": "not_null_ed_classification__johnston_icd9_icd9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623957.519707, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd9", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd9"]}, "compiled_path": "../target/compiled/the_tuva_project/seeds/value_sets/ed_classification/ed_classification_seeds.yml/not_null_ed_classification__johnston_icd9_icd9.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd9\nfrom cms_synthetic.ed_classification._value_set_johnston_icd9\nwhere icd9 is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd9", "file_key_name": "seeds.ed_classification__johnston_icd9", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd9", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "icd9", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd9')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_ed_classification__johnston_icd10_icd10", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_ed_classification__johnston_icd10_icd10.sql", "original_file_path": "seeds/value_sets/ed_classification/ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "unique_ed_classification__johnston_icd10_icd10"], "alias": "unique_ed_classification__johnston_icd10_icd10", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623957.520427, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd10", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd10"]}, "compiled_path": "../target/compiled/the_tuva_project/seeds/value_sets/ed_classification/ed_classification_seeds.yml/unique_ed_classification__johnston_icd10_icd10.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd10 as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.ed_classification._value_set_johnston_icd10\nwhere icd10 is not null\ngroup by icd10\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd10", "file_key_name": "seeds.ed_classification__johnston_icd10", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd10", "test_metadata": {"name": "unique", "kwargs": {"column_name": "icd10", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd10')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_ed_classification__johnston_icd10_icd10", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_ed_classification__johnston_icd10_icd10.sql", "original_file_path": "seeds/value_sets/ed_classification/ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "not_null_ed_classification__johnston_icd10_icd10"], "alias": "not_null_ed_classification__johnston_icd10_icd10", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623957.52111, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd10", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd10"]}, "compiled_path": "../target/compiled/the_tuva_project/seeds/value_sets/ed_classification/ed_classification_seeds.yml/not_null_ed_classification__johnston_icd10_icd10.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd10\nfrom cms_synthetic.ed_classification._value_set_johnston_icd10\nwhere icd10 is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd10", "file_key_name": "seeds.ed_classification__johnston_icd10", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd10", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "icd10", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd10')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33.sql", "original_file_path": "models/pharmacy/pharmacy_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7", "fqn": ["the_tuva_project", "pharmacy", "dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number"], "alias": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33"}, "created_at": 1729623957.771477, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33\") }}", "language": "sql", "refs": [{"name": "pharmacy__brand_generic_opportunity", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.pharmacy__brand_generic_opportunity"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/pharmacy_models.yml/dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from cms_synthetic.pharmacy.brand_generic_opportunity\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.pharmacy__brand_generic_opportunity", "attached_node": "model.the_tuva_project.pharmacy__brand_generic_opportunity", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["data_source", "claim_id", "claim_line_number"], "model": "{{ get_where_subquery(ref('pharmacy__brand_generic_opportunity')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd.sql", "original_file_path": "models/pharmacy/pharmacy_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42", "fqn": ["the_tuva_project", "pharmacy", "dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc"], "alias": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd"}, "created_at": 1729623957.7824, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd\") }}", "language": "sql", "refs": [{"name": "pharmacy__generic_available_list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.pharmacy__generic_available_list"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/pharmacy_models.yml/dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n generic_available_sk, generic_ndc\n from cms_synthetic.pharmacy.generic_available_list\n group by generic_available_sk, generic_ndc\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.pharmacy__generic_available_list", "attached_node": "model.the_tuva_project.pharmacy__generic_available_list", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["generic_available_sk", "generic_ndc"], "model": "{{ get_where_subquery(ref('pharmacy__generic_available_list')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91.sql", "original_file_path": "models/pharmacy/pharmacy_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59", "fqn": ["the_tuva_project", "pharmacy", "dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number"], "alias": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91"}, "created_at": 1729623957.784576, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91\") }}", "language": "sql", "refs": [{"name": "pharmacy__pharmacy_claim_expanded", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded"]}, "compiled_path": "../target/compiled/the_tuva_project/models/pharmacy/pharmacy_models.yml/dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from cms_synthetic.pharmacy.pharmacy_claim_expanded\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.pharmacy__pharmacy_claim_expanded", "attached_node": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["data_source", "claim_id", "claim_line_number"], "model": "{{ get_where_subquery(ref('pharmacy__pharmacy_claim_expanded')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__condition_condition_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__condition_condition_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0", "fqn": ["the_tuva_project", "core", "unique_core__condition_condition_id"], "alias": "unique_core__condition_condition_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.834302, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__condition_condition_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n condition_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.condition\nwhere condition_id is not null\ngroup by condition_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition_id", "file_key_name": "models.core__condition", "attached_node": "model.the_tuva_project.core__condition", "test_metadata": {"name": "unique", "kwargs": {"column_name": "condition_id", "model": "{{ get_where_subquery(ref('core__condition')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__eligibility_eligibility_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__eligibility_eligibility_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a", "fqn": ["the_tuva_project", "core", "unique_core__eligibility_eligibility_id"], "alias": "unique_core__eligibility_eligibility_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.8350499, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__eligibility"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__eligibility_eligibility_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n eligibility_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.eligibility\nwhere eligibility_id is not null\ngroup by eligibility_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "eligibility_id", "file_key_name": "models.core__eligibility", "attached_node": "model.the_tuva_project.core__eligibility", "test_metadata": {"name": "unique", "kwargs": {"column_name": "eligibility_id", "model": "{{ get_where_subquery(ref('core__eligibility')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__encounter_encounter_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__encounter_encounter_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792", "fqn": ["the_tuva_project", "core", "unique_core__encounter_encounter_id"], "alias": "unique_core__encounter_encounter_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623957.835722, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__encounter_encounter_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n encounter_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.encounter\nwhere encounter_id is not null\ngroup by encounter_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "encounter_id", "file_key_name": "models.core__encounter", "attached_node": "model.the_tuva_project.core__encounter", "test_metadata": {"name": "unique", "kwargs": {"column_name": "encounter_id", "model": "{{ get_where_subquery(ref('core__encounter')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__lab_result_lab_result_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__lab_result_lab_result_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af", "fqn": ["the_tuva_project", "core", "unique_core__lab_result_lab_result_id"], "alias": "unique_core__lab_result_lab_result_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.8366349, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__lab_result"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__lab_result_lab_result_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n lab_result_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.lab_result\nwhere lab_result_id is not null\ngroup by lab_result_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "lab_result_id", "file_key_name": "models.core__lab_result", "attached_node": "model.the_tuva_project.core__lab_result", "test_metadata": {"name": "unique", "kwargs": {"column_name": "lab_result_id", "model": "{{ get_where_subquery(ref('core__lab_result')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__location_location_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__location_location_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a", "fqn": ["the_tuva_project", "core", "unique_core__location_location_id"], "alias": "unique_core__location_location_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.837709, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__location"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__location_location_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n location_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.location\nwhere location_id is not null\ngroup by location_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "location_id", "file_key_name": "models.core__location", "attached_node": "model.the_tuva_project.core__location", "test_metadata": {"name": "unique", "kwargs": {"column_name": "location_id", "model": "{{ get_where_subquery(ref('core__location')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__medication_medication_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__medication_medication_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1", "fqn": ["the_tuva_project", "core", "unique_core__medication_medication_id"], "alias": "unique_core__medication_medication_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.839435, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__medication_medication_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n medication_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.medication\nwhere medication_id is not null\ngroup by medication_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "medication_id", "file_key_name": "models.core__medication", "attached_node": "model.the_tuva_project.core__medication", "test_metadata": {"name": "unique", "kwargs": {"column_name": "medication_id", "model": "{{ get_where_subquery(ref('core__medication')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__observation_observation_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__observation_observation_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59", "fqn": ["the_tuva_project", "core", "unique_core__observation_observation_id"], "alias": "unique_core__observation_observation_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.8400981, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__observation_observation_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n observation_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.observation\nwhere observation_id is not null\ngroup by observation_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "observation_id", "file_key_name": "models.core__observation", "attached_node": "model.the_tuva_project.core__observation", "test_metadata": {"name": "unique", "kwargs": {"column_name": "observation_id", "model": "{{ get_where_subquery(ref('core__observation')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__patient_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__patient_patient_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e", "fqn": ["the_tuva_project", "core", "unique_core__patient_patient_id"], "alias": "unique_core__patient_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "ERROR"}, "created_at": 1729623957.8407621, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"error\") }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__patient_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.patient\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.core__patient", "attached_node": "model.the_tuva_project.core__patient", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__pharmacy_claim_pharmacy_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__pharmacy_claim_pharmacy_claim_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c", "fqn": ["the_tuva_project", "core", "unique_core__pharmacy_claim_pharmacy_claim_id"], "alias": "unique_core__pharmacy_claim_pharmacy_claim_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "ERROR"}, "created_at": 1729623957.841524, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"error\") }}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__pharmacy_claim_pharmacy_claim_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n pharmacy_claim_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.pharmacy_claim\nwhere pharmacy_claim_id is not null\ngroup by pharmacy_claim_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "pharmacy_claim_id", "file_key_name": "models.core__pharmacy_claim", "attached_node": "model.the_tuva_project.core__pharmacy_claim", "test_metadata": {"name": "unique", "kwargs": {"column_name": "pharmacy_claim_id", "model": "{{ get_where_subquery(ref('core__pharmacy_claim')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__practitioner_practitioner_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__practitioner_practitioner_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6", "fqn": ["the_tuva_project", "core", "unique_core__practitioner_practitioner_id"], "alias": "unique_core__practitioner_practitioner_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.842195, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__practitioner"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__practitioner_practitioner_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n practitioner_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.practitioner\nwhere practitioner_id is not null\ngroup by practitioner_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "practitioner_id", "file_key_name": "models.core__practitioner", "attached_node": "model.the_tuva_project.core__practitioner", "test_metadata": {"name": "unique", "kwargs": {"column_name": "practitioner_id", "model": "{{ get_where_subquery(ref('core__practitioner')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__procedure_procedure_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__procedure_procedure_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5", "fqn": ["the_tuva_project", "core", "unique_core__procedure_procedure_id"], "alias": "unique_core__procedure_procedure_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623957.8428469, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__procedure_procedure_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n procedure_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.procedure\nwhere procedure_id is not null\ngroup by procedure_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "procedure_id", "file_key_name": "models.core__procedure", "attached_node": "model.the_tuva_project.core__procedure", "test_metadata": {"name": "unique", "kwargs": {"column_name": "procedure_id", "model": "{{ get_where_subquery(ref('core__procedure')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_data_quality__data_quality_test_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0.sql", "original_file_path": "models/data_quality/data_quality_models.yml", "unique_id": "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98", "fqn": ["the_tuva_project", "data_quality", "unique_data_quality__data_quality_test_summary_data_quality_check"], "alias": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0"}, "created_at": 1729623957.972969, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0\") }}", "language": "sql", "refs": [{"name": "data_quality__data_quality_test_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__data_quality_test_summary"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/data_quality_models.yml/unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.data_quality.data_quality_test_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__data_quality_test_summary", "attached_node": "model.the_tuva_project.data_quality__data_quality_test_summary", "test_metadata": {"name": "unique", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__data_quality_test_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_data_quality__data_quality_test_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670.sql", "original_file_path": "models/data_quality/data_quality_models.yml", "unique_id": "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084", "fqn": ["the_tuva_project", "data_quality", "not_null_data_quality__data_quality_test_summary_data_quality_check"], "alias": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670"}, "created_at": 1729623957.9737248, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670\") }}", "language": "sql", "refs": [{"name": "data_quality__data_quality_test_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__data_quality_test_summary"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/data_quality_models.yml/not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom cms_synthetic.data_quality.data_quality_test_summary\nwhere data_quality_check is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__data_quality_test_summary", "attached_node": "model.the_tuva_project.data_quality__data_quality_test_summary", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__data_quality_test_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_data_quality__analytics_checks_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a.sql", "original_file_path": "models/data_quality/data_quality_models.yml", "unique_id": "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0", "fqn": ["the_tuva_project", "data_quality", "unique_data_quality__analytics_checks_summary_data_quality_check"], "alias": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a"}, "created_at": 1729623957.9744031, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a\") }}", "language": "sql", "refs": [{"name": "data_quality__analytics_checks_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__analytics_checks_summary"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/data_quality_models.yml/unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.data_quality.analytics_checks_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__analytics_checks_summary", "attached_node": "model.the_tuva_project.data_quality__analytics_checks_summary", "test_metadata": {"name": "unique", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__analytics_checks_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_data_quality__analytics_checks_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a.sql", "original_file_path": "models/data_quality/data_quality_models.yml", "unique_id": "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a", "fqn": ["the_tuva_project", "data_quality", "not_null_data_quality__analytics_checks_summary_data_quality_check"], "alias": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a"}, "created_at": 1729623957.9750369, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a\") }}", "language": "sql", "refs": [{"name": "data_quality__analytics_checks_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__analytics_checks_summary"]}, "compiled_path": "../target/compiled/the_tuva_project/models/data_quality/data_quality_models.yml/not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom cms_synthetic.data_quality.analytics_checks_summary\nwhere data_quality_check is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__analytics_checks_summary", "attached_node": "model.the_tuva_project.data_quality__analytics_checks_summary", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__analytics_checks_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_cms_hcc__patient_risk_scores_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_cms_hcc__patient_risk_scores_patient_id.sql", "original_file_path": "models/cms_hcc/cms_hcc_models.yml", "unique_id": "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126", "fqn": ["the_tuva_project", "cms_hcc", "unique_cms_hcc__patient_risk_scores_patient_id"], "alias": "unique_cms_hcc__patient_risk_scores_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623958.5261161, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_scores"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/cms_hcc_models.yml/unique_cms_hcc__patient_risk_scores_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.cms_hcc.patient_risk_scores\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.cms_hcc__patient_risk_scores", "attached_node": "model.the_tuva_project.cms_hcc__patient_risk_scores", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('cms_hcc__patient_risk_scores')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d.sql", "original_file_path": "models/cms_hcc/cms_hcc_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba", "fqn": ["the_tuva_project", "cms_hcc", "dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version"], "alias": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d"}, "created_at": 1729623958.526867, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d\") }}", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/cms_hcc_models.yml/dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, model_version\n from cms_synthetic.cms_hcc._int_demographic_factors\n group by patient_id, model_version\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.cms_hcc__int_demographic_factors", "attached_node": "model.the_tuva_project.cms_hcc__int_demographic_factors", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "model_version"], "model": "{{ get_where_subquery(ref('cms_hcc__int_demographic_factors')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_cms_hcc__int_eligible_conditions_condition_code", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_cms_hcc__int_eligible_conditions_condition_code.sql", "original_file_path": "models/cms_hcc/cms_hcc_models.yml", "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc", "fqn": ["the_tuva_project", "cms_hcc", "not_null_cms_hcc__int_eligible_conditions_condition_code"], "alias": "not_null_cms_hcc__int_eligible_conditions_condition_code", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623958.5294662, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__int_eligible_conditions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/cms_hcc_models.yml/not_null_cms_hcc__int_eligible_conditions_condition_code.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition_code\nfrom cms_synthetic.cms_hcc._int_eligible_conditions\nwhere condition_code is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition_code", "file_key_name": "models.cms_hcc__int_eligible_conditions", "attached_node": "model.the_tuva_project.cms_hcc__int_eligible_conditions", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition_code", "model": "{{ get_where_subquery(ref('cms_hcc__int_eligible_conditions')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_cms_hcc__int_members_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_cms_hcc__int_members_patient_id.sql", "original_file_path": "models/cms_hcc/cms_hcc_models.yml", "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b", "fqn": ["the_tuva_project", "cms_hcc", "not_null_cms_hcc__int_members_patient_id"], "alias": "not_null_cms_hcc__int_members_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623958.53019, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__int_members", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_members"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/cms_hcc_models.yml/not_null_cms_hcc__int_members_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.cms_hcc._int_members\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.cms_hcc__int_members", "attached_node": "model.the_tuva_project.cms_hcc__int_members", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('cms_hcc__int_members')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_cms_hcc__int_members_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_cms_hcc__int_members_patient_id.sql", "original_file_path": "models/cms_hcc/cms_hcc_models.yml", "unique_id": "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb", "fqn": ["the_tuva_project", "cms_hcc", "unique_cms_hcc__int_members_patient_id"], "alias": "unique_cms_hcc__int_members_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729623958.530872, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__int_members", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_members"]}, "compiled_path": "../target/compiled/the_tuva_project/models/cms_hcc/cms_hcc_models.yml/unique_cms_hcc__int_members_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.cms_hcc._int_members\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.cms_hcc__int_members", "attached_node": "model.the_tuva_project.cms_hcc__int_members", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('cms_hcc__int_members')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df.sql", "original_file_path": "models/claims_preprocessing/claims_preprocessing_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d", "fqn": ["the_tuva_project", "claims_preprocessing", "dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number"], "alias": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df"}, "created_at": 1729623958.595419, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df\") }}", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/claims_preprocessing/claims_preprocessing_models.yml/dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n claim_id, claim_line_number\n from cms_synthetic.claims_preprocessing.normalized_input_medical_claim\n group by claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.normalized_input__medical_claim", "attached_node": "model.the_tuva_project.normalized_input__medical_claim", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["claim_id", "claim_line_number"], "model": "{{ get_where_subquery(ref('normalized_input__medical_claim')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__condition_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__condition_patient_id.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__condition_patient_id"], "alias": "not_null_quality_measures__stg_core__condition_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.0393229, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__condition"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__condition_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n) select patient_id\nfrom __dbt__cte___stg_condition\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__condition", "attached_node": "model.the_tuva_project.quality_measures__stg_core__condition", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__condition')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__encounter_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__encounter_patient_id.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__encounter_patient_id"], "alias": "not_null_quality_measures__stg_core__encounter_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.040051, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__encounter"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__encounter_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n) select patient_id\nfrom __dbt__cte___stg_encounter\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__encounter", "attached_node": "model.the_tuva_project.quality_measures__stg_core__encounter", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__encounter')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__medication_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__medication_patient_id.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__medication_patient_id"], "alias": "not_null_quality_measures__stg_core__medication_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.040724, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__medication_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n) select patient_id\nfrom __dbt__cte___stg_medication\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__medication", "attached_node": "model.the_tuva_project.quality_measures__stg_core__medication", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__medication')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__observation_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__observation_patient_id.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__observation_patient_id"], "alias": "not_null_quality_measures__stg_core__observation_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.041484, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__observation"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__observation_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n) select patient_id\nfrom __dbt__cte___stg_observation\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__observation", "attached_node": "model.the_tuva_project.quality_measures__stg_core__observation", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__observation')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__patient_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__patient_patient_id.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__patient_patient_id"], "alias": "not_null_quality_measures__stg_core__patient_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.0422678, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__patient_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n) select patient_id\nfrom __dbt__cte___stg_patient\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__patient_sex", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__patient_sex.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__patient_sex"], "alias": "not_null_quality_measures__stg_core__patient_sex", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.043065, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__patient_sex.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n) select sex\nfrom __dbt__cte___stg_patient\nwhere sex is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "sex", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "sex", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown", "resource_type": "test", "package_name": "the_tuva_project", "path": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b", "fqn": ["the_tuva_project", "quality_measures", "accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown"], "alias": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "warn", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "warn", "alias": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae"}, "created_at": 1729623959.043821, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\",alias=\"accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae.sql", "compiled": true, "compiled_code": "\n \n \n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), all_values as (\n\n select\n sex as value_field,\n count(*) as n_records\n\n from __dbt__cte___stg_patient\n group by sex\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'female','male','unknown'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "sex", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "accepted_values", "kwargs": {"values": ["female", "male", "unknown"], "column_name": "sex", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__patient_birth_date", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__patient_birth_date.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__patient_birth_date"], "alias": "not_null_quality_measures__stg_core__patient_birth_date", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.048728, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__patient_birth_date.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n) select birth_date\nfrom __dbt__cte___stg_patient\nwhere birth_date is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "birth_date", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "birth_date", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__procedure_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__procedure_patient_id.sql", "original_file_path": "models/quality_measures/quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__procedure_patient_id"], "alias": "not_null_quality_measures__stg_core__procedure_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729623959.0494452, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "../target/compiled/the_tuva_project/models/quality_measures/quality_measures_models.yml/not_null_quality_measures__stg_core__procedure_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n) select patient_id\nfrom __dbt__cte___stg_procedure\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__procedure", "attached_node": "model.the_tuva_project.quality_measures__stg_core__procedure", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__procedure')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd.sql", "original_file_path": "models/financial_pmpm/financial_pmpm_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23", "fqn": ["the_tuva_project", "financial_pmpm", "dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_"], "alias": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd"}, "created_at": 1729623959.157644, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd\") }}", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery", "macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "../target/compiled/the_tuva_project/models/financial_pmpm/financial_pmpm_models.yml/dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, year_month, plan\n from cms_synthetic.financial_pmpm.pmpm_prep\n group by patient_id, year_month, plan\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.financial_pmpm__pmpm_prep", "attached_node": "model.the_tuva_project.financial_pmpm__pmpm_prep", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "year_month", "{{ quote_column('plan') }}"], "model": "{{ get_where_subquery(ref('financial_pmpm__pmpm_prep')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_chronic_conditions__cms_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586", "fqn": ["the_tuva_project", "chronic_conditions", "unique_chronic_conditions__cms_chronic_conditions_wide_patient_id"], "alias": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2"}, "created_at": 1729623959.218657, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id"], "alias": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c"}, "created_at": 1729623959.219546, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_long_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_long_patient_id"], "alias": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53"}, "created_at": 1729623959.220254, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_long\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_long_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_long_claim_id"], "alias": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4"}, "created_at": 1729623959.221014, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_long\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_long_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_long_condition"], "alias": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf"}, "created_at": 1729623959.221765, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_long\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d", "fqn": ["the_tuva_project", "chronic_conditions", "dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition"], "alias": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3"}, "created_at": 1729623959.222454, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, claim_id, start_date, condition\n from cms_synthetic.chronic_conditions.cms_chronic_conditions_long\n group by patient_id, claim_id, start_date, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "claim_id", "start_date", "condition"], "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_all_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_all_patient_id"], "alias": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c"}, "created_at": 1729623959.224745, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_all", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_all')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_all_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_all_claim_id"], "alias": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9"}, "created_at": 1729623959.22542, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_all", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_all')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_all_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_all_condition"], "alias": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c"}, "created_at": 1729623959.226076, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_all", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_all')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id"], "alias": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d"}, "created_at": 1729623959.226887, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id"], "alias": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827"}, "created_at": 1729623959.227699, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition"], "alias": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785"}, "created_at": 1729623959.228734, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_", "resource_type": "test", "package_name": "the_tuva_project", "path": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6", "fqn": ["the_tuva_project", "chronic_conditions", "accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_"], "alias": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f"}, "created_at": 1729623959.2295082, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "accepted_values", "kwargs": {"values": ["Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)"], "column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id"], "alias": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741"}, "created_at": 1729623959.232325, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id"], "alias": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e"}, "created_at": 1729623959.233214, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_oud_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_oud_condition"], "alias": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4"}, "created_at": 1729623959.233911, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_", "resource_type": "test", "package_name": "the_tuva_project", "path": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e.sql", "original_file_path": "models/chronic_conditions/cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5", "fqn": ["the_tuva_project", "chronic_conditions", "accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_"], "alias": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e"}, "created_at": 1729623959.234567, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/cms_chronic_conditions_models.yml/accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Opioid Use Disorder (OUD)'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "accepted_values", "kwargs": {"values": ["Opioid Use Disorder (OUD)"], "column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c.sql", "original_file_path": "models/chronic_conditions/tuva_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2", "fqn": ["the_tuva_project", "chronic_conditions", "dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition"], "alias": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c"}, "created_at": 1729623959.2522979, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/tuva_chronic_conditions_models.yml/dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, condition\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n group by patient_id, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__tuva_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "condition"], "model": "{{ get_where_subquery(ref('chronic_conditions__tuva_chronic_conditions_long')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550.sql", "original_file_path": "models/chronic_conditions/tuva_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158", "fqn": ["the_tuva_project", "chronic_conditions", "unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id"], "alias": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550"}, "created_at": 1729623959.254318, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/tuva_chronic_conditions_models.yml/unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__tuva_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__tuva_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4.sql", "original_file_path": "models/chronic_conditions/tuva_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id"], "alias": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4"}, "created_at": 1729623959.255133, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"]}, "compiled_path": "../target/compiled/the_tuva_project/models/chronic_conditions/tuva_chronic_conditions_models.yml/not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__tuva_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__tuva_chronic_conditions_wide')) }}"}, "namespace": null}}, "model.the_tuva_project.core__medical_claim": {"database": "cms_synthetic", "schema": "core", "name": "core__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core/final/core__medical_claim.sql", "original_file_path": "models/core/final/core__medical_claim.sql", "unique_id": "model.the_tuva_project.core__medical_claim", "fqn": ["the_tuva_project", "core", "final", "core__medical_claim"], "alias": "medical_claim", "checksum": {"name": "sha256", "checksum": "41428bc0eb9047a2b8a1eec6c3d57d9b04073f32fda2e28989dc59c2f23aebb7"}, "config": {"enabled": true, "alias": "medical_claim", "schema": "core", "database": null, "tags": ["core", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core", "encounters"], "description": "The medical claim table contains information on services rendered to patients and billed by the provider to the insurer as claims.\n", "columns": {"medical_claim_id": {"name": "medical_claim_id", "description": "Unique identifier for each row in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__claim_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "The date when the healthcare service was provided. Format: YYYY-MM-DD.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_start_date": {"name": "claim_line_start_date", "description": "Start date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_end_date": {"name": "claim_line_end_date", "description": "End date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "Admission date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Discharge date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_1": {"name": "service_category_1", "description": "The broader service category this claim belongs to.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/service_categories/service_category__service_categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_2": {"name": "service_category_2", "description": "The more specific service category this claim belongs to.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/service_categories/service_category__service_categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_3": {"name": "service_category_3", "description": "The most specific service category this claim belongs to.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Place of service for the claim (professional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__place_of_service.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_description": {"name": "place_of_service_description", "description": "Place of service description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__bill_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_description": {"name": "bill_type_description", "description": "Bill type description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code for the claim line (institutional only and typically multiple codes per claim).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__revenue_center.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_description": {"name": "revenue_center_description", "description": "Revenue center description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_unit_quantity": {"name": "service_unit_quantity", "description": "The number of units for the particular revenue center code.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "The CPT or HCPCS code representing the procedure or service provided. These codes are used to describe medical, surgical, and diagnostic services.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "1st modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "2nd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "3rd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "4th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "5th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_id": {"name": "rendering_id", "description": "Rendering ID for the claim (typically represents the physician or entity providing services).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_tin": {"name": "rendering_tin", "description": "Rendering provider tax identification number (TIN).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_name": {"name": "rendering_name", "description": "Rendering provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_id": {"name": "billing_id", "description": "Billing ID for the claim (typically represents organization billing the claim).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_tin": {"name": "billing_tin", "description": "Billing provider tax identification number (TIN).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_name": {"name": "billing_name", "description": "Billing provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_cost_amount": {"name": "total_cost_amount", "description": "The total amount paid on the claim by different parties.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_flag": {"name": "enrollment_flag", "description": "Flag indicating if the claim has corresponding enrollment during the same time period the service occurred.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models/core/core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "medical_claim", "tags": ["core", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729624485.09048, "relation_name": "cms_synthetic.core.medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect * from {{ ref('core__stg_claims_medical_claim')}}", "language": "sql", "refs": [{"name": "core__stg_claims_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/final/core__medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708": {"database": "cms_synthetic", "schema": "dbt_test__audit", "name": "unique_core__medical_claim_medical_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__medical_claim_medical_claim_id.sql", "original_file_path": "models/core/core_models.yml", "unique_id": "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708", "fqn": ["the_tuva_project", "core", "unique_core__medical_claim_medical_claim_id"], "alias": "unique_core__medical_claim_medical_claim_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "ERROR"}, "created_at": 1729624485.130869, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"error\") }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "../target/compiled/the_tuva_project/models/core/core_models.yml/unique_core__medical_claim_medical_claim_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n medical_claim_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.medical_claim\nwhere medical_claim_id is not null\ngroup by medical_claim_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "medical_claim_id", "file_key_name": "models.core__medical_claim", "attached_node": "model.the_tuva_project.core__medical_claim", "test_metadata": {"name": "unique", "kwargs": {"column_name": "medical_claim_id", "model": "{{ get_where_subquery(ref('core__medical_claim')) }}"}, "namespace": null}}}, "sources": {}, "macros": {"macro.input_layer.try_to_cast_date": {"name": "try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/try_to_cast_date.sql", "original_file_path": "../macros/try_to_cast_date.sql", "unique_id": "macro.input_layer.try_to_cast_date", "macro_sql": "\r\n\r\n{%- macro try_to_cast_date(column_name, date_format='YYYY-MM-DD') -%}\r\n\r\n {{ return(adapter.dispatch('try_to_cast_date')(column_name, date_format)) }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.input_layer.snowflake__try_to_cast_date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.267564, "supported_languages": null}, "macro.input_layer.bigquery__try_to_cast_date": {"name": "bigquery__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/try_to_cast_date.sql", "original_file_path": "../macros/try_to_cast_date.sql", "unique_id": "macro.input_layer.bigquery__try_to_cast_date", "macro_sql": "{%- macro bigquery__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n safe_cast( date( {{ column_name }} ) as date )\r\n {%- else -%}\r\n safe_cast( {{ column_name }} as date )\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.26778, "supported_languages": null}, "macro.input_layer.default__try_to_cast_date": {"name": "default__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/try_to_cast_date.sql", "original_file_path": "../macros/try_to_cast_date.sql", "unique_id": "macro.input_layer.default__try_to_cast_date", "macro_sql": "{%- macro default__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2678962, "supported_languages": null}, "macro.input_layer.postgres__try_to_cast_date": {"name": "postgres__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/try_to_cast_date.sql", "original_file_path": "../macros/try_to_cast_date.sql", "unique_id": "macro.input_layer.postgres__try_to_cast_date", "macro_sql": "{%- macro postgres__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {{ dbt.safe_cast(column_name, api.Column.translate_type(\"date\")).strip() }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2680802, "supported_languages": null}, "macro.input_layer.redshift__try_to_cast_date": {"name": "redshift__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/try_to_cast_date.sql", "original_file_path": "../macros/try_to_cast_date.sql", "unique_id": "macro.input_layer.redshift__try_to_cast_date", "macro_sql": "{%- macro redshift__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYYMMDD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}\\\\d{2}\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYYMMDD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'MM/DD/YYYY' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{2}/\\\\d{2}/\\\\d{4}'\r\n then to_date( {{ column_name }}, 'MM/DD/YYYY')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD HH:MI:SS')\r\n else date(NULL)\r\n end\r\n {%- else -%}\r\n date(NULL)\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.268793, "supported_languages": null}, "macro.input_layer.snowflake__try_to_cast_date": {"name": "snowflake__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/try_to_cast_date.sql", "original_file_path": "../macros/try_to_cast_date.sql", "unique_id": "macro.input_layer.snowflake__try_to_cast_date", "macro_sql": "{%- macro snowflake__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.26893, "supported_languages": null}, "macro.input_layer.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "input_layer", "path": "../macros/generate_schema_name.sql", "original_file_path": "../macros/generate_schema_name.sql", "unique_id": "macro.input_layer.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\r\n {%- set default_schema = target.schema -%}\r\n {%- if custom_schema_name is not none -%}\r\n {{ custom_schema_name | trim }}\r\n {%- else -%}\r\n {{ default_schema }}\r\n {%- endif -%}\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2693, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog": {"name": "snowflake__get_catalog", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog", "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.274104, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_relations": {"name": "snowflake__get_catalog_relations", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations", "macro_sql": "{% macro snowflake__get_catalog_relations(information_schema, relations) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.27442, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_tables_sql": {"name": "snowflake__get_catalog_tables_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro_sql": "{% macro snowflake__get_catalog_tables_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n case\n when is_dynamic = 'YES' and table_type = 'BASE TABLE' THEN 'DYNAMIC TABLE'\n else table_type\n end as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n from {{ information_schema }}.tables\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2746072, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_columns_sql": {"name": "snowflake__get_catalog_columns_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro_sql": "{% macro snowflake__get_catalog_columns_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n from {{ information_schema }}.columns\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.274892, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_results_sql": {"name": "snowflake__get_catalog_results_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro_sql": "{% macro snowflake__get_catalog_results_sql() -%}\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n order by \"column_index\"\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.274972, "supported_languages": null}, "macro.dbt_snowflake.snowflake__catalog_equals": {"name": "snowflake__catalog_equals", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__catalog_equals", "macro_sql": "{% macro snowflake__catalog_equals(field, value) %}\n \"{{ field }}\" ilike '{{ value }}' and upper(\"{{ field }}\") = upper('{{ value }}')\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2751129, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql": {"name": "snowflake__get_catalog_schemas_where_clause_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", "macro_sql": "{% macro snowflake__get_catalog_schemas_where_clause_sql(schemas) -%}\n where ({%- for schema in schemas -%}\n ({{ snowflake__catalog_equals('table_schema', schema) }}){%- if not loop.last %} or {% endif -%}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__catalog_equals"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2753248, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql": {"name": "snowflake__get_catalog_relations_where_clause_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", "macro_sql": "{% macro snowflake__get_catalog_relations_where_clause_sql(relations) -%}\n where (\n {%- for relation in relations -%}\n {% if relation.schema and relation.identifier %}\n (\n {{ snowflake__catalog_equals('table_schema', relation.schema) }}\n and {{ snowflake__catalog_equals('table_name', relation.identifier) }}\n )\n {% elif relation.schema %}\n (\n {{ snowflake__catalog_equals('table_schema', relation.schema) }}\n )\n {% else %}\n {% do exceptions.raise_compiler_error(\n '`get_catalog_relations` requires a list of relations, each with a schema'\n ) %}\n {% endif %}\n\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__catalog_equals"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.275742, "supported_languages": null}, "macro.dbt_snowflake.get_column_comment_sql": {"name": "get_column_comment_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.get_column_comment_sql", "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.288552, "supported_languages": null}, "macro.dbt_snowflake.get_persist_docs_column_list": {"name": "get_persist_docs_column_list", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.288787, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_columns_in_relation": {"name": "snowflake__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation.render() }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation.render() }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.289429, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_schemas": {"name": "snowflake__list_schemas", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__list_schemas", "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.290019, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_paginated_relations_array": {"name": "snowflake__get_paginated_relations_array", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_paginated_relations_array", "macro_sql": "{% macro snowflake__get_paginated_relations_array(max_iter, max_results_per_iter, max_total_results, schema_relation, watermark) %}\n\n {% set paginated_relations = [] %}\n\n {% for _ in range(0, max_iter) %}\n\n {% if schema_relation is string %}\n {%- set paginated_sql -%}\n show objects in {{ schema_relation }} limit {{ max_results_per_iter }} from '{{ watermark.table_name }}'\n {%- endset -%}\n {% else %}\n {%- set paginated_sql -%}\n show objects in {{ schema_relation.include(identifier=False) }} limit {{ max_results_per_iter }} from '{{ watermark.table_name }}'\n {%- endset -%}\n {% endif -%}\n\n {%- set paginated_result = run_query(paginated_sql) %}\n {%- set paginated_n = (paginated_result | length) -%}\n\n {#\n terminating condition: if there are 0 records in the result we reached\n the end exactly on the previous iteration\n #}\n {%- if paginated_n == 0 -%}\n {%- break -%}\n {%- endif -%}\n\n {#\n terminating condition: At some point the user needs to be reasonable with how\n many objects are contained in their schemas. Since there was already\n one iteration before attempting pagination, loop.index == max_iter means\n the limit has been surpassed.\n #}\n\n {%- if loop.index == max_iter -%}\n {%- set msg -%}\n dbt will list a maximum of {{ max_total_results }} objects in schema {{ schema_relation }}.\n Your schema exceeds this limit. Please contact support@getdbt.com for troubleshooting tips,\n or review and reduce the number of objects contained.\n {%- endset -%}\n\n {% do exceptions.raise_compiler_error(msg) %}\n {%- endif -%}\n\n {%- do paginated_relations.append(paginated_result) -%}\n {% set watermark.table_name = paginated_result.columns[1].values()[-1] %}\n\n {#\n terminating condition: paginated_n < max_results_per_iter means we reached the end\n #}\n {%- if paginated_n < max_results_per_iter -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n\n {{ return(paginated_relations) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.291054, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_relations_without_caching": {"name": "snowflake__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation, max_iter=10, max_results_per_iter=10000) %}\n\n {%- set max_total_results = max_results_per_iter * max_iter -%}\n {% if schema_relation is string %}\n {%- set sql -%}\n show objects in {{ schema_relation }} limit {{ max_results_per_iter }}\n {%- endset -%}\n {% else %}\n {%- set sql -%}\n show objects in {{ schema_relation.include(identifier=False) }} limit {{ max_results_per_iter }}\n {%- endset -%}\n {% endif -%}\n\n {%- set result = run_query(sql) -%}\n\n {%- set n = (result | length) -%}\n {%- set watermark = namespace(table_name=result.columns[1].values()[-1]) -%}\n {%- set paginated = namespace(result=[]) -%}\n\n {% if n >= max_results_per_iter %}\n\n {% set paginated.result = snowflake__get_paginated_relations_array(\n max_iter,\n max_results_per_iter,\n max_total_results,\n schema_relation,\n watermark\n )\n %}\n\n {% endif %}\n\n {%- set all_results_array = [result] + paginated.result -%}\n {%- set result = result.merge(all_results_array) -%}\n {%- do return(result) -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_snowflake.snowflake__get_paginated_relations_array"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2919512, "supported_languages": null}, "macro.dbt_snowflake.snowflake__check_schema_exists": {"name": "snowflake__check_schema_exists", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2922251, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_type": {"name": "snowflake__alter_column_type", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation.render() }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2927082, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_comment": {"name": "snowflake__alter_relation_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n {%- if relation.is_dynamic_table -%}\n {%- set relation_type = 'dynamic table' -%}\n {%- else -%}\n {%- set relation_type = relation.type -%}\n {%- endif -%}\n comment on {{ relation_type }} {{ relation.render() }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.293036, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_comment": {"name": "snowflake__alter_column_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n alter {{ relation_type }} {{ relation.render() }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.293569, "supported_languages": null}, "macro.dbt_snowflake.get_current_query_tag": {"name": "get_current_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.get_current_query_tag", "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2937138, "supported_languages": null}, "macro.dbt_snowflake.set_query_tag": {"name": "set_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__set_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2938392, "supported_languages": null}, "macro.dbt_snowflake.snowflake__set_query_tag": {"name": "snowflake__set_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_current_query_tag", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2942238, "supported_languages": null}, "macro.dbt_snowflake.unset_query_tag": {"name": "unset_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.unset_query_tag", "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.294369, "supported_languages": null}, "macro.dbt_snowflake.snowflake__unset_query_tag": {"name": "snowflake__unset_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.294754, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": {"name": "snowflake__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"dynamic table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation.render() }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation.render() }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2954729, "supported_languages": null}, "macro.dbt_snowflake.snowflake_dml_explicit_transaction": {"name": "snowflake_dml_explicit_transaction", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.295657, "supported_languages": null}, "macro.dbt_snowflake.snowflake__truncate_relation": {"name": "snowflake__truncate_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation.render() }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.295865, "supported_languages": null}, "macro.dbt_snowflake.snowflake__copy_grants": {"name": "snowflake__copy_grants", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "unique_id": "macro.dbt_snowflake.snowflake__copy_grants", "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.296148, "supported_languages": null}, "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": {"name": "snowflake__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.296244, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_relation_last_modified": {"name": "snowflake__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/metadata.sql", "original_file_path": "macros/metadata.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_relation_last_modified", "macro_sql": "{% macro snowflake__get_relation_last_modified(information_schema, relations) -%}\n\n {%- call statement('last_modified', fetch_result=True) -%}\n select table_schema as schema,\n table_name as identifier,\n last_altered as last_modified,\n {{ current_timestamp() }} as snapshotted_at\n from {{ information_schema }}.tables\n where (\n {%- for relation in relations -%}\n (upper(table_schema) = upper('{{ relation.schema }}') and\n upper(table_name) = upper('{{ relation.identifier }}')){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n {%- endcall -%}\n\n {{ return(load_result('last_modified')) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.296842, "supported_languages": null}, "macro.dbt_snowflake.materialization_test_snowflake": {"name": "materialization_test_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/test.sql", "original_file_path": "macros/materializations/test.sql", "unique_id": "macro.dbt_snowflake.materialization_test_snowflake", "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_test_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.297141, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__get_merge_sql": {"name": "snowflake__get_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.default__get_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2985442, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": {"name": "snowflake__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2987971, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_merge_sql": {"name": "snowflake__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.2989929, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_incremental_append_sql": {"name": "snowflake__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_append_sql", "macro_sql": "{% macro snowflake__get_incremental_append_sql(get_incremental_append_sql) %}\n {% set dml = default__get_incremental_append_sql(get_incremental_append_sql) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.299152, "supported_languages": null}, "macro.dbt_snowflake.snowflake__load_csv_rows": {"name": "snowflake__load_csv_rows", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3013031, "supported_languages": null}, "macro.dbt_snowflake.materialization_seed_snowflake": {"name": "materialization_seed_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_seed_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.301682, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_view_snowflake": {"name": "materialization_view_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "unique_id": "macro.dbt_snowflake.materialization_view_snowflake", "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = snowflake__create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {% do return(to_return) %}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt_snowflake.snowflake__create_or_replace_view", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3021498, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_table_snowflake": {"name": "materialization_table_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_snowflake.materialization_table_snowflake", "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3041432, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.py_write_table": {"name": "py_write_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_snowflake.py_write_table", "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False, table_type=none) %}\n{#- The following logic is only for backwards-compatiblity with deprecated `temporary` parameter -#}\n{% if table_type is not none %}\n {#- Just use the table_type as-is -#}\n{% elif temporary -%}\n {#- Case 1 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {%- set table_type = \"temporary\" -%}\n{% else %}\n {#- Case 2 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {#- Snowflake treats \"\" as meaning \"permanent\" -#}\n {%- set table_type = \"\" -%}\n{%- endif %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n session.use_database(target_relation.database)\n session.use_schema(target_relation.schema)\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n {% set target_relation_name = resolve_model_name(target_relation) %}\n df.write.mode(\"overwrite\").save_as_table('{{ target_relation_name }}', table_type='{{table_type}}')\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3045728, "supported_languages": null}, "macro.dbt_snowflake.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_snowflake.py_script_comment", "macro_sql": "{% macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.304675, "supported_languages": null}, "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": {"name": "dbt_snowflake_get_tmp_relation_type", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n{%- set tmp_relation_type = config.get('tmp_relation_type') -%}\n /* {#\n High-level principles:\n If we are running multiple statements (DELETE + INSERT),\n and we want to guarantee identical inputs to both statements,\n then we must first save the model query results as a temporary table\n (which presumably comes with a performance cost).\n If we are running a single statement (MERGE or INSERT alone),\n we _may_ save the model query definition as a view instead,\n for (presumably) faster overall incremental processing.\n\n Low-level specifics:\n If an invalid option is specified, then we will raise an\n excpetion with corresponding message.\n\n Languages other than SQL (like Python) will use a temporary table.\n With the default strategy of merge, the user may choose between a temporary\n table and view (defaulting to view).\n\n The append strategy can use a view because it will run a single INSERT statement.\n\n When unique_key is none, the delete+insert strategy can use a view beacuse a\n single INSERT statement is run with no DELETES as part of the statement.\n Otherwise, play it safe by using a temporary table.\n #} */\n\n {% if language == \"python\" and tmp_relation_type is not none %}\n {% do exceptions.raise_compiler_error(\n \"Python models currently only support 'table' for tmp_relation_type but \"\n ~ tmp_relation_type ~ \" was specified.\"\n ) %}\n {% endif %}\n\n {% if strategy == \"delete+insert\" and tmp_relation_type is not none and tmp_relation_type != \"table\" and unique_key is not none %}\n {% do exceptions.raise_compiler_error(\n \"In order to maintain consistent results when `unique_key` is not none,\n the `delete+insert` strategy only supports `table` for `tmp_relation_type` but \"\n ~ tmp_relation_type ~ \" was specified.\"\n )\n %}\n {% endif %}\n\n {% if language != \"sql\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"table\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"view\" %}\n {{ return(\"view\") }}\n {% elif strategy in (\"default\", \"merge\", \"append\") %}\n {{ return(\"view\") }}\n {% elif strategy == \"delete+insert\" and unique_key is none %}\n {{ return(\"view\") }}\n {% else %}\n {{ return(\"table\") }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3070521, "supported_languages": null}, "macro.dbt_snowflake.materialization_incremental_snowflake": {"name": "materialization_incremental_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ snowflake__create_view_as_with_temp_flag(tmp_relation, compiled_code, True) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.should_full_refresh", "macro.dbt.load_relation", "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro.dbt.make_temp_relation", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", "macro.dbt.process_schema_changes", "macro.dbt.drop_relation_if_exists", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.309932, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.snowflake__get_incremental_default_sql": {"name": "snowflake__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.310118, "supported_languages": null}, "macro.dbt_snowflake.materialization_snapshot_snowflake": {"name": "materialization_snapshot_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_snapshot_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3104372, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_dynamic_table_snowflake": {"name": "materialization_dynamic_table_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.materialization_dynamic_table_snowflake", "macro_sql": "{% materialization dynamic_table, adapter='snowflake' %}\n\n {% set query_tag = set_query_tag() %}\n\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.DynamicTable) %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% set build_sql = dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% if build_sql == '' %}\n {{ dynamic_table_execute_no_op(target_relation) }}\n {% else %}\n {{ dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) }}\n {% endif %}\n\n {{ run_hooks(post_hooks) }}\n\n {% do unset_query_tag(query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.load_cached_relation", "macro.dbt.run_hooks", "macro.dbt_snowflake.dynamic_table_get_build_sql", "macro.dbt_snowflake.dynamic_table_execute_no_op", "macro.dbt_snowflake.dynamic_table_execute_build_sql", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.314445, "supported_languages": ["sql"]}, "macro.dbt_snowflake.dynamic_table_get_build_sql": {"name": "dynamic_table_get_build_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_get_build_sql", "macro_sql": "{% macro dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_dynamic_table %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = snowflake__get_dynamic_table_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"No configuration changes were identified on: `\" ~ target_relation ~ \"`. Continuing.\") }}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = snowflake__get_alter_dynamic_table_as_sql(existing_relation, configuration_changes, target_relation, sql) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'continue', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario: `\" ~ on_configuration_change ~ \"`\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_sql", "macro.dbt.get_replace_sql", "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.315469, "supported_languages": null}, "macro.dbt_snowflake.dynamic_table_execute_no_op": {"name": "dynamic_table_execute_no_op", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_execute_no_op", "macro_sql": "{% macro dynamic_table_execute_no_op(relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.31565, "supported_languages": null}, "macro.dbt_snowflake.dynamic_table_execute_build_sql": {"name": "dynamic_table_execute_build_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_execute_build_sql", "macro_sql": "{% macro dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3160179, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes": {"name": "snowflake__get_dynamic_table_configuration_changes", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", "macro_sql": "{% macro snowflake__get_dynamic_table_configuration_changes(existing_relation, new_config) -%}\n {% set _existing_dynamic_table = snowflake__describe_dynamic_table(existing_relation) %}\n {% set _configuration_changes = existing_relation.dynamic_table_config_changeset(_existing_dynamic_table, new_config.model) %}\n {% do return(_configuration_changes) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__describe_dynamic_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.316247, "supported_languages": null}, "macro.dbt_snowflake.snowflake__can_clone_table": {"name": "snowflake__can_clone_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/clone.sql", "original_file_path": "macros/materializations/clone.sql", "unique_id": "macro.dbt_snowflake.snowflake__can_clone_table", "macro_sql": "{% macro snowflake__can_clone_table() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.316454, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_or_replace_clone": {"name": "snowflake__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/clone.sql", "original_file_path": "macros/materializations/clone.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_clone", "macro_sql": "{% macro snowflake__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace\n {{ \"transient\" if config.get(\"transient\", true) }}\n table {{ this_relation }}\n clone {{ defer_relation }}\n {{ \"copy grants\" if config.get(\"copy_grants\", false) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3166752, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_sql": {"name": "snowflake__get_drop_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_sql", "macro_sql": "{% macro snowflake__get_drop_sql(relation) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_drop_dynamic_table_sql(relation) }}\n\n {% else %}\n {{ default__get_drop_sql(relation) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", "macro.dbt.default__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.316941, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_sql": {"name": "snowflake__get_replace_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_sql", "macro_sql": "{% macro snowflake__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {% if existing_relation.is_dynamic_table and target_relation.is_dynamic_table %}\n {{ snowflake__get_replace_dynamic_table_sql(target_relation, sql) }}\n\n {% else %}\n {{ default__get_replace_sql(existing_relation, target_relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", "macro.dbt.default__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.317271, "supported_languages": null}, "macro.dbt_snowflake.snowflake__rename_relation": {"name": "snowflake__rename_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__rename_relation", "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3174841, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_create_sql": {"name": "snowflake__get_create_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_create_sql", "macro_sql": "{% macro snowflake__get_create_sql(relation, sql) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_create_dynamic_table_as_sql(relation, sql) }}\n\n {% else %}\n {{ default__get_create_sql(relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", "macro.dbt.default__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.317771, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_table_sql": {"name": "snowflake__get_drop_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_table_sql", "macro_sql": "{% macro snowflake__get_drop_table_sql(relation) %}\n drop table if exists {{ relation }} cascade\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.318072, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_table_sql": {"name": "snowflake__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_table_sql", "macro_sql": "{% macro snowflake__get_replace_table_sql(relation, sql) %}\n {{ snowflake__create_table_as(False, relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.31825, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_rename_table_sql": {"name": "snowflake__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_rename_table_sql", "macro_sql": "{%- macro snowflake__get_rename_table_sql(relation, new_name) -%}\n alter table {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.31841, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_table_as": {"name": "snowflake__create_table_as", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_table_as", "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- set transient = config.get('transient', default=true) -%}\n\n {% if temporary -%}\n {%- set table_type = \"temporary\" -%}\n {%- elif transient -%}\n {%- set table_type = \"transient\" -%}\n {%- else -%}\n {%- set table_type = \"\" -%}\n {%- endif %}\n\n {%- if language == 'sql' -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {{ table_type }} table {{ relation }}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {% set compiled_code = get_select_subquery(compiled_code) %}\n {% endif %}\n {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from (\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, table_type=table_type) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery", "macro.dbt_snowflake.py_write_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.322112, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_view_sql": {"name": "snowflake__get_drop_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_view_sql", "macro_sql": "{% macro snowflake__get_drop_view_sql(relation) %}\n drop view if exists {{ relation }} cascade\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.322266, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_view_sql": {"name": "snowflake__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_view_sql", "macro_sql": "{% macro snowflake__get_replace_view_sql(relation, sql) %}\n {{ snowflake__create_view_as(relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3224, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_rename_view_sql": {"name": "snowflake__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_rename_view_sql", "macro_sql": "{%- macro snowflake__get_rename_view_sql(relation, new_name) -%}\n alter view {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3226109, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag": {"name": "snowflake__create_view_as_with_temp_flag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", "macro_sql": "{% macro snowflake__create_view_as_with_temp_flag(relation, sql, is_temporary=False) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} {% if is_temporary -%}\n temporary\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt_snowflake.get_persist_docs_column_list", "macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3241081, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as": {"name": "snowflake__create_view_as", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_view_as", "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {{ snowflake__create_view_as_with_temp_flag(relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3242218, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_or_replace_view": {"name": "snowflake__create_or_replace_view", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_view", "macro_sql": "{% macro snowflake__create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and not old_relation.is_view -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.325116, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql": {"name": "snowflake__get_drop_dynamic_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/drop.sql", "original_file_path": "macros/relations/dynamic_table/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", "macro_sql": "{% macro snowflake__get_drop_dynamic_table_sql(relation) %}\n drop dynamic table if exists {{ relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3252878, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql": {"name": "snowflake__get_replace_dynamic_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/replace.sql", "original_file_path": "macros/relations/dynamic_table/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", "macro_sql": "{% macro snowflake__get_replace_dynamic_table_sql(relation, sql) %}\n\n create or replace dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n ;\n {{ snowflake__refresh_dynamic_table(relation) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__refresh_dynamic_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3256488, "supported_languages": null}, "macro.dbt_snowflake.snowflake__describe_dynamic_table": {"name": "snowflake__describe_dynamic_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/describe.sql", "original_file_path": "macros/relations/dynamic_table/describe.sql", "unique_id": "macro.dbt_snowflake.snowflake__describe_dynamic_table", "macro_sql": "{% macro snowflake__describe_dynamic_table(relation) %}\n {%- set _dynamic_table_sql -%}\n show dynamic tables\n like '{{ relation.identifier }}'\n in schema {{ relation.database }}.{{ relation.schema }}\n ;\n select\n \"name\",\n \"schema_name\",\n \"database_name\",\n \"text\",\n \"target_lag\",\n \"warehouse\"\n from table(result_scan(last_query_id()))\n {%- endset %}\n {% set _dynamic_table = run_query(_dynamic_table_sql) %}\n\n {% do return({'dynamic_table': _dynamic_table}) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.326282, "supported_languages": null}, "macro.dbt_snowflake.snowflake__refresh_dynamic_table": {"name": "snowflake__refresh_dynamic_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/refresh.sql", "original_file_path": "macros/relations/dynamic_table/refresh.sql", "unique_id": "macro.dbt_snowflake.snowflake__refresh_dynamic_table", "macro_sql": "{% macro snowflake__refresh_dynamic_table(relation) -%}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n\n alter dynamic table {{ relation }} refresh\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.326442, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql": {"name": "snowflake__get_alter_dynamic_table_as_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/alter.sql", "original_file_path": "macros/relations/dynamic_table/alter.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql", "macro_sql": "{% macro snowflake__get_alter_dynamic_table_as_sql(\n existing_relation,\n configuration_changes,\n target_relation,\n sql\n) -%}\n {{- log('Applying ALTER to: ' ~ existing_relation) -}}\n\n {% if configuration_changes.requires_full_refresh %}\n {{- get_replace_sql(existing_relation, target_relation, sql) -}}\n\n {% else %}\n\n {%- set target_lag = configuration_changes.target_lag -%}\n {%- if target_lag -%}{{- log('Applying UPDATE TARGET_LAG to: ' ~ existing_relation) -}}{%- endif -%}\n {%- set snowflake_warehouse = configuration_changes.snowflake_warehouse -%}\n {%- if snowflake_warehouse -%}{{- log('Applying UPDATE WAREHOUSE to: ' ~ existing_relation) -}}{%- endif -%}\n\n alter dynamic table {{ existing_relation }} set\n {% if target_lag %}target_lag = '{{ target_lag.context }}'{% endif %}\n {% if snowflake_warehouse %}warehouse = {{ snowflake_warehouse.context }}{% endif %}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.327282, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql": {"name": "snowflake__get_create_dynamic_table_as_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/create.sql", "original_file_path": "macros/relations/dynamic_table/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", "macro_sql": "{% macro snowflake__get_create_dynamic_table_as_sql(relation, sql) -%}\n\n create dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.32757, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp": {"name": "snowflake__current_timestamp", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.327829, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_string_as_time": {"name": "snowflake__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.327989, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_get_time": {"name": "snowflake__snapshot_get_time", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.328075, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": {"name": "snowflake__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3281522, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": {"name": "snowflake__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3282502, "supported_languages": null}, "macro.dbt_snowflake.snowflake__escape_single_quotes": {"name": "snowflake__escape_single_quotes", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.328395, "supported_languages": null}, "macro.dbt_snowflake.snowflake__right": {"name": "snowflake__right", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt_snowflake.snowflake__right", "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.328577, "supported_languages": null}, "macro.dbt_snowflake.snowflake__safe_cast": {"name": "snowflake__safe_cast", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt_snowflake.snowflake__safe_cast", "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n {% if type|upper == \"GEOMETRY\" -%}\n try_to_geometry({{field}})\n {% elif type|upper == \"GEOGRAPHY\" -%}\n try_to_geography({{field}})\n {% elif type|upper != \"VARIANT\" -%}\n {#-- Snowflake try_cast does not support casting to variant, and expects the field as a string --#}\n {% set field_as_string = dbt.string_literal(field) if field is number else field %}\n try_cast({{field_as_string}} as {{type}})\n {% else -%}\n {{ adapter.dispatch('cast', 'dbt')(field, type) }}\n {% endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.string_literal", "macro.dbt.cast", "macro.dbt_snowflake.snowflake__cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.329122, "supported_languages": null}, "macro.dbt_snowflake.snowflake__cast": {"name": "snowflake__cast", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/cast.sql", "original_file_path": "macros/utils/cast.sql", "unique_id": "macro.dbt_snowflake.snowflake__cast", "macro_sql": "{% macro snowflake__cast(field, type) %}\n {% if (type|upper == \"GEOGRAPHY\") -%}\n to_geography({{field}})\n {% elif (type|upper == \"GEOMETRY\") -%}\n to_geometry({{field}})\n {% else -%}\n cast({{field}} as {{type}})\n {% endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.329447, "supported_languages": null}, "macro.dbt_snowflake.snowflake__bool_or": {"name": "snowflake__bool_or", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt_snowflake.snowflake__bool_or", "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.32955, "supported_languages": null}, "macro.dbt_snowflake.snowflake__array_construct": {"name": "snowflake__array_construct", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt_snowflake.snowflake__array_construct", "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.329676, "supported_languages": null}, "macro.dbt.run_hooks": {"name": "run_hooks", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3305442, "supported_languages": null}, "macro.dbt.make_hook_config": {"name": "make_hook_config", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.330687, "supported_languages": null}, "macro.dbt.before_begin": {"name": "before_begin", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.330786, "supported_languages": null}, "macro.dbt.in_transaction": {"name": "in_transaction", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3309178, "supported_languages": null}, "macro.dbt.after_commit": {"name": "after_commit", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3310258, "supported_languages": null}, "macro.dbt.set_sql_header": {"name": "set_sql_header", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.33135, "supported_languages": null}, "macro.dbt.should_full_refresh": {"name": "should_full_refresh", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3315709, "supported_languages": null}, "macro.dbt.should_store_failures": {"name": "should_store_failures", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.331899, "supported_languages": null}, "macro.dbt.snapshot_merge_sql": {"name": "snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.332453, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"name": "default__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n {%- set columns = config.get(\"snapshot_table_column_names\") or get_snapshot_table_column_names() -%}\n\n merge into {{ target.render() }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }}\n\n when matched\n and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_snapshot_table_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.332853, "supported_languages": null}, "macro.dbt.strategy_dispatch": {"name": "strategy_dispatch", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.335961, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"name": "snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3361018, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"name": "default__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3362718, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"name": "snapshot_timestamp_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, model_config, target_exists) %}\n {# The model_config parameter is no longer used, but is passed in anyway for compatibility. #}\n {% set primary_key = config.get('unique_key') %}\n {% set updated_at = config.get('updated_at') %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes') or false %}\n {% set columns = config.get(\"snapshot_table_column_names\") or get_snapshot_table_column_names() %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ columns.dbt_valid_from }} < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_snapshot_table_column_names", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.336885, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"name": "snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.33701, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"name": "default__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.337136, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"name": "snapshot_check_all_get_existing_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n {#-- N.B. The whitespace below is necessary to avoid edge case issue with comments --#}\n {#-- See: https://github.com/dbt-labs/dbt-core/issues/6781 --#}\n select {{ check_cols_config | join(', ') }} from (\n {{ node['compiled_code'] }}\n ) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.338132, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"name": "snapshot_check_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, model_config, target_exists) %}\n {# The model_config parameter is no longer used, but is passed in anyway for compatibility. #}\n {% set check_cols_config = config.get('check_cols') %}\n {% set primary_key = config.get('unique_key') %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes') or false %}\n {% set updated_at = config.get('updated_at') or snapshot_get_time() %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.339145, "supported_languages": null}, "macro.dbt.create_columns": {"name": "create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.346803, "supported_languages": null}, "macro.dbt.default__create_columns": {"name": "default__create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation.render() }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3470259, "supported_languages": null}, "macro.dbt.post_snapshot": {"name": "post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.34715, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"name": "default__post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.347218, "supported_languages": null}, "macro.dbt.get_true_sql": {"name": "get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.347521, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"name": "default__get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.347646, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"name": "snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.347806, "supported_languages": null}, "macro.dbt.get_snapshot_table_column_names": {"name": "get_snapshot_table_column_names", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.get_snapshot_table_column_names", "macro_sql": "{% macro get_snapshot_table_column_names() %}\n {{ return({'dbt_valid_to': 'dbt_valid_to', 'dbt_valid_from': 'dbt_valid_from', 'dbt_scd_id': 'dbt_scd_id', 'dbt_updated_at': 'dbt_updated_at'}) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.347975, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"name": "default__snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {% set columns = config.get('snapshot_table_column_names') or get_snapshot_table_column_names() %}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where {{ columns.dbt_valid_to }} is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as {{ columns.dbt_updated_at }},\n {{ strategy.updated_at }} as {{ columns.dbt_valid_from }},\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as {{ columns.dbt_valid_to }},\n {{ strategy.scd_id }} as {{ columns.dbt_scd_id }}\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as {{ columns.dbt_updated_at }},\n {{ strategy.updated_at }} as {{ columns.dbt_valid_from }},\n {{ strategy.updated_at }} as {{ columns.dbt_valid_to }}\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.{{ columns.dbt_scd_id }}\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as {{ columns.dbt_valid_from }},\n {{ snapshot_get_time() }} as {{ columns.dbt_updated_at }},\n {{ snapshot_get_time() }} as {{ columns.dbt_valid_to }},\n snapshotted_data.{{ columns.dbt_scd_id }}\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_snapshot_table_column_names", "macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.348928, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"name": "build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.349069, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"name": "default__build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n {% set columns = config.get('snapshot_table_column_names') or get_snapshot_table_column_names() %}\n\n select *,\n {{ strategy.scd_id }} as {{ columns.dbt_scd_id }},\n {{ strategy.updated_at }} as {{ columns.dbt_updated_at }},\n {{ strategy.updated_at }} as {{ columns.dbt_valid_from }},\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as {{ columns.dbt_valid_to }}\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_snapshot_table_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.349422, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3497841, "supported_languages": null}, "macro.dbt.get_updated_at_column_data_type": {"name": "get_updated_at_column_data_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.get_updated_at_column_data_type", "macro_sql": "{% macro get_updated_at_column_data_type(snapshot_sql) %}\n {% set snapshot_sql_column_schema = get_column_schema_from_query(snapshot_sql) %}\n {% set dbt_updated_at_data_type = null %}\n {% set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {% set ns.dbt_updated_at_data_type = null -%}\n {% for column in snapshot_sql_column_schema %}\n {% if ((column.column == 'dbt_updated_at') or (column.column == 'DBT_UPDATED_AT')) %}\n {% set ns.dbt_updated_at_data_type = column.dtype %}\n {% endif %}\n {% endfor %}\n {{ return(ns.dbt_updated_at_data_type or none) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3503559, "supported_languages": null}, "macro.dbt.check_time_data_types": {"name": "check_time_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.check_time_data_types", "macro_sql": "{% macro check_time_data_types(sql) %}\n {% set dbt_updated_at_data_type = get_updated_at_column_data_type(sql) %}\n {% set snapshot_get_time_data_type = get_snapshot_get_time_data_type() %}\n {% if snapshot_get_time_data_type is not none and dbt_updated_at_data_type is not none and snapshot_get_time_data_type != dbt_updated_at_data_type %}\n {% if exceptions.warn_snapshot_timestamp_data_types %}\n {{ exceptions.warn_snapshot_timestamp_data_types(snapshot_get_time_data_type, dbt_updated_at_data_type) }}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_updated_at_column_data_type", "macro.dbt.get_snapshot_get_time_data_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3507042, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"name": "materialization_snapshot_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot.sql", "original_file_path": "macros/materializations/snapshots/snapshot.sql", "unique_id": "macro.dbt.materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {# The model['config'] parameter below is no longer used, but passing anyway for compatibility #}\n {# It was a dictionary of config, instead of the config object from the context #}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", model['config'], target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set build_or_select_sql = build_sql %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {% set columns = config.get(\"snapshot_table_column_names\") or get_snapshot_table_column_names() %}\n\n {{ adapter.valid_snapshot_target(target_relation, columns) }}\n\n {% set build_or_select_sql = snapshot_staging_table(strategy, sql, target_relation) %}\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n\n {{ check_time_data_types(build_or_select_sql) }}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.get_snapshot_table_column_names", "macro.dbt.snapshot_staging_table", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.check_time_data_types", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.355659, "supported_languages": ["sql"]}, "macro.dbt.materialization_test_default": {"name": "materialization_test_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/test.sql", "original_file_path": "macros/materializations/tests/test.sql", "unique_id": "macro.dbt.materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% set store_failures_as = config.get('store_failures_as') %}\n -- if `--store-failures` is invoked via command line and `store_failures_as` is not set,\n -- config.get('store_failures_as', 'table') returns None, not 'table'\n {% if store_failures_as == none %}{% set store_failures_as = 'table' %}{% endif %}\n {% if store_failures_as not in ['table', 'view'] %}\n {{ exceptions.raise_compiler_error(\n \"'\" ~ store_failures_as ~ \"' is not a valid value for `store_failures_as`. \"\n \"Accepted values are: ['ephemeral', 'table', 'view']\"\n ) }}\n {% endif %}\n\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type=store_failures_as) -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ get_create_sql(target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.get_create_sql", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.357889, "supported_languages": ["sql"]}, "macro.dbt.get_test_sql": {"name": "get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.359021, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"name": "default__get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.359333, "supported_languages": null}, "macro.dbt.get_unit_test_sql": {"name": "get_unit_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.get_unit_test_sql", "macro_sql": "{% macro get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}\n {{ adapter.dispatch('get_unit_test_sql', 'dbt')(main_sql, expected_fixture_sql, expected_column_names) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_unit_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3595068, "supported_languages": null}, "macro.dbt.default__get_unit_test_sql": {"name": "default__get_unit_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.default__get_unit_test_sql", "macro_sql": "{% macro default__get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}\n-- Build actual result given inputs\nwith dbt_internal_unit_test_actual as (\n select\n {% for expected_column_name in expected_column_names %}{{expected_column_name}}{% if not loop.last -%},{% endif %}{%- endfor -%}, {{ dbt.string_literal(\"actual\") }} as {{ adapter.quote(\"actual_or_expected\") }}\n from (\n {{ main_sql }}\n ) _dbt_internal_unit_test_actual\n),\n-- Build expected result\ndbt_internal_unit_test_expected as (\n select\n {% for expected_column_name in expected_column_names %}{{expected_column_name}}{% if not loop.last -%}, {% endif %}{%- endfor -%}, {{ dbt.string_literal(\"expected\") }} as {{ adapter.quote(\"actual_or_expected\") }}\n from (\n {{ expected_fixture_sql }}\n ) _dbt_internal_unit_test_expected\n)\n-- Union actual and expected results\nselect * from dbt_internal_unit_test_actual\nunion all\nselect * from dbt_internal_unit_test_expected\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.360091, "supported_languages": null}, "macro.dbt.get_where_subquery": {"name": "get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.360424, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"name": "default__get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3606982, "supported_languages": null}, "macro.dbt.materialization_unit_default": {"name": "materialization_unit_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/unit.sql", "original_file_path": "macros/materializations/tests/unit.sql", "unique_id": "macro.dbt.materialization_unit_default", "macro_sql": "{%- materialization unit, default -%}\n\n {% set relations = [] %}\n\n {% set expected_rows = config.get('expected_rows') %}\n {% set expected_sql = config.get('expected_sql') %}\n {% set tested_expected_column_names = expected_rows[0].keys() if (expected_rows | length ) > 0 else get_columns_in_query(sql) %} %}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {% do run_query(get_create_table_as_sql(True, temp_relation, get_empty_subquery_sql(sql))) %}\n {%- set columns_in_relation = adapter.get_columns_in_relation(temp_relation) -%}\n {%- set column_name_to_data_types = {} -%}\n {%- for column in columns_in_relation -%}\n {%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}\n {%- endfor -%}\n\n {% if not expected_sql %}\n {% set expected_sql = get_expected_sql(expected_rows, column_name_to_data_types) %}\n {% endif %}\n {% set unit_test_sql = get_unit_test_sql(sql, expected_sql, tested_expected_column_names) %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ unit_test_sql }}\n\n {%- endcall %}\n\n {% do adapter.drop_relation(temp_relation) %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt.make_temp_relation", "macro.dbt.run_query", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_empty_subquery_sql", "macro.dbt.get_expected_sql", "macro.dbt.get_unit_test_sql", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3621151, "supported_languages": ["sql"]}, "macro.dbt.materialization_materialized_view_default": {"name": "materialization_materialized_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialization_materialized_view_default", "macro_sql": "{% materialization materialized_view, default %}\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.MaterializedView) %}\n {% set intermediate_relation = make_intermediate_relation(target_relation) %}\n {% set backup_relation_type = target_relation.MaterializedView if existing_relation is none else existing_relation.type %}\n {% set backup_relation = make_backup_relation(target_relation, backup_relation_type) %}\n\n {{ materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) }}\n\n {% set build_sql = materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% if build_sql == '' %}\n {{ materialized_view_execute_no_op(target_relation) }}\n {% else %}\n {{ materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) }}\n {% endif %}\n\n {{ materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.materialized_view_setup", "macro.dbt.materialized_view_get_build_sql", "macro.dbt.materialized_view_execute_no_op", "macro.dbt.materialized_view_execute_build_sql", "macro.dbt.materialized_view_teardown"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.367403, "supported_languages": ["sql"]}, "macro.dbt.materialized_view_setup": {"name": "materialized_view_setup", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_setup", "macro_sql": "{% macro materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) %}\n\n -- backup_relation and intermediate_relation should not already exist in the database\n -- it's possible these exist because of a previous run that exited unexpectedly\n {% set preexisting_backup_relation = load_cached_relation(backup_relation) %}\n {% set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.367698, "supported_languages": null}, "macro.dbt.materialized_view_teardown": {"name": "materialized_view_teardown", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_teardown", "macro_sql": "{% macro materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) %}\n\n -- drop the temp relations if they exist to leave the database clean for the next run\n {{ drop_relation_if_exists(backup_relation) }}\n {{ drop_relation_if_exists(intermediate_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.367881, "supported_languages": null}, "macro.dbt.materialized_view_get_build_sql": {"name": "materialized_view_get_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_get_build_sql", "macro_sql": "{% macro materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_materialized_view_as_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_materialized_view %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = get_materialized_view_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = refresh_materialized_view(target_relation) %}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation.render() ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation.render() ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_materialized_view_as_sql", "macro.dbt.get_replace_sql", "macro.dbt.get_materialized_view_configuration_changes", "macro.dbt.refresh_materialized_view", "macro.dbt.get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3688462, "supported_languages": null}, "macro.dbt.materialized_view_execute_no_op": {"name": "materialized_view_execute_no_op", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_no_op", "macro_sql": "{% macro materialized_view_execute_no_op(target_relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ target_relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.369065, "supported_languages": null}, "macro.dbt.materialized_view_execute_build_sql": {"name": "materialized_view_execute_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_build_sql", "macro_sql": "{% macro materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) %}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3695428, "supported_languages": null}, "macro.dbt.materialization_view_default": {"name": "materialization_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/view.sql", "original_file_path": "macros/materializations/models/view.sql", "unique_id": "macro.dbt.materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3721988, "supported_languages": ["sql"]}, "macro.dbt.materialization_table_default": {"name": "materialization_table_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/table.sql", "original_file_path": "macros/materializations/models/table.sql", "unique_id": "macro.dbt.materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.374818, "supported_languages": ["sql"]}, "macro.dbt.get_quoted_csv": {"name": "get_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.376402, "supported_languages": null}, "macro.dbt.diff_columns": {"name": "diff_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3768818, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"name": "diff_column_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.377394, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"name": "get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3777761, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"name": "default__get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.37831, "supported_languages": null}, "macro.dbt.get_merge_sql": {"name": "get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n -- back compat for old kwarg name\n {% set incremental_predicates = kwargs.get('predicates', incremental_predicates) %}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.386816, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"name": "default__get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n {%- set predicates = [] if incremental_predicates is none else [] + incremental_predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{\"(\" ~ predicates | join(\") and (\") ~ \")\"}}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3882968, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"name": "get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.388523, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"name": "default__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last}}\n {% endfor %}\n {% if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {% endif %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n )\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%};\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3892531, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"name": "get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.389457, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"name": "default__get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.389933, "supported_languages": null}, "macro.dbt.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/is_incremental.sql", "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", "unique_id": "macro.dbt.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3905542, "supported_languages": null}, "macro.dbt.get_incremental_append_sql": {"name": "get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3916328, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"name": "default__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.391818, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"name": "get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.391957, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"name": "default__get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3921669, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"name": "get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.392303, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"name": "default__get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.392575, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"name": "get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.392711, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"name": "default__get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3928928, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"name": "get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.393026, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"name": "default__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.39319, "supported_languages": null}, "macro.dbt.get_incremental_microbatch_sql": {"name": "get_incremental_microbatch_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_microbatch_sql", "macro_sql": "{% macro get_incremental_microbatch_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_microbatch_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_microbatch_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.393412, "supported_languages": null}, "macro.dbt.default__get_incremental_microbatch_sql": {"name": "default__get_incremental_microbatch_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_microbatch_sql", "macro_sql": "{% macro default__get_incremental_microbatch_sql(arg_dict) %}\n\n {{ exceptions.raise_not_implemented('microbatch materialization strategy not implemented for adapter ' + adapter.type()) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.3935318, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"name": "get_insert_into_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.393735, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"name": "materialization_incremental_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/incremental.sql", "original_file_path": "macros/materializations/models/incremental/incremental.sql", "unique_id": "macro.dbt.materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% set contract_config = config.get('contract') %}\n {% if not contract_config or not contract_config.enforced %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {% endif %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.398388, "supported_languages": ["sql"]}, "macro.dbt.incremental_validate_on_schema_change": {"name": "incremental_validate_on_schema_change", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.404446, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"name": "check_for_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.405313, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"name": "sync_column_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.406167, "supported_languages": null}, "macro.dbt.process_schema_changes": {"name": "process_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.406782, "supported_languages": null}, "macro.dbt.can_clone_table": {"name": "can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.can_clone_table", "macro_sql": "{% macro can_clone_table() %}\n {{ return(adapter.dispatch('can_clone_table', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__can_clone_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.406971, "supported_languages": null}, "macro.dbt.default__can_clone_table": {"name": "default__can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.default__can_clone_table", "macro_sql": "{% macro default__can_clone_table() %}\n {{ return(False) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4070551, "supported_languages": null}, "macro.dbt.create_or_replace_clone": {"name": "create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.create_or_replace_clone", "macro_sql": "{% macro create_or_replace_clone(this_relation, defer_relation) %}\n {{ return(adapter.dispatch('create_or_replace_clone', 'dbt')(this_relation, defer_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_or_replace_clone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.407279, "supported_languages": null}, "macro.dbt.default__create_or_replace_clone": {"name": "default__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.default__create_or_replace_clone", "macro_sql": "{% macro default__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace table {{ this_relation.render() }} clone {{ defer_relation.render() }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.407406, "supported_languages": null}, "macro.dbt.materialization_clone_default": {"name": "materialization_clone_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/clone.sql", "original_file_path": "macros/materializations/models/clone/clone.sql", "unique_id": "macro.dbt.materialization_clone_default", "macro_sql": "{%- materialization clone, default -%}\n\n {%- set relations = {'relations': []} -%}\n\n {%- if not defer_relation -%}\n -- nothing to do\n {{ log(\"No relation found in state manifest for \" ~ model.unique_id, info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n\n {%- if existing_relation and not flags.FULL_REFRESH -%}\n -- noop!\n {{ log(\"Relation \" ~ existing_relation ~ \" already exists\", info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set other_existing_relation = load_cached_relation(defer_relation) -%}\n\n -- If this is a database that can do zero-copy cloning of tables, and the other relation is a table, then this will be a table\n -- Otherwise, this will be a view\n\n {% set can_clone_table = can_clone_table() %}\n\n {%- if other_existing_relation and other_existing_relation.type == 'table' and can_clone_table -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {% if existing_relation is not none and not existing_relation.is_table %}\n {{ log(\"Dropping relation \" ~ existing_relation.render() ~ \" because it is of type \" ~ existing_relation.type) }}\n {{ drop_relation_if_exists(existing_relation) }}\n {% endif %}\n\n -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'\n {% call statement('main') %}\n {% if target_relation and defer_relation and target_relation == defer_relation %}\n {{ log(\"Target relation and defer relation are the same, skipping clone for relation: \" ~ target_relation.render()) }}\n {% else %}\n {{ create_or_replace_clone(target_relation, defer_relation) }}\n {% endif %}\n\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do persist_docs(target_relation, model) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n {%- else -%}\n\n {%- set target_relation = this.incorporate(type='view') -%}\n\n -- reuse the view materialization\n -- TODO: support actual dispatch for materialization macros\n -- Tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799\n {% set search_name = \"materialization_view_\" ~ adapter.type() %}\n {% if not search_name in context %}\n {% set search_name = \"materialization_view_default\" %}\n {% endif %}\n {% set materialization_macro = context[search_name] %}\n {% set relations = materialization_macro() %}\n {{ return(relations) }}\n\n {%- endif -%}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.can_clone_table", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_or_replace_clone", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4107678, "supported_languages": ["sql"]}, "macro.dbt.materialization_seed_default": {"name": "materialization_seed_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/seed.sql", "original_file_path": "macros/materializations/seeds/seed.sql", "unique_id": "macro.dbt.materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparison later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation.render())) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.413472, "supported_languages": ["sql"]}, "macro.dbt.create_csv_table": {"name": "create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.419322, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"name": "default__create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.420016, "supported_languages": null}, "macro.dbt.reset_csv_table": {"name": "reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.420196, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"name": "default__reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation.render() %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.420612, "supported_languages": null}, "macro.dbt.get_csv_sql": {"name": "get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4207711, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"name": "default__get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.420873, "supported_languages": null}, "macro.dbt.get_binding_char": {"name": "get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4209762, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"name": "default__get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4210649, "supported_languages": null}, "macro.dbt.get_batch_size": {"name": "get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.421178, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"name": "default__get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.421267, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"name": "get_seed_column_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.42167, "supported_languages": null}, "macro.dbt.load_csv_rows": {"name": "load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.421865, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"name": "default__load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.423285, "supported_languages": null}, "macro.dbt.generate_alias_name": {"name": "generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.423671, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"name": "default__generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name -%}\n\n {{ custom_alias_name | trim }}\n\n {%- elif node.version -%}\n\n {{ return(node.name ~ \"_v\" ~ (node.version | replace(\".\", \"_\"))) }}\n\n {%- else -%}\n\n {{ node.name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.424143, "supported_languages": null}, "macro.dbt.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.424605, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4248278, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"name": "generate_schema_name_for_env", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4250932, "supported_languages": null}, "macro.dbt.generate_database_name": {"name": "generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.425437, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"name": "default__generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.425631, "supported_languages": null}, "macro.dbt.get_drop_sql": {"name": "get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.get_drop_sql", "macro_sql": "{%- macro get_drop_sql(relation) -%}\n {{- log('Applying DROP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.426377, "supported_languages": null}, "macro.dbt.default__get_drop_sql": {"name": "default__get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__get_drop_sql", "macro_sql": "{%- macro default__get_drop_sql(relation) -%}\n\n {%- if relation.is_view -%}\n {{ drop_view(relation) }}\n\n {%- elif relation.is_table -%}\n {{ drop_table(relation) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ drop_materialized_view(relation) }}\n\n {%- else -%}\n drop {{ relation.type }} if exists {{ relation.render() }} cascade\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.drop_view", "macro.dbt.drop_table", "macro.dbt.drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.426682, "supported_languages": null}, "macro.dbt.drop_relation": {"name": "drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.42692, "supported_languages": null}, "macro.dbt.default__drop_relation": {"name": "default__drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {{ get_drop_sql(relation) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.427087, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"name": "drop_relation_if_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.42733, "supported_languages": null}, "macro.dbt.get_replace_sql": {"name": "get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.get_replace_sql", "macro_sql": "{% macro get_replace_sql(existing_relation, target_relation, sql) %}\n {{- log('Applying REPLACE to: ' ~ existing_relation) -}}\n {{- adapter.dispatch('get_replace_sql', 'dbt')(existing_relation, target_relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.428424, "supported_languages": null}, "macro.dbt.default__get_replace_sql": {"name": "default__get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.default__get_replace_sql", "macro_sql": "{% macro default__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {# /* use a create or replace statement if possible */ #}\n\n {% set is_replaceable = existing_relation.type == target_relation_type and existing_relation.can_be_replaced %}\n\n {% if is_replaceable and existing_relation.is_view %}\n {{ get_replace_view_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_table %}\n {{ get_replace_table_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_materialized_view %}\n {{ get_replace_materialized_view_sql(target_relation, sql) }}\n\n {# /* a create or replace statement is not possible, so try to stage and/or backup to be safe */ #}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}\n {%- elif target_relation.can_be_renamed and existing_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one without using a backup */ #}\n {%- elif target_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_drop_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }}\n\n {# /* create target_relation in place by first backing up the existing relation */ #}\n {%- elif existing_relation.can_be_renamed -%}\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* no renaming is allowed, so just drop and create */ #}\n {%- else -%}\n {{ get_drop_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }}\n\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_view_sql", "macro.dbt.get_replace_table_sql", "macro.dbt.get_replace_materialized_view_sql", "macro.dbt.get_create_intermediate_sql", "macro.dbt.get_create_backup_sql", "macro.dbt.get_rename_intermediate_sql", "macro.dbt.get_drop_backup_sql", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.42943, "supported_languages": null}, "macro.dbt.get_create_intermediate_sql": {"name": "get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.get_create_intermediate_sql", "macro_sql": "{%- macro get_create_intermediate_sql(relation, sql) -%}\n {{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4297721, "supported_languages": null}, "macro.dbt.default__get_create_intermediate_sql": {"name": "default__get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.default__get_create_intermediate_sql", "macro_sql": "{%- macro default__get_create_intermediate_sql(relation, sql) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n -- drop any pre-existing intermediate\n {{ get_drop_sql(intermediate_relation) }};\n\n {{ get_create_sql(intermediate_relation, sql) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4299579, "supported_languages": null}, "macro.dbt.drop_schema_named": {"name": "drop_schema_named", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/schema.sql", "original_file_path": "macros/relations/schema.sql", "unique_id": "macro.dbt.drop_schema_named", "macro_sql": "{% macro drop_schema_named(schema_name) %}\n {{ return(adapter.dispatch('drop_schema_named', 'dbt') (schema_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_schema_named"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.430228, "supported_languages": null}, "macro.dbt.default__drop_schema_named": {"name": "default__drop_schema_named", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/schema.sql", "original_file_path": "macros/relations/schema.sql", "unique_id": "macro.dbt.default__drop_schema_named", "macro_sql": "{% macro default__drop_schema_named(schema_name) %}\n {% set schema_relation = api.Relation.create(schema=schema_name) %}\n {{ adapter.drop_schema(schema_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4304168, "supported_languages": null}, "macro.dbt.get_drop_backup_sql": {"name": "get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.get_drop_backup_sql", "macro_sql": "{%- macro get_drop_backup_sql(relation) -%}\n {{- log('Applying DROP BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.430685, "supported_languages": null}, "macro.dbt.default__get_drop_backup_sql": {"name": "default__get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.default__get_drop_backup_sql", "macro_sql": "{%- macro default__get_drop_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n {{ get_drop_sql(backup_relation) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4308422, "supported_languages": null}, "macro.dbt.get_rename_sql": {"name": "get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.get_rename_sql", "macro_sql": "{%- macro get_rename_sql(relation, new_name) -%}\n {{- log('Applying RENAME to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_sql', 'dbt')(relation, new_name) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.431447, "supported_languages": null}, "macro.dbt.default__get_rename_sql": {"name": "default__get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__get_rename_sql", "macro_sql": "{%- macro default__get_rename_sql(relation, new_name) -%}\n\n {%- if relation.is_view -%}\n {{ get_rename_view_sql(relation, new_name) }}\n\n {%- elif relation.is_table -%}\n {{ get_rename_table_sql(relation, new_name) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_rename_materialized_view_sql(relation, new_name) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_rename_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.get_rename_view_sql", "macro.dbt.get_rename_table_sql", "macro.dbt.get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.431809, "supported_languages": null}, "macro.dbt.rename_relation": {"name": "rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4319732, "supported_languages": null}, "macro.dbt.default__rename_relation": {"name": "default__rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation.render() }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.432385, "supported_languages": null}, "macro.dbt.get_create_backup_sql": {"name": "get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.get_create_backup_sql", "macro_sql": "{%- macro get_create_backup_sql(relation) -%}\n {{- log('Applying CREATE BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.432698, "supported_languages": null}, "macro.dbt.default__get_create_backup_sql": {"name": "default__get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.default__get_create_backup_sql", "macro_sql": "{%- macro default__get_create_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n -- drop any pre-existing backup\n {{ get_drop_sql(backup_relation) }};\n\n {{ get_rename_sql(relation, backup_relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4330208, "supported_languages": null}, "macro.dbt.get_create_sql": {"name": "get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.get_create_sql", "macro_sql": "{%- macro get_create_sql(relation, sql) -%}\n {{- log('Applying CREATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.433425, "supported_languages": null}, "macro.dbt.default__get_create_sql": {"name": "default__get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.default__get_create_sql", "macro_sql": "{%- macro default__get_create_sql(relation, sql) -%}\n\n {%- if relation.is_view -%}\n {{ get_create_view_as_sql(relation, sql) }}\n\n {%- elif relation.is_table -%}\n {{ get_create_table_as_sql(False, relation, sql) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_create_materialized_view_as_sql(relation, sql) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_create_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.get_create_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.433828, "supported_languages": null}, "macro.dbt.get_rename_intermediate_sql": {"name": "get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.get_rename_intermediate_sql", "macro_sql": "{%- macro get_rename_intermediate_sql(relation) -%}\n {{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.434114, "supported_languages": null}, "macro.dbt.default__get_rename_intermediate_sql": {"name": "default__get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.default__get_rename_intermediate_sql", "macro_sql": "{%- macro default__get_rename_intermediate_sql(relation) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n {{ get_rename_sql(intermediate_relation, relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.434262, "supported_languages": null}, "macro.dbt.drop_materialized_view": {"name": "drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.drop_materialized_view", "macro_sql": "{% macro drop_materialized_view(relation) -%}\n {{- adapter.dispatch('drop_materialized_view', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4345028, "supported_languages": null}, "macro.dbt.default__drop_materialized_view": {"name": "default__drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.default__drop_materialized_view", "macro_sql": "{% macro default__drop_materialized_view(relation) -%}\n drop materialized view if exists {{ relation.render() }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4346209, "supported_languages": null}, "macro.dbt.get_replace_materialized_view_sql": {"name": "get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.get_replace_materialized_view_sql", "macro_sql": "{% macro get_replace_materialized_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4348311, "supported_languages": null}, "macro.dbt.default__get_replace_materialized_view_sql": {"name": "default__get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.default__get_replace_materialized_view_sql", "macro_sql": "{% macro default__get_replace_materialized_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.434963, "supported_languages": null}, "macro.dbt.refresh_materialized_view": {"name": "refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.refresh_materialized_view", "macro_sql": "{% macro refresh_materialized_view(relation) %}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n {{- adapter.dispatch('refresh_materialized_view', 'dbt')(relation) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__refresh_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.435209, "supported_languages": null}, "macro.dbt.default__refresh_materialized_view": {"name": "default__refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.default__refresh_materialized_view", "macro_sql": "{% macro default__refresh_materialized_view(relation) %}\n {{ exceptions.raise_compiler_error(\"`refresh_materialized_view` has not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.435312, "supported_languages": null}, "macro.dbt.get_rename_materialized_view_sql": {"name": "get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.get_rename_materialized_view_sql", "macro_sql": "{% macro get_rename_materialized_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_materialized_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.435528, "supported_languages": null}, "macro.dbt.default__get_rename_materialized_view_sql": {"name": "default__get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.default__get_rename_materialized_view_sql", "macro_sql": "{% macro default__get_rename_materialized_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.435638, "supported_languages": null}, "macro.dbt.get_alter_materialized_view_as_sql": {"name": "get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_alter_materialized_view_as_sql", "macro_sql": "{% macro get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{- log('Applying ALTER to: ' ~ relation) -}}\n {{- adapter.dispatch('get_alter_materialized_view_as_sql', 'dbt')(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n ) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.436175, "supported_languages": null}, "macro.dbt.default__get_alter_materialized_view_as_sql": {"name": "default__get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_alter_materialized_view_as_sql", "macro_sql": "{% macro default__get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.436327, "supported_languages": null}, "macro.dbt.get_materialized_view_configuration_changes": {"name": "get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_materialized_view_configuration_changes", "macro_sql": "{% macro get_materialized_view_configuration_changes(existing_relation, new_config) %}\n /* {#\n It's recommended that configuration changes be formatted as follows:\n {\"\": [{\"action\": \"\", \"context\": ...}]}\n\n For example:\n {\n \"indexes\": [\n {\"action\": \"drop\", \"context\": \"index_abc\"},\n {\"action\": \"create\", \"context\": {\"columns\": [\"column_1\", \"column_2\"], \"type\": \"hash\", \"unique\": True}},\n ],\n }\n\n Either way, `get_materialized_view_configuration_changes` needs to align with `get_alter_materialized_view_as_sql`.\n #} */\n {{- log('Determining configuration changes on: ' ~ existing_relation) -}}\n {%- do return(adapter.dispatch('get_materialized_view_configuration_changes', 'dbt')(existing_relation, new_config)) -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_materialized_view_configuration_changes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.436534, "supported_languages": null}, "macro.dbt.default__get_materialized_view_configuration_changes": {"name": "default__get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_materialized_view_configuration_changes", "macro_sql": "{% macro default__get_materialized_view_configuration_changes(existing_relation, new_config) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4366379, "supported_languages": null}, "macro.dbt.get_create_materialized_view_as_sql": {"name": "get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.get_create_materialized_view_as_sql", "macro_sql": "{% macro get_create_materialized_view_as_sql(relation, sql) -%}\n {{- adapter.dispatch('get_create_materialized_view_as_sql', 'dbt')(relation, sql) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.436865, "supported_languages": null}, "macro.dbt.default__get_create_materialized_view_as_sql": {"name": "default__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.default__get_create_materialized_view_as_sql", "macro_sql": "{% macro default__get_create_materialized_view_as_sql(relation, sql) -%}\n {{ exceptions.raise_compiler_error(\n \"`get_create_materialized_view_as_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.436969, "supported_languages": null}, "macro.dbt.get_table_columns_and_constraints": {"name": "get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_table_columns_and_constraints", "macro_sql": "{%- macro get_table_columns_and_constraints() -%}\n {{ adapter.dispatch('get_table_columns_and_constraints', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.437921, "supported_languages": null}, "macro.dbt.default__get_table_columns_and_constraints": {"name": "default__get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_table_columns_and_constraints", "macro_sql": "{% macro default__get_table_columns_and_constraints() -%}\n {{ return(table_columns_and_constraints()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.438007, "supported_languages": null}, "macro.dbt.table_columns_and_constraints": {"name": "table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.table_columns_and_constraints", "macro_sql": "{% macro table_columns_and_constraints() %}\n {# loop through user_provided_columns to create DDL with data types and constraints #}\n {%- set raw_column_constraints = adapter.render_raw_columns_constraints(raw_columns=model['columns']) -%}\n {%- set raw_model_constraints = adapter.render_raw_model_constraints(raw_constraints=model['constraints']) -%}\n (\n {% for c in raw_column_constraints -%}\n {{ c }}{{ \",\" if not loop.last or raw_model_constraints }}\n {% endfor %}\n {% for c in raw_model_constraints -%}\n {{ c }}{{ \",\" if not loop.last }}\n {% endfor -%}\n )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.438391, "supported_languages": null}, "macro.dbt.get_assert_columns_equivalent": {"name": "get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_assert_columns_equivalent", "macro_sql": "\n\n{%- macro get_assert_columns_equivalent(sql) -%}\n {{ adapter.dispatch('get_assert_columns_equivalent', 'dbt')(sql) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.438512, "supported_languages": null}, "macro.dbt.default__get_assert_columns_equivalent": {"name": "default__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_assert_columns_equivalent", "macro_sql": "{% macro default__get_assert_columns_equivalent(sql) -%}\n {{ return(assert_columns_equivalent(sql)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4386072, "supported_languages": null}, "macro.dbt.assert_columns_equivalent": {"name": "assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.assert_columns_equivalent", "macro_sql": "{% macro assert_columns_equivalent(sql) %}\n\n {#-- First ensure the user has defined 'columns' in yaml specification --#}\n {%- set user_defined_columns = model['columns'] -%}\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {#-- Obtain the column schema provided by sql file. #}\n {%- set sql_file_provided_columns = get_column_schema_from_query(sql, config.get('sql_header', none)) -%}\n {#--Obtain the column schema provided by the schema file by generating an 'empty schema' query from the model's columns. #}\n {%- set schema_file_provided_columns = get_column_schema_from_query(get_empty_schema_sql(user_defined_columns)) -%}\n\n {#-- create dictionaries with name and formatted data type and strings for exception #}\n {%- set sql_columns = format_columns(sql_file_provided_columns) -%}\n {%- set yaml_columns = format_columns(schema_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['formatted'] != yaml_col[0]['formatted'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query", "macro.dbt.get_empty_schema_sql", "macro.dbt.format_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.43983, "supported_languages": null}, "macro.dbt.format_columns": {"name": "format_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.format_columns", "macro_sql": "{% macro format_columns(columns) %}\n {% set formatted_columns = [] %}\n {% for column in columns %}\n {%- set formatted_column = adapter.dispatch('format_column', 'dbt')(column) -%}\n {%- do formatted_columns.append(formatted_column) -%}\n {% endfor %}\n {{ return(formatted_columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4402869, "supported_languages": null}, "macro.dbt.default__format_column": {"name": "default__format_column", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__format_column", "macro_sql": "{% macro default__format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.440546, "supported_languages": null}, "macro.dbt.drop_table": {"name": "drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.drop_table", "macro_sql": "{% macro drop_table(relation) -%}\n {{- adapter.dispatch('drop_table', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.440747, "supported_languages": null}, "macro.dbt.default__drop_table": {"name": "default__drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.default__drop_table", "macro_sql": "{% macro default__drop_table(relation) -%}\n drop table if exists {{ relation.render() }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4408371, "supported_languages": null}, "macro.dbt.get_replace_table_sql": {"name": "get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.get_replace_table_sql", "macro_sql": "{% macro get_replace_table_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.441042, "supported_languages": null}, "macro.dbt.default__get_replace_table_sql": {"name": "default__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.default__get_replace_table_sql", "macro_sql": "{% macro default__get_replace_table_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.441151, "supported_languages": null}, "macro.dbt.get_rename_table_sql": {"name": "get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.get_rename_table_sql", "macro_sql": "{% macro get_rename_table_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_table_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_rename_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4413598, "supported_languages": null}, "macro.dbt.default__get_rename_table_sql": {"name": "default__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.default__get_rename_table_sql", "macro_sql": "{% macro default__get_rename_table_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.441469, "supported_languages": null}, "macro.dbt.get_create_table_as_sql": {"name": "get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.442235, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"name": "default__get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.442366, "supported_languages": null}, "macro.dbt.create_table_as": {"name": "create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4428449, "supported_languages": null}, "macro.dbt.default__create_table_as": {"name": "default__create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced and (not temporary) %}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- set sql = get_select_subquery(sql) %}\n {% endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.443466, "supported_languages": null}, "macro.dbt.default__get_column_names": {"name": "default__get_column_names", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_column_names", "macro_sql": "{% macro default__get_column_names() %}\n {#- loop through user_provided_columns to get column names -#}\n {%- set user_provided_columns = model['columns'] -%}\n {%- for i in user_provided_columns %}\n {%- set col = user_provided_columns[i] -%}\n {%- set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] -%}\n {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.44425, "supported_languages": null}, "macro.dbt.get_select_subquery": {"name": "get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_select_subquery", "macro_sql": "{% macro get_select_subquery(sql) %}\n {{ return(adapter.dispatch('get_select_subquery', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.44463, "supported_languages": null}, "macro.dbt.default__get_select_subquery": {"name": "default__get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_select_subquery", "macro_sql": "{% macro default__get_select_subquery(sql) %}\n select {{ adapter.dispatch('get_column_names', 'dbt')() }}\n from (\n {{ sql }}\n ) as model_subq\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.444876, "supported_languages": null}, "macro.dbt.drop_view": {"name": "drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.drop_view", "macro_sql": "{% macro drop_view(relation) -%}\n {{- adapter.dispatch('drop_view', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.445162, "supported_languages": null}, "macro.dbt.default__drop_view": {"name": "default__drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.default__drop_view", "macro_sql": "{% macro default__drop_view(relation) -%}\n drop view if exists {{ relation.render() }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.445258, "supported_languages": null}, "macro.dbt.get_replace_view_sql": {"name": "get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.get_replace_view_sql", "macro_sql": "{% macro get_replace_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4461, "supported_languages": null}, "macro.dbt.default__get_replace_view_sql": {"name": "default__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__get_replace_view_sql", "macro_sql": "{% macro default__get_replace_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.446229, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"name": "create_or_replace_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.447458, "supported_languages": null}, "macro.dbt.handle_existing_table": {"name": "handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.44799, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"name": "default__handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation.render() ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.448422, "supported_languages": null}, "macro.dbt.get_rename_view_sql": {"name": "get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.get_rename_view_sql", "macro_sql": "{% macro get_rename_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_rename_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4486809, "supported_languages": null}, "macro.dbt.default__get_rename_view_sql": {"name": "default__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.default__get_rename_view_sql", "macro_sql": "{% macro default__get_rename_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4487948, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"name": "get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.449187, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"name": "default__get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.449308, "supported_languages": null}, "macro.dbt.create_view_as": {"name": "create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.449439, "supported_languages": null}, "macro.dbt.default__create_view_as": {"name": "default__create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation.render() }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.44992, "supported_languages": null}, "macro.dbt.default__test_relationships": {"name": "default__test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/relationships.sql", "original_file_path": "macros/generic_test_sql/relationships.sql", "unique_id": "macro.dbt.default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.450254, "supported_languages": null}, "macro.dbt.default__test_not_null": {"name": "default__test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/not_null.sql", "original_file_path": "macros/generic_test_sql/not_null.sql", "unique_id": "macro.dbt.default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.450478, "supported_languages": null}, "macro.dbt.default__test_unique": {"name": "default__test_unique", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/unique.sql", "original_file_path": "macros/generic_test_sql/unique.sql", "unique_id": "macro.dbt.default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.450769, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"name": "default__test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/accepted_values.sql", "original_file_path": "macros/generic_test_sql/accepted_values.sql", "unique_id": "macro.dbt.default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.451475, "supported_languages": null}, "macro.dbt.statement": {"name": "statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.453217, "supported_languages": null}, "macro.dbt.noop_statement": {"name": "noop_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.453832, "supported_languages": null}, "macro.dbt.run_query": {"name": "run_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.454154, "supported_languages": null}, "macro.dbt.convert_datetime": {"name": "convert_datetime", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.456359, "supported_languages": null}, "macro.dbt.dates_in_range": {"name": "dates_in_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partition start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4572968, "supported_languages": null}, "macro.dbt.partition_range": {"name": "partition_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.457846, "supported_languages": null}, "macro.dbt.py_current_timestring": {"name": "py_current_timestring", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4580202, "supported_languages": null}, "macro.dbt.except": {"name": "except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.458195, "supported_languages": null}, "macro.dbt.default__except": {"name": "default__except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.458254, "supported_languages": null}, "macro.dbt.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4589498, "supported_languages": null}, "macro.dbt.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4593909, "supported_languages": null}, "macro.dbt.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.459562, "supported_languages": null}, "macro.dbt.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n {# call as follows:\n\n date_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n ) #}\n\n\n with rawdata as (\n\n {{dbt.generate_series(\n dbt.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n ),\n\n all_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n ),\n\n filtered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n )\n\n select * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_series", "macro.dbt.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.459869, "supported_languages": null}, "macro.dbt.date": {"name": "date", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date.sql", "original_file_path": "macros/utils/date.sql", "unique_id": "macro.dbt.date", "macro_sql": "{% macro date(year, month, day) %}\n {{ return(adapter.dispatch('date', 'dbt') (year, month, day)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.460159, "supported_languages": null}, "macro.dbt.default__date": {"name": "default__date", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date.sql", "original_file_path": "macros/utils/date.sql", "unique_id": "macro.dbt.default__date", "macro_sql": "{% macro default__date(year, month, day) -%}\n {%- set dt = modules.datetime.date(year, month, day) -%}\n {%- set iso_8601_formatted_date = dt.strftime('%Y-%m-%d') -%}\n to_date('{{ iso_8601_formatted_date }}', 'YYYY-MM-DD')\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.460376, "supported_languages": null}, "macro.dbt.replace": {"name": "replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4606578, "supported_languages": null}, "macro.dbt.default__replace": {"name": "default__replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4607942, "supported_languages": null}, "macro.dbt.concat": {"name": "concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.461171, "supported_languages": null}, "macro.dbt.default__concat": {"name": "default__concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.461289, "supported_languages": null}, "macro.dbt.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.462102, "supported_languages": null}, "macro.dbt.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.462531, "supported_languages": null}, "macro.dbt.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.462671, "supported_languages": null}, "macro.dbt.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.463047, "supported_languages": null}, "macro.dbt.length": {"name": "length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.463252, "supported_languages": null}, "macro.dbt.default__length": {"name": "default__length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.463331, "supported_languages": null}, "macro.dbt.dateadd": {"name": "dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.463592, "supported_languages": null}, "macro.dbt.default__dateadd": {"name": "default__dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.463713, "supported_languages": null}, "macro.dbt.intersect": {"name": "intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4638789, "supported_languages": null}, "macro.dbt.default__intersect": {"name": "default__intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.463936, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"name": "escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.464131, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"name": "default__escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.464236, "supported_languages": null}, "macro.dbt.right": {"name": "right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.464459, "supported_languages": null}, "macro.dbt.default__right": {"name": "default__right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.464561, "supported_languages": null}, "macro.dbt.listagg": {"name": "listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.465159, "supported_languages": null}, "macro.dbt.default__listagg": {"name": "default__listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.465461, "supported_languages": null}, "macro.dbt.datediff": {"name": "datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.465726, "supported_languages": null}, "macro.dbt.default__datediff": {"name": "default__datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4658492, "supported_languages": null}, "macro.dbt.safe_cast": {"name": "safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.466075, "supported_languages": null}, "macro.dbt.default__safe_cast": {"name": "default__safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.466199, "supported_languages": null}, "macro.dbt.hash": {"name": "hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.466397, "supported_languages": null}, "macro.dbt.default__hash": {"name": "default__hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.466516, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"name": "cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4667, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"name": "default__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.466814, "supported_languages": null}, "macro.dbt.cast": {"name": "cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast.sql", "original_file_path": "macros/utils/cast.sql", "unique_id": "macro.dbt.cast", "macro_sql": "{% macro cast(field, type) %}\n {{ return(adapter.dispatch('cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.467018, "supported_languages": null}, "macro.dbt.default__cast": {"name": "default__cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast.sql", "original_file_path": "macros/utils/cast.sql", "unique_id": "macro.dbt.default__cast", "macro_sql": "{% macro default__cast(field, type) %}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4671109, "supported_languages": null}, "macro.dbt.any_value": {"name": "any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4672902, "supported_languages": null}, "macro.dbt.default__any_value": {"name": "default__any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.467367, "supported_languages": null}, "macro.dbt.position": {"name": "position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.467576, "supported_languages": null}, "macro.dbt.default__position": {"name": "default__position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.467905, "supported_languages": null}, "macro.dbt.string_literal": {"name": "string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4680908, "supported_languages": null}, "macro.dbt.default__string_literal": {"name": "default__string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.46817, "supported_languages": null}, "macro.dbt.type_string": {"name": "type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.468959, "supported_languages": null}, "macro.dbt.default__type_string": {"name": "default__type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4690728, "supported_languages": null}, "macro.dbt.type_timestamp": {"name": "type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.469204, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"name": "default__type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.469315, "supported_languages": null}, "macro.dbt.type_float": {"name": "type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.46943, "supported_languages": null}, "macro.dbt.default__type_float": {"name": "default__type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.469538, "supported_languages": null}, "macro.dbt.type_numeric": {"name": "type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.469653, "supported_languages": null}, "macro.dbt.default__type_numeric": {"name": "default__type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.469803, "supported_languages": null}, "macro.dbt.type_bigint": {"name": "type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.46993, "supported_languages": null}, "macro.dbt.default__type_bigint": {"name": "default__type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4700391, "supported_languages": null}, "macro.dbt.type_int": {"name": "type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4701529, "supported_languages": null}, "macro.dbt.default__type_int": {"name": "default__type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.470256, "supported_languages": null}, "macro.dbt.type_boolean": {"name": "type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.470369, "supported_languages": null}, "macro.dbt.default__type_boolean": {"name": "default__type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.470471, "supported_languages": null}, "macro.dbt.array_concat": {"name": "array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.470678, "supported_languages": null}, "macro.dbt.default__array_concat": {"name": "default__array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4707782, "supported_languages": null}, "macro.dbt.bool_or": {"name": "bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4709601, "supported_languages": null}, "macro.dbt.default__bool_or": {"name": "default__bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.471037, "supported_languages": null}, "macro.dbt.last_day": {"name": "last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.471354, "supported_languages": null}, "macro.dbt.default_last_day": {"name": "default_last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4715781, "supported_languages": null}, "macro.dbt.default__last_day": {"name": "default__last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4717062, "supported_languages": null}, "macro.dbt.split_part": {"name": "split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.472178, "supported_languages": null}, "macro.dbt.default__split_part": {"name": "default__split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4723089, "supported_languages": null}, "macro.dbt._split_part_negative": {"name": "_split_part_negative", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt._split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 + {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.472477, "supported_languages": null}, "macro.dbt.date_trunc": {"name": "date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.472789, "supported_languages": null}, "macro.dbt.default__date_trunc": {"name": "default__date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4728892, "supported_languages": null}, "macro.dbt.array_construct": {"name": "array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.473171, "supported_languages": null}, "macro.dbt.default__array_construct": {"name": "default__array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.473356, "supported_languages": null}, "macro.dbt.array_append": {"name": "array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.473568, "supported_languages": null}, "macro.dbt.default__array_append": {"name": "default__array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.473668, "supported_languages": null}, "macro.dbt.create_schema": {"name": "create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.473969, "supported_languages": null}, "macro.dbt.default__create_schema": {"name": "default__create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4741042, "supported_languages": null}, "macro.dbt.drop_schema": {"name": "drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.474219, "supported_languages": null}, "macro.dbt.default__drop_schema": {"name": "default__drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.47435, "supported_languages": null}, "macro.dbt.current_timestamp": {"name": "current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.475132, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"name": "default__current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.475269, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"name": "snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.475379, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"name": "default__snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4754581, "supported_languages": null}, "macro.dbt.get_snapshot_get_time_data_type": {"name": "get_snapshot_get_time_data_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.get_snapshot_get_time_data_type", "macro_sql": "{% macro get_snapshot_get_time_data_type() %}\n {% set snapshot_time = adapter.dispatch('snapshot_get_time', 'dbt')() %}\n {% set time_data_type_sql = 'select ' ~ snapshot_time ~ ' as dbt_snapshot_time' %}\n {% set snapshot_time_column_schema = get_column_schema_from_query(time_data_type_sql) %}\n {% set time_data_type = snapshot_time_column_schema[0].dtype %}\n {{ return(time_data_type or none) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt_snowflake.snowflake__snapshot_get_time", "macro.dbt.get_column_schema_from_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.475756, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"name": "current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.475882, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"name": "default__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.475971, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"name": "current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.476095, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"name": "default__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4762151, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"name": "get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.477018, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"name": "default__get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.47712, "supported_languages": null}, "macro.dbt.create_indexes": {"name": "create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.477233, "supported_languages": null}, "macro.dbt.default__create_indexes": {"name": "default__create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4775429, "supported_languages": null}, "macro.dbt.get_drop_index_sql": {"name": "get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_drop_index_sql", "macro_sql": "{% macro get_drop_index_sql(relation, index_name) -%}\n {{ adapter.dispatch('get_drop_index_sql', 'dbt')(relation, index_name) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_drop_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4776828, "supported_languages": null}, "macro.dbt.default__get_drop_index_sql": {"name": "default__get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_drop_index_sql", "macro_sql": "{% macro default__get_drop_index_sql(relation, index_name) -%}\n {{ exceptions.raise_compiler_error(\"`get_drop_index_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4777842, "supported_languages": null}, "macro.dbt.get_show_indexes_sql": {"name": "get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_show_indexes_sql", "macro_sql": "{% macro get_show_indexes_sql(relation) -%}\n {{ adapter.dispatch('get_show_indexes_sql', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_indexes_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.477895, "supported_languages": null}, "macro.dbt.default__get_show_indexes_sql": {"name": "default__get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_show_indexes_sql", "macro_sql": "{% macro default__get_show_indexes_sql(relation) -%}\n {{ exceptions.raise_compiler_error(\"`get_show_indexes_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.477986, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"name": "make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4802501, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"name": "default__make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.480374, "supported_languages": null}, "macro.dbt.make_temp_relation": {"name": "make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.480531, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"name": "default__make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.480747, "supported_languages": null}, "macro.dbt.make_backup_relation": {"name": "make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.48092, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"name": "default__make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.48115, "supported_languages": null}, "macro.dbt.truncate_relation": {"name": "truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4812832, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"name": "default__truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation.render() }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4814148, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"name": "get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4815922, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"name": "default__get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.481995, "supported_languages": null}, "macro.dbt.load_cached_relation": {"name": "load_cached_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4821608, "supported_languages": null}, "macro.dbt.load_relation": {"name": "load_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4824162, "supported_languages": null}, "macro.dbt.collect_freshness": {"name": "collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.482767, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"name": "default__collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.483058, "supported_languages": null}, "macro.dbt.validate_sql": {"name": "validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.validate_sql", "macro_sql": "{% macro validate_sql(sql) -%}\n {{ return(adapter.dispatch('validate_sql', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__validate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.48328, "supported_languages": null}, "macro.dbt.default__validate_sql": {"name": "default__validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.default__validate_sql", "macro_sql": "{% macro default__validate_sql(sql) -%}\n {% call statement('validate_sql') -%}\n explain {{ sql }}\n {% endcall %}\n {{ return(load_result('validate_sql')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.483437, "supported_languages": null}, "macro.dbt.copy_grants": {"name": "copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.485127, "supported_languages": null}, "macro.dbt.default__copy_grants": {"name": "default__copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.485217, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"name": "support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.485337, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"name": "default__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.485418, "supported_languages": null}, "macro.dbt.should_revoke": {"name": "should_revoke", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4856691, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"name": "get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.485805, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"name": "default__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation.render() }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.485893, "supported_languages": null}, "macro.dbt.get_grant_sql": {"name": "get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.486051, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"name": "default__get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation.render() }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4861991, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"name": "get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4863622, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"name": "default__get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation.render() }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.486618, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"name": "get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.486781, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"name": "default__get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4872699, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"name": "call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4874072, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"name": "default__call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4875891, "supported_languages": null}, "macro.dbt.apply_grants": {"name": "apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.487755, "supported_languages": null}, "macro.dbt.default__apply_grants": {"name": "default__apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation.render() ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4886348, "supported_languages": null}, "macro.dbt.get_show_sql": {"name": "get_show_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_show_sql", "macro_sql": "{% macro get_show_sql(compiled_code, sql_header, limit) -%}\n {%- if sql_header is not none -%}\n {{ sql_header }}\n {%- endif %}\n {{ get_limit_subquery_sql(compiled_code, limit) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.488971, "supported_languages": null}, "macro.dbt.get_limit_subquery_sql": {"name": "get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_limit_subquery_sql", "macro_sql": "\n{%- macro get_limit_subquery_sql(sql, limit) -%}\n {{ adapter.dispatch('get_limit_sql', 'dbt')(sql, limit) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_limit_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.489111, "supported_languages": null}, "macro.dbt.default__get_limit_sql": {"name": "default__get_limit_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.default__get_limit_sql", "macro_sql": "{% macro default__get_limit_sql(sql, limit) %}\n {{ compiled_code }}\n {% if limit is not none %}\n limit {{ limit }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.489252, "supported_languages": null}, "macro.dbt.alter_column_comment": {"name": "alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.490002, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"name": "default__alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.490125, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"name": "alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4902668, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"name": "default__alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.490387, "supported_languages": null}, "macro.dbt.persist_docs": {"name": "persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.490601, "supported_languages": null}, "macro.dbt.default__persist_docs": {"name": "default__persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.490945, "supported_languages": null}, "macro.dbt.get_catalog_relations": {"name": "get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog_relations", "macro_sql": "{% macro get_catalog_relations(information_schema, relations) -%}\n {{ return(adapter.dispatch('get_catalog_relations', 'dbt')(information_schema, relations)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.494553, "supported_languages": null}, "macro.dbt.default__get_catalog_relations": {"name": "default__get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog_relations", "macro_sql": "{% macro default__get_catalog_relations(information_schema, relations) -%}\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog_relations not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.494742, "supported_languages": null}, "macro.dbt.get_catalog": {"name": "get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4948869, "supported_languages": null}, "macro.dbt.default__get_catalog": {"name": "default__get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.495072, "supported_languages": null}, "macro.dbt.information_schema_name": {"name": "information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.495202, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"name": "default__information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.4953191, "supported_languages": null}, "macro.dbt.list_schemas": {"name": "list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.495453, "supported_languages": null}, "macro.dbt.default__list_schemas": {"name": "default__list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.495625, "supported_languages": null}, "macro.dbt.check_schema_exists": {"name": "check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.495769, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"name": "default__check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.496093, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"name": "list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.496232, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"name": "default__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.49635, "supported_languages": null}, "macro.dbt.get_catalog_for_single_relation": {"name": "get_catalog_for_single_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog_for_single_relation", "macro_sql": "{% macro get_catalog_for_single_relation(relation) %}\n {{ return(adapter.dispatch('get_catalog_for_single_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_catalog_for_single_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.496479, "supported_languages": null}, "macro.dbt.default__get_catalog_for_single_relation": {"name": "default__get_catalog_for_single_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog_for_single_relation", "macro_sql": "{% macro default__get_catalog_for_single_relation(relation) %}\n {{ exceptions.raise_not_implemented(\n 'get_catalog_for_single_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.496594, "supported_languages": null}, "macro.dbt.get_relations": {"name": "get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relations", "macro_sql": "{% macro get_relations() %}\n {{ return(adapter.dispatch('get_relations', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.496903, "supported_languages": null}, "macro.dbt.default__get_relations": {"name": "default__get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relations", "macro_sql": "{% macro default__get_relations() %}\n {{ exceptions.raise_not_implemented(\n 'get_relations macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.497018, "supported_languages": null}, "macro.dbt.get_relation_last_modified": {"name": "get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relation_last_modified", "macro_sql": "{% macro get_relation_last_modified(information_schema, relations) %}\n {{ return(adapter.dispatch('get_relation_last_modified', 'dbt')(information_schema, relations)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_relation_last_modified"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.497164, "supported_languages": null}, "macro.dbt.default__get_relation_last_modified": {"name": "default__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relation_last_modified", "macro_sql": "{% macro default__get_relation_last_modified(information_schema, relations) %}\n {{ exceptions.raise_not_implemented(\n 'get_relation_last_modified macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.497288, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"name": "get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.499398, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"name": "default__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.499555, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"name": "sql_convert_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.499813, "supported_languages": null}, "macro.dbt.get_empty_subquery_sql": {"name": "get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_subquery_sql", "macro_sql": "{% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}\n {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.499972, "supported_languages": null}, "macro.dbt.default__get_empty_subquery_sql": {"name": "default__get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_subquery_sql", "macro_sql": "{% macro default__get_empty_subquery_sql(select_sql, select_sql_header=none) %}\n {%- if select_sql_header is not none -%}\n {{ select_sql_header }}\n {%- endif -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.500133, "supported_languages": null}, "macro.dbt.get_empty_schema_sql": {"name": "get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_schema_sql", "macro_sql": "{% macro get_empty_schema_sql(columns) -%}\n {{ return(adapter.dispatch('get_empty_schema_sql', 'dbt')(columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_schema_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.500265, "supported_languages": null}, "macro.dbt.default__get_empty_schema_sql": {"name": "default__get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_schema_sql", "macro_sql": "{% macro default__get_empty_schema_sql(columns) %}\n {%- set col_err = [] -%}\n {%- set col_naked_numeric = [] -%}\n select\n {% for i in columns %}\n {%- set col = columns[i] -%}\n {%- if col['data_type'] is not defined -%}\n {%- do col_err.append(col['name']) -%}\n {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n {%- do col_naked_numeric.append(col['name']) -%}\n {%- endif -%}\n {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n {{ cast('null', col['data_type']) }} as {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n {%- if (col_err | length) > 0 -%}\n {{ exceptions.column_type_missing(column_names=col_err) }}\n {%- elif (col_naked_numeric | length) > 0 -%}\n {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5011148, "supported_languages": null}, "macro.dbt.get_column_schema_from_query": {"name": "get_column_schema_from_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_column_schema_from_query", "macro_sql": "{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n {% set columns = [] %}\n {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n {{ return(column_schema) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.501364, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"name": "get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.501494, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"name": "default__get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n {{ get_empty_subquery_sql(select_sql) }}\n {% endcall %}\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.501775, "supported_languages": null}, "macro.dbt.alter_column_type": {"name": "alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.501955, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"name": "default__alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation.render() }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation.render() }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation.render() }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation.render() }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.502461, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"name": "alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.502653, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"name": "default__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation.render() }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.503228, "supported_languages": null}, "macro.dbt.get_fixture_sql": {"name": "get_fixture_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.get_fixture_sql", "macro_sql": "{% macro get_fixture_sql(rows, column_name_to_data_types) %}\n-- Fixture for {{ model.name }}\n{% set default_row = {} %}\n\n{%- if not column_name_to_data_types -%}\n{#-- Use defer_relation IFF it is available in the manifest and 'this' is missing from the database --#}\n{%- set this_or_defer_relation = defer_relation if (defer_relation and not load_relation(this)) else this -%}\n{%- set columns_in_relation = adapter.get_columns_in_relation(this_or_defer_relation) -%}\n\n{%- set column_name_to_data_types = {} -%}\n{%- for column in columns_in_relation -%}\n{#-- This needs to be a case-insensitive comparison --#}\n{%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}\n{%- endfor -%}\n{%- endif -%}\n\n{%- if not column_name_to_data_types -%}\n {{ exceptions.raise_compiler_error(\"Not able to get columns for unit test '\" ~ model.name ~ \"' from relation \" ~ this ~ \" because the relation doesn't exist\") }}\n{%- endif -%}\n\n{%- for column_name, column_type in column_name_to_data_types.items() -%}\n {%- do default_row.update({column_name: (safe_cast(\"null\", column_type) | trim )}) -%}\n{%- endfor -%}\n\n{{ validate_fixture_rows(rows, row_number) }}\n\n{%- for row in rows -%}\n{%- set formatted_row = format_row(row, column_name_to_data_types) -%}\n{%- set default_row_copy = default_row.copy() -%}\n{%- do default_row_copy.update(formatted_row) -%}\nselect\n{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {%- endif %}\n{%- endfor %}\n{%- if not loop.last %}\nunion all\n{% endif %}\n{%- endfor -%}\n\n{%- if (rows | length) == 0 -%}\n select\n {%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%},{%- endif %}\n {%- endfor %}\n limit 0\n{%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_relation", "macro.dbt.safe_cast", "macro.dbt.validate_fixture_rows", "macro.dbt.format_row"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.506804, "supported_languages": null}, "macro.dbt.get_expected_sql": {"name": "get_expected_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.get_expected_sql", "macro_sql": "{% macro get_expected_sql(rows, column_name_to_data_types) %}\n\n{%- if (rows | length) == 0 -%}\n select * from dbt_internal_unit_test_actual\n limit 0\n{%- else -%}\n{%- for row in rows -%}\n{%- set formatted_row = format_row(row, column_name_to_data_types) -%}\nselect\n{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {%- endif %}\n{%- endfor %}\n{%- if not loop.last %}\nunion all\n{% endif %}\n{%- endfor -%}\n{%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.format_row"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.507261, "supported_languages": null}, "macro.dbt.format_row": {"name": "format_row", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.format_row", "macro_sql": "\n\n{%- macro format_row(row, column_name_to_data_types) -%}\n {#-- generate case-insensitive formatted row --#}\n {% set formatted_row = {} %}\n {%- for column_name, column_value in row.items() -%}\n {% set column_name = column_name|lower %}\n\n {%- if column_name not in column_name_to_data_types %}\n {#-- if user-provided row contains column name that relation does not contain, raise an error --#}\n {% set fixture_name = \"expected output\" if model.resource_type == 'unit_test' else (\"'\" ~ model.name ~ \"'\") %}\n {{ exceptions.raise_compiler_error(\n \"Invalid column name: '\" ~ column_name ~ \"' in unit test fixture for \" ~ fixture_name ~ \".\"\n \"\\nAccepted columns for \" ~ fixture_name ~ \" are: \" ~ (column_name_to_data_types.keys()|list)\n ) }}\n {%- endif -%}\n\n {%- set column_type = column_name_to_data_types[column_name] %}\n\n {#-- sanitize column_value: wrap yaml strings in quotes, apply cast --#}\n {%- set column_value_clean = column_value -%}\n {%- if column_value is string -%}\n {%- set column_value_clean = dbt.string_literal(dbt.escape_single_quotes(column_value)) -%}\n {%- elif column_value is none -%}\n {%- set column_value_clean = 'null' -%}\n {%- endif -%}\n\n {%- set row_update = {column_name: safe_cast(column_value_clean, column_type) } -%}\n {%- do formatted_row.update(row_update) -%}\n {%- endfor -%}\n {{ return(formatted_row) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.string_literal", "macro.dbt.escape_single_quotes", "macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.508091, "supported_languages": null}, "macro.dbt.validate_fixture_rows": {"name": "validate_fixture_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.validate_fixture_rows", "macro_sql": "{%- macro validate_fixture_rows(rows, row_number) -%}\n {{ return(adapter.dispatch('validate_fixture_rows', 'dbt')(rows, row_number)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__validate_fixture_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.508259, "supported_languages": null}, "macro.dbt.default__validate_fixture_rows": {"name": "default__validate_fixture_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.default__validate_fixture_rows", "macro_sql": "{%- macro default__validate_fixture_rows(rows, row_number) -%}\n {# This is an abstract method for adapter overrides as needed #}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.508333, "supported_languages": null}, "macro.dbt.resolve_model_name": {"name": "resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.resolve_model_name", "macro_sql": "{% macro resolve_model_name(input_model_name) %}\n {{ return(adapter.dispatch('resolve_model_name', 'dbt')(input_model_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.509964, "supported_languages": null}, "macro.dbt.default__resolve_model_name": {"name": "default__resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.default__resolve_model_name", "macro_sql": "\n\n{%- macro default__resolve_model_name(input_model_name) -%}\n {{ input_model_name | string | replace('\"', '\\\"') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.510077, "supported_languages": null}, "macro.dbt.build_ref_function": {"name": "build_ref_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {% set _ref_args = [_ref.get('package'), _ref['name']] if _ref.get('package') else [_ref['name'],] %}\n {%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}\n {%- if _ref.get('version') -%}\n {% do _ref_args.extend([\"v\" ~ _ref['version']]) %}\n {%- endif -%}\n {%- do ref_dict.update({_ref_args | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef ref(*args, **kwargs):\n refs = {{ ref_dict | tojson }}\n key = '.'.join(args)\n version = kwargs.get(\"v\") or kwargs.get(\"version\")\n if version:\n key += f\".v{version}\"\n dbt_load_df_function = kwargs.get(\"dbt_load_df_function\")\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5106518, "supported_languages": null}, "macro.dbt.build_source_function": {"name": "build_source_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = '.'.join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5109491, "supported_languages": null}, "macro.dbt.build_config_dict": {"name": "build_config_dict", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {% set config_dbt_used = zip(model.config.config_keys_used, model.config.config_keys_defaults) | list %}\n {%- for key, default in config_dbt_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == \"language\" -%}\n {%- set value = \"python\" -%}\n {%- endif -%}\n {%- set value = model.config.get(key, default) -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.511505, "supported_languages": null}, "macro.dbt.py_script_postfix": {"name": "py_script_postfix", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = \"{{ this.database }}\"\n schema = \"{{ this.schema }}\"\n identifier = \"{{ this.identifier }}\"\n {% set this_relation_name = resolve_model_name(this) %}\n def __repr__(self):\n return '{{ this_relation_name }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args, **kwargs: ref(*args, **kwargs, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.resolve_model_name", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5118861, "supported_languages": null}, "macro.dbt.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.511945, "supported_languages": null}, "macro.dbt.test_unique": {"name": "test_unique", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.512386, "supported_languages": null}, "macro.dbt.test_not_null": {"name": "test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5125718, "supported_languages": null}, "macro.dbt.test_accepted_values": {"name": "test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.512796, "supported_languages": null}, "macro.dbt.test_relationships": {"name": "test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.513006, "supported_languages": null}, "macro.dbt_utils.get_url_host": {"name": "get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "unique_id": "macro.dbt_utils.get_url_host", "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_host"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.51333, "supported_languages": null}, "macro.dbt_utils.default__get_url_host": {"name": "default__get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "unique_id": "macro.dbt_utils.default__get_url_host", "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part", "macro.dbt.replace", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.513698, "supported_languages": null}, "macro.dbt_utils.get_url_path": {"name": "get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "unique_id": "macro.dbt_utils.get_url_path", "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_path"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.514168, "supported_languages": null}, "macro.dbt_utils.default__get_url_path": {"name": "default__get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "unique_id": "macro.dbt_utils.default__get_url_path", "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.position", "macro.dbt.split_part", "macro.dbt.right", "macro.dbt.length", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.514643, "supported_languages": null}, "macro.dbt_utils.get_url_parameter": {"name": "get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "unique_id": "macro.dbt_utils.get_url_parameter", "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_parameter"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.514896, "supported_languages": null}, "macro.dbt_utils.default__get_url_parameter": {"name": "default__get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "unique_id": "macro.dbt_utils.default__get_url_parameter", "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5151281, "supported_languages": null}, "macro.dbt_utils.test_fewer_rows_than": {"name": "test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "unique_id": "macro.dbt_utils.test_fewer_rows_than", "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_fewer_rows_than"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5161622, "supported_languages": null}, "macro.dbt_utils.default__test_fewer_rows_than": {"name": "default__test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "unique_id": "macro.dbt_utils.default__test_fewer_rows_than", "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5169501, "supported_languages": null}, "macro.dbt_utils.test_equal_rowcount": {"name": "test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "unique_id": "macro.dbt_utils.test_equal_rowcount", "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equal_rowcount"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.51772, "supported_languages": null}, "macro.dbt_utils.default__test_equal_rowcount": {"name": "default__test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "unique_id": "macro.dbt_utils.default__test_equal_rowcount", "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.518765, "supported_languages": null}, "macro.dbt_utils.test_relationships_where": {"name": "test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "unique_id": "macro.dbt_utils.test_relationships_where", "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_relationships_where"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5193212, "supported_languages": null}, "macro.dbt_utils.default__test_relationships_where": {"name": "default__test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "unique_id": "macro.dbt_utils.default__test_relationships_where", "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.519577, "supported_languages": null}, "macro.dbt_utils.test_recency": {"name": "test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "unique_id": "macro.dbt_utils.test_recency", "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_recency"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5201678, "supported_languages": null}, "macro.dbt_utils.default__test_recency": {"name": "default__test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "unique_id": "macro.dbt_utils.default__test_recency", "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.current_timestamp", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.520768, "supported_languages": null}, "macro.dbt_utils.test_not_constant": {"name": "test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "unique_id": "macro.dbt_utils.test_not_constant", "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_constant"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.521141, "supported_languages": null}, "macro.dbt_utils.default__test_not_constant": {"name": "default__test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "unique_id": "macro.dbt_utils.default__test_not_constant", "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.521472, "supported_languages": null}, "macro.dbt_utils.test_accepted_range": {"name": "test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "unique_id": "macro.dbt_utils.test_accepted_range", "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_accepted_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.521982, "supported_languages": null}, "macro.dbt_utils.default__test_accepted_range": {"name": "default__test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "unique_id": "macro.dbt_utils.default__test_accepted_range", "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.522326, "supported_languages": null}, "macro.dbt_utils.test_not_accepted_values": {"name": "test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "unique_id": "macro.dbt_utils.test_not_accepted_values", "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.522796, "supported_languages": null}, "macro.dbt_utils.default__test_not_accepted_values": {"name": "default__test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "unique_id": "macro.dbt_utils.default__test_not_accepted_values", "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5230742, "supported_languages": null}, "macro.dbt_utils.test_at_least_one": {"name": "test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "unique_id": "macro.dbt_utils.test_at_least_one", "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_at_least_one"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.523668, "supported_languages": null}, "macro.dbt_utils.default__test_at_least_one": {"name": "default__test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "unique_id": "macro.dbt_utils.default__test_at_least_one", "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% set pruned_cols = [column_name] %}\n\n{% if group_by_columns|length() > 0 %}\n\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n {% set pruned_cols = group_by_columns %}\n\n {% if column_name not in pruned_cols %}\n {% do pruned_cols.append(column_name) %}\n {% endif %}\n\n{% endif %}\n\n{% set select_pruned_cols = pruned_cols|join(' ,') %}\n\nselect *\nfrom (\n with pruned_rows as (\n select\n {{ select_pruned_cols }}\n from {{ model }}\n where {{ column_name }} is not null\n limit 1\n )\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from pruned_rows\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5242612, "supported_languages": null}, "macro.dbt_utils.test_unique_combination_of_columns": {"name": "test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.test_unique_combination_of_columns", "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_unique_combination_of_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.524805, "supported_languages": null}, "macro.dbt_utils.default__test_unique_combination_of_columns": {"name": "default__test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.525337, "supported_languages": null}, "macro.dbt_utils.test_cardinality_equality": {"name": "test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "unique_id": "macro.dbt_utils.test_cardinality_equality", "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_cardinality_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.525878, "supported_languages": null}, "macro.dbt_utils.default__test_cardinality_equality": {"name": "default__test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "unique_id": "macro.dbt_utils.default__test_cardinality_equality", "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.52614, "supported_languages": null}, "macro.dbt_utils.test_expression_is_true": {"name": "test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "unique_id": "macro.dbt_utils.test_expression_is_true", "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.526457, "supported_languages": null}, "macro.dbt_utils.default__test_expression_is_true": {"name": "default__test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "unique_id": "macro.dbt_utils.default__test_expression_is_true", "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.52672, "supported_languages": null}, "macro.dbt_utils.test_not_null_proportion": {"name": "test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "unique_id": "macro.dbt_utils.test_not_null_proportion", "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_null_proportion"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.527276, "supported_languages": null}, "macro.dbt_utils.default__test_not_null_proportion": {"name": "default__test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "unique_id": "macro.dbt_utils.default__test_not_null_proportion", "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.527998, "supported_languages": null}, "macro.dbt_utils.test_sequential_values": {"name": "test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "unique_id": "macro.dbt_utils.test_sequential_values", "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_sequential_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.528883, "supported_languages": null}, "macro.dbt_utils.default__test_sequential_values": {"name": "default__test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "unique_id": "macro.dbt_utils.default__test_sequential_values", "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.slugify", "macro.dbt.type_timestamp", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5295548, "supported_languages": null}, "macro.dbt_utils.test_equality": {"name": "test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "unique_id": "macro.dbt_utils.test_equality", "macro_sql": "{% test equality(model, compare_model, compare_columns=None, exclude_columns=None, precision = None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns, exclude_columns, precision)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.531401, "supported_languages": null}, "macro.dbt_utils.default__test_equality": {"name": "default__test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "unique_id": "macro.dbt_utils.default__test_equality", "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None, exclude_columns=None, precision = None) %}\n\n{%- if compare_columns and exclude_columns -%}\n {{ exceptions.raise_compiler_error(\"Both a compare and an ignore list were provided to the `equality` macro. Only one is allowed\") }}\n{%- endif -%}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{# Ensure there are no extra columns in the compare_model vs model #}\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- do dbt_utils._is_ephemeral(compare_model, 'test_equality') -%}\n\n {%- set model_columns = adapter.get_columns_in_relation(model) -%}\n {%- set compare_model_columns = adapter.get_columns_in_relation(compare_model) -%}\n\n\n {%- if exclude_columns -%}\n {#-- Lower case ignore columns for easier comparison --#}\n {%- set exclude_columns = exclude_columns | map(\"lower\") | list %}\n\n {# Filter out the excluded columns #}\n {%- set include_columns = [] %}\n {%- set include_model_columns = [] %}\n {%- for column in model_columns -%}\n {%- if column.name | lower not in exclude_columns -%}\n {% do include_columns.append(column) %}\n {%- endif %}\n {%- endfor %}\n {%- for column in compare_model_columns -%}\n {%- if column.name | lower not in exclude_columns -%}\n {% do include_model_columns.append(column) %}\n {%- endif %}\n {%- endfor %}\n\n {%- set compare_columns_set = set(include_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- set compare_model_columns_set = set(include_model_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- else -%}\n {%- set compare_columns_set = set(model_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- set compare_model_columns_set = set(compare_model_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- endif -%}\n\n {% if compare_columns_set != compare_model_columns_set %}\n {{ exceptions.raise_compiler_error(compare_model ~\" has less columns than \" ~ model ~ \", please ensure they have the same columns or use the `compare_columns` or `exclude_columns` arguments to subset them.\") }}\n {% endif %}\n\n\n{% endif %}\n\n{%- if not precision -%}\n {%- if not compare_columns -%}\n {# \n You cannot get the columns in an ephemeral model (due to not existing in the information schema),\n so if the user does not provide an explicit list of columns we must error in the case it is ephemeral\n #}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model)-%}\n\n {%- if exclude_columns -%}\n {#-- Lower case ignore columns for easier comparison --#}\n {%- set exclude_columns = exclude_columns | map(\"lower\") | list %}\n\n {# Filter out the excluded columns #}\n {%- set include_columns = [] %}\n {%- for column in compare_columns -%}\n {%- if column.name | lower not in exclude_columns -%}\n {% do include_columns.append(column) %}\n {%- endif %}\n {%- endfor %}\n\n {%- set compare_columns = include_columns | map(attribute='quoted') %}\n {%- else -%} {# Compare columns provided #}\n {%- set compare_columns = compare_columns | map(attribute='quoted') %}\n {%- endif -%}\n {%- endif -%}\n\n {% set compare_cols_csv = compare_columns | join(', ') %}\n\n{% else %} {# Precision required #}\n {#-\n If rounding is required, we need to get the types, so it cannot be ephemeral even if they provide column names\n -#}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set columns = adapter.get_columns_in_relation(model) -%}\n\n {% set columns_list = [] %}\n {%- for col in columns -%}\n {%- if (\n (col.name|lower in compare_columns|map('lower') or not compare_columns) and\n (col.name|lower not in exclude_columns|map('lower') or not exclude_columns)\n ) -%}\n {# Databricks double type is not picked up by any number type checks in dbt #}\n {%- if col.is_float() or col.is_numeric() or col.data_type == 'double' -%}\n {# Cast is required due to postgres not having round for a double precision number #}\n {%- do columns_list.append('round(cast(' ~ col.quoted ~ ' as ' ~ dbt.type_numeric() ~ '),' ~ precision ~ ') as ' ~ col.quoted) -%}\n {%- else -%} {# Non-numeric type #}\n {%- do columns_list.append(col.quoted) -%}\n {%- endif -%}\n {% endif %}\n {%- endfor -%}\n\n {% set compare_cols_csv = columns_list | join(', ') %}\n\n{% endif %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_numeric", "macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.534774, "supported_languages": null}, "macro.dbt_utils.test_not_empty_string": {"name": "test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "unique_id": "macro.dbt_utils.test_not_empty_string", "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_empty_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.53526, "supported_languages": null}, "macro.dbt_utils.default__test_not_empty_string": {"name": "default__test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "unique_id": "macro.dbt_utils.default__test_not_empty_string", "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.535491, "supported_languages": null}, "macro.dbt_utils.test_mutually_exclusive_ranges": {"name": "test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_mutually_exclusive_ranges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.539129, "supported_languages": null}, "macro.dbt_utils.default__test_mutually_exclusive_ranges": {"name": "default__test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.54037, "supported_languages": null}, "macro.dbt_utils.pretty_log_format": {"name": "pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "unique_id": "macro.dbt_utils.pretty_log_format", "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.540587, "supported_languages": null}, "macro.dbt_utils.default__pretty_log_format": {"name": "default__pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "unique_id": "macro.dbt_utils.default__pretty_log_format", "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5407062, "supported_languages": null}, "macro.dbt_utils._is_relation": {"name": "_is_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/_is_relation.sql", "original_file_path": "macros/jinja_helpers/_is_relation.sql", "unique_id": "macro.dbt_utils._is_relation", "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5410318, "supported_languages": null}, "macro.dbt_utils.pretty_time": {"name": "pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "unique_id": "macro.dbt_utils.pretty_time", "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5412412, "supported_languages": null}, "macro.dbt_utils.default__pretty_time": {"name": "default__pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "unique_id": "macro.dbt_utils.default__pretty_time", "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.541378, "supported_languages": null}, "macro.dbt_utils.log_info": {"name": "log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "unique_id": "macro.dbt_utils.log_info", "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__log_info"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.541567, "supported_languages": null}, "macro.dbt_utils.default__log_info": {"name": "default__log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "unique_id": "macro.dbt_utils.default__log_info", "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.541753, "supported_languages": null}, "macro.dbt_utils.slugify": {"name": "slugify", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/slugify.sql", "original_file_path": "macros/jinja_helpers/slugify.sql", "unique_id": "macro.dbt_utils.slugify", "macro_sql": "{% macro slugify(string) %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5422232, "supported_languages": null}, "macro.dbt_utils._is_ephemeral": {"name": "_is_ephemeral", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/_is_ephemeral.sql", "original_file_path": "macros/jinja_helpers/_is_ephemeral.sql", "unique_id": "macro.dbt_utils._is_ephemeral", "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.542977, "supported_languages": null}, "macro.dbt_utils.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5436642, "supported_languages": null}, "macro.dbt_utils.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.544188, "supported_languages": null}, "macro.dbt_utils.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.544373, "supported_languages": null}, "macro.dbt_utils.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.generate_series", "macro.dbt_utils.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5446799, "supported_languages": null}, "macro.dbt_utils.safe_subtract": {"name": "safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_subtract.sql", "original_file_path": "macros/sql/safe_subtract.sql", "unique_id": "macro.dbt_utils.safe_subtract", "macro_sql": "{%- macro safe_subtract(field_list) -%}\n {{ return(adapter.dispatch('safe_subtract', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_subtract"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.545034, "supported_languages": null}, "macro.dbt_utils.default__safe_subtract": {"name": "default__safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_subtract.sql", "original_file_path": "macros/sql/safe_subtract.sql", "unique_id": "macro.dbt_utils.default__safe_subtract", "macro_sql": "\n\n{%- macro default__safe_subtract(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_subtract` macro takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' -\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.545434, "supported_languages": null}, "macro.dbt_utils.nullcheck_table": {"name": "nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "unique_id": "macro.dbt_utils.nullcheck_table", "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.545693, "supported_languages": null}, "macro.dbt_utils.default__nullcheck_table": {"name": "default__nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "unique_id": "macro.dbt_utils.default__nullcheck_table", "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5459409, "supported_languages": null}, "macro.dbt_utils.get_relations_by_pattern": {"name": "get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.get_relations_by_pattern", "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.546572, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_pattern": {"name": "default__get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_pattern", "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.54718, "supported_languages": null}, "macro.dbt_utils.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.547982, "supported_languages": null}, "macro.dbt_utils.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5767748, "supported_languages": null}, "macro.dbt_utils.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5770361, "supported_languages": null}, "macro.dbt_utils.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.577488, "supported_languages": null}, "macro.dbt_utils.get_relations_by_prefix": {"name": "get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.get_relations_by_prefix", "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_prefix"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5783098, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_prefix": {"name": "default__get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_prefix", "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5790029, "supported_languages": null}, "macro.dbt_utils.get_tables_by_prefix_sql": {"name": "get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.579356, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_prefix_sql": {"name": "default__get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5797231, "supported_languages": null}, "macro.dbt_utils.star": {"name": "star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "unique_id": "macro.dbt_utils.star", "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__star"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.580967, "supported_languages": null}, "macro.dbt_utils.default__star": {"name": "default__star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "unique_id": "macro.dbt_utils.default__star", "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.58199, "supported_languages": null}, "macro.dbt_utils.unpivot": {"name": "unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "unique_id": "macro.dbt_utils.unpivot", "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__unpivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.583275, "supported_languages": null}, "macro.dbt_utils.default__unpivot": {"name": "default__unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "unique_id": "macro.dbt_utils.default__unpivot", "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(col.column) }}\n {% else %}\n {{ col.column }}\n {% endif %}\n as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_string", "macro.dbt.cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.584405, "supported_languages": null}, "macro.dbt_utils.safe_divide": {"name": "safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "unique_id": "macro.dbt_utils.safe_divide", "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_divide"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.584681, "supported_languages": null}, "macro.dbt_utils.default__safe_divide": {"name": "default__safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "unique_id": "macro.dbt_utils.default__safe_divide", "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5848262, "supported_languages": null}, "macro.dbt_utils.union_relations": {"name": "union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "unique_id": "macro.dbt_utils.union_relations", "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__union_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.588495, "supported_languages": null}, "macro.dbt_utils.default__union_relations": {"name": "default__union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "unique_id": "macro.dbt_utils.default__union_relations", "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.string_literal", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.591081, "supported_languages": null}, "macro.dbt_utils.group_by": {"name": "group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "unique_id": "macro.dbt_utils.group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.591342, "supported_languages": null}, "macro.dbt_utils.default__group_by": {"name": "default__group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "unique_id": "macro.dbt_utils.default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.59153, "supported_languages": null}, "macro.dbt_utils.deduplicate": {"name": "deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.deduplicate", "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.snowflake__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.592406, "supported_languages": null}, "macro.dbt_utils.default__deduplicate": {"name": "default__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.default__deduplicate", "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.592641, "supported_languages": null}, "macro.dbt_utils.redshift__deduplicate": {"name": "redshift__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.redshift__deduplicate", "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }} as tt\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.592766, "supported_languages": null}, "macro.dbt_utils.postgres__deduplicate": {"name": "postgres__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.postgres__deduplicate", "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.592907, "supported_languages": null}, "macro.dbt_utils.snowflake__deduplicate": {"name": "snowflake__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.snowflake__deduplicate", "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5930612, "supported_languages": null}, "macro.dbt_utils.databricks__deduplicate": {"name": "databricks__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.databricks__deduplicate", "macro_sql": "\n{%- macro databricks__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.593193, "supported_languages": null}, "macro.dbt_utils.bigquery__deduplicate": {"name": "bigquery__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.bigquery__deduplicate", "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.593371, "supported_languages": null}, "macro.dbt_utils.surrogate_key": {"name": "surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "unique_id": "macro.dbt_utils.surrogate_key", "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.593737, "supported_languages": null}, "macro.dbt_utils.default__surrogate_key": {"name": "default__surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "unique_id": "macro.dbt_utils.default__surrogate_key", "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5939279, "supported_languages": null}, "macro.dbt_utils.safe_add": {"name": "safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "unique_id": "macro.dbt_utils.safe_add", "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_add"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.5942411, "supported_languages": null}, "macro.dbt_utils.default__safe_add": {"name": "default__safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "unique_id": "macro.dbt_utils.default__safe_add", "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.59485, "supported_languages": null}, "macro.dbt_utils.nullcheck": {"name": "nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "unique_id": "macro.dbt_utils.nullcheck", "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.595131, "supported_languages": null}, "macro.dbt_utils.default__nullcheck": {"name": "default__nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "unique_id": "macro.dbt_utils.default__nullcheck", "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.595376, "supported_languages": null}, "macro.dbt_utils.get_tables_by_pattern_sql": {"name": "get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.598764, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_pattern_sql": {"name": "default__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.599031, "supported_languages": null}, "macro.dbt_utils.redshift__get_tables_by_pattern_sql": {"name": "redshift__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.redshift__get_tables_by_pattern_sql", "macro_sql": "{% macro redshift__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% set sql %}\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from \"{{ database }}\".\"information_schema\".\"tables\"\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n union all\n select distinct\n schemaname as {{ adapter.quote('table_schema') }},\n tablename as {{ adapter.quote('table_name') }},\n 'external' as {{ adapter.quote('table_type') }}\n from svv_external_tables\n where redshift_database_name = '{{ database }}'\n and schemaname ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n {% endset %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.599522, "supported_languages": null}, "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": {"name": "bigquery__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._bigquery__get_matching_schemata", "macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.60005, "supported_languages": null}, "macro.dbt_utils._bigquery__get_matching_schemata": {"name": "_bigquery__get_matching_schemata", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6004128, "supported_languages": null}, "macro.dbt_utils.get_column_values": {"name": "get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "unique_id": "macro.dbt_utils.get_column_values", "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_column_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.601619, "supported_languages": null}, "macro.dbt_utils.default__get_column_values": {"name": "default__get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "unique_id": "macro.dbt_utils.default__get_column_values", "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_ephemeral", "macro.dbt.load_relation", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.602916, "supported_languages": null}, "macro.dbt_utils.pivot": {"name": "pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "unique_id": "macro.dbt_utils.pivot", "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.603866, "supported_languages": null}, "macro.dbt_utils.default__pivot": {"name": "default__pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "unique_id": "macro.dbt_utils.default__pivot", "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.escape_single_quotes", "macro.dbt_utils.slugify"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.604476, "supported_languages": null}, "macro.dbt_utils.get_filtered_columns_in_relation": {"name": "get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.604952, "supported_languages": null}, "macro.dbt_utils.default__get_filtered_columns_in_relation": {"name": "default__get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.605862, "supported_languages": null}, "macro.dbt_utils.width_bucket": {"name": "width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.width_bucket", "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.snowflake__width_bucket"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.606656, "supported_languages": null}, "macro.dbt_utils.default__width_bucket": {"name": "default__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.default__width_bucket", "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.606993, "supported_languages": null}, "macro.dbt_utils.snowflake__width_bucket": {"name": "snowflake__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.snowflake__width_bucket", "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.607167, "supported_languages": null}, "macro.dbt_utils.get_query_results_as_dict": {"name": "get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.get_query_results_as_dict", "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_query_results_as_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.607521, "supported_languages": null}, "macro.dbt_utils.default__get_query_results_as_dict": {"name": "default__get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.default__get_query_results_as_dict", "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.607981, "supported_languages": null}, "macro.dbt_utils.generate_surrogate_key": {"name": "generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.generate_surrogate_key", "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.608382, "supported_languages": null}, "macro.dbt_utils.default__generate_surrogate_key": {"name": "default__generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.default__generate_surrogate_key", "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%}\n {%- set default_null_value = \"\" -%}\n{%- else -%}\n {%- set default_null_value = '_dbt_utils_surrogate_key_null_' -%}\n{%- endif -%}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.hash", "macro.dbt.concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.608841, "supported_languages": null}, "macro.dbt_utils.get_table_types_sql": {"name": "get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.get_table_types_sql", "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_utils.default__get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.609539, "supported_languages": null}, "macro.dbt_utils.default__get_table_types_sql": {"name": "default__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.default__get_table_types_sql", "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.609662, "supported_languages": null}, "macro.dbt_utils.postgres__get_table_types_sql": {"name": "postgres__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.postgres__get_table_types_sql", "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6097732, "supported_languages": null}, "macro.dbt_utils.databricks__get_table_types_sql": {"name": "databricks__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.databricks__get_table_types_sql", "macro_sql": "{% macro databricks__get_table_types_sql() %}\n case table_type\n when 'MANAGED' then 'table'\n when 'BASE TABLE' then 'table'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.60988, "supported_languages": null}, "macro.dbt_utils.get_single_value": {"name": "get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "unique_id": "macro.dbt_utils.get_single_value", "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_single_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.610427, "supported_languages": null}, "macro.dbt_utils.default__get_single_value": {"name": "default__get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "unique_id": "macro.dbt_utils.default__get_single_value", "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.611027, "supported_languages": null}, "macro.dbt_utils.degrees_to_radians": {"name": "degrees_to_radians", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.degrees_to_radians", "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.612132, "supported_languages": null}, "macro.dbt_utils.haversine_distance": {"name": "haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.haversine_distance", "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__haversine_distance"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.612334, "supported_languages": null}, "macro.dbt_utils.default__haversine_distance": {"name": "default__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.default__haversine_distance", "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6127841, "supported_languages": null}, "macro.dbt_utils.bigquery__haversine_distance": {"name": "bigquery__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.bigquery__haversine_distance", "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.degrees_to_radians"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.613374, "supported_languages": null}, "macro.the_tuva_project.get_selected_seeds": {"name": "get_selected_seeds", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/get_selected_seeds.sql", "original_file_path": "macros/get_selected_seeds.sql", "unique_id": "macro.the_tuva_project.get_selected_seeds", "macro_sql": "{% macro get_selected_seeds() %}\n{% if execute %}\n {% set nodes = graph.nodes.values() %}\n {% set selected_nodes = selected_resources %}\n {% set ns = namespace(selected_seeds=[]) %}\n\n {% for node in nodes %}\n {% if node.resource_type == 'seed' and node.unique_id in selected_nodes and node.package_name in['the_tuva_project','tuva','integration_tests'] %}\n {% if adapter.config.quoting.database %}\n {% set db =adapter.quote(node.database) %}\n {% else %}\n {% set db = node.database %}\n {% endif %}\n {% if adapter.config.quoting.schema %}\n {% set sch =adapter.quote(node.schema) %}\n {% else %}\n {% set sch = node.schema %}\n {% endif %}\n {% if adapter.config.quoting.identifier %}\n {% set idf =adapter.quote(node.alias) %}\n {% else %}\n {% set idf = node.alias %}\n {% endif %}\n {% set fully_qualified_name = db ~ '.' ~ sch ~ '.' ~ idf %}\n\n {% do ns.selected_seeds.append(fully_qualified_name) %}\n {% endif %}\n {% endfor %}\n\n {{ return(ns.selected_seeds) }}\n{% else %}\n {{ return([]) }}\n{% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.615367, "supported_languages": null}, "macro.the_tuva_project.apply_regex": {"name": "apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.apply_regex", "macro_sql": "{%- macro apply_regex(column_name, regex) -%}\n\n {{ return(adapter.dispatch('apply_regex')(column_name, regex)) }}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.the_tuva_project.snowflake__apply_regex"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.615886, "supported_languages": null}, "macro.the_tuva_project.default__apply_regex": {"name": "default__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.default__apply_regex", "macro_sql": "{%- macro default__apply_regex(column_name, regex) -%}\n\n regexp_like({{ column_name }}, '{{ regex}}')\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.615985, "supported_languages": null}, "macro.the_tuva_project.snowflake__apply_regex": {"name": "snowflake__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.snowflake__apply_regex", "macro_sql": "{%- macro snowflake__apply_regex(column_name, regex) -%}\n\n regexp_like({{ column_name }}, '{{ regex }}')\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6160798, "supported_languages": null}, "macro.the_tuva_project.bigquery__apply_regex": {"name": "bigquery__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.bigquery__apply_regex", "macro_sql": "{%- macro bigquery__apply_regex(column_name, regex) -%}\n\n regexp_contains({{ column_name }}, r'{{ regex }}')\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.616174, "supported_languages": null}, "macro.the_tuva_project.postgres__apply_regex": {"name": "postgres__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.postgres__apply_regex", "macro_sql": "{%- macro postgres__apply_regex(column_name, regex) -%}\n\n {{ column_name }} similar to '{{ regex }}'\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.616269, "supported_languages": null}, "macro.the_tuva_project.redshift__apply_regex": {"name": "redshift__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.redshift__apply_regex", "macro_sql": "{%- macro redshift__apply_regex(column_name, regex) -%}\n\n {{ column_name }} similar to '{{ regex }}'\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.616362, "supported_languages": null}, "macro.the_tuva_project.duckdb__apply_regex": {"name": "duckdb__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/apply_regex.sql", "original_file_path": "macros/apply_regex.sql", "unique_id": "macro.the_tuva_project.duckdb__apply_regex", "macro_sql": "{%- macro duckdb__apply_regex(column_name, regex) -%}\n\n regexp_matches({{ column_name }}, '{{ regex }}')\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.616456, "supported_languages": null}, "macro.the_tuva_project.try_to_cast_date": {"name": "try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.try_to_cast_date", "macro_sql": "\r\n\r\n{%- macro try_to_cast_date(column_name, date_format='YYYY-MM-DD') -%}\r\n\r\n {{ return(adapter.dispatch('try_to_cast_date')(column_name, date_format)) }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.input_layer.snowflake__try_to_cast_date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6181319, "supported_languages": null}, "macro.the_tuva_project.bigquery__try_to_cast_date": {"name": "bigquery__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.bigquery__try_to_cast_date", "macro_sql": "{%- macro bigquery__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n safe_cast( date( {{ column_name }} ) as date )\r\n {%- else -%}\r\n safe_cast( {{ column_name }} as date )\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6182919, "supported_languages": null}, "macro.the_tuva_project.default__try_to_cast_date": {"name": "default__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.default__try_to_cast_date", "macro_sql": "{%- macro default__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.618381, "supported_languages": null}, "macro.the_tuva_project.postgres__try_to_cast_date": {"name": "postgres__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.postgres__try_to_cast_date", "macro_sql": "{%- macro postgres__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {{ dbt.safe_cast(column_name, api.Column.translate_type(\"date\")).strip() }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.618526, "supported_languages": null}, "macro.the_tuva_project.redshift__try_to_cast_date": {"name": "redshift__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.redshift__try_to_cast_date", "macro_sql": "{%- macro redshift__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYYMMDD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}\\\\d{2}\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYYMMDD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'MM/DD/YYYY' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{2}/\\\\d{2}/\\\\d{4}'\r\n then to_date( {{ column_name }}, 'MM/DD/YYYY')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD HH:MI:SS')\r\n else date(NULL)\r\n end\r\n {%- else -%}\r\n date(NULL)\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6189299, "supported_languages": null}, "macro.the_tuva_project.snowflake__try_to_cast_date": {"name": "snowflake__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.snowflake__try_to_cast_date", "macro_sql": "{%- macro snowflake__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6190379, "supported_languages": null}, "macro.the_tuva_project.athena__try_to_cast_date": {"name": "athena__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/try_to_cast_date.sql", "original_file_path": "macros/try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.athena__try_to_cast_date", "macro_sql": "{%- macro athena__try_to_cast_date(column_name, date_format) -%}\r\n (case\r\n when typeof({{ column_name }}) = 'date' then date({{ column_name }})\r\n else try_cast(substring(try_cast({{ column_name }} as varchar), 1, 10) as date)\r\n end)\r\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6191711, "supported_languages": null}, "macro.the_tuva_project.limit_zero": {"name": "limit_zero", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/limit_zero.sql", "original_file_path": "macros/limit_zero.sql", "unique_id": "macro.the_tuva_project.limit_zero", "macro_sql": "{% macro limit_zero() -%}\n {% if adapter.type == 'fabric' %}\n {# No limit for Fabric #}\n {{ return('') }}\n {% else %}\n {{ adapter.dispatch('limit_zero')() }}\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.default__limit_zero"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.619471, "supported_languages": null}, "macro.the_tuva_project.default__limit_zero": {"name": "default__limit_zero", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/limit_zero.sql", "original_file_path": "macros/limit_zero.sql", "unique_id": "macro.the_tuva_project.default__limit_zero", "macro_sql": "{% macro default__limit_zero() -%}\n limit 0\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.619532, "supported_languages": null}, "macro.the_tuva_project.fabric__limit_zero": {"name": "fabric__limit_zero", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/limit_zero.sql", "original_file_path": "macros/limit_zero.sql", "unique_id": "macro.the_tuva_project.fabric__limit_zero", "macro_sql": "{% macro fabric__limit_zero() -%}\n {# No limit statement for Fabric #}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6195872, "supported_languages": null}, "macro.the_tuva_project.quote_column": {"name": "quote_column", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/quote_column.sql", "original_file_path": "macros/quote_column.sql", "unique_id": "macro.the_tuva_project.quote_column", "macro_sql": "{% macro quote_column(column_name) %}\n {%- if target.type == 'fabric' -%}\n \"{{ column_name }}\"\n {%- else -%}\n {{ column_name }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.619783, "supported_languages": null}, "macro.the_tuva_project.load_seed": {"name": "load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.load_seed", "macro_sql": "{% macro load_seed(uri,pattern,compression=false,headers=false,null_marker=false) %}\n{{ return(adapter.dispatch('load_seed', 'the_tuva_project')(uri,pattern,compression,headers,null_marker)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.snowflake__load_seed"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.62348, "supported_languages": null}, "macro.the_tuva_project.duckdb__load_seed": {"name": "duckdb__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.duckdb__load_seed", "macro_sql": "{% macro duckdb__load_seed(uri,pattern,compression,headers,null_marker) %}\n{%- set columns = adapter.get_columns_in_relation(this) -%}\n{%- set collist = [] -%}\n\n{% for col in columns %}\n {% do collist.append(\"'\" ~col.name~\"'\" ~ \": \" ~ \"'\"~col.dtype~\"'\") %}\n{% endfor %}\n\n{%- set cols = collist|join(',') -%}\n{# { log( cols,true) } #}\n\n{% set sql %}\n create or replace table {{this}} as\n select\n *\n from\n read_csv('s3://{{ uri }}/{{ pattern }}*',\n {% if null_marker == true %} nullstr = '\\N' {% else %} nullstr = '' {% endif %},\n header=true,\n columns= { {{ cols }} } )\n\n{% endset %}\n\n{% call statement('ducksql',fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% if execute %}\n{# debugging { log(sql, True)} #}\n{% set results = load_result('ducksql') %}\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ uri ,True) }}\n{# debugging { log(results, True) } #}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.624393, "supported_languages": null}, "macro.the_tuva_project.redshift__load_seed": {"name": "redshift__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.redshift__load_seed", "macro_sql": "{% macro redshift__load_seed(uri,pattern,compression,headers,null_marker) %}\n{% set sql %}\n\n{% set access_key_part_1 = 'AKIA2EPVN' %}\n{% set access_key_part_2 = 'TV4GFRR5377' %}\n\n{% set secret_key_part_1 = 'refUFvpX0ekY6CKEBEM' %}\n{% set secret_key_part_2 = '7BBfwDm/aUwSmmqX/Updi' %}\n\n{% set full_access_key = access_key_part_1 ~ access_key_part_2 %}\n{% set full_secret_key = secret_key_part_1 ~ secret_key_part_2 %}\n\ncopy {{ this }}\n from 's3://{{ uri }}/{{ pattern }}'\n access_key_id '{{ full_access_key }}'\n secret_access_key '{{ full_secret_key }}'\n csv\n {% if compression == true %} gzip {% else %} {% endif %}\n {% if headers == true %} ignoreheader 1 {% else %} {% endif %}\n emptyasnull\n region 'us-east-1'\n\n{% endset %}\n\n{% call statement('redsql',fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% if execute %}\n{# debugging { log(sql, True)} #}\n{% set results = load_result('redsql') %}\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ uri ,True) }}\n{# debugging { log(results, True) } #}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.625303, "supported_languages": null}, "macro.the_tuva_project.athena__load_seed": {"name": "athena__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.athena__load_seed", "macro_sql": "{% macro athena__load_seed(uri, pattern, compression, headers, null_marker) %}\n {% if execute %}\n {% do adapter.load_tuva_seed(this, uri, pattern, compression, headers, null_marker) %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.625528, "supported_languages": null}, "macro.the_tuva_project.snowflake__load_seed": {"name": "snowflake__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.snowflake__load_seed", "macro_sql": "{% macro snowflake__load_seed(uri,pattern,compression,headers,null_marker) %}\n{% set sql %}\ncopy into {{ this }}\n from s3://{{ uri }}\n file_format = (type = CSV\n {% if compression == true %} compression = 'GZIP' {% else %} compression = 'none' {% endif %}\n {% if headers == true %} skip_header = 1 {% else %} {% endif %}\n empty_field_as_null = true\n field_optionally_enclosed_by = '\"'\n)\npattern = '.*\\/{{pattern}}.*';\n{% endset %}\n{% call statement('snowsql',fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% if execute %}\n{# debugging { log(sql, True)} #}\n{% set results = load_result('snowsql') %}\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ uri ~ \"/\" ~ pattern ~ \"*\\n rows: \" ~ results['data']|sum(attribute=2),True) }}\n{# debugging { log(results, True)} #}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6261828, "supported_languages": null}, "macro.the_tuva_project.bigquery__load_seed": {"name": "bigquery__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.bigquery__load_seed", "macro_sql": "{% macro bigquery__load_seed(uri,pattern,compression,headers,null_marker) %}\n{%- set columns = adapter.get_columns_in_relation(this) -%}\n{%- set collist = [] -%}\n\n{% for col in columns %}\n {% do collist.append(col.name ~ \" \" ~ col.dtype) %}\n{% endfor %}\n\n{%- set cols = collist|join(',') -%}\n{# { log( cols,true) } #}\n{% set sql %}\nload data into {{ this }} ( {{collist|join(',')}} )\nfrom files (format = 'csv',\n uris = ['gs://{{ uri }}/{{ pattern }}*'],\n {% if compression == true %} compression = 'GZIP', {% else %} {% endif %}\n {% if headers == true %} skip_leading_rows = 1, {% else %} {% endif %}\n {% if null_marker == true %} null_marker = '\\\\N', {% else %} {% endif %}\n quote = '\"',\n allow_quoted_newlines = True\n )\n{% endset %}\n\n{% call statement('bigsql',fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% if execute %}\n{# { log(sql, True) } #}\n{% set results = load_result('bigsql') %}\n{{ log(\"Loaded data from external gs resource\\n loaded to: \" ~ this ~ \"\\n from: gs://\" ~ uri ~ \"/\" ~ pattern ~ \"*\",True) }}\n{# log(results, True) #}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.627271, "supported_languages": null}, "macro.the_tuva_project.databricks__load_seed": {"name": "databricks__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.databricks__load_seed", "macro_sql": "{% macro databricks__load_seed(uri,pattern,compression,headers,null_marker) %}\n{% if execute %}\n\n{%- set s3_path = 's3://' ~ uri ~ '/' -%}\n{%- set columns = adapter.get_columns_in_relation(this) -%}\n{%- set collist = [] -%}\n\n{% for col in columns %}\n {% do collist.append(\"_c\" ~ loop.index0 ~ \"::\" ~ col.dtype ~ \" AS \" ~ col.name ) %}\n{% endfor %}\n\n{%- set cols = collist|join(',\\n ') -%}\n\n{% set sql %}\nCOPY INTO {{ this }}\nFROM (\n SELECT\n {{ cols }}\n\n FROM '{{ s3_path }}'\n {% if env_var('AWS_SESSION_TOKEN', False) %}\n WITH (\n CREDENTIAL (\n AWS_ACCESS_KEY = \"{{ env_var('AWS_ACCESS_KEY_ID') }}\",\n AWS_SECRET_KEY = \"{{ env_var('AWS_SECRET_ACCESS_KEY') }}\",\n AWS_SESSION_TOKEN = \"{{ env_var('AWS_SESSION_TOKEN') }}\"\n )\n )\n {% endif %}\n)\nFILEFORMAT = CSV\nPATTERN = '{{ pattern }}*'\nFORMAT_OPTIONS (\n {% if headers == true %} 'skipRows' = '1', {% else %} 'skipRows' = '0', {% endif %}\n {% if null_marker == true %} 'nullValue' = '\\\\N', {% else %} {% endif %}\n 'enforceSchema' = 'false',\n 'inferSchema' = 'false',\n 'sep' = ',',\n 'escape' = \"\\\"\",\n 'multiline' = 'true'\n)\nCOPY_OPTIONS (\n 'mergeSchema' = 'false',\n 'force' = 'true'\n)\n{% endset %}\n\n{# check logs/dbt.log for output #}\n{{ log(cols, info=False) }}\n{{ log('Current model: ' ~ this ~ '\\n', info=False) }}\n{{ log('Full s3 path: ' ~ s3_path ~ '\\n', info=False) }}\n{{ log(sql, info=False) }}\n\n{% call statement('databrickssql',fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% set results = load_result('databrickssql') %}\n{% set rows_affected = results['data'][0][0] %}\n\n{{ log(results, info=False) }}\n{{ log(rows_affected, info=False) }}\n\n{{ log(\"Loaded data from external s3 resource:\", True) }}\n{{ log(\" source: \\t\" ~ s3_path ~ pattern, True) }}\n{{ log(\" target: \\t\" ~ this | replace('`',''), True) }}\n{{ log(\" rows: \\t\\033[92m\" ~ rows_affected ~ \"\\033[0m\", True) }}\n\n{% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.628778, "supported_languages": null}, "macro.the_tuva_project.postgres__load_seed": {"name": "postgres__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.postgres__load_seed", "macro_sql": "{% macro postgres__load_seed(uri,pattern,compression,headers,null_marker) %}\n{%- set columns = adapter.get_columns_in_relation(this) -%}\n{%- set collist = [] -%}\n{%- for col in columns -%}\n {%- do collist.append(col.name) -%}\n{%- endfor -%}\n{%- set cols = collist|join(\",\") -%}\n\n{%- set s3_bucket = var(\"tuva_seeds_s3_bucket\", uri.split(\"/\")[0]) -%}\n{%- set s3_key = uri.split(\"/\")[1:]|join(\"/\") + \"/\" + pattern + \"_0.csv.gz\" -%}\n{%- if var(\"tuva_seeds_s3_key_prefix\", \"\") != \"\" -%}\n{%- set s3_key = var(\"tuva_seeds_s3_key_prefix\") + \"/\" + s3_key -%}\n{%- endif -%}\n{%- set s3_region = \"us-east-1\" -%}\n{%- set options = [\"(\", \"format csv\", \", encoding ''utf8''\"] -%}\n{%- do options.append(\", null ''\\\\N''\") if null_marker == true -%}\n{%- do options.append(\")\") -%}\n{%- set options_s = options | join(\"\") -%}\n\n{% set sql %}\nSELECT aws_s3.table_import_from_s3(\n '{{ this }}',\n '{{ cols }}',\n '{{ options_s }}',\n aws_commons.create_s3_uri('{{s3_bucket}}', '{{s3_key}}', '{{s3_region}}')\n)\n{% endset %}\n\n{% call statement('postgressql',fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% if execute %}\n{# debugging { log(sql, True)} #}\n{% set results = load_result('postgressql') %}\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ s3_bucket ~ \"/\" ~ s3_key ,True) }}\n{# debugging { log(results, True) } #}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.629941, "supported_languages": null}, "macro.the_tuva_project.fabric__load_seed": {"name": "fabric__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.fabric__load_seed", "macro_sql": "{% macro fabric__load_seed(uri, pattern, compression, headers, null_marker) %}\n{% set sql %}\nCOPY INTO {{ this }}\nFROM 'https://tuvapublicresources.blob.core.windows.net/{{ uri }}/{{ pattern }}'\nWITH (\n FILE_TYPE = 'CSV',\n FIELDTERMINATOR = ',',\n ROWTERMINATOR = '\\n'\n {% if headers == true %}, FIRSTROW = 2 {% else %} {% endif %}\n);\n{% endset %}\n{% call statement('fabricsql', fetch_result=true) %}\n{{ sql }}\n{% endcall %}\n\n{% if execute %}\n{# debugging { log(sql, True)} #}\n{% set results = load_result('fabricsql') %}\n{% set rows_loaded = results['response'].rows_affected|default(0) %}\n{{ log(\"Loaded data from external Azure Blob Storage\\n loaded to: \" ~ this ~ \"\\n from: \" ~ uri ~ \"/\" ~ pattern ~ \"\\n rows: \" ~ rows_loaded, True) }}\n{# debugging { log(results, True)} #}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.63058, "supported_languages": null}, "macro.the_tuva_project.default__load_seed": {"name": "default__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/load_seed.sql", "original_file_path": "macros/load_seed.sql", "unique_id": "macro.the_tuva_project.default__load_seed", "macro_sql": "{% macro default__load_seed(uri,pattern,compression,headers,null_marker) %}\n{% if execute %}\n{% do log('No adapter found, seed not loaded',info = True) %}\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.630769, "supported_languages": null}, "macro.the_tuva_project.date_part": {"name": "date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/date_part.sql", "original_file_path": "macros/date_part.sql", "unique_id": "macro.the_tuva_project.date_part", "macro_sql": "{% macro date_part(datepart, date) -%}\r\n {{ adapter.dispatch('date_part') (datepart, date) }}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.default__date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6312199, "supported_languages": null}, "macro.the_tuva_project.default__date_part": {"name": "default__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/date_part.sql", "original_file_path": "macros/date_part.sql", "unique_id": "macro.the_tuva_project.default__date_part", "macro_sql": "{% macro default__date_part(datepart, date) -%}\r\n date_part('{{ datepart }}', {{ date }})\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.631319, "supported_languages": null}, "macro.the_tuva_project.bigquery__date_part": {"name": "bigquery__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/date_part.sql", "original_file_path": "macros/date_part.sql", "unique_id": "macro.the_tuva_project.bigquery__date_part", "macro_sql": "{% macro bigquery__date_part(datepart, date) -%}\r\n extract({{ datepart }} from {{ date }})\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.631438, "supported_languages": null}, "macro.the_tuva_project.athena__date_part": {"name": "athena__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/date_part.sql", "original_file_path": "macros/date_part.sql", "unique_id": "macro.the_tuva_project.athena__date_part", "macro_sql": "{% macro athena__date_part(datepart, date) -%}\r\n extract({{ datepart }} from {{ date }})\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.631541, "supported_languages": null}, "macro.the_tuva_project.fabric__date_part": {"name": "fabric__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/date_part.sql", "original_file_path": "macros/date_part.sql", "unique_id": "macro.the_tuva_project.fabric__date_part", "macro_sql": "{% macro fabric__date_part(datepart, date) %}\r\n {% if datepart == 'year' %}\r\n YEAR({{ date }})\r\n {% elif datepart == 'month' %}\r\n MONTH({{ date }})\r\n {% else %}\r\n NULL\r\n {% endif %}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6317298, "supported_languages": null}, "macro.the_tuva_project.ltrim": {"name": "ltrim", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/ltrim.sql", "original_file_path": "macros/ltrim.sql", "unique_id": "macro.the_tuva_project.ltrim", "macro_sql": "\n\n{%- macro ltrim(column_name, trimstr) -%}\n\n {{ return(adapter.dispatch('ltrim')(column_name, trimstr)) }}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.the_tuva_project.default__ltrim"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.631976, "supported_languages": null}, "macro.the_tuva_project.default__ltrim": {"name": "default__ltrim", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/ltrim.sql", "original_file_path": "macros/ltrim.sql", "unique_id": "macro.the_tuva_project.default__ltrim", "macro_sql": "{%- macro default__ltrim(column_name, trimstr) -%}\n\n ltrim({{ column_name }}, '{{ trimstr }}')\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.632212, "supported_languages": null}, "macro.the_tuva_project.databricks__ltrim": {"name": "databricks__ltrim", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/ltrim.sql", "original_file_path": "macros/ltrim.sql", "unique_id": "macro.the_tuva_project.databricks__ltrim", "macro_sql": "{%- macro databricks__ltrim(column_name, trimstr) -%}\n\n ltrim('{{ trimstr }}', {{ column_name }})\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.632324, "supported_languages": null}, "macro.the_tuva_project.log_warning_for_seeds": {"name": "log_warning_for_seeds", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/log_warning_for_seeds.sql", "original_file_path": "macros/log_warning_for_seeds.sql", "unique_id": "macro.the_tuva_project.log_warning_for_seeds", "macro_sql": "{% macro log_warning_for_seeds() %}\n\n {% set seeds = get_selected_seeds() %}\n\n {% for seed in seeds %}\n {% set sql_query = \"select count(*) as row_count from \" ~ seed %}\n {% set result = run_query(sql_query) %}\n {% set row_count = result[0][0] %}\n {% if row_count == 0 %}\n {% if var('error_empty_seeds',False) == true %}\n {% do exceptions.raise_compiler_error (\"The seed \" ~ seed ~ \" contains no data. Check tuva:dbt_project.yml configurations to ensure data was correctly loaded with post hook\") %}\n {% else %}\n {% do exceptions.warn(\"The seed \" ~ seed ~ \" contains no data. Check tuva:dbt_project.yml configurations to ensure data was correctly loaded with post hook\") %}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.get_selected_seeds", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6331189, "supported_languages": null}, "macro.the_tuva_project.substring": {"name": "substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.substring", "macro_sql": "{% macro substring(string, start, length) %}\n {{ return(adapter.dispatch('substring', 'macros')(string, start, length)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.snowflake__substring"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.633973, "supported_languages": null}, "macro.the_tuva_project.default__substring": {"name": "default__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.default__substring", "macro_sql": "{% macro default__substring(string, start, length) %}\n substring({{ string }}, {{ start }}, {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.63411, "supported_languages": null}, "macro.the_tuva_project.postgres__substring": {"name": "postgres__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.postgres__substring", "macro_sql": "{% macro postgres__substring(string, start, length) %}\n substring({{ string }} from {{ start }} for {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.634232, "supported_languages": null}, "macro.the_tuva_project.snowflake__substring": {"name": "snowflake__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.snowflake__substring", "macro_sql": "{% macro snowflake__substring(string, start, length) %}\n substr({{ string }}, {{ start }}, {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.634346, "supported_languages": null}, "macro.the_tuva_project.bigquery__substring": {"name": "bigquery__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.bigquery__substring", "macro_sql": "{% macro bigquery__substring(string, start, length) %}\n substr({{ string }}, {{ start }}, {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.634461, "supported_languages": null}, "macro.the_tuva_project.redshift__substring": {"name": "redshift__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.redshift__substring", "macro_sql": "{% macro redshift__substring(string, start, length) %}\n substring({{ string }}, {{ start }}, {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6345768, "supported_languages": null}, "macro.the_tuva_project.databricks__substring": {"name": "databricks__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.databricks__substring", "macro_sql": "{% macro databricks__substring(string, start, length) %}\n substring({{ string }}, {{ start }}, {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.634707, "supported_languages": null}, "macro.the_tuva_project.duckdb__substring": {"name": "duckdb__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/substring.sql", "original_file_path": "macros/substring.sql", "unique_id": "macro.the_tuva_project.duckdb__substring", "macro_sql": "{% macro duckdb__substring(string, start, length) %}\n substring({{ string }}, {{ start }}, {{ length }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.634824, "supported_languages": null}, "macro.the_tuva_project.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/generate_schema_name.sql", "original_file_path": "macros/generate_schema_name.sql", "unique_id": "macro.the_tuva_project.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is not none -%}\n {{ custom_schema_name | trim }}\n {%- else -%}\n {{ default_schema }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6351008, "supported_languages": null}, "macro.the_tuva_project.medical_claim_header_duplicate_check": {"name": "medical_claim_header_duplicate_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/medical_claim_header_duplicate_check.sql", "original_file_path": "macros/data_quality/medical_claim_header_duplicate_check.sql", "unique_id": "macro.the_tuva_project.medical_claim_header_duplicate_check", "macro_sql": "{% macro medical_claim_header_duplicate_check(relation, column_list, claim_type) %}\n {%- for column_item in column_list %}\n select\n claim_id\n , data_source\n , '{{ column_item }}' as column_checked\n , count(distinct {{ column_item }}) as duplicate_count\n from {{ relation }}\n where claim_type = '{{ claim_type }}'\n group by\n claim_id\n , data_source\n having count(distinct {{ column_item }}) > 1\n {% if not loop.last -%}\n union all\n {%- endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.635591, "supported_languages": null}, "macro.the_tuva_project.eligibility_missing_column_check": {"name": "eligibility_missing_column_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/eligibility_missing_column_check.sql", "original_file_path": "macros/data_quality/eligibility_missing_column_check.sql", "unique_id": "macro.the_tuva_project.eligibility_missing_column_check", "macro_sql": "{% macro eligibility_missing_column_check(relation, column_list) %}\n {%- for column_item in column_list %}\n select\n patient_id\n , data_source\n , '{{ column_item }}' as column_checked\n from {{ relation }}\n where {{ column_item }} is null\n {% if not loop.last -%}\n union all\n {%- endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6359308, "supported_languages": null}, "macro.the_tuva_project.eligibility_denominator_invalid_values": {"name": "eligibility_denominator_invalid_values", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/eligibility_denominator_invalid_values.sql", "original_file_path": "macros/data_quality/eligibility_denominator_invalid_values.sql", "unique_id": "macro.the_tuva_project.eligibility_denominator_invalid_values", "macro_sql": "{% macro eligibility_denominator_invalid_values(relation) %}\n{%- set sql_statement -%}\n select test_field\n from {{ ref('data_quality__test_catalog') }}\n where source_table = 'normalized_input__eligibility'\n and test_category = 'invalid_values'\n{%- endset -%}\n\n{%- set results = run_query(sql_statement) -%}\n\n{%- if execute -%}\n{%- set results_list = results.columns[0].values() -%}\n{%- else -%}\n{%- set results_list = [] -%}\n{%- endif -%}\n\n {%- for test_field in results_list -%}\n select\n cat.test_name\n , count(distinct rel.patient_id) as denominator\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ relation }} as rel\n left join {{ ref('data_quality__test_catalog') }} as cat\n on cat.test_category = 'invalid_values'\n and cat.source_table = 'normalized_input__eligibility'\n and cat.test_field = '{{ test_field }}'\n where rel.{{ test_field }} is not null\n group by cat.test_name\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.636998, "supported_languages": null}, "macro.the_tuva_project.medical_claim_denominator_invalid_values": {"name": "medical_claim_denominator_invalid_values", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/medical_claim_denominator_invalid_values.sql", "original_file_path": "macros/data_quality/medical_claim_denominator_invalid_values.sql", "unique_id": "macro.the_tuva_project.medical_claim_denominator_invalid_values", "macro_sql": "{% macro medical_claim_denominator_invalid_values(relation) %}\n{%- set sql_statement -%}\n select test_field\n from {{ ref('data_quality__test_catalog') }}\n where source_table = 'normalized_input__medical_claim'\n and test_category = 'invalid_values'\n{%- endset -%}\n\n{%- set results = run_query(sql_statement) -%}\n\n{%- if execute -%}\n{%- set results_list = results.columns[0].values() -%}\n{%- else -%}\n{%- set results_list = [] -%}\n{%- endif -%}\n\n {%- for test_field in results_list -%}\n select\n cat.test_name\n , count(distinct rel.claim_id||rel.data_source) as denominator\n , '{{ var('tuva_last_run')}}' as tuva_last_run\n from {{ relation }} as rel\n left join {{ ref('data_quality__test_catalog') }} as cat\n on cat.test_category = 'invalid_values'\n and cat.source_table = 'normalized_input__medical_claim'\n and cat.test_field = '{{ test_field }}'\n where rel.{{ test_field }} is not null\n group by cat.test_name\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.637974, "supported_languages": null}, "macro.the_tuva_project.pharmacy_claim_missing_column_check": {"name": "pharmacy_claim_missing_column_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/pharmacy_claim_missing_column_check.sql", "original_file_path": "macros/data_quality/pharmacy_claim_missing_column_check.sql", "unique_id": "macro.the_tuva_project.pharmacy_claim_missing_column_check", "macro_sql": "{% macro pharmacy_claim_missing_column_check(relation, column_list) %}\n {%- for column_item in column_list %}\n select\n claim_id\n , data_source\n , '{{ column_item }}' as column_checked\n from {{ relation }}\n where {{ column_item }} is null\n {% if not loop.last -%}\n union all\n {%- endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.638297, "supported_languages": null}, "macro.the_tuva_project.medical_claim_missing_column_check": {"name": "medical_claim_missing_column_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/medical_claim_missing_column_check.sql", "original_file_path": "macros/data_quality/medical_claim_missing_column_check.sql", "unique_id": "macro.the_tuva_project.medical_claim_missing_column_check", "macro_sql": "{% macro medical_claim_missing_column_check(relation, column_list, claim_type) %}\n {%- for column_item in column_list %}\n select\n claim_id\n , data_source\n , '{{ column_item }}' as column_checked\n from {{ relation }}\n where {{ column_item }} is null\n and claim_type = '{{ claim_type }}'\n {% if not loop.last -%}\n union all\n {%- endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.638645, "supported_languages": null}, "macro.the_tuva_project.pharmacy_claim_header_duplicate_check": {"name": "pharmacy_claim_header_duplicate_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/pharmacy_claim_header_duplicate_check.sql", "original_file_path": "macros/data_quality/pharmacy_claim_header_duplicate_check.sql", "unique_id": "macro.the_tuva_project.pharmacy_claim_header_duplicate_check", "macro_sql": "{% macro pharmacy_claim_header_duplicate_check(relation, column_list) %}\n {%- for column_item in column_list %}\n select\n claim_id\n , data_source\n , '{{ column_item }}' as column_checked\n , count(distinct {{ column_item }}) as duplicate_count\n from {{ relation }}\n group by claim_id, data_source\n having count(distinct {{ column_item }}) > 1\n {% if not loop.last -%}\n union all\n {%- endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.639008, "supported_languages": null}, "macro.the_tuva_project.medical_claim_date_check": {"name": "medical_claim_date_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/data_quality/medical_claim_date_check.sql", "original_file_path": "macros/data_quality/medical_claim_date_check.sql", "unique_id": "macro.the_tuva_project.medical_claim_date_check", "macro_sql": "{% macro medical_claim_date_check(relation, column_list, claim_type=false) %}\n {%- for column_item in column_list -%}\n select\n claim_id\n , data_source\n , '{{ column_item }}' as column_checked\n from {{ relation }} as rel\n left join {{ ref('reference_data__calendar') }} as cal\n on rel.{{ column_item }} = cal.full_date\n where cal.full_date is null\n and rel.{{ column_item }} is not null\n {% if claim_type -%}\n and rel.claim_type = '{{ claim_type }}'\n {% endif -%}\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.6396842, "supported_languages": null}, "macro.the_tuva_project.test_claims_preprocessing_pipeline_checks": {"name": "test_claims_preprocessing_pipeline_checks", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros/tests/claims_preprocessing_pipeline_checks.sql", "original_file_path": "macros/tests/claims_preprocessing_pipeline_checks.sql", "unique_id": "macro.the_tuva_project.test_claims_preprocessing_pipeline_checks", "macro_sql": "{% test claims_preprocessing_pipeline_checks(model) %}\n\n select *\n from {{ ref('data_quality__claims_preprocessing_test_detail' )}}\n where pipeline_test = 1\n\n{% endtest %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729623951.639828, "supported_languages": null}}, "docs": {"doc.input_layer.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "input_layer", "path": "overview.md", "original_file_path": "docs/overview.md", "unique_id": "doc.input_layer.__overview__", "block_contents": "# \ud83e\uddf0\u00a0What is The Tuva Project?\n\nHealthcare data is difficult to analyze - we're working to change that. The Tuva Project is an open source knowledge base, code base, and community for healthcare data people.\n\n### \ud83d\udd6e\u00a0[Knowledge](https://thetuvaproject.com/)\nWe're writing the open book on how to transform and analyze healthcare data.\n\n### \ud83d\udda5\ufe0f\u00a0[Code](https://github.com/tuva-health)\nWe're translating knowledge into precise code that anyone can run on their healthcare data.\n\n### \ud83e\udd1d\u00a0[Community](https://join.slack.com/t/thetuvaproject/shared_invite/zt-16iz61187-G522Mc2WGA2mHF57e0il0Q)\nWe're building a community we're healthcare data people can ask questions and share knowledge about healthcare data."}, "doc.dbt.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "dbt", "path": "overview.md", "original_file_path": "docs/overview.md", "unique_id": "doc.dbt.__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}, "doc.the_tuva_project.accession_number": {"name": "accession_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.accession_number", "block_contents": "The lab order number from the source system."}, "doc.the_tuva_project.address": {"name": "address", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.address", "block_contents": "The street address of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.admission_date": {"name": "admission_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.admission_date", "block_contents": "Admission date for the claim (inpatient claims only)."}, "doc.the_tuva_project.admit_age": {"name": "admit_age", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_age", "block_contents": "The age of the patient at the time of admission."}, "doc.the_tuva_project.admit_source_code": {"name": "admit_source_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_source_code", "block_contents": "Indicates where the patient was before the healthcare encounter (inpatient claims only)."}, "doc.the_tuva_project.admit_source_description": {"name": "admit_source_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_source_description", "block_contents": "Description of the admit_source_code for the encounter."}, "doc.the_tuva_project.admit_type_code": {"name": "admit_type_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_type_code", "block_contents": "Indicates the type of admission (inpatient claims only)."}, "doc.the_tuva_project.admit_type_description": {"name": "admit_type_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_type_description", "block_contents": "Description of the admit_type_code for the encounter."}, "doc.the_tuva_project.age": {"name": "age", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.age", "block_contents": "The age of the patient calculated based on their date of birth and the last time the tuva project was run."}, "doc.the_tuva_project.age_group": {"name": "age_group", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.age_group", "block_contents": "The decade age group the patient falls into based on their calculated age."}, "doc.the_tuva_project.allowed_amount": {"name": "allowed_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.allowed_amount", "block_contents": "The total amount allowed (includes amount paid by the insurer and patient)."}, "doc.the_tuva_project.ambulance_flag": {"name": "ambulance_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ambulance_flag", "block_contents": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.apr_drg_code": {"name": "apr_drg_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.apr_drg_code", "block_contents": "APR-DRG for the claim (inpatient claims only)."}, "doc.the_tuva_project.apr_drg_description": {"name": "apr_drg_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.apr_drg_description", "block_contents": "Description of the APR-DRG code."}, "doc.the_tuva_project.atc_code": {"name": "atc_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.atc_code", "block_contents": "ATC code for the medication."}, "doc.the_tuva_project.atc_description": {"name": "atc_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.atc_description", "block_contents": "Description for the ATC code."}, "doc.the_tuva_project.atc_mapping_method": {"name": "atc_mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.atc_mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.attending_provider_id": {"name": "attending_provider_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.attending_provider_id", "block_contents": "ID for the attending provider on the encounter."}, "doc.the_tuva_project.attending_provider_name": {"name": "attending_provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.attending_provider_name", "block_contents": "Name of the attending provider on the encounter."}, "doc.the_tuva_project.bill_type_code": {"name": "bill_type_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.bill_type_code", "block_contents": "Bill type code for the claim (institutional claims only)."}, "doc.the_tuva_project.bill_type_description": {"name": "bill_type_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.bill_type_description", "block_contents": "Bill type description."}, "doc.the_tuva_project.billing_id": {"name": "billing_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.billing_id", "block_contents": "Billing ID for the claim (typically represents organization billing the claim)."}, "doc.the_tuva_project.billing_name": {"name": "billing_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.billing_name", "block_contents": "Billing provider name."}, "doc.the_tuva_project.billing_tin": {"name": "billing_tin", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.billing_tin", "block_contents": "Billing provider tax identification number (TIN)."}, "doc.the_tuva_project.birth_date": {"name": "birth_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.birth_date", "block_contents": "The birth date of the patient."}, "doc.the_tuva_project.ccs_category": {"name": "ccs_category", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ccs_category", "block_contents": "The Clinical Classifications Software (CCS) category code for the diagnosis or procedure."}, "doc.the_tuva_project.ccs_category_description": {"name": "ccs_category_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ccs_category_description", "block_contents": "Description of the Clinical Classifications Software (CCS) category."}, "doc.the_tuva_project.charge_amount": {"name": "charge_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.charge_amount", "block_contents": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars."}, "doc.the_tuva_project.city": {"name": "city", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.city", "block_contents": "The city of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.claim_attribution_number": {"name": "claim_attribution_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_attribution_number", "block_contents": "A unique number used for attributing or associating claims with specific entities or processes."}, "doc.the_tuva_project.claim_count": {"name": "claim_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_count", "block_contents": "The number of claims associated with the encounter or record."}, "doc.the_tuva_project.claim_end_date": {"name": "claim_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_end_date", "block_contents": "End date for the claim."}, "doc.the_tuva_project.claim_id": {"name": "claim_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_id", "block_contents": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient."}, "doc.the_tuva_project.claim_line_attribution_number": {"name": "claim_line_attribution_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_attribution_number", "block_contents": "A unique number used for attributing or associating specific claim lines with entities or processes."}, "doc.the_tuva_project.claim_line_end_date": {"name": "claim_line_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_end_date", "block_contents": "End date for the claim line."}, "doc.the_tuva_project.claim_line_id": {"name": "claim_line_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_id", "block_contents": "Unique identifier for each line item within a claim."}, "doc.the_tuva_project.claim_line_number": {"name": "claim_line_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_number", "block_contents": "Indicates the line number for the particular line of the claim."}, "doc.the_tuva_project.claim_line_start_date": {"name": "claim_line_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_start_date", "block_contents": "Start date for the claim line."}, "doc.the_tuva_project.claim_start_date": {"name": "claim_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_start_date", "block_contents": "The date when the healthcare service was provided. Format: YYYY-MM-DD."}, "doc.the_tuva_project.claim_type": {"name": "claim_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_type", "block_contents": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision."}, "doc.the_tuva_project.close_flag": {"name": "close_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.close_flag", "block_contents": "A flag indicating if the claim has been closed."}, "doc.the_tuva_project.coinsurance_amount": {"name": "coinsurance_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.coinsurance_amount", "block_contents": "The total coinsurance charged on the claim by the provider."}, "doc.the_tuva_project.collection_date": {"name": "collection_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.collection_date", "block_contents": "Date the test was collected."}, "doc.the_tuva_project.condition_id": {"name": "condition_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.condition_id", "block_contents": "Unique identifier for each condition in the table."}, "doc.the_tuva_project.condition_rank": {"name": "condition_rank", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.condition_rank", "block_contents": "The numerical ranking of a diagnosis code in a claim. Principle diagnosis code is given a ranking of 1. Claims data typically has a strict ranking of conditions whereas medical records will often not have this information or the information won't be accurate."}, "doc.the_tuva_project.condition_type": {"name": "condition_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.condition_type", "block_contents": "The type of condition i.e. problem, admitting, or billing."}, "doc.the_tuva_project.copayment_amount": {"name": "copayment_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.copayment_amount", "block_contents": "The total copayment charged on the claim by the provider."}, "doc.the_tuva_project.county": {"name": "county", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.county", "block_contents": "The county for the patient."}, "doc.the_tuva_project.custom_attributed_provider": {"name": "custom_attributed_provider", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider", "block_contents": "Unique identifier for the provider assigned to this patient-year_month by the user."}, "doc.the_tuva_project.custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider_practice", "block_contents": "Name of the practice for the attributed provider assigned by the user."}, "doc.the_tuva_project.custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider_organization", "block_contents": "Name of the organization for the attributed provider assigned by the user."}, "doc.the_tuva_project.custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider_lob", "block_contents": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial)."}, "doc.the_tuva_project.data_source": {"name": "data_source", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.data_source", "block_contents": "User-configured field that indicates the data source."}, "doc.the_tuva_project.days_supply": {"name": "days_supply", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.days_supply", "block_contents": "The number of days supply included."}, "doc.the_tuva_project.death_date": {"name": "death_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.death_date", "block_contents": "Date the patient died if there is one."}, "doc.the_tuva_project.death_flag": {"name": "death_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.death_flag", "block_contents": "A flag indicating if the patient has died."}, "doc.the_tuva_project.deductible_amount": {"name": "deductible_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.deductible_amount", "block_contents": "The total amount charged on the claim by the provider."}, "doc.the_tuva_project.default_ccsr_category_description_ip": {"name": "default_ccsr_category_description_ip", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_description_ip", "block_contents": "Description of the default Clinical Classifications Software Refined (CCSR) category for inpatient services."}, "doc.the_tuva_project.default_ccsr_category_description_op": {"name": "default_ccsr_category_description_op", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_description_op", "block_contents": "Description of the default Clinical Classifications Software Refined (CCSR) category for outpatient services."}, "doc.the_tuva_project.default_ccsr_category_ip": {"name": "default_ccsr_category_ip", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_ip", "block_contents": "The default Clinical Classifications Software Refined (CCSR) category code for inpatient services."}, "doc.the_tuva_project.default_ccsr_category_op": {"name": "default_ccsr_category_op", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_op", "block_contents": "The default Clinical Classifications Software Refined (CCSR) category code for outpatient services."}, "doc.the_tuva_project.delivery_flag": {"name": "delivery_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.delivery_flag", "block_contents": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no)."}, "doc.the_tuva_project.delivery_type": {"name": "delivery_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.delivery_type", "block_contents": "Type of delivery that occurred during the encounter, if applicable."}, "doc.the_tuva_project.diagnosis_code_1": {"name": "diagnosis_code_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.diagnosis_code_1", "block_contents": "The primary diagnosis code for the encounter or claim."}, "doc.the_tuva_project.diagnosis_code_type": {"name": "diagnosis_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.diagnosis_code_type", "block_contents": "The coding system used for the diagnosis code (e.g., ICD-10-CM, ICD-9-CM)."}, "doc.the_tuva_project.discharge_date": {"name": "discharge_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.discharge_date", "block_contents": "Discharge date for the claim (inpatient claims only)."}, "doc.the_tuva_project.discharge_disposition_code": {"name": "discharge_disposition_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.discharge_disposition_code", "block_contents": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only)."}, "doc.the_tuva_project.discharge_disposition_description": {"name": "discharge_disposition_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.discharge_disposition_description", "block_contents": "Description of the discharge_disposition_code for the encounter."}, "doc.the_tuva_project.dispensing_date": {"name": "dispensing_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.dispensing_date", "block_contents": "Date the medication was dispensed."}, "doc.the_tuva_project.dispensing_provider_id": {"name": "dispensing_provider_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.dispensing_provider_id", "block_contents": "ID for the provider that dispensed the prescription (e.g. pharmacy)."}, "doc.the_tuva_project.dispensing_provider_name": {"name": "dispensing_provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.dispensing_provider_name", "block_contents": "Dispensing provider name."}, "doc.the_tuva_project.distinct_claims": {"name": "distinct_claims", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.distinct_claims", "block_contents": "The number of distinct claims associated with the record."}, "doc.the_tuva_project.distinct_service_category_count": {"name": "distinct_service_category_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.distinct_service_category_count", "block_contents": "The count of distinct service categories associated with the claim."}, "doc.the_tuva_project.dme_flag": {"name": "dme_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.dme_flag", "block_contents": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.dq_problem": {"name": "dq_problem", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.dq_problem", "block_contents": "A flag or description indicating a data quality issue."}, "doc.the_tuva_project.dual_status_code": {"name": "dual_status_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.dual_status_code", "block_contents": "Indicates whether the patient is dually eligible for Medicare and Medicaid."}, "doc.the_tuva_project.duplicate_row_number": {"name": "duplicate_row_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.duplicate_row_number", "block_contents": "A number assigned to duplicate rows for identification purposes."}, "doc.the_tuva_project.ed_flag": {"name": "ed_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ed_flag", "block_contents": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no)."}, "doc.the_tuva_project.eligibility_id": {"name": "eligibility_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.eligibility_id", "block_contents": "Unique identifier for each eligibility row in the table."}, "doc.the_tuva_project.encounter_claim_number": {"name": "encounter_claim_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_claim_number", "block_contents": "A unique identifier for the encounter or claim."}, "doc.the_tuva_project.encounter_claim_number_desc": {"name": "encounter_claim_number_desc", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_claim_number_desc", "block_contents": "A description or additional information about the encounter claim number."}, "doc.the_tuva_project.encounter_end_date": {"name": "encounter_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_end_date", "block_contents": "Date when the encounter ended."}, "doc.the_tuva_project.encounter_group": {"name": "encounter_group", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_group", "block_contents": "Categorization of the encounter into groups based on predefined criteria."}, "doc.the_tuva_project.encounter_id": {"name": "encounter_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_id", "block_contents": "Unique identifier for each encounter in the dataset."}, "doc.the_tuva_project.encounter_source_type": {"name": "encounter_source_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_source_type", "block_contents": "Indicates whether the encounter is from a claims or clinical data source"}, "doc.the_tuva_project.encounter_start_date": {"name": "encounter_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_start_date", "block_contents": "Date when the encounter started."}, "doc.the_tuva_project.encounter_type": {"name": "encounter_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_type", "block_contents": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc."}, "doc.the_tuva_project.end_date": {"name": "end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.end_date", "block_contents": "The end date of the service or claim period."}, "doc.the_tuva_project.enrollment_end_date": {"name": "enrollment_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.enrollment_end_date", "block_contents": "Date the patient's insurance eligibility ended."}, "doc.the_tuva_project.enrollment_flag": {"name": "enrollment_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.enrollment_flag", "block_contents": "Flag indicating if the claim has corresponding enrollment during the same time period the service occurred."}, "doc.the_tuva_project.enrollment_start_date": {"name": "enrollment_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.enrollment_start_date", "block_contents": "Date the patient's insurance eligibility began."}, "doc.the_tuva_project.facility_id": {"name": "facility_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_id", "block_contents": "Facility ID for the claim (typically represents the facility where services were performed)."}, "doc.the_tuva_project.facility_name": {"name": "facility_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_name", "block_contents": "Facility name."}, "doc.the_tuva_project.facility_npi": {"name": "facility_npi", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_npi", "block_contents": "Facility NPI for the claim (typically represents the facility where services were performed)."}, "doc.the_tuva_project.facility_type": {"name": "facility_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_type", "block_contents": "The type of facility e.g. acute care hospital."}, "doc.the_tuva_project.first_name": {"name": "first_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.first_name", "block_contents": "The first name of the patient."}, "doc.the_tuva_project.gender": {"name": "gender", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.gender", "block_contents": "The gender of the patient."}, "doc.the_tuva_project.hcpcs_code": {"name": "hcpcs_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_code", "block_contents": "The CPT or HCPCS code representing the procedure or service provided. These codes are used to describe medical, surgical, and diagnostic services."}, "doc.the_tuva_project.hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_1", "block_contents": "1st modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_2", "block_contents": "2nd modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_3", "block_contents": "3rd modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_4", "block_contents": "4th modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_5", "block_contents": "5th modifier for HCPCS code."}, "doc.the_tuva_project.in_network_flag": {"name": "in_network_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.in_network_flag", "block_contents": "Flag indicating if the claim was in or out of network."}, "doc.the_tuva_project.inferred_claim_end_column_used": {"name": "inferred_claim_end_column_used", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_end_column_used", "block_contents": "The column used to infer the claim end date."}, "doc.the_tuva_project.inferred_claim_end_year_month": {"name": "inferred_claim_end_year_month", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_end_year_month", "block_contents": "The inferred year and month of the claim end date."}, "doc.the_tuva_project.inferred_claim_start_column_used": {"name": "inferred_claim_start_column_used", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_start_column_used", "block_contents": "The column used to infer the claim start date."}, "doc.the_tuva_project.inferred_claim_start_year_month": {"name": "inferred_claim_start_year_month", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_start_year_month", "block_contents": "The inferred year and month of the claim start date."}, "doc.the_tuva_project.inst_claim_count": {"name": "inst_claim_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.inst_claim_count", "block_contents": "Number of institutional claims generated from the encounter."}, "doc.the_tuva_project.lab_flag": {"name": "lab_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.lab_flag", "block_contents": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.lab_result_id": {"name": "lab_result_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.lab_result_id", "block_contents": "Unique identifier for each lab result."}, "doc.the_tuva_project.last_name": {"name": "last_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.last_name", "block_contents": "The last name of the patient."}, "doc.the_tuva_project.latitude": {"name": "latitude", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.latitude", "block_contents": "The latitude of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.length_of_stay": {"name": "length_of_stay", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.length_of_stay", "block_contents": "Length of the encounter calculated as encounter_end_date - encounter_start_date."}, "doc.the_tuva_project.location_id": {"name": "location_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.location_id", "block_contents": "Unique identifier for each location."}, "doc.the_tuva_project.longitude": {"name": "longitude", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.longitude", "block_contents": "The longitude of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.mapping_method": {"name": "mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.medical_claim_id": {"name": "medical_claim_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.medical_claim_id", "block_contents": "Unique identifier for each row in the table."}, "doc.the_tuva_project.medical_surgical": {"name": "medical_surgical", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.medical_surgical", "block_contents": "A flag or code indicating if the service was medical or surgical."}, "doc.the_tuva_project.medicare_status_code": {"name": "medicare_status_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.medicare_status_code", "block_contents": "Indicates how the patient became eligible for Medicare."}, "doc.the_tuva_project.medication_id": {"name": "medication_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.medication_id", "block_contents": "Unique identifier for each medication in the table."}, "doc.the_tuva_project.member_id": {"name": "member_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.member_id", "block_contents": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan."}, "doc.the_tuva_project.min_closing_row": {"name": "min_closing_row", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.min_closing_row", "block_contents": "The minimum row number for closing entries in the dataset."}, "doc.the_tuva_project.modality": {"name": "modality", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.modality", "block_contents": "The mode or method of treatment or service delivery."}, "doc.the_tuva_project.modifier_1": {"name": "modifier_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_1", "block_contents": "First modifier for the procedure code."}, "doc.the_tuva_project.modifier_2": {"name": "modifier_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_2", "block_contents": "Second modifier for the procedure code."}, "doc.the_tuva_project.modifier_3": {"name": "modifier_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_3", "block_contents": "Third modifier for the procedure code."}, "doc.the_tuva_project.modifier_4": {"name": "modifier_4", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_4", "block_contents": "Fourth modifier for the procedure code."}, "doc.the_tuva_project.modifier_5": {"name": "modifier_5", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_5", "block_contents": "Fifth modifier for the procedure code."}, "doc.the_tuva_project.mortality_flag": {"name": "mortality_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.mortality_flag", "block_contents": "A flag indicating if the patient died during the encounter."}, "doc.the_tuva_project.ms_drg_code": {"name": "ms_drg_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ms_drg_code", "block_contents": "MS-DRG for the claim (inpatient claims only)."}, "doc.the_tuva_project.ms_drg_description": {"name": "ms_drg_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ms_drg_description", "block_contents": "Description of the ms_drg_code."}, "doc.the_tuva_project.name": {"name": "name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.name", "block_contents": "The name of the location."}, "doc.the_tuva_project.ndc_code": {"name": "ndc_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ndc_code", "block_contents": "National drug code associated with the medication."}, "doc.the_tuva_project.ndc_description": {"name": "ndc_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ndc_description", "block_contents": "Description for the NDC."}, "doc.the_tuva_project.ndc_mapping_method": {"name": "ndc_mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ndc_mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.newborn_flag": {"name": "newborn_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.newborn_flag", "block_contents": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no)."}, "doc.the_tuva_project.nicu_flag": {"name": "nicu_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.nicu_flag", "block_contents": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.normalized_abnormal_flag": {"name": "normalized_abnormal_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_abnormal_flag", "block_contents": "Normalized abnormal flag."}, "doc.the_tuva_project.normalized_code": {"name": "normalized_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_code", "block_contents": "The normalized code."}, "doc.the_tuva_project.normalized_code_type": {"name": "normalized_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_code_type", "block_contents": "The normalized type of code."}, "doc.the_tuva_project.normalized_component": {"name": "normalized_component", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_component", "block_contents": "The normalized component."}, "doc.the_tuva_project.normalized_description": {"name": "normalized_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_description", "block_contents": "Normalized description of the code."}, "doc.the_tuva_project.normalized_reference_range_high": {"name": "normalized_reference_range_high", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_reference_range_high", "block_contents": "The normalized high end of the reference range."}, "doc.the_tuva_project.normalized_reference_range_low": {"name": "normalized_reference_range_low", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_reference_range_low", "block_contents": "The normalized low end of the reference range."}, "doc.the_tuva_project.normalized_units": {"name": "normalized_units", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_units", "block_contents": "Normalized units of the lab test."}, "doc.the_tuva_project.npi": {"name": "npi", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.npi", "block_contents": "The national provider identifier associated with the record e.g. facility_npi, provider_npi"}, "doc.the_tuva_project.observation_date": {"name": "observation_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_date", "block_contents": "Date the observation was recorded."}, "doc.the_tuva_project.observation_flag": {"name": "observation_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_flag", "block_contents": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no)."}, "doc.the_tuva_project.observation_id": {"name": "observation_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_id", "block_contents": "Unique identifier for each observation in the dataset."}, "doc.the_tuva_project.observation_type": {"name": "observation_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_type", "block_contents": "Type of observation."}, "doc.the_tuva_project.old_encounter_id": {"name": "old_encounter_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.old_encounter_id", "block_contents": "A previous or alternative identifier for the encounter."}, "doc.the_tuva_project.onset_date": {"name": "onset_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.onset_date", "block_contents": "Date when the condition first occurred."}, "doc.the_tuva_project.ordering_practitioner_id": {"name": "ordering_practitioner_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.ordering_practitioner_id", "block_contents": "Unique identifier for the practitioner who ordered the lab test."}, "doc.the_tuva_project.original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.original_reason_entitlement_code", "block_contents": "Original reason for Medicare entitlement code."}, "doc.the_tuva_project.original_service_cat_2": {"name": "original_service_cat_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.original_service_cat_2", "block_contents": "The original second-level service category."}, "doc.the_tuva_project.original_service_cat_3": {"name": "original_service_cat_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.original_service_cat_3", "block_contents": "The original third-level service category."}, "doc.the_tuva_project.paid_amount": {"name": "paid_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.paid_amount", "block_contents": "The total amount paid by the insurer."}, "doc.the_tuva_project.paid_date": {"name": "paid_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.paid_date", "block_contents": "The date the claim was paid."}, "doc.the_tuva_project.panel_id": {"name": "panel_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.panel_id", "block_contents": "Unique identifier for the panel."}, "doc.the_tuva_project.parent_organization": {"name": "parent_organization", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.parent_organization", "block_contents": "The parent organization associated with the facility."}, "doc.the_tuva_project.patient_data_source_id": {"name": "patient_data_source_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.patient_data_source_id", "block_contents": "Identifier for the source system from which patient data originated."}, "doc.the_tuva_project.patient_id": {"name": "patient_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.patient_id", "block_contents": "Unique identifier for each patient in the dataset."}, "doc.the_tuva_project.patient_row_num": {"name": "patient_row_num", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.patient_row_num", "block_contents": "A row number assigned to the patient's records."}, "doc.the_tuva_project.payer": {"name": "payer", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.payer", "block_contents": "Name of the payer (i.e. health insurer) providing coverage."}, "doc.the_tuva_project.payer_attributed_provider": {"name": "payer_attributed_provider", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider", "block_contents": "Unique identifier for the provider assigned to this patient-year_month by the payer."}, "doc.the_tuva_project.payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider_practice", "block_contents": "Name of the practice for the payer attributed provider."}, "doc.the_tuva_project.payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider_organization", "block_contents": "Name of the organization for the payer attributed provider."}, "doc.the_tuva_project.payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider_lob", "block_contents": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial)."}, "doc.the_tuva_project.payer_type": {"name": "payer_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_type", "block_contents": "Type of payer (e.g. commercial, medicare, medicaid, etc.)."}, "doc.the_tuva_project.pharmacy_claim_id": {"name": "pharmacy_claim_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.pharmacy_claim_id", "block_contents": "Unique identifier for each row in the table."}, "doc.the_tuva_project.pharmacy_flag": {"name": "pharmacy_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.pharmacy_flag", "block_contents": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.phone": {"name": "phone", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.phone", "block_contents": "The phone number for the patient."}, "doc.the_tuva_project.place_of_service_code": {"name": "place_of_service_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.place_of_service_code", "block_contents": "Place of service for the claim (professional claims only)."}, "doc.the_tuva_project.place_of_service_description": {"name": "place_of_service_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.place_of_service_description", "block_contents": "Place of service description."}, "doc.the_tuva_project.plan": {"name": "plan", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.plan", "block_contents": "Name of the plan (i.e. sub contract) providing coverage."}, "doc.the_tuva_project.practice_affiliation": {"name": "practice_affiliation", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.practice_affiliation", "block_contents": "Practice affiliation of the provider."}, "doc.the_tuva_project.practitioner_id": {"name": "practitioner_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.practitioner_id", "block_contents": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc)."}, "doc.the_tuva_project.prescribing_date": {"name": "prescribing_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.prescribing_date", "block_contents": "Date the medication was prescribed."}, "doc.the_tuva_project.prescribing_provider_id": {"name": "prescribing_provider_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.prescribing_provider_id", "block_contents": "ID for the provider that wrote the prescription (e.g. priamry care physician)."}, "doc.the_tuva_project.prescribing_provider_name": {"name": "prescribing_provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.prescribing_provider_name", "block_contents": "Prescribing provider name."}, "doc.the_tuva_project.present_on_admit_code": {"name": "present_on_admit_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.present_on_admit_code", "block_contents": "The present_on_admit_code related to the condition."}, "doc.the_tuva_project.present_on_admit_description": {"name": "present_on_admit_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.present_on_admit_description", "block_contents": "The description of the present_on_admit_code for the condition."}, "doc.the_tuva_project.primary_diagnosis_code": {"name": "primary_diagnosis_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_diagnosis_code", "block_contents": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim."}, "doc.the_tuva_project.primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_diagnosis_code_type", "block_contents": "The type of condition code reported in the source system e.g. ICD-10-CM."}, "doc.the_tuva_project.primary_diagnosis_description": {"name": "primary_diagnosis_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_diagnosis_description", "block_contents": "Description of the primary diagnosis code."}, "doc.the_tuva_project.primary_specialty_description": {"name": "primary_specialty_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_specialty_description", "block_contents": "Description of the primary medical specialty of the provider."}, "doc.the_tuva_project.primary_taxonomy_code": {"name": "primary_taxonomy_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_taxonomy_code", "block_contents": "The primary taxonomy code identifying the provider's specialty, classification, or area of practice."}, "doc.the_tuva_project.priority": {"name": "priority", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.priority", "block_contents": "The priority or urgency level of the service or claim."}, "doc.the_tuva_project.priority_number": {"name": "priority_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.priority_number", "block_contents": "A number indicating the priority or sequence of the service or claim."}, "doc.the_tuva_project.procedure_date": {"name": "procedure_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.procedure_date", "block_contents": "Date when the procedure was performed."}, "doc.the_tuva_project.procedure_id": {"name": "procedure_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.procedure_id", "block_contents": "The unique identifier for the performed procedure."}, "doc.the_tuva_project.prof_claim_count": {"name": "prof_claim_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.prof_claim_count", "block_contents": "Number of professional claims generated from the encounter."}, "doc.the_tuva_project.provider_first_name": {"name": "provider_first_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_first_name", "block_contents": "The first name of the healthcare provider."}, "doc.the_tuva_project.provider_last_name": {"name": "provider_last_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_last_name", "block_contents": "The last name of the healthcare provider."}, "doc.the_tuva_project.provider_name": {"name": "provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_name", "block_contents": "The name of the healthcare provider."}, "doc.the_tuva_project.provider_specialty": {"name": "provider_specialty", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_specialty", "block_contents": "The medical specialty of the provider."}, "doc.the_tuva_project.quantity": {"name": "quantity", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.quantity", "block_contents": "The quantity of the medication."}, "doc.the_tuva_project.quantity_unit": {"name": "quantity_unit", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.quantity_unit", "block_contents": "The units for the quantity."}, "doc.the_tuva_project.race": {"name": "race", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.race", "block_contents": "The patient's race."}, "doc.the_tuva_project.recorded_date": {"name": "recorded_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.recorded_date", "block_contents": "Date when the condition was recorded."}, "doc.the_tuva_project.refills": {"name": "refills", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.refills", "block_contents": "Number of refills for the prescription."}, "doc.the_tuva_project.relative_rank": {"name": "relative_rank", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.relative_rank", "block_contents": "A ranking or order of importance for the record."}, "doc.the_tuva_project.rend_primary_specialty_description": {"name": "rend_primary_specialty_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rend_primary_specialty_description", "block_contents": "A description of the rendering provider's primary specialty."}, "doc.the_tuva_project.rendering_id": {"name": "rendering_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rendering_id", "block_contents": "Rendering ID for the claim (typically represents the physician or entity providing services)."}, "doc.the_tuva_project.rendering_name": {"name": "rendering_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rendering_name", "block_contents": "Rendering provider name."}, "doc.the_tuva_project.rendering_tin": {"name": "rendering_tin", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rendering_tin", "block_contents": "Rendering provider tax identification number (TIN)."}, "doc.the_tuva_project.resolved_date": {"name": "resolved_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.resolved_date", "block_contents": "Date when the condition was resolved."}, "doc.the_tuva_project.result": {"name": "result", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.result", "block_contents": "The result of the record (e.g., lab test, observation, etc)."}, "doc.the_tuva_project.result_date": {"name": "result_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.result_date", "block_contents": "Date of the test result."}, "doc.the_tuva_project.revenue_center_code": {"name": "revenue_center_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.revenue_center_code", "block_contents": "Revenue center code for the claim line (institutional only and typically multiple codes per claim)."}, "doc.the_tuva_project.revenue_center_description": {"name": "revenue_center_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.revenue_center_description", "block_contents": "Revenue center description."}, "doc.the_tuva_project.route": {"name": "route", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.route", "block_contents": "The route used to administer the medication."}, "doc.the_tuva_project.rxnorm_code": {"name": "rxnorm_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rxnorm_code", "block_contents": "RxNorm code associated with the medication."}, "doc.the_tuva_project.rxnorm_description": {"name": "rxnorm_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rxnorm_description", "block_contents": "Description for the RxNorm code."}, "doc.the_tuva_project.rxnorm_mapping_method": {"name": "rxnorm_mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.rxnorm_mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.service_category_1": {"name": "service_category_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.service_category_1", "block_contents": "The broader service category this claim belongs to."}, "doc.the_tuva_project.service_category_2": {"name": "service_category_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.service_category_2", "block_contents": "The more specific service category this claim belongs to."}, "doc.the_tuva_project.service_category_3": {"name": "service_category_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.service_category_3", "block_contents": "The most specific service category this claim belongs to."}, "doc.the_tuva_project.service_type": {"name": "service_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.service_type", "block_contents": "The type of service provided."}, "doc.the_tuva_project.service_unit_quantity": {"name": "service_unit_quantity", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.service_unit_quantity", "block_contents": "The number of units for the particular revenue center code."}, "doc.the_tuva_project.sex": {"name": "sex", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.sex", "block_contents": "The gender of the patient."}, "doc.the_tuva_project.social_security_number": {"name": "social_security_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.social_security_number", "block_contents": "The social security number of the patient."}, "doc.the_tuva_project.source_abnormal_flag": {"name": "source_abnormal_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_abnormal_flag", "block_contents": "Indicates whether the result is abnormal or normal."}, "doc.the_tuva_project.source_code": {"name": "source_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_code", "block_contents": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)"}, "doc.the_tuva_project.source_code_type": {"name": "source_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_code_type", "block_contents": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)"}, "doc.the_tuva_project.source_component": {"name": "source_component", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_component", "block_contents": "The description for the component of the test from the source system."}, "doc.the_tuva_project.source_description": {"name": "source_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_description", "block_contents": "Description of the source code in the source system."}, "doc.the_tuva_project.source_model": {"name": "source_model", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_model", "block_contents": "Indicates the DBT source relation name from which data is derived."}, "doc.the_tuva_project.source_model_name": {"name": "source_model_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_model_name", "block_contents": "The name of the source data model."}, "doc.the_tuva_project.source_reference_range_high": {"name": "source_reference_range_high", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_reference_range_high", "block_contents": "The high end of the reference range from the source system."}, "doc.the_tuva_project.source_reference_range_low": {"name": "source_reference_range_low", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_reference_range_low", "block_contents": "The low end of the reference range from the source system."}, "doc.the_tuva_project.source_units": {"name": "source_units", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.source_units", "block_contents": "Source units of the lab test."}, "doc.the_tuva_project.specialty": {"name": "specialty", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.specialty", "block_contents": "Specialty of the provider."}, "doc.the_tuva_project.specimen": {"name": "specimen", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.specimen", "block_contents": "The type of specimen e.g. blood, plasma, urine."}, "doc.the_tuva_project.start_date": {"name": "start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.start_date", "block_contents": "The start date of the service or claim period."}, "doc.the_tuva_project.state": {"name": "state", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.state", "block_contents": "The state of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.status": {"name": "status", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.status", "block_contents": "Status of the record (e.g., condition, test, etc)."}, "doc.the_tuva_project.strength": {"name": "strength", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.strength", "block_contents": "The strength of the medication."}, "doc.the_tuva_project.sub_specialty": {"name": "sub_specialty", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.sub_specialty", "block_contents": "Sub specialty of the provider."}, "doc.the_tuva_project.subscriber_id": {"name": "subscriber_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.subscriber_id", "block_contents": "Identifier that links a patient to a particular insurance product or health plan."}, "doc.the_tuva_project.subscriber_relation": {"name": "subscriber_relation", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.subscriber_relation", "block_contents": "Identifier that links a patient to a particular insurance product or health plan."}, "doc.the_tuva_project.total_allowed_amount": {"name": "total_allowed_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.total_allowed_amount", "block_contents": "The total amount allowed by the insurance company for all services in the claim."}, "doc.the_tuva_project.total_charge_amount": {"name": "total_charge_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.total_charge_amount", "block_contents": "The total amount charged for all services in the claim."}, "doc.the_tuva_project.total_cost_amount": {"name": "total_cost_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.total_cost_amount", "block_contents": "The total amount paid on the claim by different parties."}, "doc.the_tuva_project.total_paid_amount": {"name": "total_paid_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.total_paid_amount", "block_contents": "The total amount paid for all services in the claim."}, "doc.the_tuva_project.tuva_last_run": {"name": "tuva_last_run", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.tuva_last_run", "block_contents": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var."}, "doc.the_tuva_project.year_month": {"name": "year_month", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.year_month", "block_contents": "Unique year-month of in the dataset computed from eligibility."}, "doc.the_tuva_project.zip_code": {"name": "zip_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks/column_descriptions.md", "unique_id": "doc.the_tuva_project.zip_code", "block_contents": "The zip code of the record (e.g., facility location, patient, etc)."}}, "exposures": {}, "metrics": {}, "groups": {}, "selectors": {}, "disabled": {"model.the_tuva_project.normalize__unmapped_condition": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__unmapped_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__unmapped_condition.sql", "original_file_path": "models/normalize/normalize__unmapped_condition.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_condition", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_condition"], "alias": "unmapped_condition", "checksum": {"name": "sha256", "checksum": "5d7d6154fd808195dbc476fc9779cce5be79e25b46e2f35d0d646296af338145"}, "config": {"enabled": false, "alias": "unmapped_condition", "schema": "normalize", "database": null, "tags": ["normalize"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalize"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_condition", "tags": "normalize", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.482223, "relation_name": "cms_synthetic.normalize.unmapped_condition", "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\n ) | as_bool\n )\n}}\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n sum(i.item_count) as item_count,\n i.domain as domain,\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\n cast( null as {{ dbt.type_string() }} ) as added_by,\n cast( null as {{ dbt.type_string() }} ) as added_date,\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\n cast( null as {{ dbt.type_string() }} ) as notes\nfrom {{ref('normalize__stg_unmapped_condition')}} i\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_medication": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__unmapped_medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__unmapped_medication.sql", "original_file_path": "models/normalize/normalize__unmapped_medication.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_medication", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_medication"], "alias": "unmapped_medication", "checksum": {"name": "sha256", "checksum": "46e57680d71754346b88baef605fccd3df775ba1d95604a790f3110a62f0b2ea"}, "config": {"enabled": false, "alias": "unmapped_medication", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_medication", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.487962, "relation_name": "cms_synthetic.normalize.unmapped_medication", "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('clinical_enabled', var('tuva_marts_enabled', False))\n ) | as_bool\n )\n}}\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n sum(i.item_count) as item_count,\n i.domain as domain,\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\n cast( null as {{ dbt.type_string() }} ) as added_by,\n cast( null as {{ dbt.type_string() }} ) as added_date,\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\n cast( null as {{ dbt.type_string() }} ) as notes\nfrom {{ref('normalize__stg_unmapped_medication')}} i\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_procedure": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__unmapped_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__unmapped_procedure.sql", "original_file_path": "models/normalize/normalize__unmapped_procedure.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_procedure", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_procedure"], "alias": "unmapped_procedure", "checksum": {"name": "sha256", "checksum": "3a6f6471a75d5a3f5a97f1801b9b65b861ad5d2997482a2f8ebcab754af29ece"}, "config": {"enabled": false, "alias": "unmapped_procedure", "schema": "normalize", "database": null, "tags": ["normalize"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalize"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_procedure", "tags": "normalize", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4840431, "relation_name": "cms_synthetic.normalize.unmapped_procedure", "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\n ) | as_bool\n )\n}}\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n sum(i.item_count) as item_count,\n i.domain as domain,\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\n cast( null as {{ dbt.type_string() }} ) as added_by,\n cast( null as {{ dbt.type_string() }} ) as added_date,\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\n cast( null as {{ dbt.type_string() }} ) as notes\nfrom {{ref('normalize__stg_unmapped_procedure')}} i\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__all_unmapped": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__all_unmapped", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__all_unmapped.sql", "original_file_path": "models/normalize/normalize__all_unmapped.sql", "unique_id": "model.the_tuva_project.normalize__all_unmapped", "fqn": ["the_tuva_project", "normalize", "normalize__all_unmapped"], "alias": "all_unmapped", "checksum": {"name": "sha256", "checksum": "c4721a47a88fada1042d1bbdc5f4b31978fdc8623d8678e475240a986db9a705"}, "config": {"enabled": false, "alias": "all_unmapped", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "all_unmapped", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.478936, "relation_name": "cms_synthetic.normalize.all_unmapped", "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\n ) | as_bool\n )\n}}\nwith agg_cte as (\n {% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n select * From {{ref('normalize__stg_unmapped_lab_result')}} union all\n select * From {{ref('normalize__stg_unmapped_medication')}} union all\n select * From {{ref('normalize__stg_unmapped_observation')}} union all\n {%- endif %}\n select * From {{ref('normalize__stg_unmapped_condition')}} union all\n select * From {{ref('normalize__stg_unmapped_procedure')}}\n)\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n sum(i.item_count) as item_count,\n {{ dbt.listagg(measure=\"distinct i.domain\", delimiter_text=\"', '\", order_by_clause=\"order by i.domain\" )}} as domains,\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\n cast( null as {{ dbt.type_string() }} ) as added_by,\n cast( null as {{ dbt.type_string() }} ) as added_date,\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\n cast( null as {{ dbt.type_string() }} ) as notes\nfrom agg_cte i\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_lab_result", "package": null, "version": null}, {"name": "normalize__stg_unmapped_medication", "package": null, "version": null}, {"name": "normalize__stg_unmapped_observation", "package": null, "version": null}, {"name": "normalize__stg_unmapped_condition", "package": null, "version": null}, {"name": "normalize__stg_unmapped_procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_observation": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__unmapped_observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__unmapped_observation.sql", "original_file_path": "models/normalize/normalize__unmapped_observation.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_observation", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_observation"], "alias": "unmapped_observation", "checksum": {"name": "sha256", "checksum": "f787520d636cdba72a03ceae1291cee61c2304ec1e57fab030ade79bfdd3be45"}, "config": {"enabled": false, "alias": "unmapped_observation", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_observation", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.489634, "relation_name": "cms_synthetic.normalize.unmapped_observation", "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('clinical_enabled', var('tuva_marts_enabled', False))\n ) | as_bool\n )\n}}\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n sum(i.item_count) as item_count,\n i.domain as domain,\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\n cast( null as {{ dbt.type_string() }} ) as added_by,\n cast( null as {{ dbt.type_string() }} ) as added_date,\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\n cast( null as {{ dbt.type_string() }} ) as notes\nfrom {{ref('normalize__stg_unmapped_observation')}} i\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__all_codes": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__all_codes", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__all_codes.sql", "original_file_path": "models/normalize/normalize__all_codes.sql", "unique_id": "model.the_tuva_project.normalize__all_codes", "fqn": ["the_tuva_project", "normalize", "normalize__all_codes"], "alias": "all_codes", "checksum": {"name": "sha256", "checksum": "75d20207b4c5ca17258d268e0a32f7e9c241c2f15814b51dfe95feeb58ccd070"}, "config": {"enabled": false, "alias": "all_codes", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "all_codes", "tags": "normalized", "materialized": "view", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.480514, "relation_name": "cms_synthetic.normalize.all_codes", "raw_code": "{{ config(\n enabled = ( var('enable_normalize_engine', False) == True and\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\n ) | as_bool\n )\n}}\nwith agg_cte as (\n {% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\n select * From {{ref('normalize__stg_unmapped_lab_result')}} union all\n select * From {{ref('normalize__stg_unmapped_medication')}} union all\n select * From {{ref('normalize__stg_unmapped_observation')}} union all\n {%- endif %}\n select * From {{ref('normalize__stg_unmapped_condition')}} union all\n select * From {{ref('normalize__stg_unmapped_procedure')}}\n)\n\nselect source_code_type,\n source_code,\n source_description,\n item_count,\n domains,\n data_sources,\n normalized_code_type,\n normalized_code,\n normalized_description,\n not_mapped,\n added_by,\n added_date,\n reviewed_by,\n reviewed_date,\n notes\nfrom {{ ref('custom_mapped') }}\n\n{% if target.type == 'fabric' %}\nunion\n{% else %}\nunion distinct\n{% endif %}\n\nselect un.source_code_type,\n un.source_code,\n un.source_description,\n un.item_count,\n un.domains,\n un.data_sources,\n un.normalized_code_type,\n un.normalized_code,\n un.normalized_description,\n un.not_mapped,\n un.added_by,\n un.added_date,\n un.reviewed_by,\n un.reviewed_date,\n un.notes\n from {{ref('normalize__all_unmapped')}} un \n left join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(un.source_code_type) = lower(custom_mapped.source_code_type)\n or ( un.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (un.source_code = custom_mapped.source_code\n or ( un.source_code is null and custom_mapped.source_code is null)\n )\n and (un.source_description = custom_mapped.source_description\n or ( un.source_description is null and custom_mapped.source_description is null)\n )\n where custom_mapped.source_code_type is null\n and custom_mapped.source_code is null\n and custom_mapped.source_description is null", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_lab_result", "package": null, "version": null}, {"name": "normalize__stg_unmapped_medication", "package": null, "version": null}, {"name": "normalize__stg_unmapped_observation", "package": null, "version": null}, {"name": "normalize__stg_unmapped_condition", "package": null, "version": null}, {"name": "normalize__stg_unmapped_procedure", "package": null, "version": null}, {"name": "custom_mapped", "package": null, "version": null}, {"name": "normalize__all_unmapped", "package": null, "version": null}, {"name": "custom_mapped", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_lab_result": [{"database": "cms_synthetic", "schema": "normalize", "name": "normalize__unmapped_lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/normalize__unmapped_lab_result.sql", "original_file_path": "models/normalize/normalize__unmapped_lab_result.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_lab_result", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_lab_result"], "alias": "unmapped_lab_result", "checksum": {"name": "sha256", "checksum": "d888200436e0be41ca3261f10fdddf08e73c294f2c6d85b0033747d1a68dd940"}, "config": {"enabled": false, "alias": "unmapped_lab_result", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_lab_result", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.486303, "relation_name": "cms_synthetic.normalize.unmapped_lab_result", "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('clinical_enabled', var('tuva_marts_enabled', False))\n ) | as_bool\n )\n}}\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n sum(i.item_count) as item_count,\n i.domain as domain,\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\n cast( null as {{ dbt.type_string() }} ) as added_by,\n cast( null as {{ dbt.type_string() }} ) as added_date,\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\n cast( null as {{ dbt.type_string() }} ) as notes\nfrom {{ref('normalize__stg_unmapped_lab_result')}} i\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_procedure": [{"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalize__stg_unmapped_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/staging/normalize__stg_unmapped_procedure.sql", "original_file_path": "models/normalize/staging/normalize__stg_unmapped_procedure.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_procedure", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_procedure"], "alias": "normalize__stg_unmapped_procedure", "checksum": {"name": "sha256", "checksum": "b1d0f39eef725b505fd1525a8859156163e3be176ff300712a4f469718c493a5"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4910982, "relation_name": null, "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\n ) | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) == True %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'procedure' as domain,\n i.data_source\nfrom {{ref('core__procedure')}} i\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (i.source_code = custom_mapped.source_code\n or ( i.source_code is null and custom_mapped.source_code is null)\n )\n and (i.source_description = custom_mapped.source_description\n or ( i.source_description is null and custom_mapped.source_description is null)\n )\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\n and custom_mapped.not_mapped is null\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% else %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'procedure' as domain,\n i.data_source\nfrom {{ref('core__procedure')}} i\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% endif %}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_lab_result": [{"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalize__stg_unmapped_lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/staging/normalize__stg_unmapped_lab_result.sql", "original_file_path": "models/normalize/staging/normalize__stg_unmapped_lab_result.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_lab_result", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_lab_result"], "alias": "normalize__stg_unmapped_lab_result", "checksum": {"name": "sha256", "checksum": "0f7734717399110d286b595a2684424a88f84d302118f67ae64c39f28399bb8b"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.491811, "relation_name": null, "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('clinical_enabled', var('tuva_marts_enabled', False))\n ) | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) == True %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'lab_result' as domain,\n i.data_source\nfrom {{ref('core__lab_result')}} i\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (i.source_code = custom_mapped.source_code\n or ( i.source_code is null and custom_mapped.source_code is null)\n )\n and (i.source_description = custom_mapped.source_description\n or ( i.source_description is null and custom_mapped.source_description is null)\n )\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\n and custom_mapped.not_mapped is null\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% else %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'lab_result' as domain,\n i.data_source\nfrom {{ref('core__lab_result')}} i\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% endif %}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_condition": [{"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalize__stg_unmapped_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/staging/normalize__stg_unmapped_condition.sql", "original_file_path": "models/normalize/staging/normalize__stg_unmapped_condition.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_condition", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_condition"], "alias": "normalize__stg_unmapped_condition", "checksum": {"name": "sha256", "checksum": "2553e8e577c09c598606e71cd0bc2c8e980f2a72738b65dd2b4ec3c66cc00066"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.490365, "relation_name": null, "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\n ) | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) == True %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'condition' as domain,\n i.data_source\nfrom {{ref('core__condition')}} i\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (i.source_code = custom_mapped.source_code\n or ( i.source_code is null and custom_mapped.source_code is null)\n )\n and (i.source_description = custom_mapped.source_description\n or ( i.source_description is null and custom_mapped.source_description is null)\n )\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\n and custom_mapped.not_mapped is null\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% else %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'condition' as domain,\n i.data_source\nfrom {{ref('core__condition')}} i\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% endif %}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_observation": [{"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalize__stg_unmapped_observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/staging/normalize__stg_unmapped_observation.sql", "original_file_path": "models/normalize/staging/normalize__stg_unmapped_observation.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_observation", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_observation"], "alias": "normalize__stg_unmapped_observation", "checksum": {"name": "sha256", "checksum": "8b2a6fa1325718af111b274da4d5ec32117ce6c1e9561e6a32c2da94c8b67245"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.4934988, "relation_name": null, "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('clinical_enabled', var('tuva_marts_enabled', False))\n ) | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) == True %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'observation' as domain,\n i.data_source\nfrom {{ref('core__observation')}} i\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (i.source_code = custom_mapped.source_code\n or ( i.source_code is null and custom_mapped.source_code is null)\n )\n and (i.source_description = custom_mapped.source_description\n or ( i.source_description is null and custom_mapped.source_description is null)\n )\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\n and custom_mapped.not_mapped is null\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% else %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'observation' as domain,\n i.data_source\nfrom {{ref('core__observation')}} i\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% endif %}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_medication": [{"database": "cms_synthetic", "schema": "dbt_tom", "name": "normalize__stg_unmapped_medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize/staging/normalize__stg_unmapped_medication.sql", "original_file_path": "models/normalize/staging/normalize__stg_unmapped_medication.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_medication", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_medication"], "alias": "normalize__stg_unmapped_medication", "checksum": {"name": "sha256", "checksum": "4cdac66de7bcf3e0454a847b2cd1c9aed5a2d98c7a7f66b87543788b84962cfe"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models/normalize/_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729623958.49255, "relation_name": null, "raw_code": "{{ config(\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\n var('clinical_enabled', var('tuva_marts_enabled', False))\n ) | as_bool\n )\n}}\n\n{% if var('enable_normalize_engine',false) == True %}\n\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'medication' as domain,\n i.data_source\nfrom {{ref('core__medication')}} i\nleft join {{ ref('custom_mapped') }} custom_mapped\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\n )\n and (i.source_code = custom_mapped.source_code\n or ( i.source_code is null and custom_mapped.source_code is null)\n )\n and (i.source_description = custom_mapped.source_description\n or ( i.source_description is null and custom_mapped.source_description is null)\n )\nwhere i.ndc_code is null and i.ndc_description is null and i.rxnorm_code is null and i.rxnorm_description is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\n and custom_mapped.not_mapped is null\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% else %}\n\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\n count(*) as item_count,\n 'medication' as domain,\n i.data_source\nfrom {{ref('core__medication')}} i\nwhere i.ndc_code is null and i.ndc_description is null and i.rxnorm_code is null and i.rxnorm_description is null\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\n\n{% endif %}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "snapshot.the_tuva_project.cms_hcc__patient_risk_scores_snapshot": [{"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_scores_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "cms_hcc/cms_hcc__patient_risk_scores_snapshot.sql", "original_file_path": "snapshots/cms_hcc/cms_hcc__patient_risk_scores_snapshot.sql", "unique_id": "snapshot.the_tuva_project.cms_hcc__patient_risk_scores_snapshot", "fqn": ["the_tuva_project", "cms_hcc", "cms_hcc__patient_risk_scores_snapshot", "cms_hcc__patient_risk_scores_snapshot"], "alias": "patient_risk_scores_snapshot", "checksum": {"name": "sha256", "checksum": "4b3b21d99ed2cd4e07165637399c669fb083e7218930a0113cec064678c2b69e"}, "config": {"enabled": false, "alias": "patient_risk_scores_snapshot", "schema": null, "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "patient_id||payment_year||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "cms_hcc", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["cms_hcc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "cms_hcc", "alias": "patient_risk_scores_snapshot", "tags": ["cms_hcc"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "patient_id||payment_year||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729623956.431804, "relation_name": "cms_synthetic.cms_hcc.patient_risk_scores_snapshot", "raw_code": "\n\n{% set schema_var %}\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_cms_hcc{% else %}cms_hcc{%- endif -%}\n{% endset %}\n\n{{\n config({\n \"target_schema\": schema_var\n , \"alias\": \"patient_risk_scores_snapshot\"\n , \"tags\": \"cms_hcc\"\n , \"strategy\": \"timestamp\"\n , \"updated_at\": \"tuva_last_run\"\n , \"unique_key\": \"patient_id||payment_year||tuva_last_run\"\n , \"enabled\": var('snapshots_enabled',False) == true and var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) == true | as_bool\n })\n}}\n\nselect * from {{ ref('cms_hcc__patient_risk_scores') }}\n\n", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}], "snapshot.the_tuva_project.cms_hcc__patient_risk_factors_snapshot": [{"database": "cms_synthetic", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_factors_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "cms_hcc/cms_hcc__patient_risk_factors_snapshot.sql", "original_file_path": "snapshots/cms_hcc/cms_hcc__patient_risk_factors_snapshot.sql", "unique_id": "snapshot.the_tuva_project.cms_hcc__patient_risk_factors_snapshot", "fqn": ["the_tuva_project", "cms_hcc", "cms_hcc__patient_risk_factors_snapshot", "cms_hcc__patient_risk_factors_snapshot"], "alias": "patient_risk_factors_snapshot", "checksum": {"name": "sha256", "checksum": "a70be9d54e7002d8c58e34ad19d6e3fd8ed685e4a555886ce6ce53163e959f3f"}, "config": {"enabled": false, "alias": "patient_risk_factors_snapshot", "schema": null, "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "patient_id||model_version||payment_year||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "cms_hcc", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["cms_hcc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "cms_hcc", "alias": "patient_risk_factors_snapshot", "tags": ["cms_hcc"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "patient_id||model_version||payment_year||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729623956.461854, "relation_name": "cms_synthetic.cms_hcc.patient_risk_factors_snapshot", "raw_code": "\n\n{% set schema_var %}\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_cms_hcc{% else %}cms_hcc{%- endif -%}\n{% endset %}\n\n{{\n config({\n \"target_schema\": schema_var\n , \"alias\": \"patient_risk_factors_snapshot\"\n , \"tags\": \"cms_hcc\"\n , \"strategy\": \"timestamp\"\n , \"updated_at\": \"tuva_last_run\"\n , \"unique_key\": \"patient_id||model_version||payment_year||tuva_last_run\"\n , \"enabled\": var('snapshots_enabled',False) == true and var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) == true | as_bool\n })\n}}\n\nselect * from {{ ref('cms_hcc__patient_risk_factors') }}\n\n", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}], "snapshot.the_tuva_project.quality_measures__summary_long_snapshot": [{"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__summary_long_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "quality_measures/quality_measures__summary_long_snapshot.sql", "original_file_path": "snapshots/quality_measures/quality_measures__summary_long_snapshot.sql", "unique_id": "snapshot.the_tuva_project.quality_measures__summary_long_snapshot", "fqn": ["the_tuva_project", "quality_measures", "quality_measures__summary_long_snapshot", "quality_measures__summary_long_snapshot"], "alias": "summary_long_snapshot", "checksum": {"name": "sha256", "checksum": "508100013ad380223276c6d6452bacdfc8e465acbc98483518f15a99fa0200ee"}, "config": {"enabled": false, "alias": "summary_long_snapshot", "schema": null, "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "patient_id||denominator_flag||numerator_flag||exclusion_flag||evidence_date||exclusion_date||exclusion_reason||performance_period_begin||performance_period_end||measure_id||measure_name||measure_version||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "quality_measures", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["quality_measures"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "quality_measures", "alias": "summary_long_snapshot", "tags": ["quality_measures"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "patient_id||denominator_flag||numerator_flag||exclusion_flag||evidence_date||exclusion_date||exclusion_reason||performance_period_begin||performance_period_end||measure_id||measure_name||measure_version||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729623956.466409, "relation_name": "cms_synthetic.quality_measures.summary_long_snapshot", "raw_code": "\n\n{% set schema_var %}\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_quality_measures{% else %}quality_measures{%- endif -%}\n{% endset %}\n\n{{\n config({\n \"target_schema\": schema_var\n , \"alias\": \"summary_long_snapshot\"\n , \"tags\": \"quality_measures\"\n , \"strategy\": \"timestamp\"\n , \"updated_at\": \"tuva_last_run\"\n , \"unique_key\": \"patient_id||denominator_flag||numerator_flag||exclusion_flag||evidence_date||exclusion_date||exclusion_reason||performance_period_begin||performance_period_end||measure_id||measure_name||measure_version||tuva_last_run\"\n , \"enabled\": var('snapshots_enabled',False) == true and var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) == true | as_bool\n })\n}}\n\nselect * from {{ ref('quality_measures__summary_long') }}\n\n", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}], "snapshot.the_tuva_project.quality_measures__summary_counts_snapshot": [{"database": "cms_synthetic", "schema": "quality_measures", "name": "quality_measures__summary_counts_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "quality_measures/quality_measures__summary_counts_snapshot.sql", "original_file_path": "snapshots/quality_measures/quality_measures__summary_counts_snapshot.sql", "unique_id": "snapshot.the_tuva_project.quality_measures__summary_counts_snapshot", "fqn": ["the_tuva_project", "quality_measures", "quality_measures__summary_counts_snapshot", "quality_measures__summary_counts_snapshot"], "alias": "summary_counts_snapshot", "checksum": {"name": "sha256", "checksum": "348565060acc2b018b5f81bca5b1994b9af39929bc7a448eb6eb029db5a6b2f1"}, "config": {"enabled": false, "alias": "summary_counts_snapshot", "schema": null, "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "measure_id||measure_name||measure_version||performance_period_begin||performance_period_end||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "quality_measures", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["quality_measures"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "quality_measures", "alias": "summary_counts_snapshot", "tags": ["quality_measures"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "measure_id||measure_name||measure_version||performance_period_begin||performance_period_end||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729623956.470727, "relation_name": "cms_synthetic.quality_measures.summary_counts_snapshot", "raw_code": "\n\n{% set schema_var %}\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_quality_measures{% else %}quality_measures{%- endif -%}\n{% endset %}\n\n{{\n config({\n \"target_schema\": schema_var\n , \"alias\": \"summary_counts_snapshot\"\n , \"tags\": \"quality_measures\"\n , \"strategy\": \"timestamp\"\n , \"updated_at\": \"tuva_last_run\"\n , \"unique_key\": \"measure_id||measure_name||measure_version||performance_period_begin||performance_period_end||tuva_last_run\"\n , \"enabled\": var('snapshots_enabled',False) == true and var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) == true | as_bool\n })\n}}\n\nselect * from {{ ref('quality_measures__summary_counts') }}\n\n", "language": "sql", "refs": [{"name": "quality_measures__summary_counts", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}]}, "parent_map": {"model.input_layer.provider_attribution": ["seed.input_layer.provider_attribution_seed"], "model.input_layer.procedure": [], "model.input_layer.practitioner": [], "model.input_layer.encounter": [], "model.input_layer.eligibility": ["seed.input_layer.eligibility_seed"], "model.input_layer.medical_claim": ["seed.input_layer.medical_claim_seed"], "model.input_layer.pharmacy_claim": ["seed.input_layer.pharmacy_claim_seed"], "model.input_layer.location": [], "model.input_layer.patient": [], "model.input_layer.condition": [], "model.input_layer.medication": [], "model.input_layer.observation": [], "model.input_layer.lab_result": [], "seed.input_layer.eligibility_seed": [], "seed.input_layer.medical_claim_seed": [], "seed.input_layer.provider_attribution_seed": [], "seed.input_layer.lab_result_seed": [], "seed.input_layer.observation_seed": [], "seed.input_layer.pharmacy_claim_seed": [], "model.the_tuva_project.pharmacy__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.pharmacy__brand_generic_opportunity": ["model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__int_generic_cost", "model.the_tuva_project.pharmacy__stg_pharmacy_claim"], "model.the_tuva_project.pharmacy__generic_available_list": ["model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": ["model.the_tuva_project.pharmacy__brand_generic_opportunity", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic"], "model.the_tuva_project.pharmacy__int_claims_current_cost": ["model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic"], "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": ["model.the_tuva_project.pharmacy__int_claims_current_cost", "seed.the_tuva_project.pharmacy__rxnorm_generic_available"], "model.the_tuva_project.pharmacy__int_brand_with_generic_available": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available"], "model.the_tuva_project.pharmacy__int_generic_cost": ["model.the_tuva_project.pharmacy__int_claims_current_cost", "seed.the_tuva_project.pharmacy__rxnorm_generic_available"], "model.the_tuva_project.medical_claim_expanded": ["model.input_layer.medical_claim"], "model.the_tuva_project.core__stg_claims_encounter": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.core__stg_clinical_condition": ["model.input_layer.condition"], "model.the_tuva_project.core__stg_claims_location": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.core__stg_claims_practitioner": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.core__stg_claims_eligibility": ["model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.core__stg_claims_medical_claim": ["model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.core__stg_claims_procedure": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.core__stg_clinical_patient": ["model.input_layer.patient"], "model.the_tuva_project.core__stg_clinical_procedure": ["model.input_layer.procedure"], "model.the_tuva_project.core__stg_clinical_encounter": ["model.input_layer.encounter"], "model.the_tuva_project.core__stg_clinical_medication": ["model.input_layer.medication"], "model.the_tuva_project.core__stg_claims_condition": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__present_on_admission"], "model.the_tuva_project.core__stg_clinical_lab_result": ["model.input_layer.lab_result"], "model.the_tuva_project.core__stg_clinical_practitioner": ["model.input_layer.practitioner"], "model.the_tuva_project.core__stg_claims_pharmacy_claim": ["model.the_tuva_project.normalized_input__pharmacy_claim"], "model.the_tuva_project.core__stg_clinical_location": ["model.input_layer.location"], "model.the_tuva_project.core__stg_claims_patient": ["model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.core__stg_clinical_observation": ["model.input_layer.observation"], "model.the_tuva_project.core__pharmacy_claim": ["model.the_tuva_project.core__stg_claims_pharmacy_claim"], "model.the_tuva_project.core__condition": ["model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_clinical_condition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__patient": ["model.the_tuva_project.core__stg_claims_patient", "model.the_tuva_project.core__stg_clinical_patient"], "model.the_tuva_project.core__lab_result": ["model.the_tuva_project.core__stg_clinical_lab_result", "seed.the_tuva_project.terminology__loinc", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__encounter": ["model.the_tuva_project.core__stg_claims_encounter", "model.the_tuva_project.core__stg_clinical_encounter"], "model.the_tuva_project.core__eligibility": ["model.the_tuva_project.core__stg_claims_eligibility"], "model.the_tuva_project.core__procedure": ["model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.core__stg_clinical_procedure", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__location": ["model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_clinical_location"], "model.the_tuva_project.core__member_months": ["model.the_tuva_project.core__eligibility", "model.the_tuva_project.financial_pmpm__stg_provider_attribution", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.core__medication": ["model.the_tuva_project.core__stg_clinical_medication", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.core__observation": ["model.the_tuva_project.core__stg_clinical_observation", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__loinc", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__practitioner": ["model.the_tuva_project.core__stg_claims_practitioner", "model.the_tuva_project.core__stg_clinical_practitioner"], "model.the_tuva_project.mart_review__stg_member_month": ["model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__stg_medical_claim": ["model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__data_source": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.mart_review__tuva_chronic_conditions": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__patient"], "model.the_tuva_project.mart_review__inpatient": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__location", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"], "model.the_tuva_project.mart_review__pharmacy": ["model.the_tuva_project.core__location", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__practitioner", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.mart_review__patient_risk_scores": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "model.the_tuva_project.mart_review__patient_risk_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.mart_review__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.mart_review__quality_measures_summary_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.mart_review__enrollment_change": ["model.the_tuva_project.mart_review__stg_member_month"], "model.the_tuva_project.mart_review__pmpm": ["model.the_tuva_project.financial_pmpm__pmpm_payer"], "model.the_tuva_project.mart_review__members_with_claims": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.mart_review__stg_pharmacy_claim"], "model.the_tuva_project.mart_review__patient_risk": ["model.the_tuva_project.mart_review__patient_risk_factors"], "model.the_tuva_project.mart_review__ed_classification": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__location", "model.the_tuva_project.ed_classification__summary", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"], "model.the_tuva_project.mart_review__calendar_month": ["seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__member_months": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.mart_review__claims_with_enrollment": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.mart_review__stg_medical_claim"], "model.the_tuva_project.mart_review__readmissions": ["model.the_tuva_project.readmissions__readmission_summary"], "model.the_tuva_project.mart_review__quality_measures_value_set": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.mart_review__number_of_conditions": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__patient"], "model.the_tuva_project.data_quality__stg_institutional_inpatient": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__stg_pharmacy_claim": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__stg_eligibility": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__stg_medical_claim": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_to_mart"], "model.the_tuva_project.data_quality__raw_summary": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__data_quality_detail": ["model.the_tuva_project.data_quality__data_quality_claims_detail", "model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__summary": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"], "model.the_tuva_project.data_quality__quality_trend": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__data_quality_for_pbi": ["model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi"], "model.the_tuva_project.data_quality__practitioner_practice_affiliation": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_sub_specialty": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_last_name": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_practitioner_id": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_data_source": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_npi": ["model.input_layer.practitioner", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__practitioner_first_name": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_specialty": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__location_parent_organization": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_latitude": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_facility_type": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_zip_code": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_data_source": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_city": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_npi": ["model.input_layer.location", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__location_location_id": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_longitude": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_address": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_state": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_name": ["model.input_layer.location"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_admit_type_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": ["model.input_layer.encounter", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__encounter_encounter_type": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__encounter_type"], "model.the_tuva_project.data_quality__encounter_admit_source_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_ms_drg_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_admit_source_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_source"], "model.the_tuva_project.data_quality__encounter_charge_amount": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_length_of_stay": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_allowed_amount": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__encounter_facility_id": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__encounter_data_source": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_attending_provider_id": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__encounter_encounter_start_date": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_paid_amount": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_encounter_end_date": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_admit_type_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_type"], "model.the_tuva_project.data_quality__encounter_encounter_id": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_apr_drg_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_patient_id": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_apr_drg_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__apr_drg"], "model.the_tuva_project.data_quality__encounter_ms_drg_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__discharge_disposition"], "model.the_tuva_project.data_quality__procedure_normalized_code_type": ["model.input_layer.procedure", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__procedure_normalized_description": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_procedure_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_claim_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_source_code": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_source_code_type": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_source_description": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_practitioner_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_data_source": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_patient_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_procedure_date": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_encounter_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_modifier_5": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_4": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_normalized_code": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"], "model.the_tuva_project.data_quality__procedure_modifier_1": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_3": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_2": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_specimen": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_units": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_lab_result_id": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_collection_date": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_component": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"], "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__lab_result_result": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_code_type": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_description": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_code": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"], "model.the_tuva_project.data_quality__lab_result_source_description": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_status": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_accession_number": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_result_date": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_data_source": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_units": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_code_type": ["model.input_layer.lab_result", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_code": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_patient_id": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_component": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_encounter_id": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__condition_patient_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_normalized_code": ["model.input_layer.condition", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__condition_encounter_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_status": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_present_on_admit_description": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_normalized_description": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_condition_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_condition_rank": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_normalized_code_type": ["model.input_layer.condition", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__condition_onset_date": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_recorded_date": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_source_description": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_claim_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_source_code_type": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_data_source": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_condition_type": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_present_on_admit_code": ["model.input_layer.condition", "seed.the_tuva_project.terminology__present_on_admission"], "model.the_tuva_project.data_quality__condition_resolved_date": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_source_code": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__patient_sex": ["model.input_layer.patient", "seed.the_tuva_project.terminology__gender"], "model.the_tuva_project.data_quality__patient_state": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_city": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_longitude": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_county": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_race": ["model.input_layer.patient", "seed.the_tuva_project.terminology__race"], "model.the_tuva_project.data_quality__patient_death_flag": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_address": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_data_source": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_zip_code": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_first_name": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_last_name": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_latitude": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_birth_date": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_death_date": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_patient_id": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__medication_rxnorm_code": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.data_quality__medication_source_code": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_atc_code": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.data_quality__medication_dispensing_date": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_prescribing_date": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_days_supply": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_strength": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_patient_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_rxnorm_description": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_encounter_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_data_source": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_atc_description": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_quantity_unit": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_source_description": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_ndc_code": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_medication_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_source_code_type": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_ndc_description": ["model.input_layer.medication", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.data_quality__medication_quantity": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_practitioner_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_route": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__observation_source_code": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_units": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_observation_type": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_code": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_description": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_data_source": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_panel_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_observation_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_reference_range_low": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_result": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_code_type": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_observation_date": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_encounter_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_description": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_reference_range_high": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_units": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_code_type": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_patient_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__pharmacy_data_source": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_claim_line_number": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_days_supply": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_payer": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_paid_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_dispensing_date": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_member_id": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_ndc_code": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.data_quality__pharmacy_paid_date": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_refills": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_plan": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_patient_id": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_deductible_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_quantity": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_allowed_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_copayment_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_claim_id": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__eligibility_payer_type": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"], "model.the_tuva_project.data_quality__eligibility_zip_code": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_start_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_plan": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_end_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_medicare_status_code": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_status"], "model.the_tuva_project.data_quality__eligibility_death_flag": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_first_name": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_phone": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_payer": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_state": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__ssa_fips_state"], "model.the_tuva_project.data_quality__eligibility_member_id": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_data_source": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_race": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__race"], "model.the_tuva_project.data_quality__eligibility_address": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_patient_id": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_gender": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__gender"], "model.the_tuva_project.data_quality__eligibility_birth_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_city": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_dual_status_code": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_dual_eligibility"], "model.the_tuva_project.data_quality__eligibility_last_name": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_orec"], "model.the_tuva_project.data_quality__eligibility_death_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__claim_claim_line_number": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_charge_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_paid_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_data_source": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_line_start_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_paid_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_member_id": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_patient_id": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_payer": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_line_end_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_coinsurance_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_plan": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_copayment_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_total_cost_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_diagnosis_code_type": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__claim_deductible_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_type": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__claim_type"], "model.the_tuva_project.data_quality__claim_allowed_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_id": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_hcpcs_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__professional_claim_start_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__professional_diagnosis_code_1": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__professional_diagnosis_code_3": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__professional_diagnosis_code_2": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__professional_billing_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__professional_place_of_service_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__place_of_service"], "model.the_tuva_project.data_quality__professional_rendering_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__professional_facility_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__professional_claim_end_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_present_on_admission_2": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"], "model.the_tuva_project.data_quality__institutional_admission_date": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_present_on_admission_3": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_present_on_admission_1": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_ms_drg_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__institutional_billing_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__institutional_claim_start_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__institutional_procedure_date_1": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_procedure_date_3": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__institutional_procedure_date_2": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_admit_type_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_type"], "model.the_tuva_project.data_quality__institutional_claim_end_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_apr_drg_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__apr_drg"], "model.the_tuva_project.data_quality__institutional_facility_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__institutional_discharge_date": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_bill_type_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__bill_type"], "model.the_tuva_project.data_quality__institutional_revenue_center_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.data_quality__institutional_service_unit_quantity": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_admit_source_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_source"], "model.the_tuva_project.data_quality__institutional_procedure_code_1": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.data_quality__institutional_rendering_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__institutional_procedure_code_2": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.data_quality__institutional_procedure_code_3": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.data_quality__unique_value_examples": ["model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "model.the_tuva_project.data_quality__primary_keys_location_location_id", "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"], "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": ["model.the_tuva_project.data_quality__patient_patient_id"], "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": ["model.the_tuva_project.data_quality__practitioner_practitioner_id"], "model.the_tuva_project.data_quality__primary_keys_location_location_id": ["model.the_tuva_project.data_quality__location_location_id"], "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": ["model.the_tuva_project.data_quality__encounter_encounter_id"], "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": ["model.the_tuva_project.data_quality__medication_medication_id"], "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": ["model.the_tuva_project.data_quality__condition_condition_id"], "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": ["model.the_tuva_project.data_quality__observation_observation_id"], "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": ["model.the_tuva_project.data_quality__procedure_procedure_id"], "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": ["model.the_tuva_project.data_quality__lab_result_lab_result_id"], "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"], "model.the_tuva_project.data_quality__data_quality_clinical_detail": ["model.the_tuva_project.data_quality__condition_claim_id", "model.the_tuva_project.data_quality__condition_condition_id", "model.the_tuva_project.data_quality__condition_condition_rank", "model.the_tuva_project.data_quality__condition_condition_type", "model.the_tuva_project.data_quality__condition_data_source", "model.the_tuva_project.data_quality__condition_encounter_id", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__condition_normalized_description", "model.the_tuva_project.data_quality__condition_onset_date", "model.the_tuva_project.data_quality__condition_patient_id", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.data_quality__condition_present_on_admit_description", "model.the_tuva_project.data_quality__condition_recorded_date", "model.the_tuva_project.data_quality__condition_resolved_date", "model.the_tuva_project.data_quality__condition_source_code", "model.the_tuva_project.data_quality__condition_source_code_type", "model.the_tuva_project.data_quality__condition_source_description", "model.the_tuva_project.data_quality__condition_status", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__encounter_admit_source_description", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__encounter_admit_type_description", "model.the_tuva_project.data_quality__encounter_allowed_amount", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__encounter_apr_drg_description", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_charge_amount", "model.the_tuva_project.data_quality__encounter_data_source", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "model.the_tuva_project.data_quality__encounter_encounter_end_date", "model.the_tuva_project.data_quality__encounter_encounter_id", "model.the_tuva_project.data_quality__encounter_encounter_start_date", "model.the_tuva_project.data_quality__encounter_encounter_type", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__encounter_length_of_stay", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__encounter_ms_drg_description", "model.the_tuva_project.data_quality__encounter_paid_amount", "model.the_tuva_project.data_quality__encounter_patient_id", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "model.the_tuva_project.data_quality__lab_result_accession_number", "model.the_tuva_project.data_quality__lab_result_collection_date", "model.the_tuva_project.data_quality__lab_result_data_source", "model.the_tuva_project.data_quality__lab_result_encounter_id", "model.the_tuva_project.data_quality__lab_result_lab_result_id", "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_component", "model.the_tuva_project.data_quality__lab_result_normalized_description", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "model.the_tuva_project.data_quality__lab_result_normalized_units", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__lab_result_patient_id", "model.the_tuva_project.data_quality__lab_result_result", "model.the_tuva_project.data_quality__lab_result_result_date", "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_source_code", "model.the_tuva_project.data_quality__lab_result_source_code_type", "model.the_tuva_project.data_quality__lab_result_source_component", "model.the_tuva_project.data_quality__lab_result_source_description", "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "model.the_tuva_project.data_quality__lab_result_source_units", "model.the_tuva_project.data_quality__lab_result_specimen", "model.the_tuva_project.data_quality__lab_result_status", "model.the_tuva_project.data_quality__location_address", "model.the_tuva_project.data_quality__location_city", "model.the_tuva_project.data_quality__location_data_source", "model.the_tuva_project.data_quality__location_facility_type", "model.the_tuva_project.data_quality__location_latitude", "model.the_tuva_project.data_quality__location_location_id", "model.the_tuva_project.data_quality__location_longitude", "model.the_tuva_project.data_quality__location_name", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__location_parent_organization", "model.the_tuva_project.data_quality__location_state", "model.the_tuva_project.data_quality__location_zip_code", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_atc_description", "model.the_tuva_project.data_quality__medication_data_source", "model.the_tuva_project.data_quality__medication_days_supply", "model.the_tuva_project.data_quality__medication_dispensing_date", "model.the_tuva_project.data_quality__medication_encounter_id", "model.the_tuva_project.data_quality__medication_medication_id", "model.the_tuva_project.data_quality__medication_ndc_code", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__medication_patient_id", "model.the_tuva_project.data_quality__medication_practitioner_id", "model.the_tuva_project.data_quality__medication_prescribing_date", "model.the_tuva_project.data_quality__medication_quantity", "model.the_tuva_project.data_quality__medication_quantity_unit", "model.the_tuva_project.data_quality__medication_route", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.data_quality__medication_rxnorm_description", "model.the_tuva_project.data_quality__medication_source_code", "model.the_tuva_project.data_quality__medication_source_code_type", "model.the_tuva_project.data_quality__medication_source_description", "model.the_tuva_project.data_quality__medication_strength", "model.the_tuva_project.data_quality__observation_data_source", "model.the_tuva_project.data_quality__observation_encounter_id", "model.the_tuva_project.data_quality__observation_normalized_code", "model.the_tuva_project.data_quality__observation_normalized_code_type", "model.the_tuva_project.data_quality__observation_normalized_description", "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "model.the_tuva_project.data_quality__observation_normalized_units", "model.the_tuva_project.data_quality__observation_observation_date", "model.the_tuva_project.data_quality__observation_observation_id", "model.the_tuva_project.data_quality__observation_observation_type", "model.the_tuva_project.data_quality__observation_panel_id", "model.the_tuva_project.data_quality__observation_patient_id", "model.the_tuva_project.data_quality__observation_result", "model.the_tuva_project.data_quality__observation_source_code", "model.the_tuva_project.data_quality__observation_source_code_type", "model.the_tuva_project.data_quality__observation_source_description", "model.the_tuva_project.data_quality__observation_source_reference_range_high", "model.the_tuva_project.data_quality__observation_source_reference_range_low", "model.the_tuva_project.data_quality__observation_source_units", "model.the_tuva_project.data_quality__patient_address", "model.the_tuva_project.data_quality__patient_birth_date", "model.the_tuva_project.data_quality__patient_city", "model.the_tuva_project.data_quality__patient_county", "model.the_tuva_project.data_quality__patient_data_source", "model.the_tuva_project.data_quality__patient_death_date", "model.the_tuva_project.data_quality__patient_death_flag", "model.the_tuva_project.data_quality__patient_first_name", "model.the_tuva_project.data_quality__patient_last_name", "model.the_tuva_project.data_quality__patient_latitude", "model.the_tuva_project.data_quality__patient_longitude", "model.the_tuva_project.data_quality__patient_patient_id", "model.the_tuva_project.data_quality__patient_race", "model.the_tuva_project.data_quality__patient_sex", "model.the_tuva_project.data_quality__patient_state", "model.the_tuva_project.data_quality__patient_zip_code", "model.the_tuva_project.data_quality__practitioner_data_source", "model.the_tuva_project.data_quality__practitioner_first_name", "model.the_tuva_project.data_quality__practitioner_last_name", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "model.the_tuva_project.data_quality__practitioner_practitioner_id", "model.the_tuva_project.data_quality__practitioner_specialty", "model.the_tuva_project.data_quality__practitioner_sub_specialty", "model.the_tuva_project.data_quality__procedure_claim_id", "model.the_tuva_project.data_quality__procedure_data_source", "model.the_tuva_project.data_quality__procedure_encounter_id", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.data_quality__procedure_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_description", "model.the_tuva_project.data_quality__procedure_patient_id", "model.the_tuva_project.data_quality__procedure_practitioner_id", "model.the_tuva_project.data_quality__procedure_procedure_date", "model.the_tuva_project.data_quality__procedure_procedure_id", "model.the_tuva_project.data_quality__procedure_source_code", "model.the_tuva_project.data_quality__procedure_source_code_type", "model.the_tuva_project.data_quality__procedure_source_description"], "model.the_tuva_project.data_quality__claim_type_summary": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__data_quality_claims_detail": ["model.the_tuva_project.data_quality__claim_allowed_amount", "model.the_tuva_project.data_quality__claim_charge_amount", "model.the_tuva_project.data_quality__claim_claim_id", "model.the_tuva_project.data_quality__claim_claim_line_end_date", "model.the_tuva_project.data_quality__claim_claim_line_number", "model.the_tuva_project.data_quality__claim_claim_line_start_date", "model.the_tuva_project.data_quality__claim_claim_type", "model.the_tuva_project.data_quality__claim_coinsurance_amount", "model.the_tuva_project.data_quality__claim_copayment_amount", "model.the_tuva_project.data_quality__claim_data_source", "model.the_tuva_project.data_quality__claim_deductible_amount", "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__claim_member_id", "model.the_tuva_project.data_quality__claim_paid_amount", "model.the_tuva_project.data_quality__claim_paid_date", "model.the_tuva_project.data_quality__claim_patient_id", "model.the_tuva_project.data_quality__claim_payer", "model.the_tuva_project.data_quality__claim_plan", "model.the_tuva_project.data_quality__claim_total_cost_amount", "model.the_tuva_project.data_quality__eligibility_address", "model.the_tuva_project.data_quality__eligibility_birth_date", "model.the_tuva_project.data_quality__eligibility_city", "model.the_tuva_project.data_quality__eligibility_data_source", "model.the_tuva_project.data_quality__eligibility_death_date", "model.the_tuva_project.data_quality__eligibility_death_flag", "model.the_tuva_project.data_quality__eligibility_dual_status_code", "model.the_tuva_project.data_quality__eligibility_end_date", "model.the_tuva_project.data_quality__eligibility_first_name", "model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__eligibility_last_name", "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "model.the_tuva_project.data_quality__eligibility_member_id", "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "model.the_tuva_project.data_quality__eligibility_patient_id", "model.the_tuva_project.data_quality__eligibility_payer", "model.the_tuva_project.data_quality__eligibility_payer_type", "model.the_tuva_project.data_quality__eligibility_phone", "model.the_tuva_project.data_quality__eligibility_plan", "model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__eligibility_start_date", "model.the_tuva_project.data_quality__eligibility_state", "model.the_tuva_project.data_quality__eligibility_zip_code", "model.the_tuva_project.data_quality__institutional_admission_date", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_claim_end_date", "model.the_tuva_project.data_quality__institutional_claim_start_date", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__institutional_discharge_date", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__institutional_procedure_date_1", "model.the_tuva_project.data_quality__institutional_procedure_date_2", "model.the_tuva_project.data_quality__institutional_procedure_date_3", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "model.the_tuva_project.data_quality__pharmacy_claim_id", "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "model.the_tuva_project.data_quality__pharmacy_data_source", "model.the_tuva_project.data_quality__pharmacy_days_supply", "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_member_id", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.data_quality__pharmacy_paid_amount", "model.the_tuva_project.data_quality__pharmacy_paid_date", "model.the_tuva_project.data_quality__pharmacy_patient_id", "model.the_tuva_project.data_quality__pharmacy_payer", "model.the_tuva_project.data_quality__pharmacy_plan", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_quantity", "model.the_tuva_project.data_quality__pharmacy_refills", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_claim_end_date", "model.the_tuva_project.data_quality__professional_claim_start_date", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.data_quality__professional_rendering_npi"], "model.the_tuva_project.data_quality__eligibility_dq_stage": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__inpatient_dq_stage": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__service_category_pmpm_trend": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__analytics_reference_summary": ["model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__quality_measures_reference", "model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.data_quality__service_categories_pmpm"], "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__data_quality_test_summary": ["model.the_tuva_project.data_quality__eligibility_date_checks", "model.the_tuva_project.data_quality__eligibility_demographics", "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "model.the_tuva_project.data_quality__eligibility_missing_payer", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "model.the_tuva_project.data_quality__primary_key_check"], "model.the_tuva_project.data_quality__analytics_populated": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.core__encounter", "model.the_tuva_project.financial_pmpm__pmpm_payer", "model.the_tuva_project.quality_measures__summary_long", "model.the_tuva_project.readmissions__readmission_summary", "model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.data_quality__core_populated": ["model.the_tuva_project.core__condition", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__patient", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__procedure"], "model.the_tuva_project.data_quality__data_loss": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"], "model.the_tuva_project.data_quality__eligibility_trend": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__analytics_checks_summary": ["model.the_tuva_project.data_quality__acute_inpatient", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__cms_hcc", "model.the_tuva_project.data_quality__ed_classification", "model.the_tuva_project.data_quality__encounters_missing_groups_union", "model.the_tuva_project.data_quality__quality_measures", "model.the_tuva_project.data_quality__readmissions"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__claim_date_trends": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__chronic_conditions_none": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.core__patient", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__eligibility_date_checks": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__ed_classification": ["model.the_tuva_project.ed_classification__summary"], "model.the_tuva_project.data_quality__cms_hcc_reference": ["model.the_tuva_project.cms_hcc__patient_risk_scores", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__acute_inpatient_prevelence": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__medical_claim_date_checks": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage"], "model.the_tuva_project.data_quality__eligibility_missing_payer": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"], "model.the_tuva_project.data_quality__encounters_missing_groups": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.data_quality__readmissions_reference": ["model.the_tuva_project.readmissions__readmission_summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__pharmacy_claim_npi": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__medical_claim_patient_id": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"], "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": ["model.input_layer.pharmacy_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"], "model.the_tuva_project.data_quality__acute_inpatient": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__eligibility_demographics": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__pharmacy_claim_ndc": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.data_quality__cms_hcc": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.data_quality__service_categories_pmpm": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__ed_classification_reference": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.ed_classification__summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__financial_pmpm": ["model.the_tuva_project.financial_pmpm__pmpm_prep", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__quality_measures": ["model.the_tuva_project.quality_measures__summary_counts"], "model.the_tuva_project.data_quality__readmissions": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.data_quality__dx_and_px": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_9_pcs"], "model.the_tuva_project.data_quality__chronic_conditions_prevalence": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__eligibility", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__primary_key_check": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__eligibility_missing_patient_id": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__medical_claim_provider_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__claim_percent": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__acute_inpatient_reference": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__quality_measures_reference": ["model.the_tuva_project.quality_measures__summary_counts", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__encounters_missing_groups_union": ["model.the_tuva_project.data_quality__encounters_missing_groups"], "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": ["seed.the_tuva_project.clinical_concept_library__clinical_concepts", "seed.the_tuva_project.clinical_concept_library__coding_systems", "seed.the_tuva_project.clinical_concept_library__value_set_members"], "model.the_tuva_project.ed_classification__stg_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.ed_classification__stg_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.ed_classification__summary": ["model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "model.the_tuva_project.ed_classification__stg_patient", "seed.the_tuva_project.ed_classification__categories", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": ["model.the_tuva_project.ed_classification__int_map_primary_dx"], "model.the_tuva_project.ed_classification__int_map_primary_dx": ["model.the_tuva_project.ed_classification__stg_encounter", "seed.the_tuva_project.ed_classification__johnston_icd10", "seed.the_tuva_project.ed_classification__johnston_icd9"], "model.the_tuva_project.readmissions__stg_core__encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.readmissions__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.readmissions__encounter_augmented": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__index_admission", "model.the_tuva_project.readmissions__planned_encounter"], "model.the_tuva_project.readmissions__readmission_summary": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__encounter_overlap": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__encounter_specialty_cohort": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__specialty_cohort", "seed.the_tuva_project.readmissions__surgery_gynecology_cohort"], "model.the_tuva_project.readmissions__encounter_data_quality": ["model.the_tuva_project.readmissions__encounter_overlap", "model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.readmissions__exclusion": ["model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category"], "model.the_tuva_project.readmissions__index_admission": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__exclusion", "model.the_tuva_project.readmissions__index_discharge_requirement", "model.the_tuva_project.readmissions__index_time_requirement"], "model.the_tuva_project.readmissions__index_time_requirement": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__planned_encounter": ["model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__acute_diagnosis_ccs", "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs"], "model.the_tuva_project.readmissions__encounter": ["model.the_tuva_project.readmissions__stg_core__encounter"], "model.the_tuva_project.readmissions__readmission_crude": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_overlap"], "model.the_tuva_project.readmissions__procedure_ccs": ["model.the_tuva_project.readmissions__stg_core__procedure", "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.readmissions__encounter_with_ccs": ["model.the_tuva_project.readmissions__encounter", "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.readmissions__index_discharge_requirement": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.cms_hcc__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.cms_hcc__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.cms_hcc__stg_core__member_months": ["model.the_tuva_project.core__member_months"], "model.the_tuva_project.cms_hcc__stg_core__medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.cms_hcc__stg_core__eligibility": ["model.the_tuva_project.core__eligibility"], "model.the_tuva_project.cms_hcc__patient_risk_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors"], "model.the_tuva_project.cms_hcc__patient_risk_scores": ["model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.cms_hcc__stg_core__member_months", "seed.the_tuva_project.cms_hcc__adjustment_rates"], "model.the_tuva_project.cms_hcc__int_disease_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_factors"], "model.the_tuva_project.cms_hcc__int_eligible_conditions": ["model.the_tuva_project.cms_hcc__stg_core__condition", "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "seed.the_tuva_project.cms_hcc__cpt_hcpcs"], "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_interaction_factors"], "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": ["model.the_tuva_project.cms_hcc__int_hcc_mapping", "seed.the_tuva_project.cms_hcc__disease_hierarchy"], "model.the_tuva_project.cms_hcc__int_hcc_mapping": ["model.the_tuva_project.cms_hcc__int_eligible_conditions", "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings"], "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disabled_interaction_factors"], "model.the_tuva_project.cms_hcc__int_hcc_count_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors"], "model.the_tuva_project.cms_hcc__int_demographic_factors": ["model.the_tuva_project.cms_hcc__int_members", "seed.the_tuva_project.cms_hcc__demographic_factors"], "model.the_tuva_project.cms_hcc__int_members": ["model.the_tuva_project.cms_hcc__stg_core__eligibility", "model.the_tuva_project.cms_hcc__stg_core__patient"], "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors"], "model.the_tuva_project.normalized_input__stg_medical_claim": ["model.input_layer.medical_claim"], "model.the_tuva_project.normalized_input__stg_pharmacy_claim": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.normalized_input__stg_eligibility": ["model.input_layer.eligibility"], "model.the_tuva_project.normalized_input__eligibility": ["model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "model.the_tuva_project.normalized_input__stg_eligibility"], "model.the_tuva_project.normalized_input__pharmacy_claim": ["model.the_tuva_project.normalized_input__stg_pharmacy_claim", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.normalized_input__medical_claim": ["model.the_tuva_project.normalized_input__int_admit_source_final", "model.the_tuva_project.normalized_input__int_admit_type_final", "model.the_tuva_project.normalized_input__int_apr_drg_final", "model.the_tuva_project.normalized_input__int_bill_type_final", "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_ms_drg_final", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_present_on_admit_final", "model.the_tuva_project.normalized_input__int_procedure_code_final", "model.the_tuva_project.normalized_input__int_procedure_date_final", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.normalized_input__stg_medical_claim"], "model.the_tuva_project.normalized_input__int_revenue_center_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.normalized_input__int_medical_date_aggregation": ["model.the_tuva_project.normalized_input__int_medical_claim_date_normalize"], "model.the_tuva_project.normalized_input__int_procedure_date_voting": ["model.the_tuva_project.normalized_input__int_procedure_date_normalize"], "model.the_tuva_project.normalized_input__int_present_on_admit_final": ["model.the_tuva_project.normalized_input__int_present_on_admit_voting"], "model.the_tuva_project.normalized_input__int_apr_drg_final": ["model.the_tuva_project.normalized_input__int_apr_drg_voting"], "model.the_tuva_project.normalized_input__int_admit_type_final": ["model.the_tuva_project.normalized_input__int_admit_type_voting"], "model.the_tuva_project.normalized_input__int_admit_source_final": ["model.the_tuva_project.normalized_input__int_admit_source_voting"], "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": ["model.the_tuva_project.normalized_input__stg_eligibility", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.normalized_input__int_admit_source_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source"], "model.the_tuva_project.normalized_input__int_ms_drg_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"], "model.the_tuva_project.normalized_input__int_discharge_disposition_final": ["model.the_tuva_project.normalized_input__int_discharge_disposition_voting"], "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": ["model.the_tuva_project.normalized_input__int_diagnosis_code_normalize"], "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"], "model.the_tuva_project.normalized_input__int_procedure_date_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.normalized_input__int_procedure_date_final": ["model.the_tuva_project.normalized_input__int_procedure_date_voting"], "model.the_tuva_project.normalized_input__int_undetermined_claim_type": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.normalized_input__int_procedure_code_final": ["model.the_tuva_project.normalized_input__int_procedure_code_voting"], "model.the_tuva_project.normalized_input__int_apr_drg_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__apr_drg"], "model.the_tuva_project.normalized_input__int_ms_drg_final": ["model.the_tuva_project.normalized_input__int_ms_drg_voting"], "model.the_tuva_project.normalized_input__int_admit_type_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_type"], "model.the_tuva_project.normalized_input__int_present_on_admit_voting": ["model.the_tuva_project.normalized_input__int_present_on_admit_normalize"], "model.the_tuva_project.normalized_input__int_procedure_code_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"], "model.the_tuva_project.normalized_input__int_bill_type_final": ["model.the_tuva_project.normalized_input__int_bill_type_voting"], "model.the_tuva_project.normalized_input__int_bill_type_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__bill_type"], "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__present_on_admission"], "model.the_tuva_project.normalized_input__int_place_of_service_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__place_of_service"], "model.the_tuva_project.normalized_input__int_medical_npi_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.normalized_input__int_diagnosis_code_final": ["model.the_tuva_project.normalized_input__int_diagnosis_code_voting"], "model.the_tuva_project.normalized_input__int_procedure_code_voting": ["model.the_tuva_project.normalized_input__int_procedure_code_normalize"], "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.service_category__stg_medical_claim": ["model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.service_category__stg_outpatient_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__stg_office_based": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__stg_inpatient_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.service_category__stg_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__service_category_grouper": ["model.the_tuva_project.service_category__combined_institutional_header_level", "model.the_tuva_project.service_category__combined_institutional_line_level", "model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.service_category__service_categories"], "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__ambulatory_surgery_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__home_health_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__urgent_care_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__ambulatory_surgery_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__dialysis_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.service_category__lab_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": ["model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_rehab_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__dialysis_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__dme_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__outpatient_hospice_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__home_health_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__emergency_department_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_hospice_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__inpatient_psychiatric_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_rehab_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_substance_use_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__pharmacy_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__combined_institutional_line_level": ["model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__lab_institutional", "model.the_tuva_project.service_category__observation_institutional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__pharmacy_institutional"], "model.the_tuva_project.service_category__outpatient_surgery_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__inpatient_hospice_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_rehab_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__pharmacy_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__office_based_radiology": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__inpatient_hospice_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__lab_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__combined_institutional_header_level": ["model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__home_health_institutional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_surgery_institutional", "model.the_tuva_project.service_category__urgent_care_institutional"], "model.the_tuva_project.service_category__urgent_care_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__outpatient_radiology_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_radiology_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__combined_professional": ["model.the_tuva_project.service_category__acute_inpatient_professional", "model.the_tuva_project.service_category__ambulance_professional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "model.the_tuva_project.service_category__inpatient_rehab_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__office_based_other_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__outpatient_rehab_professional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_surgery_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__urgent_care_professional"], "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.service_category__acute_inpatient_institutional_other": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__ambulance_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__office_based_other_professional": ["model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__outpatient_substance_use_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__office_based_surgery_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__ambulance_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_psychiatric_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__outpatient_substance_use_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__emergency_department_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_surgery_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_rehab_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__observation_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__office_based_physical_therapy_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__observation_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__office_based_visit_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__acute_inpatient_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.encounters__patient_data_source_id": ["model.the_tuva_project.normalized_input__eligibility", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.encounters__stg_professional": ["model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.encounters__stg_outpatient_institutional": ["model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.encounters__stg_medical_claim": ["model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.encounters__stg_inpatient_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional"], "model.the_tuva_project.encounters__stg_eligibility": ["model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.ambulance__encounter_grain": ["model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_substance_use__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_substance_use__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_surgery__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.dialysis__encounter_grain": ["model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.acute_inpatient__encounter_grain": ["model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_rehab__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.home_health__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.orphaned_claim__encounter_grain": ["model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_ptotst__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_radiology__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_radiology__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.lab__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_psych__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.asc__encounter_grain": ["model.the_tuva_project.asc__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_hospice__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_hospice__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_hospice__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.emergency_department__encounter_grain": ["model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_injections__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_injections__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_psych__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_psych__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_snf__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_snf__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.dme__encounter_grain": ["model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_substance_use__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.urgent_care__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.urgent_care__generate_encounter_id", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.office_visit__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_rehab__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_rehab__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.encounters__combined_claim_line_crosswalk": ["model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.ambulance__match_claims_to_anchor", "model.the_tuva_project.asc__match_claims_to_anchor", "model.the_tuva_project.dialysis__match_claims_to_anchor", "model.the_tuva_project.dme__match_claims_to_anchor", "model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__match_claims_to_anchor", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.lab__match_claims_to_anchor", "model.the_tuva_project.office_visits__int_office_visits_claim_line", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "model.the_tuva_project.urgent_care__match_claims_to_anchor"], "model.the_tuva_project.encounters__orphaned_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_substance_use__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__anchor_events"], "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id"], "model.the_tuva_project.inpatient_rehab__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_rehab__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__start_end_dates"], "model.the_tuva_project.inpatient_rehab__start_end_dates": ["model.the_tuva_project.inpatient_rehab__generate_encounter_id"], "model.the_tuva_project.emergency_department__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.emergency_department__start_end_dates": ["model.the_tuva_project.emergency_department__generate_encounter_id"], "model.the_tuva_project.emergency_department__prof_claims": ["model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_outpatient_institutional", "model.the_tuva_project.encounters__stg_professional"], "model.the_tuva_project.home_health__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__anchor_events"], "model.the_tuva_project.home_health__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__generate_encounter_id"], "model.the_tuva_project.home_health__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_psych__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__start_end_dates"], "model.the_tuva_project.inpatient_psych__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_psych__start_end_dates": ["model.the_tuva_project.inpatient_psych__generate_encounter_id"], "model.the_tuva_project.urgent_care__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__generate_encounter_id"], "model.the_tuva_project.urgent_care__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__anchor_events"], "model.the_tuva_project.urgent_care__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_injections__generate_encounter_id"], "model.the_tuva_project.outpatient_injections__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_outpatient_institutional"], "model.the_tuva_project.outpatient_injections__generate_encounter_id": ["model.the_tuva_project.outpatient_injections__anchor_events"], "model.the_tuva_project.dme__match_claims_to_anchor": ["model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dme__generate_encounter_id": ["model.the_tuva_project.dme__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dme__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.lab__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__generate_encounter_id"], "model.the_tuva_project.lab__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__anchor_events"], "model.the_tuva_project.lab__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.ambulance__match_claims_to_anchor": ["model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.ambulance__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.ambulance__generate_encounter_id": ["model.the_tuva_project.ambulance__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_substance_use__start_end_dates": ["model.the_tuva_project.inpatient_substance_use__generate_encounter_id"], "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_substance_use__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__start_end_dates"], "model.the_tuva_project.outpatient_radiology__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_radiology__generate_encounter_id"], "model.the_tuva_project.outpatient_radiology__generate_encounter_id": ["model.the_tuva_project.outpatient_radiology__anchor_events"], "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"], "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events"], "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_surgery__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__anchor_events"], "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__generate_encounter_id"], "model.the_tuva_project.outpatient_surgery__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__generate_encounter_id": ["model.the_tuva_project.asc__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__start_end_dates": ["model.the_tuva_project.asc__generate_encounter_id"], "model.the_tuva_project.asc__match_claims_to_anchor": ["model.the_tuva_project.asc__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_psych__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_psych__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__anchor_events"], "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__generate_encounter_id"], "model.the_tuva_project.outpatient_hospice__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__anchor_events"], "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__generate_encounter_id"], "model.the_tuva_project.outpatient_hospice__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.office_visits__int_office_visits_ptotst": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_radiology": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.service_category__office_based_radiology"], "model.the_tuva_project.office_visits__int_office_visits": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.office_visits__int_office_visits_telehealth": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": ["model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_injections": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_union": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_ptotst", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_telehealth"], "model.the_tuva_project.office_visits__int_office_visits_em": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_claim_line": ["model.the_tuva_project.office_visits__int_office_visits_encounter_ranking", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_surgery": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.dialysis__generate_encounter_id": ["model.the_tuva_project.dialysis__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dialysis__match_claims_to_anchor": ["model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dialysis__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_snf__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__start_end_dates"], "model.the_tuva_project.inpatient_snf__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_snf__start_end_dates": ["model.the_tuva_project.inpatient_snf__generate_encounter_id"], "model.the_tuva_project.acute_inpatient__prof_claims": ["model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"], "model.the_tuva_project.acute_inpatient__start_end_dates": ["model.the_tuva_project.acute_inpatient__generate_encounter_id"], "model.the_tuva_project.acute_inpatient__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__generate_encounter_id"], "model.the_tuva_project.outpatient_rehab__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__anchor_events"], "model.the_tuva_project.outpatient_rehab__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_hospice__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_hospice__start_end_dates": ["model.the_tuva_project.inpatient_hospice__generate_encounter_id"], "model.the_tuva_project.inpatient_hospice__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_hospice__start_end_dates"], "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id"], "model.the_tuva_project.outpatient_ptotst__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__anchor_events"], "model.the_tuva_project.quality_measures__stg_medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.quality_measures__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.quality_measures__stg_core__observation": ["model.the_tuva_project.core__observation"], "model.the_tuva_project.quality_measures__stg_core__medication": ["model.the_tuva_project.core__medication"], "model.the_tuva_project.quality_measures__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.quality_measures__stg_core__lab_result": ["model.the_tuva_project.core__lab_result"], "model.the_tuva_project.quality_measures__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.quality_measures__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.quality_measures__stg_core__encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.quality_measures__summary_wide": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__summary_counts": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__summary_long": ["model.the_tuva_project.quality_measures__int_adh_diabetes_long", "model.the_tuva_project.quality_measures__int_adhras_long", "model.the_tuva_project.quality_measures__int_cbe0055_long", "model.the_tuva_project.quality_measures__int_cbe0101_long", "model.the_tuva_project.quality_measures__int_cqm130_long", "model.the_tuva_project.quality_measures__int_cqm236_long", "model.the_tuva_project.quality_measures__int_cqm438_long", "model.the_tuva_project.quality_measures__int_cqm48_long", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0041_long", "model.the_tuva_project.quality_measures__int_nqf0053_long", "model.the_tuva_project.quality_measures__int_nqf0059_long", "model.the_tuva_project.quality_measures__int_nqf0097_long", "model.the_tuva_project.quality_measures__int_nqf0420_long", "model.the_tuva_project.quality_measures__int_nqf2372_long", "model.the_tuva_project.quality_measures__stg_core__patient"], "model.the_tuva_project.quality_measures__int_nqf0041_denominator": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0041_numerator": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0041_long": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator"], "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf2372_numerator": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf2372_long": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_numerator"], "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf2372_denominator": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"], "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0097_long": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "model.the_tuva_project.quality_measures__int_nqf0097_numerator"], "model.the_tuva_project.quality_measures__int_nqf0097_numerator": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0097_denominator": ["model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__concepts", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm438_exclusions": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_numerator": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_long": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator"], "model.the_tuva_project.quality_measures__int_cqm48_denominator": ["model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm48__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm48_long": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_numerator"], "model.the_tuva_project.quality_measures__int_cqm48_numerator": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm48_exclusions": ["model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"], "model.the_tuva_project.quality_measures__int_nqf0420_numerator": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0420_long": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator"], "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0420_denominator": ["model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": ["model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_medical_claim"], "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": ["model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": ["model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0034_denominator": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0034_long": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": [], "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": ["model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0034_numerator": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cbe0055_numerator": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0055_denominator": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0055_long": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_numerator"], "model.the_tuva_project.quality_measures__int_cbe0101_long": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator"], "model.the_tuva_project.quality_measures__int_cbe0101_denominator": ["model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0101_numerator": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm236__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm236_denominator": ["model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm236_numerator": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm236_exclusions": ["model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_cqm236_long": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_numerator"], "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0053_denominator": ["model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": ["model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf0053_long": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_numerator"], "model.the_tuva_project.quality_measures__int_nqf0053_numerator": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"], "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator"], "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adh_diabetes_long": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"], "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adhras__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_adhras_long": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_adhras_numerator"], "model.the_tuva_project.quality_measures__int_adhras_denominator": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adhras_numerator": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_adhras_denominator"], "model.the_tuva_project.quality_measures__int_adhras_exclusions": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0059_denominator": ["model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf0059_numerator": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__stg_core__lab_result", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0059_long": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf0059_numerator"], "model.the_tuva_project.quality_measures__int_cqm130_exclusions": ["model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm130__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm130_long": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator"], "model.the_tuva_project.quality_measures__int_cqm130_denominator": ["model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm130_numerator": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": ["model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.ahrq_measures__stg_pqi_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.ahrq_measures__stg_pqi_condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.ahrq_measures__stg_pqi_procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.ahrq_measures__pqi_num_long": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "model.the_tuva_project.ahrq_measures__pqi_denom_long": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"], "model.the_tuva_project.ahrq_measures__pqi_summary": ["model.the_tuva_project.ahrq_measures__pqi_num_long", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__measures"], "model.the_tuva_project.ahrq_measures__pqi_rate": ["model.the_tuva_project.ahrq_measures__pqi_denom_long", "model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": ["model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"], "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_16_num": ["model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_07_num": ["model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_15_num": ["model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_05_num": ["model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_14_num": ["model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_08_num": ["model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_11_num": ["model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_01_num": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_12_num": ["model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_03_num": ["model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ccsr__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.ccsr__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.ccsr__singular_condition_category": ["model.the_tuva_project.ccsr__long_condition_category"], "model.the_tuva_project.ccsr__long_condition_category": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.ccsr__stg_core__condition", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"], "model.the_tuva_project.ccsr__long_procedure_category": ["model.the_tuva_project.ccsr__procedure_category_map", "model.the_tuva_project.ccsr__stg_core__procedure"], "model.the_tuva_project.ccsr__dx_vertical_pivot": ["seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map"], "model.the_tuva_project.ccsr__procedure_category_map": ["seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map"], "model.the_tuva_project.financial_pmpm__stg_provider_attribution": ["model.input_layer.provider_attribution"], "model.the_tuva_project.financial_pmpm__stg_eligibility": ["model.the_tuva_project.core__eligibility"], "model.the_tuva_project.financial_pmpm__stg_medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.financial_pmpm__pmpm_payer": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__pmpm_prep": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot"], "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": ["model.the_tuva_project.financial_pmpm__stg_medical_claim", "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim"], "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.hcc_suspecting__stg_core__medication": ["model.the_tuva_project.core__medication"], "model.the_tuva_project.hcc_suspecting__stg_core__observation": ["model.the_tuva_project.core__observation"], "model.the_tuva_project.hcc_suspecting__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.hcc_suspecting__stg_core__lab_result": ["model.the_tuva_project.core__lab_result"], "model.the_tuva_project.hcc_suspecting__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.hcc_suspecting__list": ["model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"], "model.the_tuva_project.hcc_suspecting__summary": ["model.the_tuva_project.hcc_suspecting__list", "model.the_tuva_project.hcc_suspecting__stg_core__patient"], "model.the_tuva_project.hcc_suspecting__list_rollup": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": ["model.the_tuva_project.hcc_suspecting__int_all_conditions"], "model.the_tuva_project.hcc_suspecting__int_observation_suspects": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "model.the_tuva_project.hcc_suspecting__stg_core__observation", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_medication_suspects": ["model.the_tuva_project.hcc_suspecting__int_all_medications", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_lab_suspects": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": ["model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "seed.the_tuva_project.hcc_suspecting__clinical_concepts"], "model.the_tuva_project.hcc_suspecting__int_all_conditions": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings"], "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_all_medications": ["model.the_tuva_project.hcc_suspecting__stg_core__medication", "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim"], "model.the_tuva_project.hcc_suspecting__int_prep_conditions": ["model.the_tuva_project.hcc_suspecting__stg_core__condition", "seed.the_tuva_project.terminology__snomed_icd_10_map"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.cms_chronic_conditions__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.cms_chronic_conditions__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields", "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": ["model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": ["model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "seed.the_tuva_project.terminology__admit_type": [], "seed.the_tuva_project.terminology__medicare_orec": [], "seed.the_tuva_project.terminology__gender": [], "seed.the_tuva_project.terminology__ethnicity": [], "seed.the_tuva_project.terminology__ccs_services_procedures": [], "seed.the_tuva_project.terminology__ms_drg": [], "seed.the_tuva_project.terminology__hcpcs_to_rbcs": [], "seed.the_tuva_project.terminology__revenue_center": [], "seed.the_tuva_project.terminology__icd_9_cm": [], "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": [], "seed.the_tuva_project.terminology__race": [], "seed.the_tuva_project.terminology__rxnorm_to_atc": [], "seed.the_tuva_project.terminology__medicare_status": [], "seed.the_tuva_project.terminology__loinc_deprecated_mapping": [], "seed.the_tuva_project.terminology__place_of_service": [], "seed.the_tuva_project.terminology__discharge_disposition": [], "seed.the_tuva_project.terminology__icd_9_pcs": [], "seed.the_tuva_project.terminology__present_on_admission": [], "seed.the_tuva_project.terminology__mdc": [], "seed.the_tuva_project.terminology__admit_source": [], "seed.the_tuva_project.terminology__rxnorm_brand_generic": [], "seed.the_tuva_project.terminology__other_provider_taxonomy": [], "seed.the_tuva_project.terminology__icd_10_cm": [], "seed.the_tuva_project.terminology__claim_type": [], "seed.the_tuva_project.terminology__hcpcs_level_2": [], "seed.the_tuva_project.terminology__ndc": [], "seed.the_tuva_project.terminology__encounter_type": [], "seed.the_tuva_project.terminology__snomed_ct": [], "seed.the_tuva_project.terminology__provider": [], "seed.the_tuva_project.terminology__payer_type": [], "seed.the_tuva_project.terminology__ms_drg_weights_los": [], "seed.the_tuva_project.terminology__apr_drg": [], "seed.the_tuva_project.terminology__icd_10_pcs": [], "seed.the_tuva_project.terminology__nitos": [], "seed.the_tuva_project.terminology__medicare_dual_eligibility": [], "seed.the_tuva_project.terminology__bill_type": [], "seed.the_tuva_project.terminology__loinc": [], "seed.the_tuva_project.terminology__snomed_icd_10_map": [], "seed.the_tuva_project.clinical_concept_library__value_set_members": [], "seed.the_tuva_project.clinical_concept_library__coding_systems": [], "seed.the_tuva_project.clinical_concept_library__clinical_concepts": [], "seed.the_tuva_project.pharmacy__rxnorm_generic_available": [], "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": [], "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": [], "seed.the_tuva_project.data_quality__crosswalk_field_info": [], "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": [], "seed.the_tuva_project.data_quality__reference_mart_analytics": [], "seed.the_tuva_project.service_category__service_categories": [], "seed.the_tuva_project.ed_classification__johnston_icd9": [], "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": [], "seed.the_tuva_project.ed_classification__johnston_icd10": [], "seed.the_tuva_project.ed_classification__categories": [], "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": [], "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": [], "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": [], "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": [], "seed.the_tuva_project.readmissions__specialty_cohort": [], "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": [], "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": [], "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": [], "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": [], "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": [], "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": [], "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": [], "seed.the_tuva_project.cms_hcc__disease_hierarchy": [], "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": [], "seed.the_tuva_project.cms_hcc__disease_factors": [], "seed.the_tuva_project.cms_hcc__disease_interaction_factors": [], "seed.the_tuva_project.cms_hcc__cpt_hcpcs": [], "seed.the_tuva_project.cms_hcc__adjustment_rates": [], "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": [], "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": [], "seed.the_tuva_project.cms_hcc__demographic_factors": [], "seed.the_tuva_project.quality_measures__value_sets": [], "seed.the_tuva_project.quality_measures__measures": [], "seed.the_tuva_project.quality_measures__concepts": [], "seed.the_tuva_project.pqi__measures": [], "seed.the_tuva_project.pqi__value_sets": [], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": [], "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": [], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": [], "seed.the_tuva_project.hcc_suspecting__clinical_concepts": [], "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": [], "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": [], "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": [], "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": [], "seed.the_tuva_project.reference_data__fips_county": [], "seed.the_tuva_project.reference_data__calendar": [], "seed.the_tuva_project.reference_data__ssa_fips_state": [], "seed.the_tuva_project.reference_data__ansi_fips_state": [], "seed.the_tuva_project.reference_data__code_type": [], "operation.the_tuva_project.the_tuva_project-on-run-end-0": [], "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617": ["seed.the_tuva_project.ed_classification__johnston_icd9"], "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0": ["seed.the_tuva_project.ed_classification__johnston_icd9"], "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd": ["seed.the_tuva_project.ed_classification__johnston_icd10"], "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7": ["seed.the_tuva_project.ed_classification__johnston_icd10"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7": ["model.the_tuva_project.pharmacy__brand_generic_opportunity"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42": ["model.the_tuva_project.pharmacy__generic_available_list"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0": ["model.the_tuva_project.core__condition"], "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a": ["model.the_tuva_project.core__eligibility"], "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792": ["model.the_tuva_project.core__encounter"], "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af": ["model.the_tuva_project.core__lab_result"], "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a": ["model.the_tuva_project.core__location"], "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1": ["model.the_tuva_project.core__medication"], "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59": ["model.the_tuva_project.core__observation"], "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e": ["model.the_tuva_project.core__patient"], "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c": ["model.the_tuva_project.core__pharmacy_claim"], "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6": ["model.the_tuva_project.core__practitioner"], "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5": ["model.the_tuva_project.core__procedure"], "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba": ["model.the_tuva_project.cms_hcc__int_demographic_factors"], "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b": ["model.the_tuva_project.cms_hcc__int_members"], "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb": ["model.the_tuva_project.cms_hcc__int_members"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d": ["model.the_tuva_project.normalized_input__medical_claim"], "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348": ["model.the_tuva_project.quality_measures__stg_core__condition"], "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159": ["model.the_tuva_project.quality_measures__stg_core__encounter"], "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652": ["model.the_tuva_project.quality_measures__stg_core__medication"], "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e": ["model.the_tuva_project.quality_measures__stg_core__observation"], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9": ["model.the_tuva_project.quality_measures__stg_core__procedure"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"], "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"], "model.the_tuva_project.core__medical_claim": ["model.the_tuva_project.core__stg_claims_medical_claim"], "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708": ["model.the_tuva_project.core__medical_claim"]}, "child_map": {"model.input_layer.provider_attribution": ["model.the_tuva_project.financial_pmpm__stg_provider_attribution"], "model.input_layer.procedure": ["model.the_tuva_project.core__stg_clinical_procedure", "model.the_tuva_project.data_quality__procedure_claim_id", "model.the_tuva_project.data_quality__procedure_data_source", "model.the_tuva_project.data_quality__procedure_encounter_id", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.data_quality__procedure_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_description", "model.the_tuva_project.data_quality__procedure_patient_id", "model.the_tuva_project.data_quality__procedure_practitioner_id", "model.the_tuva_project.data_quality__procedure_procedure_date", "model.the_tuva_project.data_quality__procedure_procedure_id", "model.the_tuva_project.data_quality__procedure_source_code", "model.the_tuva_project.data_quality__procedure_source_code_type", "model.the_tuva_project.data_quality__procedure_source_description"], "model.input_layer.practitioner": ["model.the_tuva_project.core__stg_clinical_practitioner", "model.the_tuva_project.data_quality__practitioner_data_source", "model.the_tuva_project.data_quality__practitioner_first_name", "model.the_tuva_project.data_quality__practitioner_last_name", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "model.the_tuva_project.data_quality__practitioner_practitioner_id", "model.the_tuva_project.data_quality__practitioner_specialty", "model.the_tuva_project.data_quality__practitioner_sub_specialty"], "model.input_layer.encounter": ["model.the_tuva_project.core__stg_clinical_encounter", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__encounter_admit_source_description", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__encounter_admit_type_description", "model.the_tuva_project.data_quality__encounter_allowed_amount", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__encounter_apr_drg_description", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_charge_amount", "model.the_tuva_project.data_quality__encounter_data_source", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "model.the_tuva_project.data_quality__encounter_encounter_end_date", "model.the_tuva_project.data_quality__encounter_encounter_id", "model.the_tuva_project.data_quality__encounter_encounter_start_date", "model.the_tuva_project.data_quality__encounter_encounter_type", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__encounter_length_of_stay", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__encounter_ms_drg_description", "model.the_tuva_project.data_quality__encounter_paid_amount", "model.the_tuva_project.data_quality__encounter_patient_id", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description"], "model.input_layer.eligibility": ["model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__eligibility_address", "model.the_tuva_project.data_quality__eligibility_birth_date", "model.the_tuva_project.data_quality__eligibility_city", "model.the_tuva_project.data_quality__eligibility_data_source", "model.the_tuva_project.data_quality__eligibility_date_checks", "model.the_tuva_project.data_quality__eligibility_death_date", "model.the_tuva_project.data_quality__eligibility_death_flag", "model.the_tuva_project.data_quality__eligibility_demographics", "model.the_tuva_project.data_quality__eligibility_dq_stage", "model.the_tuva_project.data_quality__eligibility_dual_status_code", "model.the_tuva_project.data_quality__eligibility_end_date", "model.the_tuva_project.data_quality__eligibility_first_name", "model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__eligibility_last_name", "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "model.the_tuva_project.data_quality__eligibility_member_id", "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "model.the_tuva_project.data_quality__eligibility_missing_payer", "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "model.the_tuva_project.data_quality__eligibility_patient_id", "model.the_tuva_project.data_quality__eligibility_payer", "model.the_tuva_project.data_quality__eligibility_payer_type", "model.the_tuva_project.data_quality__eligibility_phone", "model.the_tuva_project.data_quality__eligibility_plan", "model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__eligibility_start_date", "model.the_tuva_project.data_quality__eligibility_state", "model.the_tuva_project.data_quality__eligibility_trend", "model.the_tuva_project.data_quality__eligibility_zip_code", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__raw_summary", "model.the_tuva_project.data_quality__stg_eligibility", "model.the_tuva_project.normalized_input__stg_eligibility"], "model.input_layer.medical_claim": ["model.the_tuva_project.data_quality__claim_allowed_amount", "model.the_tuva_project.data_quality__claim_charge_amount", "model.the_tuva_project.data_quality__claim_claim_id", "model.the_tuva_project.data_quality__claim_claim_line_end_date", "model.the_tuva_project.data_quality__claim_claim_line_number", "model.the_tuva_project.data_quality__claim_claim_line_start_date", "model.the_tuva_project.data_quality__claim_claim_type", "model.the_tuva_project.data_quality__claim_coinsurance_amount", "model.the_tuva_project.data_quality__claim_copayment_amount", "model.the_tuva_project.data_quality__claim_data_source", "model.the_tuva_project.data_quality__claim_date_trends", "model.the_tuva_project.data_quality__claim_deductible_amount", "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__claim_member_id", "model.the_tuva_project.data_quality__claim_paid_amount", "model.the_tuva_project.data_quality__claim_paid_date", "model.the_tuva_project.data_quality__claim_patient_id", "model.the_tuva_project.data_quality__claim_payer", "model.the_tuva_project.data_quality__claim_percent", "model.the_tuva_project.data_quality__claim_plan", "model.the_tuva_project.data_quality__claim_total_cost_amount", "model.the_tuva_project.data_quality__claim_type_summary", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__inpatient_dq_stage", "model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_claim_end_date", "model.the_tuva_project.data_quality__institutional_claim_start_date", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_claim_end_date", "model.the_tuva_project.data_quality__professional_claim_start_date", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.data_quality__professional_rendering_npi", "model.the_tuva_project.data_quality__raw_summary", "model.the_tuva_project.data_quality__stg_institutional_inpatient", "model.the_tuva_project.data_quality__stg_medical_claim", "model.the_tuva_project.medical_claim_expanded", "model.the_tuva_project.normalized_input__stg_medical_claim"], "model.input_layer.pharmacy_claim": ["model.the_tuva_project.data_quality__claim_date_trends", "model.the_tuva_project.data_quality__claim_percent", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "model.the_tuva_project.data_quality__pharmacy_claim_id", "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "model.the_tuva_project.data_quality__pharmacy_data_source", "model.the_tuva_project.data_quality__pharmacy_days_supply", "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_member_id", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.data_quality__pharmacy_paid_amount", "model.the_tuva_project.data_quality__pharmacy_paid_date", "model.the_tuva_project.data_quality__pharmacy_patient_id", "model.the_tuva_project.data_quality__pharmacy_payer", "model.the_tuva_project.data_quality__pharmacy_plan", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_quantity", "model.the_tuva_project.data_quality__pharmacy_refills", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__raw_summary", "model.the_tuva_project.data_quality__stg_pharmacy_claim", "model.the_tuva_project.normalized_input__stg_pharmacy_claim"], "model.input_layer.location": ["model.the_tuva_project.core__stg_clinical_location", "model.the_tuva_project.data_quality__location_address", "model.the_tuva_project.data_quality__location_city", "model.the_tuva_project.data_quality__location_data_source", "model.the_tuva_project.data_quality__location_facility_type", "model.the_tuva_project.data_quality__location_latitude", "model.the_tuva_project.data_quality__location_location_id", "model.the_tuva_project.data_quality__location_longitude", "model.the_tuva_project.data_quality__location_name", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__location_parent_organization", "model.the_tuva_project.data_quality__location_state", "model.the_tuva_project.data_quality__location_zip_code"], "model.input_layer.patient": ["model.the_tuva_project.core__stg_clinical_patient", "model.the_tuva_project.data_quality__patient_address", "model.the_tuva_project.data_quality__patient_birth_date", "model.the_tuva_project.data_quality__patient_city", "model.the_tuva_project.data_quality__patient_county", "model.the_tuva_project.data_quality__patient_data_source", "model.the_tuva_project.data_quality__patient_death_date", "model.the_tuva_project.data_quality__patient_death_flag", "model.the_tuva_project.data_quality__patient_first_name", "model.the_tuva_project.data_quality__patient_last_name", "model.the_tuva_project.data_quality__patient_latitude", "model.the_tuva_project.data_quality__patient_longitude", "model.the_tuva_project.data_quality__patient_patient_id", "model.the_tuva_project.data_quality__patient_race", "model.the_tuva_project.data_quality__patient_sex", "model.the_tuva_project.data_quality__patient_state", "model.the_tuva_project.data_quality__patient_zip_code"], "model.input_layer.condition": ["model.the_tuva_project.core__stg_clinical_condition", "model.the_tuva_project.data_quality__condition_claim_id", "model.the_tuva_project.data_quality__condition_condition_id", "model.the_tuva_project.data_quality__condition_condition_rank", "model.the_tuva_project.data_quality__condition_condition_type", "model.the_tuva_project.data_quality__condition_data_source", "model.the_tuva_project.data_quality__condition_encounter_id", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__condition_normalized_description", "model.the_tuva_project.data_quality__condition_onset_date", "model.the_tuva_project.data_quality__condition_patient_id", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.data_quality__condition_present_on_admit_description", "model.the_tuva_project.data_quality__condition_recorded_date", "model.the_tuva_project.data_quality__condition_resolved_date", "model.the_tuva_project.data_quality__condition_source_code", "model.the_tuva_project.data_quality__condition_source_code_type", "model.the_tuva_project.data_quality__condition_source_description", "model.the_tuva_project.data_quality__condition_status"], "model.input_layer.medication": ["model.the_tuva_project.core__stg_clinical_medication", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_atc_description", "model.the_tuva_project.data_quality__medication_data_source", "model.the_tuva_project.data_quality__medication_days_supply", "model.the_tuva_project.data_quality__medication_dispensing_date", "model.the_tuva_project.data_quality__medication_encounter_id", "model.the_tuva_project.data_quality__medication_medication_id", "model.the_tuva_project.data_quality__medication_ndc_code", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__medication_patient_id", "model.the_tuva_project.data_quality__medication_practitioner_id", "model.the_tuva_project.data_quality__medication_prescribing_date", "model.the_tuva_project.data_quality__medication_quantity", "model.the_tuva_project.data_quality__medication_quantity_unit", "model.the_tuva_project.data_quality__medication_route", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.data_quality__medication_rxnorm_description", "model.the_tuva_project.data_quality__medication_source_code", "model.the_tuva_project.data_quality__medication_source_code_type", "model.the_tuva_project.data_quality__medication_source_description", "model.the_tuva_project.data_quality__medication_strength"], "model.input_layer.observation": ["model.the_tuva_project.core__stg_clinical_observation", "model.the_tuva_project.data_quality__observation_data_source", "model.the_tuva_project.data_quality__observation_encounter_id", "model.the_tuva_project.data_quality__observation_normalized_code", "model.the_tuva_project.data_quality__observation_normalized_code_type", "model.the_tuva_project.data_quality__observation_normalized_description", "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "model.the_tuva_project.data_quality__observation_normalized_units", "model.the_tuva_project.data_quality__observation_observation_date", "model.the_tuva_project.data_quality__observation_observation_id", "model.the_tuva_project.data_quality__observation_observation_type", "model.the_tuva_project.data_quality__observation_panel_id", "model.the_tuva_project.data_quality__observation_patient_id", "model.the_tuva_project.data_quality__observation_result", "model.the_tuva_project.data_quality__observation_source_code", "model.the_tuva_project.data_quality__observation_source_code_type", "model.the_tuva_project.data_quality__observation_source_description", "model.the_tuva_project.data_quality__observation_source_reference_range_high", "model.the_tuva_project.data_quality__observation_source_reference_range_low", "model.the_tuva_project.data_quality__observation_source_units"], "model.input_layer.lab_result": ["model.the_tuva_project.core__stg_clinical_lab_result", "model.the_tuva_project.data_quality__lab_result_accession_number", "model.the_tuva_project.data_quality__lab_result_collection_date", "model.the_tuva_project.data_quality__lab_result_data_source", "model.the_tuva_project.data_quality__lab_result_encounter_id", "model.the_tuva_project.data_quality__lab_result_lab_result_id", "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_component", "model.the_tuva_project.data_quality__lab_result_normalized_description", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "model.the_tuva_project.data_quality__lab_result_normalized_units", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__lab_result_patient_id", "model.the_tuva_project.data_quality__lab_result_result", "model.the_tuva_project.data_quality__lab_result_result_date", "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_source_code", "model.the_tuva_project.data_quality__lab_result_source_code_type", "model.the_tuva_project.data_quality__lab_result_source_component", "model.the_tuva_project.data_quality__lab_result_source_description", "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "model.the_tuva_project.data_quality__lab_result_source_units", "model.the_tuva_project.data_quality__lab_result_specimen", "model.the_tuva_project.data_quality__lab_result_status"], "seed.input_layer.eligibility_seed": ["model.input_layer.eligibility"], "seed.input_layer.medical_claim_seed": ["model.input_layer.medical_claim"], "seed.input_layer.provider_attribution_seed": ["model.input_layer.provider_attribution"], "seed.input_layer.lab_result_seed": [], "seed.input_layer.observation_seed": [], "seed.input_layer.pharmacy_claim_seed": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.pharmacy__stg_pharmacy_claim": ["model.the_tuva_project.pharmacy__brand_generic_opportunity", "model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "model.the_tuva_project.pharmacy__brand_generic_opportunity": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7"], "model.the_tuva_project.pharmacy__generic_available_list": ["test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42"], "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": ["model.the_tuva_project.pharmacy__generic_available_list", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59"], "model.the_tuva_project.pharmacy__int_claims_current_cost": ["model.the_tuva_project.pharmacy__brand_generic_opportunity", "model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_generic_cost", "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc"], "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": [], "model.the_tuva_project.pharmacy__int_brand_with_generic_available": ["model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "model.the_tuva_project.pharmacy__int_generic_cost": ["model.the_tuva_project.pharmacy__brand_generic_opportunity"], "model.the_tuva_project.medical_claim_expanded": [], "model.the_tuva_project.core__stg_claims_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.core__stg_clinical_condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.core__stg_claims_location": ["model.the_tuva_project.core__location"], "model.the_tuva_project.core__stg_claims_practitioner": ["model.the_tuva_project.core__practitioner"], "model.the_tuva_project.core__stg_claims_eligibility": ["model.the_tuva_project.core__eligibility"], "model.the_tuva_project.core__stg_claims_medical_claim": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_claims_practitioner"], "model.the_tuva_project.core__stg_claims_procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.core__stg_clinical_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.core__stg_clinical_procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.core__stg_clinical_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.core__stg_clinical_medication": ["model.the_tuva_project.core__medication"], "model.the_tuva_project.core__stg_claims_condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.core__stg_clinical_lab_result": ["model.the_tuva_project.core__lab_result"], "model.the_tuva_project.core__stg_clinical_practitioner": ["model.the_tuva_project.core__practitioner"], "model.the_tuva_project.core__stg_claims_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_claims_practitioner"], "model.the_tuva_project.core__stg_clinical_location": ["model.the_tuva_project.core__location"], "model.the_tuva_project.core__stg_claims_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.core__stg_clinical_observation": ["model.the_tuva_project.core__observation"], "model.the_tuva_project.core__pharmacy_claim": ["model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim", "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim", "model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.mart_review__stg_pharmacy_claim", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c"], "model.the_tuva_project.core__condition": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ccsr__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_hcc__stg_core__condition", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.hcc_suspecting__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0"], "model.the_tuva_project.core__patient": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient", "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "model.the_tuva_project.cms_hcc__stg_core__patient", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.ed_classification__stg_patient", "model.the_tuva_project.hcc_suspecting__stg_core__patient", "model.the_tuva_project.mart_review__number_of_conditions", "model.the_tuva_project.mart_review__patient", "model.the_tuva_project.mart_review__tuva_chronic_conditions", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient", "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e"], "model.the_tuva_project.core__lab_result": ["model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__lab_result", "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af"], "model.the_tuva_project.core__encounter": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.data_quality__acute_inpatient", "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "model.the_tuva_project.data_quality__encounters_missing_groups", "model.the_tuva_project.ed_classification__stg_encounter", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.readmissions__stg_core__encounter", "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792"], "model.the_tuva_project.core__eligibility": ["model.the_tuva_project.cms_hcc__stg_core__eligibility", "model.the_tuva_project.core__member_months", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.financial_pmpm__stg_eligibility", "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a"], "model.the_tuva_project.core__procedure": ["model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ccsr__stg_core__procedure", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.readmissions__stg_core__procedure", "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5"], "model.the_tuva_project.core__location": ["model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient", "model.the_tuva_project.mart_review__pharmacy", "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a"], "model.the_tuva_project.core__member_months": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "model.the_tuva_project.cms_hcc__stg_core__member_months", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "model.the_tuva_project.data_quality__service_categories_pmpm", "model.the_tuva_project.data_quality__service_category_pmpm_trend", "model.the_tuva_project.financial_pmpm__pmpm_prep", "model.the_tuva_project.mart_review__claims_with_enrollment", "model.the_tuva_project.mart_review__member_months", "model.the_tuva_project.mart_review__members_with_claims", "model.the_tuva_project.mart_review__stg_member_month"], "model.the_tuva_project.core__medication": ["model.the_tuva_project.hcc_suspecting__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__medication", "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1"], "model.the_tuva_project.core__observation": ["model.the_tuva_project.hcc_suspecting__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__observation", "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59"], "model.the_tuva_project.core__practitioner": ["model.the_tuva_project.mart_review__pharmacy", "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6"], "model.the_tuva_project.mart_review__stg_member_month": ["model.the_tuva_project.mart_review__enrollment_change"], "model.the_tuva_project.mart_review__stg_medical_claim": ["model.the_tuva_project.mart_review__claims_with_enrollment", "model.the_tuva_project.mart_review__members_with_claims"], "model.the_tuva_project.mart_review__stg_pharmacy_claim": ["model.the_tuva_project.mart_review__members_with_claims"], "model.the_tuva_project.mart_review__data_source": [], "model.the_tuva_project.mart_review__tuva_chronic_conditions": [], "model.the_tuva_project.mart_review__inpatient": [], "model.the_tuva_project.mart_review__pharmacy": [], "model.the_tuva_project.mart_review__patient_risk_scores": [], "model.the_tuva_project.mart_review__patient_risk_factors": ["model.the_tuva_project.mart_review__patient_risk"], "model.the_tuva_project.mart_review__patient": [], "model.the_tuva_project.mart_review__quality_measures_summary_long": [], "model.the_tuva_project.mart_review__enrollment_change": [], "model.the_tuva_project.mart_review__pmpm": [], "model.the_tuva_project.mart_review__members_with_claims": [], "model.the_tuva_project.mart_review__patient_risk": [], "model.the_tuva_project.mart_review__ed_classification": [], "model.the_tuva_project.mart_review__calendar_month": [], "model.the_tuva_project.mart_review__member_months": [], "model.the_tuva_project.mart_review__claims_with_enrollment": [], "model.the_tuva_project.mart_review__readmissions": [], "model.the_tuva_project.mart_review__quality_measures_value_set": [], "model.the_tuva_project.mart_review__number_of_conditions": [], "model.the_tuva_project.data_quality__stg_institutional_inpatient": ["model.the_tuva_project.data_quality__institutional_admission_date", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__institutional_discharge_date", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__institutional_procedure_date_1", "model.the_tuva_project.data_quality__institutional_procedure_date_2", "model.the_tuva_project.data_quality__institutional_procedure_date_3"], "model.the_tuva_project.data_quality__stg_pharmacy_claim": [], "model.the_tuva_project.data_quality__stg_eligibility": [], "model.the_tuva_project.data_quality__stg_medical_claim": [], "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": ["model.the_tuva_project.data_quality__summary"], "model.the_tuva_project.data_quality__raw_summary": [], "model.the_tuva_project.data_quality__data_quality_detail": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "model.the_tuva_project.data_quality__quality_trend", "model.the_tuva_project.data_quality__summary"], "model.the_tuva_project.data_quality__summary": [], "model.the_tuva_project.data_quality__quality_trend": [], "model.the_tuva_project.data_quality__data_quality_for_pbi": [], "model.the_tuva_project.data_quality__practitioner_practice_affiliation": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_sub_specialty": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_last_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id"], "model.the_tuva_project.data_quality__practitioner_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_npi": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_first_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_specialty": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_parent_organization": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_latitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_facility_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_zip_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_city": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_npi": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_location_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_location_location_id"], "model.the_tuva_project.data_quality__location_longitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_address": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_state": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_type_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_ms_drg_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_charge_amount": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_length_of_stay": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_allowed_amount": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_facility_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_attending_provider_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_start_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_paid_amount": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_end_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_type_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id"], "model.the_tuva_project.data_quality__encounter_apr_drg_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_apr_drg_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_ms_drg_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_procedure_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"], "model.the_tuva_project.data_quality__procedure_claim_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_procedure_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_5": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_4": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_1": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_3": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_2": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_specimen": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_lab_result_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id"], "model.the_tuva_project.data_quality__lab_result_collection_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_component": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_result": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_status": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_accession_number": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_result_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_component": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_status": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_present_on_admit_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_condition_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_condition_condition_id"], "model.the_tuva_project.data_quality__condition_condition_rank": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_onset_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_recorded_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_claim_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_condition_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_present_on_admit_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_resolved_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_sex": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_state": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_city": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_longitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_county": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_race": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_death_flag": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_address": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_zip_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_first_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_last_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_latitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_birth_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_death_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_patient_patient_id"], "model.the_tuva_project.data_quality__medication_rxnorm_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_atc_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_dispensing_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_prescribing_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_days_supply": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_strength": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_rxnorm_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_atc_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_quantity_unit": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_ndc_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_medication_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_medication_medication_id"], "model.the_tuva_project.data_quality__medication_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_ndc_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_quantity": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_route": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_observation_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_panel_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_observation_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_observation_observation_id"], "model.the_tuva_project.data_quality__observation_source_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_result": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_observation_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__pharmacy_data_source": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_claim_line_number": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_days_supply": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_payer": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_paid_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_dispensing_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_member_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_ndc_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_paid_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_refills": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_plan": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_patient_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_deductible_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_quantity": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_allowed_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_copayment_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_claim_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_payer_type": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_zip_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_plan": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_medicare_status_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_death_flag": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_first_name": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_phone": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_payer": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_state": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_member_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_data_source": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_race": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_address": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_patient_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_gender": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_birth_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_city": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_dual_status_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_last_name": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_death_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_line_number": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_charge_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_paid_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_data_source": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_line_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_paid_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_member_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_patient_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_payer": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_line_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_coinsurance_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_plan": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_copayment_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_total_cost_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_diagnosis_code_type": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_deductible_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_type": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_allowed_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_hcpcs_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_claim_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_diagnosis_code_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_diagnosis_code_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_diagnosis_code_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_billing_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_place_of_service_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_rendering_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_facility_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_claim_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_present_on_admission_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_admission_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_present_on_admission_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_present_on_admission_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_ms_drg_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_billing_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_claim_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_date_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_date_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_date_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_admit_type_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_claim_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_apr_drg_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_facility_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_discharge_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_bill_type_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_revenue_center_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_service_unit_quantity": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_admit_source_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_code_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_rendering_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_code_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_code_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__unique_value_examples": [], "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_location_location_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": ["model.the_tuva_project.data_quality__data_quality_for_pbi"], "model.the_tuva_project.data_quality__data_quality_clinical_detail": ["model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "model.the_tuva_project.data_quality__data_quality_detail"], "model.the_tuva_project.data_quality__claim_type_summary": [], "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": ["model.the_tuva_project.data_quality__data_quality_for_pbi"], "model.the_tuva_project.data_quality__data_quality_claims_detail": ["model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "model.the_tuva_project.data_quality__data_quality_detail"], "model.the_tuva_project.data_quality__eligibility_dq_stage": ["model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id"], "model.the_tuva_project.data_quality__inpatient_dq_stage": ["model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields"], "model.the_tuva_project.data_quality__service_category_pmpm_trend": [], "model.the_tuva_project.data_quality__analytics_reference_summary": [], "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": [], "model.the_tuva_project.data_quality__data_quality_test_summary": ["test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084", "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98"], "model.the_tuva_project.data_quality__analytics_populated": [], "model.the_tuva_project.data_quality__core_populated": [], "model.the_tuva_project.data_quality__data_loss": [], "model.the_tuva_project.data_quality__eligibility_trend": [], "model.the_tuva_project.data_quality__analytics_checks_summary": ["test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a", "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": [], "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": [], "model.the_tuva_project.data_quality__claim_date_trends": [], "model.the_tuva_project.data_quality__chronic_conditions_none": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__eligibility_date_checks": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__ed_classification": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__cms_hcc_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__acute_inpatient_prevelence": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__medical_claim_date_checks": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__eligibility_missing_payer": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__encounters_missing_groups": ["model.the_tuva_project.data_quality__encounters_missing_groups_union"], "model.the_tuva_project.data_quality__readmissions_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_npi": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_patient_id": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__acute_inpatient": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__eligibility_demographics": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_ndc": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__cms_hcc": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__service_categories_pmpm": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__ed_classification_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__financial_pmpm": [], "model.the_tuva_project.data_quality__quality_measures": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__readmissions": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__dx_and_px": [], "model.the_tuva_project.data_quality__chronic_conditions_prevalence": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__primary_key_check": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__eligibility_missing_patient_id": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_provider_npi": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__claim_percent": [], "model.the_tuva_project.data_quality__acute_inpatient_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__quality_measures_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__encounters_missing_groups_union": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "model.the_tuva_project.ed_classification__stg_patient": ["model.the_tuva_project.ed_classification__summary"], "model.the_tuva_project.ed_classification__stg_encounter": ["model.the_tuva_project.ed_classification__int_map_primary_dx"], "model.the_tuva_project.ed_classification__summary": ["model.the_tuva_project.data_quality__ed_classification", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.mart_review__ed_classification"], "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": ["model.the_tuva_project.ed_classification__summary"], "model.the_tuva_project.ed_classification__int_map_primary_dx": ["model.the_tuva_project.ed_classification__int_filter_encounter_with_classification"], "model.the_tuva_project.readmissions__stg_core__encounter": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__stg_core__procedure": ["model.the_tuva_project.readmissions__procedure_ccs"], "model.the_tuva_project.readmissions__encounter_augmented": ["model.the_tuva_project.data_quality__readmissions", "model.the_tuva_project.readmissions__readmission_summary"], "model.the_tuva_project.readmissions__readmission_summary": ["model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.mart_review__readmissions"], "model.the_tuva_project.readmissions__encounter_overlap": ["model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.readmissions__readmission_crude"], "model.the_tuva_project.readmissions__encounter_specialty_cohort": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__encounter_data_quality": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__exclusion": ["model.the_tuva_project.readmissions__index_admission"], "model.the_tuva_project.readmissions__index_admission": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__index_time_requirement": ["model.the_tuva_project.readmissions__index_admission"], "model.the_tuva_project.readmissions__planned_encounter": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__encounter": ["model.the_tuva_project.readmissions__encounter_augmented", "model.the_tuva_project.readmissions__encounter_overlap", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__index_admission", "model.the_tuva_project.readmissions__index_discharge_requirement", "model.the_tuva_project.readmissions__index_time_requirement", "model.the_tuva_project.readmissions__readmission_crude"], "model.the_tuva_project.readmissions__readmission_crude": [], "model.the_tuva_project.readmissions__procedure_ccs": ["model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__planned_encounter"], "model.the_tuva_project.readmissions__encounter_with_ccs": ["model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__exclusion", "model.the_tuva_project.readmissions__planned_encounter"], "model.the_tuva_project.readmissions__index_discharge_requirement": ["model.the_tuva_project.readmissions__index_admission"], "model.the_tuva_project.cms_hcc__stg_core__condition": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "model.the_tuva_project.cms_hcc__stg_core__patient": ["model.the_tuva_project.cms_hcc__int_members"], "model.the_tuva_project.cms_hcc__stg_core__member_months": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "model.the_tuva_project.cms_hcc__stg_core__medical_claim": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "model.the_tuva_project.cms_hcc__stg_core__eligibility": ["model.the_tuva_project.cms_hcc__int_members"], "model.the_tuva_project.cms_hcc__patient_risk_factors": ["model.the_tuva_project.cms_hcc__patient_risk_scores", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__cms_hcc", "model.the_tuva_project.mart_review__patient_risk_factors"], "model.the_tuva_project.cms_hcc__patient_risk_scores": ["model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.mart_review__patient_risk_scores", "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126"], "model.the_tuva_project.cms_hcc__int_disease_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_eligible_conditions": ["model.the_tuva_project.cms_hcc__int_hcc_mapping", "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc"], "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": ["model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors"], "model.the_tuva_project.cms_hcc__int_hcc_mapping": ["model.the_tuva_project.cms_hcc__int_hcc_hierarchy"], "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_hcc_count_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_demographic_factors": ["model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors", "model.the_tuva_project.cms_hcc__patient_risk_factors", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba"], "model.the_tuva_project.cms_hcc__int_members": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b", "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb"], "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.normalized_input__stg_medical_claim": ["model.the_tuva_project.normalized_input__int_admit_source_voting", "model.the_tuva_project.normalized_input__int_admit_type_voting", "model.the_tuva_project.normalized_input__int_apr_drg_voting", "model.the_tuva_project.normalized_input__int_bill_type_voting", "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_ms_drg_voting", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_present_on_admit_normalize", "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "model.the_tuva_project.normalized_input__int_procedure_date_normalize", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__stg_pharmacy_claim": ["model.the_tuva_project.normalized_input__pharmacy_claim"], "model.the_tuva_project.normalized_input__stg_eligibility": ["model.the_tuva_project.normalized_input__eligibility", "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize"], "model.the_tuva_project.normalized_input__eligibility": ["model.the_tuva_project.core__stg_claims_eligibility", "model.the_tuva_project.core__stg_claims_patient", "model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.encounters__stg_eligibility"], "model.the_tuva_project.normalized_input__pharmacy_claim": ["model.the_tuva_project.core__stg_claims_pharmacy_claim"], "model.the_tuva_project.normalized_input__medical_claim": ["model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d"], "model.the_tuva_project.normalized_input__int_revenue_center_normalize": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": ["model.the_tuva_project.normalized_input__int_medical_date_aggregation", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_medical_date_aggregation": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_procedure_date_voting": ["model.the_tuva_project.normalized_input__int_procedure_date_final"], "model.the_tuva_project.normalized_input__int_present_on_admit_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_apr_drg_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_admit_type_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_admit_source_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": ["model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.normalized_input__int_admit_source_voting": ["model.the_tuva_project.normalized_input__int_admit_source_final"], "model.the_tuva_project.normalized_input__int_ms_drg_voting": ["model.the_tuva_project.normalized_input__int_ms_drg_final"], "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": ["model.the_tuva_project.normalized_input__int_discharge_disposition_final"], "model.the_tuva_project.normalized_input__int_discharge_disposition_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": ["model.the_tuva_project.normalized_input__int_diagnosis_code_final"], "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": ["model.the_tuva_project.normalized_input__int_diagnosis_code_voting"], "model.the_tuva_project.normalized_input__int_procedure_date_normalize": ["model.the_tuva_project.normalized_input__int_procedure_date_voting"], "model.the_tuva_project.normalized_input__int_procedure_date_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_undetermined_claim_type": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_procedure_code_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_apr_drg_voting": ["model.the_tuva_project.normalized_input__int_apr_drg_final"], "model.the_tuva_project.normalized_input__int_ms_drg_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_admit_type_voting": ["model.the_tuva_project.normalized_input__int_admit_type_final"], "model.the_tuva_project.normalized_input__int_present_on_admit_voting": ["model.the_tuva_project.normalized_input__int_present_on_admit_final"], "model.the_tuva_project.normalized_input__int_procedure_code_normalize": ["model.the_tuva_project.normalized_input__int_procedure_code_voting"], "model.the_tuva_project.normalized_input__int_bill_type_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_bill_type_voting": ["model.the_tuva_project.normalized_input__int_bill_type_final"], "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": ["model.the_tuva_project.normalized_input__int_present_on_admit_voting"], "model.the_tuva_project.normalized_input__int_place_of_service_normalize": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_medical_npi_normalize": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_diagnosis_code_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_procedure_code_voting": ["model.the_tuva_project.normalized_input__int_procedure_code_final"], "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": ["model.the_tuva_project.core__stg_claims_medical_claim"], "model.the_tuva_project.service_category__stg_medical_claim": ["model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__acute_inpatient_professional", "model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__ambulance_professional", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_institutional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__inpatient_rehab_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__lab_institutional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__observation_institutional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_rehab_professional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_surgery_institutional", "model.the_tuva_project.service_category__outpatient_surgery_professional", "model.the_tuva_project.service_category__pharmacy_institutional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_office_based", "model.the_tuva_project.service_category__stg_outpatient_institutional", "model.the_tuva_project.service_category__stg_professional", "model.the_tuva_project.service_category__urgent_care_institutional", "model.the_tuva_project.service_category__urgent_care_professional"], "model.the_tuva_project.service_category__stg_outpatient_institutional": ["model.the_tuva_project.encounters__stg_outpatient_institutional", "model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__lab_institutional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_surgery_institutional", "model.the_tuva_project.service_category__pharmacy_institutional"], "model.the_tuva_project.service_category__stg_office_based": ["model.the_tuva_project.service_category__office_based_other_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional"], "model.the_tuva_project.service_category__stg_inpatient_institutional": ["model.the_tuva_project.encounters__stg_inpatient_institutional", "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__pharmacy_institutional", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__stg_professional": ["model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_surgery_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__service_category_grouper": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__ambulatory_surgery_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__home_health_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__urgent_care_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__ambulatory_surgery_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__dialysis_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__lab_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_rehab_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__dialysis_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__dme_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional"], "model.the_tuva_project.service_category__outpatient_hospice_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__home_health_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__emergency_department_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_hospice_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_psychiatric_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_rehab_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__inpatient_substance_use_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__pharmacy_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__combined_institutional_line_level": ["model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.service_category__outpatient_surgery_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__inpatient_hospice_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_rehab_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__pharmacy_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__office_based_radiology": ["model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__inpatient_hospice_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__lab_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__combined_institutional_header_level": ["model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.service_category__urgent_care_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_radiology_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__outpatient_radiology_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__combined_professional": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__acute_inpatient_institutional_other": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__ambulance_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__office_based_other_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_substance_use_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__office_based_surgery_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__ambulance_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__outpatient_psychiatric_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_substance_use_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__emergency_department_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_surgery_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_rehab_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__observation_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__office_based_physical_therapy_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__observation_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__office_based_visit_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__acute_inpatient_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.encounters__patient_data_source_id": ["model.the_tuva_project.core__stg_claims_encounter", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.encounters__stg_professional": ["model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.inpatient_hospice__prof_claims", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_substance_use__prof_claims"], "model.the_tuva_project.encounters__stg_outpatient_institutional": ["model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.outpatient_injections__anchor_events"], "model.the_tuva_project.encounters__stg_medical_claim": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.ambulance__anchor_events", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.ambulance__match_claims_to_anchor", "model.the_tuva_project.asc__anchor_events", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.asc__generate_encounter_id", "model.the_tuva_project.asc__match_claims_to_anchor", "model.the_tuva_project.dialysis__anchor_events", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.dialysis__match_claims_to_anchor", "model.the_tuva_project.dme__anchor_events", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.dme__match_claims_to_anchor", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.home_health__anchor_events", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.home_health__generate_encounter_id", "model.the_tuva_project.home_health__match_claims_to_anchor", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_hospice__prof_claims", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.lab__anchor_events", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.lab__generate_encounter_id", "model.the_tuva_project.lab__match_claims_to_anchor", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__anchor_events", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "model.the_tuva_project.outpatient_injections__anchor_events", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "model.the_tuva_project.outpatient_psych__anchor_events", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_psych__generate_encounter_id", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "model.the_tuva_project.outpatient_ptotst__anchor_events", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "model.the_tuva_project.outpatient_radiology__anchor_events", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "model.the_tuva_project.outpatient_rehab__anchor_events", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "model.the_tuva_project.outpatient_substance_use__anchor_events", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "model.the_tuva_project.outpatient_surgery__anchor_events", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "model.the_tuva_project.urgent_care__anchor_events", "model.the_tuva_project.urgent_care__encounter_grain", "model.the_tuva_project.urgent_care__generate_encounter_id", "model.the_tuva_project.urgent_care__match_claims_to_anchor"], "model.the_tuva_project.encounters__stg_inpatient_institutional": [], "model.the_tuva_project.encounters__stg_eligibility": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.ambulance__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_substance_use__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_surgery__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.dialysis__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.acute_inpatient__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_rehab__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.home_health__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.orphaned_claim__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_ptotst__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_radiology__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.lab__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_psych__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.asc__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_hospice__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_hospice__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.emergency_department__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_injections__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_psych__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_snf__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.dme__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_substance_use__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.urgent_care__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.office_visit__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_rehab__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.encounters__combined_claim_line_crosswalk": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.encounters__orphaned_claims": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.orphaned_claim__encounter_grain"], "model.the_tuva_project.outpatient_substance_use__anchor_events": ["model.the_tuva_project.outpatient_substance_use__generate_encounter_id"], "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor"], "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_rehab__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_rehab__start_end_dates"], "model.the_tuva_project.inpatient_rehab__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_rehab__start_end_dates": ["model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_rehab__prof_claims"], "model.the_tuva_project.emergency_department__generate_encounter_id": ["model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.emergency_department__start_end_dates": ["model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.emergency_department__prof_claims"], "model.the_tuva_project.emergency_department__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.home_health__generate_encounter_id": ["model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.home_health__match_claims_to_anchor"], "model.the_tuva_project.home_health__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.home_health__anchor_events": ["model.the_tuva_project.home_health__generate_encounter_id"], "model.the_tuva_project.inpatient_psych__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_psych__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_psych__start_end_dates"], "model.the_tuva_project.inpatient_psych__start_end_dates": ["model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_psych__prof_claims"], "model.the_tuva_project.urgent_care__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.urgent_care__generate_encounter_id": ["model.the_tuva_project.urgent_care__encounter_grain", "model.the_tuva_project.urgent_care__match_claims_to_anchor"], "model.the_tuva_project.urgent_care__anchor_events": ["model.the_tuva_project.urgent_care__generate_encounter_id"], "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_injections__anchor_events": ["model.the_tuva_project.outpatient_injections__generate_encounter_id"], "model.the_tuva_project.outpatient_injections__generate_encounter_id": ["model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor"], "model.the_tuva_project.dme__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.dme__generate_encounter_id": ["model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.dme__match_claims_to_anchor"], "model.the_tuva_project.dme__anchor_events": ["model.the_tuva_project.dme__generate_encounter_id"], "model.the_tuva_project.lab__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.lab__generate_encounter_id": ["model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.lab__match_claims_to_anchor"], "model.the_tuva_project.lab__anchor_events": ["model.the_tuva_project.lab__generate_encounter_id"], "model.the_tuva_project.ambulance__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.ambulance__anchor_events": ["model.the_tuva_project.ambulance__generate_encounter_id"], "model.the_tuva_project.ambulance__generate_encounter_id": ["model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.ambulance__match_claims_to_anchor"], "model.the_tuva_project.inpatient_substance_use__start_end_dates": ["model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.inpatient_substance_use__prof_claims"], "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.inpatient_substance_use__start_end_dates"], "model.the_tuva_project.inpatient_substance_use__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_radiology__anchor_events": ["model.the_tuva_project.outpatient_radiology__generate_encounter_id"], "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_radiology__generate_encounter_id": ["model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor"], "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": ["model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor"], "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": ["model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"], "model.the_tuva_project.outpatient_surgery__generate_encounter_id": ["model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor"], "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_surgery__anchor_events": ["model.the_tuva_project.outpatient_surgery__generate_encounter_id"], "model.the_tuva_project.asc__generate_encounter_id": ["model.the_tuva_project.asc__start_end_dates"], "model.the_tuva_project.asc__start_end_dates": ["model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.asc__match_claims_to_anchor"], "model.the_tuva_project.asc__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.asc__anchor_events": ["model.the_tuva_project.asc__generate_encounter_id"], "model.the_tuva_project.outpatient_psych__anchor_events": ["model.the_tuva_project.outpatient_psych__generate_encounter_id"], "model.the_tuva_project.outpatient_psych__generate_encounter_id": ["model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor"], "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_hospice__generate_encounter_id": ["model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor"], "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_hospice__anchor_events": ["model.the_tuva_project.outpatient_hospice__generate_encounter_id"], "model.the_tuva_project.office_visits__int_office_visits_ptotst": ["model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_radiology": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_ptotst", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_telehealth": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": ["model.the_tuva_project.office_visits__int_office_visits_claim_line"], "model.the_tuva_project.office_visits__int_office_visits_injections": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_union": ["model.the_tuva_project.office_visits__int_office_visits_claim_line", "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking"], "model.the_tuva_project.office_visits__int_office_visits_em": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_claim_line": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.office_visits__int_office_visits_surgery": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.dialysis__generate_encounter_id": ["model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dialysis__match_claims_to_anchor"], "model.the_tuva_project.dialysis__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.dialysis__anchor_events": ["model.the_tuva_project.dialysis__generate_encounter_id"], "model.the_tuva_project.inpatient_snf__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_snf__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_snf__start_end_dates"], "model.the_tuva_project.inpatient_snf__start_end_dates": ["model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_snf__prof_claims"], "model.the_tuva_project.acute_inpatient__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.acute_inpatient__start_end_dates": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.acute_inpatient__prof_claims"], "model.the_tuva_project.acute_inpatient__generate_encounter_id": ["model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_rehab__generate_encounter_id": ["model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor"], "model.the_tuva_project.outpatient_rehab__anchor_events": ["model.the_tuva_project.outpatient_rehab__generate_encounter_id"], "model.the_tuva_project.inpatient_hospice__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_hospice__prof_claims", "model.the_tuva_project.inpatient_hospice__start_end_dates"], "model.the_tuva_project.inpatient_hospice__start_end_dates": ["model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_hospice__prof_claims"], "model.the_tuva_project.inpatient_hospice__prof_claims": [], "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_ptotst__anchor_events": ["model.the_tuva_project.outpatient_ptotst__generate_encounter_id"], "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": ["model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor"], "model.the_tuva_project.quality_measures__stg_medical_claim": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__stg_core__patient": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__summary_long", "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b", "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6", "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd", "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69"], "model.the_tuva_project.quality_measures__stg_core__observation": ["model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e"], "model.the_tuva_project.quality_measures__stg_core__medication": ["model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652"], "model.the_tuva_project.quality_measures__stg_core__condition": ["model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348"], "model.the_tuva_project.quality_measures__stg_core__lab_result": ["model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_numerator"], "model.the_tuva_project.quality_measures__stg_pharmacy_claim": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia"], "model.the_tuva_project.quality_measures__stg_core__procedure": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9"], "model.the_tuva_project.quality_measures__stg_core__encounter": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159"], "model.the_tuva_project.quality_measures__summary_wide": [], "model.the_tuva_project.quality_measures__summary_counts": ["model.the_tuva_project.data_quality__quality_measures", "model.the_tuva_project.data_quality__quality_measures_reference"], "model.the_tuva_project.quality_measures__summary_long": ["model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.mart_review__quality_measures_summary_long", "model.the_tuva_project.quality_measures__summary_counts", "model.the_tuva_project.quality_measures__summary_wide"], "model.the_tuva_project.quality_measures__int_nqf0041_denominator": ["model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_long", "model.the_tuva_project.quality_measures__int_nqf0041_numerator"], "model.the_tuva_project.quality_measures__int_nqf0041_numerator": ["model.the_tuva_project.quality_measures__int_nqf0041_long"], "model.the_tuva_project.quality_measures__int_nqf0041_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator"], "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0041_long"], "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": ["model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_nqf2372_numerator": ["model.the_tuva_project.quality_measures__int_nqf2372_long"], "model.the_tuva_project.quality_measures__int_nqf2372_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": ["model.the_tuva_project.quality_measures__int_nqf2372_long"], "model.the_tuva_project.quality_measures__int_nqf2372_denominator": ["model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_long", "model.the_tuva_project.quality_measures__int_nqf2372_numerator"], "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0097_long"], "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0097_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0097_numerator": ["model.the_tuva_project.quality_measures__int_nqf0097_long"], "model.the_tuva_project.quality_measures__int_nqf0097_denominator": ["model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "model.the_tuva_project.quality_measures__int_nqf0097_long", "model.the_tuva_project.quality_measures__int_nqf0097_numerator"], "model.the_tuva_project.quality_measures__int_cqm438__performance_period": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__int_cqm438_exclusions"], "model.the_tuva_project.quality_measures__int_cqm438_exclusions": ["model.the_tuva_project.quality_measures__int_cqm438_long"], "model.the_tuva_project.quality_measures__int_cqm438_denominator": ["model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_long", "model.the_tuva_project.quality_measures__int_cqm438_numerator"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": ["model.the_tuva_project.quality_measures__int_cqm438_denominator"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": ["model.the_tuva_project.quality_measures__int_cqm438_denominator"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": ["model.the_tuva_project.quality_measures__int_cqm438_denominator"], "model.the_tuva_project.quality_measures__int_cqm438_numerator": ["model.the_tuva_project.quality_measures__int_cqm438_long"], "model.the_tuva_project.quality_measures__int_cqm438_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm48_denominator": ["model.the_tuva_project.quality_measures__int_cqm48_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_long", "model.the_tuva_project.quality_measures__int_cqm48_numerator"], "model.the_tuva_project.quality_measures__int_cqm48__performance_period": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_exclusions"], "model.the_tuva_project.quality_measures__int_cqm48_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm48_numerator": ["model.the_tuva_project.quality_measures__int_cqm48_long"], "model.the_tuva_project.quality_measures__int_cqm48_exclusions": ["model.the_tuva_project.quality_measures__int_cqm48_long"], "model.the_tuva_project.quality_measures__int_nqf0420_numerator": ["model.the_tuva_project.quality_measures__int_nqf0420_long"], "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0420_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0420_long"], "model.the_tuva_project.quality_measures__int_nqf0420_denominator": ["model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_long", "model.the_tuva_project.quality_measures__int_nqf0420_numerator"], "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia"], "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": ["model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0034_denominator": ["model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0034_numerator"], "model.the_tuva_project.quality_measures__int_nqf0034_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0034_numerator"], "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0034_long"], "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": ["model.the_tuva_project.quality_measures__int_nqf0034_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0034_numerator": ["model.the_tuva_project.quality_measures__int_nqf0034_long"], "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0055_long"], "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_numerator"], "model.the_tuva_project.quality_measures__int_cbe0055_numerator": ["model.the_tuva_project.quality_measures__int_cbe0055_long"], "model.the_tuva_project.quality_measures__int_cbe0055_denominator": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_long", "model.the_tuva_project.quality_measures__int_cbe0055_numerator"], "model.the_tuva_project.quality_measures__int_cbe0055_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cbe0101_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cbe0101_denominator": ["model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_long", "model.the_tuva_project.quality_measures__int_cbe0101_numerator"], "model.the_tuva_project.quality_measures__int_cbe0101_numerator": ["model.the_tuva_project.quality_measures__int_cbe0101_long"], "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0101_long"], "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions"], "model.the_tuva_project.quality_measures__int_cqm236__performance_period": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclusions"], "model.the_tuva_project.quality_measures__int_cqm236_denominator": ["model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_long", "model.the_tuva_project.quality_measures__int_cqm236_numerator"], "model.the_tuva_project.quality_measures__int_cqm236_numerator": ["model.the_tuva_project.quality_measures__int_cqm236_long"], "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": ["model.the_tuva_project.quality_measures__int_cqm236_exclusions"], "model.the_tuva_project.quality_measures__int_cqm236_exclusions": ["model.the_tuva_project.quality_measures__int_cqm236_long"], "model.the_tuva_project.quality_measures__int_cqm236_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"], "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": ["model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"], "model.the_tuva_project.quality_measures__int_nqf0053_denominator": ["model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_long", "model.the_tuva_project.quality_measures__int_nqf0053_numerator"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": ["model.the_tuva_project.quality_measures__int_nqf0053_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0053_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0053_numerator": ["model.the_tuva_project.quality_measures__int_nqf0053_long"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0053_long"], "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": ["model.the_tuva_project.quality_measures__int_adh_diabetes_long"], "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": ["model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"], "model.the_tuva_project.quality_measures__int_adh_diabetes_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"], "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": ["model.the_tuva_project.quality_measures__int_adh_diabetes_long"], "model.the_tuva_project.quality_measures__int_adhras__performance_period": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_adhras_numerator"], "model.the_tuva_project.quality_measures__int_adhras_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_adhras_denominator": ["model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_adhras_long", "model.the_tuva_project.quality_measures__int_adhras_numerator"], "model.the_tuva_project.quality_measures__int_adhras_numerator": ["model.the_tuva_project.quality_measures__int_adhras_long"], "model.the_tuva_project.quality_measures__int_adhras_exclusions": ["model.the_tuva_project.quality_measures__int_adhras_long"], "model.the_tuva_project.quality_measures__int_nqf0059_denominator": ["model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf0059_long", "model.the_tuva_project.quality_measures__int_nqf0059_numerator"], "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0059_long"], "model.the_tuva_project.quality_measures__int_nqf0059_numerator": ["model.the_tuva_project.quality_measures__int_nqf0059_long"], "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0059_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm130_exclusions": ["model.the_tuva_project.quality_measures__int_cqm130_long"], "model.the_tuva_project.quality_measures__int_cqm130__performance_period": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions"], "model.the_tuva_project.quality_measures__int_cqm130_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm130_denominator": ["model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_long", "model.the_tuva_project.quality_measures__int_cqm130_numerator"], "model.the_tuva_project.quality_measures__int_cqm130_numerator": ["model.the_tuva_project.quality_measures__int_cqm130_long"], "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_num", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__pqi_summary"], "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"], "model.the_tuva_project.ahrq_measures__stg_pqi_patient": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender"], "model.the_tuva_project.ahrq_measures__stg_pqi_condition": ["model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "model.the_tuva_project.ahrq_measures__stg_pqi_procedure": ["model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "model.the_tuva_project.ahrq_measures__pqi_num_long": ["model.the_tuva_project.ahrq_measures__pqi_rate", "model.the_tuva_project.ahrq_measures__pqi_summary"], "model.the_tuva_project.ahrq_measures__pqi_denom_long": ["model.the_tuva_project.ahrq_measures__pqi_rate"], "model.the_tuva_project.ahrq_measures__pqi_summary": [], "model.the_tuva_project.ahrq_measures__pqi_rate": [], "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": [], "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_16_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": ["model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_07_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_16_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_15_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_05_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_14_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_08_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_11_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_01_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_16_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_12_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_03_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ccsr__stg_core__condition": ["model.the_tuva_project.ccsr__long_condition_category"], "model.the_tuva_project.ccsr__stg_core__procedure": ["model.the_tuva_project.ccsr__long_procedure_category"], "model.the_tuva_project.ccsr__singular_condition_category": [], "model.the_tuva_project.ccsr__long_condition_category": ["model.the_tuva_project.ccsr__singular_condition_category"], "model.the_tuva_project.ccsr__long_procedure_category": [], "model.the_tuva_project.ccsr__dx_vertical_pivot": ["model.the_tuva_project.ccsr__long_condition_category", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient"], "model.the_tuva_project.ccsr__procedure_category_map": ["model.the_tuva_project.ccsr__long_procedure_category"], "model.the_tuva_project.financial_pmpm__stg_provider_attribution": ["model.the_tuva_project.core__member_months"], "model.the_tuva_project.financial_pmpm__stg_eligibility": [], "model.the_tuva_project.financial_pmpm__stg_medical_claim": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__pmpm_payer": ["model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.mart_review__pmpm"], "model.the_tuva_project.financial_pmpm__pmpm_prep": ["model.the_tuva_project.data_quality__financial_pmpm", "model.the_tuva_project.financial_pmpm__pmpm_payer", "model.the_tuva_project.financial_pmpm__pmpm_payer_plan", "model.the_tuva_project.mart_review__member_months", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23"], "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": [], "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": ["model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot"], "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.hcc_suspecting__stg_core__medication": ["model.the_tuva_project.hcc_suspecting__int_all_medications"], "model.the_tuva_project.hcc_suspecting__stg_core__observation": ["model.the_tuva_project.hcc_suspecting__int_observation_suspects"], "model.the_tuva_project.hcc_suspecting__stg_core__condition": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions"], "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim": ["model.the_tuva_project.hcc_suspecting__int_all_medications"], "model.the_tuva_project.hcc_suspecting__stg_core__lab_result": ["model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs"], "model.the_tuva_project.hcc_suspecting__stg_core__patient": ["model.the_tuva_project.hcc_suspecting__summary"], "model.the_tuva_project.hcc_suspecting__list": ["model.the_tuva_project.hcc_suspecting__list_rollup", "model.the_tuva_project.hcc_suspecting__summary"], "model.the_tuva_project.hcc_suspecting__summary": [], "model.the_tuva_project.hcc_suspecting__list_rollup": [], "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": ["model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_observation_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_medication_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_lab_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": ["model.the_tuva_project.hcc_suspecting__int_lab_suspects"], "model.the_tuva_project.hcc_suspecting__int_all_conditions": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"], "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_all_medications": ["model.the_tuva_project.hcc_suspecting__int_medication_suspects"], "model.the_tuva_project.hcc_suspecting__int_prep_conditions": ["model.the_tuva_project.hcc_suspecting__int_all_conditions", "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient": [], "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "model.the_tuva_project.cms_chronic_conditions__stg_core__patient": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "model.the_tuva_project.cms_chronic_conditions__stg_core__condition": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.mart_review__number_of_conditions", "model.the_tuva_project.mart_review__tuva_chronic_conditions", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": ["test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105", "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": ["test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561", "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "model.the_tuva_project.data_quality__chronic_conditions_none", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008"], "seed.the_tuva_project.terminology__admit_type": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_admit_type_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type"], "seed.the_tuva_project.terminology__medicare_orec": ["model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code"], "seed.the_tuva_project.terminology__gender": ["model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__patient_sex"], "seed.the_tuva_project.terminology__ethnicity": [], "seed.the_tuva_project.terminology__ccs_services_procedures": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__ms_drg": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__inpatient_dq_stage", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_ms_drg_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__hcpcs_to_rbcs": [], "seed.the_tuva_project.terminology__revenue_center": ["model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__icd_9_cm": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__condition", "model.the_tuva_project.core__observation", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": [], "seed.the_tuva_project.terminology__race": ["model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__patient_race"], "seed.the_tuva_project.terminology__rxnorm_to_atc": ["model.the_tuva_project.core__medication", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.mart_review__pharmacy"], "seed.the_tuva_project.terminology__medicare_status": ["model.the_tuva_project.data_quality__eligibility_medicare_status_code"], "seed.the_tuva_project.terminology__loinc_deprecated_mapping": [], "seed.the_tuva_project.terminology__place_of_service": ["model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__discharge_disposition": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.readmissions__encounter_data_quality"], "seed.the_tuva_project.terminology__icd_9_pcs": ["model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.normalized_input__int_procedure_code_normalize"], "seed.the_tuva_project.terminology__present_on_admission": ["model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.normalized_input__int_present_on_admit_normalize"], "seed.the_tuva_project.terminology__mdc": [], "seed.the_tuva_project.terminology__admit_source": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_admit_source_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type"], "seed.the_tuva_project.terminology__rxnorm_brand_generic": ["model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "seed.the_tuva_project.terminology__other_provider_taxonomy": [], "seed.the_tuva_project.terminology__icd_10_cm": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__condition", "model.the_tuva_project.core__observation", "model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.urgent_care__encounter_grain"], "seed.the_tuva_project.terminology__claim_type": ["model.the_tuva_project.data_quality__claim_claim_type"], "seed.the_tuva_project.terminology__hcpcs_level_2": ["model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_normalized_code"], "seed.the_tuva_project.terminology__ndc": ["model.the_tuva_project.core__medication", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.normalized_input__pharmacy_claim", "model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__stg_pharmacy_claim"], "seed.the_tuva_project.terminology__encounter_type": ["model.the_tuva_project.data_quality__encounter_encounter_type"], "seed.the_tuva_project.terminology__snomed_ct": ["model.the_tuva_project.core__condition", "model.the_tuva_project.core__lab_result", "model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure"], "seed.the_tuva_project.terminology__provider": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_claims_practitioner", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_rendering_npi", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.ed_classification__summary", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.normalized_input__pharmacy_claim", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.urgent_care__encounter_grain"], "seed.the_tuva_project.terminology__payer_type": ["model.the_tuva_project.data_quality__eligibility_missing_payer", "model.the_tuva_project.data_quality__eligibility_payer_type"], "seed.the_tuva_project.terminology__ms_drg_weights_los": [], "seed.the_tuva_project.terminology__apr_drg": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__inpatient_dq_stage", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_apr_drg_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_inpatient_institutional"], "seed.the_tuva_project.terminology__icd_10_pcs": ["model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "model.the_tuva_project.readmissions__procedure_ccs"], "seed.the_tuva_project.terminology__nitos": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__medicare_dual_eligibility": ["model.the_tuva_project.data_quality__eligibility_dual_status_code"], "seed.the_tuva_project.terminology__bill_type": ["model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.normalized_input__int_bill_type_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__loinc": ["model.the_tuva_project.core__lab_result", "model.the_tuva_project.core__observation", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_normalized_component"], "seed.the_tuva_project.terminology__snomed_icd_10_map": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions"], "seed.the_tuva_project.clinical_concept_library__value_set_members": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"], "seed.the_tuva_project.clinical_concept_library__coding_systems": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"], "seed.the_tuva_project.clinical_concept_library__clinical_concepts": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"], "seed.the_tuva_project.pharmacy__rxnorm_generic_available": ["model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__int_generic_cost", "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc"], "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk"], "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": [], "seed.the_tuva_project.data_quality__crosswalk_field_info": ["model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "model.the_tuva_project.data_quality__summary"], "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": [], "seed.the_tuva_project.data_quality__reference_mart_analytics": ["model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__quality_measures_reference", "model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.data_quality__service_categories_pmpm"], "seed.the_tuva_project.service_category__service_categories": ["model.the_tuva_project.service_category__service_category_grouper"], "seed.the_tuva_project.ed_classification__johnston_icd9": ["model.the_tuva_project.ed_classification__int_map_primary_dx", "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0", "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617"], "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": [], "seed.the_tuva_project.ed_classification__johnston_icd10": ["model.the_tuva_project.ed_classification__int_map_primary_dx", "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7", "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd"], "seed.the_tuva_project.ed_classification__categories": ["model.the_tuva_project.ed_classification__summary"], "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": ["model.the_tuva_project.readmissions__encounter_with_ccs"], "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__specialty_cohort": ["model.the_tuva_project.readmissions__encounter_specialty_cohort"], "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": ["model.the_tuva_project.readmissions__exclusion"], "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": ["model.the_tuva_project.readmissions__encounter_specialty_cohort"], "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": ["model.the_tuva_project.readmissions__procedure_ccs"], "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": ["model.the_tuva_project.cms_hcc__int_disabled_interaction_factors"], "seed.the_tuva_project.cms_hcc__disease_hierarchy": ["model.the_tuva_project.cms_hcc__int_hcc_hierarchy"], "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": ["model.the_tuva_project.cms_hcc__int_hcc_mapping"], "seed.the_tuva_project.cms_hcc__disease_factors": ["model.the_tuva_project.cms_hcc__int_disease_factors"], "seed.the_tuva_project.cms_hcc__disease_interaction_factors": ["model.the_tuva_project.cms_hcc__int_disease_interaction_factors"], "seed.the_tuva_project.cms_hcc__cpt_hcpcs": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "seed.the_tuva_project.cms_hcc__adjustment_rates": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": ["model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors"], "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": ["model.the_tuva_project.cms_hcc__int_hcc_count_factors"], "seed.the_tuva_project.cms_hcc__demographic_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors"], "seed.the_tuva_project.quality_measures__value_sets": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"], "seed.the_tuva_project.quality_measures__measures": ["model.the_tuva_project.mart_review__quality_measures_value_set", "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__int_nqf2372__performance_period"], "seed.the_tuva_project.quality_measures__concepts": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator"], "seed.the_tuva_project.pqi__measures": ["model.the_tuva_project.ahrq_measures__pqi_summary"], "seed.the_tuva_project.pqi__value_sets": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": ["model.the_tuva_project.ccsr__procedure_category_map"], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": ["model.the_tuva_project.ccsr__long_condition_category", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient"], "seed.the_tuva_project.hcc_suspecting__clinical_concepts": ["model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs"], "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": ["model.the_tuva_project.hcc_suspecting__int_all_conditions"], "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": ["model.the_tuva_project.hcc_suspecting__int_all_conditions", "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects"], "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": [], "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "seed.the_tuva_project.reference_data__fips_county": [], "seed.the_tuva_project.reference_data__calendar": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.core__member_months", "model.the_tuva_project.data_quality__claim_date_trends", "model.the_tuva_project.data_quality__eligibility_dq_stage", "model.the_tuva_project.data_quality__eligibility_trend", "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "model.the_tuva_project.data_quality__financial_pmpm", "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "model.the_tuva_project.data_quality__quality_trend", "model.the_tuva_project.data_quality__service_category_pmpm_trend", "model.the_tuva_project.mart_review__calendar_month", "model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.mart_review__stg_member_month", "model.the_tuva_project.mart_review__stg_pharmacy_claim", "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_procedure_date_normalize"], "seed.the_tuva_project.reference_data__ssa_fips_state": ["model.the_tuva_project.data_quality__eligibility_state"], "seed.the_tuva_project.reference_data__ansi_fips_state": [], "seed.the_tuva_project.reference_data__code_type": ["model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_code_type"], "operation.the_tuva_project.the_tuva_project-on-run-end-0": [], "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617": [], "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0": [], "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd": [], "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59": [], "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0": [], "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a": [], "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792": [], "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af": [], "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a": [], "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1": [], "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59": [], "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e": [], "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c": [], "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6": [], "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5": [], "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98": [], "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084": [], "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0": [], "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a": [], "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba": [], "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc": [], "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b": [], "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d": [], "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348": [], "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159": [], "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652": [], "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e": [], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd": [], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69": [], "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b": [], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6": [], "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23": [], "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00": [], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea": [], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2": [], "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158": [], "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561": [], "model.the_tuva_project.core__medical_claim": ["model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__service_categories_pmpm", "model.the_tuva_project.data_quality__service_category_pmpm_trend", "model.the_tuva_project.financial_pmpm__stg_medical_claim", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_medical_claim", "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708"], "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708": []}, "group_map": {}, "saved_queries": {}, "semantic_models": {}, "unit_tests": {}} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v12.json", "dbt_version": "1.8.6", "generated_at": "2024-10-25T14:34:28.294692Z", "invocation_id": "7a3fb5b6-66c4-4d4a-b7ed-a46ac2f1bdcb", "env": {}, "project_name": "input_layer", "project_id": "c67fdb5d91230d67641e7c60c81d655e", "user_id": "c5ffe329-cd24-4f82-be78-c62b00387d3d", "send_anonymous_usage_stats": true, "adapter_type": "snowflake"}, "nodes": {"model.input_layer.condition": {"database": "tuva", "schema": "input_layer", "name": "condition", "resource_type": "model", "package_name": "input_layer", "path": "condition.sql", "original_file_path": "models\\condition.sql", "unique_id": "model.input_layer.condition", "fqn": ["input_layer", "condition"], "alias": "condition", "checksum": {"name": "sha256", "checksum": "0681ec87a5cdc92bfbf9933f197ede55f15bf5ed3b6cb4e7200abf73c5468d03"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The condition table contains information related to medical conditions patients have, including problems, admitting diagnosis codes, and billable diagnosis codes.\n", "columns": {"condition_id": {"name": "condition_id", "description": "Unique identifier for each condition in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date when the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "onset_date": {"name": "onset_date", "description": "Date when the condition first occurred.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "resolved_date": {"name": "resolved_date", "description": "Date when the condition was resolved.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of the condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition i.e. problem, admitting, or billing.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The condition code in the source system e.g. the ICD-10 code.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the condition code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of condition code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized condition code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "The numerical ranking of a diagnosis code in a claim. Principle diagnosis code is given a ranking of 1. Claims data typically has a strict ranking of conditions whereas medical records will often not have this information or the information won't be accurate.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "present_on_admit_code": {"name": "present_on_admit_code", "description": "The present_on_admit_code related to the condition.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "present_on_admit_description": {"name": "present_on_admit_description", "description": "The description of the present_on_admit_code for the condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.955006, "relation_name": "tuva.input_layer.condition", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as condition_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as claim_id\r\n , cast(null as date) as recorded_date\r\n , cast(null as date) as onset_date\r\n , cast(null as date) as resolved_date\r\n , cast(null as {{ dbt.type_string() }} ) as status\r\n , cast(null as {{ dbt.type_string() }} ) as condition_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(null as {{ dbt.type_int() }} ) as condition_rank\r\n , cast(null as {{ dbt.type_string() }} ) as present_on_admit_code\r\n , cast(null as {{ dbt.type_string() }} ) as present_on_admit_description\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\condition.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as condition_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as recorded_date\n , cast(null as date) as onset_date\n , cast(null as date) as resolved_date\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as condition_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as integer ) as condition_rank\n , cast(null as TEXT ) as present_on_admit_code\n , cast(null as TEXT ) as present_on_admit_description\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.eligibility": {"database": "tuva", "schema": "input_layer", "name": "eligibility", "resource_type": "model", "package_name": "input_layer", "path": "eligibility.sql", "original_file_path": "models\\eligibility.sql", "unique_id": "model.input_layer.eligibility", "fqn": ["input_layer", "eligibility"], "alias": "eligibility", "checksum": {"name": "sha256", "checksum": "0f628680d0f0db4c63f41bb10631b3eb250f3bcc347d267e1d564c7aab7551ad"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The eligibility table includes information about a patient's health insurance coverage and demographics (note: we use the word patient as a synonym for member). Every claims dataset should include some sort of eligibility data, otherwise it's impossible to calculate member months, which are needed to calculate measures like PMPM.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_id": {"name": "subscriber_id", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Biological sex of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "Race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "Date the patient was born.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "Indicates whether the patient has died.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_type": {"name": "payer_type", "description": "Type of payer (e.g. commercial, medicare, medicaid, etc.).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__payer_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "Original reason for Medicare entitlement code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "Patient's first name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Patient's last name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "Patient's social security number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_relation": {"name": "subscriber_relation", "description": "Relationship to the policy holder (self, spouse, dependent, etc)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "Patient's street address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "Patient's city of address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "State the patient lives in (most recent known address)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "Zip code the patient lives in (most recent known address).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "phone": {"name": "phone", "description": "Patient's phone number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9042997, "relation_name": "tuva.input_layer.eligibility", "raw_code": "select\r\n patient_id\r\n , member_id\r\n , subscriber_id\r\n , gender\r\n , race\r\n , birth_date\r\n , death_date\r\n , death_flag\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , payer\r\n , payer_type\r\n , plan\r\n , original_reason_entitlement_code\r\n , dual_status_code\r\n , medicare_status_code\r\n , first_name\r\n , last_name\r\n , social_security_number\r\n , subscriber_relation\r\n , address\r\n , city\r\n , state\r\n , zip_code\r\n , phone\r\n , data_source\r\n , file_name\r\n , ingest_datetime\r\nfrom {{ ref('eligibility_seed') }}", "language": "sql", "refs": [{"name": "eligibility_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.eligibility_seed"]}, "compiled_path": "target\\compiled\\input_layer\\models\\eligibility.sql", "compiled": true, "compiled_code": "select\n patient_id\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , subscriber_relation\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom dev_thuxuan._tuva_synthetic.eligibility_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.encounter": {"database": "tuva", "schema": "input_layer", "name": "encounter", "resource_type": "model", "package_name": "input_layer", "path": "encounter.sql", "original_file_path": "models\\encounter.sql", "unique_id": "model.input_layer.encounter", "fqn": ["input_layer", "encounter"], "alias": "encounter", "checksum": {"name": "sha256", "checksum": "ec2c7a75dea236d96df79eb1475ff29f8766a5b9b79d7f6c7dbf5bdc5c4e45f2"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The encounter table contains information about patients visits (i.e. encounters). This includes acute inpatient, emergency department, office visits, SNF stays, etc.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__encounter_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Admission source code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Admission type code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Discharge disposition code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_id": {"name": "attending_provider_id", "description": "Attending provider ID for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_name": {"name": "attending_provider_name", "description": "Attending provider name for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility identifier for the encounter (typically represents the facility where services were performed). Can be an NPI or source code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name for the encounter (typically represents the facility where services were performed).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG code for the encounter.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid for the encounter by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient) on the encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the encounter by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9609244, "relation_name": "tuva.input_layer.encounter", "raw_code": "select \r\n cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_type\r\n , cast(null as date) as encounter_start_date\r\n , cast(null as date) as encounter_end_date\r\n , cast(null as {{ dbt.type_int() }} ) as length_of_stay\r\n , cast(null as {{ dbt.type_string() }} ) as admit_source_code\r\n , cast(null as {{ dbt.type_string() }} ) as admit_source_description\r\n , cast(null as {{ dbt.type_string() }} ) as admit_type_code\r\n , cast(null as {{ dbt.type_string() }} ) as admit_type_description\r\n , cast(null as {{ dbt.type_string() }} ) as discharge_disposition_code\r\n , cast(null as {{ dbt.type_string() }} ) as discharge_disposition_description\r\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_id\r\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_name\r\n , cast(null as {{ dbt.type_string() }} ) as facility_id\r\n , cast(null as {{ dbt.type_string() }} ) as facility_name\r\n , cast(null as {{ dbt.type_string() }} ) as primary_diagnosis_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as primary_diagnosis_code\r\n , cast(null as {{ dbt.type_string() }} ) as primary_diagnosis_description\r\n , cast(null as {{ dbt.type_string() }} ) as ms_drg_code\r\n , cast(null as {{ dbt.type_string() }} ) as ms_drg_description\r\n , cast(null as {{ dbt.type_string() }} ) as apr_drg_code\r\n , cast(null as {{ dbt.type_string() }} ) as apr_drg_description\r\n , cast(null as {{ dbt.type_numeric() }} ) as paid_amount\r\n , cast(null as {{ dbt.type_numeric() }} ) as allowed_amount\r\n , cast(null as {{ dbt.type_numeric() }} ) as charge_amount\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\encounter.sql", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_type\n , cast(null as date) as encounter_start_date\n , cast(null as date) as encounter_end_date\n , cast(null as integer ) as length_of_stay\n , cast(null as TEXT ) as admit_source_code\n , cast(null as TEXT ) as admit_source_description\n , cast(null as TEXT ) as admit_type_code\n , cast(null as TEXT ) as admit_type_description\n , cast(null as TEXT ) as discharge_disposition_code\n , cast(null as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(null as TEXT ) as facility_id\n , cast(null as TEXT ) as facility_name\n , cast(null as TEXT ) as primary_diagnosis_code_type\n , cast(null as TEXT ) as primary_diagnosis_code\n , cast(null as TEXT ) as primary_diagnosis_description\n , cast(null as TEXT ) as ms_drg_code\n , cast(null as TEXT ) as ms_drg_description\n , cast(null as TEXT ) as apr_drg_code\n , cast(null as TEXT ) as apr_drg_description\n , cast(null as numeric(28,6) ) as paid_amount\n , cast(null as numeric(28,6) ) as allowed_amount\n , cast(null as numeric(28,6) ) as charge_amount\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.lab_result": {"database": "tuva", "schema": "input_layer", "name": "lab_result", "resource_type": "model", "package_name": "input_layer", "path": "lab_result.sql", "original_file_path": "models\\lab_result.sql", "unique_id": "model.input_layer.lab_result", "fqn": ["input_layer", "lab_result"], "alias": "lab_result", "checksum": {"name": "sha256", "checksum": "6243bc2dffe3a6fca8105414f648c9c1febc9311dd71085c83f2a4b95f362f4a"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The lab result table contains information about lab test results, including the LOINC code and description, units, reference range, and result.\n", "columns": {"lab_result_id": {"name": "lab_result_id", "description": "Unique identifier for the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter. Included in this table if the lab test can be linked to an encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "accession_number": {"name": "accession_number", "description": "The lab order number from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The code type from the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code for the lab from the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "The description for the lab test from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_component": {"name": "source_component", "description": "The description for the component of the test from the source system.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized code type.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code e.g. LOINC.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "The normalized description for the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_component": {"name": "normalized_component", "description": "The normalized component.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "The status of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "collection_date": {"name": "collection_date", "description": "Date the test was collected.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_abnormal_flag": {"name": "source_abnormal_flag", "description": "Indicates whether the result is abnormal or normal.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_abnormal_flag": {"name": "normalized_abnormal_flag", "description": "Normalized abnormal flag.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specimen": {"name": "specimen", "description": "The type of specimen e.g. blood, plasma, urine.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ordering_practitioner_id": {"name": "ordering_practitioner_id", "description": "Unique identifier for the practitioner who ordered the lab test.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9669251, "relation_name": "tuva.input_layer.lab_result", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as lab_result_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as accession_number\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(null as {{ dbt.type_string() }} ) as source_component\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_component\r\n , cast(null as {{ dbt.type_string() }} ) as status\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , cast(null as date) as result_date\r\n , cast(null as date) as collection_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_units\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_units\r\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_low\r\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_high\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_low\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_high\r\n , cast(null as {{ dbt.type_int() }} ) as source_abnormal_flag\r\n , cast(null as {{ dbt.type_int() }} ) as normalized_abnormal_flag\r\n , cast(null as {{ dbt.type_string() }} ) as specimen\r\n , cast(null as {{ dbt.type_string() }} ) as ordering_practitioner_id\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\lab_result.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as lab_result_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as accession_number\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as source_component\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as normalized_component\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as result\n , cast(null as date) as result_date\n , cast(null as date) as collection_date\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as integer ) as source_abnormal_flag\n , cast(null as integer ) as normalized_abnormal_flag\n , cast(null as TEXT ) as specimen\n , cast(null as TEXT ) as ordering_practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.location": {"database": "tuva", "schema": "input_layer", "name": "location", "resource_type": "model", "package_name": "input_layer", "path": "location.sql", "original_file_path": "models\\location.sql", "unique_id": "model.input_layer.location", "fqn": ["input_layer", "location"], "alias": "location", "checksum": {"name": "sha256", "checksum": "fc6e5bfdff50c772b2075f4a7fbdba2c4e977d98eddc8eb79358e0b7a7061283"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The location table contains information on practice and facility locations where patients receive medical care.\n", "columns": {"location_id": {"name": "location_id", "description": "Unique identifier for each location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "The national provider identifier associated with the location e.g. facility_npi.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "name": {"name": "name", "description": "The name of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_organization": {"name": "parent_organization", "description": "The parent organization associated with the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The street address of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9699244, "relation_name": "tuva.input_layer.location", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as location_id\r\n , cast(null as {{ dbt.type_string() }} ) as npi\r\n , cast(null as {{ dbt.type_string() }} ) as name\r\n , cast(null as {{ dbt.type_string() }} ) as facility_type\r\n , cast(null as {{ dbt.type_string() }} ) as parent_organization\r\n , cast(null as {{ dbt.type_string() }} ) as address\r\n , cast(null as {{ dbt.type_string() }} ) as city\r\n , cast(null as {{ dbt.type_string() }} ) as state\r\n , cast(null as {{ dbt.type_string() }} ) as zip_code\r\n , cast(null as {{ dbt.type_float() }} ) as latitude\r\n , cast(null as {{ dbt.type_float() }} ) as longitude\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\location.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as location_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(null as TEXT ) as parent_organization\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.medical_claim": {"database": "tuva", "schema": "input_layer", "name": "medical_claim", "resource_type": "model", "package_name": "input_layer", "path": "medical_claim.sql", "original_file_path": "models\\medical_claim.sql", "unique_id": "model.input_layer.medical_claim", "fqn": ["input_layer", "medical_claim"], "alias": "medical_claim", "checksum": {"name": "sha256", "checksum": "90ed77ffdeeed277bd4bd4f372cfb2862350347e986fc8edcf0daebd9a71695c"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The medical_claim table contains information on healthcare services and supplies provided to patients, billed by providers, and paid for by health insurers. It includes information on the provider who rendered the service, the amount paid for the service by the health insurer, and the underlying reason for the service (i.e. diagnosis).\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__claim_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "Start date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_start_date": {"name": "claim_line_start_date", "description": "Start date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_end_date": {"name": "claim_line_end_date", "description": "End date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "Admission date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Discharge date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Place of service for the claim (professional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__place_of_service.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__bill_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code for the claim line (institutional only and typically multiple codes per claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__revenue_center.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_unit_quantity": {"name": "service_unit_quantity", "description": "The number of units for the particular revenue center code.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "HCPCS level 1 or level 2 code for the claim line.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "1st modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "2nd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "3rd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "4th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "5th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_npi": {"name": "rendering_npi", "description": "Rendering NPI for the claim (typically represents the physician or entity providing services).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_tin": {"name": "rendering_tin", "description": "Rendering provider tax identification number (TIN).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_npi": {"name": "billing_npi", "description": "Billing NPI for the claim (typically represents organization billing the claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_tin": {"name": "billing_tin", "description": "Billing provider tax identification number (TIN).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid on the claim by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient) on the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount paid by the patient that applies towards their deductible.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_cost_amount": {"name": "total_cost_amount", "description": "The total amount paid on the claim by different parties.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_type": {"name": "diagnosis_code_type", "description": "Indicates the type of diagnosis code (e.g. ICD-10-CM).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_1": {"name": "diagnosis_code_1", "description": "1st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_2": {"name": "diagnosis_code_2", "description": "2nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_3": {"name": "diagnosis_code_3", "description": "3rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_4": {"name": "diagnosis_code_4", "description": "4th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_5": {"name": "diagnosis_code_5", "description": "5th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_6": {"name": "diagnosis_code_6", "description": "6th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_7": {"name": "diagnosis_code_7", "description": "7th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_8": {"name": "diagnosis_code_8", "description": "8th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_9": {"name": "diagnosis_code_9", "description": "9th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_10": {"name": "diagnosis_code_10", "description": "10th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_11": {"name": "diagnosis_code_11", "description": "11th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_12": {"name": "diagnosis_code_12", "description": "12th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_13": {"name": "diagnosis_code_13", "description": "13th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_14": {"name": "diagnosis_code_14", "description": "14th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_15": {"name": "diagnosis_code_15", "description": "15th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_16": {"name": "diagnosis_code_16", "description": "16th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_17": {"name": "diagnosis_code_17", "description": "17th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_18": {"name": "diagnosis_code_18", "description": "18th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_19": {"name": "diagnosis_code_19", "description": "19th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_20": {"name": "diagnosis_code_20", "description": "20th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_21": {"name": "diagnosis_code_21", "description": "21st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_22": {"name": "diagnosis_code_22", "description": "22nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_23": {"name": "diagnosis_code_23", "description": "23rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_24": {"name": "diagnosis_code_24", "description": "24th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_25": {"name": "diagnosis_code_25", "description": "25th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_1": {"name": "diagnosis_poa_1", "description": "Present on admission code for the 1st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_2": {"name": "diagnosis_poa_2", "description": "Present on admission code for the 2nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_3": {"name": "diagnosis_poa_3", "description": "Present on admission code for the 3rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_4": {"name": "diagnosis_poa_4", "description": "Present on admission code for the 4th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_5": {"name": "diagnosis_poa_5", "description": "Present on admission code for the 5th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_6": {"name": "diagnosis_poa_6", "description": "Present on admission code for the 6th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_7": {"name": "diagnosis_poa_7", "description": "Present on admission code for the 7th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_8": {"name": "diagnosis_poa_8", "description": "Present on admission code for the 8th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_9": {"name": "diagnosis_poa_9", "description": "Present on admission code for the 9th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_10": {"name": "diagnosis_poa_10", "description": "Present on admission code for the 10th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_11": {"name": "diagnosis_poa_11", "description": "Present on admission code for the 11th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_12": {"name": "diagnosis_poa_12", "description": "Present on admission code for the 12th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_13": {"name": "diagnosis_poa_13", "description": "Present on admission code for the 13th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_14": {"name": "diagnosis_poa_14", "description": "Present on admission code for the 14th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_15": {"name": "diagnosis_poa_15", "description": "Present on admission code for the 15th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_16": {"name": "diagnosis_poa_16", "description": "Present on admission code for the 16th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_17": {"name": "diagnosis_poa_17", "description": "Present on admission code for the 17th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_18": {"name": "diagnosis_poa_18", "description": "Present on admission code for the 18th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_19": {"name": "diagnosis_poa_19", "description": "Present on admission code for the 19th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_20": {"name": "diagnosis_poa_20", "description": "Present on admission code for the 20th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_21": {"name": "diagnosis_poa_21", "description": "Present on admission code for the 21st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_22": {"name": "diagnosis_poa_22", "description": "Present on admission code for the 22nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_23": {"name": "diagnosis_poa_23", "description": "Present on admission code for the 23rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_24": {"name": "diagnosis_poa_24", "description": "Present on admission code for the 24th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_25": {"name": "diagnosis_poa_25", "description": "Present on admission code for the 25th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_type": {"name": "procedure_code_type", "description": "Indicates the type of procedure code (e.g. ICD-10-PCS).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_1": {"name": "procedure_code_1", "description": "1st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_2": {"name": "procedure_code_2", "description": "2nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_3": {"name": "procedure_code_3", "description": "3rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_4": {"name": "procedure_code_4", "description": "4th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_5": {"name": "procedure_code_5", "description": "5th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_6": {"name": "procedure_code_6", "description": "6th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_7": {"name": "procedure_code_7", "description": "7th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_8": {"name": "procedure_code_8", "description": "8th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_9": {"name": "procedure_code_9", "description": "9th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_10": {"name": "procedure_code_10", "description": "10th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_11": {"name": "procedure_code_11", "description": "11th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_12": {"name": "procedure_code_12", "description": "12th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_13": {"name": "procedure_code_13", "description": "13th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_14": {"name": "procedure_code_14", "description": "14th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_15": {"name": "procedure_code_15", "description": "15th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_16": {"name": "procedure_code_16", "description": "16th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_17": {"name": "procedure_code_17", "description": "17th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_18": {"name": "procedure_code_18", "description": "18th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_19": {"name": "procedure_code_19", "description": "19th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_20": {"name": "procedure_code_20", "description": "20th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_21": {"name": "procedure_code_21", "description": "21st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_22": {"name": "procedure_code_22", "description": "22nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_23": {"name": "procedure_code_23", "description": "23rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_24": {"name": "procedure_code_24", "description": "24th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_25": {"name": "procedure_code_25", "description": "25th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_1": {"name": "procedure_date_1", "description": "Date of the 1st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_2": {"name": "procedure_date_2", "description": "Date of the 2nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_3": {"name": "procedure_date_3", "description": "Date of the 3rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_4": {"name": "procedure_date_4", "description": "Date of the 4th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_5": {"name": "procedure_date_5", "description": "Date of the 5th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_6": {"name": "procedure_date_6", "description": "Date of the 6th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_7": {"name": "procedure_date_7", "description": "Date of the 7th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_8": {"name": "procedure_date_8", "description": "Date of the 8th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_9": {"name": "procedure_date_9", "description": "Date of the 9th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_10": {"name": "procedure_date_10", "description": "Date of the 10th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_11": {"name": "procedure_date_11", "description": "Date of the 11th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_12": {"name": "procedure_date_12", "description": "Date of the 12th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_13": {"name": "procedure_date_13", "description": "Date of the 13th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_14": {"name": "procedure_date_14", "description": "Date of the 14th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_15": {"name": "procedure_date_15", "description": "Date of the 15th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_16": {"name": "procedure_date_16", "description": "Date of the 16th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_17": {"name": "procedure_date_17", "description": "Date of the 17th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_18": {"name": "procedure_date_18", "description": "Date of the 18th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_19": {"name": "procedure_date_19", "description": "Date of the 19th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_20": {"name": "procedure_date_20", "description": "Date of the 20th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_21": {"name": "procedure_date_21", "description": "Date of the 21st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_22": {"name": "procedure_date_22", "description": "Date of the 22nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_23": {"name": "procedure_date_23", "description": "Date of the 23rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_24": {"name": "procedure_date_24", "description": "Date of the 24th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_25": {"name": "procedure_date_25", "description": "Date of the 25th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9430068, "relation_name": "tuva.input_layer.medical_claim", "raw_code": "select\r\n claim_id\r\n , claim_line_number\r\n , claim_type\r\n , patient_id\r\n , member_id\r\n , payer\r\n , plan\r\n , claim_start_date\r\n , claim_end_date\r\n , claim_line_start_date\r\n , claim_line_end_date\r\n , admission_date\r\n , discharge_date\r\n , admit_source_code\r\n , admit_type_code\r\n , discharge_disposition_code\r\n , place_of_service_code\r\n , bill_type_code\r\n , ms_drg_code\r\n , apr_drg_code\r\n , revenue_center_code\r\n , service_unit_quantity\r\n , hcpcs_code\r\n , hcpcs_modifier_1\r\n , hcpcs_modifier_2\r\n , hcpcs_modifier_3\r\n , hcpcs_modifier_4\r\n , hcpcs_modifier_5\r\n , rendering_npi\r\n , rendering_tin\r\n , billing_npi\r\n , billing_tin\r\n , facility_npi\r\n , paid_date\r\n , paid_amount\r\n , allowed_amount\r\n , charge_amount\r\n , coinsurance_amount\r\n , copayment_amount\r\n , deductible_amount\r\n , total_cost_amount\r\n , diagnosis_code_type\r\n , diagnosis_code_1\r\n , diagnosis_code_2\r\n , diagnosis_code_3\r\n , diagnosis_code_4\r\n , diagnosis_code_5\r\n , diagnosis_code_6\r\n , diagnosis_code_7\r\n , diagnosis_code_8\r\n , diagnosis_code_9\r\n , diagnosis_code_10\r\n , diagnosis_code_11\r\n , diagnosis_code_12\r\n , diagnosis_code_13\r\n , diagnosis_code_14\r\n , diagnosis_code_15\r\n , diagnosis_code_16\r\n , diagnosis_code_17\r\n , diagnosis_code_18\r\n , diagnosis_code_19\r\n , diagnosis_code_20\r\n , diagnosis_code_21\r\n , diagnosis_code_22\r\n , diagnosis_code_23\r\n , diagnosis_code_24\r\n , diagnosis_code_25\r\n , diagnosis_poa_1\r\n , diagnosis_poa_2\r\n , diagnosis_poa_3\r\n , diagnosis_poa_4\r\n , diagnosis_poa_5\r\n , diagnosis_poa_6\r\n , diagnosis_poa_7\r\n , diagnosis_poa_8\r\n , diagnosis_poa_9\r\n , diagnosis_poa_10\r\n , diagnosis_poa_11\r\n , diagnosis_poa_12\r\n , diagnosis_poa_13\r\n , diagnosis_poa_14\r\n , diagnosis_poa_15\r\n , diagnosis_poa_16\r\n , diagnosis_poa_17\r\n , diagnosis_poa_18\r\n , diagnosis_poa_19\r\n , diagnosis_poa_20\r\n , diagnosis_poa_21\r\n , diagnosis_poa_22\r\n , diagnosis_poa_23\r\n , diagnosis_poa_24\r\n , diagnosis_poa_25\r\n , procedure_code_type\r\n , procedure_code_1\r\n , procedure_code_2\r\n , procedure_code_3\r\n , procedure_code_4\r\n , procedure_code_5\r\n , procedure_code_6\r\n , procedure_code_7\r\n , procedure_code_8\r\n , procedure_code_9\r\n , procedure_code_10\r\n , procedure_code_11\r\n , procedure_code_12\r\n , procedure_code_13\r\n , procedure_code_14\r\n , procedure_code_15\r\n , procedure_code_16\r\n , procedure_code_17\r\n , procedure_code_18\r\n , procedure_code_19\r\n , procedure_code_20\r\n , procedure_code_21\r\n , procedure_code_22\r\n , procedure_code_23\r\n , procedure_code_24\r\n , procedure_code_25\r\n , procedure_date_1\r\n , procedure_date_2\r\n , procedure_date_3\r\n , procedure_date_4\r\n , procedure_date_5\r\n , procedure_date_6\r\n , procedure_date_7\r\n , procedure_date_8\r\n , procedure_date_9\r\n , procedure_date_10\r\n , procedure_date_11\r\n , procedure_date_12\r\n , procedure_date_13\r\n , procedure_date_14\r\n , procedure_date_15\r\n , procedure_date_16\r\n , procedure_date_17\r\n , procedure_date_18\r\n , procedure_date_19\r\n , procedure_date_20\r\n , procedure_date_21\r\n , procedure_date_22\r\n , procedure_date_23\r\n , procedure_date_24\r\n , procedure_date_25\r\n , in_network_flag\r\n , data_source\r\n , file_name\r\n , ingest_datetime\r\nfrom {{ ref('medical_claim_seed') }}", "language": "sql", "refs": [{"name": "medical_claim_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.medical_claim_seed"]}, "compiled_path": "target\\compiled\\input_layer\\models\\medical_claim.sql", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom dev_thuxuan._tuva_synthetic.medical_claim_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.medication": {"database": "tuva", "schema": "input_layer", "name": "medication", "resource_type": "model", "package_name": "input_layer", "path": "medication.sql", "original_file_path": "models\\medication.sql", "unique_id": "model.input_layer.medication", "fqn": ["input_layer", "medication"], "alias": "medication", "checksum": {"name": "sha256", "checksum": "872d7cb7ae5f99297f66545422d26c1296e97458c2e4d01aa9c0845f3ec504c4"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The medication table contains information on medications ordered and/or administered during a patient encounter.\n", "columns": {"medication_id": {"name": "medication_id", "description": "Unique identifier for each medication in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_date": {"name": "prescribing_date", "description": "Date the medication was prescribed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The source code type of the medication.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The source code for the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "The source description of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code associated with the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description for the NDC.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "RxNorm code associated with the medication.", "meta": {"terminology": "https://www.nlm.nih.gov/research/umls/rxnorm/index.html"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "Description for the RxNorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_code": {"name": "atc_code", "description": "ATC code for the medication.", "meta": {"terminology": "https://www.who.int/tools/atc-ddd-toolkit/atc-classification"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_description": {"name": "atc_description", "description": "Description for the ATC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "route": {"name": "route", "description": "The route used to administer the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "strength": {"name": "strength", "description": "The strength of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "The quantity of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity_unit": {"name": "quantity_unit", "description": "The units for the quantity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "The number of days supply included.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner who ordered the medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer"}, "created_at": 1729866314.9744976, "relation_name": "tuva.input_layer.medication", "raw_code": "select \r\n cast(null as {{ dbt.type_string() }} ) as medication_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as date) as dispensing_date\r\n , cast(null as date) as prescribing_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_description\r\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\r\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_description\r\n , cast(null as {{ dbt.type_string() }} ) as atc_code\r\n , cast(null as {{ dbt.type_string() }} ) as atc_description\r\n , cast(null as {{ dbt.type_string() }} ) as route\r\n , cast(null as {{ dbt.type_string() }} ) as strength\r\n , cast(null as {{ dbt.type_int() }} ) as quantity\r\n , cast(null as {{ dbt.type_string() }} ) as quantity_unit\r\n , cast(null as {{ dbt.type_int() }} ) as days_supply\r\n , cast(null as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\medication.sql", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as medication_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as date) as dispensing_date\n , cast(null as date) as prescribing_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as ndc_code\n , cast(null as TEXT ) as ndc_description\n , cast(null as TEXT ) as rxnorm_code\n , cast(null as TEXT ) as rxnorm_description\n , cast(null as TEXT ) as atc_code\n , cast(null as TEXT ) as atc_description\n , cast(null as TEXT ) as route\n , cast(null as TEXT ) as strength\n , cast(null as integer ) as quantity\n , cast(null as TEXT ) as quantity_unit\n , cast(null as integer ) as days_supply\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.observation": {"database": "tuva", "schema": "input_layer", "name": "observation", "resource_type": "model", "package_name": "input_layer", "path": "observation.sql", "original_file_path": "models\\observation.sql", "unique_id": "model.input_layer.observation", "fqn": ["input_layer", "observation"], "alias": "observation", "checksum": {"name": "sha256", "checksum": "f0a66f2135df8dde3c82a1e878344b84cf6ba91e888aba791fb24054a4a68b49"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The observation table contains information on measurements other than lab tests e.g. blood pressure, height, and weight.\n", "columns": {"observation_id": {"name": "observation_id", "description": "Unique identifier for each observation in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "panel_id": {"name": "panel_id", "description": "Unique identifier for the panel.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "Date the observation was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_type": {"name": "observation_type", "description": "Type of observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "Source code type of the observation.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "Source code of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Source description of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "Normalized code type of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "Normalized code of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the observatino.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Custom description of the source system e.g. Epic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9774976, "relation_name": "tuva.input_layer.observation", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as observation_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as panel_id\r\n , cast(null as date) as observation_date\r\n , cast(null as {{ dbt.type_string() }} ) as observation_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , cast(null as {{ dbt.type_string() }} ) as source_units\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_units\r\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_low\r\n , cast(null as {{ dbt.type_string() }} ) as source_reference_range_high\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_low\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_reference_range_high\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\observation.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as observation_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as panel_id\n , cast(null as date) as observation_date\n , cast(null as TEXT ) as observation_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as result\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.patient": {"database": "tuva", "schema": "input_layer", "name": "patient", "resource_type": "model", "package_name": "input_layer", "path": "patient.sql", "original_file_path": "models\\patient.sql", "unique_id": "model.input_layer.patient", "fqn": ["input_layer", "patient"], "alias": "patient", "checksum": {"name": "sha256", "checksum": "cbefd07f63c702d654570131db84de9829b24f0a6889922f62f451f812c86674"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The patient table contains demographic and geographic information on patients.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each person across all datasets.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "The first name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "The last name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "The death date of the patient if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "A flag indicating if the patient has died.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "Patient's social security number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The address of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city where the patient lives.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state where the patient lives.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "county": {"name": "county", "description": "The county for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9794977, "relation_name": "tuva.input_layer.patient", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as first_name\r\n , cast(null as {{ dbt.type_string() }} ) as last_name\r\n , cast(null as {{ dbt.type_string() }} ) as sex\r\n , cast(null as {{ dbt.type_string() }} ) as race\r\n , cast(null as date) as birth_date\r\n , cast(null as date) as death_date\r\n , cast(null as {{ dbt.type_int() }} ) as death_flag\r\n , cast(null as {{ dbt.type_string() }} ) as social_security_number\r\n , cast(null as {{ dbt.type_string() }} ) as address\r\n , cast(null as {{ dbt.type_string() }} ) as city\r\n , cast(null as {{ dbt.type_string() }} ) as state\r\n , cast(null as {{ dbt.type_string() }} ) as zip_code\r\n , cast(null as {{ dbt.type_string() }} ) as county\r\n , cast(null as {{ dbt.type_float() }} ) as latitude\r\n , cast(null as {{ dbt.type_float() }} ) as longitude\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_int", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\patient.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as sex\n , cast(null as TEXT ) as race\n , cast(null as date) as birth_date\n , cast(null as date) as death_date\n , cast(null as integer ) as death_flag\n , cast(null as TEXT ) as social_security_number\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as TEXT ) as county\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.pharmacy_claim": {"database": "tuva", "schema": "input_layer", "name": "pharmacy_claim", "resource_type": "model", "package_name": "input_layer", "path": "pharmacy_claim.sql", "original_file_path": "models\\pharmacy_claim.sql", "unique_id": "model.input_layer.pharmacy_claim", "fqn": ["input_layer", "pharmacy_claim"], "alias": "pharmacy_claim", "checksum": {"name": "sha256", "checksum": "a8224cc265d536dc58d2b5cb1c0306d118cd31500e2ed91cb16a1a02df42f0e2"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The pharmacy_claim table includes information about retail and specialty drug prescriptions that have been filled by a patient, billed by a pharmacy, and paid by an insurer.\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_npi": {"name": "prescribing_provider_npi", "description": "NPI for the provider that wrote the prescription (e.g. priamry care physician).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_npi": {"name": "dispensing_provider_npi", "description": "NPI for the provider that dispensed the prescription (e.g. pharmacy).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "Number of doses.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days supply.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the prescription.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "Date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid by the health insurer for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "Contractual amount allowed to be paid by the payer + patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the claim by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file from the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9470026, "relation_name": "tuva.input_layer.pharmacy_claim", "raw_code": "select\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , member_id\r\n , payer\r\n , plan\r\n , prescribing_provider_npi\r\n , dispensing_provider_npi\r\n , dispensing_date\r\n , ndc_code\r\n , quantity\r\n , days_supply\r\n , refills\r\n , paid_date\r\n , paid_amount\r\n , allowed_amount\r\n , charge_amount\r\n , coinsurance_amount\r\n , copayment_amount\r\n , deductible_amount\r\n , in_network_flag\r\n , data_source\r\n , file_name\r\n , ingest_datetime\r\nfrom {{ ref('pharmacy_claim_seed') }}", "language": "sql", "refs": [{"name": "pharmacy_claim_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.pharmacy_claim_seed"]}, "compiled_path": "target\\compiled\\input_layer\\models\\pharmacy_claim.sql", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom dev_thuxuan._tuva_synthetic.pharmacy_claim_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.practitioner": {"database": "tuva", "schema": "input_layer", "name": "practitioner", "resource_type": "model", "package_name": "input_layer", "path": "practitioner.sql", "original_file_path": "models\\practitioner.sql", "unique_id": "model.input_layer.practitioner", "fqn": ["input_layer", "practitioner"], "alias": "practitioner", "checksum": {"name": "sha256", "checksum": "c74a045ae7b92c1b4783f37237acda2051d3b1a6d5d0d256158ff38fa2ebbe64"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The practitioner table contains information on the providers in the dataset e.g. physicians, physicians assistants, etc.\n", "columns": {"practitioner_id": {"name": "practitioner_id", "description": "Unique ID for the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "NPI for the provider.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "First name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Last name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_affiliation": {"name": "practice_affiliation", "description": "Practice affiliation of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty": {"name": "specialty", "description": "Specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sub_specialty": {"name": "sub_specialty", "description": "Sub specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.981498, "relation_name": "tuva.input_layer.practitioner", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(null as {{ dbt.type_string() }} ) as npi\r\n , cast(null as {{ dbt.type_string() }} ) as first_name\r\n , cast(null as {{ dbt.type_string() }} ) as last_name\r\n , cast(null as {{ dbt.type_string() }} ) as practice_affiliation\r\n , cast(null as {{ dbt.type_string() }} ) as specialty\r\n , cast(null as {{ dbt.type_string() }} ) as sub_specialty\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\practitioner.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as practice_affiliation\n , cast(null as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.procedure": {"database": "tuva", "schema": "input_layer", "name": "procedure", "resource_type": "model", "package_name": "input_layer", "path": "procedure.sql", "original_file_path": "models\\procedure.sql", "unique_id": "model.input_layer.procedure", "fqn": ["input_layer", "procedure"], "alias": "procedure", "checksum": {"name": "sha256", "checksum": "e104cb6031505c8aeda62cba2a3cedebf0c63746c63be091fccb5bc3f72c970c"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The procedure table contains information on procedures that were performed on patients in the dataset.\n", "columns": {"procedure_id": {"name": "procedure_id", "description": "The unique identifier for the performed procedure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each person across all datasets.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "The encounter_id for the encounter where this procedure was performed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "The claim on which the procedure was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date": {"name": "procedure_date", "description": "Date when the procedure was performed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "Type of procedure code for the procedure in the source system.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The procedure code in the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the procedure code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "Normalized type of procedure code for the procedure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Description of the procedure code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_1": {"name": "modifier_1", "description": "First modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_2": {"name": "modifier_2", "description": "Second modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_3": {"name": "modifier_3", "description": "Third modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_4": {"name": "modifier_4", "description": "Fourth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_5": {"name": "modifier_5", "description": "Fifth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "ID of the provider who performed the procedure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "file_name": {"name": "file_name", "description": "The file name of the source file", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingest_datetime": {"name": "ingest_datetime", "description": "The date and time the source file/data was ingested into the data warehouse or landed in cloud storage", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9854977, "relation_name": "tuva.input_layer.procedure", "raw_code": "select\r\n cast(null as {{ dbt.type_string() }} ) as procedure_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as claim_id\r\n , cast(null as date) as procedure_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(null as {{ dbt.type_string() }} ) as modifier_1\r\n , cast(null as {{ dbt.type_string() }} ) as modifier_2\r\n , cast(null as {{ dbt.type_string() }} ) as modifier_3\r\n , cast(null as {{ dbt.type_string() }} ) as modifier_4\r\n , cast(null as {{ dbt.type_string() }} ) as modifier_5\r\n , cast(null as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n , cast(null as {{ dbt.type_string() }} ) as file_name\r\n , cast(null as {{ dbt.type_timestamp() }} ) as ingest_datetime\r\nlimit 0", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": []}, "compiled_path": "target\\compiled\\input_layer\\models\\procedure.sql", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as procedure_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as procedure_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as modifier_1\n , cast(null as TEXT ) as modifier_2\n , cast(null as TEXT ) as modifier_3\n , cast(null as TEXT ) as modifier_4\n , cast(null as TEXT ) as modifier_5\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.input_layer.provider_attribution": {"database": "tuva", "schema": "input_layer", "name": "provider_attribution", "resource_type": "model", "package_name": "input_layer", "path": "provider_attribution.sql", "original_file_path": "models\\provider_attribution.sql", "unique_id": "model.input_layer.provider_attribution", "fqn": ["input_layer", "provider_attribution"], "alias": "provider_attribution", "checksum": {"name": "sha256", "checksum": "79484d90e04790f9ad5671334db4cfcde7cc181268efb800b54243d3c4f7754a"}, "config": {"enabled": true, "alias": null, "schema": "input_layer", "database": "tuva", "tags": ["input_layer"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#A91A4D"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["input_layer"], "description": "The provider_attribution table assigns a provider to each patient-member_month of eligibility. The user may assign both a payer attributed provider (as typically assigned by the payer in VBC contracts) as well as custom attributed provider (typically determined by the user). Fields related to each attributed provider (practice, organization, line of business)are also present.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset as a 6 character string (yyyymm, e.g. 202401).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider": {"name": "payer_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the payer.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "description": "Name of the practice for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "description": "Name of the organization for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "description": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider": {"name": "custom_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "description": "Name of the practice for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "description": "Name of the organization for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "description": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#A91A4D"}, "patch_path": "input_layer://models\\_models.yml", "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#A91A4D"}, "database": "tuva", "schema": "input_layer", "tags": "input_layer", "materialized": "table"}, "created_at": 1729866314.9500115, "relation_name": "tuva.input_layer.provider_attribution", "raw_code": "select\r\n patient_id\r\n , year_month\r\n , payer\r\n , plan\r\n , data_source\r\n , payer_attributed_provider\r\n , payer_attributed_provider_practice\r\n , payer_attributed_provider_organization\r\n , payer_attributed_provider_lob\r\n , custom_attributed_provider\r\n , custom_attributed_provider_practice\r\n , custom_attributed_provider_organization\r\n , custom_attributed_provider_lob\r\nfrom {{ ref('provider_attribution_seed') }}", "language": "sql", "refs": [{"name": "provider_attribution_seed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.input_layer.provider_attribution_seed"]}, "compiled_path": "target\\compiled\\input_layer\\models\\provider_attribution.sql", "compiled": true, "compiled_code": "select\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , payer_attributed_provider\n , payer_attributed_provider_practice\n , payer_attributed_provider_organization\n , payer_attributed_provider_lob\n , custom_attributed_provider\n , custom_attributed_provider_practice\n , custom_attributed_provider_organization\n , custom_attributed_provider_lob\nfrom dev_thuxuan._tuva_synthetic.provider_attribution_seed", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "seed.input_layer.eligibility_seed": {"database": "dev_thuxuan", "schema": "_tuva_synthetic", "name": "eligibility_seed", "resource_type": "seed", "package_name": "input_layer", "path": "eligibility_seed.csv", "original_file_path": "../seeds\\eligibility_seed.csv", "unique_id": "seed.input_layer.eligibility_seed", "fqn": ["input_layer", "eligibility_seed"], "alias": "eligibility_seed", "checksum": {"name": "sha256", "checksum": "6ed27e28eb51135fe699e911c94b3c014822bd68036fd2b0b039a36f22a569af"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"patient_id": "varchar(255)", "member_id": "varchar(255)", "subscriber_id": "varchar(255)", "gender": "varchar(255)", "race": "varchar(255)", "birth_date": "date", "death_date": "date", "death_flag": "integer", "enrollment_start_date": "date", "enrollment_end_date": "date", "payer": "varchar(255)", "payer_type": "varchar(255)", "plan": "varchar(255)", "original_reason_entitlement_code": "varchar(255)", "dual_status_code": "varchar(255)", "medicare_status_code": "varchar(255)", "first_name": "varchar(255)", "last_name": "varchar(255)", "social_security_number": "varchar(255)", "subscriber_relation": "varchar(255)", "address": "varchar(255)", "city": "varchar(255)", "state": "varchar(255)", "zip_code": "varchar(255)", "phone": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds\\_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"patient_id": "varchar(255)", "member_id": "varchar(255)", "subscriber_id": "varchar(255)", "gender": "varchar(255)", "race": "varchar(255)", "birth_date": "date", "death_date": "date", "death_flag": "integer", "enrollment_start_date": "date", "enrollment_end_date": "date", "payer": "varchar(255)", "payer_type": "varchar(255)", "plan": "varchar(255)", "original_reason_entitlement_code": "varchar(255)", "dual_status_code": "varchar(255)", "medicare_status_code": "varchar(255)", "first_name": "varchar(255)", "last_name": "varchar(255)", "social_security_number": "varchar(255)", "subscriber_relation": "varchar(255)", "address": "varchar(255)", "city": "varchar(255)", "state": "varchar(255)", "zip_code": "varchar(255)", "phone": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729866314.7244782, "relation_name": "dev_thuxuan._tuva_synthetic.eligibility_seed", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.lab_result_seed": {"database": "dev_thuxuan", "schema": "_tuva_synthetic", "name": "lab_result_seed", "resource_type": "seed", "package_name": "input_layer", "path": "lab_result_seed.csv", "original_file_path": "../seeds\\lab_result_seed.csv", "unique_id": "seed.input_layer.lab_result_seed", "fqn": ["input_layer", "lab_result_seed"], "alias": "lab_result_seed", "checksum": {"name": "sha256", "checksum": "f4a5befc9f192ba40d00a04f01e3782a99032b555f548fa130650f5b4c528d45"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"lab_result_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "accession_number": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "source_component": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "normalized_component": "varchar(255)", "status": "varchar(255)", "result": "varchar(255)", "result_date": "date", "collection_date": "date", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "source_abnormal_flag": "integer", "normalized_abnormal_flag": "integer", "specimen": "varchar(255)", "ordering_practitioner_id": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime", "tuva_last_run": "varchar(255)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds\\_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"lab_result_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "accession_number": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "source_component": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "normalized_component": "varchar(255)", "status": "varchar(255)", "result": "varchar(255)", "result_date": "date", "collection_date": "date", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "source_abnormal_flag": "integer", "normalized_abnormal_flag": "integer", "specimen": "varchar(255)", "ordering_practitioner_id": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime", "tuva_last_run": "varchar(255)"}}, "created_at": 1729866314.7434645, "relation_name": "dev_thuxuan._tuva_synthetic.lab_result_seed", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.medical_claim_seed": {"database": "dev_thuxuan", "schema": "_tuva_synthetic", "name": "medical_claim_seed", "resource_type": "seed", "package_name": "input_layer", "path": "medical_claim_seed.csv", "original_file_path": "../seeds\\medical_claim_seed.csv", "unique_id": "seed.input_layer.medical_claim_seed", "fqn": ["input_layer", "medical_claim_seed"], "alias": "medical_claim_seed", "checksum": {"name": "sha256", "checksum": "5327a9e9aec0c0d566781bce1dd560e4d58ee279e433b135aef1643011eba304"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "claim_type": "varchar(255)", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "claim_start_date": "date", "claim_end_date": "date", "claim_line_start_date": "date", "claim_line_end_date": "date", "admission_date": "date", "discharge_date": "date", "admit_source_code": "varchar(255)", "admit_type_code": "varchar(255)", "discharge_disposition_code": "varchar(255)", "place_of_service_code": "varchar(255)", "bill_type_code": "varchar(255)", "ms_drg_code": "varchar(255)", "apr_drg_code": "varchar(255)", "revenue_center_code": "varchar(255)", "service_unit_quantity": "integer", "hcpcs_code": "varchar(255)", "hcpcs_modifier_1": "varchar(255)", "hcpcs_modifier_2": "varchar(255)", "hcpcs_modifier_3": "varchar(255)", "hcpcs_modifier_4": "varchar(255)", "hcpcs_modifier_5": "varchar(255)", "rendering_npi": "varchar(255)", "billing_npi": "varchar(255)", "facility_npi": "varchar(255)", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "coinsurance_amount": "float", "copayment_amount": "float", "deductible_amount": "float", "total_cost_amount": "float", "diagnosis_code_type": "varchar(255)", "diagnosis_code_1": "varchar(255)", "diagnosis_code_2": "varchar(255)", "diagnosis_code_3": "varchar(255)", "diagnosis_code_4": "varchar(255)", "diagnosis_code_5": "varchar(255)", "diagnosis_code_6": "varchar(255)", "diagnosis_code_7": "varchar(255)", "diagnosis_code_8": "varchar(255)", "diagnosis_code_9": "varchar(255)", "diagnosis_code_10": "varchar(255)", "diagnosis_code_11": "varchar(255)", "diagnosis_code_12": "varchar(255)", "diagnosis_code_13": "varchar(255)", "diagnosis_code_14": "varchar(255)", "diagnosis_code_15": "varchar(255)", "diagnosis_code_16": "varchar(255)", "diagnosis_code_17": "varchar(255)", "diagnosis_code_18": "varchar(255)", "diagnosis_code_19": "varchar(255)", "diagnosis_code_20": "varchar(255)", "diagnosis_code_21": "varchar(255)", "diagnosis_code_22": "varchar(255)", "diagnosis_code_23": "varchar(255)", "diagnosis_code_24": "varchar(255)", "diagnosis_code_25": "varchar(255)", "diagnosis_poa_1": "varchar(255)", "diagnosis_poa_2": "varchar(255)", "diagnosis_poa_3": "varchar(255)", "diagnosis_poa_4": "varchar(255)", "diagnosis_poa_5": "varchar(255)", "diagnosis_poa_6": "varchar(255)", "diagnosis_poa_7": "varchar(255)", "diagnosis_poa_8": "varchar(255)", "diagnosis_poa_9": "varchar(255)", "diagnosis_poa_10": "varchar(255)", "diagnosis_poa_11": "varchar(255)", "diagnosis_poa_12": "varchar(255)", "diagnosis_poa_13": "varchar(255)", "diagnosis_poa_14": "varchar(255)", "diagnosis_poa_15": "varchar(255)", "diagnosis_poa_16": "varchar(255)", "diagnosis_poa_17": "varchar(255)", "diagnosis_poa_18": "varchar(255)", "diagnosis_poa_19": "varchar(255)", "diagnosis_poa_20": "varchar(255)", "diagnosis_poa_21": "varchar(255)", "diagnosis_poa_22": "varchar(255)", "diagnosis_poa_23": "varchar(255)", "diagnosis_poa_24": "varchar(255)", "diagnosis_poa_25": "varchar(255)", "procedure_code_type": "varchar(255)", "procedure_code_1": "varchar(255)", "procedure_code_2": "varchar(255)", "procedure_code_3": "varchar(255)", "procedure_code_4": "varchar(255)", "procedure_code_5": "varchar(255)", "procedure_code_6": "varchar(255)", "procedure_code_7": "varchar(255)", "procedure_code_8": "varchar(255)", "procedure_code_9": "varchar(255)", "procedure_code_10": "varchar(255)", "procedure_code_11": "varchar(255)", "procedure_code_12": "varchar(255)", "procedure_code_13": "varchar(255)", "procedure_code_14": "varchar(255)", "procedure_code_15": "varchar(255)", "procedure_code_16": "varchar(255)", "procedure_code_17": "varchar(255)", "procedure_code_18": "varchar(255)", "procedure_code_19": "varchar(255)", "procedure_code_20": "varchar(255)", "procedure_code_21": "varchar(255)", "procedure_code_22": "varchar(255)", "procedure_code_23": "varchar(255)", "procedure_code_24": "varchar(255)", "procedure_code_25": "varchar(255)", "procedure_date_1": "date", "procedure_date_2": "date", "procedure_date_3": "date", "procedure_date_4": "date", "procedure_date_5": "date", "procedure_date_6": "date", "procedure_date_7": "date", "procedure_date_8": "date", "procedure_date_9": "date", "procedure_date_10": "date", "procedure_date_11": "date", "procedure_date_12": "date", "procedure_date_13": "date", "procedure_date_14": "date", "procedure_date_15": "date", "procedure_date_16": "date", "procedure_date_17": "date", "procedure_date_18": "date", "procedure_date_19": "date", "procedure_date_20": "date", "procedure_date_21": "date", "procedure_date_22": "date", "procedure_date_23": "date", "procedure_date_24": "date", "procedure_date_25": "date", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds\\_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "claim_type": "varchar(255)", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "claim_start_date": "date", "claim_end_date": "date", "claim_line_start_date": "date", "claim_line_end_date": "date", "admission_date": "date", "discharge_date": "date", "admit_source_code": "varchar(255)", "admit_type_code": "varchar(255)", "discharge_disposition_code": "varchar(255)", "place_of_service_code": "varchar(255)", "bill_type_code": "varchar(255)", "ms_drg_code": "varchar(255)", "apr_drg_code": "varchar(255)", "revenue_center_code": "varchar(255)", "service_unit_quantity": "integer", "hcpcs_code": "varchar(255)", "hcpcs_modifier_1": "varchar(255)", "hcpcs_modifier_2": "varchar(255)", "hcpcs_modifier_3": "varchar(255)", "hcpcs_modifier_4": "varchar(255)", "hcpcs_modifier_5": "varchar(255)", "rendering_npi": "varchar(255)", "billing_npi": "varchar(255)", "facility_npi": "varchar(255)", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "coinsurance_amount": "float", "copayment_amount": "float", "deductible_amount": "float", "total_cost_amount": "float", "diagnosis_code_type": "varchar(255)", "diagnosis_code_1": "varchar(255)", "diagnosis_code_2": "varchar(255)", "diagnosis_code_3": "varchar(255)", "diagnosis_code_4": "varchar(255)", "diagnosis_code_5": "varchar(255)", "diagnosis_code_6": "varchar(255)", "diagnosis_code_7": "varchar(255)", "diagnosis_code_8": "varchar(255)", "diagnosis_code_9": "varchar(255)", "diagnosis_code_10": "varchar(255)", "diagnosis_code_11": "varchar(255)", "diagnosis_code_12": "varchar(255)", "diagnosis_code_13": "varchar(255)", "diagnosis_code_14": "varchar(255)", "diagnosis_code_15": "varchar(255)", "diagnosis_code_16": "varchar(255)", "diagnosis_code_17": "varchar(255)", "diagnosis_code_18": "varchar(255)", "diagnosis_code_19": "varchar(255)", "diagnosis_code_20": "varchar(255)", "diagnosis_code_21": "varchar(255)", "diagnosis_code_22": "varchar(255)", "diagnosis_code_23": "varchar(255)", "diagnosis_code_24": "varchar(255)", "diagnosis_code_25": "varchar(255)", "diagnosis_poa_1": "varchar(255)", "diagnosis_poa_2": "varchar(255)", "diagnosis_poa_3": "varchar(255)", "diagnosis_poa_4": "varchar(255)", "diagnosis_poa_5": "varchar(255)", "diagnosis_poa_6": "varchar(255)", "diagnosis_poa_7": "varchar(255)", "diagnosis_poa_8": "varchar(255)", "diagnosis_poa_9": "varchar(255)", "diagnosis_poa_10": "varchar(255)", "diagnosis_poa_11": "varchar(255)", "diagnosis_poa_12": "varchar(255)", "diagnosis_poa_13": "varchar(255)", "diagnosis_poa_14": "varchar(255)", "diagnosis_poa_15": "varchar(255)", "diagnosis_poa_16": "varchar(255)", "diagnosis_poa_17": "varchar(255)", "diagnosis_poa_18": "varchar(255)", "diagnosis_poa_19": "varchar(255)", "diagnosis_poa_20": "varchar(255)", "diagnosis_poa_21": "varchar(255)", "diagnosis_poa_22": "varchar(255)", "diagnosis_poa_23": "varchar(255)", "diagnosis_poa_24": "varchar(255)", "diagnosis_poa_25": "varchar(255)", "procedure_code_type": "varchar(255)", "procedure_code_1": "varchar(255)", "procedure_code_2": "varchar(255)", "procedure_code_3": "varchar(255)", "procedure_code_4": "varchar(255)", "procedure_code_5": "varchar(255)", "procedure_code_6": "varchar(255)", "procedure_code_7": "varchar(255)", "procedure_code_8": "varchar(255)", "procedure_code_9": "varchar(255)", "procedure_code_10": "varchar(255)", "procedure_code_11": "varchar(255)", "procedure_code_12": "varchar(255)", "procedure_code_13": "varchar(255)", "procedure_code_14": "varchar(255)", "procedure_code_15": "varchar(255)", "procedure_code_16": "varchar(255)", "procedure_code_17": "varchar(255)", "procedure_code_18": "varchar(255)", "procedure_code_19": "varchar(255)", "procedure_code_20": "varchar(255)", "procedure_code_21": "varchar(255)", "procedure_code_22": "varchar(255)", "procedure_code_23": "varchar(255)", "procedure_code_24": "varchar(255)", "procedure_code_25": "varchar(255)", "procedure_date_1": "date", "procedure_date_2": "date", "procedure_date_3": "date", "procedure_date_4": "date", "procedure_date_5": "date", "procedure_date_6": "date", "procedure_date_7": "date", "procedure_date_8": "date", "procedure_date_9": "date", "procedure_date_10": "date", "procedure_date_11": "date", "procedure_date_12": "date", "procedure_date_13": "date", "procedure_date_14": "date", "procedure_date_15": "date", "procedure_date_16": "date", "procedure_date_17": "date", "procedure_date_18": "date", "procedure_date_19": "date", "procedure_date_20": "date", "procedure_date_21": "date", "procedure_date_22": "date", "procedure_date_23": "date", "procedure_date_24": "date", "procedure_date_25": "date", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729866314.8040519, "relation_name": "dev_thuxuan._tuva_synthetic.medical_claim_seed", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.observation_seed": {"database": "dev_thuxuan", "schema": "_tuva_synthetic", "name": "observation_seed", "resource_type": "seed", "package_name": "input_layer", "path": "observation_seed.csv", "original_file_path": "../seeds\\observation_seed.csv", "unique_id": "seed.input_layer.observation_seed", "fqn": ["input_layer", "observation_seed"], "alias": "observation_seed", "checksum": {"name": "sha256", "checksum": "1bf517a342bbe7bcda0a7bec43280155281bbf2e78f605663d0d6a2db730329b"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"observation_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "panel_id": "varchar(255)", "observation_date": "date", "observation_type": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "result": "varchar(255)", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds\\_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"observation_id": "varchar(255)", "patient_id": "varchar(255)", "encounter_id": "varchar(255)", "panel_id": "varchar(255)", "observation_date": "date", "observation_type": "varchar(255)", "source_code_type": "varchar(255)", "source_code": "varchar(255)", "source_description": "varchar(255)", "normalized_code_type": "varchar(255)", "normalized_code": "varchar(255)", "normalized_description": "varchar(255)", "result": "varchar(255)", "source_units": "varchar(255)", "normalized_units": "varchar(255)", "source_reference_range_low": "varchar(255)", "source_reference_range_high": "varchar(255)", "normalized_reference_range_low": "varchar(255)", "normalized_reference_range_high": "varchar(255)", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729866314.8190517, "relation_name": "dev_thuxuan._tuva_synthetic.observation_seed", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.pharmacy_claim_seed": {"database": "dev_thuxuan", "schema": "_tuva_synthetic", "name": "pharmacy_claim_seed", "resource_type": "seed", "package_name": "input_layer", "path": "pharmacy_claim_seed.csv", "original_file_path": "../seeds\\pharmacy_claim_seed.csv", "unique_id": "seed.input_layer.pharmacy_claim_seed", "fqn": ["input_layer", "pharmacy_claim_seed"], "alias": "pharmacy_claim_seed", "checksum": {"name": "sha256", "checksum": "f45fdfb7b829bb0f73635eddee09d49957d71b16d897a41d9e9ecb0e32e0b0d3"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "prescribing_provider_npi": "varchar(255)", "dispensing_provider_npi": "varchar(255)", "dispensing_date": "date", "ndc_code": "varchar(255)", "quantity": "integer", "days_supply": "integer", "refills": "integer", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds\\_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"claim_id": "varchar(255)", "claim_line_number": "integer", "patient_id": "varchar(255)", "member_id": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "prescribing_provider_npi": "varchar(255)", "dispensing_provider_npi": "varchar(255)", "dispensing_date": "date", "ndc_code": "varchar(255)", "quantity": "integer", "days_supply": "integer", "refills": "integer", "paid_date": "date", "paid_amount": "float", "allowed_amount": "float", "charge_amount": "float", "in_network_flag": "integer", "data_source": "varchar(255)", "file_name": "varchar(255)", "ingest_datetime": "datetime"}}, "created_at": 1729866314.8270526, "relation_name": "dev_thuxuan._tuva_synthetic.pharmacy_claim_seed", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "depends_on": {"macros": []}}, "seed.input_layer.provider_attribution_seed": {"database": "dev_thuxuan", "schema": "_tuva_synthetic", "name": "provider_attribution_seed", "resource_type": "seed", "package_name": "input_layer", "path": "provider_attribution_seed.csv", "original_file_path": "../seeds\\provider_attribution_seed.csv", "unique_id": "seed.input_layer.provider_attribution_seed", "fqn": ["input_layer", "provider_attribution_seed"], "alias": "provider_attribution_seed", "checksum": {"name": "sha256", "checksum": "9dd1af98dc7f19433c964a593f106ce03a9d54f926963c980241532ef8ff89ec"}, "config": {"enabled": true, "alias": null, "schema": "_tuva_synthetic", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"patient_id": "varchar(255)", "year_month": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "data_source": "varchar(255)", "payer_attributed_provider": "varchar(255)", "payer_attributed_provider_practice": "varchar(255)", "payer_attributed_provider_organization": "varchar(255)", "payer_attributed_provider_lob": "varchar(255)", "custom_attributed_provider": "varchar(255)", "custom_attributed_provider_practice": "varchar(255)", "custom_attributed_provider_organization": "varchar(255)", "custom_attributed_provider_lob": "varchar(255)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "input_layer://../seeds\\_seeds.yml", "build_path": null, "unrendered_config": {"schema": "_tuva_synthetic", "enabled": true, "column_types": {"patient_id": "varchar(255)", "year_month": "varchar(255)", "payer": "varchar(255)", "plan": "varchar(255)", "data_source": "varchar(255)", "payer_attributed_provider": "varchar(255)", "payer_attributed_provider_practice": "varchar(255)", "payer_attributed_provider_organization": "varchar(255)", "payer_attributed_provider_lob": "varchar(255)", "custom_attributed_provider": "varchar(255)", "custom_attributed_provider_practice": "varchar(255)", "custom_attributed_provider_organization": "varchar(255)", "custom_attributed_provider_lob": "varchar(255)"}}, "created_at": 1729866314.8370495, "relation_name": "dev_thuxuan._tuva_synthetic.provider_attribution_seed", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "depends_on": {"macros": []}}, "model.the_tuva_project.ahrq_measures__pqi_denom_long": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_denom_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\final\\ahrq_measures__pqi_denom_long.sql", "original_file_path": "models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_denom_long.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_denom_long", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_denom_long"], "alias": "pqi_denom_long", "checksum": {"name": "sha256", "checksum": "45cb512693751f1d100dc8f616b9f8c41dbb5d8890be1138969b6b46a92b2eb1"}, "config": {"enabled": true, "alias": "pqi_denom_long", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Long table that unions the denominator for all the PQI measures.\n", "columns": {"year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding denominator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_denom_long", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.9830475, "relation_name": "dev_thuxuan.ahrq_measures.pqi_denom_long", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '01' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_01_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '03' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_03_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '05' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_05_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '07' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_07_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '08' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_08_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '11' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_11_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '12' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_12_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '14' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_14_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '15' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_15_denom') }} as d\r\n\r\nunion all\r\n\r\nselect\r\n d.year_number\r\n , d.patient_id\r\n , d.data_source\r\n , '16' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_16_denom') }} as d", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_01_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_denom", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_denom_long.sql", "compiled": true, "compiled_code": "\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '01' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_01_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '03' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_03_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '05' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_05_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '07' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_07_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '08' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_08_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '11' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_11_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '12' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_12_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '14' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_14_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '15' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_15_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '16' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_16_denom as d", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_exclusion_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\final\\ahrq_measures__pqi_exclusion_long.sql", "original_file_path": "models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_exclusion_long.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_exclusion_long", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_exclusion_long"], "alias": "pqi_exclusion_long", "checksum": {"name": "sha256", "checksum": "ab9f660bf218382b4a9955cb255067ef7f4c602ce966186e7693d738429d0b8a"}, "config": {"enabled": true, "alias": "pqi_exclusion_long", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Long table that unions the exclusions for all the PQI measures.\n", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "description of the reason the encounter was excluded", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_number": {"name": "exclusion_number", "description": "for a given encounter and pqi measure, the number of exclusion it qualifies for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_exclusion_long", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.986033, "relation_name": "dev_thuxuan.ahrq_measures.pqi_exclusion_long", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 1 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_01_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 3 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_03_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 5 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_05_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 7 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_07_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 8 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_08_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 11 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_11_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 12 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_12_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 14 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_14_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 15 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_15_exclusions') }} as e\r\n\r\nunion all\r\n\r\nselect\r\n e.data_source\r\n , e.encounter_id\r\n , e.exclusion_reason\r\n , e.exclusion_number\r\n , 16 as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_16_exclusions') }} as e", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_01_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_exclusions", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_exclusion_long.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 1 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_01_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 3 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_03_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 5 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_05_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 7 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_07_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 8 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_08_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 11 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_11_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 12 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_12_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 14 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_14_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 15 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_15_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 16 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_16_exclusions as e", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_num_long": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_num_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\final\\ahrq_measures__pqi_num_long.sql", "original_file_path": "models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_num_long.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_num_long", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_num_long"], "alias": "pqi_num_long", "checksum": {"name": "sha256", "checksum": "6bc92b271252d2e40049aac52eec41e69087a860608c1802f19288abc29e1fd6"}, "config": {"enabled": true, "alias": "pqi_num_long", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Long table that unions the numerator for all the PQI measures.\n", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding numerator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_number": {"name": "exclusion_number", "description": "for a given encounter and pqi measure, the number of exclusion it qualifies for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_num_long", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.9880373, "relation_name": "dev_thuxuan.ahrq_measures.pqi_num_long", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '01' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_01_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '03' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_03_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '05' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_05_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '07' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_07_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '08' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_08_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '11' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_11_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '12' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_12_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '14' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_14_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '15' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_15_num') }} as n\r\n\r\nunion all\r\n\r\nselect\r\n n.data_source\r\n , n.patient_id\r\n , n.year_number\r\n , n.encounter_id\r\n , '16' as pqi_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_16_num') }} as n", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_01_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_num", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_num", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_num_long.sql", "compiled": true, "compiled_code": "\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '01' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_01_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '03' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_03_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '05' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_05_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '07' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_07_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '08' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_08_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '11' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_11_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '12' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_12_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '14' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_14_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '15' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_15_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '16' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_16_num as n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_rate": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_rate", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\final\\ahrq_measures__pqi_rate.sql", "original_file_path": "models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_rate.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_rate", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_rate"], "alias": "pqi_rate", "checksum": {"name": "sha256", "checksum": "fc3d6d78b04e9c8f057c93eb877d507f0e9d7d9ad253d0aecd5697a374ed5fae"}, "config": {"enabled": true, "alias": "pqi_rate", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Table that combines numerator and denominator and calculates a rate per 100k\n", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding numerator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denom_count": {"name": "denom_count", "description": "the count of patients that qualified for the denominator of the corresponding year and pqi number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "num_count": {"name": "num_count", "description": "the count of patients that qualified for the numerator of the corresponding year and pqi number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rate_per_100_thousand": {"name": "rate_per_100_thousand", "description": "the calculated rate per 100 thousand (numerator divided by denominator, multiplied by 100000)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_rate", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.991132, "relation_name": "dev_thuxuan.ahrq_measures.pqi_rate", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith num as (\r\n select\r\n data_source\r\n , year_number\r\n , pqi_number\r\n , count(encounter_id) as num_count\r\n from {{ ref('ahrq_measures__pqi_num_long') }}\r\n group by\r\n data_source\r\n , year_number\r\n , pqi_number\r\n)\r\n\r\n, denom as (\r\n select\r\n data_source\r\n , year_number\r\n , pqi_number\r\n , count(patient_id) as denom_count\r\n from {{ ref('ahrq_measures__pqi_denom_long') }} as d\r\n group by\r\n data_source\r\n , year_number\r\n , pqi_number\r\n)\r\n\r\nselect\r\n d.data_source\r\n , d.year_number\r\n , d.pqi_number\r\n , d.denom_count\r\n , coalesce(num.num_count, 0) as num_count\r\n , coalesce(num.num_count, 0) / d.denom_count * 100000 as rate_per_100_thousand\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom denom as d\r\nleft join num\r\n on d.pqi_number = num.pqi_number\r\n and d.year_number = num.year_number\r\n and d.data_source = num.data_source", "language": "sql", "refs": [{"name": "ahrq_measures__pqi_num_long", "package": null, "version": null}, {"name": "ahrq_measures__pqi_denom_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__pqi_num_long", "model.the_tuva_project.ahrq_measures__pqi_denom_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_rate.sql", "compiled": true, "compiled_code": "\n\nwith num as (\n select\n data_source\n , year_number\n , pqi_number\n , count(encounter_id) as num_count\n from dev_thuxuan.ahrq_measures.pqi_num_long\n group by\n data_source\n , year_number\n , pqi_number\n)\n\n, denom as (\n select\n data_source\n , year_number\n , pqi_number\n , count(patient_id) as denom_count\n from dev_thuxuan.ahrq_measures.pqi_denom_long as d\n group by\n data_source\n , year_number\n , pqi_number\n)\n\nselect\n d.data_source\n , d.year_number\n , d.pqi_number\n , d.denom_count\n , coalesce(num.num_count, 0) as num_count\n , coalesce(num.num_count, 0) / d.denom_count * 100000 as rate_per_100_thousand\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom denom as d\nleft join num\n on d.pqi_number = num.pqi_number\n and d.year_number = num.year_number\n and d.data_source = num.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__pqi_summary": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__pqi_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\final\\ahrq_measures__pqi_summary.sql", "original_file_path": "models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_summary.sql", "unique_id": "model.the_tuva_project.ahrq_measures__pqi_summary", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "final", "ahrq_measures__pqi_summary"], "alias": "pqi_summary", "checksum": {"name": "sha256", "checksum": "8eddfbf9b9ec85b06d7686efe802d617aaedea16c3799dba11dd0ac6a57bb4bd"}, "config": {"enabled": true, "alias": "pqi_summary", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Summary table for pqi numerators that bring in encounter details for analytics reporting.\n", "columns": {"pqi_number": {"name": "pqi_number", "description": "the number of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_name": {"name": "pqi_name", "description": "the name of the pqi measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_number": {"name": "year_number", "description": "the year the patient qualified for the corresponding numerator", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the encounter (typically represents the facility where services were performed). \n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid for the encounter by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "pqi_summary", "tags": ["ahrq_measures", "pqi"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.994043, "relation_name": "dev_thuxuan.ahrq_measures.pqi_summary", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect p.pqi_number\r\n , m.pqi_name\r\n , e.year_number\r\n , e.encounter_id\r\n , e.data_source\r\n , e.patient_id\r\n , e.facility_id\r\n , e.ms_drg_code\r\n , e.ms_drg_description\r\n , e.encounter_start_date\r\n , e.encounter_end_date\r\n , e.length_of_stay\r\n , e.paid_amount\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ref('ahrq_measures__pqi_num_long')}} p \r\ninner join {{ref('ahrq_measures__stg_pqi_inpatient_encounter')}} e\r\n on p.encounter_id = e.encounter_id\r\n and p.data_source = e.data_source\r\ninner join {{ ref('pqi__measures') }} m on cast(p.pqi_number as {{ dbt.type_string() }}) = m.pqi_number", "language": "sql", "refs": [{"name": "ahrq_measures__pqi_num_long", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.ahrq_measures__pqi_num_long", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\final\\ahrq_measures__pqi_summary.sql", "compiled": true, "compiled_code": "\n\nselect p.pqi_number\n , m.pqi_name\n , e.year_number\n , e.encounter_id\n , e.data_source\n , e.patient_id\n , e.facility_id\n , e.ms_drg_code\n , e.ms_drg_description\n , e.encounter_start_date\n , e.encounter_end_date\n , e.length_of_stay\n , e.paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures.pqi_num_long p \ninner join dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter e\n on p.encounter_id = e.encounter_id\n and p.data_source = e.data_source\ninner join dev_thuxuan.ahrq_measures._value_set_pqi_measures m on cast(p.pqi_number as TEXT) = m.pqi_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_01_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_01_denom"], "alias": "_int_pqi_01_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_01_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 01 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_01_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.9971416, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_01_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_01_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_01_exclusions"], "alias": "_int_pqi_01_exclusions", "checksum": {"name": "sha256", "checksum": "2aef79bc3dda7d795f1972ffb83b527871cb9dbfe804179cbf3907a8e6f21a7d"}, "config": {"enabled": true, "alias": "_int_pqi_01_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 01 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_01_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866315.9991322, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_01_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_exclusions.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_01_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_01_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_01_num"], "alias": "_int_pqi_01_num", "checksum": {"name": "sha256", "checksum": "edea590ea05c0485f60ac76a306bb3ea5864349b0885635b4da630b2cece48f0"}, "config": {"enabled": true, "alias": "_int_pqi_01_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 01 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_01_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0011284, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_01_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as pqi\r\n on e.primary_diagnosis_code = pqi.code\r\n and pqi.value_set_name = 'diabetes_with_short-term_complications_diagnosis_codes'\r\n and pqi.pqi_number = '01'\r\ninner join {{ ref('ahrq_measures__int_pqi_01_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_01_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_01_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_01_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_01_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_short-term_complications_diagnosis_codes'\n and pqi.pqi_number = '01'\ninner join dev_thuxuan.ahrq_measures._int_pqi_01_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_01_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_03_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_03_denom"], "alias": "_int_pqi_03_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_03_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 03 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_03_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0037498, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_03_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_03_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_03_exclusions"], "alias": "_int_pqi_03_exclusions", "checksum": {"name": "sha256", "checksum": "2aef79bc3dda7d795f1972ffb83b527871cb9dbfe804179cbf3907a8e6f21a7d"}, "config": {"enabled": true, "alias": "_int_pqi_03_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 03 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_03_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0058632, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_03_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_exclusions.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_03_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_03_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_03_num"], "alias": "_int_pqi_03_num", "checksum": {"name": "sha256", "checksum": "bc8f1a11dd914e33387110d57efb1cc2619b2099b08049963e6fa3b2c9adb784"}, "config": {"enabled": true, "alias": "_int_pqi_03_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 03 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_03_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0078723, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_03_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as pqi\r\n on e.primary_diagnosis_code = pqi.code\r\n and pqi.value_set_name = 'diabetes_with_long-term_complications_diagnosis_codes'\r\n and pqi.pqi_number = '03'\r\ninner join {{ ref('ahrq_measures__int_pqi_03_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_03_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_03_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_03_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_long-term_complications_diagnosis_codes'\n and pqi.pqi_number = '03'\ninner join dev_thuxuan.ahrq_measures._int_pqi_03_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_03_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_05_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_05_denom"], "alias": "_int_pqi_05_denom", "checksum": {"name": "sha256", "checksum": "60474534ac26525b550b3055fa195c39c59445464e48f77c8e6a341a044c2758"}, "config": {"enabled": true, "alias": "_int_pqi_05_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 05 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_05_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0108662, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_05_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 40", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 40", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_05_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_05_exclusions"], "alias": "_int_pqi_05_exclusions", "checksum": {"name": "sha256", "checksum": "3ce5aa842156f1eb960a64bc87ce3d3319e92bf9ad0be2a247a4e74c40688568"}, "config": {"enabled": true, "alias": "_int_pqi_05_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 05 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_05_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.014765, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_05_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith resp_an as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'cystic fibrosis' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi\r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system'\r\n and pqi_number = '05'\r\n where c.encounter_id is not null\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from resp_an\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system'\n and pqi_number = '05'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_05_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_05_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_05_num"], "alias": "_int_pqi_05_num", "checksum": {"name": "sha256", "checksum": "d7b1a0f71b56e15f5e0716ad8a15be1e5faf4696eec91e94c347dd8eea351a11"}, "config": {"enabled": true, "alias": "_int_pqi_05_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 05 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_05_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0177612, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_05_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('ahrq_measures__int_pqi_05_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('pqi__value_sets') }} as copd\r\n on e.primary_diagnosis_code = copd.code\r\n and copd.value_set_name = 'chronic_obstructive_pulmonary_disorder'\r\n and copd.pqi_number = '05'\r\nleft join {{ ref('pqi__value_sets') }} asthma\r\n on e.primary_diagnosis_code = asthma.code\r\n and asthma.value_set_name = 'asthma'\r\n and asthma.pqi_number = '05'\r\nleft join {{ ref('ahrq_measures__int_pqi_05_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null\r\n and (\r\n asthma.code is not null \r\n or copd.code is not null\r\n )", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_denom", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_05_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_05_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._int_pqi_05_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._value_set_pqi as copd\n on e.primary_diagnosis_code = copd.code\n and copd.value_set_name = 'chronic_obstructive_pulmonary_disorder'\n and copd.pqi_number = '05'\nleft join dev_thuxuan.ahrq_measures._value_set_pqi asthma\n on e.primary_diagnosis_code = asthma.code\n and asthma.value_set_name = 'asthma'\n and asthma.pqi_number = '05'\nleft join dev_thuxuan.ahrq_measures._int_pqi_05_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null\n and (\n asthma.code is not null \n or copd.code is not null\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_07_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_07_denom"], "alias": "_int_pqi_07_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_07_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 07 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_07_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0197613, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_07_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_07_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_07_exclusions"], "alias": "_int_pqi_07_exclusions", "checksum": {"name": "sha256", "checksum": "c90fc6d5ac4841ca791ef0e9f3debbd0ec2339b0211c96b04940bf9deab24d14"}, "config": {"enabled": true, "alias": "_int_pqi_07_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 07 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_07_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0227616, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_07_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith cardiac as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'cardiac procedure' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-pcs'\r\n and pqi.value_set_name = 'cardiac_procedure_codes'\r\n and pqi_number = 'appendix_b'\r\n where c.encounter_id is not null\r\n),\r\n\r\nckd as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'exclusion_kidney_disease_diagnosis_codes'\r\n and pqi_number = '07'\r\n where c.encounter_id is not null\r\n),\r\n\r\naccess as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-pcs'\r\n and pqi.value_set_name = 'exclusion_dialysis_access_procedure_codes'\r\n and pqi.pqi_number = '07'\r\n where c.encounter_id is not null\r\n),\r\n\r\ncombine as (\r\n select\r\n c.encounter_id\r\n , c.data_source\r\n , 'ckd' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join ckd \r\n on c.encounter_id = ckd.encounter_id\r\n and c.data_source = ckd.data_source\r\n inner join access as a \r\n on c.encounter_id = a.encounter_id\r\n and c.data_source = a.data_source\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n \r\n union all\r\n \r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from cardiac\r\n \r\n union all\r\n \r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from combine\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nckd as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'exclusion_kidney_disease_diagnosis_codes'\n and pqi_number = '07'\n where c.encounter_id is not null\n),\n\naccess as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'exclusion_dialysis_access_procedure_codes'\n and pqi.pqi_number = '07'\n where c.encounter_id is not null\n),\n\ncombine as (\n select\n c.encounter_id\n , c.data_source\n , 'ckd' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join ckd \n on c.encounter_id = ckd.encounter_id\n and c.data_source = ckd.data_source\n inner join access as a \n on c.encounter_id = a.encounter_id\n and c.data_source = a.data_source\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from combine\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_07_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_07_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_07_num"], "alias": "_int_pqi_07_num", "checksum": {"name": "sha256", "checksum": "6b9bb7ecd2248bc75a095d17adba7bd5abba584c4420cc26f07daf8635526bf5"}, "config": {"enabled": true, "alias": "_int_pqi_07_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 07 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_07_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0247622, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_07_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as hyp\r\n on e.primary_diagnosis_code = hyp.code\r\n and hyp.value_set_name = 'hypertension_diagnosis_codes'\r\n and hyp.pqi_number = '07'\r\ninner join {{ ref('ahrq_measures__int_pqi_07_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_07_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_07_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_07_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'hypertension_diagnosis_codes'\n and hyp.pqi_number = '07'\ninner join dev_thuxuan.ahrq_measures._int_pqi_07_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_07_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_08_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_08_denom"], "alias": "_int_pqi_08_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_08_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 08 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_08_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0267622, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_08_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_08_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_08_exclusions"], "alias": "_int_pqi_08_exclusions", "checksum": {"name": "sha256", "checksum": "54505093adf589276b04f865aa965e2d03e5b6f775ba6b18172052c7498a0945"}, "config": {"enabled": true, "alias": "_int_pqi_08_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 08 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_08_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0291703, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_08_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith cardiac as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'cardiac procedure' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-pcs'\r\n and pqi.value_set_name = 'cardiac_procedure_codes'\r\n and pqi.pqi_number = 'appendix_b'\r\n where c.encounter_id is not null\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from cardiac\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi.pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_08_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_08_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_08_num"], "alias": "_int_pqi_08_num", "checksum": {"name": "sha256", "checksum": "8979fef94e12e7d6414503740043733f908bba8e8f63549821e81b3c99fa9bb3"}, "config": {"enabled": true, "alias": "_int_pqi_08_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 08 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_08_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0311751, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_08_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as hyp\r\n on e.primary_diagnosis_code = hyp.code\r\n and hyp.value_set_name = 'heart_failure_diagnosis_codes'\r\n and hyp.pqi_number = '08'\r\ninner join {{ ref('ahrq_measures__int_pqi_08_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_08_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_08_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_08_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'heart_failure_diagnosis_codes'\n and hyp.pqi_number = '08'\ninner join dev_thuxuan.ahrq_measures._int_pqi_08_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_08_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_11_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_11_denom"], "alias": "_int_pqi_11_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_11_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 11 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_11_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0341778, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_11_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_11_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_11_exclusions"], "alias": "_int_pqi_11_exclusions", "checksum": {"name": "sha256", "checksum": "2ab9155d91756003b668e9857523633389ec9f1c887644ac5e44754de4b4170f"}, "config": {"enabled": true, "alias": "_int_pqi_11_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 11 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_11_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0361743, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_11_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith sickle_cell as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'sickle cell' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'sickle_cell_anemia_or_hb-s_disease_diagnosis_codes'\r\n and pqi.pqi_number = '11'\r\n where c.encounter_id is not null\r\n),\r\n\r\nimmune_dx as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'immunocompromised diagnosis' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\r\n and pqi.pqi_number = 'appendix_c'\r\n where c.encounter_id is not null\r\n),\r\n\r\nimmune_px as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'immunocompromised procedure' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-pcs'\r\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\r\n and pqi.pqi_number = 'appendix_c'\r\n where c.encounter_id is not null\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from sickle_cell\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from immune_dx\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from immune_px\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), sickle_cell as (\n select distinct\n encounter_id\n , data_source\n , 'sickle cell' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'sickle_cell_anemia_or_hb-s_disease_diagnosis_codes'\n and pqi.pqi_number = '11'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from sickle_cell\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_11_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_11_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_11_num"], "alias": "_int_pqi_11_num", "checksum": {"name": "sha256", "checksum": "eec43d261ea7f67e8765ea0b3b8e48a496f2649d5b2618bae0bbb62bfb04a6ce"}, "config": {"enabled": true, "alias": "_int_pqi_11_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 11 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_11_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0381773, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_11_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as hyp\r\n on e.primary_diagnosis_code = hyp.code\r\n and hyp.value_set_name = 'community_acquired_bacterial_pneumonia_diagnosis_codes'\r\n and hyp.pqi_number = '11'\r\ninner join {{ ref('ahrq_measures__int_pqi_11_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_11_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_11_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_11_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'community_acquired_bacterial_pneumonia_diagnosis_codes'\n and hyp.pqi_number = '11'\ninner join dev_thuxuan.ahrq_measures._int_pqi_11_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_11_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_12_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_12_denom"], "alias": "_int_pqi_12_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_12_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 12 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_12_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0401766, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_12_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_12_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_12_exclusions"], "alias": "_int_pqi_12_exclusions", "checksum": {"name": "sha256", "checksum": "e73691b0342900ad6c4e07258637c896f4af606be9864af5ebb883e0d0ff3fc2"}, "config": {"enabled": true, "alias": "_int_pqi_12_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 12 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_12_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0421667, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_12_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith kidney as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'kidney' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'kidney_or_urinary_tract_disorder_diagnosis_codes'\r\n and pqi.pqi_number = '12'\r\n where c.encounter_id is not null\r\n),\r\n\r\nimmune_dx as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'immunocompromised diagnosis' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\r\n and pqi.pqi_number = 'appendix_c'\r\n where c.encounter_id is not null\r\n),\r\n\r\nimmune_px as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'immunocompromised procedure' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-pcs'\r\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\r\n and pqi.pqi_number = 'appendix_c'\r\n where c.encounter_id is not null\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from kidney\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from immune_dx\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from immune_px\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), kidney as (\n select distinct\n encounter_id\n , data_source\n , 'kidney' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'kidney_or_urinary_tract_disorder_diagnosis_codes'\n and pqi.pqi_number = '12'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from kidney\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_12_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_12_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_12_num"], "alias": "_int_pqi_12_num", "checksum": {"name": "sha256", "checksum": "dbbda8780adf69f8d99e6fa7575a3512add3f7d179819428a5a5cd00687cb2b5"}, "config": {"enabled": true, "alias": "_int_pqi_12_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 12 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_12_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0440857, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_12_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as hyp\r\n on e.primary_diagnosis_code = hyp.code\r\n and hyp.value_set_name = 'urinary_tract_infection_diagnosis_codes'\r\n and hyp.pqi_number = '12'\r\ninner join {{ ref('ahrq_measures__int_pqi_12_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_12_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_12_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_12_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'urinary_tract_infection_diagnosis_codes'\n and hyp.pqi_number = '12'\ninner join dev_thuxuan.ahrq_measures._int_pqi_12_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_12_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_14_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_14_denom"], "alias": "_int_pqi_14_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_14_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 14 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_14_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0460856, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_14_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_14_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_14_exclusions"], "alias": "_int_pqi_14_exclusions", "checksum": {"name": "sha256", "checksum": "2aef79bc3dda7d795f1972ffb83b527871cb9dbfe804179cbf3907a8e6f21a7d"}, "config": {"enabled": true, "alias": "_int_pqi_14_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 14 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_14_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0490854, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_14_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}", "language": "sql", "refs": [{"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_exclusions.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_14_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_14_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_14_num"], "alias": "_int_pqi_14_num", "checksum": {"name": "sha256", "checksum": "4cf2ae23f4bcbd8f5ae88e0bdfeb13aaed84488f6c373daf1871a2ab5514b2af"}, "config": {"enabled": true, "alias": "_int_pqi_14_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 14 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_14_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0510857, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_14_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as hyp\r\n on e.primary_diagnosis_code = hyp.code\r\n and hyp.value_set_name = 'uncontrolled_diabetes_diagnosis_codes'\r\n and hyp.pqi_number = '14'\r\ninner join {{ ref('ahrq_measures__int_pqi_14_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_14_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_14_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_14_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'uncontrolled_diabetes_diagnosis_codes'\n and hyp.pqi_number = '14'\ninner join dev_thuxuan.ahrq_measures._int_pqi_14_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_14_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_15_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_15_denom"], "alias": "_int_pqi_15_denom", "checksum": {"name": "sha256", "checksum": "1426f212fad75001823f9768e0d05fc758ca31f510fa8233bfd3e58d60b2df74"}, "config": {"enabled": true, "alias": "_int_pqi_15_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 15 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_15_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0530863, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_15_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18\r\n and\r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} <= 39", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18\n and\n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) <= 39", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_15_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_15_exclusions"], "alias": "_int_pqi_15_exclusions", "checksum": {"name": "sha256", "checksum": "be9b3e7f3342b1eeff0f8e8db15ef4825bf83f991ae60c94975f73979396c479"}, "config": {"enabled": true, "alias": "_int_pqi_15_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 15 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_15_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0550861, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_15_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith resp_an as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'cystic fibrosis' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system_diagnosis_codes'\r\n and pqi.pqi_number = '15'\r\n where c.encounter_id is not null\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from resp_an\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system_diagnosis_codes'\n and pqi.pqi_number = '15'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_15_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_15_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_15_num"], "alias": "_int_pqi_15_num", "checksum": {"name": "sha256", "checksum": "87e411e374b7e462739cf63c7a2044c6086c85234cb5eb54af9db155dab6f7cc"}, "config": {"enabled": true, "alias": "_int_pqi_15_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 15 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_15_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0580878, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_15_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('pqi__value_sets') }} as hyp\r\n on e.primary_diagnosis_code = hyp.code\r\n and hyp.value_set_name = 'asthma_diagnosis_codes'\r\n and hyp.pqi_number = '15'\r\ninner join {{ ref('ahrq_measures__int_pqi_15_denom') }} as denom\r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\nleft join {{ ref('ahrq_measures__int_pqi_15_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_15_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_15_num.sql", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'asthma_diagnosis_codes'\n and hyp.pqi_number = '15'\ninner join dev_thuxuan.ahrq_measures._int_pqi_15_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_15_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_16_denom", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_denom.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_denom.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_16_denom"], "alias": "_int_pqi_16_denom", "checksum": {"name": "sha256", "checksum": "45be60d79a530cd34a40f67ed0c854e9b291ce9d310203100a396aa10551617b"}, "config": {"enabled": true, "alias": "_int_pqi_16_denom", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Denominator for PQI 16 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_16_denom", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0600886, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_16_denom", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct\r\n cast(substring(e.year_month, 1, 4) as int) AS year_number\r\n , e.patient_id\r\n , e.data_source\r\n , {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} as age\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_member_months') }} as e\r\ninner join {{ ref('ahrq_measures__stg_pqi_patient') }} as p \r\n on e.patient_id = p.patient_id\r\n and p.data_source = e.data_source\r\nwhere \r\n {{ datediff('p.birth_date', 'e.first_day_of_month', 'year') }} >= 18", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_member_months", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_denom.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_16_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_exclusions.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_exclusions.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_16_exclusions"], "alias": "_int_pqi_16_exclusions", "checksum": {"name": "sha256", "checksum": "58e40d31421f3d8dcf38f99d2b81df09ec2f79eb5802379155ccfd4781218062"}, "config": {"enabled": true, "alias": "_int_pqi_16_exclusions", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic specific to PQI 16 measure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_16_exclusions", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0620887, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_16_exclusions", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith amputation as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'amputation' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'traumatic_amputation_of_the_lower_extremity_diagnosis_codes'\r\n and pqi.pqi_number = '16'\r\n where c.encounter_id is not null\r\n),\r\n\r\npregnancy as (\r\n select distinct\r\n encounter_id\r\n , data_source\r\n , 'pregnancy' as exclusion_reason\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi \r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'mdc_14_principal_diagnosis_codes'\r\n and pqi.pqi_number = 'appendix_f'\r\n where c.encounter_id is not null\r\n),\r\n\r\nunion_cte as (\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from {{ ref('ahrq_measures__int_pqi_shared_exclusion_union') }}\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from amputation\r\n\r\n union all\r\n\r\n select\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n from pregnancy\r\n)\r\n\r\nselect\r\n encounter_id\r\n , data_source\r\n , exclusion_reason\r\n , row_number() over (\r\n partition by encounter_id, data_source \r\n order by exclusion_reason\r\n ) as exclusion_number\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom union_cte", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), amputation as (\n select distinct\n encounter_id\n , data_source\n , 'amputation' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'traumatic_amputation_of_the_lower_extremity_diagnosis_codes'\n and pqi.pqi_number = '16'\n where c.encounter_id is not null\n),\n\npregnancy as (\n select distinct\n encounter_id\n , data_source\n , 'pregnancy' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'mdc_14_principal_diagnosis_codes'\n and pqi.pqi_number = 'appendix_f'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from amputation\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from pregnancy\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_16_num": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_16_num", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_num.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_num.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_num", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_16_num"], "alias": "_int_pqi_16_num", "checksum": {"name": "sha256", "checksum": "f3b9fbd53d0691af169ac1a4fed12a0c9e5070b550dd8316fda74cfe21250325"}, "config": {"enabled": true, "alias": "_int_pqi_16_num", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Numerator for PQI 16 measure calculation.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_16_num", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.064089, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_16_num", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith diagnosis as (\r\n select distinct\r\n c.encounter_id\r\n , c.data_source\r\n from {{ ref('ahrq_measures__stg_pqi_condition') }} as c\r\n inner join {{ ref('pqi__value_sets') }} as pqi\r\n on c.normalized_code = pqi.code\r\n and c.normalized_code_type = 'icd-10-cm'\r\n and pqi.value_set_name = 'diabetes_diagnosis_codes'\r\n and pqi_number = '16'\r\n where c.encounter_id is not null\r\n),\r\n\r\n\r\nprocedures as (\r\n select distinct\r\n p.encounter_id\r\n , p.data_source\r\n from {{ ref('ahrq_measures__stg_pqi_procedure') }} as p\r\n inner join diagnosis as d \r\n on p.encounter_id = d.encounter_id\r\n and d.data_source = p.data_source\r\n inner join {{ ref('pqi__value_sets') }} as pqi\r\n on p.normalized_code = pqi.code\r\n and p.normalized_code_type = 'icd-10-pcs'\r\n and pqi.value_set_name = 'lower-extremity_amputation_procedure_codes'\r\n and pqi_number = '16'\r\n)\r\n\r\nselect\r\n e.data_source\r\n , e.patient_id\r\n , e.year_number\r\n , e.encounter_id\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as e\r\ninner join {{ ref('ahrq_measures__int_pqi_16_denom') }} as denom \r\n on e.patient_id = denom.patient_id\r\n and e.data_source = denom.data_source\r\n and e.year_number = denom.year_number\r\n inner join procedures as p\r\n on e.encounter_id = p.encounter_id\r\n and e.data_source = p.data_source\r\nleft join {{ ref('ahrq_measures__int_pqi_16_exclusions') }} as shared\r\n on e.encounter_id = shared.encounter_id\r\n and e.data_source = shared.data_source\r\nwhere shared.encounter_id is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_condition", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_procedure", "package": null, "version": null}, {"name": "pqi__value_sets", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_denom", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_16_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_16_num.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), diagnosis as (\n select distinct\n c.encounter_id\n , c.data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'diabetes_diagnosis_codes'\n and pqi_number = '16'\n where c.encounter_id is not null\n),\n\n\nprocedures as (\n select distinct\n p.encounter_id\n , p.data_source\n from __dbt__cte___stg_pqi_procedure as p\n inner join diagnosis as d \n on p.encounter_id = d.encounter_id\n and d.data_source = p.data_source\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on p.normalized_code = pqi.code\n and p.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'lower-extremity_amputation_procedure_codes'\n and pqi_number = '16'\n)\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._int_pqi_16_denom as denom \n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\n inner join procedures as p\n on e.encounter_id = p.encounter_id\n and e.data_source = p.data_source\nleft join dev_thuxuan.ahrq_measures._int_pqi_16_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "sql": " __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "sql": " __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_age", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_age.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_age.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_age"], "alias": "_int_pqi_shared_exclusions_missing_age", "checksum": {"name": "sha256", "checksum": "fb10e3109c85e73701a7444e1bd9e0bf0e8fe8c3769863460998761c003958fa"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusions_missing_age", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Exclusion logic for patients without an age\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusions_missing_age", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0660892, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusions_missing_age", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n/* Exclude patients with missing age */\r\nselect \r\n data_source\r\n , patient_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_patient') }}\r\nwhere birth_date is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_age.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) /* Exclude patients with missing age */\nselect \n data_source\n , patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere birth_date is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_dates.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_dates.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_dates"], "alias": "_int_pqi_shared_exclusion_missing_dates", "checksum": {"name": "sha256", "checksum": "c364e9d54ab53929ac5be3129e18555bd3bf00f5d9e67efd54da4ee10f2d4ca5"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_missing_dates", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Handles missing date fields across various PQI measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_missing_dates", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.068089, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_dates", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n-- Exclude encounters with missing start dates\r\nselect\r\n encounter_id\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\r\nwhere \r\n encounter_start_date is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_dates.sql", "compiled": true, "compiled_code": "\n-- Exclude encounters with missing start dates\nselect\n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n encounter_start_date is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_gender", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_gender.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_gender.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_gender"], "alias": "_int_pqi_shared_exclusion_missing_gender", "checksum": {"name": "sha256", "checksum": "19d231b23fb4ac2b9524a88eb373deeb61f49461d407b95e38d893efe457453f"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_missing_gender", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Handles missing gender information for PQI measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_missing_gender", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0700908, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_gender", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n-- Exclude patients with undefined or missing gender\r\nselect \r\n data_source\r\n , patient_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_patient') }}\r\nwhere \r\n sex not in ('male', 'female')", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_gender.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) -- Exclude patients with undefined or missing gender\nselect \n data_source\n , patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere \n sex not in ('male', 'female')", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "sql": " __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx"], "alias": "_int_pqi_shared_exclusion_missing_primary_dx", "checksum": {"name": "sha256", "checksum": "c10a80a514b6c5854c2df37a23c16651cb79dbf035843c91f69896810d64af4a"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_missing_primary_dx", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Handles cases with missing primary diagnosis in PQI measure calculations.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_missing_primary_dx", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0730884, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n-- Exclude encounters with missing primary diagnosis code\r\nselect \r\n encounter_id\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\r\nwhere \r\n primary_diagnosis_code is null", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx.sql", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with missing primary diagnosis code\nselect \n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n primary_diagnosis_code is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_transfer", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_transfer.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_transfer.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_transfer"], "alias": "_int_pqi_shared_exclusion_transfer", "checksum": {"name": "sha256", "checksum": "68d8f3a54b8cc95bb6ec80dd98f670c4ec58e3675a5f56ae45b593afb85daf64"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_transfer", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Excludes transferred patients from PQI calculations.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_transfer", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0750859, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_transfer", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n-- Exclude transfers from hospital, SNF, or other healthcare facility\r\nselect \r\n encounter_id\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\r\nwhere \r\n admit_source_code in ('4', '5', '6')", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_transfer.sql", "compiled": true, "compiled_code": "\n\n-- Exclude transfers from hospital, SNF, or other healthcare facility\nselect \n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n admit_source_code in ('4', '5', '6')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg"], "alias": "_int_pqi_shared_exclusion_ungroupable_drg", "checksum": {"name": "sha256", "checksum": "4bc5510516f944ee84846d17f5109a63196e4129a72c4ec857fd5943f551ad28"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_ungroupable_drg", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Excludes patients with ungroupable DRGs from PQI measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_ungroupable_drg", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.077086, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n-- Exclude encounters with ungroupable DRG\r\nselect \r\n encounter_id\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }}\r\nwhere \r\n ms_drg_code = '999'", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg.sql", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with ungroupable DRG\nselect \n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n ms_drg_code = '999'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__int_pqi_shared_exclusion_union", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_union.sql", "original_file_path": "models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_union.sql", "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "intermediate", "ahrq_measures__int_pqi_shared_exclusion_union"], "alias": "_int_pqi_shared_exclusion_union", "checksum": {"name": "sha256", "checksum": "8ef2da64286582c7bb3f49fb5b9eb75b653d7f0a1954afac1daa6cec51736d4a"}, "config": {"enabled": true, "alias": "_int_pqi_shared_exclusion_union", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Union of all exclusion criteria used across PQI measures for consistent exclusion logic.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_int_pqi_shared_exclusion_union", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0790858, "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n-- Missing Age Exclusion\r\nselect \r\n denom.encounter_id\r\n , denom.data_source\r\n , 'missing age' as exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\r\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_age') }} as age\r\n on denom.patient_id = age.patient_id\r\n and denom.data_source = age.data_source\r\n\r\nunion all\r\n\r\n-- Missing Gender Exclusion\r\nselect \r\n denom.encounter_id\r\n , denom.data_source\r\n , 'missing gender' as exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\r\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_gender') }} as gender\r\n on denom.patient_id = gender.patient_id\r\n and denom.data_source = gender.data_source\r\n\r\nunion all\r\n\r\n-- Missing Dates Exclusion\r\nselect \r\n denom.encounter_id\r\n , denom.data_source\r\n , 'missing dates' as exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\r\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_dates') }} as dates\r\n on denom.encounter_id = dates.encounter_id\r\n and denom.data_source = dates.data_source\r\n\r\nunion all\r\n\r\n-- Missing Primary Diagnosis Exclusion\r\nselect \r\n denom.encounter_id\r\n , denom.data_source\r\n , 'missing primary diagnosis' as exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\r\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx') }} as dx\r\n on denom.encounter_id = dx.encounter_id\r\n and denom.data_source = dx.data_source\r\n\r\nunion all\r\n\r\n-- Transfer Exclusion\r\nselect \r\n denom.encounter_id\r\n , denom.data_source\r\n , 'transfer' as exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\r\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_transfer') }} as tx\r\n on denom.encounter_id = tx.encounter_id\r\n and denom.data_source = tx.data_source\r\n\r\nunion all\r\n\r\n-- Ungroupable DRG Exclusion\r\nselect \r\n denom.encounter_id\r\n , denom.data_source\r\n , 'ungroupable DRG' as exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ahrq_measures__stg_pqi_inpatient_encounter') }} as denom\r\ninner join {{ ref('ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg') }} as drg\r\n on denom.encounter_id = drg.encounter_id\r\n and denom.data_source = drg.data_source", "language": "sql", "refs": [{"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_age", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_gender", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_dates", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_transfer", "package": null, "version": null}, {"name": "ahrq_measures__stg_pqi_inpatient_encounter", "package": null, "version": null}, {"name": "ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\intermediate\\ahrq_measures__int_pqi_shared_exclusion_union.sql", "compiled": true, "compiled_code": "\n\n-- Missing Age Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing age' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusions_missing_age as age\n on denom.patient_id = age.patient_id\n and denom.data_source = age.data_source\n\nunion all\n\n-- Missing Gender Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing gender' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_gender as gender\n on denom.patient_id = gender.patient_id\n and denom.data_source = gender.data_source\n\nunion all\n\n-- Missing Dates Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing dates' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_dates as dates\n on denom.encounter_id = dates.encounter_id\n and denom.data_source = dates.data_source\n\nunion all\n\n-- Missing Primary Diagnosis Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing primary diagnosis' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx as dx\n on denom.encounter_id = dx.encounter_id\n and denom.data_source = dx.data_source\n\nunion all\n\n-- Transfer Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'transfer' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_transfer as tx\n on denom.encounter_id = tx.encounter_id\n and denom.data_source = tx.data_source\n\nunion all\n\n-- Ungroupable DRG Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'ungroupable DRG' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg as drg\n on denom.encounter_id = drg.encounter_id\n and denom.data_source = drg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_condition": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_condition.sql", "original_file_path": "models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_condition.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_condition"], "alias": "_stg_pqi_condition", "checksum": {"name": "sha256", "checksum": "4fc5877e94d4293bd9e6631dc207dc2b1f3553d2236f82735e95f6ee89b9838e"}, "config": {"enabled": true, "alias": "_stg_pqi_condition", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI condition, from core.condition.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_condition", "tags": ["ahrq_measures", "pqi"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.084086, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect \r\n normalized_code_type\r\n , normalized_code\r\n , encounter_id\r\n , data_source\r\nfrom \r\n {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_condition.sql", "compiled": true, "compiled_code": "\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_inpatient_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_inpatient_encounter.sql", "original_file_path": "models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_inpatient_encounter.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_inpatient_encounter"], "alias": "_stg_pqi_inpatient_encounter", "checksum": {"name": "sha256", "checksum": "61b95310cf9b6880f8746cabf72962f8373f98a4fdb4d53c7ad22df43283c557"}, "config": {"enabled": true, "alias": "_stg_pqi_inpatient_encounter", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI inpatient encounters, serving as the basis for further PQI measure calculations.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_inpatient_encounter", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.081086, "relation_name": "dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect \r\n encounter_id\r\n , data_source\r\n , ms_drg_code\r\n , ms_drg_description\r\n , admit_source_code\r\n , encounter_start_date\r\n , encounter_end_date\r\n , length_of_stay\r\n , primary_diagnosis_code\r\n , patient_id\r\n , facility_id\r\n , paid_amount\r\n , {{ date_part('year', 'encounter_start_date') }} as year_number\r\nfrom\r\n {{ ref('core__encounter') }}\r\nwhere \r\n encounter_type = 'acute inpatient'", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part"], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_inpatient_encounter.sql", "compiled": true, "compiled_code": "\n\nselect \n encounter_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , admit_source_code\n , encounter_start_date\n , encounter_end_date\n , length_of_stay\n , primary_diagnosis_code\n , patient_id\n , facility_id\n , paid_amount\n , date_part('year', encounter_start_date) as year_number\nfrom\n dev_thuxuan.core.encounter\nwhere \n encounter_type = 'acute inpatient'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_member_months.sql", "original_file_path": "models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_member_months.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_member_months"], "alias": "_stg_pqi_member_months", "checksum": {"name": "sha256", "checksum": "bb069a3ffc7418651688121ef1406a73fc2c7bb2e27314eafd9a09d336be6bea"}, "config": {"enabled": true, "alias": "_stg_pqi_member_months", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI member months, from financial_pmpm__member_months.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_member_months", "tags": ["ahrq_measures", "pqi"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0860858, "relation_name": "dev_thuxuan.ahrq_measures._stg_pqi_member_months", "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith\r\n\r\ndate_int as (\r\n select distinct\r\n replace(year_month,'-','') yyyymm\r\n , first_day_of_month\r\n from {{ ref('reference_data__calendar') }} as c\r\n)\r\n\r\nselect \r\n data_source\r\n , patient_id\r\n , first_day_of_month\r\n , d.yyyymm as year_month\r\n\r\nfrom \r\n {{ ref('core__member_months') }} mm\r\ninner join date_int d on mm.year_month = d.yyyymm", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_member_months.sql", "compiled": true, "compiled_code": "\n\nwith\n\ndate_int as (\n select distinct\n replace(year_month,'-','') yyyymm\n , first_day_of_month\n from dev_thuxuan.reference_data.calendar as c\n)\n\nselect \n data_source\n , patient_id\n , first_day_of_month\n , d.yyyymm as year_month\n\nfrom \n dev_thuxuan.core.member_months mm\ninner join date_int d on mm.year_month = d.yyyymm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_patient": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_patient.sql", "original_file_path": "models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_patient.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_patient", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_patient"], "alias": "_stg_pqi_patient", "checksum": {"name": "sha256", "checksum": "f2da1225f3677de4ef8006ab6534168e9b76e9a322aff0cbc73fb4485f27e059"}, "config": {"enabled": true, "alias": "_stg_pqi_patient", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI patient, from core.patient.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_patient", "tags": ["ahrq_measures", "pqi"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0880861, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect \r\n data_source\r\n , birth_date\r\n , patient_id\r\n , sex\r\nfrom \r\n {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_patient.sql", "compiled": true, "compiled_code": "\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ahrq_measures__stg_pqi_procedure": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "ahrq_measures__stg_pqi_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_procedure.sql", "original_file_path": "models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_procedure.sql", "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "fqn": ["the_tuva_project", "ahrq_measures", "pqi", "staging", "ahrq_measures__stg_pqi_procedure"], "alias": "_stg_pqi_procedure", "checksum": {"name": "sha256", "checksum": "5530a1d4f7ca4b171f4a9d418934e5eaad8c6ef786f47a1aa9fb5ed15170d22e"}, "config": {"enabled": true, "alias": "_stg_pqi_procedure", "schema": "ahrq_measures", "database": null, "tags": ["ahrq_measures", "pqi"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ahrq_measures", "pqi"], "description": "Staging table for PQI condition, from core.procedure.", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ahrq_measures\\pqi\\pqi_models.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_stg_pqi_procedure", "tags": ["ahrq_measures", "pqi"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0900908, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('pqi_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect \r\n normalized_code_type\r\n , normalized_code\r\n , encounter_id\r\n , data_source\r\nfrom \r\n {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ahrq_measures\\pqi\\staging\\ahrq_measures__stg_pqi_procedure.sql", "compiled": true, "compiled_code": "\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__long_condition_category": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__long_condition_category", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\final\\ccsr__long_condition_category.sql", "original_file_path": "models\\ccsr\\final\\ccsr__long_condition_category.sql", "unique_id": "model.the_tuva_project.ccsr__long_condition_category", "fqn": ["the_tuva_project", "ccsr", "final", "ccsr__long_condition_category"], "alias": "long_condition_category", "checksum": {"name": "sha256", "checksum": "f3346a72c580603daca96474efeaefd8d1219addb57605e37a247bdc6e651c0a"}, "config": {"enabled": true, "alias": "long_condition_category", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This model contains a mapping of individual condition ICD-10-CM diagnosis codes to the CCSR's clinically meaningful diagnosis categories. Each row represents a mapping of an ICD-10 code to a CCSR category. As each ICD-10 code may be mapped to up to 6 categories, it's expected that this table will output as many or more rows than the TUVA condition model. The model is equivalent to the CCSR's Output Option 1 - Vertical File Output.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The ICD-10-CM code for the diagnosis.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The ICD-10-CM code description provided in the CCSR CSV seed file.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "The numerical ranking of a diagnosis code in a claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "body_system": {"name": "body_system", "description": "The body system to which each parent category belongs. The 22 body systems generally follow the structure of the ICD-10-CM diagnosis chapters. Note that the procedure tables don't have this column, but a conceptually related field in procedure models is `clinical_domain`.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category code for each CCSR category. In practice, this is the three letter prefix to the category code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_category_description": {"name": "parent_category_description", "description": "A description of the parent category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "A CCSR category for the ICD-10-CM code. One ICD-10-CM code may have up 6 CCSR categories associated, ordinally ranked by the ccsr_category_rank. Will be null if a record has a `code` that isn't referenced in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "The description of the CCSR category as provided in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_rank": {"name": "ccsr_category_rank", "description": "The ordinal rank of a given CCSR category mapped to an ICD-10-CM code. The CCSR seed CSV has the order of categories assigned to each ICD-10-CM code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_ip_default_category": {"name": "is_ip_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an inpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_op_default_category": {"name": "is_op_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an outpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dxccsr_version": {"name": "dxccsr_version", "description": "The version number of the CCSR program from which the dbt model was derived.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "long_condition_category", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.0940907, "relation_name": "dev_thuxuan.ccsr.long_condition_category", "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith ccsr__dx_vertical_pivot as (\r\n \r\n select * from {{ ref('ccsr__dx_vertical_pivot') }} \r\n\r\n), condition as (\r\n \r\n select * from {{ ref('ccsr__stg_core__condition') }}\r\n\r\n), dxccsr_body_systems as (\r\n\r\n select * from {{ ref('ccsr__dxccsr_v2023_1_body_systems') }}\r\n\r\n)\r\n\r\nselect \r\n condition.encounter_id,\r\n condition.claim_id,\r\n condition.patient_id,\r\n condition.normalized_code,\r\n ccsr__dx_vertical_pivot.code_description,\r\n condition.condition_rank,\r\n ccsr__dx_vertical_pivot.ccsr_parent_category,\r\n dxccsr_body_systems.body_system,\r\n dxccsr_body_systems.parent_category_description,\r\n ccsr__dx_vertical_pivot.ccsr_category,\r\n ccsr__dx_vertical_pivot.ccsr_category_description,\r\n ccsr__dx_vertical_pivot.ccsr_category_rank,\r\n ccsr__dx_vertical_pivot.is_ip_default_category,\r\n ccsr__dx_vertical_pivot.is_op_default_category,\r\n {{ var('dxccsr_version') }} as dxccsr_version,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom condition\r\nleft join ccsr__dx_vertical_pivot\r\n on condition.normalized_code = ccsr__dx_vertical_pivot.code\r\nleft join dxccsr_body_systems on ccsr__dx_vertical_pivot.ccsr_parent_category = dxccsr_body_systems.ccsr_parent_category", "language": "sql", "refs": [{"name": "ccsr__dx_vertical_pivot", "package": null, "version": null}, {"name": "ccsr__stg_core__condition", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_body_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.ccsr__stg_core__condition", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\final\\ccsr__long_condition_category.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__condition as (\n\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere normalized_code_type = 'icd-10-cm'\n), ccsr__dx_vertical_pivot as (\n \n select * from dev_thuxuan.ccsr.dx_vertical_pivot \n\n), condition as (\n \n select * from __dbt__cte__ccsr__stg_core__condition\n\n), dxccsr_body_systems as (\n\n select * from dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems\n\n)\n\nselect \n condition.encounter_id,\n condition.claim_id,\n condition.patient_id,\n condition.normalized_code,\n ccsr__dx_vertical_pivot.code_description,\n condition.condition_rank,\n ccsr__dx_vertical_pivot.ccsr_parent_category,\n dxccsr_body_systems.body_system,\n dxccsr_body_systems.parent_category_description,\n ccsr__dx_vertical_pivot.ccsr_category,\n ccsr__dx_vertical_pivot.ccsr_category_description,\n ccsr__dx_vertical_pivot.ccsr_category_rank,\n ccsr__dx_vertical_pivot.is_ip_default_category,\n ccsr__dx_vertical_pivot.is_op_default_category,\n '2023.1' as dxccsr_version,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom condition\nleft join ccsr__dx_vertical_pivot\n on condition.normalized_code = ccsr__dx_vertical_pivot.code\nleft join dxccsr_body_systems on ccsr__dx_vertical_pivot.ccsr_parent_category = dxccsr_body_systems.ccsr_parent_category", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ccsr__stg_core__condition", "sql": " __dbt__cte__ccsr__stg_core__condition as (\n\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere normalized_code_type = 'icd-10-cm'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__long_procedure_category": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__long_procedure_category", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\final\\ccsr__long_procedure_category.sql", "original_file_path": "models\\ccsr\\final\\ccsr__long_procedure_category.sql", "unique_id": "model.the_tuva_project.ccsr__long_procedure_category", "fqn": ["the_tuva_project", "ccsr", "final", "ccsr__long_procedure_category"], "alias": "long_procedure_category", "checksum": {"name": "sha256", "checksum": "4bbd4b41628d38f7cda9aeb38e6efed793aeb35084d97ba658101f09a8624f0d"}, "config": {"enabled": true, "alias": "long_procedure_category", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This model contains a mapping of individual condition ICD-10-PCS procedure codes to the CCSR's clinically meaningful procedure categories. Each row represents a mapping of an ICD-10 code to a CCSR category. The model is equivalent to the CCSR's Output Option 1 - Vertical File Output.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "The encounter_id for the encounter where this procedure was performed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The ICD-10-PCS code for the procedure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The ICD-10-PCS code description provided in the CCSR CSV seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category code for each CCSR category. In practice, this is the three letter prefix to the category code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "clinical_domain": {"name": "clinical_domain", "description": "The ICD-10-PCS Clinical Domain that the CCSR parent category belongs to. Note that the condition models don't have this column, but the `body_system` is a conceptually related column in the condition tables.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "A description of the clinical domain.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "The CCSR category mapped to the ICD-10-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prccsr_version": {"name": "prccsr_version", "description": "The version number of the CCSR program from which the dbt model was derived.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "long_procedure_category", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1000912, "relation_name": "dev_thuxuan.ccsr.long_procedure_category", "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith procedures as (\r\n\r\n select * from {{ ref('ccsr__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, ccsr__procedure_category_map as (\r\n\r\n select * from {{ ref ('ccsr__procedure_category_map') }}\r\n\r\n)\r\n\r\nselect distinct\r\n procedures.encounter_id\r\n , procedures.claim_id\r\n , procedures.patient_id\r\n , procedures.normalized_code\r\n , ccsr__procedure_category_map.code_description\r\n , ccsr__procedure_category_map.ccsr_parent_category\r\n , ccsr__procedure_category_map.ccsr_category\r\n , ccsr__procedure_category_map.ccsr_category_description\r\n , ccsr__procedure_category_map.clinical_domain\r\n , {{ var('prccsr_version') }} as prccsr_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom procedures\r\nleft join ccsr__procedure_category_map\r\n on procedures.normalized_code = ccsr__procedure_category_map.code", "language": "sql", "refs": [{"name": "ccsr__stg_core__procedure", "package": null, "version": null}, {"name": "ccsr__procedure_category_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ccsr__stg_core__procedure", "model.the_tuva_project.ccsr__procedure_category_map"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\final\\ccsr__long_procedure_category.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__procedure as (\n\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), procedures as (\n\n select * from __dbt__cte__ccsr__stg_core__procedure\n\n)\n\n, ccsr__procedure_category_map as (\n\n select * from dev_thuxuan.ccsr.procedure_category_map\n\n)\n\nselect distinct\n procedures.encounter_id\n , procedures.claim_id\n , procedures.patient_id\n , procedures.normalized_code\n , ccsr__procedure_category_map.code_description\n , ccsr__procedure_category_map.ccsr_parent_category\n , ccsr__procedure_category_map.ccsr_category\n , ccsr__procedure_category_map.ccsr_category_description\n , ccsr__procedure_category_map.clinical_domain\n , '2023.1' as prccsr_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom procedures\nleft join ccsr__procedure_category_map\n on procedures.normalized_code = ccsr__procedure_category_map.code", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ccsr__stg_core__procedure", "sql": " __dbt__cte__ccsr__stg_core__procedure as (\n\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__singular_condition_category": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__singular_condition_category", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\final\\ccsr__singular_condition_category.sql", "original_file_path": "models\\ccsr\\final\\ccsr__singular_condition_category.sql", "unique_id": "model.the_tuva_project.ccsr__singular_condition_category", "fqn": ["the_tuva_project", "ccsr", "final", "ccsr__singular_condition_category"], "alias": "singular_condition_category", "checksum": {"name": "sha256", "checksum": "e4b3c90a6a271a6a4f43fc3e0807848e8db8b4190159f19b6e18232e683ed687"}, "config": {"enabled": true, "alias": "singular_condition_category", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This model contains only the CCSR's default category assignment for the ICD-10 code, and only for the first-listed ICD-10 code (`diagnosis_code = 1`).\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for an encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique claim_id for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "body_system": {"name": "body_system", "description": "The body system to which each parent category belongs. The 22 body systems generally follow the structure of the ICD-10-CM diagnosis chapters. Note that the procedure tables don't have this column, but a conceptually related field in procedure models is `clinical_domain`.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category code for each CCSR category. In practice, this is the three letter prefix to the category code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_category_description": {"name": "parent_category_description", "description": "A description of the parent category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "A CCSR category for the ICD-10-CM code. One ICD-10-CM code may have up 6 CCSR categories associated, ordinally ranked by the ccsr_category_rank. Will be null if a record has a `code` that isn't referenced in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "The human readable description of the `ccsr_category`.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dxccsr_version": {"name": "dxccsr_version", "description": "The version number of the CCSR program from which the dbt model was derived.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "singular_condition_category", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.097091, "relation_name": "dev_thuxuan.ccsr.singular_condition_category", "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n encounter_id,\r\n claim_id,\r\n patient_id,\r\n ccsr_category,\r\n ccsr_category_description,\r\n ccsr_parent_category,\r\n parent_category_description,\r\n body_system,\r\n {{ var('dxccsr_version') }} as dxccsr_version,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ref('ccsr__long_condition_category')}}\r\nwhere\r\n is_{{ var('record_type', 'ip') }}_default_category = 1\r\n and condition_rank = 1", "language": "sql", "refs": [{"name": "ccsr__long_condition_category", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ccsr__long_condition_category"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\final\\ccsr__singular_condition_category.sql", "compiled": true, "compiled_code": "\n\nselect \n encounter_id,\n claim_id,\n patient_id,\n ccsr_category,\n ccsr_category_description,\n ccsr_parent_category,\n parent_category_description,\n body_system,\n '2023.1' as dxccsr_version,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ccsr.long_condition_category\nwhere\n is_ip_default_category = 1\n and condition_rank = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__dx_vertical_pivot": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__dx_vertical_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\intermediate\\ccsr__dx_vertical_pivot.sql", "original_file_path": "models\\ccsr\\intermediate\\ccsr__dx_vertical_pivot.sql", "unique_id": "model.the_tuva_project.ccsr__dx_vertical_pivot", "fqn": ["the_tuva_project", "ccsr", "intermediate", "ccsr__dx_vertical_pivot"], "alias": "dx_vertical_pivot", "checksum": {"name": "sha256", "checksum": "9625ebdd697e23e801752cdde0a053f7a72b24c532dcbbb0b76224b397380c75"}, "config": {"enabled": true, "alias": "dx_vertical_pivot", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This is an intermediate model that pivots the DXCCSR's wide-format mapping CSV into a long format table. While the seed uses 6 columns to represent the 6 CCSR codes that may be present, this generates one row for each CCSR category per ICD code, so up to 6 rows per code. \nThis model includes details and descriptions of the CCSR parent category and body systems that are inherited by the final models.\nThis model may also be useful in looking up CCSR condition category, body system, and parent category information.\n", "columns": {"code": {"name": "code", "description": "The ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The description of the ICD-10-CM code included in the seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "A CCSR category for the ICD-10-CM code. One ICD-10-CM code may have up 6 CCSR categories associated, ordinally ranked by the ccsr_category_rank. Will be null if a record has a `code` that isn't referenced in the CCSR seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_rank": {"name": "ccsr_category_rank", "description": "The ordinal rank of a given CCSR category mapped to an ICD-10-CM code. The CCSR seed CSV has the order of categories assigned to each ICD-10-CM code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "The human readable description of the `ccsr_category`.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The CCSR parent category - the three letter prefix for each alphanumeric category.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_ip_default_category": {"name": "is_ip_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an inpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_op_default_category": {"name": "is_op_default_category", "description": "For each ICD-10-CM code, this field will return true for the CCSR category that is the default value for the code if the underlying record is an outpatient encounter.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "dx_vertical_pivot", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.102091, "relation_name": "dev_thuxuan.ccsr.dx_vertical_pivot", "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith codes as (\r\n \r\n select\r\n icd_10_cm_code as code, \r\n icd_10_cm_code_description as code_description,\r\n -- loop to generate columns for CCSR categories 1-6\r\n {%- for i in range(1,7) %}\r\n ccsr_category_{{ i }},\r\n ccsr_category_{{ i }}_description,\r\n {%- endfor %}\r\n default_ccsr_category_ip,\r\n default_ccsr_category_op\r\n from {{ ref('ccsr__dxccsr_v2023_1_cleaned_map') }}\r\n\r\n), long_union as (\r\n -- generate select & union statements to pivot category columns to rows\r\n {% for i in range(1,7,1) %}\r\n select \r\n code,\r\n code_description,\r\n substring(ccsr_category_{{ i }}, 1, 3) as ccsr_parent_category,\r\n ccsr_category_{{ i }} as ccsr_category,\r\n ccsr_category_{{ i }}_description as ccsr_category_description,\r\n {{ i }} as ccsr_category_rank,\r\n CASE WHEN ccsr_category_{{ i }} = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\r\n CASE WHEN ccsr_category_{{ i }} = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\r\n from codes \r\n {{ \"union all\" if not loop.last else \"\" }}\r\n {%- endfor %}\r\n\r\n)\r\n\r\nselect distinct\r\n *,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom long_union\r\n-- as not all diagnosis codes have multiple categories, we can discard nulls\r\nwhere ccsr_category is not null", "language": "sql", "refs": [{"name": "ccsr__dxccsr_v2023_1_cleaned_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\intermediate\\ccsr__dx_vertical_pivot.sql", "compiled": true, "compiled_code": "\n\nwith codes as (\n \n select\n icd_10_cm_code as code, \n icd_10_cm_code_description as code_description,\n -- loop to generate columns for CCSR categories 1-6\n ccsr_category_1,\n ccsr_category_1_description,\n ccsr_category_2,\n ccsr_category_2_description,\n ccsr_category_3,\n ccsr_category_3_description,\n ccsr_category_4,\n ccsr_category_4_description,\n ccsr_category_5,\n ccsr_category_5_description,\n ccsr_category_6,\n ccsr_category_6_description,\n default_ccsr_category_ip,\n default_ccsr_category_op\n from dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map\n\n), long_union as (\n -- generate select & union statements to pivot category columns to rows\n \n select \n code,\n code_description,\n substring(ccsr_category_1, 1, 3) as ccsr_parent_category,\n ccsr_category_1 as ccsr_category,\n ccsr_category_1_description as ccsr_category_description,\n 1 as ccsr_category_rank,\n CASE WHEN ccsr_category_1 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_1 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_2, 1, 3) as ccsr_parent_category,\n ccsr_category_2 as ccsr_category,\n ccsr_category_2_description as ccsr_category_description,\n 2 as ccsr_category_rank,\n CASE WHEN ccsr_category_2 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_2 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_3, 1, 3) as ccsr_parent_category,\n ccsr_category_3 as ccsr_category,\n ccsr_category_3_description as ccsr_category_description,\n 3 as ccsr_category_rank,\n CASE WHEN ccsr_category_3 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_3 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_4, 1, 3) as ccsr_parent_category,\n ccsr_category_4 as ccsr_category,\n ccsr_category_4_description as ccsr_category_description,\n 4 as ccsr_category_rank,\n CASE WHEN ccsr_category_4 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_4 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_5, 1, 3) as ccsr_parent_category,\n ccsr_category_5 as ccsr_category,\n ccsr_category_5_description as ccsr_category_description,\n 5 as ccsr_category_rank,\n CASE WHEN ccsr_category_5 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_5 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_6, 1, 3) as ccsr_parent_category,\n ccsr_category_6 as ccsr_category,\n ccsr_category_6_description as ccsr_category_description,\n 6 as ccsr_category_rank,\n CASE WHEN ccsr_category_6 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_6 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n \n\n)\n\nselect distinct\n *,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom long_union\n-- as not all diagnosis codes have multiple categories, we can discard nulls\nwhere ccsr_category is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__procedure_category_map": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__procedure_category_map", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\intermediate\\ccsr__procedure_category_map.sql", "original_file_path": "models\\ccsr\\intermediate\\ccsr__procedure_category_map.sql", "unique_id": "model.the_tuva_project.ccsr__procedure_category_map", "fqn": ["the_tuva_project", "ccsr", "intermediate", "ccsr__procedure_category_map"], "alias": "procedure_category_map", "checksum": {"name": "sha256", "checksum": "4ae949d858bc70a4ca4a93047d5ce7bf45e6a7053dc052c76a9bd98678ba7b55"}, "config": {"enabled": true, "alias": "procedure_category_map", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "This is an intermediate model that renames some PRCCSR columns to align with other TUVA models as well as the `ccsr__dx_vertical_pivot` model.\n", "columns": {"code": {"name": "code", "description": "The ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "The description of the ICD-10-PCS code included in the seed file.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category": {"name": "ccsr_category", "description": "The CCSR category to which the ICD-10 code is mapped.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_description": {"name": "ccsr_category_description", "description": "A description of the CCSR category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "clinical_domain": {"name": "clinical_domain", "description": "The clinical domain to which the CCSR code belongs. Note that the condition models don't have this column, but the `body_system` is a conceptually related column in the condition tables.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The CCSR parent category - the three letter prefix for each alphanumeric category.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"schema": "ccsr", "alias": "procedure_category_map", "tags": ["ccsr"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1045952, "relation_name": "dev_thuxuan.ccsr.procedure_category_map", "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n icd_10_pcs as code,\r\n icd_10_pcs_description as code_description,\r\n prccsr as ccsr_category,\r\n substring(prccsr, 1, 3) as ccsr_parent_category,\r\n prccsr_description as ccsr_category_description,\r\n clinical_domain,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('ccsr__prccsr_v2023_1_cleaned_map')}}", "language": "sql", "refs": [{"name": "ccsr__prccsr_v2023_1_cleaned_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\intermediate\\ccsr__procedure_category_map.sql", "compiled": true, "compiled_code": "\n\nselect \n icd_10_pcs as code,\n icd_10_pcs_description as code_description,\n prccsr as ccsr_category,\n substring(prccsr, 1, 3) as ccsr_parent_category,\n prccsr_description as ccsr_category_description,\n clinical_domain,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ccsr._value_set_prccsr_v2023_1_cleaned_map", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__stg_core__condition": {"database": "dev_thuxuan", "schema": "test", "name": "ccsr__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\staging\\ccsr__stg_core__condition.sql", "original_file_path": "models\\ccsr\\staging\\ccsr__stg_core__condition.sql", "unique_id": "model.the_tuva_project.ccsr__stg_core__condition", "fqn": ["the_tuva_project", "ccsr", "staging", "ccsr__stg_core__condition"], "alias": "ccsr__stg_core__condition", "checksum": {"name": "sha256", "checksum": "53dcf3e02727e62f515ca661a5e705fa89f77182e14fd4c3e0105043d36c3b95"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "", "columns": {"encounter_id": {"name": "encounter_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"tags": ["ccsr"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1066003, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n encounter_id\r\n , claim_id\r\n , patient_id\r\n , normalized_code\r\n , condition_rank\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__condition') }}\r\nwhere normalized_code_type = 'icd-10-cm'", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\staging\\ccsr__stg_core__condition.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere normalized_code_type = 'icd-10-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ccsr__stg_core__procedure": {"database": "dev_thuxuan", "schema": "test", "name": "ccsr__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "ccsr\\staging\\ccsr__stg_core__procedure.sql", "original_file_path": "models\\ccsr\\staging\\ccsr__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.ccsr__stg_core__procedure", "fqn": ["the_tuva_project", "ccsr", "staging", "ccsr__stg_core__procedure"], "alias": "ccsr__stg_core__procedure", "checksum": {"name": "sha256", "checksum": "86d1ebbaa417939fb3a0b562d22c8900a7fcb8926aa0961a884d9957fcb72e63"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ccsr"], "description": "", "columns": {"encounter_id": {"name": "encounter_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ccsr\\ccsr_models.yml", "build_path": null, "unrendered_config": {"tags": ["ccsr"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1076021, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('ccsr_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n encounter_id\r\n , claim_id\r\n , patient_id\r\n , normalized_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ccsr\\staging\\ccsr__stg_core__procedure.sql", "compiled": true, "compiled_code": "\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\final\\chronic_conditions__cms_chronic_conditions_long.sql", "original_file_path": "models\\chronic_conditions\\final\\chronic_conditions__cms_chronic_conditions_long.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__cms_chronic_conditions_long"], "alias": "cms_chronic_conditions_long", "checksum": {"name": "sha256", "checksum": "764774fe7a023cadf8fea7a1bcd31a30da256b7d3a2bd5802f3964ea0ae1e8b0"}, "config": {"enabled": true, "alias": "cms_chronic_conditions_long", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model unions condition flags from the 3 upstream stage models that calculate them.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Cardiovascular Disease).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__cms_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "cms_chronic_conditions_long", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1316752, "relation_name": "dev_thuxuan.chronic_conditions.cms_chronic_conditions_long", "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n{% if target.type == 'fabric' %}\r\nwith conditions_unioned as (\r\n\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_all') }}\r\n union\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hiv_aids') }}\r\n union\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_oud') }}\r\n\r\n)\r\n{% else %}\r\nwith conditions_unioned as (\r\n\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_all') }}\r\n union distinct\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hiv_aids') }}\r\n union distinct\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_oud') }}\r\n\r\n)\r\n{% endif %}\r\n\r\nselect\r\n patient_id\r\n , claim_id\r\n , start_date\r\n , chronic_condition_type\r\n , condition_category\r\n , condition\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom conditions_unioned", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\final\\chronic_conditions__cms_chronic_conditions_long.sql", "compiled": true, "compiled_code": "\n\n\nwith conditions_unioned as (\n\n select * from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\n union distinct\n select * from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\n union distinct\n select * from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\n\n)\n\n\nselect\n patient_id\n , claim_id\n , start_date\n , chronic_condition_type\n , condition_category\n , condition\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom conditions_unioned", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_wide", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\final\\chronic_conditions__cms_chronic_conditions_wide.sql", "original_file_path": "models\\chronic_conditions\\final\\chronic_conditions__cms_chronic_conditions_wide.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__cms_chronic_conditions_wide"], "alias": "cms_chronic_conditions_wide", "checksum": {"name": "sha256", "checksum": "50e44c6afcc69f43ad2bc6a07d331cc8102bdba94a61b5d7c6a20b4f43f28f5e"}, "config": {"enabled": true, "alias": "cms_chronic_conditions_wide", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model pivots conditions on the patient level (i.e. one record per patient) with flags for each chronic condition.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_myocardial_infarction": {"name": "acute_myocardial_infarction", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "adhd_conduct_disorders_and_hyperkinetic_syndrome": {"name": "adhd_conduct_disorders_and_hyperkinetic_syndrome", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "alcohol_use_disorders": {"name": "alcohol_use_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "alzheimers_disease": {"name": "alzheimers_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "anemia": {"name": "anemia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "anxiety_disorders": {"name": "anxiety_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "asthma": {"name": "asthma", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "atrial_fibrillation_and_flutter": {"name": "atrial_fibrillation_and_flutter", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "autism_spectrum_disorders": {"name": "autism_spectrum_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "benign_prostatic_hyperplasia": {"name": "benign_prostatic_hyperplasia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "bipolar_disorder": {"name": "bipolar_disorder", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_breast": {"name": "cancer_breast", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_colorectal": {"name": "cancer_colorectal", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_endometrial": {"name": "cancer_endometrial", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_lung": {"name": "cancer_lung", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_prostate": {"name": "cancer_prostate", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cancer_urologic_kidney_renal_pelvis_and_ureter": {"name": "cancer_urologic_kidney_renal_pelvis_and_ureter", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cataract": {"name": "cataract", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cerebral_palsy": {"name": "cerebral_palsy", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "chronic_kidney_disease": {"name": "chronic_kidney_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "chronic_obstructive_pulmonary_disease": {"name": "chronic_obstructive_pulmonary_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "cystic_fibrosis_and_other_metabolic_developmental_disorders": {"name": "cystic_fibrosis_and_other_metabolic_developmental_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "depression_bipolar_or_other_depressive_mood_disorders": {"name": "depression_bipolar_or_other_depressive_mood_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "depressive_disorders": {"name": "depressive_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "diabetes": {"name": "diabetes", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "drug_use_disorders": {"name": "drug_use_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "epilepsy": {"name": "epilepsy", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "fibromyalgia_and_chronic_pain_and_fatigue": {"name": "fibromyalgia_and_chronic_pain_and_fatigue", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "glaucoma": {"name": "glaucoma", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "heart_failure_and_non_ischemic_heart_disease": {"name": "heart_failure_and_non_ischemic_heart_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_a": {"name": "hepatitis_a", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_b_acute_or_unspecified": {"name": "hepatitis_b_acute_or_unspecified", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_b_chronic": {"name": "hepatitis_b_chronic", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_c_acute": {"name": "hepatitis_c_acute", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_c_chronic": {"name": "hepatitis_c_chronic", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_c_unspecified": {"name": "hepatitis_c_unspecified", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_d": {"name": "hepatitis_d", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hepatitis_e": {"name": "hepatitis_e", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hip_pelvic_fracture": {"name": "hip_pelvic_fracture", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids": {"name": "human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hyperlipidemia": {"name": "hyperlipidemia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hypertension": {"name": "hypertension", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "hypothyroidism": {"name": "hypothyroidism", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "intellectual_disabilities_and_related_conditions": {"name": "intellectual_disabilities_and_related_conditions", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "ischemic_heart_disease": {"name": "ischemic_heart_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "learning_disabilities": {"name": "learning_disabilities", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "leukemias_and_lymphomas": {"name": "leukemias_and_lymphomas", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis": {"name": "liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "migraine_and_chronic_headache": {"name": "migraine_and_chronic_headache", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "mobility_impairments": {"name": "mobility_impairments", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "multiple_sclerosis_and_transverse_myelitis": {"name": "multiple_sclerosis_and_transverse_myelitis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "muscular_dystrophy": {"name": "muscular_dystrophy", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "non_alzheimers_dementia": {"name": "non_alzheimers_dementia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "obesity": {"name": "obesity", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "opioid_use_disorder_oud": {"name": "opioid_use_disorder_oud", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "osteoporosis_with_or_without_pathological_fracture": {"name": "osteoporosis_with_or_without_pathological_fracture", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "other_developmental_delays": {"name": "other_developmental_delays", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "parkinsons_disease_and_secondary_parkinsonism": {"name": "parkinsons_disease_and_secondary_parkinsonism", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "peripheral_vascular_disease_pvd": {"name": "peripheral_vascular_disease_pvd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "personality_disorders": {"name": "personality_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "pneumonia_all_cause": {"name": "pneumonia_all_cause", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "post_traumatic_stress_disorder_ptsd": {"name": "post_traumatic_stress_disorder_ptsd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "pressure_and_chronic_ulcers": {"name": "pressure_and_chronic_ulcers", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "rheumatoid_arthritis_osteoarthritis": {"name": "rheumatoid_arthritis_osteoarthritis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "schizophrenia": {"name": "schizophrenia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "schizophrenia_and_other_psychotic_disorders": {"name": "schizophrenia_and_other_psychotic_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "sensory_blindness_and_visual_impairment": {"name": "sensory_blindness_and_visual_impairment", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "sensory_deafness_and_hearing_impairment": {"name": "sensory_deafness_and_hearing_impairment", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "sickle_cell_disease": {"name": "sickle_cell_disease", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "spina_bifida_and_other_congenital_anomalies_of_the_nervous_system": {"name": "spina_bifida_and_other_congenital_anomalies_of_the_nervous_system", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "spinal_cord_injury": {"name": "spinal_cord_injury", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "stroke_transient_ischemic_attack": {"name": "stroke_transient_ischemic_attack", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "tobacco_use": {"name": "tobacco_use", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage": {"name": "traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "viral_hepatitis_general": {"name": "viral_hepatitis_general", "description": "flag indicating if the condition is present", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "cms_chronic_conditions_wide", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1286745, "relation_name": "dev_thuxuan.chronic_conditions.cms_chronic_conditions_wide", "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith chronic_conditions as (\r\n\r\n select distinct\r\n condition\r\n , condition_column_name\r\n from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n chronic_conditions_unioned.patient_id\r\n , chronic_conditions.condition_column_name\r\n , 1 as condition_count\r\n from {{ ref('chronic_conditions__cms_chronic_conditions_long') }} as chronic_conditions_unioned\r\n inner join chronic_conditions as chronic_conditions\r\n on chronic_conditions_unioned.condition = chronic_conditions.condition\r\n\r\n)\r\n\r\nselect\r\n p.patient_id\r\n , {{ dbt_utils.pivot(\r\n column='condition_column_name'\r\n , values=dbt_utils.get_column_values(\r\n ref ('chronic_conditions__cms_chronic_conditions_hierarchy')\r\n , 'condition_column_name'\r\n , order_by= 'condition_column_name'\r\n )\r\n , agg='max'\r\n , then_value= 1\r\n , else_value= 0\r\n , quote_identifiers = False\r\n ) }}\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('cms_chronic_conditions__stg_core__patient') }} p\r\n left join conditions\r\n on p.patient_id = conditions.patient_id\r\ngroup by\r\n p.patient_id", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.get_column_values", "macro.dbt_utils.pivot"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.cms_chronic_conditions__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\final\\chronic_conditions__cms_chronic_conditions_wide.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__patient as (\n\n\nselect \n patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), chronic_conditions as (\n\n select distinct\n condition\n , condition_column_name\n from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, conditions as (\n\n select\n chronic_conditions_unioned.patient_id\n , chronic_conditions.condition_column_name\n , 1 as condition_count\n from dev_thuxuan.chronic_conditions.cms_chronic_conditions_long as chronic_conditions_unioned\n inner join chronic_conditions as chronic_conditions\n on chronic_conditions_unioned.condition = chronic_conditions.condition\n\n)\n\nselect\n p.patient_id\n , \n \n max(\n \n case\n when condition_column_name = 'acute_myocardial_infarction'\n then 1\n else 0\n end\n )\n \n \n as acute_myocardial_infarction\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'adhd_conduct_disorders_and_hyperkinetic_syndrome'\n then 1\n else 0\n end\n )\n \n \n as adhd_conduct_disorders_and_hyperkinetic_syndrome\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alcohol_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as alcohol_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alzheimers_disease'\n then 1\n else 0\n end\n )\n \n \n as alzheimers_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anemia'\n then 1\n else 0\n end\n )\n \n \n as anemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anxiety_disorders'\n then 1\n else 0\n end\n )\n \n \n as anxiety_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'asthma'\n then 1\n else 0\n end\n )\n \n \n as asthma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'atrial_fibrillation_and_flutter'\n then 1\n else 0\n end\n )\n \n \n as atrial_fibrillation_and_flutter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'autism_spectrum_disorders'\n then 1\n else 0\n end\n )\n \n \n as autism_spectrum_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'benign_prostatic_hyperplasia'\n then 1\n else 0\n end\n )\n \n \n as benign_prostatic_hyperplasia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'bipolar_disorder'\n then 1\n else 0\n end\n )\n \n \n as bipolar_disorder\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_breast'\n then 1\n else 0\n end\n )\n \n \n as cancer_breast\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_colorectal'\n then 1\n else 0\n end\n )\n \n \n as cancer_colorectal\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_endometrial'\n then 1\n else 0\n end\n )\n \n \n as cancer_endometrial\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_lung'\n then 1\n else 0\n end\n )\n \n \n as cancer_lung\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_prostate'\n then 1\n else 0\n end\n )\n \n \n as cancer_prostate\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_urologic_kidney_renal_pelvis_and_ureter'\n then 1\n else 0\n end\n )\n \n \n as cancer_urologic_kidney_renal_pelvis_and_ureter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cataract'\n then 1\n else 0\n end\n )\n \n \n as cataract\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cerebral_palsy'\n then 1\n else 0\n end\n )\n \n \n as cerebral_palsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_kidney_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_kidney_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_obstructive_pulmonary_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_obstructive_pulmonary_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cystic_fibrosis_and_other_metabolic_developmental_disorders'\n then 1\n else 0\n end\n )\n \n \n as cystic_fibrosis_and_other_metabolic_developmental_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depression_bipolar_or_other_depressive_mood_disorders'\n then 1\n else 0\n end\n )\n \n \n as depression_bipolar_or_other_depressive_mood_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depressive_disorders'\n then 1\n else 0\n end\n )\n \n \n as depressive_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'diabetes'\n then 1\n else 0\n end\n )\n \n \n as diabetes\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'drug_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as drug_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'epilepsy'\n then 1\n else 0\n end\n )\n \n \n as epilepsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'fibromyalgia_and_chronic_pain_and_fatigue'\n then 1\n else 0\n end\n )\n \n \n as fibromyalgia_and_chronic_pain_and_fatigue\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'glaucoma'\n then 1\n else 0\n end\n )\n \n \n as glaucoma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'heart_failure_and_non_ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as heart_failure_and_non_ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_a'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_a\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_acute_or_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_acute_or_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_acute'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_acute\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_d'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_d\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_e'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_e\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hip_pelvic_fracture'\n then 1\n else 0\n end\n )\n \n \n as hip_pelvic_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids'\n then 1\n else 0\n end\n )\n \n \n as human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hyperlipidemia'\n then 1\n else 0\n end\n )\n \n \n as hyperlipidemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypertension'\n then 1\n else 0\n end\n )\n \n \n as hypertension\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypothyroidism'\n then 1\n else 0\n end\n )\n \n \n as hypothyroidism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'intellectual_disabilities_and_related_conditions'\n then 1\n else 0\n end\n )\n \n \n as intellectual_disabilities_and_related_conditions\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'learning_disabilities'\n then 1\n else 0\n end\n )\n \n \n as learning_disabilities\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'leukemias_and_lymphomas'\n then 1\n else 0\n end\n )\n \n \n as leukemias_and_lymphomas\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis'\n then 1\n else 0\n end\n )\n \n \n as liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'migraine_and_chronic_headache'\n then 1\n else 0\n end\n )\n \n \n as migraine_and_chronic_headache\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'mobility_impairments'\n then 1\n else 0\n end\n )\n \n \n as mobility_impairments\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'multiple_sclerosis_and_transverse_myelitis'\n then 1\n else 0\n end\n )\n \n \n as multiple_sclerosis_and_transverse_myelitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'muscular_dystrophy'\n then 1\n else 0\n end\n )\n \n \n as muscular_dystrophy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'non_alzheimers_dementia'\n then 1\n else 0\n end\n )\n \n \n as non_alzheimers_dementia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'obesity'\n then 1\n else 0\n end\n )\n \n \n as obesity\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'opioid_use_disorder_oud'\n then 1\n else 0\n end\n )\n \n \n as opioid_use_disorder_oud\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'osteoporosis_with_or_without_pathological_fracture'\n then 1\n else 0\n end\n )\n \n \n as osteoporosis_with_or_without_pathological_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'other_developmental_delays'\n then 1\n else 0\n end\n )\n \n \n as other_developmental_delays\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'parkinsons_disease_and_secondary_parkinsonism'\n then 1\n else 0\n end\n )\n \n \n as parkinsons_disease_and_secondary_parkinsonism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'peripheral_vascular_disease_pvd'\n then 1\n else 0\n end\n )\n \n \n as peripheral_vascular_disease_pvd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'personality_disorders'\n then 1\n else 0\n end\n )\n \n \n as personality_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pneumonia_all_cause'\n then 1\n else 0\n end\n )\n \n \n as pneumonia_all_cause\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'post_traumatic_stress_disorder_ptsd'\n then 1\n else 0\n end\n )\n \n \n as post_traumatic_stress_disorder_ptsd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pressure_and_chronic_ulcers'\n then 1\n else 0\n end\n )\n \n \n as pressure_and_chronic_ulcers\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'rheumatoid_arthritis_osteoarthritis'\n then 1\n else 0\n end\n )\n \n \n as rheumatoid_arthritis_osteoarthritis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia_and_other_psychotic_disorders'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia_and_other_psychotic_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_blindness_and_visual_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_blindness_and_visual_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_deafness_and_hearing_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_deafness_and_hearing_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sickle_cell_disease'\n then 1\n else 0\n end\n )\n \n \n as sickle_cell_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spina_bifida_and_other_congenital_anomalies_of_the_nervous_system'\n then 1\n else 0\n end\n )\n \n \n as spina_bifida_and_other_congenital_anomalies_of_the_nervous_system\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spinal_cord_injury'\n then 1\n else 0\n end\n )\n \n \n as spinal_cord_injury\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'stroke_transient_ischemic_attack'\n then 1\n else 0\n end\n )\n \n \n as stroke_transient_ischemic_attack\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'tobacco_use'\n then 1\n else 0\n end\n )\n \n \n as tobacco_use\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage'\n then 1\n else 0\n end\n )\n \n \n as traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'viral_hepatitis_general'\n then 1\n else 0\n end\n )\n \n \n as viral_hepatitis_general\n \n \n \n \n\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__cms_chronic_conditions__stg_core__patient p\n left join conditions\n on p.patient_id = conditions.patient_id\ngroup by\n p.patient_id", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__patient as (\n\n\nselect \n patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__tuva_chronic_conditions_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\final\\chronic_conditions__tuva_chronic_conditions_long.sql", "original_file_path": "models\\chronic_conditions\\final\\chronic_conditions__tuva_chronic_conditions_long.sql", "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__tuva_chronic_conditions_long"], "alias": "tuva_chronic_conditions_long", "checksum": {"name": "sha256", "checksum": "d7ef89fb02320b95353a27c2e6b36bf91eef232664f9b92e5f393836dc9af463"}, "config": {"enabled": true, "alias": "tuva_chronic_conditions_long", "schema": "chronic_conditions", "database": null, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "description": "This model creates one record per patient per condition using the tuva chronic conditions hierarchy as the grouper. The model pulls in the first and last date of the diagnosis that flagged the patient for this condition group.\n", "columns": {"patient_id": {"name": "patient_id", "description": "The unique identifier for a patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the condition that each diagnosis code rolls up to\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/chronic_conditions/chronic_conditions__tuva_chronic_conditions_hierarchy.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_diagnosis_date": {"name": "first_diagnosis_date", "description": "The first date when a diagnosis code that rolls up to this condition was coded to this patient\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_diagnosis_date": {"name": "last_diagnosis_date", "description": "The last date when a diagnosis code that rolls up to this condition was coded to this patient\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "tuva_chronic_conditions_long", "tags": ["tuva_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1904645, "relation_name": "dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long", "raw_code": "{{ config(\r\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith all_conditions as (\r\nselect \r\n patient_id,\r\n normalized_code,\r\n recorded_date\r\n from {{ ref('tuva_chronic_conditions__stg_core__condition') }}\r\n),\r\n\r\n\r\nconditions_with_first_and_last_diagnosis_date as (\r\nselect \r\n patient_id,\r\n normalized_code as icd_10_cm,\r\n min(recorded_date) as first_diagnosis_date,\r\n max(recorded_date) as last_diagnosis_date\r\nfrom all_conditions\r\ngroup by patient_id, normalized_code\r\n\r\n)\r\n\r\n\r\nselect\r\n aa.patient_id,\r\n bb.concept_name as condition,\r\n min(first_diagnosis_date) as first_diagnosis_date,\r\n max(last_diagnosis_date) as last_diagnosis_date,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom conditions_with_first_and_last_diagnosis_date aa\r\ninner join {{ ref('clinical_concept_library__value_set_member_relevant_fields') }} bb\r\non aa.icd_10_cm = bb.code\r\ngroup by aa.patient_id, bb.concept_name", "language": "sql", "refs": [{"name": "tuva_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "clinical_concept_library__value_set_member_relevant_fields", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\final\\chronic_conditions__tuva_chronic_conditions_long.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__tuva_chronic_conditions__stg_core__condition as (\n\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), all_conditions as (\nselect \n patient_id,\n normalized_code,\n recorded_date\n from __dbt__cte__tuva_chronic_conditions__stg_core__condition\n),\n\n\nconditions_with_first_and_last_diagnosis_date as (\nselect \n patient_id,\n normalized_code as icd_10_cm,\n min(recorded_date) as first_diagnosis_date,\n max(recorded_date) as last_diagnosis_date\nfrom all_conditions\ngroup by patient_id, normalized_code\n\n)\n\n\nselect\n aa.patient_id,\n bb.concept_name as condition,\n min(first_diagnosis_date) as first_diagnosis_date,\n max(last_diagnosis_date) as last_diagnosis_date,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom conditions_with_first_and_last_diagnosis_date aa\ninner join dev_thuxuan.clinical_concept_library.value_set_member_relevant_fields bb\non aa.icd_10_cm = bb.code\ngroup by aa.patient_id, bb.concept_name", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__tuva_chronic_conditions__stg_core__condition as (\n\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__tuva_chronic_conditions_wide", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\final\\chronic_conditions__tuva_chronic_conditions_wide.sql", "original_file_path": "models\\chronic_conditions\\final\\chronic_conditions__tuva_chronic_conditions_wide.sql", "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "fqn": ["the_tuva_project", "chronic_conditions", "final", "chronic_conditions__tuva_chronic_conditions_wide"], "alias": "tuva_chronic_conditions_wide", "checksum": {"name": "sha256", "checksum": "b49e23eafda282ad2cdd84a7bdc08cb8850133126713029e533e1e69634e85c9"}, "config": {"enabled": true, "alias": "tuva_chronic_conditions_wide", "schema": "chronic_conditions", "database": null, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "description": "This model creates one record per patient with flags for all the conditions in the tuva chronic conditions hierarchy. A patient will have a 1 in the column for a certain condition if they have every been coded with a diagnosis that rolls up to that condition and a 0 if not.\n", "columns": {"patient_id": {"name": "patient_id", "description": "ID of the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "obesity": {"name": "obesity", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "osteoarthritis": {"name": "osteoarthritis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copd": {"name": "copd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "anxiety_disorders": {"name": "anxiety_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ckd": {"name": "ckd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "t2d": {"name": "t2d", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cll": {"name": "cll", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dysplipidemias": {"name": "dysplipidemias", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hypertension": {"name": "hypertension", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atherosclerosis": {"name": "atherosclerosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dementia": {"name": "dementia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rheumatoid_arthritis": {"name": "rheumatoid_arthritis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "celiac": {"name": "celiac", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hip_fracture": {"name": "hip_fracture", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "immunodeficiencies_and_white_blood_cell_disorders": {"name": "immunodeficiencies_and_white_blood_cell_disorders", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "asthma": {"name": "asthma", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "t1d": {"name": "t1d", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ulcerative_colitis": {"name": "ulcerative_colitis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chrohns": {"name": "chrohns", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "holicobacter": {"name": "holicobacter", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bipolar": {"name": "bipolar", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "heart_failure": {"name": "heart_failure", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tabacco": {"name": "tabacco", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lyme": {"name": "lyme", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "breast_cancer": {"name": "breast_cancer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "osteoporosis": {"name": "osteoporosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pulmonary_embolism": {"name": "pulmonary_embolism", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "schizophrenia": {"name": "schizophrenia", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atrial_fibrillation": {"name": "atrial_fibrillation", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "colorectal_cancer": {"name": "colorectal_cancer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "depression": {"name": "depression", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deep_vein_thrombosis": {"name": "deep_vein_thrombosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alzheimer": {"name": "alzheimer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "stroke": {"name": "stroke", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "myocardial_infraction": {"name": "myocardial_infraction", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "opiod_use_disorder": {"name": "opiod_use_disorder", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lung_cancer": {"name": "lung_cancer", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "herpes": {"name": "herpes", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rickettsiosis": {"name": "rickettsiosis", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms": {"name": "ms", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alchohol": {"name": "alchohol", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adhd": {"name": "adhd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hiv": {"name": "hiv", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ptsd": {"name": "ptsd", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lupus": {"name": "lupus", "description": "flag indicating if the condition is present", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "tuva_chronic_conditions_wide", "tags": ["tuva_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2034638, "relation_name": "dev_thuxuan.chronic_conditions.tuva_chronic_conditions_wide", "raw_code": "{{ config(\r\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith patients as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\n),\r\n\r\nobesity as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Obesity'\r\n),\r\n\r\n\r\nosteoarthritis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Osteoarthritis'\r\n),\r\n\r\ncopd as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Chronic Obstructive Pulmonary Disease'\r\n),\r\n\r\nanxiety_disorders as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Anxiety Disorders'\r\n),\r\n\r\nckd as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Chronic Kidney Disease'\r\n),\r\n\r\nt2d as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Type 2 Diabetes Mellitus'\r\n),\r\n\r\ncll as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Chronic Lymphocytic Leukemia'\r\n),\r\n\r\ndysplipidemias as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Dyslipidemias'\r\n),\r\n\r\nhypertension as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Hypertension'\r\n),\r\n\r\natherosclerosis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Atherosclerosis'\r\n),\r\n\r\ndementia as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Dementia'\r\n),\r\n\r\nrheumatoid_arthritis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Rheumatoid Arthritis'\r\n),\r\n\r\nceliac as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Celiac Disease'\r\n),\r\n\r\nhip_fracture as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Hip Fracture'\r\n),\r\n\r\nimmunodeficiencies_and_white_blood_cell_disorders as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Specified Immunodeficiencies and White Blood Cell Disorders (HCC v28 concept #115)'\r\n),\r\n\r\nasthma as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Asthma'\r\n),\r\n\r\nt1d as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Type 1 Diabetes Mellitus'\r\n),\r\n\r\nulcerative_colitis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Ulcerative colitis'\r\n),\r\n\r\nchrohns as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Crohns Disease'\r\n),\r\n\r\nholicobacter as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Helicobacter pylori Infection'\r\n),\r\n\r\nbipolar as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Bipolar Affective Disorder'\r\n),\r\n\r\nheart_failure as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Heart Failure'\r\n),\r\n\r\ntabacco as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Tobacco Use'\r\n),\r\n\r\nlyme as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Lyme Disease'\r\n),\r\n\r\nbreast_cancer as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Breast Cancer'\r\n),\r\n\r\nosteoporosis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Osteoporosis'\r\n),\r\n\r\npulmonary_embolism as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Pulmonary Embolism, Thrombotic or Unspecified'\r\n),\r\n\r\nschizophrenia as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Schizophrenia'\r\n),\r\n\r\natrial_fibrillation as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Atrial Fibrillation'\r\n),\r\n\r\ncolorectal_cancer as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Colorectal Cancer'\r\n),\r\n\r\ndepression as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Major Depressive Disorder'\r\n),\r\n\r\ndeep_vein_thrombosis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Deep Vein Thrombosis of Extremities or Central Veins'\r\n),\r\n\r\nalzheimer as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Alzheimer Disease'\r\n),\r\n\r\nstroke as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Stroke'\r\n),\r\n\r\nmyocardial_infraction as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Myocardial Infarction'\r\n),\r\n\r\nopiod_use_disorder as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Opioid Use Disorder'\r\n),\r\n\r\nlung_cancer as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Lung cancer, primary or unspecified'\r\n),\r\n\r\nherpes as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Herpes Simplex Infection'\r\n),\r\n\r\nrickettsiosis as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Rickettsiosis'\r\n),\r\n\r\nms as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Multiple Sclerosis'\r\n),\r\n\r\nalchohol as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Alcohol Use Disorder'\r\n),\r\n\r\nadhd as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Attention Deficit-Hyperactivity Disorder'\r\n),\r\n\r\nhiv as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'HIV/AIDS (HCC v28 concept #1)'\r\n),\r\n\r\nptsd as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Post-Traumatic Stress Disorder'\r\n),\r\n\r\nlupus as (\r\nselect distinct patient_id\r\nfrom {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\nwhere condition = 'Systemic Lupus Erythematosus'\r\n)\r\n\r\n\r\n\r\n\r\nselect\r\n patient_id,\r\n case when patient_id in (select * from obesity) then 1\r\n else 0\r\n end as obesity,\r\n case when patient_id in (select * from osteoarthritis) then 1\r\n else 0\r\n end as osteoarthritis,\r\n case when patient_id in (select * from copd) then 1\r\n else 0\r\n end as copd,\r\n case when patient_id in (select * from anxiety_disorders) then 1\r\n else 0\r\n end as anxiety_disorders,\r\n case when patient_id in (select * from ckd) then 1\r\n else 0\r\n end as ckd,\r\n case when patient_id in (select * from t2d) then 1\r\n else 0\r\n end as t2d,\r\n case when patient_id in (select * from cll) then 1\r\n else 0\r\n end as cll,\r\n case when patient_id in (select * from dysplipidemias) then 1\r\n else 0\r\n end as dysplipidemias,\r\n case when patient_id in (select * from hypertension) then 1\r\n else 0\r\n end as hypertension,\r\n case when patient_id in (select * from atherosclerosis) then 1\r\n else 0\r\n end as atherosclerosis,\r\n case when patient_id in (select * from dementia) then 1\r\n else 0\r\n end as dementia,\r\n case when patient_id in (select * from rheumatoid_arthritis) then 1\r\n else 0\r\n end as rheumatoid_arthritis,\r\n case when patient_id in (select * from celiac) then 1\r\n else 0\r\n end as celiac,\r\n case when patient_id in (select * from hip_fracture) then 1\r\n else 0\r\n end as hip_fracture,\r\n case when patient_id in (select * from immunodeficiencies_and_white_blood_cell_disorders) then 1\r\n else 0\r\n end as immunodeficiencies_and_white_blood_cell_disorders,\r\n case when patient_id in (select * from asthma) then 1\r\n else 0\r\n end asthma,\r\n case when patient_id in (select * from t1d) then 1\r\n else 0\r\n end as t1d,\r\n case when patient_id in (select * from ulcerative_colitis) then 1\r\n else 0\r\n end as ulcerative_colitis,\r\n case when patient_id in (select * from chrohns) then 1\r\n else 0\r\n end as chrohns,\r\n case when patient_id in (select * from holicobacter) then 1\r\n else 0\r\n end as holicobacter,\r\n case when patient_id in (select * from bipolar) then 1\r\n else 0\r\n end as bipolar,\r\n case when patient_id in (select * from heart_failure) then 1\r\n else 0\r\n end as heart_failure,\r\n case when patient_id in (select * from tabacco) then 1\r\n else 0\r\n end as tabacco,\r\n case when patient_id in (select * from lyme) then 1\r\n else 0\r\n end as lyme,\r\n case when patient_id in (select * from breast_cancer) then 1\r\n else 0\r\n end as breast_cancer,\r\n case when patient_id in (select * from osteoporosis) then 1\r\n else 0\r\n end as osteoporosis,\r\n case when patient_id in (select * from pulmonary_embolism) then 1\r\n else 0\r\n end as pulmonary_embolism,\r\n case when patient_id in (select * from schizophrenia) then 1\r\n else 0\r\n end as schizophrenia,\r\n case when patient_id in (select * from atrial_fibrillation) then 1\r\n else 0\r\n end as atrial_fibrillation,\r\n case when patient_id in (select * from colorectal_cancer) then 1\r\n else 0\r\n end as colorectal_cancer,\r\n case when patient_id in (select * from depression) then 1\r\n else 0\r\n end as depression,\r\n case when patient_id in (select * from deep_vein_thrombosis) then 1\r\n else 0\r\n end as deep_vein_thrombosis,\r\n case when patient_id in (select * from alzheimer) then 1\r\n else 0\r\n end as alzheimer,\r\n case when patient_id in (select * from stroke) then 1\r\n else 0\r\n end as stroke,\r\n case when patient_id in (select * from myocardial_infraction) then 1\r\n else 0\r\n end as myocardial_infraction,\r\n case when patient_id in (select * from opiod_use_disorder) then 1\r\n else 0\r\n end as opiod_use_disorder,\r\n case when patient_id in (select * from lung_cancer) then 1\r\n else 0\r\n end as lung_cancer,\r\n case when patient_id in (select * from herpes) then 1\r\n else 0\r\n end as herpes,\r\n case when patient_id in (select * from rickettsiosis) then 1\r\n else 0\r\n end as rickettsiosis,\r\n case when patient_id in (select * from ms) then 1\r\n else 0\r\n end as ms,\r\n case when patient_id in (select * from alchohol) then 1\r\n else 0\r\n end as alchohol,\r\n case when patient_id in (select * from adhd) then 1\r\n else 0\r\n end as adhd,\r\n case when patient_id in (select * from hiv) then 1\r\n else 0\r\n end as hiv,\r\n case when patient_id in (select * from ptsd) then 1\r\n else 0\r\n end as ptsd,\r\n case when patient_id in (select * from lupus) then 1\r\n else 0\r\n end as lupus,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\n\r\nfrom patients", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\final\\chronic_conditions__tuva_chronic_conditions_wide.sql", "compiled": true, "compiled_code": "\n\nwith patients as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n),\n\nobesity as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Obesity'\n),\n\n\nosteoarthritis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoarthritis'\n),\n\ncopd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Obstructive Pulmonary Disease'\n),\n\nanxiety_disorders as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Anxiety Disorders'\n),\n\nckd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Kidney Disease'\n),\n\nt2d as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 2 Diabetes Mellitus'\n),\n\ncll as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Lymphocytic Leukemia'\n),\n\ndysplipidemias as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dyslipidemias'\n),\n\nhypertension as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hypertension'\n),\n\natherosclerosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atherosclerosis'\n),\n\ndementia as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dementia'\n),\n\nrheumatoid_arthritis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rheumatoid Arthritis'\n),\n\nceliac as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Celiac Disease'\n),\n\nhip_fracture as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hip Fracture'\n),\n\nimmunodeficiencies_and_white_blood_cell_disorders as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Specified Immunodeficiencies and White Blood Cell Disorders (HCC v28 concept #115)'\n),\n\nasthma as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Asthma'\n),\n\nt1d as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 1 Diabetes Mellitus'\n),\n\nulcerative_colitis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Ulcerative colitis'\n),\n\nchrohns as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Crohns Disease'\n),\n\nholicobacter as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Helicobacter pylori Infection'\n),\n\nbipolar as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Bipolar Affective Disorder'\n),\n\nheart_failure as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Heart Failure'\n),\n\ntabacco as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Tobacco Use'\n),\n\nlyme as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lyme Disease'\n),\n\nbreast_cancer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Breast Cancer'\n),\n\nosteoporosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoporosis'\n),\n\npulmonary_embolism as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Pulmonary Embolism, Thrombotic or Unspecified'\n),\n\nschizophrenia as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Schizophrenia'\n),\n\natrial_fibrillation as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atrial Fibrillation'\n),\n\ncolorectal_cancer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Colorectal Cancer'\n),\n\ndepression as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Major Depressive Disorder'\n),\n\ndeep_vein_thrombosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Deep Vein Thrombosis of Extremities or Central Veins'\n),\n\nalzheimer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alzheimer Disease'\n),\n\nstroke as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Stroke'\n),\n\nmyocardial_infraction as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Myocardial Infarction'\n),\n\nopiod_use_disorder as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Opioid Use Disorder'\n),\n\nlung_cancer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lung cancer, primary or unspecified'\n),\n\nherpes as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Herpes Simplex Infection'\n),\n\nrickettsiosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rickettsiosis'\n),\n\nms as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Multiple Sclerosis'\n),\n\nalchohol as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alcohol Use Disorder'\n),\n\nadhd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Attention Deficit-Hyperactivity Disorder'\n),\n\nhiv as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'HIV/AIDS (HCC v28 concept #1)'\n),\n\nptsd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Post-Traumatic Stress Disorder'\n),\n\nlupus as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Systemic Lupus Erythematosus'\n)\n\n\n\n\nselect\n patient_id,\n case when patient_id in (select * from obesity) then 1\n else 0\n end as obesity,\n case when patient_id in (select * from osteoarthritis) then 1\n else 0\n end as osteoarthritis,\n case when patient_id in (select * from copd) then 1\n else 0\n end as copd,\n case when patient_id in (select * from anxiety_disorders) then 1\n else 0\n end as anxiety_disorders,\n case when patient_id in (select * from ckd) then 1\n else 0\n end as ckd,\n case when patient_id in (select * from t2d) then 1\n else 0\n end as t2d,\n case when patient_id in (select * from cll) then 1\n else 0\n end as cll,\n case when patient_id in (select * from dysplipidemias) then 1\n else 0\n end as dysplipidemias,\n case when patient_id in (select * from hypertension) then 1\n else 0\n end as hypertension,\n case when patient_id in (select * from atherosclerosis) then 1\n else 0\n end as atherosclerosis,\n case when patient_id in (select * from dementia) then 1\n else 0\n end as dementia,\n case when patient_id in (select * from rheumatoid_arthritis) then 1\n else 0\n end as rheumatoid_arthritis,\n case when patient_id in (select * from celiac) then 1\n else 0\n end as celiac,\n case when patient_id in (select * from hip_fracture) then 1\n else 0\n end as hip_fracture,\n case when patient_id in (select * from immunodeficiencies_and_white_blood_cell_disorders) then 1\n else 0\n end as immunodeficiencies_and_white_blood_cell_disorders,\n case when patient_id in (select * from asthma) then 1\n else 0\n end asthma,\n case when patient_id in (select * from t1d) then 1\n else 0\n end as t1d,\n case when patient_id in (select * from ulcerative_colitis) then 1\n else 0\n end as ulcerative_colitis,\n case when patient_id in (select * from chrohns) then 1\n else 0\n end as chrohns,\n case when patient_id in (select * from holicobacter) then 1\n else 0\n end as holicobacter,\n case when patient_id in (select * from bipolar) then 1\n else 0\n end as bipolar,\n case when patient_id in (select * from heart_failure) then 1\n else 0\n end as heart_failure,\n case when patient_id in (select * from tabacco) then 1\n else 0\n end as tabacco,\n case when patient_id in (select * from lyme) then 1\n else 0\n end as lyme,\n case when patient_id in (select * from breast_cancer) then 1\n else 0\n end as breast_cancer,\n case when patient_id in (select * from osteoporosis) then 1\n else 0\n end as osteoporosis,\n case when patient_id in (select * from pulmonary_embolism) then 1\n else 0\n end as pulmonary_embolism,\n case when patient_id in (select * from schizophrenia) then 1\n else 0\n end as schizophrenia,\n case when patient_id in (select * from atrial_fibrillation) then 1\n else 0\n end as atrial_fibrillation,\n case when patient_id in (select * from colorectal_cancer) then 1\n else 0\n end as colorectal_cancer,\n case when patient_id in (select * from depression) then 1\n else 0\n end as depression,\n case when patient_id in (select * from deep_vein_thrombosis) then 1\n else 0\n end as deep_vein_thrombosis,\n case when patient_id in (select * from alzheimer) then 1\n else 0\n end as alzheimer,\n case when patient_id in (select * from stroke) then 1\n else 0\n end as stroke,\n case when patient_id in (select * from myocardial_infraction) then 1\n else 0\n end as myocardial_infraction,\n case when patient_id in (select * from opiod_use_disorder) then 1\n else 0\n end as opiod_use_disorder,\n case when patient_id in (select * from lung_cancer) then 1\n else 0\n end as lung_cancer,\n case when patient_id in (select * from herpes) then 1\n else 0\n end as herpes,\n case when patient_id in (select * from rickettsiosis) then 1\n else 0\n end as rickettsiosis,\n case when patient_id in (select * from ms) then 1\n else 0\n end as ms,\n case when patient_id in (select * from alchohol) then 1\n else 0\n end as alchohol,\n case when patient_id in (select * from adhd) then 1\n else 0\n end as adhd,\n case when patient_id in (select * from hiv) then 1\n else 0\n end as hiv,\n case when patient_id in (select * from ptsd) then 1\n else 0\n end as ptsd,\n case when patient_id in (select * from lupus) then 1\n else 0\n end as lupus,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n\nfrom patients", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_all", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_all.sql", "original_file_path": "models\\chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_all.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "fqn": ["the_tuva_project", "chronic_conditions", "intermediate", "chronic_conditions__cms_chronic_conditions_all"], "alias": "_int_cms_chronic_condition_all", "checksum": {"name": "sha256", "checksum": "f620462e12c1c66f605c669c5225b03bc6ef964ab9af7750415211fef47fc51e"}, "config": {"enabled": true, "alias": "_int_cms_chronic_condition_all", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model contains logic for all chronic conditions where additional_logic is not 'None'. This model includes standard exclusions and maps ICD-10-CM diagnosis codes, ICD-10-PCS procedure codes, HCPCS codes, and MS DRG codes to chronic conditions.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Cardiovascular Disease).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "_int_cms_chronic_condition_all", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1336758, "relation_name": "dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all", "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith chronic_conditions as (\r\n\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\r\n\r\n)\r\n\r\n, patient_conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date as start_date\r\n , normalized_code_type as code_type\r\n , replace(normalized_code,'.','') as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__condition') }}\r\n\r\n)\r\n\r\n, patient_ms_drgs as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , claim_start_date as start_date\r\n , 'MS-DRG' as code_type\r\n , ms_drg_code as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__medical_claim') }}\r\n\r\n)\r\n\r\n, patient_procedures as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , procedure_date as start_date\r\n , normalized_code_type as code_type\r\n , replace(normalized_code,'.','') as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, inclusions_diagnosis as (\r\n\r\n select\r\n patient_conditions.patient_id\r\n , patient_conditions.claim_id\r\n , patient_conditions.start_date\r\n , patient_conditions.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_conditions\r\n inner join chronic_conditions\r\n on patient_conditions.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'ICD-10-CM'\r\n and chronic_conditions.additional_logic = 'None'\r\n\r\n)\r\n\r\n, inclusions_ms_drg as (\r\n\r\n select\r\n patient_ms_drgs.patient_id\r\n , patient_ms_drgs.claim_id\r\n , patient_ms_drgs.start_date\r\n , patient_ms_drgs.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_ms_drgs\r\n inner join chronic_conditions\r\n on patient_ms_drgs.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'MS-DRG'\r\n and chronic_conditions.additional_logic = 'None'\r\n\r\n)\r\n\r\n, inclusions_procedure as (\r\n\r\n select\r\n patient_procedures.patient_id\r\n , patient_procedures.claim_id\r\n , patient_procedures.start_date\r\n , patient_procedures.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_procedures\r\n inner join chronic_conditions\r\n on patient_procedures.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\r\n and chronic_conditions.additional_logic = 'None'\r\n\r\n)\r\n\r\n, exclusions_diagnosis as (\r\n\r\n select distinct\r\n patient_conditions.claim_id\r\n , chronic_conditions.condition\r\n from patient_conditions\r\n inner join chronic_conditions\r\n on patient_conditions.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Exclude'\r\n and chronic_conditions.code_system = 'ICD-10-CM'\r\n\r\n)\r\n\r\n{% if target.type == 'fabric' %}\r\n, inclusions_unioned as (\r\n\r\n select * from inclusions_diagnosis\r\n union\r\n select * from inclusions_procedure\r\n union\r\n select * from inclusions_ms_drg\r\n\r\n)\r\n{% else %}\r\n, inclusions_unioned as (\r\n\r\n select * from inclusions_diagnosis\r\n union distinct\r\n select * from inclusions_procedure\r\n union distinct\r\n select * from inclusions_ms_drg\r\n\r\n)\r\n{% endif %}\r\n\r\nselect distinct\r\n cast(inclusions_unioned.patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(inclusions_unioned.claim_id as {{ dbt.type_string() }}) as claim_id\r\n , cast(inclusions_unioned.start_date as date) as start_date\r\n , cast(inclusions_unioned.chronic_condition_type as {{ dbt.type_string() }}) as chronic_condition_type\r\n , cast(inclusions_unioned.condition_category as {{ dbt.type_string() }}) as condition_category\r\n , cast(inclusions_unioned.condition as {{ dbt.type_string() }}) as condition\r\n , cast(inclusions_unioned.data_source as {{ dbt.type_string() }}) as data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom inclusions_unioned\r\n left join exclusions_diagnosis\r\n on inclusions_unioned.claim_id = exclusions_diagnosis.claim_id\r\n and inclusions_unioned.condition = exclusions_diagnosis.condition\r\nwhere exclusions_diagnosis.claim_id is null", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__medical_claim", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_all.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, exclusions_diagnosis as (\n\n select distinct\n patient_conditions.claim_id\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Exclude'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_ms_drg\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_diagnosis\n on inclusions_unioned.claim_id = exclusions_diagnosis.claim_id\n and inclusions_unioned.condition = exclusions_diagnosis.condition\nwhere exclusions_diagnosis.claim_id is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_hiv_aids.sql", "original_file_path": "models\\chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_hiv_aids.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "fqn": ["the_tuva_project", "chronic_conditions", "intermediate", "chronic_conditions__cms_chronic_conditions_hiv_aids"], "alias": "_int_cms_chronic_condition_hiv_aids", "checksum": {"name": "sha256", "checksum": "d15139fe1ee3685e8371102e6007d0dd4f5d75712d72e47449f3c3ab661a2151"}, "config": {"enabled": true, "alias": "_int_cms_chronic_condition_hiv_aids", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model contains logic for the chronic condition Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS). This model maps ICD-10-CM diagnosis codes and MS DRG codes to the chronic condition.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Other).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "_int_cms_chronic_condition_hiv_aids", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1366756, "relation_name": "dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids", "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set condition_filter = 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)' -%}\r\n\r\nwith chronic_conditions as (\r\n\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\r\n where condition = '{{ condition_filter }}'\r\n\r\n)\r\n\r\n, patient_conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date as start_date\r\n , normalized_code_type as code_type\r\n , replace(normalized_code,'.','') as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__condition') }}\r\n\r\n)\r\n\r\n, patient_ms_drgs as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , claim_start_date as start_date\r\n , 'MS-DRG' as code_type\r\n , ms_drg_code as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__medical_claim') }}\r\n\r\n)\r\n\r\n/*\r\n Exception logic: a claim with the diagnosis code R75 requires a second\r\n qualifying claim that is not R75 (a screening code)\r\n\r\n This CTE excludes encounters with the exception code. Those encounters\r\n will be evaluated separately.\r\n*/\r\n, inclusions_diagnosis as (\r\n\r\n select\r\n patient_conditions.patient_id\r\n , patient_conditions.claim_id\r\n , patient_conditions.start_date\r\n , patient_conditions.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_conditions\r\n inner join chronic_conditions\r\n on patient_conditions.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'ICD-10-CM'\r\n and chronic_conditions.code <> 'R75'\r\n\r\n)\r\n\r\n, inclusions_ms_drg as (\r\n\r\n select\r\n patient_ms_drgs.patient_id\r\n , patient_ms_drgs.claim_id\r\n , patient_ms_drgs.start_date\r\n , patient_ms_drgs.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_ms_drgs\r\n inner join chronic_conditions\r\n on patient_ms_drgs.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'MS-DRG'\r\n\r\n)\r\n\r\n/*\r\n Exception logic: a claim with the diagnosis code R75 requires a second\r\n qualifying claim that is not R75 (a screening code)\r\n\r\n This CTE includes encounters with the exception code only where that\r\n patient has another encounter that is not R75.\r\n*/\r\n, exception_diagnosis as (\r\n\r\n select\r\n patient_conditions.patient_id\r\n , patient_conditions.claim_id\r\n , patient_conditions.start_date\r\n , patient_conditions.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_conditions\r\n inner join chronic_conditions\r\n on patient_conditions.code = chronic_conditions.code\r\n inner join inclusions_diagnosis\r\n on patient_conditions.patient_id = inclusions_diagnosis.patient_id\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'ICD-10-CM'\r\n and chronic_conditions.code = 'R75'\r\n\r\n)\r\n\r\n{% if target.type == 'fabric' %}\r\n, inclusions_unioned as (\r\n\r\n select * from inclusions_diagnosis\r\n union\r\n select * from inclusions_ms_drg\r\n union\r\n select * from exception_diagnosis\r\n\r\n)\r\n{% else %}\r\n, inclusions_unioned as (\r\n\r\n select * from inclusions_diagnosis\r\n union distinct\r\n select * from inclusions_ms_drg\r\n union distinct\r\n select * from exception_diagnosis\r\n\r\n)\r\n{% endif %}\r\n\r\nselect distinct\r\n cast(inclusions_unioned.patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(inclusions_unioned.claim_id as {{ dbt.type_string() }}) as claim_id\r\n , cast(inclusions_unioned.start_date as date) as start_date\r\n , cast(inclusions_unioned.chronic_condition_type as {{ dbt.type_string() }}) as chronic_condition_type\r\n , cast(inclusions_unioned.condition_category as {{ dbt.type_string() }}) as condition_category\r\n , cast(inclusions_unioned.condition as {{ dbt.type_string() }}) as condition\r\n , cast(inclusions_unioned.data_source as {{ dbt.type_string() }}) as data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom inclusions_unioned", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_hiv_aids.sql", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), chronic_conditions as (\n\n select * from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE excludes encounters with the exception code. Those encounters\n will be evaluated separately.\n*/\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code <> 'R75'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE includes encounters with the exception code only where that\n patient has another encounter that is not R75.\n*/\n, exception_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n inner join inclusions_diagnosis\n on patient_conditions.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code = 'R75'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_ms_drg\n union distinct\n select * from exception_diagnosis\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom inclusions_unioned", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_oud", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_oud.sql", "original_file_path": "models\\chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_oud.sql", "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "fqn": ["the_tuva_project", "chronic_conditions", "intermediate", "chronic_conditions__cms_chronic_conditions_oud"], "alias": "_int_cms_chronic_condition_oud", "checksum": {"name": "sha256", "checksum": "6cd2af1178b62675a370c695d1587a7d5a28cc23e447217f4b30e9eb6405dc26"}, "config": {"enabled": true, "alias": "_int_cms_chronic_condition_oud", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "This model contains logic for the chronic condition Opioid Use Disorder (OUD). This model maps ICD-10-CM diagnosis codes, ICD-10-PCS procedure codes, HCPCS codes, and NDC codes to the chronic condition.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "start_date": {"name": "start_date", "description": "Start date of the chronic condition derived from diagnosis, procedure, or medication.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "The type of chronic condition as defined by CMS. ('Common' or 'Other chronic or potentially disabling conditions')\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "The category of the condition (e.g. Substance Abuse).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "The name of the chronic condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Indicates the name of the source dataset (e.g. Medicare Claims).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"schema": "chronic_conditions", "alias": "_int_cms_chronic_condition_oud", "tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.138672, "relation_name": "dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud", "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set condition_filter = 'Opioid Use Disorder (OUD)' -%}\r\n\r\n{%- set naltrexone_ndcs = (\r\n '00056001122', '00056001130', '00056001170', '00056007950', '00056008050',\r\n '00185003901', '00185003930', '00406009201', '00406009203', '00406117001',\r\n '00406117003', '00555090201', '00555090202', '00904703604', '16729008101',\r\n '16729008110', '42291063230', '43063059115', '47335032683', '47335032688',\r\n '50090286600', '50436010501', '51224020630', '51224020650', '51285027501',\r\n '51285027502', '52152010502', '52152010504', '52152010530', '54868557400',\r\n '63459030042', '63629104601', '63629104701', '65694010003', '65694010010',\r\n '65757030001', '65757030202', '68084029111', '68084029121', '68094085362',\r\n '68115068030'\r\n )\r\n-%}\r\n\r\nwith chronic_conditions as (\r\n\r\n select * from {{ ref('chronic_conditions__cms_chronic_conditions_hierarchy') }}\r\n where condition = '{{ condition_filter }}'\r\n\r\n)\r\n\r\n, patient_conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date as start_date\r\n , normalized_code_type as code_type\r\n , replace(normalized_code,'.','') as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__condition') }}\r\n\r\n)\r\n\r\n, patient_medications as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , paid_date as start_date\r\n , replace(ndc_code,'.','') as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__pharmacy_claim') }}\r\n\r\n)\r\n\r\n, patient_procedures as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , procedure_date as start_date\r\n , normalized_code_type as code_type\r\n , replace(normalized_code,'.','') as code\r\n , data_source\r\n from {{ ref('cms_chronic_conditions__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, inclusions_diagnosis as (\r\n\r\n select\r\n patient_conditions.patient_id\r\n , patient_conditions.claim_id\r\n , patient_conditions.start_date\r\n , patient_conditions.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_conditions\r\n inner join chronic_conditions\r\n on patient_conditions.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'ICD-10-CM'\r\n\r\n)\r\n\r\n, inclusions_procedure as (\r\n\r\n select\r\n patient_procedures.patient_id\r\n , patient_procedures.claim_id\r\n , patient_procedures.start_date\r\n , patient_procedures.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_procedures\r\n inner join chronic_conditions\r\n on patient_procedures.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\r\n\r\n)\r\n\r\n/*\r\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\r\n alcohol or other drug use disorder where opioid DX is not present\r\n\r\n This CTE excludes medication encounters with the exception codes for\r\n Naltrexone. Those encounters will be evaluated separately.\r\n*/\r\n, inclusions_medication as (\r\n\r\n select\r\n patient_medications.patient_id\r\n , patient_medications.claim_id\r\n , patient_medications.start_date\r\n , patient_medications.data_source\r\n , chronic_conditions.chronic_condition_type\r\n , chronic_conditions.condition_category\r\n , chronic_conditions.condition\r\n from patient_medications\r\n inner join chronic_conditions\r\n on patient_medications.code = chronic_conditions.code\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'NDC'\r\n and chronic_conditions.code not in {{ naltrexone_ndcs }}\r\n\r\n)\r\n\r\n/*\r\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\r\n alcohol or other drug use disorder where opioid DX is not present\r\n\r\n This CTE includes patients with evidence of the chronic conditions Alcohol\r\n Use Disorders or Drug Use Disorders.\r\n*/\r\n, exclusions_other_chronic_conditions as (\r\n\r\n select distinct patient_id\r\n from {{ ref('chronic_conditions__cms_chronic_conditions_all') }}\r\n where condition in (\r\n 'Alcohol Use Disorders'\r\n , 'Drug Use Disorders'\r\n )\r\n\r\n)\r\n\r\n/*\r\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\r\n alcohol or other drug use disorder where opioid DX is not present\r\n\r\n This CTE creates the exclusion list which consists of patients with\r\n medication encounters for Naltrexone having Alcohol Use Disorder or Drug\r\n Use Disorder and missing the Opioid Use Disorder diagnosis codes.\r\n*/\r\n, exclusions_medication as (\r\n select distinct\r\n patient_medications.patient_id\r\n from patient_medications\r\n inner join chronic_conditions\r\n on patient_medications.code = chronic_conditions.code\r\n inner join exclusions_other_chronic_conditions\r\n on patient_medications.patient_id = exclusions_other_chronic_conditions.patient_id\r\n left join inclusions_diagnosis\r\n on patient_medications.patient_id = inclusions_diagnosis.patient_id\r\n where chronic_conditions.inclusion_type = 'Include'\r\n and chronic_conditions.code_system = 'NDC'\r\n and chronic_conditions.code in {{ naltrexone_ndcs }}\r\n and inclusions_diagnosis.patient_id is null\r\n\r\n)\r\n\r\n{% if target.type == 'fabric' %}\r\n, inclusions_unioned as (\r\n\r\n select * from inclusions_diagnosis\r\n union\r\n select * from inclusions_procedure\r\n union\r\n select * from inclusions_medication\r\n\r\n)\r\n{% else %}\r\n, inclusions_unioned as (\r\n\r\n select * from inclusions_diagnosis\r\n union distinct\r\n select * from inclusions_procedure\r\n union distinct\r\n select * from inclusions_medication\r\n\r\n)\r\n{% endif %}\r\n\r\nselect distinct\r\n cast(inclusions_unioned.patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(inclusions_unioned.claim_id as {{ dbt.type_string() }}) as claim_id\r\n , cast(inclusions_unioned.start_date as date) as start_date\r\n , cast(inclusions_unioned.chronic_condition_type as {{ dbt.type_string() }}) as chronic_condition_type\r\n , cast(inclusions_unioned.condition_category as {{ dbt.type_string() }}) as condition_category\r\n , cast(inclusions_unioned.condition as {{ dbt.type_string() }}) as condition\r\n , cast(inclusions_unioned.data_source as {{ dbt.type_string() }}) as data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom inclusions_unioned\r\n left join exclusions_medication\r\n on inclusions_unioned.patient_id = exclusions_medication.patient_id\r\nwhere exclusions_medication.patient_id is null", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hierarchy", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__condition", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__pharmacy_claim", "package": null, "version": null}, {"name": "cms_chronic_conditions__stg_core__procedure", "package": null, "version": null}, {"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\intermediate\\chronic_conditions__cms_chronic_conditions_oud.sql", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim as (\n\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Opioid Use Disorder (OUD)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_medications as (\n\n select\n patient_id\n , claim_id\n , paid_date as start_date\n , replace(ndc_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE excludes medication encounters with the exception codes for\n Naltrexone. Those encounters will be evaluated separately.\n*/\n, inclusions_medication as (\n\n select\n patient_medications.patient_id\n , patient_medications.claim_id\n , patient_medications.start_date\n , patient_medications.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code not in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE includes patients with evidence of the chronic conditions Alcohol\n Use Disorders or Drug Use Disorders.\n*/\n, exclusions_other_chronic_conditions as (\n\n select distinct patient_id\n from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\n where condition in (\n 'Alcohol Use Disorders'\n , 'Drug Use Disorders'\n )\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE creates the exclusion list which consists of patients with\n medication encounters for Naltrexone having Alcohol Use Disorder or Drug\n Use Disorder and missing the Opioid Use Disorder diagnosis codes.\n*/\n, exclusions_medication as (\n select distinct\n patient_medications.patient_id\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n inner join exclusions_other_chronic_conditions\n on patient_medications.patient_id = exclusions_other_chronic_conditions.patient_id\n left join inclusions_diagnosis\n on patient_medications.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n and inclusions_diagnosis.patient_id is null\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_medication\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_medication\n on inclusions_unioned.patient_id = exclusions_medication.patient_id\nwhere exclusions_medication.patient_id is null", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim as (\n\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n)"}, {"id": "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "sql": " __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__condition": {"database": "dev_thuxuan", "schema": "test", "name": "cms_chronic_conditions__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\cms_chronic_conditions__stg_core__condition.sql", "original_file_path": "models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__condition.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__condition"], "alias": "cms_chronic_conditions__stg_core__condition", "checksum": {"name": "sha256", "checksum": "a70e41749804fd6e994d9e402d8009d0ac5056125b8406bd3b3c83d7bcb6b89b"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.140672, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , patient_id\r\n , recorded_date\r\n , normalized_code_type\r\n , normalized_code\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__condition') }}\r\nwhere claim_id is not null", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__condition.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim": {"database": "dev_thuxuan", "schema": "test", "name": "cms_chronic_conditions__stg_core__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\cms_chronic_conditions__stg_core__medical_claim.sql", "original_file_path": "models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__medical_claim.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__medical_claim"], "alias": "cms_chronic_conditions__stg_core__medical_claim", "checksum": {"name": "sha256", "checksum": "3a392212d527d486789c1567dafde1c4238bb623dafa7900d44faa249ae42889"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1436725, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , patient_id\r\n , claim_start_date\r\n , ms_drg_code\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medical_claim') }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__patient": {"database": "dev_thuxuan", "schema": "test", "name": "cms_chronic_conditions__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\cms_chronic_conditions__stg_core__patient.sql", "original_file_path": "models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__patient.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__patient"], "alias": "cms_chronic_conditions__stg_core__patient", "checksum": {"name": "sha256", "checksum": "07322cb7611f42c7a13dc4eb47bef985761aa7d22f76edf64f311600572837ed"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1416721, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n patient_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__patient.sql", "compiled": true, "compiled_code": "\n\nselect \n patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim": {"database": "dev_thuxuan", "schema": "test", "name": "cms_chronic_conditions__stg_core__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\cms_chronic_conditions__stg_core__pharmacy_claim.sql", "original_file_path": "models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__pharmacy_claim"], "alias": "cms_chronic_conditions__stg_core__pharmacy_claim", "checksum": {"name": "sha256", "checksum": "b40972c9ce5e62621a9e4cbf97d0e2df4c7b375891bb1bd5f9b379328c04cfe8"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1446724, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , patient_id\r\n , paid_date\r\n , ndc_code\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__pharmacy_claim') }}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure": {"database": "dev_thuxuan", "schema": "test", "name": "cms_chronic_conditions__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\cms_chronic_conditions__stg_core__procedure.sql", "original_file_path": "models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "cms_chronic_conditions__stg_core__procedure"], "alias": "cms_chronic_conditions__stg_core__procedure", "checksum": {"name": "sha256", "checksum": "53d00e7c521d7f492d420fda96b6d32320ec8fbb2cbdfe289086366cf25a24ce"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\cms_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": ["cms_chronic_conditions", "chronic_conditions"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.1426723, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_chronic_conditions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , patient_id\r\n , procedure_date\r\n , normalized_code_type\r\n , normalized_code\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__procedure') }}\r\nwhere claim_id is not null", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\cms_chronic_conditions__stg_core__procedure.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition": {"database": "dev_thuxuan", "schema": "test", "name": "tuva_chronic_conditions__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\tuva_chronic_conditions__stg_core__condition.sql", "original_file_path": "models\\chronic_conditions\\staging\\tuva_chronic_conditions__stg_core__condition.sql", "unique_id": "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "tuva_chronic_conditions__stg_core__condition"], "alias": "tuva_chronic_conditions__stg_core__condition", "checksum": {"name": "sha256", "checksum": "f370672047f2b026bd5104b700c770c40070642f54642308ade51083b49abd3d"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["tuva_chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": "tuva_chronic_conditions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.204971, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n patient_id\r\n , normalized_code\r\n , recorded_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__condition')}}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\tuva_chronic_conditions__stg_core__condition.sql", "compiled": true, "compiled_code": "\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient": {"database": "dev_thuxuan", "schema": "test", "name": "tuva_chronic_conditions__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "chronic_conditions\\staging\\tuva_chronic_conditions__stg_core__patient.sql", "original_file_path": "models\\chronic_conditions\\staging\\tuva_chronic_conditions__stg_core__patient.sql", "unique_id": "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient", "fqn": ["the_tuva_project", "chronic_conditions", "staging", "tuva_chronic_conditions__stg_core__patient"], "alias": "tuva_chronic_conditions__stg_core__patient", "checksum": {"name": "sha256", "checksum": "47a2c172b79fd191be1a9e81b8f5a936d1cfc42b4bfb4f24c5436c775ff9e8a5"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["tuva_chronic_conditions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["tuva_chronic_conditions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "build_path": null, "unrendered_config": {"tags": "tuva_chronic_conditions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2059793, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('tuva_chronic_conditions_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n patient_id\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\staging\\tuva_chronic_conditions__stg_core__patient.sql", "compiled": true, "compiled_code": "\n\nselect \n patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.medical_claim_expanded": {"database": "dev_thuxuan", "schema": "claims_expanded", "name": "medical_claim_expanded", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_expanded\\medical_claim_expanded.sql", "original_file_path": "models\\claims_expanded\\medical_claim_expanded.sql", "unique_id": "model.the_tuva_project.medical_claim_expanded", "fqn": ["the_tuva_project", "claims_expanded", "medical_claim_expanded"], "alias": "medical_claim_expanded", "checksum": {"name": "sha256", "checksum": "04ff66dd3885b586f0e72f7a5acbb9ece6c6a162a10835ee6e4d0893ea9b63c5"}, "config": {"enabled": true, "alias": null, "schema": "claims_expanded", "database": null, "tags": ["claims_expanded"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_expanded"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_expanded\\_claims_expanded_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_expanded", "materialized": "table", "tags": "claims_expanded", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2129796, "relation_name": "dev_thuxuan.claims_expanded.medical_claim_expanded", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect *\r\nfrom {{ ref('medical_claim') }}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_expanded\\medical_claim_expanded.sql", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom tuva.input_layer.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "claims_enrollment__flag_claims_with_enrollment", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\claims_enrollment\\claims_enrollment__flag_claims_with_enrollment.sql", "original_file_path": "models\\claims_preprocessing\\claims_enrollment\\claims_enrollment__flag_claims_with_enrollment.sql", "unique_id": "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "fqn": ["the_tuva_project", "claims_preprocessing", "claims_enrollment", "claims_enrollment__flag_claims_with_enrollment"], "alias": "flag_claims_with_enrollment", "checksum": {"name": "sha256", "checksum": "02f57ad0f67dcc27c6d122443c130dfe60bbd27ed23d6c69bdb4e0a2138b950f"}, "config": {"enabled": true, "alias": "flag_claims_with_enrollment", "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing"], "description": "This table contains claims with matching enrollment", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_start_year_month": {"name": "inferred_claim_start_year_month", "description": "The claim start date year and month. If claim line start date is missing then the following column will be used, \nin the following order if also NULL: claim start date, admission date\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_end_year_month": {"name": "inferred_claim_end_year_month", "description": "The claim end date year and month. If claim line end date is missing then the following column will be used, \nin the following order if also NULL: claim end date, discharge date\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_start_column_used": {"name": "inferred_claim_start_column_used", "description": "The name of the column used to populated inferred_claim_start_year_month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inferred_claim_end_column_used": {"name": "inferred_claim_end_column_used", "description": "The name of the column used to populated inferred_claim_start_column_used.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "flag_claims_with_enrollment", "tags": ["claims_preprocessing"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.217074, "relation_name": "dev_thuxuan.claims_preprocessing.flag_claims_with_enrollment", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith claim_dates as(\r\n select\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , coalesce(claim_line_start_date, claim_start_date, admission_date) as inferred_claim_start_date\r\n , coalesce(claim_line_end_date, claim_end_date, discharge_date) as inferred_claim_end_date\r\n , case\r\n when claim_line_start_date is not null then 'claim_line_start_date'\r\n when claim_line_start_date is null and claim_start_date is not null then 'claim_start_date'\r\n when claim_line_start_date is null and claim_start_date is null and admission_date is not null then 'admission_date'\r\n end as inferred_claim_start_column_used\r\n , case\r\n when claim_line_end_date is not null then 'claim_line_end_date'\r\n when claim_line_end_date is null and claim_end_date is not null then 'claim_end_date'\r\n when claim_line_end_date is null and claim_end_date is null and discharge_date is not null then 'discharge_date'\r\n end as inferred_claim_end_column_used\r\n from {{ ref('normalized_input__medical_claim') }}\r\n)\r\n\r\n, claim_year_month as(\r\n select\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , inferred_claim_start_date\r\n , inferred_claim_end_date\r\n , inferred_claim_start_column_used\r\n , inferred_claim_end_column_used\r\n\r\n , {{ dbt.concat([\r\n date_part('year', 'inferred_claim_start_date'),\r\n dbt.right(\r\n dbt.concat([\r\n \"'0'\",\r\n date_part('month', 'inferred_claim_start_date'),\r\n ]),\r\n 2\r\n )\r\n ]) }} as inferred_claim_start_year_month\r\n\r\n , {{ dbt.concat([\r\n date_part('year', 'inferred_claim_end_date'),\r\n dbt.right(\r\n dbt.concat([\r\n \"'0'\",\r\n date_part('month', 'inferred_claim_end_date'),\r\n ]),\r\n 2\r\n )\r\n ]) }} as inferred_claim_end_year_month\r\n\r\nfrom claim_dates\r\n\r\n)\r\n\r\nselect distinct\r\n claim.claim_id\r\n , claim.claim_line_number\r\n , claim.patient_id\r\n , claim.payer\r\n , claim.{{ quote_column('plan') }}\r\n , claim.inferred_claim_start_year_month\r\n , claim.inferred_claim_end_year_month\r\n , claim.inferred_claim_start_column_used\r\n , claim.inferred_claim_end_column_used\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('core__member_months')}} mm\r\ninner join claim_year_month claim\r\n on mm.patient_id = claim.patient_id\r\n and mm.payer = claim.payer\r\n and mm.{{ quote_column('plan') }} = claim.{{ quote_column('plan') }}\r\n and mm.year_month >= claim.inferred_claim_start_year_month\r\n and mm.year_month <= claim.inferred_claim_end_year_month", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.right", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\claims_enrollment\\claims_enrollment__flag_claims_with_enrollment.sql", "compiled": true, "compiled_code": "\n\n\nwith claim_dates as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , coalesce(claim_line_start_date, claim_start_date, admission_date) as inferred_claim_start_date\n , coalesce(claim_line_end_date, claim_end_date, discharge_date) as inferred_claim_end_date\n , case\n when claim_line_start_date is not null then 'claim_line_start_date'\n when claim_line_start_date is null and claim_start_date is not null then 'claim_start_date'\n when claim_line_start_date is null and claim_start_date is null and admission_date is not null then 'admission_date'\n end as inferred_claim_start_column_used\n , case\n when claim_line_end_date is not null then 'claim_line_end_date'\n when claim_line_end_date is null and claim_end_date is not null then 'claim_end_date'\n when claim_line_end_date is null and claim_end_date is null and discharge_date is not null then 'discharge_date'\n end as inferred_claim_end_column_used\n from dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\n)\n\n, claim_year_month as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , inferred_claim_start_date\n , inferred_claim_end_date\n , inferred_claim_start_column_used\n , inferred_claim_end_column_used\n\n , date_part('year', inferred_claim_start_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_start_date),\n 2\n )\n end as inferred_claim_start_year_month\n\n , date_part('year', inferred_claim_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_end_date),\n 2\n )\n end as inferred_claim_end_year_month\n\nfrom claim_dates\n\n)\n\nselect distinct\n claim.claim_id\n , claim.claim_line_number\n , claim.patient_id\n , claim.payer\n , claim.plan\n , claim.inferred_claim_start_year_month\n , claim.inferred_claim_end_year_month\n , claim.inferred_claim_start_column_used\n , claim.inferred_claim_end_column_used\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom dev_thuxuan.core.member_months mm\ninner join claim_year_month claim\n on mm.patient_id = claim.patient_id\n and mm.payer = claim.payer\n and mm.plan = claim.plan\n and mm.year_month >= claim.inferred_claim_start_year_month\n and mm.year_month <= claim.inferred_claim_end_year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "acute_inpatient__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\acute_inpatient__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\acute_inpatient__encounter_grain.sql", "unique_id": "model.the_tuva_project.acute_inpatient__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "acute_inpatient__encounter_grain"], "alias": "acute_inpatient__encounter_grain", "checksum": {"name": "sha256", "checksum": "258234b863eac448a8fe0f1dc35a9b9b125bc44166320bed5a07ae837a5c5e42"}, "config": {"enabled": true, "alias": "acute_inpatient__encounter_grain", "schema": "claims_preprocessing", "database": null, "tags": ["acute_inpatient", "claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["acute_inpatient", "claims_preprocessing", "encounters"], "description": "This table pulls together all the data needed to perform acute inpatient analytics into a single table.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "acute_inpatient__encounter_grain", "tags": ["acute_inpatient", "claims_preprocessing", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3157067, "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'acute inpatient'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('acute_inpatient__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n)\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when d.service_category_3 in ( 'l/d - cesarean delivery', 'l/d - vaginal delivery') then 1 else 0 end ) as delivery_flag\r\n ,max(case when d.service_category_3 ='l/d - cesarean delivery' then 1 else 0 end ) as cesarean_delivery\r\n ,max(case when d.service_category_3 ='l/d - vaginal delivery' then 1 else 0 end ) as vaginal_delivery\r\n ,max(case when d.service_category_3 in ('l/d - newborn','l/d - newborn nicu') then 1 else 0 end ) as newborn_flag\r\n ,max(case when d.service_category_3 ='l/d - newborn nicu' then 1 else 0 end ) as nicu_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type -- not changing grain, but bringing into final\r\n,encounter_group\r\n)\r\n\r\n\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, c.patient_data_source_id\r\n, tot.encounter_type\r\n, tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, c.facility_id as facility_id\r\n, sc.observation_flag\r\n, sc.ed_flag\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.delivery_flag\r\n, case when sc.cesarean_delivery = 1 then 'cesarean'\r\n when sc.vaginal_delivery = 1 then 'vaginal'\r\n else null end as delivery_type\r\n, sc.newborn_flag\r\n, sc.nicu_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, c.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('acute_inpatient__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "acute_inpatient__start_end_dates", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "acute_inpatient__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.encounters__stg_eligibility", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\acute_inpatient__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'acute inpatient'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when d.service_category_3 in ( 'l/d - cesarean delivery', 'l/d - vaginal delivery') then 1 else 0 end ) as delivery_flag\n ,max(case when d.service_category_3 ='l/d - cesarean delivery' then 1 else 0 end ) as cesarean_delivery\n ,max(case when d.service_category_3 ='l/d - vaginal delivery' then 1 else 0 end ) as vaginal_delivery\n ,max(case when d.service_category_3 in ('l/d - newborn','l/d - newborn nicu') then 1 else 0 end ) as newborn_flag\n ,max(case when d.service_category_3 ='l/d - newborn nicu' then 1 else 0 end ) as nicu_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n,encounter_group\n)\n\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, sc.observation_flag\n, sc.ed_flag\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.delivery_flag\n, case when sc.cesarean_delivery = 1 then 'cesarean'\n when sc.vaginal_delivery = 1 then 'vaginal'\n else null end as delivery_type\n, sc.newborn_flag\n, sc.nicu_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "ambulance__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\ambulance__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\ambulance__encounter_grain.sql", "unique_id": "model.the_tuva_project.ambulance__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "ambulance__encounter_grain"], "alias": "ambulance__encounter_grain", "checksum": {"name": "sha256", "checksum": "cd72c508a8b0e23c72e1429d949b48727801de18bfc5ca79c58fbd32a99d89ed"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per ambulance encounter id summarizing encounter level metrics. ambulances will roll up to other encounters unless they appear on their own day with no other claims.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4110909, "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('ambulance__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'ambulance - orphaned'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n, encounter_type -- not changing grain, but bringing into final\r\n, encounter_group\r\n\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_pos as \r\n(\r\n select encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where place_of_service_code is not null\r\n group by \r\n encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n)\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \r\n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, pos.place_of_service_code\r\n, pos.place_of_service_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\r\nand\r\npos.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "ambulance__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\ambulance__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.ambulance__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulance - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type -- not changing grain, but bringing into final\n, encounter_group\n\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "asc__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\asc__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\asc__encounter_grain.sql", "unique_id": "model.the_tuva_project.asc__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "asc__encounter_grain"], "alias": "asc__encounter_grain", "checksum": {"name": "sha256", "checksum": "3efab6f89cabbba9e45dbc1a8cf15e34bba8ae4d8d82ad1de57012e9f8838389"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per asc encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3631027, "relation_name": "dev_thuxuan.claims_preprocessing.asc__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,ed.encounter_start_date \r\n ,ed.encounter_end_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'ambulatory surgery center'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('asc__start_end_dates') }} ed on cli.old_encounter_id = ed.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_hcpc as \r\n(\r\n select encounter_id\r\n , hcpcs_code\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where hcpcs_code is not null\r\n group by \r\n encounter_id\r\n , hcpcs_code\r\n)\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \r\n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.encounter_end_date\r\n, d.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, {{ dbt.datediff(\"d.encounter_start_date\",\"d.encounter_end_date\",\"day\")}} as length_of_stay\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, hcpc.hcpcs_code\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\r\nand\r\nhcpc.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "asc__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.asc__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\asc__encounter_grain.sql", "compiled": true, "compiled_code": "\n\n\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,ed.encounter_start_date \n ,ed.encounter_end_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulatory surgery center'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.asc__start_end_dates ed on cli.old_encounter_id = ed.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, datediff(\n day,\n d.encounter_start_date,\n d.encounter_end_date\n ) as length_of_stay\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dialysis__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\dialysis__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\dialysis__encounter_grain.sql", "unique_id": "model.the_tuva_project.dialysis__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "dialysis__encounter_grain"], "alias": "dialysis__encounter_grain", "checksum": {"name": "sha256", "checksum": "cc90c80243e00f5ee3c5346758411575703c7b2ac86926a9cf7a3fa7dc9b7eeb"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per dialysis encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3661048, "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('dialysis__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'dialysis'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \r\n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "dialysis__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\dialysis__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.dialysis__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dialysis'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dme__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\dme__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\dme__encounter_grain.sql", "unique_id": "model.the_tuva_project.dme__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "dme__encounter_grain"], "alias": "dme__encounter_grain", "checksum": {"name": "sha256", "checksum": "56cb0771bd416df3c244c39428e99e883b8a219a861e35137ac47432aba155a9"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per dme encounter id summarizing encounter level metrics. dmes will roll up to other encounters unless they appear on their own day with no other claims.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4060886, "relation_name": "dev_thuxuan.claims_preprocessing.dme__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('dme__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'dme - orphaned'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_pos as \r\n(\r\n select encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where place_of_service_code is not null\r\n group by \r\n encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n)\r\n\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \r\n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, pos.place_of_service_code\r\n, pos.place_of_service_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\r\nand\r\npos.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "dme__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\dme__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.dme__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dme - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "emergency_department__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\emergency_department__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\emergency_department__encounter_grain.sql", "unique_id": "model.the_tuva_project.emergency_department__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "emergency_department__encounter_grain"], "alias": "emergency_department__encounter_grain", "checksum": {"name": "sha256", "checksum": "8ad82ac58d5d58ce142193bd0aac727115e02cbe61b07f77a65e2eb5e7ff2652"}, "config": {"enabled": true, "alias": "emergency_department__encounter_grain", "schema": "claims_preprocessing", "database": null, "tags": ["emergency_department", "claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["emergency_department", "claims_preprocessing", "encounters"], "description": "This table pulls together all the data needed to perform acute inpatient analytics into a single table.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "emergency_department__encounter_grain", "tags": ["emergency_department", "claims_preprocessing", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3197067, "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'emergency department'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('emergency_department__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n,encounter_header_values as (\r\n select distinct patient_data_source_id\r\n ,data_source\r\n ,encounter_id\r\n from detail_values\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n ,encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type -- not changing grain, but bringing into final\r\n, encounter_group\r\n)\r\n\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, ehv.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"a.encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, sc.observation_flag\r\n, c.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, ehv.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('emergency_department__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\ninner join encounter_header_values ehv on x.encounter_id = ehv.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "emergency_department__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "emergency_department__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\emergency_department__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'emergency department'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n,encounter_header_values as (\n select distinct patient_data_source_id\n ,data_source\n ,encounter_id\n from detail_values\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n, encounter_group\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, ehv.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n a.encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, sc.observation_flag\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, ehv.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\ninner join encounter_header_values ehv on x.encounter_id = ehv.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "home_health__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\home_health__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\home_health__encounter_grain.sql", "unique_id": "model.the_tuva_project.home_health__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "home_health__encounter_grain"], "alias": "home_health__encounter_grain", "checksum": {"name": "sha256", "checksum": "43c20c368307344ff2145662f03900a9a3a538a5822f57ea357f8a6b30a8e613"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3741207, "relation_name": "dev_thuxuan.claims_preprocessing.home_health__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('home_health__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'home health'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \r\n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "home_health__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.home_health__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\home_health__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.home_health__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'home health'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_hospice__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\inpatient_hospice__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\inpatient_hospice__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_hospice__encounter_grain"], "alias": "inpatient_hospice__encounter_grain", "checksum": {"name": "sha256", "checksum": "7a7316439fe042a0d7b7b9284431d0db0d04ef15c480e6768073a2c39992c6f4"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3371055, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'inpatient hospice'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('inpatient_hospice__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n ,encounter_type\r\n ,encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n, encounter_group\r\n\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, c.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, c.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, sc.ed_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, c.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('inpatient_hospice__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_hospice__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_hospice__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_hospice__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\inpatient_hospice__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n ,encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_psych__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\inpatient_psych__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\inpatient_psych__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_psych__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_psych__encounter_grain"], "alias": "inpatient_psych__encounter_grain", "checksum": {"name": "sha256", "checksum": "bd8c0ae5c5ab195a8a67988a716c790138e32b17e0cb5debfc5070f9baec1372"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient psych. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3237069, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'inpatient psych'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('inpatient_psych__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n ,encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type\r\n, encounter_group\r\n\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, c.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, c.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, sc.ed_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, c.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('inpatient_psych__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_psych__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_psych__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_psych__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\inpatient_psych__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_rehab__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\inpatient_rehab__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\inpatient_rehab__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_rehab__encounter_grain"], "alias": "inpatient_rehab__encounter_grain", "checksum": {"name": "sha256", "checksum": "906e174cced2ecde2e28d3542a93fe1804d633dd61070f387e8bdf12d7ea57a7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.326707, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'inpatient rehabilitation'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('inpatient_rehab__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n, encounter_group\r\n ,encounter_type\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type\r\n, encounter_group\r\n\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, c.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, c.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, sc.ed_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, c.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('inpatient_rehab__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_rehab__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_rehab__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_rehab__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\inpatient_rehab__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n, encounter_group\n ,encounter_type\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_snf__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\inpatient_snf__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\inpatient_snf__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_snf__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_snf__encounter_grain"], "alias": "inpatient_snf__encounter_grain", "checksum": {"name": "sha256", "checksum": "fcf0aec7fa12e47b7f68bd4b641655056ed63a5a5967b8d61d7535e00358c684"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.330104, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'inpatient skilled nursing'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('inpatient_snf__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n ,encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n, encounter_type\r\n, encounter_group\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, c.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, c.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, sc.ed_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, c.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('inpatient_snf__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_snf__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_snf__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_snf__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\inpatient_snf__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient skilled nursing'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_substance_use__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\inpatient_substance_use__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\inpatient_substance_use__encounter_grain.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "inpatient_substance_use__encounter_grain"], "alias": "inpatient_substance_use__encounter_grain", "checksum": {"name": "sha256", "checksum": "951ce974821a0e36016df2b2d5d11656f6fdd15c561babb4a68c65530223a05a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Encounters for inpatient rehab. One row per encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3341053, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,ed.encounter_start_date\r\n ,ed.encounter_end_date\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'inpatient substance use'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join {{ ref('inpatient_substance_use__start_end_dates') }} ed on cli.old_encounter_id = ed.encounter_id\r\n)\r\n\r\n,encounter_cross_walk as (\r\n select distinct encounter_id\r\n ,old_encounter_id\r\n from detail_values\r\n)\r\n\r\n,first_last_inst_inst_values as (\r\nselect *\r\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\r\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\r\nfrom detail_values\r\nwhere claim_type = 'institutional'\r\n)\r\n\r\n, institutional_claim_details as (\r\n select distinct\r\n d.encounter_id\r\n , f.diagnosis_code_1\r\n , f.diagnosis_code_type\r\n , f.facility_id as facility_id\r\n , f.ms_drg_code as ms_drg_code\r\n , f.apr_drg_code as apr_drg_code\r\n , f.admit_source_code as admit_source_code\r\n , f.admit_type_code as admit_type_code\r\n , l.discharge_disposition_code as discharge_disposition_code\r\n , d.patient_data_source_id\r\n , d.data_source\r\n from detail_values d\r\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\r\n and\r\n f.first_num =1 \r\n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\r\n and\r\n l.last_num = 1 \r\n\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n, encounter_type\r\n, encounter_group\r\n\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect\r\n x.encounter_id\r\n, a.encounter_start_date\r\n, a.encounter_end_date\r\n, c.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"encounter_end_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, c.diagnosis_code_type as primary_diagnosis_code_type\r\n, c.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, c.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, sc.ed_flag\r\n, c.ms_drg_code\r\n, j.ms_drg_description\r\n, j.medical_surgical\r\n, c.apr_drg_code\r\n, k.apr_drg_description\r\n, c.admit_source_code\r\n, h.admit_source_description\r\n, c.admit_type_code\r\n, i.admit_type_description\r\n, c.discharge_disposition_code\r\n, g.discharge_disposition_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, {{ dbt.datediff(\"a.encounter_start_date\",\"a.encounter_end_date\",\"day\") }} as length_of_stay\r\n, case\r\n when c.discharge_disposition_code = '20' then 1\r\n else 0\r\n end mortality_flag\r\n, c.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('inpatient_substance_use__start_end_dates') }} a\r\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\r\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\r\nleft join institutional_claim_details c\r\n on x.encounter_id = c.encounter_id\r\nleft join patient e\r\n on c.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on c.facility_id = b.npi\r\nleft join {{ ref('terminology__discharge_disposition') }} g\r\n on c.discharge_disposition_code = g.discharge_disposition_code\r\nleft join {{ ref('terminology__admit_source') }} h\r\n on c.admit_source_code = h.admit_source_code\r\nleft join {{ ref('terminology__admit_type') }} i\r\n on c.admit_type_code = i.admit_type_code\r\nleft join {{ ref('terminology__ms_drg') }} j\r\n on c.ms_drg_code = j.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg') }} k\r\n on c.apr_drg_code = k.apr_drg_code\r\nleft join {{ ref('terminology__icd_10_cm')}} icd10cm\r\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and c.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm')}} icd9cm\r\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and c.diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "inpatient_substance_use__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "inpatient_substance_use__start_end_dates", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_substance_use__start_end_dates", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\inpatient_substance_use__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "lab__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\lab__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\lab__encounter_grain.sql", "unique_id": "model.the_tuva_project.lab__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "lab__encounter_grain"], "alias": "lab__encounter_grain", "checksum": {"name": "sha256", "checksum": "70002fa37733409540466e1cf7b8181a9276f9900c52ebd2615b97cb57127bcf"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per lab encounter id summarizing encounter level metrics. labs will roll up to other encounters unless they appear on their own day with no other claims.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4005122, "relation_name": "dev_thuxuan.claims_preprocessing.lab__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('lab__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'lab - orphaned'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_pos as \r\n(\r\n select encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where place_of_service_code is not null\r\n group by \r\n encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n)\r\n\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \r\n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, pos.place_of_service_code\r\n, pos.place_of_service_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\r\nand\r\npos.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "lab__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.lab__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\lab__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.lab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'lab - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visit__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visit__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\office_visit__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\office_visit__encounter_grain.sql", "unique_id": "model.the_tuva_project.office_visit__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "office_visit__encounter_grain"], "alias": "office_visit__encounter_grain", "checksum": {"name": "sha256", "checksum": "1f9bfd4f1975574674f8d196640dc4d7b0ba05985ac8b4b3e1d91b5ba48e6149"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient office visit surgery encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3945022, "relation_name": "dev_thuxuan.claims_preprocessing.office_visit__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'office visit surgery' as encounter_type\r\n from {{ ref('office_visits__int_office_visits_surgery') }}\r\n\r\n union all\r\n\r\nselect distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'office visit injections' as encounter_type\r\n from {{ ref('office_visits__int_office_visits_injections') }}\r\n\r\n union all \r\n\r\nselect distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'office visit radiology' as encounter_type\r\n from {{ ref('office_visits__int_office_visits_radiology') }}\r\n\r\n union all\r\n\r\nselect distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'office visit - other' as encounter_type\r\n from {{ ref('office_visits__int_office_visits') }}\r\n\r\n union all \r\n\r\nselect distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'office visit' as encounter_type\r\n from {{ ref('office_visits__int_office_visits_em') }}\r\n\r\n union all \r\n\r\nselect distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'telehealth' as encounter_type\r\n from {{ ref('office_visits__int_office_visits_telehealth') }}\r\n\r\n union all \r\n\r\nselect distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n ,'office visit pt/ot/st' as encounter_type\r\n from {{ ref('office_visits__int_office_visits') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_group = 'office based'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n and\r\n d.encounter_type = cli.encounter_type\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_physician as \r\n(\r\n select encounter_id\r\n , billing_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where billing_id is not null\r\n group by \r\n encounter_id\r\n , billing_id\r\n)\r\n\r\n,highest_paid_hcpc as \r\n(\r\n select encounter_id\r\n , hcpcs_code\r\n , ccs_category\r\n , ccs_category_description\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where hcpcs_code is not null\r\n group by \r\n encounter_id\r\n , hcpcs_code\r\n , ccs_category\r\n , ccs_category_description\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, phy.billing_id\r\n, {{ dbt.concat([\"b2.provider_first_name\", \"' '\", \"b2.provider_last_name\"]) }} as provider_name\r\n, b2.primary_specialty_description as provider_specialty\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, hcpc.hcpcs_code\r\n, hcpc.ccs_category\r\n, hcpc.ccs_category_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_physician phy on d.encounter_id = phy.encounter_id\r\nand\r\nphy.paid_order = 1\r\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\r\nand\r\nhcpc.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__provider') }} b2\r\n on phy.billing_id = b2.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_surgery", "package": null, "version": null}, {"name": "office_visits__int_office_visits_injections", "package": null, "version": null}, {"name": "office_visits__int_office_visits_radiology", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "office_visits__int_office_visits_em", "package": null, "version": null}, {"name": "office_visits__int_office_visits_telehealth", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\office_visit__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit surgery' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_surgery\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit injections' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_injections\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit radiology' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_radiology\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit - other' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_em\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'telehealth' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit pt/ot/st' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_group = 'office based'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n and\n d.encounter_type = cli.encounter_type\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_physician as \n(\n select encounter_id\n , billing_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where billing_id is not null\n group by \n encounter_id\n , billing_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, phy.billing_id\n, b2.provider_first_name || ' ' || b2.provider_last_name as provider_name\n, b2.primary_specialty_description as provider_specialty\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, hcpc.ccs_category\n, hcpc.ccs_category_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_physician phy on d.encounter_id = phy.encounter_id\nand\nphy.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.provider b2\n on phy.billing_id = b2.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.orphaned_claim__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "orphaned_claim__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\orphaned_claim__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\orphaned_claim__encounter_grain.sql", "unique_id": "model.the_tuva_project.orphaned_claim__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "orphaned_claim__encounter_grain"], "alias": "orphaned_claim__encounter_grain", "checksum": {"name": "sha256", "checksum": "672ed92ee28fff09947010b94dde20af2aeff4f9b85a7249308a11215106aae7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "orphaned claims (usually professional claims) that don't roll up to an anchor event, get assigned their own encounter id for completeness.", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4150908, "relation_name": "dev_thuxuan.claims_preprocessing.orphaned_claim__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select\r\n cli.encounter_id\r\n , min(stg.start_date) as encounter_start_date\r\n , max(stg.start_date) as encounter_end_date\r\n from {{ ref('encounters__stg_medical_claim') }} as stg\r\n inner join {{ ref('encounters__orphaned_claims') }} as cli\r\n on stg.claim_id = cli.claim_id\r\n and stg.claim_line_number = cli.claim_line_number\r\n group by\r\n cli.encounter_id\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n ,d.encounter_end_date\r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__orphaned_claims') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n inner join encounter_date d on cli.encounter_id = d.encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_pos as \r\n(\r\n select encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where place_of_service_code is not null\r\n group by \r\n encounter_id\r\n , place_of_service_code\r\n , place_of_service_description\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.encounter_end_date\r\n, d.patient_data_source_id\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, pos.place_of_service_code\r\n, pos.place_of_service_description\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\r\nand\r\npos.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__orphaned_claims", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__orphaned_claims", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\orphaned_claim__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select\n cli.encounter_id\n , min(stg.start_date) as encounter_start_date\n , max(stg.start_date) as encounter_end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as stg\n inner join dev_thuxuan.claims_preprocessing.encounters__orphaned_claims as cli\n on stg.claim_id = cli.claim_id\n and stg.claim_line_number = cli.claim_line_number\n group by\n cli.encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n ,d.encounter_end_date\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__orphaned_claims cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n inner join encounter_date d on cli.encounter_id = d.encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospice__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_hospice__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_hospice__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_hospice__encounter_grain"], "alias": "outpatient_hospice__encounter_grain", "checksum": {"name": "sha256", "checksum": "638e83d012ff3c031f09b36237695423f342bd4b9d58b1aced419765dbf2077c"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3701048, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_hospice__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient hospice'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n, tot.encounter_type\r\n, tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_hospice__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_hospice__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_hospice__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_hospice__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_hospital_or_clinic__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_hospital_or_clinic__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_hospital_or_clinic__encounter_grain"], "alias": "outpatient_hospital_or_clinic__encounter_grain", "checksum": {"name": "sha256", "checksum": "d48706307ae59b60cdb446979b1b9da91049516bcfc8dc4759ab12f922cde0ed"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient rehab encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3561203, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_hospital_or_clinic__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient hospital or clinic'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_hospital_or_clinic__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_hospital_or_clinic__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospital or clinic'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_injections__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_injections__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_injections__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_injections__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_injections__encounter_grain"], "alias": "outpatient_injections__encounter_grain", "checksum": {"name": "sha256", "checksum": "bea37bcf6732d7e52ce02ff26b58e13259a78664e77478fb5a88e709545cdbd1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3771203, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_injections__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient injections'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,highest_paid_hcpc as \r\n(\r\n select encounter_id\r\n , hcpcs_code\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where substring(hcpcs_code,1,1)='J'\r\n\r\n group by \r\n encounter_id\r\n , hcpcs_code\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, hcpc.hcpcs_code\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\r\nand\r\nhcpc.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_injections__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_injections__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_injections__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_injections__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient injections'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where substring(hcpcs_code,1,1)='J'\n\n group by \n encounter_id\n , hcpcs_code\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_psych__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_psych__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_psych__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_psych__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_psych__encounter_grain"], "alias": "outpatient_psych__encounter_grain", "checksum": {"name": "sha256", "checksum": "8c80ee1bfdc18629bb3233d54de397fb85a8a67f6800eff2c5afba8b53309341"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient psych encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.349119, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_psych__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient psych'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_psych__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_psych__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_psych__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_psych__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_ptotst__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_ptotst__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_ptotst__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_ptotst__encounter_grain"], "alias": "outpatient_ptotst__encounter_grain", "checksum": {"name": "sha256", "checksum": "76cebd56ee4ecd0df62e2644cd2ef2f7100da7137f8b1cc5f0d5f2040f8edbbf"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3841038, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_ptotst__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient pt/ot/st'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_ptotst__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_ptotst__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_ptotst__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient pt/ot/st'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_radiology__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_radiology__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_radiology__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_radiology__encounter_grain"], "alias": "outpatient_radiology__encounter_grain", "checksum": {"name": "sha256", "checksum": "adb2ae955a24d3c7f1f9b8110bcf920e9d459cee99e2067835add481fa67784e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient radiology encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.388105, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_radiology__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient radiology'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n,hcpcs_code as \r\n(\r\n select distinct hcpcs_code\r\n ,encounter_id\r\n from detail_values\r\n\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, hcpc.hcpcs_code\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join hcpcs_code hcpc on d.encounter_id = hcpc.encounter_id\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_radiology__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_radiology__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_radiology__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_radiology__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient radiology'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,hcpcs_code as \n(\n select distinct hcpcs_code\n ,encounter_id\n from detail_values\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join hcpcs_code hcpc on d.encounter_id = hcpc.encounter_id\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_rehab__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_rehab__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_rehab__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_rehab__encounter_grain"], "alias": "outpatient_rehab__encounter_grain", "checksum": {"name": "sha256", "checksum": "c1b94d24b568448589505d2c8625424f07b142664c98bc0314500798087472bc"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient rehab encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.35212, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_rehab__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient rehabilitation'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_rehab__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_rehab__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_rehab__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_rehab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_substance_use__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_substance_use__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_substance_use__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_substance_use__encounter_grain"], "alias": "outpatient_substance_use__encounter_grain", "checksum": {"name": "sha256", "checksum": "84a961c27e24693c7c725fdb8b662ea1c687709a6186c765be5ae30e93350f8b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient hospice encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3811193, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_substance_use__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient substance use'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_substance_use__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_substance_use__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_substance_use__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_surgery__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\outpatient_surgery__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\outpatient_surgery__encounter_grain.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "outpatient_surgery__encounter_grain"], "alias": "outpatient_surgery__encounter_grain", "checksum": {"name": "sha256", "checksum": "651b46417814ca9f1710755ee152eefe7ef2e13d5fdb6e656056082eca109d38"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per outpatient rehab encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3591034, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('outpatient_surgery__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'outpatient surgery'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "outpatient_surgery__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.outpatient_surgery__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\outpatient_surgery__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_surgery__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient surgery'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__encounter_grain": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "urgent_care__encounter_grain", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\final\\urgent_care__encounter_grain.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\final\\urgent_care__encounter_grain.sql", "unique_id": "model.the_tuva_project.urgent_care__encounter_grain", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "final", "urgent_care__encounter_grain"], "alias": "urgent_care__encounter_grain", "checksum": {"name": "sha256", "checksum": "ed4d079f31513edf3fa1eb4ba93489d80c79f29a02630c79bc26853fd93ef6b1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "one row per urgent care encounter id summarizing encounter level metrics", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3451157, "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__encounter_grain", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith encounter_date as (\r\n select distinct old_encounter_id\r\n ,start_date as encounter_start_date\r\n from {{ ref('urgent_care__generate_encounter_id') }}\r\n)\r\n\r\n,detail_values as (\r\n select stg.*\r\n ,cli.encounter_id\r\n ,cli.old_encounter_id\r\n ,cli.encounter_type\r\n ,cli.encounter_group\r\n ,d.encounter_start_date \r\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n inner join {{ ref('encounters__combined_claim_line_crosswalk') }} cli on stg.claim_id = cli.claim_id \r\n and\r\n stg.claim_line_number = cli.claim_line_number\r\n and\r\n cli.encounter_type = 'urgent care'\r\n and\r\n cli.claim_line_attribution_number = 1\r\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\r\n)\r\n\r\n, patient as (\r\n select \r\n patient_data_source_id\r\n , birth_date\r\n , gender\r\n , race\r\n from {{ ref('encounters__stg_eligibility') }}\r\n where patient_row_num = 1\r\n )\r\n\r\n, total_amounts as (\r\n select \r\n encounter_id\r\n , encounter_type\r\n , encounter_group\r\n , sum(paid_amount) as total_paid_amount\r\n , sum(allowed_amount) as total_allowed_amount\r\n , sum(charge_amount) as total_charge_amount\r\n , count(distinct claim_id) as claim_count\r\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\r\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\r\nfrom detail_values\r\ngroup by encounter_id\r\n,encounter_type \r\n,encounter_group\r\n)\r\n\r\n\r\n,highest_paid_diagnosis as \r\n(\r\n select encounter_id\r\n , diagnosis_code_1\r\n , diagnosis_code_type\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where diagnosis_code_1 is not null\r\n group by diagnosis_code_1\r\n , encounter_id\r\n , diagnosis_code_type\r\n)\r\n\r\n,highest_paid_facility as \r\n(\r\n select encounter_id\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\r\n , sum(paid_amount) as paid_amount\r\n from detail_values\r\n where facility_id is not null\r\n group by \r\n encounter_id\r\n , facility_id\r\n)\r\n\r\n\r\n\r\n, service_category_flags as (\r\n select distinct\r\n d.encounter_id\r\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\r\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\r\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\r\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\r\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \r\n else 0 end) as pharmacy_flag\r\n from detail_values d\r\n left join {{ ref('service_category__service_category_grouper') }} scr on d.claim_id = scr.claim_id \r\n and\r\n scr.claim_line_number = d.claim_line_number\r\n group by d.encounter_id\r\n)\r\n\r\n\r\nselect d.encounter_id\r\n, d.encounter_start_date\r\n, d.patient_data_source_id\r\n\r\n,tot.encounter_type\r\n,tot.encounter_group\r\n, {{ dbt.datediff(\"birth_date\",\"d.encounter_start_date\",\"day\")}}/365 as admit_age\r\n, e.gender\r\n, e.race\r\n, hp.diagnosis_code_type as primary_diagnosis_code_type\r\n, hp.diagnosis_code_1 as primary_diagnosis_code\r\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\r\n, hf.facility_id as facility_id\r\n, b.provider_organization_name as facility_name\r\n, b.primary_specialty_description as facility_type\r\n, sc.lab_flag\r\n, sc.dme_flag\r\n, sc.ambulance_flag\r\n, sc.pharmacy_flag\r\n, sc.observation_flag\r\n, tot.total_paid_amount\r\n, tot.total_allowed_amount\r\n, tot.total_charge_amount\r\n, tot.claim_count\r\n, tot.inst_claim_count\r\n, tot.prof_claim_count\r\n, d.data_source\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom detail_values d\r\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\r\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\r\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\r\nand\r\nhp.paid_order = 1\r\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\r\nand\r\nhf.paid_order = 1\r\nleft join patient e\r\n on d.patient_data_source_id = e.patient_data_source_id\r\nleft join {{ ref('terminology__provider') }} b\r\n on hf.facility_id = b.npi\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\r\n and hp.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\r\n and hp.diagnosis_code_type = 'icd-9-cm'\r\nwhere d.encounter_row_number = 1", "language": "sql", "refs": [{"name": "urgent_care__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__stg_eligibility", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.urgent_care__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\final\\urgent_care__encounter_grain.sql", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.urgent_care__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'urgent care'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__combined_claim_line_crosswalk": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__combined_claim_line_crosswalk", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\encounters__combined_claim_line_crosswalk.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\encounters__combined_claim_line_crosswalk.sql", "unique_id": "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "encounters__combined_claim_line_crosswalk"], "alias": "encounters__combined_claim_line_crosswalk", "checksum": {"name": "sha256", "checksum": "cba84658aedf0ddb470b358f40644afc4f8da700c4d7e59adffd0b46c0b69949"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "all claim lines that belong to an encounter", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_age": {"name": "admit_age", "description": "The age of the patient at the time of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "A flag or code indicating if the service was medical or surgical.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid_amount": {"name": "total_paid_amount", "description": "The total amount paid for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed_amount": {"name": "total_allowed_amount", "description": "The total amount allowed by the insurance company for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_charge_amount": {"name": "total_charge_amount", "description": "The total amount charged for all services in the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mortality_flag": {"name": "mortality_flag", "description": "A flag indicating if the patient died during the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3401048, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith cte as \r\n(\r\nselect claim_id\r\n ,claim_line_number\r\n ,encounter_id\r\n ,'acute inpatient' as encounter_type\r\n ,'inpatient' as encounter_group\r\n ,0 as priority_number\r\nfrom {{ ref('acute_inpatient__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all\r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'acute inpatient' as encounter_type\r\n,'inpatient' as encounter_group\r\n,0 as priority_number\r\nfrom {{ ref('acute_inpatient__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n ,claim_line_number\r\n ,encounter_id\r\n ,'emergency department' as encounter_type\r\n ,'outpatient' as encounter_group\r\n ,1 as priority_number\r\nfrom {{ ref('acute_inpatient__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all\r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'emergency department' as encounter_type\r\n,'outpatient' as encounter_group\r\n,1 as priority_number\r\nfrom {{ ref('emergency_department__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n ,claim_line_number\r\n ,encounter_id\r\n ,'emergency department' as encounter_type\r\n ,'outpatient' as encounter_group\r\n ,1 as priority_number\r\nfrom {{ ref('emergency_department__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all\r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'inpatient hospice' as encounter_type\r\n,'inpatient' as encounter_group\r\n,1 as priority_number\r\nfrom {{ ref('inpatient_hospice__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,encounter_id\r\n,'inpatient psych' as encounter_type\r\n,'inpatient' as encounter_group\r\n,2 as priority_number\r\nfrom {{ ref('inpatient_psych__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all\r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'inpatient psych' as encounter_type\r\n,'inpatient' as encounter_group\r\n,2 as priority_number\r\nfrom {{ ref('inpatient_psych__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,encounter_id\r\n,'inpatient rehabilitation' as encounter_type\r\n,'inpatient' as encounter_group\r\n,3 as priority_number\r\nfrom {{ ref('inpatient_rehab__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all \r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'inpatient rehabilitation' as encounter_type\r\n,'inpatient' as encounter_group\r\n,3 as priority_number\r\nfrom {{ ref('inpatient_rehab__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,encounter_id\r\n,'inpatient skilled nursing' as encounter_type\r\n,'inpatient' as encounter_group\r\n,4 as priority_number\r\nfrom {{ ref('inpatient_snf__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all \r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'inpatient skilled nursing' as encounter_type\r\n,'inpatient' as encounter_group\r\n,4 as priority_number\r\nfrom {{ ref('inpatient_snf__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,encounter_id\r\n,'inpatient substance use' as encounter_type\r\n,'inpatient' as encounter_group\r\n,5 as priority_number\r\nfrom {{ ref('inpatient_substance_use__prof_claims') }}\r\nwhere claim_attribution_number = 1\r\n\r\nunion all \r\n\r\nselect enc.claim_id\r\n,med.claim_line_number\r\n,enc.encounter_id\r\n,'inpatient substance use' as encounter_type\r\n,'inpatient' as encounter_group\r\n,5 as priority_number\r\nfrom {{ ref('inpatient_substance_use__generate_encounter_id') }} enc\r\ninner join {{ ref('encounters__stg_medical_claim') }} med on enc.claim_id = med.claim_id\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,encounter_type\r\n,'office based' as encounter_group\r\n,9 as priority_number --priority set in combined office visit encounter ranking model\r\nfrom {{ ref('office_visits__int_office_visits_claim_line') }}\r\nwhere encounter_type = 'office visit radiology'\r\n\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,encounter_type\r\n,'office based' as encounter_group\r\n,10 as priority_number --priority set in combined office visit encounter ranking model\r\nfrom {{ ref('office_visits__int_office_visits_claim_line') }}\r\nwhere encounter_type <> 'office visit radiology'\r\n\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'urgent care' as encounter_type\r\n,'outpatient' as encounter_group\r\n,11 as priority_number --urgent care needs to be lower than ed and inpatient\r\nfrom {{ ref('urgent_care__match_claims_to_anchor') }}\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient psych' as encounter_type\r\n,'outpatient' as encounter_group\r\n,12 as priority_number \r\nfrom {{ ref('outpatient_psych__match_claims_to_anchor') }}\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient rehabilitation' as encounter_type\r\n,'outpatient' as encounter_group\r\n,13 as priority_number \r\nfrom {{ ref('outpatient_rehab__match_claims_to_anchor') }}\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'ambulatory surgery center' as encounter_type\r\n,'outpatient' as encounter_group\r\n,14 as priority_number \r\nfrom {{ ref('asc__match_claims_to_anchor') }}\r\n\r\nunion all\r\n\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient hospital or clinic' as encounter_type\r\n,'outpatient' as encounter_group\r\n,999 as priority_number \r\nfrom {{ ref('outpatient_hospital_or_clinic__match_claims_to_anchor') }} --lowest outpatient priority, roll up to more specific encounter type when available\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient surgery' as encounter_type\r\n,'outpatient' as encounter_group\r\n,18 as priority_number \r\nfrom {{ ref('outpatient_surgery__match_claims_to_anchor') }} \r\n\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'dialysis' as encounter_type\r\n,'outpatient' as encounter_group\r\n,15 as priority_number \r\nfrom {{ ref('dialysis__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient hospice' as encounter_type\r\n,'outpatient' as encounter_group\r\n,16 as priority_number \r\nfrom {{ ref('outpatient_hospice__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'home health' as encounter_type\r\n,'outpatient' as encounter_group\r\n,17 as priority_number \r\nfrom {{ ref('home_health__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient injections' as encounter_type\r\n,'outpatient' as encounter_group\r\n,19 as priority_number \r\nfrom {{ ref('outpatient_injections__match_claims_to_anchor') }}\r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient pt/ot/st' as encounter_type\r\n,'outpatient' as encounter_group\r\n,20 as priority_number \r\nfrom {{ ref('outpatient_ptotst__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient substance use' as encounter_type\r\n,'outpatient' as encounter_group\r\n,21 as priority_number \r\nfrom {{ ref('outpatient_substance_use__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'outpatient radiology' as encounter_type\r\n,'outpatient' as encounter_group\r\n,22 as priority_number \r\nfrom {{ ref('outpatient_radiology__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'lab - orphaned' as encounter_type\r\n,'other' as encounter_group\r\n,1000000 as priority_number \r\nfrom {{ ref('lab__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'dme - orphaned' as encounter_type\r\n,'other' as encounter_group\r\n,1000001 as priority_number \r\nfrom {{ ref('dme__match_claims_to_anchor') }} \r\n\r\nunion all\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'ambulance - orphaned' as encounter_type\r\n,'other' as encounter_group\r\n,1000002 as priority_number \r\nfrom {{ ref('ambulance__match_claims_to_anchor') }} \r\n\r\n)\r\n\r\n\r\nselect \r\n claim_id\r\n, claim_line_number\r\n, encounter_id as old_encounter_id\r\n, dense_rank() over (order by encounter_type, encounter_id) as encounter_id\r\n, encounter_type\r\n, encounter_group\r\n, priority_number\r\n, row_number() over (partition by claim_id , claim_line_number order by priority_number) as claim_line_attribution_number\r\nfrom cte", "language": "sql", "refs": [{"name": "acute_inpatient__prof_claims", "package": null, "version": null}, {"name": "acute_inpatient__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "acute_inpatient__prof_claims", "package": null, "version": null}, {"name": "emergency_department__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "emergency_department__prof_claims", "package": null, "version": null}, {"name": "inpatient_hospice__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_psych__prof_claims", "package": null, "version": null}, {"name": "inpatient_psych__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_rehab__prof_claims", "package": null, "version": null}, {"name": "inpatient_rehab__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_snf__prof_claims", "package": null, "version": null}, {"name": "inpatient_snf__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "inpatient_substance_use__prof_claims", "package": null, "version": null}, {"name": "inpatient_substance_use__generate_encounter_id", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "office_visits__int_office_visits_claim_line", "package": null, "version": null}, {"name": "office_visits__int_office_visits_claim_line", "package": null, "version": null}, {"name": "urgent_care__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_psych__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_rehab__match_claims_to_anchor", "package": null, "version": null}, {"name": "asc__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_surgery__match_claims_to_anchor", "package": null, "version": null}, {"name": "dialysis__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_hospice__match_claims_to_anchor", "package": null, "version": null}, {"name": "home_health__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_injections__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_ptotst__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_substance_use__match_claims_to_anchor", "package": null, "version": null}, {"name": "outpatient_radiology__match_claims_to_anchor", "package": null, "version": null}, {"name": "lab__match_claims_to_anchor", "package": null, "version": null}, {"name": "dme__match_claims_to_anchor", "package": null, "version": null}, {"name": "ambulance__match_claims_to_anchor", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.office_visits__int_office_visits_claim_line", "model.the_tuva_project.urgent_care__match_claims_to_anchor", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "model.the_tuva_project.asc__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "model.the_tuva_project.dialysis__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "model.the_tuva_project.home_health__match_claims_to_anchor", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "model.the_tuva_project.lab__match_claims_to_anchor", "model.the_tuva_project.dme__match_claims_to_anchor", "model.the_tuva_project.ambulance__match_claims_to_anchor"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\encounters__combined_claim_line_crosswalk.sql", "compiled": true, "compiled_code": "\n\nwith cte as \n(\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'acute inpatient' as encounter_type\n ,'inpatient' as encounter_group\n ,0 as priority_number\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'acute inpatient' as encounter_type\n,'inpatient' as encounter_group\n,0 as priority_number\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'emergency department' as encounter_type\n,'outpatient' as encounter_group\n,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.emergency_department__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient hospice' as encounter_type\n,'inpatient' as encounter_group\n,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,9 as priority_number --priority set in combined office visit encounter ranking model\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type = 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,10 as priority_number --priority set in combined office visit encounter ranking model\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type <> 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'urgent care' as encounter_type\n,'outpatient' as encounter_group\n,11 as priority_number --urgent care needs to be lower than ed and inpatient\nfrom dev_thuxuan.claims_preprocessing.urgent_care__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient psych' as encounter_type\n,'outpatient' as encounter_group\n,12 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_psych__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient rehabilitation' as encounter_type\n,'outpatient' as encounter_group\n,13 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_rehab__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulatory surgery center' as encounter_type\n,'outpatient' as encounter_group\n,14 as priority_number \nfrom dev_thuxuan.claims_preprocessing.asc__match_claims_to_anchor\n\nunion all\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospital or clinic' as encounter_type\n,'outpatient' as encounter_group\n,999 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor --lowest outpatient priority, roll up to more specific encounter type when available\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient surgery' as encounter_type\n,'outpatient' as encounter_group\n,18 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_surgery__match_claims_to_anchor \n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dialysis' as encounter_type\n,'outpatient' as encounter_group\n,15 as priority_number \nfrom dev_thuxuan.claims_preprocessing.dialysis__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospice' as encounter_type\n,'outpatient' as encounter_group\n,16 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_hospice__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'home health' as encounter_type\n,'outpatient' as encounter_group\n,17 as priority_number \nfrom dev_thuxuan.claims_preprocessing.home_health__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient injections' as encounter_type\n,'outpatient' as encounter_group\n,19 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_injections__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient pt/ot/st' as encounter_type\n,'outpatient' as encounter_group\n,20 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient substance use' as encounter_type\n,'outpatient' as encounter_group\n,21 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient radiology' as encounter_type\n,'outpatient' as encounter_group\n,22 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_radiology__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'lab - orphaned' as encounter_type\n,'other' as encounter_group\n,1000000 as priority_number \nfrom dev_thuxuan.claims_preprocessing.lab__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dme - orphaned' as encounter_type\n,'other' as encounter_group\n,1000001 as priority_number \nfrom dev_thuxuan.claims_preprocessing.dme__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulance - orphaned' as encounter_type\n,'other' as encounter_group\n,1000002 as priority_number \nfrom dev_thuxuan.claims_preprocessing.ambulance__match_claims_to_anchor \n\n)\n\n\nselect \n claim_id\n, claim_line_number\n, encounter_id as old_encounter_id\n, dense_rank() over (order by encounter_type, encounter_id) as encounter_id\n, encounter_type\n, encounter_group\n, priority_number\n, row_number() over (partition by claim_id , claim_line_number order by priority_number) as claim_line_attribution_number\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__orphaned_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__orphaned_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\encounters__orphaned_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\encounters__orphaned_claims.sql", "unique_id": "model.the_tuva_project.encounters__orphaned_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "encounters__orphaned_claims"], "alias": "encounters__orphaned_claims", "checksum": {"name": "sha256", "checksum": "980d775c5c6f98a66b74208844ab20f00fb48933531f677b509d9fb4569a6777"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5956256, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__orphaned_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith cte as (\r\n select stg.claim_id\r\n ,stg.claim_line_number\r\n ,stg.service_category_1\r\n ,stg.service_category_2\r\n ,stg.service_category_3\r\n ,stg.claim_type\r\n ,stg.claim_start_date\r\n ,stg.claim_end_date\r\n ,stg.start_date\r\n ,stg.end_date\r\n ,stg.patient_data_source_id\r\n from {{ ref('encounters__stg_medical_claim') }} stg\r\n left join {{ ref('encounters__combined_claim_line_crosswalk') }} enc on stg.claim_id = enc.claim_id\r\n and\r\n stg.claim_line_number = enc.claim_line_number\r\n where enc.claim_id is null -- missing from encounter mapping table\r\n)\r\n\r\n,max_encounter as (\r\n select max(encounter_id) max_encounter_id\r\n from {{ ref('encounters__combined_claim_line_crosswalk') }}\r\n)\r\n\r\nselect \r\n claim_id\r\n, claim_line_number\r\n, dense_rank() over (order by patient_data_source_id, claim_id) + max_encounter.max_encounter_id as encounter_id\r\n, 'orphaned claim' as encounter_type\r\n, 'other' as encounter_group\r\nfrom cte\r\ncross join max_encounter", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\encounters__orphaned_claims.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select stg.claim_id\n ,stg.claim_line_number\n ,stg.service_category_1\n ,stg.service_category_2\n ,stg.service_category_3\n ,stg.claim_type\n ,stg.claim_start_date\n ,stg.claim_end_date\n ,stg.start_date\n ,stg.end_date\n ,stg.patient_data_source_id\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n left join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk enc on stg.claim_id = enc.claim_id\n and\n stg.claim_line_number = enc.claim_line_number\n where enc.claim_id is null -- missing from encounter mapping table\n)\n\n,max_encounter as (\n select max(encounter_id) max_encounter_id\n from dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk\n)\n\nselect \n claim_id\n, claim_line_number\n, dense_rank() over (order by patient_data_source_id, claim_id) + max_encounter.max_encounter_id as encounter_id\n, 'orphaned claim' as encounter_type\n, 'other' as encounter_group\nfrom cte\ncross join max_encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "acute_inpatient__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.acute_inpatient__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "acute_inpatient", "acute_inpatient__generate_encounter_id"], "alias": "acute_inpatient__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "161083a1a12c68d91708a100928ea4f21f829a3dff37ad038f04a0364728dce1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient psych claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4170911, "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\nselect claim_id\r\n,patient_data_source_id\r\n,min(start_date) as start_date\r\n,max(end_date) as end_date \r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id\r\n ,patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id\r\n , enc.patient_data_source_id\r\n , c.start_date\r\n , c.end_date\r\n , enc.facility_id\r\n , enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c on enc.claim_id = c.claim_id\r\n and\r\n c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n service_category_2 in ('acute inpatient')\r\n and claim_type = 'institutional'\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id as claim_id_a\r\n , bb.claim_id as claim_id_b\r\n , aa.row_num as row_num_a\r\n , bb.row_num as row_num_b\r\n , case\r\n -- Claims with same end_date and same facility_id should be merged:\r\n when aa.end_date = bb.end_date\r\n and aa.facility_id = bb.facility_id then 1\r\n\r\n -- Claims with different end_date and start_date that are\r\n -- adjacent (i.e. separated by 1 day) should be merged:\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n\r\n -- Claims with different end_date \r\n -- should be merged if they overlap:\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n where aa.claim_id <> bb.claim_id\r\n)\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\nselect claim_id\n,patient_data_source_id\n,min(start_date) as start_date\n,max(end_date) as end_date \n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id\n ,patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id\n , enc.patient_data_source_id\n , c.start_date\n , c.end_date\n , enc.facility_id\n , enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c on enc.claim_id = c.claim_id\n and\n c.patient_data_source_id = enc.patient_data_source_id\n where\n service_category_2 in ('acute inpatient')\n and claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id\n , aa.claim_id as claim_id_a\n , bb.claim_id as claim_id_b\n , aa.row_num as row_num_a\n , bb.row_num as row_num_b\n , case\n -- Claims with same end_date and same facility_id should be merged:\n when aa.end_date = bb.end_date\n and aa.facility_id = bb.facility_id then 1\n\n -- Claims with different end_date and start_date that are\n -- adjacent (i.e. separated by 1 day) should be merged:\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n\n -- Claims with different end_date \n -- should be merged if they overlap:\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n where aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "acute_inpatient__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__prof_claims.sql", "unique_id": "model.the_tuva_project.acute_inpatient__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "acute_inpatient", "acute_inpatient__prof_claims"], "alias": "acute_inpatient__prof_claims", "checksum": {"name": "sha256", "checksum": "b3492955fd2a9b003dc5fee8fcb529fef84983ae18c2c2e10df82e0c9a015037"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.420091, "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('acute_inpatient__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n,join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('acute_inpatient__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "acute_inpatient__generate_encounter_id", "package": null, "version": null}, {"name": "acute_inpatient__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.acute_inpatient__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "acute_inpatient__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__start_end_dates.sql", "unique_id": "model.the_tuva_project.acute_inpatient__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "acute_inpatient", "acute_inpatient__start_end_dates"], "alias": "acute_inpatient__start_end_dates", "checksum": {"name": "sha256", "checksum": "4bc139de016bfd251893ebe0cee33ecf97c93b4cbb2d6dbecec169bb68fabe52"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.418091, "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('acute_inpatient__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "acute_inpatient__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.acute_inpatient__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\acute_inpatient\\acute_inpatient__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "ambulance__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__anchor_events.sql", "unique_id": "model.the_tuva_project.ambulance__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulance", "ambulance__anchor_events"], "alias": "ambulance__anchor_events", "checksum": {"name": "sha256", "checksum": "7ebb32ff005dda6512dbfe66fa59fe2773710f805c4a93acbf0a661df26ae91b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "ambulance"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "ambulance"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "ambulance"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5896165, "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'ambulance' --both inst and prof\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulance' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "ambulance__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.ambulance__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulance", "ambulance__generate_encounter_id"], "alias": "ambulance__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "33a38866e3a952c71f311aff485fd7a0d3b3eaff0099387f62f57400705072c9"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "ambulance"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "ambulance"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "ambulance"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.591626, "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('ambulance__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "ambulance__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.ambulance__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.ambulance__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ambulance__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "ambulance__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.ambulance__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulance", "ambulance__match_claims_to_anchor"], "alias": "ambulance__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "e1f0244d912e702564a7918fac0021a60afacce8e3bfdc13922bee6a61a6b897"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "ambulance"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "ambulance"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "ambulance"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5936253, "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('ambulance__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date\r\nwhere m.service_category_2 = 'ambulance'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "ambulance__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.ambulance__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulance\\ambulance__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.ambulance__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'ambulance'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "asc__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__anchor_events.sql", "unique_id": "model.the_tuva_project.asc__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__anchor_events"], "alias": "asc__anchor_events", "checksum": {"name": "sha256", "checksum": "944a40fa8d9c03ebdaa7df726252fe37fc4da34515481f6392deb4b50bc775a1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5110428, "relation_name": "dev_thuxuan.claims_preprocessing.asc__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n , end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'ambulatory surgery center' -- include both professional and institutional claims as anchor events\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n , end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulatory surgery center' -- include both professional and institutional claims as anchor events\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "asc__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.asc__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__generate_encounter_id"], "alias": "asc__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "78f9c5aa7a375ddf8c8dd99727881feaed233a099c9ae0868a4a25172b48bb39"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5140429, "relation_name": "dev_thuxuan.claims_preprocessing.asc__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith base_data as (\r\n select distinct\r\n m.patient_data_source_id\r\n , m.start_date\r\n , m.end_date\r\n , m.claim_id\r\n from {{ ref('encounters__stg_medical_claim') }} as m\r\n inner join {{ ref('asc__anchor_events') }} as u\r\n on m.claim_id = u.claim_id\r\n)\r\n\r\n-- Determine Previous Maximum End Date\r\n, grouped_data as (\r\n select\r\n bd.*\r\n , max(end_date) over (\r\n partition by patient_data_source_id \r\n order by start_date, claim_id \r\n rows between unbounded preceding and 1 preceding\r\n ) as previous_max_end_date\r\n from base_data as bd\r\n)\r\n\r\n-- Flag New Encounter Groups\r\n, flagged_data as (\r\n select\r\n gd.*\r\n , case \r\n when start_date > coalesce(previous_max_end_date, '1900-01-01') then 1 \r\n else 0 \r\n end as new_group_flag\r\n from grouped_data as gd\r\n)\r\n\r\n-- Assign Encounter Groups per Patient\r\n, numbered_data as (\r\n select\r\n fd.*\r\n , sum(new_group_flag) over (\r\n partition by patient_data_source_id \r\n order by start_date, claim_id \r\n rows unbounded preceding\r\n ) as encounter_group\r\n from flagged_data as fd\r\n)\r\n\r\n-- Identify Unique Encounters\r\n, unique_encounters as (\r\n select\r\n patient_data_source_id\r\n , encounter_group\r\n , min(start_date) as encounter_start_date\r\n from numbered_data\r\n group by\r\n patient_data_source_id\r\n , encounter_group\r\n)\r\n\r\n-- Assign asc encounter_id\r\n, numbered_encounters as (\r\n select\r\n patient_data_source_id\r\n , encounter_group\r\n , row_number() over (\r\n order by patient_data_source_id, encounter_start_date\r\n ) as encounter_id\r\n from unique_encounters\r\n)\r\n\r\n-- Merge Encounters with Claims\r\nselect\r\n nd.patient_data_source_id\r\n , nd.start_date\r\n , nd.end_date\r\n , nd.claim_id\r\n , ne.encounter_id as old_encounter_id\r\nfrom numbered_data as nd\r\ninner join numbered_encounters as ne\r\n on nd.patient_data_source_id = ne.patient_data_source_id\r\n and nd.encounter_group = ne.encounter_group", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "asc__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.asc__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith base_data as (\n select distinct\n m.patient_data_source_id\n , m.start_date\n , m.end_date\n , m.claim_id\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as m\n inner join dev_thuxuan.claims_preprocessing.asc__anchor_events as u\n on m.claim_id = u.claim_id\n)\n\n-- Determine Previous Maximum End Date\n, grouped_data as (\n select\n bd.*\n , max(end_date) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows between unbounded preceding and 1 preceding\n ) as previous_max_end_date\n from base_data as bd\n)\n\n-- Flag New Encounter Groups\n, flagged_data as (\n select\n gd.*\n , case \n when start_date > coalesce(previous_max_end_date, '1900-01-01') then 1 \n else 0 \n end as new_group_flag\n from grouped_data as gd\n)\n\n-- Assign Encounter Groups per Patient\n, numbered_data as (\n select\n fd.*\n , sum(new_group_flag) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows unbounded preceding\n ) as encounter_group\n from flagged_data as fd\n)\n\n-- Identify Unique Encounters\n, unique_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , min(start_date) as encounter_start_date\n from numbered_data\n group by\n patient_data_source_id\n , encounter_group\n)\n\n-- Assign asc encounter_id\n, numbered_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , row_number() over (\n order by patient_data_source_id, encounter_start_date\n ) as encounter_id\n from unique_encounters\n)\n\n-- Merge Encounters with Claims\nselect\n nd.patient_data_source_id\n , nd.start_date\n , nd.end_date\n , nd.claim_id\n , ne.encounter_id as old_encounter_id\nfrom numbered_data as nd\ninner join numbered_encounters as ne\n on nd.patient_data_source_id = ne.patient_data_source_id\n and nd.encounter_group = ne.encounter_group", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "asc__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.asc__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__match_claims_to_anchor"], "alias": "asc__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "54863d4bbb60e60473685f00ed852b2b0c6c4a0ee17a1108de5adfa3a55488bb"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5170422, "relation_name": "dev_thuxuan.claims_preprocessing.asc__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n dat.old_encounter_id\r\n , dat.encounter_start_date\r\n , dat.encounter_end_date\r\n , med.claim_id\r\n , med.claim_line_number\r\n , row_number() over (\r\n partition by med.claim_id, med.claim_line_number\r\n order by dat.old_encounter_id\r\n ) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} as med\r\ninner join {{ ref('asc__start_end_dates') }} as dat\r\n on med.patient_data_source_id = dat.patient_data_source_id\r\n and med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "asc__start_end_dates", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.asc__start_end_dates"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect\n dat.old_encounter_id\n , dat.encounter_start_date\n , dat.encounter_end_date\n , med.claim_id\n , med.claim_line_number\n , row_number() over (\n partition by med.claim_id, med.claim_line_number\n order by dat.old_encounter_id\n ) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as med\ninner join dev_thuxuan.claims_preprocessing.asc__start_end_dates as dat\n on med.patient_data_source_id = dat.patient_data_source_id\n and med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.asc__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "asc__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__start_end_dates.sql", "unique_id": "model.the_tuva_project.asc__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "ambulatory_surgery_center", "asc__start_end_dates"], "alias": "asc__start_end_dates", "checksum": {"name": "sha256", "checksum": "336c4ab3fb6874e50784b6f629d6ddb3ae7bdf9444902135466a05bc0fab5717"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "asc"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "asc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "asc"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.520043, "relation_name": "dev_thuxuan.claims_preprocessing.asc__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n patient_data_source_id\r\n , old_encounter_id\r\n , min(start_date) as encounter_start_date\r\n , max(end_date) as encounter_end_date\r\nfrom {{ ref('asc__generate_encounter_id') }}\r\ngroup by\r\n patient_data_source_id\r\n , old_encounter_id", "language": "sql", "refs": [{"name": "asc__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.asc__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\ambulatory_surgery_center\\asc__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_data_source_id\n , old_encounter_id\n , min(start_date) as encounter_start_date\n , max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.asc__generate_encounter_id\ngroup by\n patient_data_source_id\n , old_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dialysis__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__anchor_events.sql", "unique_id": "model.the_tuva_project.dialysis__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dialysis", "dialysis__anchor_events"], "alias": "dialysis__anchor_events", "checksum": {"name": "sha256", "checksum": "06cadf722a50a7a22756b44e429cd5019ab80086201d0426b6f9dd18ef10e558"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dialysis"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dialysis"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dialysis"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5230432, "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'dialysis' --both inst and professional as anchor\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'dialysis' --both inst and professional as anchor\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dialysis__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.dialysis__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dialysis", "dialysis__generate_encounter_id"], "alias": "dialysis__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "98de20bc6dd45a6c42f00d1392bbbc5e71a5f2d69ae76d1ae664bbf793acff99"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dialysis"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dialysis"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dialysis"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.526043, "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('dialysis__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dialysis__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dialysis__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dialysis__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dialysis__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dialysis__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.dialysis__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dialysis", "dialysis__match_claims_to_anchor"], "alias": "dialysis__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "95b425307f13e044bcceb327513f2b64afc698890077ae4437abb21c4775cbe8"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dialysis"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dialysis"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dialysis"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5290422, "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('dialysis__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dialysis__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dialysis__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\dialysis\\dialysis__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dialysis__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dme__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\dme\\dme__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\dme\\dme__anchor_events.sql", "unique_id": "model.the_tuva_project.dme__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dme", "dme__anchor_events"], "alias": "dme__anchor_events", "checksum": {"name": "sha256", "checksum": "06926f596d4b4baf27a585cdc236fbc653461cab843dbade77a3b8a35ee31c1e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dme"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dme"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dme"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5836167, "relation_name": "dev_thuxuan.claims_preprocessing.dme__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'durable medical equipment' --both inst and prof\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\dme\\dme__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'durable medical equipment' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dme__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\dme\\dme__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\dme\\dme__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.dme__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dme", "dme__generate_encounter_id"], "alias": "dme__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "10f011abdda682352d9cdbfd2dd3b575d31483a73142f4d14dbd3ce39f5fc65d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dme"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dme"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dme"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5856168, "relation_name": "dev_thuxuan.claims_preprocessing.dme__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('dme__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dme__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dme__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\dme\\dme__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dme__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.dme__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "dme__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\dme\\dme__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\dme\\dme__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.dme__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "dme", "dme__match_claims_to_anchor"], "alias": "dme__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "dba62368611261e12e2f7d6fc51083de65e16c7c1abf00814c66f8328411a2d5"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "dme"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "dme"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "dme"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5866163, "relation_name": "dev_thuxuan.claims_preprocessing.dme__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('dme__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date\r\nwhere m.service_category_2 = 'durable medical equipment'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "dme__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.dme__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\dme\\dme__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dme__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'durable medical equipment'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "emergency_department__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.emergency_department__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "emergency_department", "emergency_department__generate_encounter_id"], "alias": "emergency_department__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "cc6c7e96a371fe9e151882a2c425ee3a1037ffd119ffb5c6885a05a9dfb2e498"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient psych claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4230928, "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\n select\r\n claim_id,\r\n patient_data_source_id,\r\n min(start_date) as start_date,\r\n max(end_date) as end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id, patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id,\r\n enc.patient_data_source_id,\r\n c.start_date,\r\n c.end_date,\r\n enc.facility_id,\r\n enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c \r\n on enc.claim_id = c.claim_id\r\n and c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n enc.service_category_2 = 'emergency department' --both inst and prof\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id,\r\n claim_id,\r\n start_date,\r\n end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id,\r\n aa.claim_id as claim_id_a,\r\n bb.claim_id as claim_id_b,\r\n aa.row_num as row_num_a,\r\n bb.row_num as row_num_b,\r\n case\r\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n and aa.claim_id <> bb.claim_id\r\n)\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'emergency department' --both inst and prof\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "emergency_department__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__prof_claims.sql", "unique_id": "model.the_tuva_project.emergency_department__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "emergency_department", "emergency_department__prof_claims"], "alias": "emergency_department__prof_claims", "checksum": {"name": "sha256", "checksum": "b5109a61c7ba76a63c4f76cc9bd6381e9ee6962ed281cc41a3ec0eeb55203aab"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.427089, "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('emergency_department__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n,join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('emergency_department__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n\r\n-- ensuring each claim is only attributed to one encounter with claim_attribution_number\r\n,inst_and_prof as (\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date\r\n\r\nunion all \r\n\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,med.claim_id\r\n,med.claim_line_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_outpatient_institutional') }} inst on med.claim_id = inst.claim_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date \r\nwhere dat.claim_id <> med.claim_id\r\n)\r\n\r\nselect distinct encounter_id\r\n,encounter_start_date\r\n,encounter_end_date\r\n,claim_id\r\n,claim_line_number\r\n,row_number () over (partition by claim_id ,claim_line_number order by encounter_id) as claim_attribution_number\r\nfrom inst_and_prof", "language": "sql", "refs": [{"name": "emergency_department__generate_encounter_id", "package": null, "version": null}, {"name": "emergency_department__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.encounters__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n\n-- ensuring each claim is only attributed to one encounter with claim_attribution_number\n,inst_and_prof as (\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date\n\nunion all \n\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,med.claim_id\n,med.claim_line_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_outpatient_institutional inst on med.claim_id = inst.claim_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date \nwhere dat.claim_id <> med.claim_id\n)\n\nselect distinct encounter_id\n,encounter_start_date\n,encounter_end_date\n,claim_id\n,claim_line_number\n,row_number () over (partition by claim_id ,claim_line_number order by encounter_id) as claim_attribution_number\nfrom inst_and_prof", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.emergency_department__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "emergency_department__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__start_end_dates.sql", "unique_id": "model.the_tuva_project.emergency_department__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "emergency_department", "emergency_department__start_end_dates"], "alias": "emergency_department__start_end_dates", "checksum": {"name": "sha256", "checksum": "f288ae24a41e7293efd348b676ab36a1891640f77186771d9c05a9e0677118a0"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4250908, "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('emergency_department__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "emergency_department__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.emergency_department__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\emergency_department\\emergency_department__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "home_health__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__anchor_events.sql", "unique_id": "model.the_tuva_project.home_health__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "home_health", "home_health__anchor_events"], "alias": "home_health__anchor_events", "checksum": {"name": "sha256", "checksum": "ab38414e639f3d84f756e0fe7f5f46030bc37dd62dfa3acbb82fedb1d6cef13f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "home_health"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "home_health"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "home_health"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5400505, "relation_name": "dev_thuxuan.claims_preprocessing.home_health__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'home health' -- both prof and inst as anchors\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'home health' -- both prof and inst as anchors\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "home_health__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.home_health__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "home_health", "home_health__generate_encounter_id"], "alias": "home_health__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "a3d0920ab9b2abd0dde9b753b57c726274bfc83fb92091a7f760a8f09a5a948a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "home_health"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "home_health"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "home_health"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5420496, "relation_name": "dev_thuxuan.claims_preprocessing.home_health__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('home_health__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "home_health__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.home_health__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.home_health__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "home_health__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.home_health__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "home_health", "home_health__match_claims_to_anchor"], "alias": "home_health__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "faac8e00c10201ec6b96e71bb3fca47293931bf80341fca2a9c3e2626bdbda0b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "home_health"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "home_health"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "home_health"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5440502, "relation_name": "dev_thuxuan.claims_preprocessing.home_health__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('home_health__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "home_health__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\home_health\\home_health__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.home_health__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_hospice__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_hospice", "inpatient_hospice__generate_encounter_id"], "alias": "inpatient_hospice__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "8c3f03da1dc6c11ba996b392766bc1cd1a7cfbe0ba9bf54727a413a3314a80f6"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient hospice claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.453091, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\n select\r\n claim_id,\r\n patient_data_source_id,\r\n min(start_date) as start_date,\r\n max(end_date) as end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id, patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id,\r\n enc.patient_data_source_id,\r\n c.start_date,\r\n c.end_date,\r\n enc.facility_id,\r\n enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c \r\n on enc.claim_id = c.claim_id\r\n and c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n enc.service_category_2 in ('inpatient hospice')\r\n and enc.claim_type = 'institutional'\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id,\r\n claim_id,\r\n start_date,\r\n end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id,\r\n aa.claim_id as claim_id_a,\r\n bb.claim_id as claim_id_b,\r\n aa.row_num as row_num_a,\r\n bb.row_num as row_num_b,\r\n case\r\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n and aa.claim_id <> bb.claim_id\r\n)\r\n\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 in ('inpatient hospice')\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_hospice__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_hospice", "inpatient_hospice__prof_claims"], "alias": "inpatient_hospice__prof_claims", "checksum": {"name": "sha256", "checksum": "ad069a0087e305703b029ec57ad7ab038c078363311dfb1b8a97d750bcaaf0b3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4580915, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('inpatient_hospice__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n, join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('inpatient_hospice__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_hospice__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_hospice__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_hospice__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n, join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_hospice__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_hospice__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_hospice__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_hospice", "inpatient_hospice__start_end_dates"], "alias": "inpatient_hospice__start_end_dates", "checksum": {"name": "sha256", "checksum": "e2aa1cb9e2549563eba620d1f15afe5660999f412aad8698be7e6cafbd9e6242"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4560907, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('inpatient_hospice__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_hospice__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_hospice__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_hospice\\inpatient_hospice__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_psych__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_psych__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_psych", "inpatient_psych__generate_encounter_id"], "alias": "inpatient_psych__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1db12b053c06d9ece183dcfb4cfb92ad7035296e8431c8f617d5f806ae4c1948"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient psych claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4290912, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\n select\r\n claim_id,\r\n patient_data_source_id,\r\n min(start_date) as start_date,\r\n max(end_date) as end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id, patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id,\r\n enc.patient_data_source_id,\r\n c.start_date,\r\n c.end_date,\r\n enc.facility_id,\r\n enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c \r\n on enc.claim_id = c.claim_id\r\n and c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n enc.service_category_2 = 'inpatient psychiatric'\r\n and enc.claim_type = 'institutional'\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id,\r\n claim_id,\r\n start_date,\r\n end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id,\r\n aa.claim_id as claim_id_a,\r\n bb.claim_id as claim_id_b,\r\n aa.row_num as row_num_a,\r\n bb.row_num as row_num_b,\r\n case\r\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n and aa.claim_id <> bb.claim_id\r\n)\r\n\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient psychiatric'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_psych__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_psych__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_psych", "inpatient_psych__prof_claims"], "alias": "inpatient_psych__prof_claims", "checksum": {"name": "sha256", "checksum": "187bf95415583c782b42e3d4843b6750b3800e050a0b04d03b9f7e6d3bc68bba"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.433091, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('inpatient_psych__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n,join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('inpatient_psych__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_psych__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_psych__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_psych__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_psych__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_psych__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_psych", "inpatient_psych__start_end_dates"], "alias": "inpatient_psych__start_end_dates", "checksum": {"name": "sha256", "checksum": "dd183c4ec5ff79c4f33d613a9a484670e6d50363b7ba163014b1c71e3a941268"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4310913, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('inpatient_psych__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_psych__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_psych__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_psych\\inpatient_psych__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_rehab__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_rehab", "inpatient_rehab__generate_encounter_id"], "alias": "inpatient_rehab__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "d673ba0a5318ec5b4072c36b7314541c49ca12c1f2e357be436db918b83e6010"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient rehab claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4340916, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\n select\r\n claim_id,\r\n patient_data_source_id,\r\n min(start_date) as start_date,\r\n max(end_date) as end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id, patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id,\r\n enc.patient_data_source_id,\r\n c.start_date,\r\n c.end_date,\r\n enc.facility_id,\r\n enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c \r\n on enc.claim_id = c.claim_id\r\n and c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n enc.service_category_2 = 'inpatient rehabilitation'\r\n and enc.claim_type = 'institutional'\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id,\r\n claim_id,\r\n start_date,\r\n end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id,\r\n aa.claim_id as claim_id_a,\r\n bb.claim_id as claim_id_b,\r\n aa.row_num as row_num_a,\r\n bb.row_num as row_num_b,\r\n case\r\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n and aa.claim_id <> bb.claim_id\r\n)\r\n\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient rehabilitation'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_rehab__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_rehab", "inpatient_rehab__prof_claims"], "alias": "inpatient_rehab__prof_claims", "checksum": {"name": "sha256", "checksum": "07cf23b0f37696961b013f4f6ba93b72c514ae0015deeab20a97ff459109bb3e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4390903, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('inpatient_rehab__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n,join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('inpatient_rehab__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_rehab__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_rehab__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_rehab__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_rehab__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_rehab__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_rehab", "inpatient_rehab__start_end_dates"], "alias": "inpatient_rehab__start_end_dates", "checksum": {"name": "sha256", "checksum": "4edd8115a60e18ec93abbbd9d9d7d9c80ed8d355d0370b2dc2a6f2895cddebe3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4360907, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('inpatient_rehab__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_rehab__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_rehab__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_rehab\\inpatient_rehab__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_snf__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_snf__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_snf", "inpatient_snf__generate_encounter_id"], "alias": "inpatient_snf__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "06d89ae171bd7527d795a7394f5f0f637e97ca999dfaadf41081356ca49e3cdc"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient snf claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.441092, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\n select\r\n claim_id,\r\n patient_data_source_id,\r\n min(start_date) as start_date,\r\n max(end_date) as end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id, patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id,\r\n enc.patient_data_source_id,\r\n c.start_date,\r\n c.end_date,\r\n enc.facility_id,\r\n enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c \r\n on enc.claim_id = c.claim_id\r\n and c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n enc.service_category_2 = 'skilled nursing'\r\n and enc.claim_type = 'institutional'\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id,\r\n claim_id,\r\n start_date,\r\n end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id,\r\n aa.claim_id as claim_id_a,\r\n bb.claim_id as claim_id_b,\r\n aa.row_num as row_num_a,\r\n bb.row_num as row_num_b, \r\n case\r\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n and aa.claim_id <> bb.claim_id\r\n)\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'skilled nursing'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b, \n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_snf__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_snf__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_snf", "inpatient_snf__prof_claims"], "alias": "inpatient_snf__prof_claims", "checksum": {"name": "sha256", "checksum": "0b772ef829a09572aee30c3e04c47c4f40c58a8a2884fc458c6f04b0628c5f41"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4460912, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('inpatient_snf__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n,join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('inpatient_snf__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_snf__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_snf__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_snf__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_snf__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_snf__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_snf", "inpatient_snf__start_end_dates"], "alias": "inpatient_snf__start_end_dates", "checksum": {"name": "sha256", "checksum": "cd611ef3a9c864666219fc0d7e2477040690c21938315d26d7b2ae67926e794a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.443091, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('inpatient_snf__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_snf__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_snf__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_snf\\inpatient_snf__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_substance_use__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_substance_use", "inpatient_substance_use__generate_encounter_id"], "alias": "inpatient_substance_use__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1d46a4fd5a1c2d260bc73a2be3cdaabc89ec7d359acdf2fa8bb0b0fb1202177d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "generate encounter id and stitch inpatient substance_use claims together", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4470906, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claim_start_end as (\r\n select\r\n claim_id,\r\n patient_data_source_id,\r\n min(start_date) as start_date,\r\n max(end_date) as end_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n group by claim_id, patient_data_source_id\r\n)\r\n\r\n, base as (\r\n select distinct\r\n enc.claim_id,\r\n enc.patient_data_source_id,\r\n c.start_date,\r\n c.end_date,\r\n enc.facility_id,\r\n enc.discharge_disposition_code\r\n from {{ ref('encounters__stg_medical_claim') }} enc\r\n inner join claim_start_end c \r\n on enc.claim_id = c.claim_id\r\n and c.patient_data_source_id = enc.patient_data_source_id\r\n where\r\n enc.service_category_2 = 'inpatient substance use'\r\n and enc.claim_type = 'institutional'\r\n)\r\n\r\n, add_row_num as (\r\n select\r\n patient_data_source_id,\r\n claim_id,\r\n start_date,\r\n end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\r\n from base\r\n)\r\n\r\n, check_for_merges_with_larger_row_num as (\r\n select\r\n aa.patient_data_source_id,\r\n aa.claim_id as claim_id_a,\r\n bb.claim_id as claim_id_b,\r\n aa.row_num as row_num_a,\r\n bb.row_num as row_num_b,\r\n case\r\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\r\n when {{ dbt.dateadd(datepart= 'day', interval=1, from_date_or_timestamp='aa.end_date') }} = bb.start_date\r\n and aa.facility_id = bb.facility_id\r\n and aa.discharge_disposition_code = '30' then 1\r\n when aa.end_date <> bb.end_date\r\n and aa.end_date >= bb.start_date\r\n and aa.facility_id = bb.facility_id then 1\r\n else 0\r\n end as merge_flag\r\n from add_row_num as aa\r\n inner join add_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num < bb.row_num\r\n and aa.claim_id <> bb.claim_id\r\n)\r\n\r\n\r\n, merges_with_larger_row_num as (\r\n select\r\n patient_data_source_id\r\n , claim_id_a\r\n , claim_id_b\r\n , row_num_a\r\n , row_num_b\r\n , merge_flag\r\n from check_for_merges_with_larger_row_num\r\n where merge_flag = 1\r\n)\r\n\r\n, claim_ids_that_merge_with_larger_row_num as (\r\n select distinct\r\n claim_id_a as claim_id\r\n from merges_with_larger_row_num\r\n)\r\n\r\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\r\n select distinct\r\n aa.claim_id as claim_id\r\n from add_row_num as aa\r\n inner join merges_with_larger_row_num as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and bb.row_num_a < aa.row_num\r\n and bb.row_num_b > aa.row_num\r\n)\r\n\r\n, close_flags as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , case\r\n when bb.claim_id is null\r\n and cc.claim_id is null then 1\r\n else 0\r\n end as close_flag\r\n from add_row_num as aa\r\n left join claim_ids_that_merge_with_larger_row_num as bb\r\n on aa.claim_id = bb.claim_id\r\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\r\n on aa.claim_id = cc.claim_id\r\n)\r\n\r\n, join_every_row_to_later_closes as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.row_num\r\n , bb.row_num as row_num_b\r\n from close_flags as aa\r\n inner join close_flags as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.row_num <= bb.row_num\r\n where bb.close_flag = 1\r\n)\r\n\r\n, find_min_closing_row_num_for_every_claim as (\r\n select\r\n patient_data_source_id\r\n , claim_id\r\n , min(row_num_b) as min_closing_row\r\n from join_every_row_to_later_closes\r\n group by\r\n patient_data_source_id\r\n , claim_id\r\n)\r\n\r\n, add_min_closing_row_to_every_claim as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , bb.min_closing_row\r\n from close_flags as aa\r\n left join find_min_closing_row_num_for_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.claim_id = bb.claim_id\r\n)\r\n\r\n, add_encounter_id as (\r\n select\r\n aa.patient_data_source_id\r\n , aa.claim_id\r\n , aa.start_date\r\n , aa.end_date\r\n , aa.discharge_disposition_code\r\n , aa.facility_id\r\n , aa.row_num\r\n , aa.close_flag\r\n , aa.min_closing_row\r\n , bb.claim_id as encounter_id\r\n from add_min_closing_row_to_every_claim as aa\r\n left join add_min_closing_row_to_every_claim as bb\r\n on aa.patient_data_source_id = bb.patient_data_source_id\r\n and aa.min_closing_row = bb.row_num\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , claim_id\r\n , start_date\r\n , end_date\r\n , discharge_disposition_code\r\n , facility_id\r\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\r\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\r\n , close_flag\r\n , min_closing_row\r\n , dense_rank() over (order by encounter_id) as encounter_id\r\nfrom add_encounter_id", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient substance use'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__prof_claims": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_substance_use__prof_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__prof_claims.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__prof_claims.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__prof_claims", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_substance_use", "inpatient_substance_use__prof_claims"], "alias": "inpatient_substance_use__prof_claims", "checksum": {"name": "sha256", "checksum": "eb5ea79daa583c27434eb48f563a224d64cc74e7c232cfa315cf97b6f6841978"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "match corresponding prof claims to institutional claims", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4510918, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__prof_claims", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith first_claim as (\r\n select *\r\n from {{ ref('inpatient_substance_use__generate_encounter_id') }}\r\n where encounter_claim_number = 1\r\n)\r\n\r\n,join_first_claim_dates as (\r\n select f.*\r\n ,dat.encounter_end_date\r\n ,dat.encounter_start_date\r\n from first_claim f \r\n inner join {{ ref('inpatient_substance_use__start_end_dates') }} dat on f.encounter_id = dat.encounter_id\r\n)\r\n\r\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\r\nselect dat.encounter_id\r\n,dat.encounter_start_date\r\n,dat.encounter_end_date\r\n,prof.claim_id\r\n,prof.claim_line_number\r\n-- ,med.start_date\r\n-- ,med.end_date\r\n-- ,med.place_of_service_code\r\n-- ,med.place_of_service_description\r\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_professional') }} prof on med.claim_line_id = prof.claim_line_id\r\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\r\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "language": "sql", "refs": [{"name": "inpatient_substance_use__generate_encounter_id", "package": null, "version": null}, {"name": "inpatient_substance_use__start_end_dates", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__prof_claims.sql", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n-- ,med.start_date\n-- ,med.end_date\n-- ,med.place_of_service_code\n-- ,med.place_of_service_description\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.inpatient_substance_use__start_end_dates": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "inpatient_substance_use__start_end_dates", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__start_end_dates.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__start_end_dates.sql", "unique_id": "model.the_tuva_project.inpatient_substance_use__start_end_dates", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "inpatient_substance_use", "inpatient_substance_use__start_end_dates"], "alias": "inpatient_substance_use__start_end_dates", "checksum": {"name": "sha256", "checksum": "faf5f1bda6f46617760039e9cd6d7321760a65663263beaed115ddb17ac68e1f"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "calculate start and end date of encounter", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.449091, "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect encounter_id \r\n, min(start_date) as encounter_start_date\r\n, max(end_date) as encounter_end_date\r\nfrom {{ ref('inpatient_substance_use__generate_encounter_id') }}\r\ngroup by encounter_id", "language": "sql", "refs": [{"name": "inpatient_substance_use__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.inpatient_substance_use__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\inpatient_substance_use\\inpatient_substance_use__start_end_dates.sql", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id\ngroup by encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "lab__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\lab\\lab__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\lab\\lab__anchor_events.sql", "unique_id": "model.the_tuva_project.lab__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "lab", "lab__anchor_events"], "alias": "lab__anchor_events", "checksum": {"name": "sha256", "checksum": "5386af2aed94777bb9c6561abafb2edb73f12ba247f4857d2b9c03ccd1bac810"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "lab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "lab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "lab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5746143, "relation_name": "dev_thuxuan.claims_preprocessing.lab__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'lab' --both inst and prof\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\lab\\lab__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'lab' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "lab__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\lab\\lab__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\lab\\lab__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.lab__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "lab", "lab__generate_encounter_id"], "alias": "lab__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "000517abd864f3e65f6a752d038e2039161f75273505ca49a532c97c5dd44d27"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "lab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "lab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "lab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5776143, "relation_name": "dev_thuxuan.claims_preprocessing.lab__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('lab__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "lab__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\lab\\lab__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.lab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.lab__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "lab__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\lab\\lab__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\lab\\lab__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.lab__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "lab", "lab__match_claims_to_anchor"], "alias": "lab__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "88d081a66f71bd5c3b5ec8900d9b30cc405978fc2726c19647d5e3687471bc29"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "lab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "lab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "lab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5796142, "relation_name": "dev_thuxuan.claims_preprocessing.lab__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('lab__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date\r\nwhere m.service_category_2 = 'lab'", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "lab__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\lab\\lab__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.lab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'lab'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits"], "alias": "office_visits__int_office_visits", "checksum": {"name": "sha256", "checksum": "68fe4c127e355e87b91da0f984b97ce6b65dd736002a98e18f98e1b970412189"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4720914, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as (\r\n select distinct\r\n mc.patient_data_source_id\r\n , mc.start_date\r\n , mc.claim_id\r\n , mc.claim_line_number\r\n , mc.service_category_1\r\n , mc.service_category_2\r\n , mc.service_category_3\r\n from {{ ref('encounters__stg_medical_claim') }} as mc\r\n inner join {{ ref('service_category__combined_professional') }} as p -- joining in all sc regardless of final priority\r\n on mc.claim_id = p.claim_id\r\n and mc.claim_line_number = p.claim_line_number\r\n where p.service_category_1 = 'office-based'\r\n)\r\n\r\nselect\r\n patient_data_source_id\r\n , start_date\r\n , claim_id\r\n , claim_line_number\r\n , service_category_1\r\n , service_category_2\r\n , service_category_3\r\n , dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__combined_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits.sql", "compiled": true, "compiled_code": "\n\nwith anchor as (\n select distinct\n mc.patient_data_source_id\n , mc.start_date\n , mc.claim_id\n , mc.claim_line_number\n , mc.service_category_1\n , mc.service_category_2\n , mc.service_category_3\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as mc\n inner join dev_thuxuan.claims_preprocessing._int_combined_professional as p -- joining in all sc regardless of final priority\n on mc.claim_id = p.claim_id\n and mc.claim_line_number = p.claim_line_number\n where p.service_category_1 = 'office-based'\n)\n\nselect\n patient_data_source_id\n , start_date\n , claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_claim_line": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_claim_line", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_claim_line.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_claim_line.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_claim_line", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_claim_line"], "alias": "office_visits__int_office_visits_claim_line", "checksum": {"name": "sha256", "checksum": "e5d90903d7bd9f45ba96b77296f431747ff8f315f5075e07b5603c713b792af5"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4760938, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_claim_line", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith rank_cte as (\r\nselect *\r\nfrom {{ ref('office_visits__int_office_visits_union')}}\r\n)\r\n\r\n,crosswalk_cte as (\r\nselect old_encounter_id\r\n,encounter_type\r\nfrom {{ ref('office_visits__int_office_visits_encounter_ranking') }}\r\nwhere relative_rank = 1\r\n)\r\n\r\nselect r.claim_id\r\n, r.claim_line_number\r\n, r.old_encounter_id\r\n, x.encounter_type\r\nfrom rank_cte r\r\ninner join crosswalk_cte x on r.old_encounter_id = x.old_encounter_id", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_union", "package": null, "version": null}, {"name": "office_visits__int_office_visits_encounter_ranking", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_union", "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_claim_line.sql", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,crosswalk_cte as (\nselect old_encounter_id\n,encounter_type\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_encounter_ranking\nwhere relative_rank = 1\n)\n\nselect r.claim_id\n, r.claim_line_number\n, r.old_encounter_id\n, x.encounter_type\nfrom rank_cte r\ninner join crosswalk_cte x on r.old_encounter_id = x.old_encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_em": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_em", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_em.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_em.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_em", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_em"], "alias": "office_visits__int_office_visits_em", "checksum": {"name": "sha256", "checksum": "12a2618821ede166b5d99775f56e4e7b458111a6afd4a10464096515c89713e3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4670906, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_em", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n ov.patient_data_source_id\r\n ,ov.start_date\r\n ,ov.claim_id\r\n ,ov.claim_line_number\r\n ,ov.old_encounter_id\r\nfrom {{ ref('office_visits__int_office_visits')}} ov\r\nwhere service_category_2 = 'office-based visit'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_em.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based visit'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_encounter_ranking", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_encounter_ranking.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_encounter_ranking.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_encounter_ranking"], "alias": "office_visits__int_office_visits_encounter_ranking", "checksum": {"name": "sha256", "checksum": "3eb74684de8d75d9a33205c0017dd51cdf3111a4228843299935f33890148cf7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.474091, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_encounter_ranking", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith rank_cte as (\r\nselect *\r\nfrom {{ ref('office_visits__int_office_visits_union')}}\r\n)\r\n\r\n,dist_encounter as (\r\nselect distinct old_encounter_id\r\n,encounter_type\r\n,priority_number\r\nfrom rank_cte\r\n)\r\n\r\nselect \r\nold_encounter_id\r\n,encounter_type\r\n,priority_number\r\n,row_number() over (partition by old_encounter_id order by priority_number) as relative_rank\r\nfrom dist_encounter", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_union", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_union"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_encounter_ranking.sql", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,dist_encounter as (\nselect distinct old_encounter_id\n,encounter_type\n,priority_number\nfrom rank_cte\n)\n\nselect \nold_encounter_id\n,encounter_type\n,priority_number\n,row_number() over (partition by old_encounter_id order by priority_number) as relative_rank\nfrom dist_encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_injections": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_injections", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_injections.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_injections.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_injections", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_injections"], "alias": "office_visits__int_office_visits_injections", "checksum": {"name": "sha256", "checksum": "66f78b819baeaedaa505cf6501b6dec43abd8382d55febd541401c2ef11938f3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.460091, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_injections", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n ov.patient_data_source_id\r\n ,ov.start_date\r\n ,ov.claim_id\r\n ,ov.claim_line_number\r\n ,ov.old_encounter_id\r\nfrom {{ ref('office_visits__int_office_visits')}} ov\r\ninner join {{ ref('encounters__stg_medical_claim')}} mc on mc.claim_id = ov.claim_id\r\n and mc.claim_line_number = ov.claim_line_number\r\nwhere substring(hcpcs_code,1,1) = 'J'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_injections.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\nwhere substring(hcpcs_code,1,1) = 'J'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_ptotst": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_ptotst", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_ptotst.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_ptotst.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_ptotst", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_ptotst"], "alias": "office_visits__int_office_visits_ptotst", "checksum": {"name": "sha256", "checksum": "bcf26d7d399904eed360248e75f5659c5d4b5031b24a1fa343b8c74e6c0d0d03"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4610906, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_ptotst", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n ov.patient_data_source_id\r\n ,ov.start_date\r\n ,ov.claim_id\r\n ,ov.claim_line_number\r\n ,ov.old_encounter_id\r\nfrom {{ ref('office_visits__int_office_visits')}} ov\r\nwhere service_category_2 = 'office-based pt/ot/st'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_ptotst.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based pt/ot/st'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_radiology": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_radiology", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_radiology.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_radiology.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_radiology", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_radiology"], "alias": "office_visits__int_office_visits_radiology", "checksum": {"name": "sha256", "checksum": "c0954f5523419a80e2274a3d008e1b7e3c70caec2b5c3df4f9007d7170cc3306"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4630907, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_radiology", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith max_encounter as (\r\n select max(old_encounter_id) as max_encounter_id\r\n from {{ ref('office_visits__int_office_visits') }}\r\n)\r\n\r\nselect distinct\r\n ov.patient_data_source_id\r\n ,ov.start_date\r\n ,ov.claim_id\r\n ,ov.claim_line_number\r\n ,mc.hcpcs_code\r\n ,dense_rank() over (order by ov.patient_data_source_id, ov.start_date, mc.hcpcs_code) + mx.max_encounter_id as old_encounter_id\r\nfrom {{ ref('office_visits__int_office_visits') }} ov\r\ncross join max_encounter mx\r\ninner join {{ ref('encounters__stg_medical_claim') }} mc on mc.claim_id = ov.claim_id\r\n and mc.claim_line_number = ov.claim_line_number\r\ninner join {{ ref('service_category__office_based_radiology')}} scrad on mc.claim_id = scrad.claim_id\r\n and mc.claim_line_number = scrad.claim_line_number", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}, {"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__office_based_radiology", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__office_based_radiology"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_radiology.sql", "compiled": true, "compiled_code": "\n\nwith max_encounter as (\n select max(old_encounter_id) as max_encounter_id\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits\n)\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,mc.hcpcs_code\n ,dense_rank() over (order by ov.patient_data_source_id, ov.start_date, mc.hcpcs_code) + mx.max_encounter_id as old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\ncross join max_encounter mx\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\ninner join dev_thuxuan.claims_preprocessing.service_category__office_based_radiology scrad on mc.claim_id = scrad.claim_id\n and mc.claim_line_number = scrad.claim_line_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_surgery": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_surgery", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_surgery.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_surgery.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_surgery", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_surgery"], "alias": "office_visits__int_office_visits_surgery", "checksum": {"name": "sha256", "checksum": "25112e73e0819fadcc458c19b8629f3f2a9edec9e20bd430313ed88ef8ee9853"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4650908, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_surgery", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n ov.patient_data_source_id\r\n ,ov.start_date\r\n ,ov.claim_id\r\n ,ov.claim_line_number\r\n ,ov.old_encounter_id\r\nfrom {{ ref('office_visits__int_office_visits')}} ov\r\nwhere service_category_2 = 'office-based surgery'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_surgery.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based surgery'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_telehealth": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_telehealth", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_telehealth.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_telehealth.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_telehealth", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_telehealth"], "alias": "office_visits__int_office_visits_telehealth", "checksum": {"name": "sha256", "checksum": "196379ed5b535758ebcc3264666dfc9ee8e2c332dbc7ce20fa80c5262b3e659a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4690912, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_telehealth", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n ov.patient_data_source_id\r\n ,ov.start_date\r\n ,ov.claim_id\r\n ,ov.claim_line_number\r\n ,ov.old_encounter_id\r\nfrom {{ ref('office_visits__int_office_visits')}} ov\r\nwhere service_category_2 = 'telehealth visit'", "language": "sql", "refs": [{"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_telehealth.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'telehealth visit'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.office_visits__int_office_visits_union": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "office_visits__int_office_visits_union", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_union.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_union.sql", "unique_id": "model.the_tuva_project.office_visits__int_office_visits_union", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "office_visits", "office_visits__int_office_visits_union"], "alias": "office_visits__int_office_visits_union", "checksum": {"name": "sha256", "checksum": "dfaf0a3b774a00e1649e206a7107b99b4d04632674f6337bfaae0841d025f582"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4781034, "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_union", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'office visit radiology' as encounter_type\r\n,0 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits_radiology') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'office visit surgery' as encounter_type\r\n,1 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits_surgery') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'office visit injections' as encounter_type\r\n,2 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits_injections') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'office visit pt/ot/st' as encounter_type\r\n,3 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits_ptotst') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'office visit' as encounter_type\r\n,4 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits_em') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'telehealth' as encounter_type\r\n,5 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits_telehealth') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect claim_id\r\n,claim_line_number\r\n,old_encounter_id\r\n,'office visit - other' as encounter_type\r\n,9999 as priority_number\r\nfrom {{ ref('office_visits__int_office_visits') }}", "language": "sql", "refs": [{"name": "office_visits__int_office_visits_radiology", "package": null, "version": null}, {"name": "office_visits__int_office_visits_surgery", "package": null, "version": null}, {"name": "office_visits__int_office_visits_injections", "package": null, "version": null}, {"name": "office_visits__int_office_visits_ptotst", "package": null, "version": null}, {"name": "office_visits__int_office_visits_em", "package": null, "version": null}, {"name": "office_visits__int_office_visits_telehealth", "package": null, "version": null}, {"name": "office_visits__int_office_visits", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_ptotst", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.office_visits__int_office_visits"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\office_visits\\office_visits__int_office_visits_union.sql", "compiled": true, "compiled_code": "\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit radiology' as encounter_type\n,0 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_radiology\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit surgery' as encounter_type\n,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_surgery\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit injections' as encounter_type\n,2 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_injections\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit pt/ot/st' as encounter_type\n,3 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_ptotst\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit' as encounter_type\n,4 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_em\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'telehealth' as encounter_type\n,5 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit - other' as encounter_type\n,9999 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospice__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospice", "outpatient_hospice__anchor_events"], "alias": "outpatient_hospice__anchor_events", "checksum": {"name": "sha256", "checksum": "a6579e670e8d1c40547312247ead0be5798c0462eb9f8eed147ac85748ee282e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5320585, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'outpatient hospice' --both inst and prof\r\n \r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient hospice' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospice__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospice", "outpatient_hospice__generate_encounter_id"], "alias": "outpatient_hospice__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "9b468b3022b2a0bbe5025b5ded3913cee8238c1229f2f16ea3a1d82565b62fbd"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5360508, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_hospice__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospice__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospice__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospice__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospice", "outpatient_hospice__match_claims_to_anchor"], "alias": "outpatient_hospice__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "b2bac02a758453a76a0643ff4d738a23970f2f4c343691513dab600be2c549f9"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospice"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5380497, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_hospice__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospice__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospice\\outpatient_hospice__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospice__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospital_or_clinic", "outpatient_hospital_or_clinic__anchor_events"], "alias": "outpatient_hospital_or_clinic__anchor_events", "checksum": {"name": "sha256", "checksum": "cd97d6b4f07dfede2b6e11e375cf93e3f5a75d71976ba64d58f7f636c4c50dd0"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5025244, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where \r\n service_category_2 in (\r\n 'outpatient hospital or clinic' -- both prof and inst\r\n , 'observation' -- orphaned obs that didn't roll up to other encounter\r\n )\r\n)\r\n\r\nselect distinct \r\n claim_id\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where \n service_category_2 in (\n 'outpatient hospital or clinic' -- both prof and inst\n , 'observation' -- orphaned obs that didn't roll up to other encounter\n )\n)\n\nselect distinct \n claim_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospital_or_clinic", "outpatient_hospital_or_clinic__generate_encounter_id"], "alias": "outpatient_hospital_or_clinic__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "bda6a19660fc17e156908a08531e613af259e6bfc5d1a58744c83446308370d1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5050368, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_hospital_or_clinic__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_hospital_or_clinic__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_hospital_or_clinic", "outpatient_hospital_or_clinic__match_claims_to_anchor"], "alias": "outpatient_hospital_or_clinic__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "2404892ba3815c78aad8fb1cae57a23150d017d0b5146c6261a457ea980d90df"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_hospital_or_clinic"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5080428, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_hospital_or_clinic__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_hospital_or_clinic\\outpatient_hospital_or_clinic__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_injections__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_injections__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_injections", "outpatient_injections__anchor_events"], "alias": "outpatient_injections__anchor_events", "checksum": {"name": "sha256", "checksum": "65a104396fc30f9200a1295b96ac3b59f63498d3b113992b219eac9980cb05f1"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5460558, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as \r\n(\r\nselect distinct\r\n med.patient_data_source_id\r\n ,med.start_date\r\nfrom {{ ref('encounters__stg_medical_claim') }} med\r\ninner join {{ ref('encounters__stg_outpatient_institutional') }} outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere substring(med.hcpcs_code,1,1) = 'J'\r\n)\r\n\r\n\r\nselect distinct \r\n patient_data_source_id\r\n ,start_date\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "encounters__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as \n(\nselect distinct\n med.patient_data_source_id\n ,med.start_date\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.hcpcs_code,1,1) = 'J'\n)\n\n\nselect distinct \n patient_data_source_id\n ,start_date\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_injections__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_injections__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_injections", "outpatient_injections__generate_encounter_id"], "alias": "outpatient_injections__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "094f1a6fa807ef722268d009cc71bbab97814696aa1447c2062c69c3e0452956"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5480502, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom {{ ref('outpatient_injections__anchor_events') }}", "language": "sql", "refs": [{"name": "outpatient_injections__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.outpatient_injections__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.outpatient_injections__anchor_events", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_injections__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_injections", "outpatient_injections__match_claims_to_anchor"], "alias": "outpatient_injections__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "89fd1a5e0de65df6464497aa6e872e1a917f303dbe33ffa01a7da8f4446fbc31"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_injections"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5511088, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_injections__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_injections__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_injections__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_injections\\outpatient_injections__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_injections__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_psych__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_psych__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_psych", "outpatient_psych__anchor_events"], "alias": "outpatient_psych__anchor_events", "checksum": {"name": "sha256", "checksum": "e2ef8c2153e6e41595cbbfd6a078008734db3d45abefebc418c7d16d1721e8ba"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.487325, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'outpatient psychiatric' --both inst and prof as anchor\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient psychiatric' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_psych__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_psych__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_psych", "outpatient_psych__generate_encounter_id"], "alias": "outpatient_psych__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "5dfd5c399d22bca7ca8d1473da77d5fee2937470b066218c8c164b28416baf66"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4893284, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_psych__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_psych__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_psych__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_psych__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_psych", "outpatient_psych__match_claims_to_anchor"], "alias": "outpatient_psych__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "f2da768e207815904b5f8fc0c7a628245914ff48723b39043c945bb6c023fe8b"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_psych"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4917016, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_psych__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_psych__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_psych\\outpatient_psych__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_psych__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_ptotst__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_ptotst", "outpatient_ptotst__anchor_events"], "alias": "outpatient_ptotst__anchor_events", "checksum": {"name": "sha256", "checksum": "f9ecac70c4f94c5c59c025b3ac0c6101b514eb13ddbe87eae014643f01cfdcb5"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5531106, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'outpatient pt/ot/st' --both inst and prof as anchor\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient pt/ot/st' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_ptotst__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_ptotst", "outpatient_ptotst__generate_encounter_id"], "alias": "outpatient_ptotst__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1fc9cbefd6ccf5f080246def45256d7bec101f44e718ae4a932f8177840cc9bb"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5551112, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_ptotst__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_ptotst__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_ptotst__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_ptotst__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_ptotst", "outpatient_ptotst__match_claims_to_anchor"], "alias": "outpatient_ptotst__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "ae5625915e922b63599c6cc72b903ee23d2de774faf4f5b276ce2735277ff7ee"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_ptotst"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5571096, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_ptotst__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_ptotst__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_ptotst\\outpatient_ptotst__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_ptotst__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_radiology__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_radiology", "outpatient_radiology__anchor_events"], "alias": "outpatient_radiology__anchor_events", "checksum": {"name": "sha256", "checksum": "ce8a43a042528a18a8f85ec9147fdd5a0f2efe3623c2f952df2a91bfc183db31"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5666082, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n patient_data_source_id\r\n , start_date\r\n , hcpcs_code\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'outpatient radiology' --both professional and inst\r\n)\r\n\r\nselect distinct \r\n patient_data_source_id\r\n , start_date\r\n , hcpcs_code\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n patient_data_source_id\n , start_date\n , hcpcs_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient radiology' --both professional and inst\n)\n\nselect distinct \n patient_data_source_id\n , start_date\n , hcpcs_code\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_radiology__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_radiology", "outpatient_radiology__generate_encounter_id"], "alias": "outpatient_radiology__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1bce095fe77482a1b94c926bc394916149a4154a2a0988eda0102a46bac646b3"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5686145, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,hcpcs_code\r\n,dense_rank() over (order by patient_data_source_id, start_date, hcpcs_code) as old_encounter_id\r\nfrom {{ ref('outpatient_radiology__anchor_events') }}", "language": "sql", "refs": [{"name": "outpatient_radiology__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.outpatient_radiology__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,hcpcs_code\n,dense_rank() over (order by patient_data_source_id, start_date, hcpcs_code) as old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.outpatient_radiology__anchor_events", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_radiology__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_radiology", "outpatient_radiology__match_claims_to_anchor"], "alias": "outpatient_radiology__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "86bf5b4af957b6b51fd984d9892de4407bb0e88e731791079705a0d14584b8bb"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_radiology"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5716145, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , m.hcpcs_code\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_radiology__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date\r\nand\r\nm.hcpcs_code = u.hcpcs_code", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_radiology__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_radiology__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_radiology\\outpatient_radiology__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , m.hcpcs_code\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_radiology__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nand\nm.hcpcs_code = u.hcpcs_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_rehab__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_rehab", "outpatient_rehab__anchor_events"], "alias": "outpatient_rehab__anchor_events", "checksum": {"name": "sha256", "checksum": "4bb70dd1f04d03acdca86b3722ee52a522b1fd2a3ea6f87f20331319cc2db38a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.494577, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'outpatient rehabilitation'\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient rehabilitation'\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_rehab__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_rehab", "outpatient_rehab__generate_encounter_id"], "alias": "outpatient_rehab__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "1eb2fd33486505193428389fc7e6dde9e90b2cb9de1d77f6a9b33e2fdc25b647"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4971795, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_rehab__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_rehab__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_rehab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_rehab__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_rehab", "outpatient_rehab__match_claims_to_anchor"], "alias": "outpatient_rehab__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "3c145abd6f24b3fb491c882c9e6cf18de90239b33b952ea73bca14ca32e9bb99"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_rehab"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4992151, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_rehab__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_rehab__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_rehab\\outpatient_rehab__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_rehab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_substance_use__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_substance_use", "outpatient_substance_use__anchor_events"], "alias": "outpatient_substance_use__anchor_events", "checksum": {"name": "sha256", "checksum": "4f8b6a0469a7779e675066eda91326456d8be60b2b6e29f2a0ddd022549cd4ff"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5591104, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 = 'outpatient substance use'\r\n and claim_type = 'institutional'\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient substance use'\n and claim_type = 'institutional'\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_substance_use__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_substance_use", "outpatient_substance_use__generate_encounter_id"], "alias": "outpatient_substance_use__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "c82cbc2f4bb8e552fc8b48b4020816788152ca50a185960bef808daa2e486ab7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5611112, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_substance_use__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_substance_use__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__generate_encounter_id.sql", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_substance_use__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_substance_use__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_substance_use", "outpatient_substance_use__match_claims_to_anchor"], "alias": "outpatient_substance_use__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "4f6e66123ce03e146e27ab8921ab4ac8e8bb7ab6ef400efac03bfe3d9514d32e"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_substance_use"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5641108, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_substance_use__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_substance_use__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_substance_use\\outpatient_substance_use__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_substance_use__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_surgery__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__anchor_events.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_surgery", "outpatient_surgery__anchor_events"], "alias": "outpatient_surgery__anchor_events", "checksum": {"name": "sha256", "checksum": "80ecc315eb580906bf3da8fe8b514a5d11917f458e0f67531247bd8bc20eb713"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5976286, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category as (\r\n select distinct\r\n claim_id\r\n , patient_data_source_id\r\n , start_date\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 in ('outpatient surgery') --both inst and prof anchor\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_category", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__anchor_events.sql", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('outpatient surgery') --both inst and prof anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_surgery__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_surgery", "outpatient_surgery__generate_encounter_id"], "alias": "outpatient_surgery__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "2f2945f205f10317a0951068aa93bbe5f6a72d9b7f98f59b5d668175f087bbf4"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.5996256, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_surgery__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_surgery__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__generate_encounter_id.sql", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_surgery__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "outpatient_surgery__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "outpatient_surgery", "outpatient_surgery__match_claims_to_anchor"], "alias": "outpatient_surgery__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "e0ea3eab3cf8ec0fe83db38abd1586a9c66dec827e25175f0a24b9fbffdec91d"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "outpatient_surgery"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6016264, "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('outpatient_surgery__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "outpatient_surgery__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\outpatient_surgery\\outpatient_surgery__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_surgery__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__anchor_events": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "urgent_care__anchor_events", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__anchor_events.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__anchor_events.sql", "unique_id": "model.the_tuva_project.urgent_care__anchor_events", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "urgent_care", "urgent_care__anchor_events"], "alias": "urgent_care__anchor_events", "checksum": {"name": "sha256", "checksum": "c7f27df2ea5a317b680472766737eddc2085b80970ee6ce225ee336afa1d69db"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "urgent_care"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4800928, "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__anchor_events", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n select distinct\r\n claim_id\r\n from {{ ref('encounters__stg_medical_claim') }}\r\n where\r\n service_category_2 in ('urgent care') --both inst and prof anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__anchor_events.sql", "compiled": true, "compiled_code": "\n\n select distinct\n claim_id\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('urgent care') --both inst and prof anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__generate_encounter_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "urgent_care__generate_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__generate_encounter_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__generate_encounter_id.sql", "unique_id": "model.the_tuva_project.urgent_care__generate_encounter_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "urgent_care", "urgent_care__generate_encounter_id"], "alias": "urgent_care__generate_encounter_id", "checksum": {"name": "sha256", "checksum": "9ad208dc2f25c7a4408e1697548596422bbaf44541881e356a1c373f6757e3d0"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters", "urgent_care"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters", "urgent_care"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.4830902, "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__generate_encounter_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith anchor as \r\n(\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('urgent_care__anchor_events') }} u on m.claim_id = u.claim_id\r\n)\r\n\r\nselect patient_data_source_id\r\n,start_date\r\n,claim_id\r\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\r\nfrom anchor", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "urgent_care__anchor_events", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__anchor_events"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__generate_encounter_id.sql", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.urgent_care__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.urgent_care__match_claims_to_anchor": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "urgent_care__match_claims_to_anchor", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__match_claims_to_anchor.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__match_claims_to_anchor.sql", "unique_id": "model.the_tuva_project.urgent_care__match_claims_to_anchor", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "intermediate", "urgent_care", "urgent_care__match_claims_to_anchor"], "alias": "urgent_care__match_claims_to_anchor", "checksum": {"name": "sha256", "checksum": "52ae8795dd8dd96128c5a9dd89b52f600758e565ec01cf4bab7d9514c64763df"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "view", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.48532, "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__match_claims_to_anchor", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct m.patient_data_source_id\r\n , m.start_date\r\n , m.claim_id\r\n , m.claim_line_number\r\n , u.old_encounter_id\r\nfrom {{ ref('encounters__stg_medical_claim') }} m\r\ninner join {{ ref('urgent_care__generate_encounter_id') }} u on m.patient_data_source_id = u.patient_data_source_id\r\nand\r\nm.start_date = u.start_date", "language": "sql", "refs": [{"name": "encounters__stg_medical_claim", "package": null, "version": null}, {"name": "urgent_care__generate_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__generate_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\intermediate\\urgent_care\\urgent_care__match_claims_to_anchor.sql", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.urgent_care__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__patient_data_source_id": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__patient_data_source_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\staging\\encounters__patient_data_source_id.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\staging\\encounters__patient_data_source_id.sql", "unique_id": "model.the_tuva_project.encounters__patient_data_source_id", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__patient_data_source_id"], "alias": "encounters__patient_data_source_id", "checksum": {"name": "sha256", "checksum": "efc9b7cb9f98e26f679604a4586ce355a71a223b4ca28474e0da196e9d27a162"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6141446, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\nselect distinct patient_id\r\n,data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct patient_id\r\n,data_source\r\nfrom {{ ref('normalized_input__eligibility')}}\r\n)\r\n\r\nselect\r\npatient_id\r\n,data_source\r\n,dense_rank() over (order by concat(patient_id,data_source)) as patient_data_source_id\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.normalized_input__eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\staging\\encounters__patient_data_source_id.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct patient_id\n,data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\n\n\nunion distinct\n\n\nselect distinct patient_id\n,data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\npatient_id\n,data_source\n,dense_rank() over (order by concat(patient_id,data_source)) as patient_data_source_id\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_eligibility": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\staging\\encounters__stg_eligibility.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\staging\\encounters__stg_eligibility.sql", "unique_id": "model.the_tuva_project.encounters__stg_eligibility", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_eligibility"], "alias": "encounters__stg_eligibility", "checksum": {"name": "sha256", "checksum": "7b9cc7dd6cce92bdd50ff2aafe896ea772dd7fa4c572b919ade0a37d1dc4bbc8"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6111438, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_eligibility", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n e.patient_id\r\n , e.birth_date\r\n , e.gender\r\n , e.race\r\n , d.patient_data_source_id\r\n , row_number() over (partition by d.patient_data_source_id order by e.enrollment_start_date desc) patient_row_num\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__eligibility') }} e\r\ninner join {{ ref('encounters__patient_data_source_id') }} d on e.patient_id = d.patient_id\r\nand\r\ne.data_source = d.data_source", "language": "sql", "refs": [{"name": "normalized_input__eligibility", "package": null, "version": null}, {"name": "encounters__patient_data_source_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__eligibility", "model.the_tuva_project.encounters__patient_data_source_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\staging\\encounters__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\nselect\n e.patient_id\n , e.birth_date\n , e.gender\n , e.race\n , d.patient_data_source_id\n , row_number() over (partition by d.patient_data_source_id order by e.enrollment_start_date desc) patient_row_num\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_eligibility e\ninner join dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id d on e.patient_id = d.patient_id\nand\ne.data_source = d.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_inpatient_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__stg_inpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\staging\\encounters__stg_inpatient_institutional.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\staging\\encounters__stg_inpatient_institutional.sql", "unique_id": "model.the_tuva_project.encounters__stg_inpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_inpatient_institutional"], "alias": "encounters__stg_inpatient_institutional", "checksum": {"name": "sha256", "checksum": "2cb3edb87760c8b70696d7b02bb05d4a701d8a32e4df261db0bde83ce7d6524a"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.605134, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_inpatient_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect \r\n claim_id\r\n, service_type\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_inpatient_institutional') }} a", "language": "sql", "refs": [{"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\staging\\encounters__stg_inpatient_institutional.sql", "compiled": true, "compiled_code": "\n\nselect \n claim_id\n, service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_inpatient_institutional a", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_medical_claim": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\staging\\encounters__stg_medical_claim.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\staging\\encounters__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.encounters__stg_medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_medical_claim"], "alias": "encounters__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "4a2574b4bf6c07814997a5879c263b44e96bbd9920acc20b9c72ddc03640baf7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "Staging med claims for encounter grouper", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6036253, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n m.apr_drg_code\r\n , m.patient_id \r\n , d.patient_data_source_id\r\n , m.claim_id\r\n , m.claim_line_number\r\n , {{ dbt.concat([\"m.claim_id\",\"'|'\",\"cast(m.claim_line_number as \" ~ dbt.type_string() ~ \")\"]) }} as claim_line_id\r\n , m.claim_type\r\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\r\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\r\n , m.admission_date\r\n , m.discharge_date\r\n , m.claim_start_date\r\n , m.claim_end_date\r\n , m.claim_line_start_date\r\n , m.claim_line_end_date\r\n , g.service_category_1\r\n , g.service_category_2\r\n , g.service_category_3\r\n , m.bill_type_code\r\n , bt.bill_type_description\r\n , m.hcpcs_code\r\n , m.hcpcs_modifier_1\r\n , m.hcpcs_modifier_2\r\n , m.hcpcs_modifier_3\r\n , m.hcpcs_modifier_4\r\n , m.hcpcs_modifier_5\r\n , c.ccs_category\r\n , c.ccs_category_description\r\n , m.ms_drg_code\r\n , drg.ms_drg_description\r\n , m.admit_source_code\r\n , m.admit_type_code\r\n , m.place_of_service_code\r\n , pos.place_of_service_description\r\n , m.revenue_center_code\r\n , r.revenue_center_description\r\n , m.diagnosis_code_type\r\n , m.diagnosis_code_1\r\n , dx.default_ccsr_category_ip\r\n , dx.default_ccsr_category_op\r\n , dx.default_ccsr_category_description_ip\r\n , dx.default_ccsr_category_description_op\r\n , p.primary_taxonomy_code\r\n , p.primary_specialty_description\r\n , n.modality\r\n , m.billing_id\r\n , m.rendering_id\r\n , rend.primary_specialty_description as rend_primary_specialty_description\r\n , m.facility_id\r\n , m.discharge_disposition_code\r\n , m.paid_amount\r\n , m.charge_amount\r\n , m.allowed_amount\r\n , m.data_source\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('normalized_input__medical_claim') }} m\r\ninner join {{ ref('service_category__service_category_grouper') }} g on m.claim_id = g.claim_id\r\nand\r\nm.claim_line_number = g.claim_line_number\r\nand g.duplicate_row_number = 1\r\ninner join {{ ref('encounters__patient_data_source_id') }} d on m.patient_id = d.patient_id\r\nand\r\nm.data_source = d.data_source\r\nleft join {{ ref('ccsr__dxccsr_v2023_1_cleaned_map') }} dx on m.diagnosis_code_1 = dx.icd_10_cm_code\r\nleft join {{ ref('terminology__provider') }} p on m.facility_id = p.npi\r\nleft join {{ ref('terminology__ccs_services_procedures') }} c on m.hcpcs_code = c.hcpcs_code\r\nleft join {{ ref('terminology__nitos') }} n on m.hcpcs_code = n.hcpcs_code\r\nleft join {{ ref('terminology__ms_drg') }} drg on m.ms_drg_code = drg.ms_drg_code\r\nleft join {{ ref('terminology__revenue_center') }} r on m.revenue_center_code = r.revenue_center_code\r\nleft join {{ ref('terminology__place_of_service') }} pos on m.place_of_service_code = pos.place_of_service_code\r\nleft join {{ ref('terminology__bill_type') }} bt on m.bill_type_code = bt.bill_type_code\r\nleft join {{ ref('terminology__provider')}} rend on m.rendering_id = rend.npi", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "encounters__patient_data_source_id", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_cleaned_map", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__ccs_services_procedures", "package": null, "version": null}, {"name": "terminology__nitos", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.encounters__patient_data_source_id", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__revenue_center", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\staging\\encounters__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nselect\n m.apr_drg_code\n , m.patient_id \n , d.patient_data_source_id\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , g.service_category_1\n , g.service_category_2\n , g.service_category_3\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , m.hcpcs_modifier_1\n , m.hcpcs_modifier_2\n , m.hcpcs_modifier_3\n , m.hcpcs_modifier_4\n , m.hcpcs_modifier_5\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.admit_source_code\n , m.admit_type_code\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_type\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , n.modality\n , m.billing_id\n , m.rendering_id\n , rend.primary_specialty_description as rend_primary_specialty_description\n , m.facility_id\n , m.discharge_disposition_code\n , m.paid_amount\n , m.charge_amount\n , m.allowed_amount\n , m.data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.service_category_grouper g on m.claim_id = g.claim_id\nand\nm.claim_line_number = g.claim_line_number\nand g.duplicate_row_number = 1\ninner join dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id d on m.patient_id = d.patient_id\nand\nm.data_source = d.data_source\nleft join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join dev_thuxuan.terminology.provider p on m.facility_id = p.npi\nleft join dev_thuxuan.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join dev_thuxuan.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join dev_thuxuan.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join dev_thuxuan.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join dev_thuxuan.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join dev_thuxuan.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join dev_thuxuan.terminology.provider rend on m.rendering_id = rend.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_outpatient_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__stg_outpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\staging\\encounters__stg_outpatient_institutional.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\staging\\encounters__stg_outpatient_institutional.sql", "unique_id": "model.the_tuva_project.encounters__stg_outpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_outpatient_institutional"], "alias": "encounters__stg_outpatient_institutional", "checksum": {"name": "sha256", "checksum": "2f99594a1c13acdb5b1a08f521865532c51e6b9cd6b4d13ffee9fbf4428b66d9"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6071444, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_outpatient_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect distinct \r\n claim_id\r\n, service_type\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_outpatient_institutional') }} a", "language": "sql", "refs": [{"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\staging\\encounters__stg_outpatient_institutional.sql", "compiled": true, "compiled_code": "\n\n\nselect distinct \n claim_id\n, service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_outpatient_institutional a", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.encounters__stg_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "encounters__stg_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\encounters\\staging\\encounters__stg_professional.sql", "original_file_path": "models\\claims_preprocessing\\encounters\\staging\\encounters__stg_professional.sql", "unique_id": "model.the_tuva_project.encounters__stg_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "encounters", "staging", "encounters__stg_professional"], "alias": "encounters__stg_professional", "checksum": {"name": "sha256", "checksum": "f6b7919441d48de213dcaf87d5473374ccf5054aad7e91fb5ca7df0206ba8b78"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": ["claims_preprocessing", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["claims_preprocessing", "encounters"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\encounters\\encounter_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "materialized": "table", "tags": ["claims_preprocessing", "encounters"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6091442, "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n claim_id\r\n, claim_line_number\r\n, claim_line_id\r\n, service_type\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_professional') }} a", "language": "sql", "refs": [{"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\encounters\\staging\\encounters__stg_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, claim_line_number\n, claim_line_id\n, service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_professional a", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__eligibility": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\final\\normalized_input__eligibility.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\final\\normalized_input__eligibility.sql", "unique_id": "model.the_tuva_project.normalized_input__eligibility", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "final", "normalized_input__eligibility"], "alias": "normalized_input_eligibility", "checksum": {"name": "sha256", "checksum": "4dda3892b0dad0f935526be18545480878d097013610b392a487dbedb4f7a4a2"}, "config": {"enabled": true, "alias": "normalized_input_eligibility", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "The eligibility table contains information on patient health plan and \nsupplemental insurance eligibility.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_id": {"name": "subscriber_id", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Biological sex of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "Race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "Date the patient was born.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "Flag indicating if the patient is deceased", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_type": {"name": "payer_type", "description": "Type of payer (e.g. commercial, medicare, medicaid, etc.).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__payer_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "Original reason for Medicare entitlement code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "Patient's first name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Patient's last name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "Patient's social security number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_relation": {"name": "subscriber_relation", "description": "Relationship to the policy holder (self, spouse, dependent, etc)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "Patient's street address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "Patient's city of address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "State the patient lives in (most recent known address)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "Zip code the patient lives in (most recent known address).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "phone": {"name": "phone", "description": "Patient's phone number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "normalized_input_eligibility", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2200732, "relation_name": "dev_thuxuan.claims_preprocessing.normalized_input_eligibility", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n cast(elig.patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(elig.member_id as {{ dbt.type_string() }} ) as member_id\r\n , cast(elig.subscriber_id as {{ dbt.type_string() }} ) as subscriber_id\r\n , cast(elig.gender as {{ dbt.type_string() }} ) as gender\r\n , cast(elig.race as {{ dbt.type_string() }} ) as race\r\n , cast(date_norm.normalized_birth_date as date ) as birth_date\r\n , cast(date_norm.normalized_death_date as date ) as death_date\r\n , cast(elig.death_flag as int ) as death_flag\r\n , cast(date_norm.normalized_enrollment_start_date as date ) as enrollment_start_date\r\n , cast(date_norm.normalized_enrollment_end_date as date ) as enrollment_end_date\r\n , cast(elig.payer as {{ dbt.type_string() }} ) as payer\r\n , cast(elig.payer_type as {{ dbt.type_string() }} ) as payer_type\r\n , cast(elig.{{ quote_column('plan') }} as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\r\n , cast(elig.original_reason_entitlement_code as {{ dbt.type_string() }} ) as original_reason_entitlement_code\r\n , cast(elig.dual_status_code as {{ dbt.type_string() }} ) as dual_status_code\r\n , cast(elig.medicare_status_code as {{ dbt.type_string() }} ) as medicare_status_code\r\n , cast(elig.first_name as {{ dbt.type_string() }} ) as first_name\r\n , cast(elig.last_name as {{ dbt.type_string() }} ) as last_name\r\n , cast(elig.social_security_number as {{ dbt.type_string() }} ) as social_security_number\r\n , cast(elig.subscriber_relation as {{ dbt.type_string() }} ) as subscriber_relation\r\n , cast(elig.address as {{ dbt.type_string() }} ) as address\r\n , cast(elig.city as {{ dbt.type_string() }} ) as city\r\n , cast(elig.state as {{ dbt.type_string() }} ) as state\r\n , cast(elig.zip_code as {{ dbt.type_string() }} ) as zip_code\r\n , cast(elig.phone as {{ dbt.type_string() }} ) as phone\r\n , cast(elig.data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_string() }} ) as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_eligibility') }} elig\r\nleft join {{ ref('normalized_input__int_eligibility_dates_normalize') }} date_norm\r\n on elig.patient_id_key = date_norm.patient_id_key", "language": "sql", "refs": [{"name": "normalized_input__stg_eligibility", "package": null, "version": null}, {"name": "normalized_input__int_eligibility_dates_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.normalized_input__stg_eligibility", "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\final\\normalized_input__eligibility.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select\n cast(elig.patient_id as TEXT ) as patient_id\n , cast(elig.member_id as TEXT ) as member_id\n , cast(elig.subscriber_id as TEXT ) as subscriber_id\n , cast(elig.gender as TEXT ) as gender\n , cast(elig.race as TEXT ) as race\n , cast(date_norm.normalized_birth_date as date ) as birth_date\n , cast(date_norm.normalized_death_date as date ) as death_date\n , cast(elig.death_flag as int ) as death_flag\n , cast(date_norm.normalized_enrollment_start_date as date ) as enrollment_start_date\n , cast(date_norm.normalized_enrollment_end_date as date ) as enrollment_end_date\n , cast(elig.payer as TEXT ) as payer\n , cast(elig.payer_type as TEXT ) as payer_type\n , cast(elig.plan as TEXT ) as plan\n , cast(elig.original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(elig.dual_status_code as TEXT ) as dual_status_code\n , cast(elig.medicare_status_code as TEXT ) as medicare_status_code\n , cast(elig.first_name as TEXT ) as first_name\n , cast(elig.last_name as TEXT ) as last_name\n , cast(elig.social_security_number as TEXT ) as social_security_number\n , cast(elig.subscriber_relation as TEXT ) as subscriber_relation\n , cast(elig.address as TEXT ) as address\n , cast(elig.city as TEXT ) as city\n , cast(elig.state as TEXT ) as state\n , cast(elig.zip_code as TEXT ) as zip_code\n , cast(elig.phone as TEXT ) as phone\n , cast(elig.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_eligibility_dates_normalize date_norm\n on elig.patient_id_key = date_norm.patient_id_key", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_eligibility", "sql": " __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__medical_claim": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\final\\normalized_input__medical_claim.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\final\\normalized_input__medical_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "final", "normalized_input__medical_claim"], "alias": "normalized_input_medical_claim", "checksum": {"name": "sha256", "checksum": "1534e6121eab31afe5b31a645948d50107e39ee003fe49c2026ff84993d6d33a"}, "config": {"enabled": true, "alias": "normalized_input_medical_claim", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "The medical claim table contains information on services rendered to \npatients and billed by the provider to the insurer as claims.\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__claim_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "Start date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_start_date": {"name": "claim_line_start_date", "description": "Start date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_end_date": {"name": "claim_line_end_date", "description": "End date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "Admission date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Discharge date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Place of service for the claim (professional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__place_of_service.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__bill_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code for the claim line (institutional only and typically multiple codes per claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__revenue_center.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_unit_quantity": {"name": "service_unit_quantity", "description": "The number of units for the particular revenue center code.", "meta": {}, "data_type": "float", "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "HCPCS level 1 or level 2 code for the claim line.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "1st modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "2nd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "3rd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "4th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "5th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_npi": {"name": "rendering_npi", "description": "Rendering NPI for the claim (typically represents the physician or entity providing services).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_npi": {"name": "billing_npi", "description": "Billing NPI for the claim (typically represents organization billing the claim).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_npi": {"name": "facility_npi", "description": "Facility NPI for the claim (typically represents the facility where services were performed).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid on the claim by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient) on the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_cost_amount": {"name": "total_cost_amount", "description": "The total amount paid on the claim by different parties.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_type": {"name": "diagnosis_code_type", "description": "Indicates the type of diagnosis code (e.g. ICD-10-CM).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_1": {"name": "diagnosis_code_1", "description": "1st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_2": {"name": "diagnosis_code_2", "description": "2nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_3": {"name": "diagnosis_code_3", "description": "3rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_4": {"name": "diagnosis_code_4", "description": "4th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_5": {"name": "diagnosis_code_5", "description": "5th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_6": {"name": "diagnosis_code_6", "description": "6th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_7": {"name": "diagnosis_code_7", "description": "7th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_8": {"name": "diagnosis_code_8", "description": "8th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_9": {"name": "diagnosis_code_9", "description": "9th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_10": {"name": "diagnosis_code_10", "description": "10th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_11": {"name": "diagnosis_code_11", "description": "11th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_12": {"name": "diagnosis_code_12", "description": "12th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_13": {"name": "diagnosis_code_13", "description": "13th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_14": {"name": "diagnosis_code_14", "description": "14th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_15": {"name": "diagnosis_code_15", "description": "15th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_16": {"name": "diagnosis_code_16", "description": "16th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_17": {"name": "diagnosis_code_17", "description": "17th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_18": {"name": "diagnosis_code_18", "description": "18th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_19": {"name": "diagnosis_code_19", "description": "19th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_20": {"name": "diagnosis_code_20", "description": "20th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_21": {"name": "diagnosis_code_21", "description": "21st ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_22": {"name": "diagnosis_code_22", "description": "22nd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_23": {"name": "diagnosis_code_23", "description": "23rd ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_24": {"name": "diagnosis_code_24", "description": "24th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code_25": {"name": "diagnosis_code_25", "description": "25th ICD (9 or 10) CM diagnosis code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_1": {"name": "diagnosis_poa_1", "description": "Present on admission code for the 1st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_2": {"name": "diagnosis_poa_2", "description": "Present on admission code for the 2nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_3": {"name": "diagnosis_poa_3", "description": "Present on admission code for the 3rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_4": {"name": "diagnosis_poa_4", "description": "Present on admission code for the 4th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_5": {"name": "diagnosis_poa_5", "description": "Present on admission code for the 5th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_6": {"name": "diagnosis_poa_6", "description": "Present on admission code for the 6th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_7": {"name": "diagnosis_poa_7", "description": "Present on admission code for the 7th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_8": {"name": "diagnosis_poa_8", "description": "Present on admission code for the 8th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_9": {"name": "diagnosis_poa_9", "description": "Present on admission code for the 9th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_10": {"name": "diagnosis_poa_10", "description": "Present on admission code for the 10th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_11": {"name": "diagnosis_poa_11", "description": "Present on admission code for the 11th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_12": {"name": "diagnosis_poa_12", "description": "Present on admission code for the 12th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_13": {"name": "diagnosis_poa_13", "description": "Present on admission code for the 13th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_14": {"name": "diagnosis_poa_14", "description": "Present on admission code for the 14th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_15": {"name": "diagnosis_poa_15", "description": "Present on admission code for the 15th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_16": {"name": "diagnosis_poa_16", "description": "Present on admission code for the 16th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_17": {"name": "diagnosis_poa_17", "description": "Present on admission code for the 17th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_18": {"name": "diagnosis_poa_18", "description": "Present on admission code for the 18th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_19": {"name": "diagnosis_poa_19", "description": "Present on admission code for the 19th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_20": {"name": "diagnosis_poa_20", "description": "Present on admission code for the 20th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_21": {"name": "diagnosis_poa_21", "description": "Present on admission code for the 21st diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_22": {"name": "diagnosis_poa_22", "description": "Present on admission code for the 22nd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_23": {"name": "diagnosis_poa_23", "description": "Present on admission code for the 23rd diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_24": {"name": "diagnosis_poa_24", "description": "Present on admission code for the 24th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_poa_25": {"name": "diagnosis_poa_25", "description": "Present on admission code for the 25th diagnosis on the claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_type": {"name": "procedure_code_type", "description": "Indicates the type of procedure code (e.g. ICD-10-PCS).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_1": {"name": "procedure_code_1", "description": "1st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_2": {"name": "procedure_code_2", "description": "2nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_3": {"name": "procedure_code_3", "description": "3rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_4": {"name": "procedure_code_4", "description": "4th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_5": {"name": "procedure_code_5", "description": "5th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_6": {"name": "procedure_code_6", "description": "6th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_7": {"name": "procedure_code_7", "description": "7th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_8": {"name": "procedure_code_8", "description": "8th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_9": {"name": "procedure_code_9", "description": "9th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_10": {"name": "procedure_code_10", "description": "10th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_11": {"name": "procedure_code_11", "description": "11th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_12": {"name": "procedure_code_12", "description": "12th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_13": {"name": "procedure_code_13", "description": "13th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_14": {"name": "procedure_code_14", "description": "14th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_15": {"name": "procedure_code_15", "description": "15th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_16": {"name": "procedure_code_16", "description": "16th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_17": {"name": "procedure_code_17", "description": "17th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_18": {"name": "procedure_code_18", "description": "18th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_19": {"name": "procedure_code_19", "description": "19th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_20": {"name": "procedure_code_20", "description": "20th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_21": {"name": "procedure_code_21", "description": "21st ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_22": {"name": "procedure_code_22", "description": "22nd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_23": {"name": "procedure_code_23", "description": "23rd ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_24": {"name": "procedure_code_24", "description": "24th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code_25": {"name": "procedure_code_25", "description": "25th ICD (9 or 10) procedure code on the claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_1": {"name": "procedure_date_1", "description": "Date of the 1st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_2": {"name": "procedure_date_2", "description": "Date of the 2nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_3": {"name": "procedure_date_3", "description": "Date of the 3rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_4": {"name": "procedure_date_4", "description": "Date of the 4th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_5": {"name": "procedure_date_5", "description": "Date of the 5th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_6": {"name": "procedure_date_6", "description": "Date of the 6th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_7": {"name": "procedure_date_7", "description": "Date of the 7th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_8": {"name": "procedure_date_8", "description": "Date of the 8th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_9": {"name": "procedure_date_9", "description": "Date of the 9th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_10": {"name": "procedure_date_10", "description": "Date of the 10th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_11": {"name": "procedure_date_11", "description": "Date of the 11th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_12": {"name": "procedure_date_12", "description": "Date of the 12th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_13": {"name": "procedure_date_13", "description": "Date of the 13th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_14": {"name": "procedure_date_14", "description": "Date of the 14th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_15": {"name": "procedure_date_15", "description": "Date of the 15th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_16": {"name": "procedure_date_16", "description": "Date of the 16th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_17": {"name": "procedure_date_17", "description": "Date of the 17th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_18": {"name": "procedure_date_18", "description": "Date of the 18th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_19": {"name": "procedure_date_19", "description": "Date of the 19th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_20": {"name": "procedure_date_20", "description": "Date of the 20th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_21": {"name": "procedure_date_21", "description": "Date of the 21st procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_22": {"name": "procedure_date_22", "description": "Date of the 22nd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_23": {"name": "procedure_date_23", "description": "Date of the 23rd procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_24": {"name": "procedure_date_24", "description": "Date of the 24th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date_25": {"name": "procedure_date_25", "description": "Date of the 25th procedure on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "normalized_input_medical_claim", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2280738, "relation_name": "dev_thuxuan.claims_preprocessing.normalized_input_medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n\tcast(med.claim_id as {{ dbt.type_string() }} ) as claim_id\r\n\t, cast(med.claim_line_number as int ) as claim_line_number\r\n\t, cast(med.claim_type as {{ dbt.type_string() }} ) as claim_type\r\n\t, cast(med.patient_id as {{ dbt.type_string() }} ) as patient_id\r\n\t, cast(med.member_id as {{ dbt.type_string() }} ) as member_id\r\n\t, cast(med.payer as {{ dbt.type_string() }} ) as payer\r\n , cast(med.{{ quote_column('plan') }} as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\r\n\t, cast(coalesce(dates.minimum_claim_start_date, undetermined.claim_start_date) as date ) as claim_start_date\r\n\t, cast(coalesce(dates.maximum_claim_end_date, undetermined.claim_start_date) as date ) as claim_end_date\r\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_start_date, undetermined.claim_line_start_date) as date ) as claim_line_start_date\r\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_end_date, undetermined.claim_line_end_date) as date ) as claim_line_end_date\r\n\t, cast(coalesce(dates.minimum_admission_date, undetermined.admission_date) as date ) as admission_date\r\n\t, cast(coalesce(dates.maximum_discharge_date, undetermined.discharge_date) as date ) as discharge_date\r\n\t, cast(coalesce(ad_source.normalized_code, undetermined.admit_source_code) as {{ dbt.type_string() }} ) as admit_source_code\r\n , cast(coalesce(ad_source.normalized_description, undetermined.admit_source_description) as {{ dbt.type_string() }} ) as admit_source_description\r\n\t, cast(coalesce(ad_type.normalized_code, undetermined.admit_type_code) as {{ dbt.type_string() }} ) as admit_type_code\r\n , cast(coalesce(ad_type.normalized_description, undetermined.admit_type_description) as {{ dbt.type_string() }} ) as admit_type_description\r\n\t, cast(coalesce(disch_disp.normalized_code, undetermined.discharge_disposition_code) as {{ dbt.type_string() }} ) as discharge_disposition_code\r\n , cast(coalesce(disch_disp.normalized_description, undetermined.discharge_disposition_description) as {{ dbt.type_string() }} ) as discharge_disposition_description\r\n\t, cast(coalesce(pos.normalized_code, undetermined.place_of_service_code) as {{ dbt.type_string() }} ) as place_of_service_code\r\n , cast(coalesce(pos.normalized_description, undetermined.place_of_service_description) as {{ dbt.type_string() }} ) as place_of_service_description\r\n\t, cast(coalesce(bill.normalized_code, undetermined.bill_type_code) as {{ dbt.type_string() }} ) as bill_type_code\r\n , cast(coalesce(bill.normalized_description, undetermined.bill_type_description) as {{ dbt.type_string() }} ) as bill_type_description\r\n\t, cast(coalesce(ms.normalized_code, undetermined.ms_drg_code) as {{ dbt.type_string() }} ) as ms_drg_code\r\n , cast(coalesce(ms.normalized_description, undetermined.ms_drg_description) as {{ dbt.type_string() }} ) as ms_drg_description\r\n\t, cast(coalesce(apr.normalized_code, undetermined.apr_drg_code) as {{ dbt.type_string() }} ) as apr_drg_code\r\n , cast(coalesce(apr.normalized_description, undetermined.apr_drg_description) as {{ dbt.type_string() }} ) as apr_drg_description\r\n\t, cast(coalesce(rev.normalized_code, undetermined.revenue_center_code) as {{ dbt.type_string() }} ) as revenue_center_code\r\n , cast(coalesce(rev.normalized_description, undetermined.revenue_center_description) as {{ dbt.type_string() }} ) as revenue_center_description\r\n\t, cast(med.service_unit_quantity as {{ dbt.type_string() }} ) as service_unit_quantity\r\n\t, cast(med.hcpcs_code as {{ dbt.type_string() }} ) as hcpcs_code\r\n\t, cast(med.hcpcs_modifier_1 as {{ dbt.type_string() }} ) as hcpcs_modifier_1\r\n\t, cast(med.hcpcs_modifier_2 as {{ dbt.type_string() }} ) as hcpcs_modifier_2\r\n\t, cast(med.hcpcs_modifier_3 as {{ dbt.type_string() }} ) as hcpcs_modifier_3\r\n\t, cast(med.hcpcs_modifier_4 as {{ dbt.type_string() }} ) as hcpcs_modifier_4\r\n\t, cast(med.hcpcs_modifier_5 as {{ dbt.type_string() }} ) as hcpcs_modifier_5\r\n\t, cast(coalesce(med_npi.normalized_rendering_npi, undetermined.rendering_npi) as {{ dbt.type_string() }} ) as rendering_id\r\n , cast(med.rendering_tin as {{ dbt.type_string() }} ) as rendering_tin\r\n , cast(coalesce(med_npi.normalized_rendering_name, undetermined.rendering_name) as {{ dbt.type_string() }} ) as rendering_name\r\n\t, cast(coalesce(med_npi.normalized_billing_npi, undetermined.billing_npi) as {{ dbt.type_string() }} ) as billing_id\r\n , cast(med.billing_tin as {{ dbt.type_string() }} ) as billing_tin\r\n , cast(coalesce(med_npi.normalized_billing_name, undetermined.billing_name) as {{ dbt.type_string() }} ) as billing_name\r\n\t, cast(coalesce(med_npi.normalized_facility_npi, undetermined.facility_npi) as {{ dbt.type_string() }} ) as facility_id\r\n\t, cast(coalesce(med_npi.normalized_facility_name, undetermined.facility_name) as {{ dbt.type_string() }} ) as facility_name\r\n , cast(med.paid_date as date ) as paid_date\r\n\t, cast(med.paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\r\n\t, cast(med.allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\r\n\t, cast(med.charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\r\n\t, cast(med.coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\r\n\t, cast(med.copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\r\n\t, cast(med.deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\r\n\t, cast(med.total_cost_amount as {{ dbt.type_numeric() }} ) as total_cost_amount\r\n\t, cast(med.diagnosis_code_type as {{ dbt.type_string() }} ) as diagnosis_code_type\r\n\t, cast(coalesce(dx_code.diagnosis_code_1, undetermined.diagnosis_code_1) as {{ dbt.type_string() }} ) as diagnosis_code_1\r\n\t, cast(coalesce(dx_code.diagnosis_code_2, undetermined.diagnosis_code_2) as {{ dbt.type_string() }} ) as diagnosis_code_2\r\n\t, cast(coalesce(dx_code.diagnosis_code_3, undetermined.diagnosis_code_3) as {{ dbt.type_string() }} ) as diagnosis_code_3\r\n\t, cast(coalesce(dx_code.diagnosis_code_4, undetermined.diagnosis_code_4) as {{ dbt.type_string() }} ) as diagnosis_code_4\r\n\t, cast(coalesce(dx_code.diagnosis_code_5, undetermined.diagnosis_code_5) as {{ dbt.type_string() }} ) as diagnosis_code_5\r\n\t, cast(coalesce(dx_code.diagnosis_code_6, undetermined.diagnosis_code_6) as {{ dbt.type_string() }} ) as diagnosis_code_6\r\n\t, cast(coalesce(dx_code.diagnosis_code_7, undetermined.diagnosis_code_7) as {{ dbt.type_string() }} ) as diagnosis_code_7\r\n\t, cast(coalesce(dx_code.diagnosis_code_8, undetermined.diagnosis_code_8) as {{ dbt.type_string() }} ) as diagnosis_code_8\r\n\t, cast(coalesce(dx_code.diagnosis_code_9, undetermined.diagnosis_code_9) as {{ dbt.type_string() }} ) as diagnosis_code_9\r\n\t, cast(coalesce(dx_code.diagnosis_code_10, undetermined.diagnosis_code_10) as {{ dbt.type_string() }} ) as diagnosis_code_10\r\n\t, cast(coalesce(dx_code.diagnosis_code_11, undetermined.diagnosis_code_11) as {{ dbt.type_string() }} ) as diagnosis_code_11\r\n\t, cast(coalesce(dx_code.diagnosis_code_12, undetermined.diagnosis_code_12) as {{ dbt.type_string() }} ) as diagnosis_code_12\r\n\t, cast(coalesce(dx_code.diagnosis_code_13, undetermined.diagnosis_code_13) as {{ dbt.type_string() }} ) as diagnosis_code_13\r\n\t, cast(coalesce(dx_code.diagnosis_code_14, undetermined.diagnosis_code_14) as {{ dbt.type_string() }} ) as diagnosis_code_14\r\n\t, cast(coalesce(dx_code.diagnosis_code_15, undetermined.diagnosis_code_15) as {{ dbt.type_string() }} ) as diagnosis_code_15\r\n\t, cast(coalesce(dx_code.diagnosis_code_16, undetermined.diagnosis_code_16) as {{ dbt.type_string() }} ) as diagnosis_code_16\r\n\t, cast(coalesce(dx_code.diagnosis_code_17, undetermined.diagnosis_code_17) as {{ dbt.type_string() }} ) as diagnosis_code_17\r\n\t, cast(coalesce(dx_code.diagnosis_code_18, undetermined.diagnosis_code_18) as {{ dbt.type_string() }} ) as diagnosis_code_18\r\n\t, cast(coalesce(dx_code.diagnosis_code_19, undetermined.diagnosis_code_19) as {{ dbt.type_string() }} ) as diagnosis_code_19\r\n\t, cast(coalesce(dx_code.diagnosis_code_20, undetermined.diagnosis_code_20) as {{ dbt.type_string() }} ) as diagnosis_code_20\r\n\t, cast(coalesce(dx_code.diagnosis_code_21, undetermined.diagnosis_code_21) as {{ dbt.type_string() }} ) as diagnosis_code_21\r\n\t, cast(coalesce(dx_code.diagnosis_code_22, undetermined.diagnosis_code_22) as {{ dbt.type_string() }} ) as diagnosis_code_22\r\n\t, cast(coalesce(dx_code.diagnosis_code_23, undetermined.diagnosis_code_23) as {{ dbt.type_string() }} ) as diagnosis_code_23\r\n\t, cast(coalesce(dx_code.diagnosis_code_24, undetermined.diagnosis_code_24) as {{ dbt.type_string() }} ) as diagnosis_code_24\r\n\t, cast(coalesce(dx_code.diagnosis_code_25, undetermined.diagnosis_code_25) as {{ dbt.type_string() }} ) as diagnosis_code_25\r\n\t, cast(coalesce(poa.diagnosis_poa_1, undetermined.diagnosis_poa_1) as {{ dbt.type_string() }} ) as diagnosis_poa_1\r\n\t, cast(coalesce(poa.diagnosis_poa_2, undetermined.diagnosis_poa_2) as {{ dbt.type_string() }} ) as diagnosis_poa_2\r\n\t, cast(coalesce(poa.diagnosis_poa_3, undetermined.diagnosis_poa_3) as {{ dbt.type_string() }} ) as diagnosis_poa_3\r\n\t, cast(coalesce(poa.diagnosis_poa_4, undetermined.diagnosis_poa_4) as {{ dbt.type_string() }} ) as diagnosis_poa_4\r\n\t, cast(coalesce(poa.diagnosis_poa_5, undetermined.diagnosis_poa_5) as {{ dbt.type_string() }} ) as diagnosis_poa_5\r\n\t, cast(coalesce(poa.diagnosis_poa_6, undetermined.diagnosis_poa_6) as {{ dbt.type_string() }} ) as diagnosis_poa_6\r\n\t, cast(coalesce(poa.diagnosis_poa_7, undetermined.diagnosis_poa_7) as {{ dbt.type_string() }} ) as diagnosis_poa_7\r\n\t, cast(coalesce(poa.diagnosis_poa_8, undetermined.diagnosis_poa_8) as {{ dbt.type_string() }} ) as diagnosis_poa_8\r\n\t, cast(coalesce(poa.diagnosis_poa_9, undetermined.diagnosis_poa_9) as {{ dbt.type_string() }} ) as diagnosis_poa_9\r\n\t, cast(coalesce(poa.diagnosis_poa_10, undetermined.diagnosis_poa_10) as {{ dbt.type_string() }} ) as diagnosis_poa_10\r\n\t, cast(coalesce(poa.diagnosis_poa_11, undetermined.diagnosis_poa_11) as {{ dbt.type_string() }} ) as diagnosis_poa_11\r\n\t, cast(coalesce(poa.diagnosis_poa_12, undetermined.diagnosis_poa_12) as {{ dbt.type_string() }} ) as diagnosis_poa_12\r\n\t, cast(coalesce(poa.diagnosis_poa_13, undetermined.diagnosis_poa_13) as {{ dbt.type_string() }} ) as diagnosis_poa_13\r\n\t, cast(coalesce(poa.diagnosis_poa_14, undetermined.diagnosis_poa_14) as {{ dbt.type_string() }} ) as diagnosis_poa_14\r\n\t, cast(coalesce(poa.diagnosis_poa_15, undetermined.diagnosis_poa_15) as {{ dbt.type_string() }} ) as diagnosis_poa_15\r\n\t, cast(coalesce(poa.diagnosis_poa_16, undetermined.diagnosis_poa_16) as {{ dbt.type_string() }} ) as diagnosis_poa_16\r\n\t, cast(coalesce(poa.diagnosis_poa_17, undetermined.diagnosis_poa_17) as {{ dbt.type_string() }} ) as diagnosis_poa_17\r\n\t, cast(coalesce(poa.diagnosis_poa_18, undetermined.diagnosis_poa_18) as {{ dbt.type_string() }} ) as diagnosis_poa_18\r\n\t, cast(coalesce(poa.diagnosis_poa_19, undetermined.diagnosis_poa_19) as {{ dbt.type_string() }} ) as diagnosis_poa_19\r\n\t, cast(coalesce(poa.diagnosis_poa_20, undetermined.diagnosis_poa_20) as {{ dbt.type_string() }} ) as diagnosis_poa_20\r\n\t, cast(coalesce(poa.diagnosis_poa_21, undetermined.diagnosis_poa_21) as {{ dbt.type_string() }} ) as diagnosis_poa_21\r\n\t, cast(coalesce(poa.diagnosis_poa_22, undetermined.diagnosis_poa_22) as {{ dbt.type_string() }} ) as diagnosis_poa_22\r\n\t, cast(coalesce(poa.diagnosis_poa_23, undetermined.diagnosis_poa_23) as {{ dbt.type_string() }} ) as diagnosis_poa_23\r\n\t, cast(coalesce(poa.diagnosis_poa_24, undetermined.diagnosis_poa_24) as {{ dbt.type_string() }} ) as diagnosis_poa_24\r\n\t, cast(coalesce(poa.diagnosis_poa_25, undetermined.diagnosis_poa_25) as {{ dbt.type_string() }} ) as diagnosis_poa_25\r\n\t, cast(med.procedure_code_type as {{ dbt.type_string() }} ) as procedure_code_type\r\n\t, cast(coalesce(px_code.procedure_code_1, undetermined.procedure_code_1) as {{ dbt.type_string() }} ) as procedure_code_1\r\n\t, cast(coalesce(px_code.procedure_code_2, undetermined.procedure_code_2) as {{ dbt.type_string() }} ) as procedure_code_2\r\n\t, cast(coalesce(px_code.procedure_code_3, undetermined.procedure_code_3) as {{ dbt.type_string() }} ) as procedure_code_3\r\n\t, cast(coalesce(px_code.procedure_code_4, undetermined.procedure_code_4) as {{ dbt.type_string() }} ) as procedure_code_4\r\n\t, cast(coalesce(px_code.procedure_code_5, undetermined.procedure_code_5) as {{ dbt.type_string() }} ) as procedure_code_5\r\n\t, cast(coalesce(px_code.procedure_code_6, undetermined.procedure_code_6) as {{ dbt.type_string() }} ) as procedure_code_6\r\n\t, cast(coalesce(px_code.procedure_code_7, undetermined.procedure_code_7) as {{ dbt.type_string() }} ) as procedure_code_7\r\n\t, cast(coalesce(px_code.procedure_code_8, undetermined.procedure_code_8) as {{ dbt.type_string() }} ) as procedure_code_8\r\n\t, cast(coalesce(px_code.procedure_code_9, undetermined.procedure_code_9) as {{ dbt.type_string() }} ) as procedure_code_9\r\n\t, cast(coalesce(px_code.procedure_code_10, undetermined.procedure_code_10) as {{ dbt.type_string() }} ) as procedure_code_10\r\n\t, cast(coalesce(px_code.procedure_code_11, undetermined.procedure_code_11) as {{ dbt.type_string() }} ) as procedure_code_11\r\n\t, cast(coalesce(px_code.procedure_code_12, undetermined.procedure_code_12) as {{ dbt.type_string() }} ) as procedure_code_12\r\n\t, cast(coalesce(px_code.procedure_code_13, undetermined.procedure_code_13) as {{ dbt.type_string() }} ) as procedure_code_13\r\n\t, cast(coalesce(px_code.procedure_code_14, undetermined.procedure_code_14) as {{ dbt.type_string() }} ) as procedure_code_14\r\n\t, cast(coalesce(px_code.procedure_code_15, undetermined.procedure_code_15) as {{ dbt.type_string() }} ) as procedure_code_15\r\n\t, cast(coalesce(px_code.procedure_code_16, undetermined.procedure_code_16) as {{ dbt.type_string() }} ) as procedure_code_16\r\n\t, cast(coalesce(px_code.procedure_code_17, undetermined.procedure_code_17) as {{ dbt.type_string() }} ) as procedure_code_17\r\n\t, cast(coalesce(px_code.procedure_code_18, undetermined.procedure_code_18) as {{ dbt.type_string() }} ) as procedure_code_18\r\n\t, cast(coalesce(px_code.procedure_code_19, undetermined.procedure_code_19) as {{ dbt.type_string() }} ) as procedure_code_19\r\n\t, cast(coalesce(px_code.procedure_code_20, undetermined.procedure_code_20) as {{ dbt.type_string() }} ) as procedure_code_20\r\n\t, cast(coalesce(px_code.procedure_code_21, undetermined.procedure_code_21) as {{ dbt.type_string() }} ) as procedure_code_21\r\n\t, cast(coalesce(px_code.procedure_code_22, undetermined.procedure_code_22) as {{ dbt.type_string() }} ) as procedure_code_22\r\n\t, cast(coalesce(px_code.procedure_code_23, undetermined.procedure_code_23) as {{ dbt.type_string() }} ) as procedure_code_23\r\n\t, cast(coalesce(px_code.procedure_code_24, undetermined.procedure_code_24) as {{ dbt.type_string() }} ) as procedure_code_24\r\n\t, cast(coalesce(px_code.procedure_code_25, undetermined.procedure_code_25) as {{ dbt.type_string() }} ) as procedure_code_25\r\n\t, cast(coalesce(px_date.procedure_date_1, undetermined.procedure_date_1) as date ) as procedure_date_1\r\n\t, cast(coalesce(px_date.procedure_date_2, undetermined.procedure_date_2) as date ) as procedure_date_2\r\n\t, cast(coalesce(px_date.procedure_date_3, undetermined.procedure_date_3) as date ) as procedure_date_3\r\n\t, cast(coalesce(px_date.procedure_date_4, undetermined.procedure_date_4) as date ) as procedure_date_4\r\n\t, cast(coalesce(px_date.procedure_date_5, undetermined.procedure_date_5) as date ) as procedure_date_5\r\n\t, cast(coalesce(px_date.procedure_date_6, undetermined.procedure_date_6) as date ) as procedure_date_6\r\n\t, cast(coalesce(px_date.procedure_date_7, undetermined.procedure_date_7) as date ) as procedure_date_7\r\n\t, cast(coalesce(px_date.procedure_date_8, undetermined.procedure_date_8) as date ) as procedure_date_8\r\n\t, cast(coalesce(px_date.procedure_date_9, undetermined.procedure_date_9) as date ) as procedure_date_9\r\n\t, cast(coalesce(px_date.procedure_date_10, undetermined.procedure_date_10) as date ) as procedure_date_10\r\n\t, cast(coalesce(px_date.procedure_date_11, undetermined.procedure_date_11) as date ) as procedure_date_11\r\n\t, cast(coalesce(px_date.procedure_date_12, undetermined.procedure_date_12) as date ) as procedure_date_12\r\n\t, cast(coalesce(px_date.procedure_date_13, undetermined.procedure_date_13) as date ) as procedure_date_13\r\n\t, cast(coalesce(px_date.procedure_date_14, undetermined.procedure_date_14) as date ) as procedure_date_14\r\n\t, cast(coalesce(px_date.procedure_date_15, undetermined.procedure_date_15) as date ) as procedure_date_15\r\n\t, cast(coalesce(px_date.procedure_date_16, undetermined.procedure_date_16) as date ) as procedure_date_16\r\n\t, cast(coalesce(px_date.procedure_date_17, undetermined.procedure_date_17) as date ) as procedure_date_17\r\n\t, cast(coalesce(px_date.procedure_date_18, undetermined.procedure_date_18) as date ) as procedure_date_18\r\n\t, cast(coalesce(px_date.procedure_date_19, undetermined.procedure_date_19) as date ) as procedure_date_19\r\n\t, cast(coalesce(px_date.procedure_date_20, undetermined.procedure_date_20) as date ) as procedure_date_20\r\n\t, cast(coalesce(px_date.procedure_date_21, undetermined.procedure_date_21) as date ) as procedure_date_21\r\n\t, cast(coalesce(px_date.procedure_date_22, undetermined.procedure_date_22) as date ) as procedure_date_22\r\n\t, cast(coalesce(px_date.procedure_date_23, undetermined.procedure_date_23) as date ) as procedure_date_23\r\n\t, cast(coalesce(px_date.procedure_date_24, undetermined.procedure_date_24) as date ) as procedure_date_24\r\n\t, cast(coalesce(px_date.procedure_date_25, undetermined.procedure_date_25) as date ) as procedure_date_25\r\n\t, cast(med.data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast(med.in_network_flag as int ) as in_network_flag\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_string() }} ) as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\r\nleft join {{ref('normalized_input__int_admit_source_final') }} ad_source\r\n on med.claim_id = ad_source.claim_id\r\n and med.data_source = ad_source.data_source\r\nleft join {{ref('normalized_input__int_admit_type_final') }} ad_type\r\n on med.claim_id = ad_type.claim_id\r\n and med.data_source = ad_type.data_source\r\nleft join {{ref('normalized_input__int_apr_drg_final') }} apr\r\n on med.claim_id = apr.claim_id\r\n and med.data_source = apr.data_source\r\nleft join {{ref('normalized_input__int_bill_type_final') }} bill\r\n on med.claim_id = bill.claim_id\r\n and med.data_source = bill.data_source\r\nleft join {{ref('normalized_input__int_medical_claim_date_normalize') }} claim_line_dates\r\n on med.claim_id = claim_line_dates.claim_id\r\n and med.claim_line_number = claim_line_dates.claim_line_number\r\n and med.data_source = claim_line_dates.data_source\r\nleft join {{ref('normalized_input__int_medical_date_aggregation') }} dates\r\n on med.claim_id = dates.claim_id\r\n and med.data_source = dates.data_source\r\nleft join {{ref('normalized_input__int_medical_npi_normalize') }} med_npi\r\n on med.claim_id = med_npi.claim_id\r\n and med.claim_line_number = med_npi.claim_line_number\r\n and med.data_source = med_npi.data_source\r\nleft join {{ref('normalized_input__int_discharge_disposition_final') }} disch_disp\r\n on med.claim_id = disch_disp.claim_id\r\n and med.data_source = disch_disp.data_source\r\nleft join {{ref('normalized_input__int_ms_drg_final') }} ms\r\n on med.claim_id = ms.claim_id\r\n and med.data_source = ms.data_source\r\nleft join {{ref('normalized_input__int_place_of_service_normalize') }} pos\r\n on med.claim_id = pos.claim_id\r\n and med.claim_line_number = pos.claim_line_number\r\n and med.data_source = pos.data_source\r\nleft join {{ref('normalized_input__int_diagnosis_code_final') }} dx_code\r\n on med.claim_id = dx_code.claim_id\r\n and med.data_source = dx_code.data_source\r\nleft join {{ref('normalized_input__int_present_on_admit_final') }} poa\r\n on med.claim_id = poa.claim_id\r\n and med.data_source = poa.data_source\r\nleft join {{ref('normalized_input__int_procedure_code_final') }} px_code\r\n on med.claim_id = px_code.claim_id\r\n and med.data_source = px_code.data_source\r\nleft join {{ref('normalized_input__int_procedure_date_final') }} px_date\r\n on med.claim_id = px_date.claim_id\r\n and med.data_source = px_date.data_source\r\nleft join {{ref('normalized_input__int_revenue_center_normalize') }} rev\r\n on med.claim_id = rev.claim_id\r\n and med.claim_line_number = rev.claim_line_number\r\n and med.data_source = rev.data_source\r\nleft join {{ref('normalized_input__int_undetermined_claim_type') }} undetermined\r\n on med.claim_id = undetermined.claim_id\r\n and med.claim_line_number = undetermined.claim_line_number\r\n and med.data_source = undetermined.data_source", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__int_admit_source_final", "package": null, "version": null}, {"name": "normalized_input__int_admit_type_final", "package": null, "version": null}, {"name": "normalized_input__int_apr_drg_final", "package": null, "version": null}, {"name": "normalized_input__int_bill_type_final", "package": null, "version": null}, {"name": "normalized_input__int_medical_claim_date_normalize", "package": null, "version": null}, {"name": "normalized_input__int_medical_date_aggregation", "package": null, "version": null}, {"name": "normalized_input__int_medical_npi_normalize", "package": null, "version": null}, {"name": "normalized_input__int_discharge_disposition_final", "package": null, "version": null}, {"name": "normalized_input__int_ms_drg_final", "package": null, "version": null}, {"name": "normalized_input__int_place_of_service_normalize", "package": null, "version": null}, {"name": "normalized_input__int_diagnosis_code_final", "package": null, "version": null}, {"name": "normalized_input__int_present_on_admit_final", "package": null, "version": null}, {"name": "normalized_input__int_procedure_code_final", "package": null, "version": null}, {"name": "normalized_input__int_procedure_date_final", "package": null, "version": null}, {"name": "normalized_input__int_revenue_center_normalize", "package": null, "version": null}, {"name": "normalized_input__int_undetermined_claim_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "model.the_tuva_project.normalized_input__int_admit_source_final", "model.the_tuva_project.normalized_input__int_admit_type_final", "model.the_tuva_project.normalized_input__int_apr_drg_final", "model.the_tuva_project.normalized_input__int_bill_type_final", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "model.the_tuva_project.normalized_input__int_ms_drg_final", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "model.the_tuva_project.normalized_input__int_present_on_admit_final", "model.the_tuva_project.normalized_input__int_procedure_code_final", "model.the_tuva_project.normalized_input__int_procedure_date_final", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\final\\normalized_input__medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n\tcast(med.claim_id as TEXT ) as claim_id\n\t, cast(med.claim_line_number as int ) as claim_line_number\n\t, cast(med.claim_type as TEXT ) as claim_type\n\t, cast(med.patient_id as TEXT ) as patient_id\n\t, cast(med.member_id as TEXT ) as member_id\n\t, cast(med.payer as TEXT ) as payer\n , cast(med.plan as TEXT ) as plan\n\t, cast(coalesce(dates.minimum_claim_start_date, undetermined.claim_start_date) as date ) as claim_start_date\n\t, cast(coalesce(dates.maximum_claim_end_date, undetermined.claim_start_date) as date ) as claim_end_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_start_date, undetermined.claim_line_start_date) as date ) as claim_line_start_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_end_date, undetermined.claim_line_end_date) as date ) as claim_line_end_date\n\t, cast(coalesce(dates.minimum_admission_date, undetermined.admission_date) as date ) as admission_date\n\t, cast(coalesce(dates.maximum_discharge_date, undetermined.discharge_date) as date ) as discharge_date\n\t, cast(coalesce(ad_source.normalized_code, undetermined.admit_source_code) as TEXT ) as admit_source_code\n , cast(coalesce(ad_source.normalized_description, undetermined.admit_source_description) as TEXT ) as admit_source_description\n\t, cast(coalesce(ad_type.normalized_code, undetermined.admit_type_code) as TEXT ) as admit_type_code\n , cast(coalesce(ad_type.normalized_description, undetermined.admit_type_description) as TEXT ) as admit_type_description\n\t, cast(coalesce(disch_disp.normalized_code, undetermined.discharge_disposition_code) as TEXT ) as discharge_disposition_code\n , cast(coalesce(disch_disp.normalized_description, undetermined.discharge_disposition_description) as TEXT ) as discharge_disposition_description\n\t, cast(coalesce(pos.normalized_code, undetermined.place_of_service_code) as TEXT ) as place_of_service_code\n , cast(coalesce(pos.normalized_description, undetermined.place_of_service_description) as TEXT ) as place_of_service_description\n\t, cast(coalesce(bill.normalized_code, undetermined.bill_type_code) as TEXT ) as bill_type_code\n , cast(coalesce(bill.normalized_description, undetermined.bill_type_description) as TEXT ) as bill_type_description\n\t, cast(coalesce(ms.normalized_code, undetermined.ms_drg_code) as TEXT ) as ms_drg_code\n , cast(coalesce(ms.normalized_description, undetermined.ms_drg_description) as TEXT ) as ms_drg_description\n\t, cast(coalesce(apr.normalized_code, undetermined.apr_drg_code) as TEXT ) as apr_drg_code\n , cast(coalesce(apr.normalized_description, undetermined.apr_drg_description) as TEXT ) as apr_drg_description\n\t, cast(coalesce(rev.normalized_code, undetermined.revenue_center_code) as TEXT ) as revenue_center_code\n , cast(coalesce(rev.normalized_description, undetermined.revenue_center_description) as TEXT ) as revenue_center_description\n\t, cast(med.service_unit_quantity as TEXT ) as service_unit_quantity\n\t, cast(med.hcpcs_code as TEXT ) as hcpcs_code\n\t, cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n\t, cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n\t, cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n\t, cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n\t, cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n\t, cast(coalesce(med_npi.normalized_rendering_npi, undetermined.rendering_npi) as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(coalesce(med_npi.normalized_rendering_name, undetermined.rendering_name) as TEXT ) as rendering_name\n\t, cast(coalesce(med_npi.normalized_billing_npi, undetermined.billing_npi) as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(coalesce(med_npi.normalized_billing_name, undetermined.billing_name) as TEXT ) as billing_name\n\t, cast(coalesce(med_npi.normalized_facility_npi, undetermined.facility_npi) as TEXT ) as facility_id\n\t, cast(coalesce(med_npi.normalized_facility_name, undetermined.facility_name) as TEXT ) as facility_name\n , cast(med.paid_date as date ) as paid_date\n\t, cast(med.paid_amount as numeric(28,6) ) as paid_amount\n\t, cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n\t, cast(med.charge_amount as numeric(28,6) ) as charge_amount\n\t, cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n\t, cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n\t, cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n\t, cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n\t, cast(med.diagnosis_code_type as TEXT ) as diagnosis_code_type\n\t, cast(coalesce(dx_code.diagnosis_code_1, undetermined.diagnosis_code_1) as TEXT ) as diagnosis_code_1\n\t, cast(coalesce(dx_code.diagnosis_code_2, undetermined.diagnosis_code_2) as TEXT ) as diagnosis_code_2\n\t, cast(coalesce(dx_code.diagnosis_code_3, undetermined.diagnosis_code_3) as TEXT ) as diagnosis_code_3\n\t, cast(coalesce(dx_code.diagnosis_code_4, undetermined.diagnosis_code_4) as TEXT ) as diagnosis_code_4\n\t, cast(coalesce(dx_code.diagnosis_code_5, undetermined.diagnosis_code_5) as TEXT ) as diagnosis_code_5\n\t, cast(coalesce(dx_code.diagnosis_code_6, undetermined.diagnosis_code_6) as TEXT ) as diagnosis_code_6\n\t, cast(coalesce(dx_code.diagnosis_code_7, undetermined.diagnosis_code_7) as TEXT ) as diagnosis_code_7\n\t, cast(coalesce(dx_code.diagnosis_code_8, undetermined.diagnosis_code_8) as TEXT ) as diagnosis_code_8\n\t, cast(coalesce(dx_code.diagnosis_code_9, undetermined.diagnosis_code_9) as TEXT ) as diagnosis_code_9\n\t, cast(coalesce(dx_code.diagnosis_code_10, undetermined.diagnosis_code_10) as TEXT ) as diagnosis_code_10\n\t, cast(coalesce(dx_code.diagnosis_code_11, undetermined.diagnosis_code_11) as TEXT ) as diagnosis_code_11\n\t, cast(coalesce(dx_code.diagnosis_code_12, undetermined.diagnosis_code_12) as TEXT ) as diagnosis_code_12\n\t, cast(coalesce(dx_code.diagnosis_code_13, undetermined.diagnosis_code_13) as TEXT ) as diagnosis_code_13\n\t, cast(coalesce(dx_code.diagnosis_code_14, undetermined.diagnosis_code_14) as TEXT ) as diagnosis_code_14\n\t, cast(coalesce(dx_code.diagnosis_code_15, undetermined.diagnosis_code_15) as TEXT ) as diagnosis_code_15\n\t, cast(coalesce(dx_code.diagnosis_code_16, undetermined.diagnosis_code_16) as TEXT ) as diagnosis_code_16\n\t, cast(coalesce(dx_code.diagnosis_code_17, undetermined.diagnosis_code_17) as TEXT ) as diagnosis_code_17\n\t, cast(coalesce(dx_code.diagnosis_code_18, undetermined.diagnosis_code_18) as TEXT ) as diagnosis_code_18\n\t, cast(coalesce(dx_code.diagnosis_code_19, undetermined.diagnosis_code_19) as TEXT ) as diagnosis_code_19\n\t, cast(coalesce(dx_code.diagnosis_code_20, undetermined.diagnosis_code_20) as TEXT ) as diagnosis_code_20\n\t, cast(coalesce(dx_code.diagnosis_code_21, undetermined.diagnosis_code_21) as TEXT ) as diagnosis_code_21\n\t, cast(coalesce(dx_code.diagnosis_code_22, undetermined.diagnosis_code_22) as TEXT ) as diagnosis_code_22\n\t, cast(coalesce(dx_code.diagnosis_code_23, undetermined.diagnosis_code_23) as TEXT ) as diagnosis_code_23\n\t, cast(coalesce(dx_code.diagnosis_code_24, undetermined.diagnosis_code_24) as TEXT ) as diagnosis_code_24\n\t, cast(coalesce(dx_code.diagnosis_code_25, undetermined.diagnosis_code_25) as TEXT ) as diagnosis_code_25\n\t, cast(coalesce(poa.diagnosis_poa_1, undetermined.diagnosis_poa_1) as TEXT ) as diagnosis_poa_1\n\t, cast(coalesce(poa.diagnosis_poa_2, undetermined.diagnosis_poa_2) as TEXT ) as diagnosis_poa_2\n\t, cast(coalesce(poa.diagnosis_poa_3, undetermined.diagnosis_poa_3) as TEXT ) as diagnosis_poa_3\n\t, cast(coalesce(poa.diagnosis_poa_4, undetermined.diagnosis_poa_4) as TEXT ) as diagnosis_poa_4\n\t, cast(coalesce(poa.diagnosis_poa_5, undetermined.diagnosis_poa_5) as TEXT ) as diagnosis_poa_5\n\t, cast(coalesce(poa.diagnosis_poa_6, undetermined.diagnosis_poa_6) as TEXT ) as diagnosis_poa_6\n\t, cast(coalesce(poa.diagnosis_poa_7, undetermined.diagnosis_poa_7) as TEXT ) as diagnosis_poa_7\n\t, cast(coalesce(poa.diagnosis_poa_8, undetermined.diagnosis_poa_8) as TEXT ) as diagnosis_poa_8\n\t, cast(coalesce(poa.diagnosis_poa_9, undetermined.diagnosis_poa_9) as TEXT ) as diagnosis_poa_9\n\t, cast(coalesce(poa.diagnosis_poa_10, undetermined.diagnosis_poa_10) as TEXT ) as diagnosis_poa_10\n\t, cast(coalesce(poa.diagnosis_poa_11, undetermined.diagnosis_poa_11) as TEXT ) as diagnosis_poa_11\n\t, cast(coalesce(poa.diagnosis_poa_12, undetermined.diagnosis_poa_12) as TEXT ) as diagnosis_poa_12\n\t, cast(coalesce(poa.diagnosis_poa_13, undetermined.diagnosis_poa_13) as TEXT ) as diagnosis_poa_13\n\t, cast(coalesce(poa.diagnosis_poa_14, undetermined.diagnosis_poa_14) as TEXT ) as diagnosis_poa_14\n\t, cast(coalesce(poa.diagnosis_poa_15, undetermined.diagnosis_poa_15) as TEXT ) as diagnosis_poa_15\n\t, cast(coalesce(poa.diagnosis_poa_16, undetermined.diagnosis_poa_16) as TEXT ) as diagnosis_poa_16\n\t, cast(coalesce(poa.diagnosis_poa_17, undetermined.diagnosis_poa_17) as TEXT ) as diagnosis_poa_17\n\t, cast(coalesce(poa.diagnosis_poa_18, undetermined.diagnosis_poa_18) as TEXT ) as diagnosis_poa_18\n\t, cast(coalesce(poa.diagnosis_poa_19, undetermined.diagnosis_poa_19) as TEXT ) as diagnosis_poa_19\n\t, cast(coalesce(poa.diagnosis_poa_20, undetermined.diagnosis_poa_20) as TEXT ) as diagnosis_poa_20\n\t, cast(coalesce(poa.diagnosis_poa_21, undetermined.diagnosis_poa_21) as TEXT ) as diagnosis_poa_21\n\t, cast(coalesce(poa.diagnosis_poa_22, undetermined.diagnosis_poa_22) as TEXT ) as diagnosis_poa_22\n\t, cast(coalesce(poa.diagnosis_poa_23, undetermined.diagnosis_poa_23) as TEXT ) as diagnosis_poa_23\n\t, cast(coalesce(poa.diagnosis_poa_24, undetermined.diagnosis_poa_24) as TEXT ) as diagnosis_poa_24\n\t, cast(coalesce(poa.diagnosis_poa_25, undetermined.diagnosis_poa_25) as TEXT ) as diagnosis_poa_25\n\t, cast(med.procedure_code_type as TEXT ) as procedure_code_type\n\t, cast(coalesce(px_code.procedure_code_1, undetermined.procedure_code_1) as TEXT ) as procedure_code_1\n\t, cast(coalesce(px_code.procedure_code_2, undetermined.procedure_code_2) as TEXT ) as procedure_code_2\n\t, cast(coalesce(px_code.procedure_code_3, undetermined.procedure_code_3) as TEXT ) as procedure_code_3\n\t, cast(coalesce(px_code.procedure_code_4, undetermined.procedure_code_4) as TEXT ) as procedure_code_4\n\t, cast(coalesce(px_code.procedure_code_5, undetermined.procedure_code_5) as TEXT ) as procedure_code_5\n\t, cast(coalesce(px_code.procedure_code_6, undetermined.procedure_code_6) as TEXT ) as procedure_code_6\n\t, cast(coalesce(px_code.procedure_code_7, undetermined.procedure_code_7) as TEXT ) as procedure_code_7\n\t, cast(coalesce(px_code.procedure_code_8, undetermined.procedure_code_8) as TEXT ) as procedure_code_8\n\t, cast(coalesce(px_code.procedure_code_9, undetermined.procedure_code_9) as TEXT ) as procedure_code_9\n\t, cast(coalesce(px_code.procedure_code_10, undetermined.procedure_code_10) as TEXT ) as procedure_code_10\n\t, cast(coalesce(px_code.procedure_code_11, undetermined.procedure_code_11) as TEXT ) as procedure_code_11\n\t, cast(coalesce(px_code.procedure_code_12, undetermined.procedure_code_12) as TEXT ) as procedure_code_12\n\t, cast(coalesce(px_code.procedure_code_13, undetermined.procedure_code_13) as TEXT ) as procedure_code_13\n\t, cast(coalesce(px_code.procedure_code_14, undetermined.procedure_code_14) as TEXT ) as procedure_code_14\n\t, cast(coalesce(px_code.procedure_code_15, undetermined.procedure_code_15) as TEXT ) as procedure_code_15\n\t, cast(coalesce(px_code.procedure_code_16, undetermined.procedure_code_16) as TEXT ) as procedure_code_16\n\t, cast(coalesce(px_code.procedure_code_17, undetermined.procedure_code_17) as TEXT ) as procedure_code_17\n\t, cast(coalesce(px_code.procedure_code_18, undetermined.procedure_code_18) as TEXT ) as procedure_code_18\n\t, cast(coalesce(px_code.procedure_code_19, undetermined.procedure_code_19) as TEXT ) as procedure_code_19\n\t, cast(coalesce(px_code.procedure_code_20, undetermined.procedure_code_20) as TEXT ) as procedure_code_20\n\t, cast(coalesce(px_code.procedure_code_21, undetermined.procedure_code_21) as TEXT ) as procedure_code_21\n\t, cast(coalesce(px_code.procedure_code_22, undetermined.procedure_code_22) as TEXT ) as procedure_code_22\n\t, cast(coalesce(px_code.procedure_code_23, undetermined.procedure_code_23) as TEXT ) as procedure_code_23\n\t, cast(coalesce(px_code.procedure_code_24, undetermined.procedure_code_24) as TEXT ) as procedure_code_24\n\t, cast(coalesce(px_code.procedure_code_25, undetermined.procedure_code_25) as TEXT ) as procedure_code_25\n\t, cast(coalesce(px_date.procedure_date_1, undetermined.procedure_date_1) as date ) as procedure_date_1\n\t, cast(coalesce(px_date.procedure_date_2, undetermined.procedure_date_2) as date ) as procedure_date_2\n\t, cast(coalesce(px_date.procedure_date_3, undetermined.procedure_date_3) as date ) as procedure_date_3\n\t, cast(coalesce(px_date.procedure_date_4, undetermined.procedure_date_4) as date ) as procedure_date_4\n\t, cast(coalesce(px_date.procedure_date_5, undetermined.procedure_date_5) as date ) as procedure_date_5\n\t, cast(coalesce(px_date.procedure_date_6, undetermined.procedure_date_6) as date ) as procedure_date_6\n\t, cast(coalesce(px_date.procedure_date_7, undetermined.procedure_date_7) as date ) as procedure_date_7\n\t, cast(coalesce(px_date.procedure_date_8, undetermined.procedure_date_8) as date ) as procedure_date_8\n\t, cast(coalesce(px_date.procedure_date_9, undetermined.procedure_date_9) as date ) as procedure_date_9\n\t, cast(coalesce(px_date.procedure_date_10, undetermined.procedure_date_10) as date ) as procedure_date_10\n\t, cast(coalesce(px_date.procedure_date_11, undetermined.procedure_date_11) as date ) as procedure_date_11\n\t, cast(coalesce(px_date.procedure_date_12, undetermined.procedure_date_12) as date ) as procedure_date_12\n\t, cast(coalesce(px_date.procedure_date_13, undetermined.procedure_date_13) as date ) as procedure_date_13\n\t, cast(coalesce(px_date.procedure_date_14, undetermined.procedure_date_14) as date ) as procedure_date_14\n\t, cast(coalesce(px_date.procedure_date_15, undetermined.procedure_date_15) as date ) as procedure_date_15\n\t, cast(coalesce(px_date.procedure_date_16, undetermined.procedure_date_16) as date ) as procedure_date_16\n\t, cast(coalesce(px_date.procedure_date_17, undetermined.procedure_date_17) as date ) as procedure_date_17\n\t, cast(coalesce(px_date.procedure_date_18, undetermined.procedure_date_18) as date ) as procedure_date_18\n\t, cast(coalesce(px_date.procedure_date_19, undetermined.procedure_date_19) as date ) as procedure_date_19\n\t, cast(coalesce(px_date.procedure_date_20, undetermined.procedure_date_20) as date ) as procedure_date_20\n\t, cast(coalesce(px_date.procedure_date_21, undetermined.procedure_date_21) as date ) as procedure_date_21\n\t, cast(coalesce(px_date.procedure_date_22, undetermined.procedure_date_22) as date ) as procedure_date_22\n\t, cast(coalesce(px_date.procedure_date_23, undetermined.procedure_date_23) as date ) as procedure_date_23\n\t, cast(coalesce(px_date.procedure_date_24, undetermined.procedure_date_24) as date ) as procedure_date_24\n\t, cast(coalesce(px_date.procedure_date_25, undetermined.procedure_date_25) as date ) as procedure_date_25\n\t, cast(med.data_source as TEXT ) as data_source\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_final ad_source\n on med.claim_id = ad_source.claim_id\n and med.data_source = ad_source.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_final ad_type\n on med.claim_id = ad_type.claim_id\n and med.data_source = ad_type.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_final apr\n on med.claim_id = apr.claim_id\n and med.data_source = apr.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_final bill\n on med.claim_id = bill.claim_id\n and med.data_source = bill.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize claim_line_dates\n on med.claim_id = claim_line_dates.claim_id\n and med.claim_line_number = claim_line_dates.claim_line_number\n and med.data_source = claim_line_dates.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_medical_date_aggregation dates\n on med.claim_id = dates.claim_id\n and med.data_source = dates.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_medical_npi_normalize med_npi\n on med.claim_id = med_npi.claim_id\n and med.claim_line_number = med_npi.claim_line_number\n and med.data_source = med_npi.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_final disch_disp\n on med.claim_id = disch_disp.claim_id\n and med.data_source = disch_disp.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_final ms\n on med.claim_id = ms.claim_id\n and med.data_source = ms.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_place_of_service_normalize pos\n on med.claim_id = pos.claim_id\n and med.claim_line_number = pos.claim_line_number\n and med.data_source = pos.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_final dx_code\n on med.claim_id = dx_code.claim_id\n and med.data_source = dx_code.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_final poa\n on med.claim_id = poa.claim_id\n and med.data_source = poa.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_final px_code\n on med.claim_id = px_code.claim_id\n and med.data_source = px_code.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_final px_date\n on med.claim_id = px_date.claim_id\n and med.data_source = px_date.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_revenue_center_normalize rev\n on med.claim_id = rev.claim_id\n and med.claim_line_number = rev.claim_line_number\n and med.data_source = rev.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_undetermined_claim_type undetermined\n on med.claim_id = undetermined.claim_id\n and med.claim_line_number = undetermined.claim_line_number\n and med.data_source = undetermined.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__pharmacy_claim": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\final\\normalized_input__pharmacy_claim.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\final\\normalized_input__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__pharmacy_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "final", "normalized_input__pharmacy_claim"], "alias": "normalized_input_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "57e5c47d0206db27f3c0731e3ca55a5811fa26aa5fd0c0126e382329a21f8618"}, "config": {"enabled": true, "alias": "normalized_input_pharmacy_claim", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "The pharmacy claim table contains information on prescription drugs that \nwere filled and billed to the insurer.\n", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_npi": {"name": "prescribing_provider_npi", "description": "NPI for the provider that wrote the prescription (e.g. priamry care physician).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_npi": {"name": "dispensing_provider_npi", "description": "NPI for the provider that dispensed the prescription (e.g. pharmacy).\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "Number of doses.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days supply.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the prescription.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "Date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid by the health insurer for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "Contractual amount allowed to be paid by the payer + patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "normalized_input_pharmacy_claim", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2310734, "relation_name": "dev_thuxuan.claims_preprocessing.normalized_input_pharmacy_claim", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n cast(claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , cast(claim_line_number as int ) as claim_line_number\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(member_id as {{ dbt.type_string() }} ) as member_id\r\n , cast(payer as {{ dbt.type_string() }} ) as payer\r\n , cast({{ quote_column('plan') }} as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\r\n , cast(prescribing_provider_npi as {{ dbt.type_string() }} ) as prescribing_provider_id\r\n , cast(coalesce({{ dbt.concat([\"pres.provider_last_name\", \"', '\", \"pres.provider_first_name\"]) }}, pres.provider_organization_name) as {{ dbt.type_string() }} ) as prescribing_provider_name\r\n , cast(dispensing_provider_npi as {{ dbt.type_string() }} ) as dispensing_provider_id\r\n , cast(coalesce({{ dbt.concat([\"disp.provider_last_name\", \"', '\", \"disp.provider_first_name\"]) }}, disp.provider_organization_name) as {{ dbt.type_string() }} ) as dispensing_provider_name , cast(dispensing_date as date ) as dispensing_date\r\n , cast(ndc_code as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(ndc.fda_description as {{ dbt.type_string() }} ) as ndc_description\r\n , cast(quantity as int ) as quantity\r\n , cast(days_supply as int ) as days_supply\r\n , cast(refills as int ) as refills\r\n , cast(paid_date as date ) as paid_date\r\n , cast(paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\r\n , cast(allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\r\n , cast(charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\r\n , cast(coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\r\n , cast(copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\r\n , cast(deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\r\n , cast(in_network_flag as int ) as in_network_flag\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_string() }} ) as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_pharmacy_claim') }} pharm\r\nleft join {{ ref('terminology__provider') }} pres\r\n on pharm.prescribing_provider_npi = pres.npi\r\nleft join {{ ref('terminology__provider') }} disp\r\n on pharm.dispensing_provider_npi = disp.npi\r\nleft join {{ ref('terminology__ndc') }} ndc\r\n on pharm.ndc_code = ndc.ndc", "language": "sql", "refs": [{"name": "normalized_input__stg_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.normalized_input__stg_pharmacy_claim", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\final\\normalized_input__pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_pharmacy_claim as (\n\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim\n) select\n cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as int ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , cast(plan as TEXT ) as plan\n , cast(prescribing_provider_npi as TEXT ) as prescribing_provider_id\n , cast(coalesce(pres.provider_last_name || ', ' || pres.provider_first_name, pres.provider_organization_name) as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_npi as TEXT ) as dispensing_provider_id\n , cast(coalesce(disp.provider_last_name || ', ' || disp.provider_first_name, disp.provider_organization_name) as TEXT ) as dispensing_provider_name , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc.fda_description as TEXT ) as ndc_description\n , cast(quantity as int ) as quantity\n , cast(days_supply as int ) as days_supply\n , cast(refills as int ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_pharmacy_claim pharm\nleft join dev_thuxuan.terminology.provider pres\n on pharm.prescribing_provider_npi = pres.npi\nleft join dev_thuxuan.terminology.provider disp\n on pharm.dispensing_provider_npi = disp.npi\nleft join dev_thuxuan.terminology.ndc ndc\n on pharm.ndc_code = ndc.ndc", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_pharmacy_claim", "sql": " __dbt__cte__normalized_input__stg_pharmacy_claim as (\n\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_source_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_source_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_source_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_source_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_source_final"], "alias": "_int_normalized_input_admit_source_final", "checksum": {"name": "sha256", "checksum": "a0b6ed47d7978de79bfeacbef9aa72a7357f9d70e1d59444ceeeb07bda0ee2b4"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_source_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_source_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.233074, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_admit_source_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_admit_source_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_admit_source_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_source_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_source_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_source_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_source_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_source_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_source_voting"], "alias": "_int_normalized_input_admit_source_voting", "checksum": {"name": "sha256", "checksum": "6decb122e0d29adecf5ba95ed96a5a4f8a6c98fe9cdc82621f59c629f0a37e06"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_source_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_source_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.235074, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\n\r\nwith normalize_cte as(\r\n select \r\n med.claim_id\r\n , med.data_source\r\n , admit.admit_source_code\r\n\r\n , admit.admit_source_description\r\n from {{ ref('normalized_input__stg_medical_claim') }} med\r\n inner join {{ ref('terminology__admit_source') }} admit\r\n on med.admit_source_code = admit.admit_source_code\r\n where claim_type = 'institutional'\r\n)\r\n, distinct_counts as(\r\n select \r\n claim_id\r\n , data_source\r\n , admit_source_code\r\n , admit_source_description\r\n , count(*) as admit_source_occurrence_count\r\n from normalize_cte\r\n where admit_source_code is not null\r\n group by \r\n claim_id\r\n , data_source\r\n , admit_source_code\r\n , admit_source_description\r\n)\r\n\r\n, occurence_comparison as(\r\n select\r\n claim_id\r\n , data_source\r\n , 'admit_source_code' as column_name\r\n , admit_source_code as normalized_code\r\n , admit_source_description as normalized_description\r\n , admit_source_occurrence_count as occurrence_count\r\n , coalesce(lead(admit_source_occurrence_count) \r\n over (partition by claim_id, data_source order by admit_source_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by claim_id, data_source order by admit_source_occurrence_count desc) as occurrence_row_count\r\n from distinct_counts dist\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_source_voting.sql", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_source_code\n\n , admit.admit_source_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.admit_source admit\n on med.admit_source_code = admit.admit_source_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n , count(*) as admit_source_occurrence_count\n from normalize_cte\n where admit_source_code is not null\n group by \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_source_code' as column_name\n , admit_source_code as normalized_code\n , admit_source_description as normalized_description\n , admit_source_occurrence_count as occurrence_count\n , coalesce(lead(admit_source_occurrence_count) \n over (partition by claim_id, data_source order by admit_source_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_source_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_type_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_type_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_type_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_type_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_type_final"], "alias": "_int_normalized_input_admit_type_final", "checksum": {"name": "sha256", "checksum": "352120aeef425949ca6ab434022ef54f0ea2ff23fc8e64a71964faf449a38de7"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_type_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_type_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.237074, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_admit_type_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_admit_type_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_admit_type_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_type_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_normalize_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_admit_type_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_admit_type_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_type_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_type_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_admit_type_voting"], "alias": "_int_normalized_input_admit_type_normalize_voting", "checksum": {"name": "sha256", "checksum": "cfc4706a5f0da062f9b215e443d69cc61dad0a4ad38eba1fc1bc8a9a9981f656"}, "config": {"enabled": true, "alias": "_int_normalized_input_admit_type_normalize_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_admit_type_normalize_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2400744, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_normalize_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith normalize_cte as(\r\n select \r\n med.claim_id\r\n , med.data_source\r\n , admit.admit_type_code\r\n , admit.admit_type_description\r\n from {{ ref('normalized_input__stg_medical_claim') }} med\r\n inner join {{ ref('terminology__admit_type') }} admit\r\n on med.admit_type_code = admit.admit_type_code\r\n where claim_type = 'institutional'\r\n)\r\n, distinct_counts as(\r\n select \r\n claim_id\r\n , data_source\r\n , admit_type_code\r\n , admit_type_description\r\n , count(*) as admit_type_occurrence_count\r\n from normalize_cte\r\n\r\n where admit_type_code is not null\r\n group by \r\n claim_id\r\n , data_source\r\n , admit_type_code\r\n , admit_type_description\r\n)\r\n\r\n, occurence_comparison as(\r\n select\r\n claim_id\r\n , data_source\r\n , 'admit_type_code' as column_name\r\n , admit_type_code as normalized_code\r\n , admit_type_description as normalized_description\r\n , admit_type_occurrence_count as occurrence_count\r\n , coalesce(lead(admit_type_occurrence_count) \r\n over (partition by claim_id, data_source order by admit_type_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by claim_id, data_source order by admit_type_occurrence_count desc) as occurrence_row_count\r\n from distinct_counts dist\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_admit_type_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_type_code\n , admit.admit_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.admit_type admit\n on med.admit_type_code = admit.admit_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n , count(*) as admit_type_occurrence_count\n from normalize_cte\n\n where admit_type_code is not null\n group by \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_type_code' as column_name\n , admit_type_code as normalized_code\n , admit_type_description as normalized_description\n , admit_type_occurrence_count as occurrence_count\n , coalesce(lead(admit_type_occurrence_count) \n over (partition by claim_id, data_source order by admit_type_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_type_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_apr_drg_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_apr_drg_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_apr_drg_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_apr_drg_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_apr_drg_final"], "alias": "_int_normalized_input_apr_drg_final", "checksum": {"name": "sha256", "checksum": "21a7ecf56d862ea12410e19efb229164a0337fb336fc15f974cea4af359c47a3"}, "config": {"enabled": true, "alias": "_int_normalized_input_apr_drg_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_apr_drg_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2420747, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_apr_drg_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_apr_drg_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_apr_drg_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_apr_drg_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_apr_drg_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_apr_drg_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_apr_drg_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_apr_drg_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_apr_drg_voting"], "alias": "_int_normalized_input_apr_drg_voting", "checksum": {"name": "sha256", "checksum": "321d511e3ad51acdc4f4fa5d540721a9007ad110c542480ab441ddd537c726ec"}, "config": {"enabled": true, "alias": "_int_normalized_input_apr_drg_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_apr_drg_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2440748, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith normalize_cte as(\r\n\r\n select \r\n med.claim_id\r\n , med.data_source\r\n , apr.apr_drg_code\r\n , apr.apr_drg_description\r\n from {{ ref('normalized_input__stg_medical_claim') }} med\r\n inner join {{ ref('terminology__apr_drg') }} apr\r\n on med.apr_drg_code = apr.apr_drg_code\r\n where claim_type = 'institutional'\r\n)\r\n, distinct_counts as(\r\n select \r\n claim_id\r\n , data_source\r\n , apr_drg_code\r\n , apr_drg_description\r\n , count(*) as apr_drg_occurrence_count\r\n from normalize_cte\r\n where apr_drg_code is not null\r\n group by \r\n claim_id\r\n , data_source\r\n , apr_drg_code\r\n , apr_drg_description\r\n)\r\n\r\n, occurence_comparison as(\r\n select\r\n claim_id\r\n , data_source\r\n , 'apr_drg_code' as column_name\r\n , apr_drg_code as normalized_code\r\n , apr_drg_description as normalized_description\r\n , apr_drg_occurrence_count as occurrence_count\r\n , coalesce(lead(apr_drg_occurrence_count) \r\n over (partition by claim_id, data_source order by apr_drg_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by claim_id, data_source order by apr_drg_occurrence_count desc) as occurrence_row_count\r\n from distinct_counts dist\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_apr_drg_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n\n select \n med.claim_id\n , med.data_source\n , apr.apr_drg_code\n , apr.apr_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.apr_drg apr\n on med.apr_drg_code = apr.apr_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n , count(*) as apr_drg_occurrence_count\n from normalize_cte\n where apr_drg_code is not null\n group by \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'apr_drg_code' as column_name\n , apr_drg_code as normalized_code\n , apr_drg_description as normalized_description\n , apr_drg_occurrence_count as occurrence_count\n , coalesce(lead(apr_drg_occurrence_count) \n over (partition by claim_id, data_source order by apr_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by apr_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_bill_type_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_bill_type_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_bill_type_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_bill_type_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_bill_type_final"], "alias": "_int_normalized_input_bill_type_final", "checksum": {"name": "sha256", "checksum": "ed28b2cdcf403eb4694cebd345d1fd96fe88495fdbfd8aaade4a16225f986d0f"}, "config": {"enabled": true, "alias": "_int_normalized_input_bill_type_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_bill_type_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2460747, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_bill_type_voting') }}\r\nwhere occurrence_row_count = 1", "language": "sql", "refs": [{"name": "normalized_input__int_bill_type_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_bill_type_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_bill_type_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_voting\nwhere occurrence_row_count = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_bill_type_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_bill_type_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_bill_type_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_bill_type_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_bill_type_voting"], "alias": "_int_normalized_input_bill_type_voting", "checksum": {"name": "sha256", "checksum": "e398fedf45f11d1be35016675b8f9c28e3efec82d87a6d1afa72ea2dc94f42cf"}, "config": {"enabled": true, "alias": "_int_normalized_input_bill_type_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_bill_type_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2490711, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith normalize_cte as(\r\n select \r\n med.claim_id\r\n , med.data_source\r\n , bill.bill_type_code\r\n , bill.bill_type_description\r\n from {{ ref('normalized_input__stg_medical_claim') }} med\r\n inner join {{ ref('terminology__bill_type') }} bill\r\n on {{ ltrim('med.bill_type_code', '0') }} = bill.bill_type_code\r\n where claim_type = 'institutional'\r\n)\r\n, distinct_counts as(\r\n select \r\n claim_id\r\n , data_source\r\n , bill_type_code\r\n , bill_type_description\r\n , count(*) as bill_type_occurrence_count\r\n from normalize_cte\r\n where bill_type_code is not null\r\n group by \r\n claim_id\r\n , data_source\r\n , bill_type_code\r\n , bill_type_description\r\n)\r\n\r\n, occurence_comparison as(\r\n select\r\n claim_id\r\n , data_source\r\n , 'bill_type_code' as column_name\r\n , bill_type_code as normalized_code\r\n , bill_type_description as normalized_description\r\n , bill_type_occurrence_count as occurrence_count\r\n , row_number() over (partition by claim_id, data_source order by bill_type_occurrence_count desc, bill_type_code asc) as occurrence_row_count\r\n from distinct_counts dist\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.ltrim"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_bill_type_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , bill.bill_type_code\n , bill.bill_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.bill_type bill\n on ltrim(med.bill_type_code, '0') = bill.bill_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n , count(*) as bill_type_occurrence_count\n from normalize_cte\n where bill_type_code is not null\n group by \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'bill_type_code' as column_name\n , bill_type_code as normalized_code\n , bill_type_description as normalized_description\n , bill_type_occurrence_count as occurrence_count\n , row_number() over (partition by claim_id, data_source order by bill_type_occurrence_count desc, bill_type_code asc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_diagnosis_code_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_diagnosis_code_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_diagnosis_code_final"], "alias": "_int_normalized_input_diagnosis_code_final", "checksum": {"name": "sha256", "checksum": "833f3dc13b44d2155cc4bfe573841485e4c4b44a1d6cf6ecf9d0b39f91712fcf"}, "config": {"enabled": true, "alias": "_int_normalized_input_diagnosis_code_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_diagnosis_code_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2510712, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when lower(column_name) = 'diagnosis_code_1' then normalized_code else null end) as diagnosis_code_1\r\n , max(case when lower(column_name) = 'diagnosis_code_2' then normalized_code else null end) as diagnosis_code_2\r\n , max(case when lower(column_name) = 'diagnosis_code_3' then normalized_code else null end) as diagnosis_code_3\r\n , max(case when lower(column_name) = 'diagnosis_code_4' then normalized_code else null end) as diagnosis_code_4\r\n , max(case when lower(column_name) = 'diagnosis_code_5' then normalized_code else null end) as diagnosis_code_5\r\n , max(case when lower(column_name) = 'diagnosis_code_6' then normalized_code else null end) as diagnosis_code_6\r\n , max(case when lower(column_name) = 'diagnosis_code_7' then normalized_code else null end) as diagnosis_code_7\r\n , max(case when lower(column_name) = 'diagnosis_code_8' then normalized_code else null end) as diagnosis_code_8\r\n , max(case when lower(column_name) = 'diagnosis_code_9' then normalized_code else null end) as diagnosis_code_9\r\n , max(case when lower(column_name) = 'diagnosis_code_10' then normalized_code else null end) as diagnosis_code_10\r\n , max(case when lower(column_name) = 'diagnosis_code_11' then normalized_code else null end) as diagnosis_code_11\r\n , max(case when lower(column_name) = 'diagnosis_code_12' then normalized_code else null end) as diagnosis_code_12\r\n , max(case when lower(column_name) = 'diagnosis_code_13' then normalized_code else null end) as diagnosis_code_13\r\n , max(case when lower(column_name) = 'diagnosis_code_14' then normalized_code else null end) as diagnosis_code_14\r\n , max(case when lower(column_name) = 'diagnosis_code_15' then normalized_code else null end) as diagnosis_code_15\r\n , max(case when lower(column_name) = 'diagnosis_code_16' then normalized_code else null end) as diagnosis_code_16\r\n , max(case when lower(column_name) = 'diagnosis_code_17' then normalized_code else null end) as diagnosis_code_17\r\n , max(case when lower(column_name) = 'diagnosis_code_18' then normalized_code else null end) as diagnosis_code_18\r\n , max(case when lower(column_name) = 'diagnosis_code_19' then normalized_code else null end) as diagnosis_code_19\r\n , max(case when lower(column_name) = 'diagnosis_code_20' then normalized_code else null end) as diagnosis_code_20\r\n , max(case when lower(column_name) = 'diagnosis_code_21' then normalized_code else null end) as diagnosis_code_21\r\n , max(case when lower(column_name) = 'diagnosis_code_22' then normalized_code else null end) as diagnosis_code_22\r\n , max(case when lower(column_name) = 'diagnosis_code_23' then normalized_code else null end) as diagnosis_code_23\r\n , max(case when lower(column_name) = 'diagnosis_code_24' then normalized_code else null end) as diagnosis_code_24\r\n , max(case when lower(column_name) = 'diagnosis_code_25' then normalized_code else null end) as diagnosis_code_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_diagnosis_code_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_diagnosis_code_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_diagnosis_code_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'diagnosis_code_1' then normalized_code else null end) as diagnosis_code_1\n , max(case when lower(column_name) = 'diagnosis_code_2' then normalized_code else null end) as diagnosis_code_2\n , max(case when lower(column_name) = 'diagnosis_code_3' then normalized_code else null end) as diagnosis_code_3\n , max(case when lower(column_name) = 'diagnosis_code_4' then normalized_code else null end) as diagnosis_code_4\n , max(case when lower(column_name) = 'diagnosis_code_5' then normalized_code else null end) as diagnosis_code_5\n , max(case when lower(column_name) = 'diagnosis_code_6' then normalized_code else null end) as diagnosis_code_6\n , max(case when lower(column_name) = 'diagnosis_code_7' then normalized_code else null end) as diagnosis_code_7\n , max(case when lower(column_name) = 'diagnosis_code_8' then normalized_code else null end) as diagnosis_code_8\n , max(case when lower(column_name) = 'diagnosis_code_9' then normalized_code else null end) as diagnosis_code_9\n , max(case when lower(column_name) = 'diagnosis_code_10' then normalized_code else null end) as diagnosis_code_10\n , max(case when lower(column_name) = 'diagnosis_code_11' then normalized_code else null end) as diagnosis_code_11\n , max(case when lower(column_name) = 'diagnosis_code_12' then normalized_code else null end) as diagnosis_code_12\n , max(case when lower(column_name) = 'diagnosis_code_13' then normalized_code else null end) as diagnosis_code_13\n , max(case when lower(column_name) = 'diagnosis_code_14' then normalized_code else null end) as diagnosis_code_14\n , max(case when lower(column_name) = 'diagnosis_code_15' then normalized_code else null end) as diagnosis_code_15\n , max(case when lower(column_name) = 'diagnosis_code_16' then normalized_code else null end) as diagnosis_code_16\n , max(case when lower(column_name) = 'diagnosis_code_17' then normalized_code else null end) as diagnosis_code_17\n , max(case when lower(column_name) = 'diagnosis_code_18' then normalized_code else null end) as diagnosis_code_18\n , max(case when lower(column_name) = 'diagnosis_code_19' then normalized_code else null end) as diagnosis_code_19\n , max(case when lower(column_name) = 'diagnosis_code_20' then normalized_code else null end) as diagnosis_code_20\n , max(case when lower(column_name) = 'diagnosis_code_21' then normalized_code else null end) as diagnosis_code_21\n , max(case when lower(column_name) = 'diagnosis_code_22' then normalized_code else null end) as diagnosis_code_22\n , max(case when lower(column_name) = 'diagnosis_code_23' then normalized_code else null end) as diagnosis_code_23\n , max(case when lower(column_name) = 'diagnosis_code_24' then normalized_code else null end) as diagnosis_code_24\n , max(case when lower(column_name) = 'diagnosis_code_25' then normalized_code else null end) as diagnosis_code_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_diagnosis_code_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_diagnosis_code_normalize"], "alias": "_int_normalized_input_diagnosis_code_normalize", "checksum": {"name": "sha256", "checksum": "179014e4821ac7e90ccc56a81480f28b3eaa3e970b84d32dc4c046820f42d2c8"}, "config": {"enabled": true, "alias": "_int_normalized_input_diagnosis_code_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_diagnosis_code_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2530742, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nwith pivot_diagnosis as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_1' as diagnosis_column\r\n , diagnosis_code_1 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_2' as diagnosis_column\r\n , diagnosis_code_2 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_3' as diagnosis_column\r\n , diagnosis_code_3 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_4' as diagnosis_column\r\n , diagnosis_code_4 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_5' as diagnosis_column\r\n , diagnosis_code_5 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_6' as diagnosis_column\r\n , diagnosis_code_6 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_7' as diagnosis_column\r\n , diagnosis_code_7 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_8' as diagnosis_column\r\n , diagnosis_code_8 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_9' as diagnosis_column\r\n , diagnosis_code_9 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_10' as diagnosis_column\r\n , diagnosis_code_10 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_11' as diagnosis_column\r\n , diagnosis_code_11 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_12' as diagnosis_column\r\n , diagnosis_code_12 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_13' as diagnosis_column\r\n , diagnosis_code_13 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_14' as diagnosis_column\r\n , diagnosis_code_14 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_15' as diagnosis_column\r\n , diagnosis_code_15 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_16' as diagnosis_column\r\n , diagnosis_code_16 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_17' as diagnosis_column\r\n , diagnosis_code_17 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_18' as diagnosis_column\r\n , diagnosis_code_18 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_19' as diagnosis_column\r\n , diagnosis_code_19 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_20' as diagnosis_column\r\n , diagnosis_code_20 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_21' as diagnosis_column\r\n , diagnosis_code_21 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_22' as diagnosis_column\r\n , diagnosis_code_22 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_23' as diagnosis_column\r\n , diagnosis_code_24 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_24' as diagnosis_column\r\n , diagnosis_code_24 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , diagnosis_code_type\r\n , 'diagnosis_code_25' as diagnosis_column\r\n , diagnosis_code_25 as diagnosis_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , diagnosis_code_type\r\n , diagnosis_column\r\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm) as normalized_diagnosis_code\r\n , count(*) as diagnosis_code_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_diagnosis piv\r\nleft join {{ ref('terminology__icd_10_cm') }} icd_10\r\n on replace(piv.diagnosis_code,'.','') = icd_10.icd_10_cm\r\n and piv.diagnosis_code_type = 'icd-10-cm'\r\nleft join {{ ref('terminology__icd_9_cm') }} icd_9\r\n on replace(piv.diagnosis_code,'.','') = icd_9.icd_9_cm\r\n and piv.diagnosis_code_type = 'icd-9-cm'\r\nwhere claim_type <> 'undetermined'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , diagnosis_code_type\r\n , diagnosis_column\r\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm)", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_diagnosis as(\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_1' as diagnosis_column\n , diagnosis_code_1 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_2' as diagnosis_column\n , diagnosis_code_2 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_3' as diagnosis_column\n , diagnosis_code_3 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_4' as diagnosis_column\n , diagnosis_code_4 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_5' as diagnosis_column\n , diagnosis_code_5 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_6' as diagnosis_column\n , diagnosis_code_6 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_7' as diagnosis_column\n , diagnosis_code_7 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_8' as diagnosis_column\n , diagnosis_code_8 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_9' as diagnosis_column\n , diagnosis_code_9 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_10' as diagnosis_column\n , diagnosis_code_10 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_11' as diagnosis_column\n , diagnosis_code_11 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_12' as diagnosis_column\n , diagnosis_code_12 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_13' as diagnosis_column\n , diagnosis_code_13 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_14' as diagnosis_column\n , diagnosis_code_14 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_15' as diagnosis_column\n , diagnosis_code_15 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_16' as diagnosis_column\n , diagnosis_code_16 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_17' as diagnosis_column\n , diagnosis_code_17 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_18' as diagnosis_column\n , diagnosis_code_18 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_19' as diagnosis_column\n , diagnosis_code_19 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_20' as diagnosis_column\n , diagnosis_code_20 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_21' as diagnosis_column\n , diagnosis_code_21 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_22' as diagnosis_column\n , diagnosis_code_22 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_23' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_24' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_25' as diagnosis_column\n , diagnosis_code_25 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm) as normalized_diagnosis_code\n , count(*) as diagnosis_code_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_diagnosis piv\nleft join dev_thuxuan.terminology.icd_10_cm icd_10\n on replace(piv.diagnosis_code,'.','') = icd_10.icd_10_cm\n and piv.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd_9\n on replace(piv.diagnosis_code,'.','') = icd_9.icd_9_cm\n and piv.diagnosis_code_type = 'icd-9-cm'\nwhere claim_type <> 'undetermined'\ngroup by \n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm)", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_diagnosis_code_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_diagnosis_code_voting"], "alias": "_int_normalized_input_diagnosis_code_voting", "checksum": {"name": "sha256", "checksum": "d19ae69e58ccaffcf91a85e79d9dde2e838c628acf597b917be7bf34823bd738"}, "config": {"enabled": true, "alias": "_int_normalized_input_diagnosis_code_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_diagnosis_code_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2550714, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_diagnosis_code_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.diagnosis_column as column_name\r\n , norm.normalized_diagnosis_code as normalized_code\r\n , norm.diagnosis_code_occurrence_count as occurrence_count\r\n , coalesce(lead(diagnosis_code_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_diagnosis_code_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.diagnosis_column = dist.diagnosis_column", "language": "sql", "refs": [{"name": "normalized_input__int_diagnosis_code_normalize", "package": null, "version": null}, {"name": "normalized_input__int_diagnosis_code_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_diagnosis_code_normalize"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_diagnosis_code_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_diagnosis_code as normalized_code\n , norm.diagnosis_code_occurrence_count as occurrence_count\n , coalesce(lead(diagnosis_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_discharge_disposition_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_discharge_disposition_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_discharge_disposition_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_discharge_disposition_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_discharge_disposition_final"], "alias": "_int_normalized_input_discharge_disposition_final", "checksum": {"name": "sha256", "checksum": "60469d9873a6ad01d5d1818a35994c6c0e3a0f179a74cd9d27da735b2816819d"}, "config": {"enabled": true, "alias": "_int_normalized_input_discharge_disposition_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_discharge_disposition_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2570713, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_discharge_disposition_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_discharge_disposition_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_discharge_disposition_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_discharge_disposition_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_discharge_disposition_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_discharge_disposition_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_discharge_disposition_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_discharge_disposition_voting"], "alias": "_int_normalized_input_discharge_disposition_voting", "checksum": {"name": "sha256", "checksum": "613692797ea7a92b591974523fb76adc8e5fdac10e6f8beb4f777c271f5d10a6"}, "config": {"enabled": true, "alias": "_int_normalized_input_discharge_disposition_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_discharge_disposition_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2600713, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith normalize_cte as(\r\n select \r\n med.claim_id\r\n , med.data_source\r\n , disch.discharge_disposition_code\r\n , disch.discharge_disposition_description\r\n from {{ ref('normalized_input__stg_medical_claim') }} med\r\n inner join {{ ref('terminology__discharge_disposition') }} disch\r\n on med.discharge_disposition_code = disch.discharge_disposition_code\r\n where claim_type = 'institutional'\r\n)\r\n, distinct_counts as(\r\n select \r\n claim_id\r\n , data_source\r\n , discharge_disposition_code\r\n , discharge_disposition_description\r\n , count(*) as discharge_disposition_occurrence_count\r\n from normalize_cte\r\n where discharge_disposition_code is not null\r\n group by \r\n claim_id\r\n , data_source\r\n , discharge_disposition_code\r\n , discharge_disposition_description\r\n)\r\n\r\n, occurence_comparison as(\r\n select\r\n claim_id\r\n , data_source\r\n , 'discharge_disposition_code' as column_name\r\n , discharge_disposition_code as normalized_code\r\n , discharge_disposition_description as normalized_description\r\n , discharge_disposition_occurrence_count as occurrence_count\r\n , coalesce(lead(discharge_disposition_occurrence_count) \r\n over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc) as occurrence_row_count\r\n from distinct_counts dist\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_discharge_disposition_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , disch.discharge_disposition_code\n , disch.discharge_disposition_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.discharge_disposition disch\n on med.discharge_disposition_code = disch.discharge_disposition_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n , count(*) as discharge_disposition_occurrence_count\n from normalize_cte\n where discharge_disposition_code is not null\n group by \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'discharge_disposition_code' as column_name\n , discharge_disposition_code as normalized_code\n , discharge_disposition_description as normalized_description\n , discharge_disposition_occurrence_count as occurrence_count\n , coalesce(lead(discharge_disposition_occurrence_count) \n over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_eligibility_dates_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_eligibility_dates_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_eligibility_dates_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_eligibility_dates_normalize"], "alias": "_int_normalized_input_eligibility_dates_normalize", "checksum": {"name": "sha256", "checksum": "a0be9fe1728c64a3ef41bb21d8e79b03b66a3c19b56fd50180d1d67530347b90"}, "config": {"enabled": true, "alias": "_int_normalized_input_eligibility_dates_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_eligibility_dates_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2620714, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_eligibility_dates_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect distinct\r\n elig.patient_id\r\n , {{ dbt.concat([\r\n \"elig.patient_id\",\r\n \"coalesce(elig.data_source,'')\",\r\n \"coalesce(elig.payer,'')\",\r\n \"coalesce(elig.\" ~ quote_column('plan') ~ \",'')\",\r\n \"coalesce(cast(elig.enrollment_start_date as \" ~ dbt.type_string() ~ \"),'')\",\r\n \"coalesce(cast(elig.enrollment_end_date as \" ~ dbt.type_string() ~ \"),'')\"\r\n ]) }} as patient_id_key\r\n , cal_dob.full_date as normalized_birth_date\r\n , cal_death.full_date as normalized_death_date\r\n , cal_enroll_start.full_date as normalized_enrollment_start_date\r\n , cal_enroll_end.full_date as normalized_enrollment_end_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_eligibility') }} elig\r\nleft join {{ ref('reference_data__calendar') }} cal_dob\r\n on elig.birth_date = cal_dob.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_death\r\n on elig.death_date = cal_death.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_enroll_start\r\n on elig.enrollment_start_date = cal_enroll_start.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_enroll_end\r\n on elig.enrollment_end_date = cal_enroll_end.full_date", "language": "sql", "refs": [{"name": "normalized_input__stg_eligibility", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.normalized_input__stg_eligibility", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_eligibility_dates_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select distinct\n elig.patient_id\n , elig.patient_id || coalesce(elig.data_source,'') || coalesce(elig.payer,'') || coalesce(elig.plan,'') || coalesce(cast(elig.enrollment_start_date as TEXT),'') || coalesce(cast(elig.enrollment_end_date as TEXT),'') as patient_id_key\n , cal_dob.full_date as normalized_birth_date\n , cal_death.full_date as normalized_death_date\n , cal_enroll_start.full_date as normalized_enrollment_start_date\n , cal_enroll_end.full_date as normalized_enrollment_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join dev_thuxuan.reference_data.calendar cal_dob\n on elig.birth_date = cal_dob.full_date\nleft join dev_thuxuan.reference_data.calendar cal_death\n on elig.death_date = cal_death.full_date\nleft join dev_thuxuan.reference_data.calendar cal_enroll_start\n on elig.enrollment_start_date = cal_enroll_start.full_date\nleft join dev_thuxuan.reference_data.calendar cal_enroll_end\n on elig.enrollment_end_date = cal_enroll_end.full_date", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_eligibility", "sql": " __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_medical_claim_date_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_claim_date_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_claim_date_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_medical_claim_date_normalize"], "alias": "_int_normalized_input_medical_claim_date_normalize", "checksum": {"name": "sha256", "checksum": "2a43d655d96e207482f8e9fdfb410d0b2198bec02e0e239fc578933c0570777f"}, "config": {"enabled": true, "alias": "_int_normalized_input_medical_claim_date_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_medical_claim_date_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2640712, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_type\r\n , med.data_source\r\n , cal_claim_start.full_date as normalized_claim_start_date\r\n , cal_claim_end.full_date as normalized_claim_end_date\r\n , cal_claim_line_start.full_date as normalized_claim_line_start_date\r\n , cal_claim_line_end.full_date as normalized_claim_line_end_date\r\n , cal_admission.full_date as normalized_admission_date\r\n , cal_discharge.full_date as normalized_discharge_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\r\nleft join {{ ref('reference_data__calendar') }} cal_claim_start\r\n on med.claim_start_date = cal_claim_start.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_claim_end\r\n on med.claim_end_date = cal_claim_end.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_claim_line_start\r\n on med.claim_line_start_date = cal_claim_line_start.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_claim_line_end\r\n on med.claim_line_end_date = cal_claim_line_end.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_admission\r\n on med.admission_date = cal_admission.full_date\r\nleft join {{ ref('reference_data__calendar') }} cal_discharge\r\n on med.discharge_date = cal_discharge.full_date", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_claim_date_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , cal_claim_start.full_date as normalized_claim_start_date\n , cal_claim_end.full_date as normalized_claim_end_date\n , cal_claim_line_start.full_date as normalized_claim_line_start_date\n , cal_claim_line_end.full_date as normalized_claim_line_end_date\n , cal_admission.full_date as normalized_admission_date\n , cal_discharge.full_date as normalized_discharge_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.reference_data.calendar cal_claim_start\n on med.claim_start_date = cal_claim_start.full_date\nleft join dev_thuxuan.reference_data.calendar cal_claim_end\n on med.claim_end_date = cal_claim_end.full_date\nleft join dev_thuxuan.reference_data.calendar cal_claim_line_start\n on med.claim_line_start_date = cal_claim_line_start.full_date\nleft join dev_thuxuan.reference_data.calendar cal_claim_line_end\n on med.claim_line_end_date = cal_claim_line_end.full_date\nleft join dev_thuxuan.reference_data.calendar cal_admission\n on med.admission_date = cal_admission.full_date\nleft join dev_thuxuan.reference_data.calendar cal_discharge\n on med.discharge_date = cal_discharge.full_date", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_medical_date_aggregation": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_medical_date_aggregation", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_date_aggregation.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_date_aggregation.sql", "unique_id": "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_medical_date_aggregation"], "alias": "_int_normalized_input_medical_date_aggregation", "checksum": {"name": "sha256", "checksum": "5596dbf9586a54cac39aaf04d1f8e561dae60f0be82b9e6c0b069182267831f0"}, "config": {"enabled": true, "alias": "_int_normalized_input_medical_date_aggregation", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_medical_date_aggregation", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.266071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_medical_date_aggregation", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , min(normalized_claim_start_date) as minimum_claim_start_date\r\n , max(normalized_claim_end_date) as maximum_claim_end_date\r\n , min(normalized_admission_date) as minimum_admission_date\r\n , max(normalized_discharge_date) as maximum_discharge_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_medical_claim_date_normalize') }}\r\nwhere claim_type = 'institutional'\r\ngroup by\r\n claim_id\r\n , data_source\r\n\r\nunion all\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , min(normalized_claim_start_date) as minimum_claim_start_date\r\n , max(normalized_claim_end_date) as maximum_claim_end_date\r\n , null as minimum_admission_date\r\n , null as maximum_discharge_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_medical_claim_date_normalize') }}\r\nwhere claim_type = 'professional'\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_medical_claim_date_normalize", "package": null, "version": null}, {"name": "normalized_input__int_medical_claim_date_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_medical_claim_date_normalize"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_date_aggregation.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , min(normalized_admission_date) as minimum_admission_date\n , max(normalized_discharge_date) as maximum_discharge_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'institutional'\ngroup by\n claim_id\n , data_source\n\nunion all\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , null as minimum_admission_date\n , null as maximum_discharge_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'professional'\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_medical_npi_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_medical_npi_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_npi_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_npi_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_medical_npi_normalize"], "alias": "_int_normalized_input_medical_npi_normalize", "checksum": {"name": "sha256", "checksum": "17f4d3f0f93f0418cf09b33fa9ca4a8d30d3967e41d5cc43625f5c6bc413dbca"}, "config": {"enabled": true, "alias": "_int_normalized_input_medical_npi_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_medical_npi_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.268071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_medical_npi_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_type\r\n , med.data_source\r\n , rend_prov.npi as normalized_rendering_npi\r\n , cast(coalesce({{ dbt.concat([\"rend_prov.provider_last_name\", \"', '\", \"rend_prov.provider_first_name\"]) }}, rend_prov.provider_organization_name) as {{ dbt.type_string() }} ) as normalized_rendering_name\r\n , bill_prov.npi as normalized_billing_npi\r\n , cast(coalesce({{ dbt.concat([\"bill_prov.provider_last_name\", \"', '\", \"bill_prov.provider_first_name\"]) }}, bill_prov.provider_organization_name) as {{ dbt.type_string() }} ) as normalized_billing_name\r\n , fac_prov.npi as normalized_facility_npi\r\n , cast(coalesce({{ dbt.concat([\"fac_prov.provider_last_name\", \"', '\", \"fac_prov.provider_first_name\"]) }}, fac_prov.provider_organization_name) as {{ dbt.type_string() }} ) as normalized_facility_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\r\nleft join {{ ref('terminology__provider') }} rend_prov\r\n on med.rendering_npi = rend_prov.npi\r\n and rend_prov.entity_type_description = 'Individual'\r\nleft join {{ ref('terminology__provider') }} bill_prov\r\n on med.billing_npi = bill_prov.npi\r\nleft join {{ ref('terminology__provider') }} fac_prov\r\n on med.facility_npi = fac_prov.npi\r\n and fac_prov.entity_type_description = 'Organization'\r\n and med.claim_type = 'institutional'", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_medical_npi_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , rend_prov.npi as normalized_rendering_npi\n , cast(coalesce(rend_prov.provider_last_name || ', ' || rend_prov.provider_first_name, rend_prov.provider_organization_name) as TEXT ) as normalized_rendering_name\n , bill_prov.npi as normalized_billing_npi\n , cast(coalesce(bill_prov.provider_last_name || ', ' || bill_prov.provider_first_name, bill_prov.provider_organization_name) as TEXT ) as normalized_billing_name\n , fac_prov.npi as normalized_facility_npi\n , cast(coalesce(fac_prov.provider_last_name || ', ' || fac_prov.provider_first_name, fac_prov.provider_organization_name) as TEXT ) as normalized_facility_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.provider rend_prov\n on med.rendering_npi = rend_prov.npi\n and rend_prov.entity_type_description = 'Individual'\nleft join dev_thuxuan.terminology.provider bill_prov\n on med.billing_npi = bill_prov.npi\nleft join dev_thuxuan.terminology.provider fac_prov\n on med.facility_npi = fac_prov.npi\n and fac_prov.entity_type_description = 'Organization'\n and med.claim_type = 'institutional'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_ms_drg_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_ms_drg_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_ms_drg_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_ms_drg_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_ms_drg_final"], "alias": "_int_normalized_input_ms_drg_final", "checksum": {"name": "sha256", "checksum": "25fa6a2358d6b425101ea661d7e0bfe3bc33cbef157ff5588f6c1cd36d55bfe0"}, "config": {"enabled": true, "alias": "_int_normalized_input_ms_drg_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_ms_drg_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.270071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_ms_drg_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)", "language": "sql", "refs": [{"name": "normalized_input__int_ms_drg_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_ms_drg_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_ms_drg_final.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_ms_drg_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_ms_drg_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_ms_drg_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_ms_drg_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_ms_drg_voting"], "alias": "_int_normalized_input_ms_drg_voting", "checksum": {"name": "sha256", "checksum": "c15e1733910c12bf13735b543bd8e83674ad5e2b29150d9385e811fa96e220d6"}, "config": {"enabled": true, "alias": "_int_normalized_input_ms_drg_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_ms_drg_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.273071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith normalize_cte as(\r\n select \r\n med.claim_id\r\n , med.data_source\r\n , ms.ms_drg_code\r\n , ms.ms_drg_description\r\n from {{ ref('normalized_input__stg_medical_claim') }} med\r\n inner join {{ ref('terminology__ms_drg') }} ms\r\n on med.ms_drg_code = ms.ms_drg_code\r\n where claim_type = 'institutional'\r\n)\r\n, distinct_counts as(\r\n select \r\n claim_id\r\n , data_source\r\n , ms_drg_code\r\n , ms_drg_description\r\n , count(*) as ms_drg_occurrence_count\r\n from normalize_cte\r\n where ms_drg_code is not null\r\n group by \r\n claim_id\r\n , data_source\r\n , ms_drg_code\r\n , ms_drg_description\r\n)\r\n\r\n, occurence_comparison as(\r\n select\r\n claim_id\r\n , data_source\r\n , 'ms_drg_code' as column_name\r\n , ms_drg_code as normalized_code\r\n , ms_drg_description as normalized_description\r\n , ms_drg_occurrence_count as occurrence_count\r\n , coalesce(lead(ms_drg_occurrence_count) \r\n over (partition by claim_id, data_source order by ms_drg_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by claim_id, data_source order by ms_drg_occurrence_count desc) as occurrence_row_count\r\n from distinct_counts dist\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , column_name\r\n , normalized_code\r\n , normalized_description\r\n , occurrence_count\r\n , next_occurrence_count\r\n , occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom occurence_comparison", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_ms_drg_voting.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , ms.ms_drg_code\n , ms.ms_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.ms_drg ms\n on med.ms_drg_code = ms.ms_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , count(*) as ms_drg_occurrence_count\n from normalize_cte\n where ms_drg_code is not null\n group by \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'ms_drg_code' as column_name\n , ms_drg_code as normalized_code\n , ms_drg_description as normalized_description\n , ms_drg_occurrence_count as occurrence_count\n , coalesce(lead(ms_drg_occurrence_count) \n over (partition by claim_id, data_source order by ms_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by ms_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_place_of_service_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_place_of_service_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_place_of_service_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_place_of_service_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_place_of_service_normalize"], "alias": "_int_normalized_input_place_of_service_normalize", "checksum": {"name": "sha256", "checksum": "53e8b075a3f04a65475f3e8a29430d78364f2254302ba692dd498b8464373a0d"}, "config": {"enabled": true, "alias": "_int_normalized_input_place_of_service_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_place_of_service_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.275071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_place_of_service_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , data_source\r\n , pos.place_of_service_code as normalized_code\r\n , pos.place_of_service_description as normalized_description\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\r\nleft join {{ ref('terminology__place_of_service') }} pos\r\n {% if target.type == 'fabric' %}\r\n on RIGHT(REPLICATE('0', 2) + med.place_of_service_code, 2) = pos.place_of_service_code\r\n {% else %}\r\n on lpad(med.place_of_service_code, 2, '0') = pos.place_of_service_code\r\n {% endif %}\r\nwhere claim_type = 'professional'", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__place_of_service"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_place_of_service_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , pos.place_of_service_code as normalized_code\n , pos.place_of_service_description as normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.place_of_service pos\n \n on lpad(med.place_of_service_code, 2, '0') = pos.place_of_service_code\n \nwhere claim_type = 'professional'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_present_on_admit_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_present_on_admit_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_present_on_admit_final"], "alias": "_int_normalized_input_present_on_admit_final", "checksum": {"name": "sha256", "checksum": "ffd6b269b3f66e12d285c19dd8ef53c79e00a531b6bff27fd7dead01dd0852fb"}, "config": {"enabled": true, "alias": "_int_normalized_input_present_on_admit_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_present_on_admit_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2770715, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when column_name = 'DIAGNOSIS_POA_1' then normalized_code else null end) as diagnosis_poa_1\r\n , max(case when column_name = 'DIAGNOSIS_POA_2' then normalized_code else null end) as diagnosis_poa_2\r\n , max(case when column_name = 'DIAGNOSIS_POA_3' then normalized_code else null end) as diagnosis_poa_3\r\n , max(case when column_name = 'DIAGNOSIS_POA_4' then normalized_code else null end) as diagnosis_poa_4\r\n , max(case when column_name = 'DIAGNOSIS_POA_5' then normalized_code else null end) as diagnosis_poa_5\r\n , max(case when column_name = 'DIAGNOSIS_POA_6' then normalized_code else null end) as diagnosis_poa_6\r\n , max(case when column_name = 'DIAGNOSIS_POA_7' then normalized_code else null end) as diagnosis_poa_7\r\n , max(case when column_name = 'DIAGNOSIS_POA_8' then normalized_code else null end) as diagnosis_poa_8\r\n , max(case when column_name = 'DIAGNOSIS_POA_9' then normalized_code else null end) as diagnosis_poa_9\r\n , max(case when column_name = 'DIAGNOSIS_POA_10' then normalized_code else null end) as diagnosis_poa_10\r\n , max(case when column_name = 'DIAGNOSIS_POA_11' then normalized_code else null end) as diagnosis_poa_11\r\n , max(case when column_name = 'DIAGNOSIS_POA_12' then normalized_code else null end) as diagnosis_poa_12\r\n , max(case when column_name = 'DIAGNOSIS_POA_13' then normalized_code else null end) as diagnosis_poa_13\r\n , max(case when column_name = 'DIAGNOSIS_POA_14' then normalized_code else null end) as diagnosis_poa_14\r\n , max(case when column_name = 'DIAGNOSIS_POA_15' then normalized_code else null end) as diagnosis_poa_15\r\n , max(case when column_name = 'DIAGNOSIS_POA_16' then normalized_code else null end) as diagnosis_poa_16\r\n , max(case when column_name = 'DIAGNOSIS_POA_17' then normalized_code else null end) as diagnosis_poa_17\r\n , max(case when column_name = 'DIAGNOSIS_POA_18' then normalized_code else null end) as diagnosis_poa_18\r\n , max(case when column_name = 'DIAGNOSIS_POA_19' then normalized_code else null end) as diagnosis_poa_19\r\n , max(case when column_name = 'DIAGNOSIS_POA_20' then normalized_code else null end) as diagnosis_poa_20\r\n , max(case when column_name = 'DIAGNOSIS_POA_21' then normalized_code else null end) as diagnosis_poa_21\r\n , max(case when column_name = 'DIAGNOSIS_POA_22' then normalized_code else null end) as diagnosis_poa_22\r\n , max(case when column_name = 'DIAGNOSIS_POA_23' then normalized_code else null end) as diagnosis_poa_23\r\n , max(case when column_name = 'DIAGNOSIS_POA_24' then normalized_code else null end) as diagnosis_poa_24\r\n , max(case when column_name = 'DIAGNOSIS_POA_25' then normalized_code else null end) as diagnosis_poa_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_present_on_admit_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_present_on_admit_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_present_on_admit_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_final.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when column_name = 'DIAGNOSIS_POA_1' then normalized_code else null end) as diagnosis_poa_1\n , max(case when column_name = 'DIAGNOSIS_POA_2' then normalized_code else null end) as diagnosis_poa_2\n , max(case when column_name = 'DIAGNOSIS_POA_3' then normalized_code else null end) as diagnosis_poa_3\n , max(case when column_name = 'DIAGNOSIS_POA_4' then normalized_code else null end) as diagnosis_poa_4\n , max(case when column_name = 'DIAGNOSIS_POA_5' then normalized_code else null end) as diagnosis_poa_5\n , max(case when column_name = 'DIAGNOSIS_POA_6' then normalized_code else null end) as diagnosis_poa_6\n , max(case when column_name = 'DIAGNOSIS_POA_7' then normalized_code else null end) as diagnosis_poa_7\n , max(case when column_name = 'DIAGNOSIS_POA_8' then normalized_code else null end) as diagnosis_poa_8\n , max(case when column_name = 'DIAGNOSIS_POA_9' then normalized_code else null end) as diagnosis_poa_9\n , max(case when column_name = 'DIAGNOSIS_POA_10' then normalized_code else null end) as diagnosis_poa_10\n , max(case when column_name = 'DIAGNOSIS_POA_11' then normalized_code else null end) as diagnosis_poa_11\n , max(case when column_name = 'DIAGNOSIS_POA_12' then normalized_code else null end) as diagnosis_poa_12\n , max(case when column_name = 'DIAGNOSIS_POA_13' then normalized_code else null end) as diagnosis_poa_13\n , max(case when column_name = 'DIAGNOSIS_POA_14' then normalized_code else null end) as diagnosis_poa_14\n , max(case when column_name = 'DIAGNOSIS_POA_15' then normalized_code else null end) as diagnosis_poa_15\n , max(case when column_name = 'DIAGNOSIS_POA_16' then normalized_code else null end) as diagnosis_poa_16\n , max(case when column_name = 'DIAGNOSIS_POA_17' then normalized_code else null end) as diagnosis_poa_17\n , max(case when column_name = 'DIAGNOSIS_POA_18' then normalized_code else null end) as diagnosis_poa_18\n , max(case when column_name = 'DIAGNOSIS_POA_19' then normalized_code else null end) as diagnosis_poa_19\n , max(case when column_name = 'DIAGNOSIS_POA_20' then normalized_code else null end) as diagnosis_poa_20\n , max(case when column_name = 'DIAGNOSIS_POA_21' then normalized_code else null end) as diagnosis_poa_21\n , max(case when column_name = 'DIAGNOSIS_POA_22' then normalized_code else null end) as diagnosis_poa_22\n , max(case when column_name = 'DIAGNOSIS_POA_23' then normalized_code else null end) as diagnosis_poa_23\n , max(case when column_name = 'DIAGNOSIS_POA_24' then normalized_code else null end) as diagnosis_poa_24\n , max(case when column_name = 'DIAGNOSIS_POA_25' then normalized_code else null end) as diagnosis_poa_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_present_on_admit_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_present_on_admit_normalize"], "alias": "_int_normalized_input_present_on_admit_normalize", "checksum": {"name": "sha256", "checksum": "bddfc433eda6677655f5ce0809136b91f5451863ff74e71b69b55e02f7321643"}, "config": {"enabled": true, "alias": "_int_normalized_input_present_on_admit_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_present_on_admit_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.280071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n\r\nwith pivot_poa as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_1' as diagnosis_column\r\n , diagnosis_poa_1 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_2' as diagnosis_column\r\n , diagnosis_poa_2 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_3' as diagnosis_column\r\n , diagnosis_poa_3 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_4' as diagnosis_column\r\n , diagnosis_poa_4 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_5' as diagnosis_column\r\n , diagnosis_poa_5 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_6' as diagnosis_column\r\n , diagnosis_poa_6 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_7' as diagnosis_column\r\n , diagnosis_poa_7 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_8' as diagnosis_column\r\n , diagnosis_poa_8 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_9' as diagnosis_column\r\n , diagnosis_poa_9 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_10' as diagnosis_column\r\n , diagnosis_poa_10 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_11' as diagnosis_column\r\n , diagnosis_poa_11 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_12' as diagnosis_column\r\n , diagnosis_poa_12 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_13' as diagnosis_column\r\n , diagnosis_poa_13 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_14' as diagnosis_column\r\n , diagnosis_poa_14 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_15' as diagnosis_column\r\n , diagnosis_poa_15 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_16' as diagnosis_column\r\n , diagnosis_poa_16 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_17' as diagnosis_column\r\n , diagnosis_poa_17 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_18' as diagnosis_column\r\n , diagnosis_poa_18 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_19' as diagnosis_column\r\n , diagnosis_poa_19 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_20' as diagnosis_column\r\n , diagnosis_poa_20 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_21' as diagnosis_column\r\n , diagnosis_poa_21 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_22' as diagnosis_column\r\n , diagnosis_poa_22 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_23' as diagnosis_column\r\n , diagnosis_poa_24 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_24' as diagnosis_column\r\n , diagnosis_poa_24 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'diagnosis_poa_25' as diagnosis_column\r\n , diagnosis_poa_25 as present_on_admit_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , poa.present_on_admit_code as normalized_present_on_admit_code\r\n , count(*) as present_on_admit_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_poa piv\r\nleft join {{ ref('terminology__present_on_admission') }} poa\r\n on replace(piv.present_on_admit_code,'.','') = poa.present_on_admit_code\r\nwhere claim_type = 'institutional'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , poa.present_on_admit_code", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__present_on_admission", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__present_on_admission"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_poa as(\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_1' as diagnosis_column\n , diagnosis_poa_1 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_2' as diagnosis_column\n , diagnosis_poa_2 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_3' as diagnosis_column\n , diagnosis_poa_3 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_4' as diagnosis_column\n , diagnosis_poa_4 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_5' as diagnosis_column\n , diagnosis_poa_5 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_6' as diagnosis_column\n , diagnosis_poa_6 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_7' as diagnosis_column\n , diagnosis_poa_7 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_8' as diagnosis_column\n , diagnosis_poa_8 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_9' as diagnosis_column\n , diagnosis_poa_9 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_10' as diagnosis_column\n , diagnosis_poa_10 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_11' as diagnosis_column\n , diagnosis_poa_11 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_12' as diagnosis_column\n , diagnosis_poa_12 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_13' as diagnosis_column\n , diagnosis_poa_13 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_14' as diagnosis_column\n , diagnosis_poa_14 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_15' as diagnosis_column\n , diagnosis_poa_15 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_16' as diagnosis_column\n , diagnosis_poa_16 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_17' as diagnosis_column\n , diagnosis_poa_17 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_18' as diagnosis_column\n , diagnosis_poa_18 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_19' as diagnosis_column\n , diagnosis_poa_19 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_20' as diagnosis_column\n , diagnosis_poa_20 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_21' as diagnosis_column\n , diagnosis_poa_21 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_22' as diagnosis_column\n , diagnosis_poa_22 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_23' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_24' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_25' as diagnosis_column\n , diagnosis_poa_25 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code as normalized_present_on_admit_code\n , count(*) as present_on_admit_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_poa piv\nleft join dev_thuxuan.terminology.present_on_admission poa\n on replace(piv.present_on_admit_code,'.','') = poa.present_on_admit_code\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_present_on_admit_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_present_on_admit_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_present_on_admit_voting"], "alias": "_int_normalized_input_present_on_admit_voting", "checksum": {"name": "sha256", "checksum": "eb0123290dd8ea0f0222f45ce161e6163f5db9b1bedb124f334a8419b2fa9e9a"}, "config": {"enabled": true, "alias": "_int_normalized_input_present_on_admit_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_present_on_admit_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2830696, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_present_on_admit_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , diagnosis_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.diagnosis_column as column_name\r\n , norm.normalized_present_on_admit_code as normalized_code\r\n , norm.present_on_admit_occurrence_count as occurrence_count\r\n , coalesce(lead(present_on_admit_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_present_on_admit_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.diagnosis_column = dist.diagnosis_column", "language": "sql", "refs": [{"name": "normalized_input__int_present_on_admit_normalize", "package": null, "version": null}, {"name": "normalized_input__int_present_on_admit_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_present_on_admit_normalize"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_present_on_admit_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_present_on_admit_code as normalized_code\n , norm.present_on_admit_occurrence_count as occurrence_count\n , coalesce(lead(present_on_admit_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_code_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_code_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_code_final"], "alias": "_int_normalized_input_procedure_code_final", "checksum": {"name": "sha256", "checksum": "7bdf91705a81d2db2c780dbd651d62835213dfde60545b4e567df4b69ff0d9fe"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_code_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_code_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.285073, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when lower(column_name) = 'procedure_code_1' then normalized_code else null end) as procedure_code_1\r\n , max(case when lower(column_name) = 'procedure_code_2' then normalized_code else null end) as procedure_code_2\r\n , max(case when lower(column_name) = 'procedure_code_3' then normalized_code else null end) as procedure_code_3\r\n , max(case when lower(column_name) = 'procedure_code_4' then normalized_code else null end) as procedure_code_4\r\n , max(case when lower(column_name) = 'procedure_code_5' then normalized_code else null end) as procedure_code_5\r\n , max(case when lower(column_name) = 'procedure_code_6' then normalized_code else null end) as procedure_code_6\r\n , max(case when lower(column_name) = 'procedure_code_7' then normalized_code else null end) as procedure_code_7\r\n , max(case when lower(column_name) = 'procedure_code_8' then normalized_code else null end) as procedure_code_8\r\n , max(case when lower(column_name) = 'procedure_code_9' then normalized_code else null end) as procedure_code_9\r\n , max(case when lower(column_name) = 'procedure_code_10' then normalized_code else null end) as procedure_code_10\r\n , max(case when lower(column_name) = 'procedure_code_11' then normalized_code else null end) as procedure_code_11\r\n , max(case when lower(column_name) = 'procedure_code_12' then normalized_code else null end) as procedure_code_12\r\n , max(case when lower(column_name) = 'procedure_code_13' then normalized_code else null end) as procedure_code_13\r\n , max(case when lower(column_name) = 'procedure_code_14' then normalized_code else null end) as procedure_code_14\r\n , max(case when lower(column_name) = 'procedure_code_15' then normalized_code else null end) as procedure_code_15\r\n , max(case when lower(column_name) = 'procedure_code_16' then normalized_code else null end) as procedure_code_16\r\n , max(case when lower(column_name) = 'procedure_code_17' then normalized_code else null end) as procedure_code_17\r\n , max(case when lower(column_name) = 'procedure_code_18' then normalized_code else null end) as procedure_code_18\r\n , max(case when lower(column_name) = 'procedure_code_19' then normalized_code else null end) as procedure_code_19\r\n , max(case when lower(column_name) = 'procedure_code_20' then normalized_code else null end) as procedure_code_20\r\n , max(case when lower(column_name) = 'procedure_code_21' then normalized_code else null end) as procedure_code_21\r\n , max(case when lower(column_name) = 'procedure_code_22' then normalized_code else null end) as procedure_code_22\r\n , max(case when lower(column_name) = 'procedure_code_23' then normalized_code else null end) as procedure_code_23\r\n , max(case when lower(column_name) = 'procedure_code_24' then normalized_code else null end) as procedure_code_24\r\n , max(case when lower(column_name) = 'procedure_code_25' then normalized_code else null end) as procedure_code_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_code_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_code_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_code_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_final.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_code_1' then normalized_code else null end) as procedure_code_1\n , max(case when lower(column_name) = 'procedure_code_2' then normalized_code else null end) as procedure_code_2\n , max(case when lower(column_name) = 'procedure_code_3' then normalized_code else null end) as procedure_code_3\n , max(case when lower(column_name) = 'procedure_code_4' then normalized_code else null end) as procedure_code_4\n , max(case when lower(column_name) = 'procedure_code_5' then normalized_code else null end) as procedure_code_5\n , max(case when lower(column_name) = 'procedure_code_6' then normalized_code else null end) as procedure_code_6\n , max(case when lower(column_name) = 'procedure_code_7' then normalized_code else null end) as procedure_code_7\n , max(case when lower(column_name) = 'procedure_code_8' then normalized_code else null end) as procedure_code_8\n , max(case when lower(column_name) = 'procedure_code_9' then normalized_code else null end) as procedure_code_9\n , max(case when lower(column_name) = 'procedure_code_10' then normalized_code else null end) as procedure_code_10\n , max(case when lower(column_name) = 'procedure_code_11' then normalized_code else null end) as procedure_code_11\n , max(case when lower(column_name) = 'procedure_code_12' then normalized_code else null end) as procedure_code_12\n , max(case when lower(column_name) = 'procedure_code_13' then normalized_code else null end) as procedure_code_13\n , max(case when lower(column_name) = 'procedure_code_14' then normalized_code else null end) as procedure_code_14\n , max(case when lower(column_name) = 'procedure_code_15' then normalized_code else null end) as procedure_code_15\n , max(case when lower(column_name) = 'procedure_code_16' then normalized_code else null end) as procedure_code_16\n , max(case when lower(column_name) = 'procedure_code_17' then normalized_code else null end) as procedure_code_17\n , max(case when lower(column_name) = 'procedure_code_18' then normalized_code else null end) as procedure_code_18\n , max(case when lower(column_name) = 'procedure_code_19' then normalized_code else null end) as procedure_code_19\n , max(case when lower(column_name) = 'procedure_code_20' then normalized_code else null end) as procedure_code_20\n , max(case when lower(column_name) = 'procedure_code_21' then normalized_code else null end) as procedure_code_21\n , max(case when lower(column_name) = 'procedure_code_22' then normalized_code else null end) as procedure_code_22\n , max(case when lower(column_name) = 'procedure_code_23' then normalized_code else null end) as procedure_code_23\n , max(case when lower(column_name) = 'procedure_code_24' then normalized_code else null end) as procedure_code_24\n , max(case when lower(column_name) = 'procedure_code_25' then normalized_code else null end) as procedure_code_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_code_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_code_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_code_normalize"], "alias": "_int_normalized_input_procedure_code_normalize", "checksum": {"name": "sha256", "checksum": "373c2c62f9bea674fe68fa7a35b0af32019e0efd086302c3e9733f468ff56c8f"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_code_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_code_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.288071, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith pivot_procedure as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_1' as procedure_column\r\n , procedure_code_1 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_2' as procedure_column\r\n , procedure_code_2 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_3' as procedure_column\r\n , procedure_code_3 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_4' as procedure_column\r\n , procedure_code_4 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_5' as procedure_column\r\n , procedure_code_5 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_6' as procedure_column\r\n , procedure_code_6 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_7' as procedure_column\r\n , procedure_code_7 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_8' as procedure_column\r\n , procedure_code_8 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_9' as procedure_column\r\n , procedure_code_9 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_10' as procedure_column\r\n , procedure_code_10 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_11' as procedure_column\r\n , procedure_code_11 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_12' as procedure_column\r\n , procedure_code_12 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_13' as procedure_column\r\n , procedure_code_13 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_14' as procedure_column\r\n , procedure_code_14 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_15' as procedure_column\r\n , procedure_code_15 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_16' as procedure_column\r\n , procedure_code_16 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_17' as procedure_column\r\n , procedure_code_17 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_18' as procedure_column\r\n , procedure_code_18 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_19' as procedure_column\r\n , procedure_code_19 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_20' as procedure_column\r\n , procedure_code_20 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_21' as procedure_column\r\n , procedure_code_21 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_22' as procedure_column\r\n , procedure_code_22 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_23' as procedure_column\r\n , procedure_code_23 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_24' as procedure_column\r\n , procedure_code_24 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , procedure_code_type\r\n , 'procedure_code_25' as procedure_column\r\n , procedure_code_25 as procedure_code\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , procedure_code_type\r\n , procedure_column\r\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs) as normalized_procedure_code\r\n , count(*) as procedure_code_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_procedure piv\r\nleft join {{ ref('terminology__icd_10_pcs') }} icd_10\r\n on replace(piv.procedure_code,'.','') = icd_10.icd_10_pcs\r\n and piv.procedure_code_type = 'icd-10-pcs'\r\nleft join {{ ref('terminology__icd_9_pcs') }} icd_9\r\n on replace(piv.procedure_code,'.','') = icd_9.icd_9_pcs\r\n and piv.procedure_code_type = 'icd-9-pcs'\r\nwhere claim_type = 'institutional'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , procedure_code_type\r\n , procedure_column\r\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs)", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_1' as procedure_column\n , procedure_code_1 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_2' as procedure_column\n , procedure_code_2 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_3' as procedure_column\n , procedure_code_3 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_4' as procedure_column\n , procedure_code_4 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_5' as procedure_column\n , procedure_code_5 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_6' as procedure_column\n , procedure_code_6 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_7' as procedure_column\n , procedure_code_7 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_8' as procedure_column\n , procedure_code_8 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_9' as procedure_column\n , procedure_code_9 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_10' as procedure_column\n , procedure_code_10 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_11' as procedure_column\n , procedure_code_11 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_12' as procedure_column\n , procedure_code_12 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_13' as procedure_column\n , procedure_code_13 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_14' as procedure_column\n , procedure_code_14 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_15' as procedure_column\n , procedure_code_15 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_16' as procedure_column\n , procedure_code_16 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_17' as procedure_column\n , procedure_code_17 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_18' as procedure_column\n , procedure_code_18 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_19' as procedure_column\n , procedure_code_19 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_20' as procedure_column\n , procedure_code_20 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_21' as procedure_column\n , procedure_code_21 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_22' as procedure_column\n , procedure_code_22 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_23' as procedure_column\n , procedure_code_23 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_24' as procedure_column\n , procedure_code_24 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_25' as procedure_column\n , procedure_code_25 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs) as normalized_procedure_code\n , count(*) as procedure_code_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join dev_thuxuan.terminology.icd_10_pcs icd_10\n on replace(piv.procedure_code,'.','') = icd_10.icd_10_pcs\n and piv.procedure_code_type = 'icd-10-pcs'\nleft join dev_thuxuan.terminology.icd_9_pcs icd_9\n on replace(piv.procedure_code,'.','') = icd_9.icd_9_pcs\n and piv.procedure_code_type = 'icd-9-pcs'\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs)", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_code_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_code_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_code_voting"], "alias": "_int_normalized_input_procedure_code_voting", "checksum": {"name": "sha256", "checksum": "bece822a93f1ddeb86cf9da2b160d157ccaae782c9f481d29e2f8725bfff79ef"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_code_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_code_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.290076, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_procedure_code_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.procedure_column as column_name\r\n , norm.normalized_procedure_code as normalized_code\r\n , norm.procedure_code_occurrence_count as occurrence_count\r\n , coalesce(lead(procedure_code_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_code_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.procedure_column = dist.procedure_column", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_code_normalize", "package": null, "version": null}, {"name": "normalized_input__int_procedure_code_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_code_normalize"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_code_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.normalized_procedure_code as normalized_code\n , norm.procedure_code_occurrence_count as occurrence_count\n , coalesce(lead(procedure_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_date_final": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_date_final", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_final.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_final.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_final", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_date_final"], "alias": "_int_normalized_input_procedure_date_final", "checksum": {"name": "sha256", "checksum": "b2a28ab6f81ece5f5d0721efbc53d9c732dcf4b0bc0fcfbbeec9187cdb975e41"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_date_final", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_date_final", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.2920763, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_final", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , max(case when lower(column_name) = 'procedure_date_1' then normalized_code else null end) as procedure_date_1\r\n , max(case when lower(column_name) = 'procedure_date_2' then normalized_code else null end) as procedure_date_2\r\n , max(case when lower(column_name) = 'procedure_date_3' then normalized_code else null end) as procedure_date_3\r\n , max(case when lower(column_name) = 'procedure_date_4' then normalized_code else null end) as procedure_date_4\r\n , max(case when lower(column_name) = 'procedure_date_5' then normalized_code else null end) as procedure_date_5\r\n , max(case when lower(column_name) = 'procedure_date_6' then normalized_code else null end) as procedure_date_6\r\n , max(case when lower(column_name) = 'procedure_date_7' then normalized_code else null end) as procedure_date_7\r\n , max(case when lower(column_name) = 'procedure_date_8' then normalized_code else null end) as procedure_date_8\r\n , max(case when lower(column_name) = 'procedure_date_9' then normalized_code else null end) as procedure_date_9\r\n , max(case when lower(column_name) = 'procedure_date_10' then normalized_code else null end) as procedure_date_10\r\n , max(case when lower(column_name) = 'procedure_date_11' then normalized_code else null end) as procedure_date_11\r\n , max(case when lower(column_name) = 'procedure_date_12' then normalized_code else null end) as procedure_date_12\r\n , max(case when lower(column_name) = 'procedure_date_13' then normalized_code else null end) as procedure_date_13\r\n , max(case when lower(column_name) = 'procedure_date_14' then normalized_code else null end) as procedure_date_14\r\n , max(case when lower(column_name) = 'procedure_date_15' then normalized_code else null end) as procedure_date_15\r\n , max(case when lower(column_name) = 'procedure_date_16' then normalized_code else null end) as procedure_date_16\r\n , max(case when lower(column_name) = 'procedure_date_17' then normalized_code else null end) as procedure_date_17\r\n , max(case when lower(column_name) = 'procedure_date_18' then normalized_code else null end) as procedure_date_18\r\n , max(case when lower(column_name) = 'procedure_date_19' then normalized_code else null end) as procedure_date_19\r\n , max(case when lower(column_name) = 'procedure_date_20' then normalized_code else null end) as procedure_date_20\r\n , max(case when lower(column_name) = 'procedure_date_21' then normalized_code else null end) as procedure_date_21\r\n , max(case when lower(column_name) = 'procedure_date_22' then normalized_code else null end) as procedure_date_22\r\n , max(case when lower(column_name) = 'procedure_date_23' then normalized_code else null end) as procedure_date_23\r\n , max(case when lower(column_name) = 'procedure_date_24' then normalized_code else null end) as procedure_date_24\r\n , max(case when lower(column_name) = 'procedure_date_25' then normalized_code else null end) as procedure_date_25\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_date_voting') }}\r\nwhere (occurrence_row_count = 1\r\n and occurrence_count > next_occurrence_count)\r\ngroup by\r\n claim_id\r\n , data_source", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_date_voting", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_date_voting"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_final.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_date_1' then normalized_code else null end) as procedure_date_1\n , max(case when lower(column_name) = 'procedure_date_2' then normalized_code else null end) as procedure_date_2\n , max(case when lower(column_name) = 'procedure_date_3' then normalized_code else null end) as procedure_date_3\n , max(case when lower(column_name) = 'procedure_date_4' then normalized_code else null end) as procedure_date_4\n , max(case when lower(column_name) = 'procedure_date_5' then normalized_code else null end) as procedure_date_5\n , max(case when lower(column_name) = 'procedure_date_6' then normalized_code else null end) as procedure_date_6\n , max(case when lower(column_name) = 'procedure_date_7' then normalized_code else null end) as procedure_date_7\n , max(case when lower(column_name) = 'procedure_date_8' then normalized_code else null end) as procedure_date_8\n , max(case when lower(column_name) = 'procedure_date_9' then normalized_code else null end) as procedure_date_9\n , max(case when lower(column_name) = 'procedure_date_10' then normalized_code else null end) as procedure_date_10\n , max(case when lower(column_name) = 'procedure_date_11' then normalized_code else null end) as procedure_date_11\n , max(case when lower(column_name) = 'procedure_date_12' then normalized_code else null end) as procedure_date_12\n , max(case when lower(column_name) = 'procedure_date_13' then normalized_code else null end) as procedure_date_13\n , max(case when lower(column_name) = 'procedure_date_14' then normalized_code else null end) as procedure_date_14\n , max(case when lower(column_name) = 'procedure_date_15' then normalized_code else null end) as procedure_date_15\n , max(case when lower(column_name) = 'procedure_date_16' then normalized_code else null end) as procedure_date_16\n , max(case when lower(column_name) = 'procedure_date_17' then normalized_code else null end) as procedure_date_17\n , max(case when lower(column_name) = 'procedure_date_18' then normalized_code else null end) as procedure_date_18\n , max(case when lower(column_name) = 'procedure_date_19' then normalized_code else null end) as procedure_date_19\n , max(case when lower(column_name) = 'procedure_date_20' then normalized_code else null end) as procedure_date_20\n , max(case when lower(column_name) = 'procedure_date_21' then normalized_code else null end) as procedure_date_21\n , max(case when lower(column_name) = 'procedure_date_22' then normalized_code else null end) as procedure_date_22\n , max(case when lower(column_name) = 'procedure_date_23' then normalized_code else null end) as procedure_date_23\n , max(case when lower(column_name) = 'procedure_date_24' then normalized_code else null end) as procedure_date_24\n , max(case when lower(column_name) = 'procedure_date_25' then normalized_code else null end) as procedure_date_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_date_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_date_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_date_normalize"], "alias": "_int_normalized_input_procedure_date_normalize", "checksum": {"name": "sha256", "checksum": "c6a645f7fba04cce668cca61596dc6bbdeda15eeb19bdc0034b6f1bf259ccf0a"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_date_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_date_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.294076, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith pivot_procedure as(\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_1' as procedure_column\r\n , procedure_date_1 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_2' as procedure_column\r\n , procedure_date_2 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_3' as procedure_column\r\n , procedure_date_3 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_4' as procedure_column\r\n , procedure_date_4 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_5' as procedure_column\r\n , procedure_date_5 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_6' as procedure_column\r\n , procedure_date_6 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_7' as procedure_column\r\n , procedure_date_7 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_8' as procedure_column\r\n , procedure_date_8 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_9' as procedure_column\r\n , procedure_date_9 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_10' as procedure_column\r\n , procedure_date_10 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_11' as procedure_column\r\n , procedure_date_11 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_12' as procedure_column\r\n , procedure_date_12 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_13' as procedure_column\r\n , procedure_date_13 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_14' as procedure_column\r\n , procedure_date_14 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_15' as procedure_column\r\n , procedure_date_15 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_16' as procedure_column\r\n , procedure_date_16 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_17' as procedure_column\r\n , procedure_date_17 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_18' as procedure_column\r\n , procedure_date_18 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_19' as procedure_column\r\n , procedure_date_19 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_20' as procedure_column\r\n , procedure_date_20 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_21' as procedure_column\r\n , procedure_date_21 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_22' as procedure_column\r\n , procedure_date_22 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_23' as procedure_column\r\n , procedure_date_23 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_24' as procedure_column\r\n , procedure_date_24 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n\r\n union all\r\n\r\n select\r\n claim_id\r\n , claim_type\r\n , data_source\r\n , 'procedure_date_25' as procedure_column\r\n , procedure_date_25 as procedure_date\r\n from {{ ref('normalized_input__stg_medical_claim') }}\r\n)\r\n\r\nselect\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n , cal.full_date as procedure_date\r\n , count(*) as procedure_date_occurrence_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom pivot_procedure piv\r\nleft join {{ ref('reference_data__calendar') }} cal\r\n on piv.procedure_date = cal.full_date\r\nwhere claim_type = 'institutional'\r\ngroup by \r\n claim_id\r\n , data_source\r\n , procedure_column\r\n , cal.full_date", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_1' as procedure_column\n , procedure_date_1 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_2' as procedure_column\n , procedure_date_2 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_3' as procedure_column\n , procedure_date_3 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_4' as procedure_column\n , procedure_date_4 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_5' as procedure_column\n , procedure_date_5 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_6' as procedure_column\n , procedure_date_6 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_7' as procedure_column\n , procedure_date_7 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_8' as procedure_column\n , procedure_date_8 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_9' as procedure_column\n , procedure_date_9 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_10' as procedure_column\n , procedure_date_10 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_11' as procedure_column\n , procedure_date_11 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_12' as procedure_column\n , procedure_date_12 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_13' as procedure_column\n , procedure_date_13 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_14' as procedure_column\n , procedure_date_14 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_15' as procedure_column\n , procedure_date_15 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_16' as procedure_column\n , procedure_date_16 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_17' as procedure_column\n , procedure_date_17 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_18' as procedure_column\n , procedure_date_18 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_19' as procedure_column\n , procedure_date_19 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_20' as procedure_column\n , procedure_date_20 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_21' as procedure_column\n , procedure_date_21 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_22' as procedure_column\n , procedure_date_22 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_23' as procedure_column\n , procedure_date_23 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_24' as procedure_column\n , procedure_date_24 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_25' as procedure_column\n , procedure_date_25 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_column\n , cal.full_date as procedure_date\n , count(*) as procedure_date_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join dev_thuxuan.reference_data.calendar cal\n on piv.procedure_date = cal.full_date\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_column\n , cal.full_date", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_procedure_date_voting": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_procedure_date_voting", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_voting.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_voting.sql", "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_voting", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_procedure_date_voting"], "alias": "_int_normalized_input_procedure_date_voting", "checksum": {"name": "sha256", "checksum": "fad7970b88cdd165e60d1c66fd8ef6f5645a57d543ac6965cae6ca4ec06f2bbf"}, "config": {"enabled": true, "alias": "_int_normalized_input_procedure_date_voting", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_procedure_date_voting", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.296182, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_voting", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith distinct_count as(\r\n select\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n , count(*) as distinct_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('normalized_input__int_procedure_date_normalize') }}\r\n group by\r\n claim_id\r\n , data_source\r\n , procedure_column\r\n)\r\n\r\nselect \r\n norm.claim_id\r\n , norm.data_source\r\n , norm.procedure_column as column_name\r\n , norm.procedure_date as normalized_code\r\n , norm.procedure_date_occurrence_count as occurrence_count\r\n , coalesce(lead(procedure_date_occurrence_count) \r\n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc),0) as next_occurrence_count\r\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc) as occurrence_row_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__int_procedure_date_normalize') }} norm\r\ninner join distinct_count dist\r\n on norm.claim_id = dist.claim_id\r\n and norm.data_source = dist.data_source\r\n and norm.procedure_column = dist.procedure_column", "language": "sql", "refs": [{"name": "normalized_input__int_procedure_date_normalize", "package": null, "version": null}, {"name": "normalized_input__int_procedure_date_normalize", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__int_procedure_date_normalize"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_procedure_date_voting.sql", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.procedure_date as normalized_code\n , norm.procedure_date_occurrence_count as occurrence_count\n , coalesce(lead(procedure_date_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_revenue_center_normalize": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_revenue_center_normalize", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_revenue_center_normalize.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_revenue_center_normalize.sql", "unique_id": "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_revenue_center_normalize"], "alias": "_int_normalized_input_revenue_center_normalize", "checksum": {"name": "sha256", "checksum": "89aa9bc4a1ff2cebc21b6cd95d80497901015bf52c7772e63bfa4579fb505a6c"}, "config": {"enabled": true, "alias": "_int_normalized_input_revenue_center_normalize", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_revenue_center_normalize", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.29819, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_revenue_center_normalize", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , data_source\r\n , rev.revenue_center_code as normalized_code\r\n , rev.revenue_center_description as normalized_description\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\r\nleft join {{ ref('terminology__revenue_center') }} rev\r\n {% if target.type == 'fabric' %}\r\n on RIGHT(REPLICATE('0', 4) + med.revenue_center_code, 4) = rev.revenue_center_code\r\n {% else %}\r\n on lpad(med.revenue_center_code, 4, '0') = rev.revenue_center_code\r\n {% endif %}\r\nwhere claim_type = 'institutional'", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__revenue_center"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_revenue_center_normalize.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , rev.revenue_center_code as normalized_code\n , rev.revenue_center_description as normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.revenue_center rev\n \n on lpad(med.revenue_center_code, 4, '0') = rev.revenue_center_code\n \nwhere claim_type = 'institutional'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__int_undetermined_claim_type": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "normalized_input__int_undetermined_claim_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_undetermined_claim_type.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_undetermined_claim_type.sql", "unique_id": "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "intermediate", "normalized_input__int_undetermined_claim_type"], "alias": "_int_normalized_input_undetermined_claim_type", "checksum": {"name": "sha256", "checksum": "66a8b592419ce318e88566e984d3c512424d949a16eb5ff41471dbeb0e54470a"}, "config": {"enabled": true, "alias": "_int_normalized_input_undetermined_claim_type", "schema": "claims_preprocessing", "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_normalized_input_undetermined_claim_type", "materialized": "table", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3001902, "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_undetermined_claim_type", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , claim_type\r\n , patient_id\r\n , member_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , claim_start_date\r\n , claim_end_date\r\n , claim_line_start_date\r\n , claim_line_end_date\r\n , admission_date\r\n , discharge_date\r\n , ad_src.admit_source_code\r\n , ad_src.admit_source_description\r\n , ad_type.admit_type_code\r\n , ad_type.admit_type_description\r\n , dis.discharge_disposition_code\r\n , dis.discharge_disposition_description\r\n , pos.place_of_service_code\r\n , pos.place_of_service_description\r\n , tob.bill_type_code\r\n , tob.bill_type_description\r\n , msdrg.ms_drg_code\r\n , msdrg.ms_drg_description\r\n , aprdrg.apr_drg_code\r\n , aprdrg.apr_drg_description\r\n , rev.revenue_center_code\r\n , rev.revenue_center_description\r\n , service_unit_quantity\r\n , hcpcs_code\r\n , hcpcs_modifier_1\r\n , hcpcs_modifier_2\r\n , hcpcs_modifier_3\r\n , hcpcs_modifier_4\r\n , hcpcs_modifier_5\r\n , rendering_npi\r\n , rendnpi.npi as rendering_name\r\n , billing_npi\r\n , billnpi.npi as billing_name\r\n , facility_npi\r\n , facnpi.npi as facility_name\r\n , paid_date\r\n , paid_amount\r\n , allowed_amount\r\n , charge_amount\r\n , coinsurance_amount\r\n , copayment_amount\r\n , deductible_amount\r\n , total_cost_amount\r\n , diagnosis_code_type\r\n , diagnosis_code_1\r\n , diagnosis_code_2\r\n , diagnosis_code_3\r\n , diagnosis_code_4\r\n , diagnosis_code_5\r\n , diagnosis_code_6\r\n , diagnosis_code_7\r\n , diagnosis_code_8\r\n , diagnosis_code_9\r\n , diagnosis_code_10\r\n , diagnosis_code_11\r\n , diagnosis_code_12\r\n , diagnosis_code_13\r\n , diagnosis_code_14\r\n , diagnosis_code_15\r\n , diagnosis_code_16\r\n , diagnosis_code_17\r\n , diagnosis_code_18\r\n , diagnosis_code_19\r\n , diagnosis_code_20\r\n , diagnosis_code_21\r\n , diagnosis_code_22\r\n , diagnosis_code_23\r\n , diagnosis_code_24\r\n , diagnosis_code_25\r\n , diagnosis_poa_1\r\n , diagnosis_poa_2\r\n , diagnosis_poa_3\r\n , diagnosis_poa_4\r\n , diagnosis_poa_5\r\n , diagnosis_poa_6\r\n , diagnosis_poa_7\r\n , diagnosis_poa_8\r\n , diagnosis_poa_9\r\n , diagnosis_poa_10\r\n , diagnosis_poa_11\r\n , diagnosis_poa_12\r\n , diagnosis_poa_13\r\n , diagnosis_poa_14\r\n , diagnosis_poa_15\r\n , diagnosis_poa_16\r\n , diagnosis_poa_17\r\n , diagnosis_poa_18\r\n , diagnosis_poa_19\r\n , diagnosis_poa_20\r\n , diagnosis_poa_21\r\n , diagnosis_poa_22\r\n , diagnosis_poa_23\r\n , diagnosis_poa_24\r\n , diagnosis_poa_25\r\n , procedure_code_type\r\n , procedure_code_1\r\n , procedure_code_2\r\n , procedure_code_3\r\n , procedure_code_4\r\n , procedure_code_5\r\n , procedure_code_6\r\n , procedure_code_7\r\n , procedure_code_8\r\n , procedure_code_9\r\n , procedure_code_10\r\n , procedure_code_11\r\n , procedure_code_12\r\n , procedure_code_13\r\n , procedure_code_14\r\n , procedure_code_15\r\n , procedure_code_16\r\n , procedure_code_17\r\n , procedure_code_18\r\n , procedure_code_19\r\n , procedure_code_20\r\n , procedure_code_21\r\n , procedure_code_22\r\n , procedure_code_23\r\n , procedure_code_24\r\n , procedure_code_25\r\n , procedure_date_1\r\n , procedure_date_2\r\n , procedure_date_3\r\n , procedure_date_4\r\n , procedure_date_5\r\n , procedure_date_6\r\n , procedure_date_7\r\n , procedure_date_8\r\n , procedure_date_9\r\n , procedure_date_10\r\n , procedure_date_11\r\n , procedure_date_12\r\n , procedure_date_13\r\n , procedure_date_14\r\n , procedure_date_15\r\n , procedure_date_16\r\n , procedure_date_17\r\n , procedure_date_18\r\n , procedure_date_19\r\n , procedure_date_20\r\n , procedure_date_21\r\n , procedure_date_22\r\n , procedure_date_23\r\n , procedure_date_24\r\n , procedure_date_25\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__stg_medical_claim') }} med\r\nleft join {{ ref('terminology__admit_source')}} ad_src\r\n on med.admit_source_code = ad_src.admit_source_code\r\nleft join {{ ref('terminology__admit_type')}} ad_type\r\n on med.admit_type_code = ad_type.admit_type_code\r\nleft join {{ ref('terminology__discharge_disposition')}} dis\r\n on med.discharge_disposition_code = dis.discharge_disposition_code\r\nleft join {{ ref('terminology__place_of_service')}} pos\r\n on med.place_of_service_code = pos.place_of_service_code\r\nleft join {{ ref('terminology__bill_type')}} tob\r\n on med.bill_type_code = tob.bill_type_code\r\nleft join {{ ref('terminology__ms_drg')}} msdrg\r\n on med.ms_drg_code = msdrg.ms_drg_code\r\nleft join {{ ref('terminology__apr_drg')}} aprdrg\r\n on med.apr_drg_code = aprdrg.apr_drg_code\r\nleft join {{ ref('terminology__revenue_center')}} rev\r\n on med.revenue_center_code = rev.revenue_center_code\r\nleft join {{ ref('terminology__provider')}} rendnpi\r\n on med.rendering_npi = rendnpi.npi\r\nleft join {{ ref('terminology__provider')}} billnpi\r\n on med.billing_npi = billnpi.npi\r\nleft join {{ ref('terminology__provider')}} facnpi\r\n on med.facility_npi = facnpi.npi\r\nwhere claim_type in ('undetermined')", "language": "sql", "refs": [{"name": "normalized_input__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__revenue_center", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\intermediate\\normalized_input__int_undetermined_claim_type.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , ad_src.admit_source_code\n , ad_src.admit_source_description\n , ad_type.admit_type_code\n , ad_type.admit_type_description\n , dis.discharge_disposition_code\n , dis.discharge_disposition_description\n , pos.place_of_service_code\n , pos.place_of_service_description\n , tob.bill_type_code\n , tob.bill_type_description\n , msdrg.ms_drg_code\n , msdrg.ms_drg_description\n , aprdrg.apr_drg_code\n , aprdrg.apr_drg_description\n , rev.revenue_center_code\n , rev.revenue_center_description\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendnpi.npi as rendering_name\n , billing_npi\n , billnpi.npi as billing_name\n , facility_npi\n , facnpi.npi as facility_name\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.admit_source ad_src\n on med.admit_source_code = ad_src.admit_source_code\nleft join dev_thuxuan.terminology.admit_type ad_type\n on med.admit_type_code = ad_type.admit_type_code\nleft join dev_thuxuan.terminology.discharge_disposition dis\n on med.discharge_disposition_code = dis.discharge_disposition_code\nleft join dev_thuxuan.terminology.place_of_service pos\n on med.place_of_service_code = pos.place_of_service_code\nleft join dev_thuxuan.terminology.bill_type tob\n on med.bill_type_code = tob.bill_type_code\nleft join dev_thuxuan.terminology.ms_drg msdrg\n on med.ms_drg_code = msdrg.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg aprdrg\n on med.apr_drg_code = aprdrg.apr_drg_code\nleft join dev_thuxuan.terminology.revenue_center rev\n on med.revenue_center_code = rev.revenue_center_code\nleft join dev_thuxuan.terminology.provider rendnpi\n on med.rendering_npi = rendnpi.npi\nleft join dev_thuxuan.terminology.provider billnpi\n on med.billing_npi = billnpi.npi\nleft join dev_thuxuan.terminology.provider facnpi\n on med.facility_npi = facnpi.npi\nwhere claim_type in ('undetermined')", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.normalized_input__stg_medical_claim", "sql": " __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__stg_eligibility": {"database": "dev_thuxuan", "schema": "test", "name": "normalized_input__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_eligibility.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_eligibility.sql", "unique_id": "model.the_tuva_project.normalized_input__stg_eligibility", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "staging", "normalized_input__stg_eligibility"], "alias": "normalized_input__stg_eligibility", "checksum": {"name": "sha256", "checksum": "3978e078a202f4c0dc5c8a8e44d5181e01cd1cc599030908679c009a1676a667"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"materialized": "ephemeral", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3021905, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n patient_id\r\n , {{ dbt.concat([\r\n \"patient_id\",\r\n \"coalesce(data_source,'')\",\r\n \"coalesce(payer,'')\",\r\n \"coalesce(\" ~ quote_column('plan') ~ \",'')\",\r\n \"coalesce(cast(enrollment_start_date as \" ~ dbt.type_string() ~ \"),'')\",\r\n \"coalesce(cast(enrollment_end_date as \" ~ dbt.type_string() ~ \"),'')\"\r\n ]) }} as patient_id_key\r\n , member_id\r\n , subscriber_id\r\n , gender\r\n , race\r\n , birth_date\r\n , death_date\r\n , death_flag\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , payer\r\n , payer_type\r\n , {{ quote_column('plan') }}\r\n , subscriber_relation\r\n , original_reason_entitlement_code\r\n , dual_status_code\r\n , medicare_status_code\r\n , first_name\r\n , last_name\r\n , social_security_number\r\n , address\r\n , city\r\n , state\r\n , zip_code\r\n , phone\r\n , data_source\r\n , file_name\r\n , ingest_datetime\r\nfrom {{ ref('eligibility') }}", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__stg_medical_claim": {"database": "dev_thuxuan", "schema": "test", "name": "normalized_input__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_medical_claim.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__stg_medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "staging", "normalized_input__stg_medical_claim"], "alias": "normalized_input__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "69b52139f309a813b3d0658a65a57bda92cf1be0dbb5cdbb33465b2af19626a6"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"materialized": "ephemeral", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3031905, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , claim_type\r\n , patient_id\r\n , member_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , claim_start_date\r\n , claim_end_date\r\n , claim_line_start_date\r\n , claim_line_end_date\r\n , admission_date\r\n , discharge_date\r\n , admit_source_code\r\n , admit_type_code\r\n , discharge_disposition_code\r\n , place_of_service_code\r\n , bill_type_code\r\n , ms_drg_code\r\n , apr_drg_code\r\n , revenue_center_code\r\n , service_unit_quantity\r\n , hcpcs_code\r\n , hcpcs_modifier_1\r\n , hcpcs_modifier_2\r\n , hcpcs_modifier_3\r\n , hcpcs_modifier_4\r\n , hcpcs_modifier_5\r\n , rendering_npi\r\n , rendering_tin\r\n , billing_npi\r\n , billing_tin\r\n , facility_npi\r\n , paid_date\r\n , paid_amount\r\n , allowed_amount\r\n , charge_amount\r\n , coinsurance_amount\r\n , copayment_amount\r\n , deductible_amount\r\n , total_cost_amount\r\n , diagnosis_code_type\r\n , diagnosis_code_1\r\n , diagnosis_code_2\r\n , diagnosis_code_3\r\n , diagnosis_code_4\r\n , diagnosis_code_5\r\n , diagnosis_code_6\r\n , diagnosis_code_7\r\n , diagnosis_code_8\r\n , diagnosis_code_9\r\n , diagnosis_code_10\r\n , diagnosis_code_11\r\n , diagnosis_code_12\r\n , diagnosis_code_13\r\n , diagnosis_code_14\r\n , diagnosis_code_15\r\n , diagnosis_code_16\r\n , diagnosis_code_17\r\n , diagnosis_code_18\r\n , diagnosis_code_19\r\n , diagnosis_code_20\r\n , diagnosis_code_21\r\n , diagnosis_code_22\r\n , diagnosis_code_23\r\n , diagnosis_code_24\r\n , diagnosis_code_25\r\n , diagnosis_poa_1\r\n , diagnosis_poa_2\r\n , diagnosis_poa_3\r\n , diagnosis_poa_4\r\n , diagnosis_poa_5\r\n , diagnosis_poa_6\r\n , diagnosis_poa_7\r\n , diagnosis_poa_8\r\n , diagnosis_poa_9\r\n , diagnosis_poa_10\r\n , diagnosis_poa_11\r\n , diagnosis_poa_12\r\n , diagnosis_poa_13\r\n , diagnosis_poa_14\r\n , diagnosis_poa_15\r\n , diagnosis_poa_16\r\n , diagnosis_poa_17\r\n , diagnosis_poa_18\r\n , diagnosis_poa_19\r\n , diagnosis_poa_20\r\n , diagnosis_poa_21\r\n , diagnosis_poa_22\r\n , diagnosis_poa_23\r\n , diagnosis_poa_24\r\n , diagnosis_poa_25\r\n , procedure_code_type\r\n , procedure_code_1\r\n , procedure_code_2\r\n , procedure_code_3\r\n , procedure_code_4\r\n , procedure_code_5\r\n , procedure_code_6\r\n , procedure_code_7\r\n , procedure_code_8\r\n , procedure_code_9\r\n , procedure_code_10\r\n , procedure_code_11\r\n , procedure_code_12\r\n , procedure_code_13\r\n , procedure_code_14\r\n , procedure_code_15\r\n , procedure_code_16\r\n , procedure_code_17\r\n , procedure_code_18\r\n , procedure_code_19\r\n , procedure_code_20\r\n , procedure_code_21\r\n , procedure_code_22\r\n , procedure_code_23\r\n , procedure_code_24\r\n , procedure_code_25\r\n , procedure_date_1\r\n , procedure_date_2\r\n , procedure_date_3\r\n , procedure_date_4\r\n , procedure_date_5\r\n , procedure_date_6\r\n , procedure_date_7\r\n , procedure_date_8\r\n , procedure_date_9\r\n , procedure_date_10\r\n , procedure_date_11\r\n , procedure_date_12\r\n , procedure_date_13\r\n , procedure_date_14\r\n , procedure_date_15\r\n , procedure_date_16\r\n , procedure_date_17\r\n , procedure_date_18\r\n , procedure_date_19\r\n , procedure_date_20\r\n , procedure_date_21\r\n , procedure_date_22\r\n , procedure_date_23\r\n , procedure_date_24\r\n , procedure_date_25\r\n , in_network_flag\r\n , data_source\r\nfrom {{ ref('medical_claim') }}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.normalized_input__stg_pharmacy_claim": {"database": "dev_thuxuan", "schema": "test", "name": "normalized_input__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_pharmacy_claim.sql", "original_file_path": "models\\claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.normalized_input__stg_pharmacy_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "normalized_input", "staging", "normalized_input__stg_pharmacy_claim"], "alias": "normalized_input__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "a8de787a92afd072ed7bbfe1e847d268feefc1c77a7ce8963d4bc03c872d76b8"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["normalized_input", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized_input", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\claims_preprocessing_models.yml", "build_path": null, "unrendered_config": {"materialized": "ephemeral", "tags": ["normalized_input", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.3031905, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , member_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , prescribing_provider_npi\r\n , dispensing_provider_npi\r\n , dispensing_date\r\n , ndc_code\r\n , quantity\r\n , days_supply\r\n , refills\r\n , paid_date\r\n , paid_amount\r\n , allowed_amount\r\n , charge_amount\r\n , coinsurance_amount\r\n , copayment_amount\r\n , deductible_amount\r\n , in_network_flag\r\n , data_source\r\n , file_name\r\n , ingest_datetime\r\nfrom {{ ref('pharmacy_claim') }}", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\normalized_input\\staging\\normalized_input__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__service_category_grouper": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__service_category_grouper", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\final\\service_category__service_category_grouper.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\final\\service_category__service_category_grouper.sql", "unique_id": "model.the_tuva_project.service_category__service_category_grouper", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "final", "service_category__service_category_grouper"], "alias": "service_category_grouper", "checksum": {"name": "sha256", "checksum": "3f4abcc65cac0cef1bb782c2587d8ccb274f14b932293b37109c49362fd730ed"}, "config": {"enabled": true, "alias": "service_category_grouper", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "Assigns every claim line into a unique service category.", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicated the type of claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_1": {"name": "service_category_1", "description": "The first service category of the claim line", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_2": {"name": "service_category_2", "description": "The second, more specific service category of the claim line", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_3": {"name": "service_category_3", "description": "The third, even more specific service category of the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_service_cat_2": {"name": "original_service_cat_2", "description": "Original categorization of service category 2 before any transformation or normalization.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_service_cat_3": {"name": "original_service_cat_3", "description": "Original categorization of service category 3 before any transformation or normalization.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_id": {"name": "claim_line_id", "description": "Concatenated field of claim_id and claim_line_number, providing a unique identifier for each line within a claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "duplicate_row_number": {"name": "duplicate_row_number", "description": "Row number used to identify duplicate entries within the data set.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_category": {"name": "ccs_category", "description": "Clinical Classifications Software category associated with the service provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_category_description": {"name": "ccs_category_description", "description": "Description of the Clinical Classifications Software category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "Medicare Severity Diagnosis Related Group code related to the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the Medicare Severity Diagnosis Related Group code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Code that identifies the place where service was provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_description": {"name": "place_of_service_description", "description": "Description of the place where service was provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code associated with the financial aspects of the care provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_description": {"name": "revenue_center_description", "description": "Description of the revenue center code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "Healthcare Common Procedure Coding System code that identifies specific services provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_ip": {"name": "default_ccsr_category_ip", "description": "Default Clinical Classifications Software for Services and Procedures category for inpatient services.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_op": {"name": "default_ccsr_category_op", "description": "Default Clinical Classifications Software for Services and Procedures category for outpatient services.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_ip": {"name": "default_ccsr_category_description_ip", "description": "Description of the default CCS for Services and Procedures category for inpatient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_op": {"name": "default_ccsr_category_description_op", "description": "Description of the default CCS for Services and Procedures category for outpatient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_taxonomy_code": {"name": "primary_taxonomy_code", "description": "Taxonomy code that classifies the providers type or specialization.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_specialty_description": {"name": "primary_specialty_description", "description": "Description of the providers primary specialty.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modality": {"name": "modality", "description": "The type of modality used in the service provided.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Code that identifies the type of bill submitted for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_description": {"name": "bill_type_description", "description": "Description of the bill type code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_model_name": {"name": "source_model_name", "description": "Name of the source model from which this data was derived.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "The original source of the data used in this model.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category_grouper", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6201444, "relation_name": "dev_thuxuan.claims_preprocessing.service_category_grouper", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_category_1_mapping as(\r\n select distinct \r\n a.claim_id\r\n , a.claim_line_number\r\n , a.claim_type\r\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\r\n else b.service_category_1\r\n end service_category_1\r\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\r\n else s.service_category_2\r\n end service_category_2\r\n , case\r\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\r\n else s.service_category_3\r\n end service_category_3\r\n ,b.service_category_2 as original_service_cat_2\r\n ,b.service_category_3 as original_service_cat_3\r\n , s.priority\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n , b.source_model_name\r\n from {{ ref('service_category__stg_medical_claim') }} a\r\n left join {{ ref('service_category__combined_professional') }} b\r\n on a.claim_id = b.claim_id\r\n and a.claim_line_number = b.claim_line_number\r\n left join {{ ref('service_category__service_categories') }} s on b.service_category_2 = s.service_category_2\r\n and\r\n b.service_category_3 = s.service_category_3\r\n where a.claim_type = 'professional'\r\n\r\n union all\r\n\r\n select distinct \r\n a.claim_id\r\n , a.claim_line_number\r\n , a.claim_type\r\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\r\n else b.service_category_1\r\n end service_category_1\r\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\r\n else s.service_category_2\r\n end service_category_2\r\n , case\r\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\r\n else s.service_category_3\r\n end service_category_3\r\n ,b.service_category_2 as original_service_cat_2\r\n ,b.service_category_3 as original_service_cat_3\r\n , s.priority\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n , b.source_model_name\r\n from {{ ref('service_category__stg_medical_claim') }} a\r\n left join {{ ref('service_category__combined_institutional_header_level') }} b\r\n on a.claim_id = b.claim_id\r\n left join {{ ref('service_category__service_categories') }} s on b.service_category_2 = s.service_category_2\r\n and\r\n b.service_category_3 = s.service_category_3\r\n where a.claim_type = 'institutional'\r\n\r\n union all\r\n\r\n select distinct \r\n a.claim_id\r\n , a.claim_line_number\r\n , a.claim_type\r\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\r\n else b.service_category_1\r\n end service_category_1\r\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\r\n else s.service_category_2\r\n end service_category_2\r\n , case\r\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\r\n else s.service_category_3\r\n end service_category_3\r\n ,b.service_category_2 as original_service_cat_2\r\n ,b.service_category_3 as original_service_cat_3\r\n , s.priority\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n , b.source_model_name\r\n from {{ ref('service_category__stg_medical_claim') }} a\r\n left join {{ ref('service_category__combined_institutional_line_level') }} b\r\n on a.claim_id = b.claim_id\r\n and a.claim_line_number = b.claim_line_number\r\n left join {{ ref('service_category__service_categories') }} s on b.service_category_2 = s.service_category_2\r\n and\r\n b.service_category_3 = s.service_category_3\r\n where a.claim_type = 'institutional'\r\n)\r\n\r\n, service_category_2_deduplication as(\r\n select \r\n claim_id\r\n , claim_line_number\r\n , claim_type\r\n , service_category_1\r\n , service_category_2\r\n , service_category_3\r\n ,original_service_cat_2\r\n ,original_service_cat_3\r\n , source_model_name\r\n , row_number() over (partition by claim_id, claim_line_number order by priority) as duplicate_row_number\r\n from service_category_1_mapping\r\n)\r\n\r\nselect\r\n d.claim_id\r\n , d.claim_line_number\r\n , d.claim_type\r\n , coalesce(service_category_1,'other') as service_category_1\r\n , coalesce(service_category_2,'other') as service_category_2\r\n , coalesce(service_category_3,'other') as service_category_3\r\n , original_service_cat_2\r\n , original_service_cat_3\r\n , duplicate_row_number\r\n , s.ccs_category\r\n , s.ccs_category_description\r\n , s.ms_drg_code\r\n , s.ms_drg_description\r\n , s.place_of_service_code\r\n , s.place_of_service_description\r\n , s.revenue_center_code\r\n , s.revenue_center_description\r\n , s.hcpcs_code\r\n , s.default_ccsr_category_ip\r\n , s.default_ccsr_category_op\r\n , s.default_ccsr_category_description_ip\r\n , s.default_ccsr_category_description_op\r\n , s.primary_taxonomy_code\r\n , s.primary_specialty_description\r\n , s.modality\r\n , s.bill_type_code\r\n , s.bill_type_description\r\n , d.source_model_name\r\n , s.data_source\r\nfrom service_category_2_deduplication d\r\ninner join {{ ref('service_category__stg_medical_claim') }} s on d.claim_id = s.claim_id\r\nand\r\nd.claim_line_number = s.claim_line_number\r\n--where duplicate_row_number = 1", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_professional", "package": null, "version": null}, {"name": "service_category__service_categories", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_institutional_header_level", "package": null, "version": null}, {"name": "service_category__service_categories", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__combined_institutional_line_level", "package": null, "version": null}, {"name": "service_category__service_categories", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__combined_professional", "seed.the_tuva_project.service_category__service_categories", "model.the_tuva_project.service_category__combined_institutional_header_level", "model.the_tuva_project.service_category__combined_institutional_line_level"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\final\\service_category__service_category_grouper.sql", "compiled": true, "compiled_code": "\n\nwith service_category_1_mapping as(\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , b.source_model_name\n from dev_thuxuan.test.service_category__stg_medical_claim a\n left join dev_thuxuan.claims_preprocessing._int_combined_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join dev_thuxuan.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'professional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , b.source_model_name\n from dev_thuxuan.test.service_category__stg_medical_claim a\n left join dev_thuxuan.claims_preprocessing._int_combined_institutional_header_level b\n on a.claim_id = b.claim_id\n left join dev_thuxuan.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , b.source_model_name\n from dev_thuxuan.test.service_category__stg_medical_claim a\n left join dev_thuxuan.claims_preprocessing._int_combined_institutional_line_level b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join dev_thuxuan.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n)\n\n, service_category_2_deduplication as(\n select \n claim_id\n , claim_line_number\n , claim_type\n , service_category_1\n , service_category_2\n , service_category_3\n ,original_service_cat_2\n ,original_service_cat_3\n , source_model_name\n , row_number() over (partition by claim_id, claim_line_number order by priority) as duplicate_row_number\n from service_category_1_mapping\n)\n\nselect\n d.claim_id\n , d.claim_line_number\n , d.claim_type\n , coalesce(service_category_1,'other') as service_category_1\n , coalesce(service_category_2,'other') as service_category_2\n , coalesce(service_category_3,'other') as service_category_3\n , original_service_cat_2\n , original_service_cat_3\n , duplicate_row_number\n , s.ccs_category\n , s.ccs_category_description\n , s.ms_drg_code\n , s.ms_drg_description\n , s.place_of_service_code\n , s.place_of_service_description\n , s.revenue_center_code\n , s.revenue_center_description\n , s.hcpcs_code\n , s.default_ccsr_category_ip\n , s.default_ccsr_category_op\n , s.default_ccsr_category_description_ip\n , s.default_ccsr_category_description_op\n , s.primary_taxonomy_code\n , s.primary_specialty_description\n , s.modality\n , s.bill_type_code\n , s.bill_type_description\n , d.source_model_name\n , s.data_source\nfrom service_category_2_deduplication d\ninner join dev_thuxuan.test.service_category__stg_medical_claim s on d.claim_id = s.claim_id\nand\nd.claim_line_number = s.claim_line_number\n--where duplicate_row_number = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_institutional_maternity", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_maternity.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_maternity.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_institutional_maternity"], "alias": "_int_acute_inpatient_institutional_maternity", "checksum": {"name": "sha256", "checksum": "b8dc0f14856f96ce6301e846b1e07d043c9ff5a930c77e914d5007ac73f70c86"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_institutional_maternity", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_institutional_maternity", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7041469, "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_maternity", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n a.claim_id\r\n , 'inpatient' as service_category_1\r\n , 'acute inpatient' as service_category_2\r\n , case \r\n when s.ms_drg_code in ('768', '796', '797', '798', '805', '806', '807') then 'l/d - vaginal delivery'\r\n when s.ms_drg_code in ('783', '784', '785', '786', '787', '788') then 'l/d - cesarean delivery'\r\n when s.ms_drg_code = '795' then 'l/d - newborn'\r\n when s.ms_drg_code in ('789', '790', '791', '792', '793', '794') then 'l/d - newborn nicu'\r\n when s.revenue_center_code in ('0173', '0174') then 'l/d - newborn nicu'\r\n else 'l/d - other'\r\n end as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} as a\r\n on s.claim_id = a.claim_id\r\ninner join {{ ref('terminology__ms_drg') }} as m\r\n on s.ms_drg_code = m.ms_drg_code\r\nwhere \r\n m.mdc_code in ('MDC 14', 'MDC 15')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_maternity.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when s.ms_drg_code in ('768', '796', '797', '798', '805', '806', '807') then 'l/d - vaginal delivery'\n when s.ms_drg_code in ('783', '784', '785', '786', '787', '788') then 'l/d - cesarean delivery'\n when s.ms_drg_code = '795' then 'l/d - newborn'\n when s.ms_drg_code in ('789', '790', '791', '792', '793', '794') then 'l/d - newborn nicu'\n when s.revenue_center_code in ('0173', '0174') then 'l/d - newborn nicu'\n else 'l/d - other'\n end as service_category_3\n , '_int_acute_inpatient_institutional_maternity' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join dev_thuxuan.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code\nwhere \n m.mdc_code in ('MDC 14', 'MDC 15')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_institutional_med_surg", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_med_surg.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_med_surg.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_institutional_med_surg"], "alias": "_int_acute_inpatient_institutional_med_surg", "checksum": {"name": "sha256", "checksum": "e3675e398603244f423404d40e822b8a3e4693e780ab1c8cc90fec2eb0ba7fd8"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_institutional_med_surg", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_institutional_med_surg", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7011473, "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_med_surg", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n a.claim_id\r\n , 'inpatient' as service_category_1\r\n , 'acute inpatient' as service_category_2\r\n , case \r\n when m.medical_surgical = 'M' then 'medical'\r\n when m.medical_surgical = 'P' then 'surgical'\r\n when m.medical_surgical = 'surgical' then 'surgical'\r\n else 'acute inpatient - other' \r\n end as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} as a\r\n on s.claim_id = a.claim_id\r\ninner join {{ ref('terminology__ms_drg') }} as m\r\n on s.ms_drg_code = m.ms_drg_code", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_med_surg.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when m.medical_surgical = 'M' then 'medical'\n when m.medical_surgical = 'P' then 'surgical'\n when m.medical_surgical = 'surgical' then 'surgical'\n else 'acute inpatient - other' \n end as service_category_3\n , '_int_acute_inpatient_institutional_med_surg' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join dev_thuxuan.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_institutional_other": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_institutional_other", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_other.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_other.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_institutional_other"], "alias": "_int_acute_inpatient_institutional_other", "checksum": {"name": "sha256", "checksum": "852689221c66427a65033127a179e680ea84a0a4c10285be0dbda99a51e51131"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_institutional_other", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_institutional_other", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.705652, "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_other", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\n--simplified by setting lowest priority instead of explicitly doing all the joins\r\nselect distinct \r\n a.claim_id\r\n , 'inpatient' as service_category_1\r\n, 'acute inpatient' as service_category_2\r\n, 'acute inpatient - other' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} a on s.claim_id = a.claim_id", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_institutional_other.sql", "compiled": true, "compiled_code": "\n\n\n--simplified by setting lowest priority instead of explicitly doing all the joins\nselect distinct \n a.claim_id\n , 'inpatient' as service_category_1\n, 'acute inpatient' as service_category_2\n, 'acute inpatient - other' as service_category_3\n, '_int_acute_inpatient_institutional_other' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__acute_inpatient_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__acute_inpatient_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_professional.sql", "unique_id": "model.the_tuva_project.service_category__acute_inpatient_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__acute_inpatient_professional"], "alias": "_int_acute_inpatient_professional", "checksum": {"name": "sha256", "checksum": "a844049e5747a99e3891a756a294cfb358c6f327f8fa4c483c817cdbc7ea25fe"}, "config": {"enabled": true, "alias": "_int_acute_inpatient_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_acute_inpatient_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6301425, "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n claim_id\r\n , claim_line_number\r\n , claim_line_id\r\n , 'inpatient' as service_category_1\r\n , 'acute inpatient' as service_category_2\r\n , case \r\n when hcpcs_code in ('59400', '59409', '59410', '59610', '59612', '59614') then 'l/d - vaginal delivery'\r\n when hcpcs_code in ('59510', '59514', '59515', '59618', '59620', '59622') then 'l/d - cesarean delivery'\r\n else 'acute inpatient - other'\r\n end as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere \r\n claim_type = 'professional'\r\n and place_of_service_code = '21'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__acute_inpatient_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when hcpcs_code in ('59400', '59409', '59410', '59610', '59612', '59614') then 'l/d - vaginal delivery'\n when hcpcs_code in ('59510', '59514', '59515', '59618', '59620', '59622') then 'l/d - cesarean delivery'\n else 'acute inpatient - other'\n end as service_category_3\n , '_int_acute_inpatient_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and place_of_service_code = '21'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulance_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__ambulance_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__ambulance_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulance_institutional.sql", "unique_id": "model.the_tuva_project.service_category__ambulance_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulance_institutional"], "alias": "_int_ambulance_institutional", "checksum": {"name": "sha256", "checksum": "364ef41490a84abf0f8d8c22dd8072d1c59a25e9d035c0a481faf6e7c9aea114"}, "config": {"enabled": true, "alias": "_int_ambulance_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulance_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.636142, "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulance_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'ancillary' as service_category_1\r\n , 'ambulance' as service_category_2\r\n , 'ambulance' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere \r\n (med.hcpcs_code between 'A0425' and 'A0436')\r\n or med.revenue_center_code = '0540'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulance_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n (med.hcpcs_code between 'A0425' and 'A0436')\n or med.revenue_center_code = '0540'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulance_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__ambulance_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__ambulance_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulance_professional.sql", "unique_id": "model.the_tuva_project.service_category__ambulance_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulance_professional"], "alias": "_int_ambulance_professional", "checksum": {"name": "sha256", "checksum": "1bffce60150481e6d57c67b8c1882cacb29db2a2672f52f78960346fefb93f4c"}, "config": {"enabled": true, "alias": "_int_ambulance_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulance_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6331422, "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulance_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n claim_id\r\n , claim_line_number\r\n , claim_line_id\r\n , 'ancillary' as service_category_1\r\n , 'ambulance' as service_category_2\r\n , 'ambulance' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere \r\n claim_type = 'professional'\r\n and (\r\n hcpcs_code between 'A0425' and 'A0436'\r\n or place_of_service_code in ('41', '42')\r\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulance_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and (\n hcpcs_code between 'A0425' and 'A0436'\n or place_of_service_code in ('41', '42')\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulatory_surgery_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__ambulatory_surgery_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__ambulatory_surgery_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulatory_surgery_institutional.sql", "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulatory_surgery_institutional"], "alias": "_int_ambulatory_surgery_institutional", "checksum": {"name": "sha256", "checksum": "146564c3890c512fd866df7dd2ea9f41dc250baca7d4a5c2c1889f9e21b6cf4e"}, "config": {"enabled": true, "alias": "_int_ambulatory_surgery_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulatory_surgery_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.708943, "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\nselect distinct \r\n med.claim_id\r\n , 'ambulatory surgery center' as service_category_2\r\n , 'ambulatory surgery center' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere revenue_center_code in ('0490','0499')\r\n\r\nunion all\r\n\r\nselect distinct \r\n med.claim_id\r\n , 'ambulatory surgery center' as service_category_2\r\n , 'ambulatory surgery center' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere med.primary_taxonomy_code = '261QA1903X'\r\n)\r\n\r\nselect distinct claim_id\r\n, 'outpatient' as service_category_1\r\n,service_category_2\r\n,service_category_3\r\n,source_model_name\r\n,tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulatory_surgery_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0490','0499')\n\nunion all\n\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere med.primary_taxonomy_code = '261QA1903X'\n)\n\nselect distinct claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__ambulatory_surgery_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__ambulatory_surgery_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__ambulatory_surgery_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulatory_surgery_professional.sql", "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__ambulatory_surgery_professional"], "alias": "_int_ambulatory_surgery_professional", "checksum": {"name": "sha256", "checksum": "4845c61a7ed321394ce550cdc113ee1b1ef853784a2f1fd4df517517bb96e1f1"}, "config": {"enabled": true, "alias": "_int_ambulatory_surgery_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_ambulatory_surgery_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6381419, "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'outpatient' as service_category_1\r\n, 'ambulatory surgery center' as service_category_2\r\n, 'ambulatory surgery center' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere med.place_of_service_code in ('24')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__ambulatory_surgery_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n, 'ambulatory surgery center' as service_category_2\n, 'ambulatory surgery center' as service_category_3\n, '_int_ambulatory_surgery_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('24')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__combined_institutional_header_level": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__combined_institutional_header_level", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__combined_institutional_header_level.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__combined_institutional_header_level.sql", "unique_id": "model.the_tuva_project.service_category__combined_institutional_header_level", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__combined_institutional_header_level"], "alias": "_int_combined_institutional_header_level", "checksum": {"name": "sha256", "checksum": "4313db42e88c51c1d56c2cc1b8f38a56d0ee6cce59c8bd7a27a18bf4d3d70ec3"}, "config": {"enabled": true, "alias": "_int_combined_institutional_header_level", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_combined_institutional_header_level", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6241438, "relation_name": "dev_thuxuan.claims_preprocessing._int_combined_institutional_header_level", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nWITH combine_header_models AS (\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('service_category__acute_inpatient_institutional_other'),\r\n ref('service_category__acute_inpatient_institutional_maternity'),\r\n ref('service_category__acute_inpatient_institutional_med_surg'),\r\n ref('service_category__inpatient_substance_use_institutional'),\r\n ref('service_category__ambulatory_surgery_institutional'),\r\n ref('service_category__dialysis_institutional'),\r\n ref('service_category__emergency_department_institutional'),\r\n ref('service_category__home_health_institutional'),\r\n ref('service_category__inpatient_hospice_institutional'),\r\n ref('service_category__outpatient_hospice_institutional'),\r\n ref('service_category__outpatient_hospital_or_clinic_institutional'),\r\n ref('service_category__outpatient_physical_therapy_institutional'),\r\n ref('service_category__outpatient_psychiatric_institutional'),\r\n ref('service_category__inpatient_skilled_nursing_institutional'),\r\n ref('service_category__urgent_care_institutional'),\r\n ref('service_category__inpatient_psychiatric_institutional'),\r\n ref('service_category__inpatient_rehab_institutional'),\r\n ref('service_category__outpatient_rehab_institutional'),\r\n ref('service_category__outpatient_substance_use_institutional'),\r\n ref('service_category__outpatient_surgery_institutional')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n)\r\n\r\nSELECT\r\n h.claim_id,\r\n h.service_category_1,\r\n h.service_category_2,\r\n h.service_category_3,\r\n h.source_model_name\r\nFROM combine_header_models h", "language": "sql", "refs": [{"name": "service_category__acute_inpatient_institutional_other", "package": null, "version": null}, {"name": "service_category__acute_inpatient_institutional_maternity", "package": null, "version": null}, {"name": "service_category__acute_inpatient_institutional_med_surg", "package": null, "version": null}, {"name": "service_category__inpatient_substance_use_institutional", "package": null, "version": null}, {"name": "service_category__ambulatory_surgery_institutional", "package": null, "version": null}, {"name": "service_category__dialysis_institutional", "package": null, "version": null}, {"name": "service_category__emergency_department_institutional", "package": null, "version": null}, {"name": "service_category__home_health_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_hospice_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_hospice_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_hospital_or_clinic_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_physical_therapy_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_psychiatric_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_skilled_nursing_institutional", "package": null, "version": null}, {"name": "service_category__urgent_care_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_psychiatric_institutional", "package": null, "version": null}, {"name": "service_category__inpatient_rehab_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_rehab_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_substance_use_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_surgery_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__home_health_institutional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "model.the_tuva_project.service_category__urgent_care_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_surgery_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__combined_institutional_header_level.sql", "compiled": true, "compiled_code": "\n\nWITH combine_header_models AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_other' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_other\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_maternity' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_maternity\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_med_surg' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_med_surg\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_dialysis_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_dialysis_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_emergency_department_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_emergency_department_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_home_health_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_home_health_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_urgent_care_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_urgent_care_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_institutional\n\n \n )\n\n \n)\n\nSELECT\n h.claim_id,\n h.service_category_1,\n h.service_category_2,\n h.service_category_3,\n h.source_model_name\nFROM combine_header_models h", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__combined_institutional_line_level": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__combined_institutional_line_level", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__combined_institutional_line_level.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__combined_institutional_line_level.sql", "unique_id": "model.the_tuva_project.service_category__combined_institutional_line_level", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__combined_institutional_line_level"], "alias": "_int_combined_institutional_line_level", "checksum": {"name": "sha256", "checksum": "38ab242a86d3de0a89d6c8d89075cf7a8b3c0f5fe3165bd16b563e3a46e000de"}, "config": {"enabled": true, "alias": "_int_combined_institutional_line_level", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_combined_institutional_line_level", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6271436, "relation_name": "dev_thuxuan.claims_preprocessing._int_combined_institutional_line_level", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nWITH combine_line_models AS (\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('service_category__pharmacy_institutional'),\r\n ref('service_category__outpatient_radiology_institutional'),\r\n ref('service_category__observation_institutional'),\r\n ref('service_category__ambulance_institutional'),\r\n ref('service_category__lab_institutional')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n)\r\n\r\nSELECT\r\n l.claim_id,\r\n l.claim_line_number,\r\n l.service_category_1,\r\n l.service_category_2,\r\n l.service_category_3,\r\n l.source_model_name\r\nFROM combine_line_models l", "language": "sql", "refs": [{"name": "service_category__pharmacy_institutional", "package": null, "version": null}, {"name": "service_category__outpatient_radiology_institutional", "package": null, "version": null}, {"name": "service_category__observation_institutional", "package": null, "version": null}, {"name": "service_category__ambulance_institutional", "package": null, "version": null}, {"name": "service_category__lab_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.service_category__pharmacy_institutional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__observation_institutional", "model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__lab_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__combined_institutional_line_level.sql", "compiled": true, "compiled_code": "\n\nWITH combine_line_models AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__pharmacy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing.service_category__pharmacy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_observation_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing._int_observation_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulance_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulance_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_lab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing._int_lab_institutional\n\n \n )\n\n \n)\n\nSELECT\n l.claim_id,\n l.claim_line_number,\n l.service_category_1,\n l.service_category_2,\n l.service_category_3,\n l.source_model_name\nFROM combine_line_models l", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__combined_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__combined_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__combined_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__combined_professional.sql", "unique_id": "model.the_tuva_project.service_category__combined_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__combined_professional"], "alias": "_int_combined_professional", "checksum": {"name": "sha256", "checksum": "a6204f21cc8bb5f447e0568b69e1d47aadf89ba30000c9ff5018fe45dc4690fb"}, "config": {"enabled": true, "alias": "_int_combined_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_combined_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.622144, "relation_name": "dev_thuxuan.claims_preprocessing._int_combined_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nWITH combined_professional_services AS (\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('service_category__acute_inpatient_professional'),\r\n ref('service_category__ambulatory_surgery_professional'),\r\n ref('service_category__dialysis_professional'),\r\n ref('service_category__emergency_department_professional'),\r\n ref('service_category__home_health_professional'),\r\n ref('service_category__inpatient_hospice_professional'),\r\n ref('service_category__inpatient_psychiatric_professional'),\r\n ref('service_category__inpatient_rehab_professional'),\r\n ref('service_category__lab_professional'),\r\n ref('service_category__office_based_other_professional'),\r\n ref('service_category__office_based_physical_therapy_professional'),\r\n ref('service_category__office_based_radiology'),\r\n ref('service_category__office_based_surgery_professional'),\r\n ref('service_category__office_based_visit_professional'),\r\n ref('service_category__outpatient_hospital_or_clinic_professional'),\r\n ref('service_category__outpatient_psychiatric_professional'),\r\n ref('service_category__outpatient_rehab_professional'),\r\n ref('service_category__inpatient_skilled_nursing_professional'),\r\n ref('service_category__urgent_care_professional'),\r\n ref('service_category__outpatient_hospice_professional'),\r\n ref('service_category__pharmacy_professional'),\r\n ref('service_category__outpatient_substance_use_professional'),\r\n ref('service_category__outpatient_physical_therapy_professional'),\r\n ref('service_category__outpatient_radiology_professional'),\r\n ref('service_category__observation_professional'),\r\n ref('service_category__dme_professional'),\r\n ref('service_category__ambulance_professional'),\r\n ref('service_category__outpatient_surgery_professional')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n)\r\n\r\nSELECT\r\n p.claim_id,\r\n p.claim_line_number,\r\n p.claim_line_id,\r\n p.service_category_1,\r\n p.service_category_2,\r\n p.service_category_3,\r\n p.tuva_last_run,\r\n p.source_model_name\r\nFROM combined_professional_services p", "language": "sql", "refs": [{"name": "service_category__acute_inpatient_professional", "package": null, "version": null}, {"name": "service_category__ambulatory_surgery_professional", "package": null, "version": null}, {"name": "service_category__dialysis_professional", "package": null, "version": null}, {"name": "service_category__emergency_department_professional", "package": null, "version": null}, {"name": "service_category__home_health_professional", "package": null, "version": null}, {"name": "service_category__inpatient_hospice_professional", "package": null, "version": null}, {"name": "service_category__inpatient_psychiatric_professional", "package": null, "version": null}, {"name": "service_category__inpatient_rehab_professional", "package": null, "version": null}, {"name": "service_category__lab_professional", "package": null, "version": null}, {"name": "service_category__office_based_other_professional", "package": null, "version": null}, {"name": "service_category__office_based_physical_therapy_professional", "package": null, "version": null}, {"name": "service_category__office_based_radiology", "package": null, "version": null}, {"name": "service_category__office_based_surgery_professional", "package": null, "version": null}, {"name": "service_category__office_based_visit_professional", "package": null, "version": null}, {"name": "service_category__outpatient_hospital_or_clinic_professional", "package": null, "version": null}, {"name": "service_category__outpatient_psychiatric_professional", "package": null, "version": null}, {"name": "service_category__outpatient_rehab_professional", "package": null, "version": null}, {"name": "service_category__inpatient_skilled_nursing_professional", "package": null, "version": null}, {"name": "service_category__urgent_care_professional", "package": null, "version": null}, {"name": "service_category__outpatient_hospice_professional", "package": null, "version": null}, {"name": "service_category__pharmacy_professional", "package": null, "version": null}, {"name": "service_category__outpatient_substance_use_professional", "package": null, "version": null}, {"name": "service_category__outpatient_physical_therapy_professional", "package": null, "version": null}, {"name": "service_category__outpatient_radiology_professional", "package": null, "version": null}, {"name": "service_category__observation_professional", "package": null, "version": null}, {"name": "service_category__dme_professional", "package": null, "version": null}, {"name": "service_category__ambulance_professional", "package": null, "version": null}, {"name": "service_category__outpatient_surgery_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.service_category__acute_inpatient_professional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "model.the_tuva_project.service_category__inpatient_rehab_professional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__office_based_other_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "model.the_tuva_project.service_category__outpatient_rehab_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "model.the_tuva_project.service_category__urgent_care_professional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__ambulance_professional", "model.the_tuva_project.service_category__outpatient_surgery_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__combined_professional.sql", "compiled": true, "compiled_code": "\n\nWITH combined_professional_services AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_dialysis_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_dialysis_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_emergency_department_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_emergency_department_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_home_health_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_home_health_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_lab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_lab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_other_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_other_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_radiology' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_radiology\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_office_based_visit_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_office_based_visit_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_urgent_care_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_urgent_care_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_observation_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_observation_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_dme_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_dme_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulance_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulance_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_professional\n\n \n )\n\n \n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.claim_line_id,\n p.service_category_1,\n p.service_category_2,\n p.service_category_3,\n p.tuva_last_run,\n p.source_model_name\nFROM combined_professional_services p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__dialysis_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__dialysis_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__dialysis_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__dialysis_institutional.sql", "unique_id": "model.the_tuva_project.service_category__dialysis_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__dialysis_institutional"], "alias": "_int_dialysis_institutional", "checksum": {"name": "sha256", "checksum": "012c9362f7bcb3485ad1848fdc5509f50857707bd313403900d1a24e089f98d9"}, "config": {"enabled": true, "alias": "_int_dialysis_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_dialysis_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6411417, "relation_name": "dev_thuxuan.claims_preprocessing._int_dialysis_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , 'outpatient' as service_category_1\r\n , 'dialysis' as service_category_2\r\n , 'dialysis' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere \r\n substring(med.bill_type_code, 1, 2) in ('72')\r\n or med.primary_taxonomy_code in (\r\n '2472R0900X'\r\n , '163WD1100X'\r\n , '163WH0500X'\r\n , '261QE0700X'\r\n )\r\n or med.ccs_category in ('91', '58', '57')\r\n or substring(med.revenue_center_code, 1, 3) in ('082', '083', '084', '085', '088')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__dialysis_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('72')\n or med.primary_taxonomy_code in (\n '2472R0900X'\n , '163WD1100X'\n , '163WH0500X'\n , '261QE0700X'\n )\n or med.ccs_category in ('91', '58', '57')\n or substring(med.revenue_center_code, 1, 3) in ('082', '083', '084', '085', '088')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__dialysis_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__dialysis_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__dialysis_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__dialysis_professional.sql", "unique_id": "model.the_tuva_project.service_category__dialysis_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__dialysis_professional"], "alias": "_int_dialysis_professional", "checksum": {"name": "sha256", "checksum": "a487d41221c4e4c5c32444bcb383fb27c432848242d2a18dbd409e5d90b25489"}, "config": {"enabled": true, "alias": "_int_dialysis_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_dialysis_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6431422, "relation_name": "dev_thuxuan.claims_preprocessing._int_dialysis_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'outpatient' as service_category_1 \r\n , 'dialysis' as service_category_2\r\n , 'dialysis' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_professional') }} as prof\r\n on med.claim_id = prof.claim_id\r\n and med.claim_line_number = prof.claim_line_number\r\nwhere \r\n med.place_of_service_code in ('65')\r\n or med.ccs_category in ('91', '58', '57')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__dialysis_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1 \n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('65')\n or med.ccs_category in ('91', '58', '57')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__dme_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__dme_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__dme_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__dme_professional.sql", "unique_id": "model.the_tuva_project.service_category__dme_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__dme_professional"], "alias": "_int_dme_professional", "checksum": {"name": "sha256", "checksum": "4bb61f06acb0029051765f2c21fd98349b568225f974813c1b7eb0ab4791e4bc"}, "config": {"enabled": true, "alias": "_int_dme_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_dme_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.645142, "relation_name": "dev_thuxuan.claims_preprocessing._int_dme_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n claim_id\r\n , claim_line_number\r\n , claim_line_id\r\n, 'ancillary' as service_category_1\r\n, 'durable medical equipment' as service_category_2\r\n, 'durable medical equipment' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\n and hcpcs_code between 'E0100' and 'E8002'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__dme_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'ancillary' as service_category_1\n, 'durable medical equipment' as service_category_2\n, 'durable medical equipment' as service_category_3\n, '_int_dme_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and hcpcs_code between 'E0100' and 'E8002'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__emergency_department_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__emergency_department_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__emergency_department_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__emergency_department_institutional.sql", "unique_id": "model.the_tuva_project.service_category__emergency_department_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__emergency_department_institutional"], "alias": "_int_emergency_department_institutional", "checksum": {"name": "sha256", "checksum": "461f1ef3d06249440dc5ac6cc2deeb06fc68b74531024876c7d47d874b056999"}, "config": {"enabled": true, "alias": "_int_emergency_department_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_emergency_department_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6471417, "relation_name": "dev_thuxuan.claims_preprocessing._int_emergency_department_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\nselect distinct \r\n med.claim_id\r\n , 'emergency department' as service_category_2\r\n , 'emergency department' as service_category_3\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n , '{{ this.name }}' as source_model_name\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\r\nOR\r\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')\r\n \r\nunion all\r\n\r\n--Adding in inpatient claims for flagging encounters with ED \r\nselect distinct \r\n med.claim_id\r\n , 'emergency department' as service_category_2\r\n , 'emergency department' as service_category_3\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n , '{{ this.name }}' as source_model_name\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} inp\r\n on med.claim_id = inp.claim_id\r\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\r\n\r\n)\r\n\r\nselect claim_id\r\n, 'outpatient' as service_category_1\r\n,service_category_2\r\n,service_category_3\r\n,tuva_last_run\r\n,source_model_name\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__emergency_department_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')\n \nunion all\n\n--Adding in inpatient claims for flagging encounters with ED \nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional inp\n on med.claim_id = inp.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\n\n)\n\nselect claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,tuva_last_run\n,source_model_name\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__emergency_department_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__emergency_department_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__emergency_department_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__emergency_department_professional.sql", "unique_id": "model.the_tuva_project.service_category__emergency_department_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__emergency_department_professional"], "alias": "_int_emergency_department_professional", "checksum": {"name": "sha256", "checksum": "bc768049ef53a08e3317cd7837e5ed1df22e251203abb747c5cd37dac8ad48d1"}, "config": {"enabled": true, "alias": "_int_emergency_department_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_emergency_department_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.649142, "relation_name": "dev_thuxuan.claims_preprocessing._int_emergency_department_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'outpatient' as service_category_1\r\n, 'emergency department' as service_category_2\r\n, 'emergency department' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere place_of_service_code = '23'\r\nOR\r\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__emergency_department_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'emergency department' as service_category_2\n, 'emergency department' as service_category_3\n, '_int_emergency_department_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '23'\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__home_health_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__home_health_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__home_health_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__home_health_institutional.sql", "unique_id": "model.the_tuva_project.service_category__home_health_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__home_health_institutional"], "alias": "_int_home_health_institutional", "checksum": {"name": "sha256", "checksum": "eb2ecb21a19aa755b7b740424794e4992abdecfc089bedaff5b1a0cdfa452e17"}, "config": {"enabled": true, "alias": "_int_home_health_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_home_health_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6511421, "relation_name": "dev_thuxuan.claims_preprocessing._int_home_health_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n claim_id\r\n , 'outpatient' as service_category_1\r\n, 'home health' as service_category_2\r\n, 'home health' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'institutional'\r\n and substring(bill_type_code, 1, 2) in ('31','32','33')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__home_health_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n , 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('31','32','33')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__home_health_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__home_health_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__home_health_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__home_health_professional.sql", "unique_id": "model.the_tuva_project.service_category__home_health_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__home_health_professional"], "alias": "_int_home_health_professional", "checksum": {"name": "sha256", "checksum": "ff3d678ee61864db66c90faa7cc8ba62230cf7a49b65c78fa9e7b9b817ce47b6"}, "config": {"enabled": true, "alias": "_int_home_health_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_home_health_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6541421, "relation_name": "dev_thuxuan.claims_preprocessing._int_home_health_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\nmed.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'outpatient' as service_category_1\r\n, 'home health' as service_category_2\r\n, 'home health' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere med.place_of_service_code in ('12')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__home_health_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('12')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_hospice_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_hospice_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_hospice_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_hospice_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_hospice_institutional"], "alias": "_int_inpatient_hospice_institutional", "checksum": {"name": "sha256", "checksum": "bfd095b4b076d8e38a6c07e2d17e27038f97ec0321fff84fb9e4e8b9ae6f2144"}, "config": {"enabled": true, "alias": "_int_inpatient_hospice_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_hospice_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.656142, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_hospice_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\ns.claim_id\r\n, 'inpatient' as service_category_1\r\n, 'inpatient hospice' as service_category_2\r\n, 'inpatient hospice' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} a on s.claim_id = a.claim_id\r\nwhere substring(s.bill_type_code, 1, 2) in ('82')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_hospice_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n, '_int_inpatient_hospice_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id\nwhere substring(s.bill_type_code, 1, 2) in ('82')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_hospice_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_hospice_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_hospice_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_hospice_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_hospice_professional"], "alias": "_int_inpatient_hospice_professional", "checksum": {"name": "sha256", "checksum": "81c6ecb0bd6b6677a0a4bf00f0d8f6455a15ffd41c9fc5a264850fcce6cd6434"}, "config": {"enabled": true, "alias": "_int_inpatient_hospice_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_hospice_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.663142, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_hospice_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\nmed.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'inpatient' as service_category_1\r\n, 'inpatient hospice' as service_category_2\r\n, 'inpatient hospice' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere place_of_service_code in ('34')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_hospice_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n,'_int_inpatient_hospice_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code in ('34')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_psychiatric_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_psychiatric_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_psychiatric_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_psychiatric_institutional"], "alias": "_int_inpatient_psychiatric_institutional", "checksum": {"name": "sha256", "checksum": "676ed2031b9a5b6c7f462d3c88b175059ddae6266e035e37d11d5a8e92b721fb"}, "config": {"enabled": true, "alias": "_int_inpatient_psychiatric_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_psychiatric_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6671422, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\ns.claim_id\r\n, 'inpatient' as service_category_1\r\n, 'inpatient psychiatric' as service_category_2\r\n, 'inpatient psychiatric' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} i on s.claim_id = i.claim_id\r\nwhere s.primary_taxonomy_code in ('283Q00000X'\r\n ,'273R00000X')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_psychiatric_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n, '_int_inpatient_psychiatric_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_psychiatric_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_psychiatric_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_psychiatric_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_psychiatric_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_psychiatric_professional"], "alias": "_int_inpatient_psychiatric_professional", "checksum": {"name": "sha256", "checksum": "e69efd2aa58d42168970820c7c6c7c2c7e5a51999c7dc70aec04208acebfadd9"}, "config": {"enabled": true, "alias": "_int_inpatient_psychiatric_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_psychiatric_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.665142, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\nclaim_id\r\n, claim_line_number\r\n, claim_line_id\r\n, 'inpatient' as service_category_1\r\n, 'inpatient psychiatric' as service_category_2\r\n, 'inpatient psychiatric' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\n and place_of_service_code in ('51','55','56')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_psychiatric_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \nclaim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n,'_int_inpatient_psychiatric_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('51','55','56')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_rehab_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_rehab_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_rehab_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_rehab_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_rehab_institutional"], "alias": "_int_inpatient_rehab_institutional", "checksum": {"name": "sha256", "checksum": "648704923b8d94381dd3c1caa056b5dfc307d2a0e1495ecff1cf365601b18095"}, "config": {"enabled": true, "alias": "_int_inpatient_rehab_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_rehab_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6711423, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_rehab_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n s.claim_id\r\n, 'inpatient' as service_category_1\r\n, 'inpatient rehabilitation' as service_category_2\r\n, 'inpatient rehabilitation' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} i on s.claim_id = i.claim_id\r\nwhere s.primary_taxonomy_code in ('283X00000X'\r\n ,'273Y00000X'\r\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_rehab_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n s.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n, '_int_inpatient_rehab_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283X00000X'\n ,'273Y00000X'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_rehab_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_rehab_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_rehab_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_rehab_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_rehab_professional"], "alias": "_int_inpatient_rehab_professional", "checksum": {"name": "sha256", "checksum": "26b0d4b8ef57efdfe4cc149831636c9a7ba1b1bb6a7be09ff51b30acc0dedffe"}, "config": {"enabled": true, "alias": "_int_inpatient_rehab_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_rehab_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6691422, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_rehab_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n claim_id\r\n, claim_line_number\r\n, claim_line_id\r\n, 'inpatient' as service_category_1\r\n, 'inpatient rehabilitation' as service_category_2\r\n, 'inpatient rehabilitation' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\n and place_of_service_code in ('61')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_rehab_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n,'_int_inpatient_rehab_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('61')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_skilled_nursing_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_skilled_nursing_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_skilled_nursing_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_skilled_nursing_institutional"], "alias": "_int_inpatient_skilled_nursing_institutional", "checksum": {"name": "sha256", "checksum": "c48e2519736a5764a01fdecde9b56aac2b2d57d7a1573bc32f2cafc96b0aebb7"}, "config": {"enabled": true, "alias": "_int_inpatient_skilled_nursing_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_skilled_nursing_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.693147, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n claim_id\r\n, 'inpatient' as service_category_1\r\n, 'skilled nursing' as service_category_2\r\n, 'skilled nursing' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'institutional'\r\n and substring(bill_type_code, 1, 2) in ('21','22')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_skilled_nursing_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('21','22')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_skilled_nursing_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_skilled_nursing_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_skilled_nursing_professional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_skilled_nursing_professional"], "alias": "_int_inpatient_skilled_nursing_professional", "checksum": {"name": "sha256", "checksum": "e0680dadd036f1d8db6d3daeb950ba8309cf34f1d5cec24983242fbd3560e030"}, "config": {"enabled": true, "alias": "_int_inpatient_skilled_nursing_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_skilled_nursing_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.695147, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n a.claim_id\r\n, a.claim_line_number\r\n, a.claim_line_id\r\n, 'inpatient' as service_category_1\r\n, 'skilled nursing' as service_category_2\r\n, 'skilled nursing' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} a\r\nleft join {{ ref('service_category__dme_professional') }} b\r\n on a.claim_id = b.claim_id\r\n and a.claim_line_number = b.claim_line_number\r\nwhere claim_type = 'professional'\r\n and place_of_service_code in ('31','32')\r\n and (b.claim_id is null and b.claim_line_number is null)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__dme_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__dme_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_skilled_nursing_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n, a.claim_line_number\n, a.claim_line_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nleft join dev_thuxuan.claims_preprocessing._int_dme_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\nwhere claim_type = 'professional'\n and place_of_service_code in ('31','32')\n and (b.claim_id is null and b.claim_line_number is null)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__inpatient_substance_use_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__inpatient_substance_use_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_substance_use_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_substance_use_institutional.sql", "unique_id": "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__inpatient_substance_use_institutional"], "alias": "_int_inpatient_substance_use_institutional", "checksum": {"name": "sha256", "checksum": "9c9196112b3d1732d10038b6f4dac7f38d5c0c170f40c3592b8e0405faf6e517"}, "config": {"enabled": true, "alias": "_int_inpatient_substance_use_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_inpatient_substance_use_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7149484, "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_substance_use_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n a.claim_id\r\n , 'inpatient' as service_category_1\r\n , 'inpatient substance use' as service_category_2\r\n , 'inpatient substance use' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as s\r\ninner join {{ ref('service_category__stg_inpatient_institutional') }} as a\r\n on s.claim_id = a.claim_id\r\nwhere \r\n s.primary_taxonomy_code in (\r\n '324500000X'\r\n , '261QR0405X'\r\n , '101YA0400X'\r\n )\r\n or s.default_ccsr_category_description_ip in (\r\n 'MBD026'\r\n , 'SYM008'\r\n , 'MBD025'\r\n , 'SYM009'\r\n , 'MBD034'\r\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__inpatient_substance_use_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'inpatient substance use' as service_category_2\n , 'inpatient substance use' as service_category_3\n , '_int_inpatient_substance_use_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\nwhere \n s.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )\n or s.default_ccsr_category_description_ip in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__lab_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__lab_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__lab_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__lab_institutional.sql", "unique_id": "model.the_tuva_project.service_category__lab_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__lab_institutional"], "alias": "_int_lab_institutional", "checksum": {"name": "sha256", "checksum": "9bfd1bdafbb7302278d365297e9eedcf7aa2cf52e214c3d0882f95c24134c601"}, "config": {"enabled": true, "alias": "_int_lab_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_lab_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.673142, "relation_name": "dev_thuxuan.claims_preprocessing._int_lab_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, 'ancillary' as service_category_1 \r\n, 'lab' as service_category_2\r\n, 'lab' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere substring(med.bill_type_code, 1, 2) in ('14')\r\nOR\r\nmed.ccs_category in ('233' -- lab\r\n,'235' --other lab\r\n,'234' --pathology\r\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__lab_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.bill_type_code, 1, 2) in ('14')\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__lab_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__lab_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__lab_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__lab_professional.sql", "unique_id": "model.the_tuva_project.service_category__lab_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__lab_professional"], "alias": "_int_lab_professional", "checksum": {"name": "sha256", "checksum": "a77465e96f7e2e5c86e8b16cc0faf4710493b6b5bb6eb699d81a98ef201f4f54"}, "config": {"enabled": true, "alias": "_int_lab_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_lab_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.676142, "relation_name": "dev_thuxuan.claims_preprocessing._int_lab_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'ancillary' as service_category_1 \r\n, 'lab' as service_category_2\r\n, 'lab' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere place_of_service_code = '81'\r\nOR\r\nmed.ccs_category in ('233' -- lab\r\n,'235' --other lab\r\n,'234' --pathology\r\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__lab_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '81'\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__observation_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__observation_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__observation_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__observation_institutional.sql", "unique_id": "model.the_tuva_project.service_category__observation_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__observation_institutional"], "alias": "_int_observation_institutional", "checksum": {"name": "sha256", "checksum": "24483886ffc06fa2700e2397c8916a596436b0f5a6901201477d9dcb74ba3377"}, "config": {"enabled": true, "alias": "_int_observation_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_observation_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.710948, "relation_name": "dev_thuxuan.claims_preprocessing._int_observation_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, 'outpatient' as service_category_1\r\n, 'observation' as service_category_2\r\n, 'observation' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\nwhere claim_type = 'institutional'\r\nand (revenue_center_code in ('0762')\r\nor hcpcs_code in ('G0378','G0379')\r\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__observation_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1\n, 'observation' as service_category_2\n, 'observation' as service_category_3\n, '_int_observation_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\nwhere claim_type = 'institutional'\nand (revenue_center_code in ('0762')\nor hcpcs_code in ('G0378','G0379')\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__observation_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__observation_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__observation_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__observation_professional.sql", "unique_id": "model.the_tuva_project.service_category__observation_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__observation_professional"], "alias": "_int_observation_professional", "checksum": {"name": "sha256", "checksum": "d3325b83f738ab81ca939aa50f25a467c08933ced384356bfe5b193360a76823"}, "config": {"enabled": true, "alias": "_int_observation_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_observation_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7129483, "relation_name": "dev_thuxuan.claims_preprocessing._int_observation_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'outpatient' as service_category_1\r\n , 'observation' as service_category_2\r\n , 'observation' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_professional') }} as prof\r\n on med.claim_id = prof.claim_id\r\n and med.claim_line_number = prof.claim_line_number\r\nwhere \r\n med.hcpcs_code in ('G0378', 'G0379')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__observation_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'observation' as service_category_2\n , 'observation' as service_category_3\n , '_int_observation_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.hcpcs_code in ('G0378', 'G0379')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_other_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__office_based_other_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__office_based_other_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_other_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_other_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_other_professional"], "alias": "service_category__office_based_other_professional", "checksum": {"name": "sha256", "checksum": "215a19f9d15e2c6a735719b23fdf380654057571af2ad7bdd3fc2ac31dc4ab0e"}, "config": {"enabled": true, "alias": "service_category__office_based_other_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_other_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7169485, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_other_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\n select distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'office-based' as service_category_1 \r\n, 'office-based other' as service_category_2\r\n, 'office-based other' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('service_category__stg_office_based') }} med\r\n left join {{ ref('service_category__pharmacy_professional') }} pharm on med.claim_line_id = pharm.claim_line_id\r\n left join {{ ref('service_category__office_based_radiology') }} rad on med.claim_line_id = rad.claim_line_id\r\n left join {{ ref('service_category__office_based_visit_professional') }} visit on med.claim_line_id = visit.claim_line_id\r\n left join {{ ref('service_category__office_based_surgery_professional') }} surg on med.claim_line_id = surg.claim_line_id\r\n left join {{ ref('service_category__office_based_physical_therapy_professional') }} pt on med.claim_line_id = pt.claim_line_id\r\n where pharm.claim_line_id is null \r\n and rad.claim_line_id is null \r\n and visit.claim_line_id is null\r\n and surg.claim_line_id is null\r\n and pt.claim_line_id is null", "language": "sql", "refs": [{"name": "service_category__stg_office_based", "package": null, "version": null}, {"name": "service_category__pharmacy_professional", "package": null, "version": null}, {"name": "service_category__office_based_radiology", "package": null, "version": null}, {"name": "service_category__office_based_visit_professional", "package": null, "version": null}, {"name": "service_category__office_based_surgery_professional", "package": null, "version": null}, {"name": "service_category__office_based_physical_therapy_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_office_based", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_other_professional.sql", "compiled": true, "compiled_code": "\n\n\n select distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'office-based' as service_category_1 \n, 'office-based other' as service_category_2\n, 'office-based other' as service_category_3\n, 'service_category__office_based_other_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_office_based med\n left join dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional pharm on med.claim_line_id = pharm.claim_line_id\n left join dev_thuxuan.claims_preprocessing.service_category__office_based_radiology rad on med.claim_line_id = rad.claim_line_id\n left join dev_thuxuan.claims_preprocessing._int_office_based_visit_professional visit on med.claim_line_id = visit.claim_line_id\n left join dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional surg on med.claim_line_id = surg.claim_line_id\n left join dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional pt on med.claim_line_id = pt.claim_line_id\n where pharm.claim_line_id is null \n and rad.claim_line_id is null \n and visit.claim_line_id is null\n and surg.claim_line_id is null\n and pt.claim_line_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_physical_therapy_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__office_based_physical_therapy_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__office_based_physical_therapy_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_physical_therapy_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_physical_therapy_professional"], "alias": "service_category__office_based_physical_therapy_professional", "checksum": {"name": "sha256", "checksum": "709a2b5844c03109d881f7c9ec3cc18b5dfdf50172bbd86fb875eb0aa487a280"}, "config": {"enabled": true, "alias": "service_category__office_based_physical_therapy_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_physical_therapy_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7189555, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'office-based' as service_category_1 \r\n , 'office-based pt/ot/st' as service_category_2\r\n , 'office-based pt/ot/st' as service_category_3\r\n ,'{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_office_based') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere (\r\nccs_category in ('213','212','215')\r\nOR\r\n med.rend_primary_specialty_description IN (\r\n 'Occupational Health'\r\n ,'Occupational Medicine'\r\n ,'Occupational Therapist in Private Practice'\r\n ,'Occupational Therapy Assistant'\r\n ,'Physical Therapist'\r\n ,'Physical Therapist in Private Practice'\r\n ,'Physical Therapy Assistant'\r\n ,'Speech Language Pathologist'\r\n ,'Speech-Language Assistant'\r\n ))\r\nand place_of_service_code = '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_physical_therapy_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based pt/ot/st' as service_category_2\n , 'office-based pt/ot/st' as service_category_3\n ,'service_category__office_based_physical_therapy_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_office_based prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (\nccs_category in ('213','212','215')\nOR\n med.rend_primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nand place_of_service_code = '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_radiology": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__office_based_radiology", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__office_based_radiology.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_radiology.sql", "unique_id": "model.the_tuva_project.service_category__office_based_radiology", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_radiology"], "alias": "service_category__office_based_radiology", "checksum": {"name": "sha256", "checksum": "469fa81bfaf9f5180c685557c8b5e20a987c75038da772d30634955a181e6d49"}, "config": {"enabled": true, "alias": "service_category__office_based_radiology", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_radiology", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7209485, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_radiology", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'office-based' as service_category_1 \r\n , 'office-based radiology' as service_category_2\r\n , case when med.modality = 'Nuclear medicine' then 'pet'\r\n when med.modality = 'Magnetic resonance' then 'mri'\r\n when med.modality = 'Computerized tomography' then 'ct'\r\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\r\n else 'general' \r\n end as service_category_3\r\n ,'{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_office_based') }} o on med.claim_id = o.claim_id\r\nand\r\nmed.claim_line_number = o.claim_line_number\r\nwhere \r\nmed.modality is not null\r\nand\r\nmed.place_of_service_code = '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_radiology.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based radiology' as service_category_2\n , case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n ,'service_category__office_based_radiology' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_office_based o on med.claim_id = o.claim_id\nand\nmed.claim_line_number = o.claim_line_number\nwhere \nmed.modality is not null\nand\nmed.place_of_service_code = '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_surgery_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__office_based_surgery_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__office_based_surgery_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_surgery_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_surgery_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_surgery_professional"], "alias": "service_category__office_based_surgery_professional", "checksum": {"name": "sha256", "checksum": "2a7162a3febdb317c5011049e605b2589fa7fe20b84bf6bfff5c101d05f8fe03"}, "config": {"enabled": true, "alias": "service_category__office_based_surgery_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__office_based_surgery_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7234733, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n{# Since HCPCS is a string, we need to exclude values that would fall in our comparison range for alphanumeric values #}\r\nwith numeric_hcpcs as (\r\n select *\r\n from {{ ref('service_category__stg_medical_claim') }} as med\r\n where {{ safe_cast('hcpcs_code', 'int')}} is not null\r\n)\r\n\r\n\r\n select distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n ,'office-based' as service_category_1 \r\n , 'office-based surgery' as service_category_2\r\n , 'office-based surgery' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\n from numeric_hcpcs as med\r\n inner join {{ ref('service_category__stg_office_based') }} as prof\r\n on med.claim_id = prof.claim_id\r\n and med.claim_line_number = prof.claim_line_number\r\n where \r\n (hcpcs_code between '10021' and '69999')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.safe_cast"], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_surgery_professional.sql", "compiled": true, "compiled_code": "\n\n\nwith numeric_hcpcs as (\n select *\n from dev_thuxuan.test.service_category__stg_medical_claim as med\n where \n \n try_cast(hcpcs_code as int)\n is not null\n)\n\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n ,'office-based' as service_category_1 \n , 'office-based surgery' as service_category_2\n , 'office-based surgery' as service_category_3\n , 'service_category__office_based_surgery_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from numeric_hcpcs as med\n inner join dev_thuxuan.test.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\n where \n (hcpcs_code between '10021' and '69999')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__office_based_visit_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__office_based_visit_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__office_based_visit_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_visit_professional.sql", "unique_id": "model.the_tuva_project.service_category__office_based_visit_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__office_based_visit_professional"], "alias": "_int_office_based_visit_professional", "checksum": {"name": "sha256", "checksum": "9d831d1c8a0cc70ada8c4551417ad7de147a23d1f9e2365038b620bfbf35e4fc"}, "config": {"enabled": true, "alias": "_int_office_based_visit_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_office_based_visit_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.679161, "relation_name": "dev_thuxuan.claims_preprocessing._int_office_based_visit_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'office-based' as service_category_1\r\n , case \r\n when med.place_of_service_code = '11' then 'office-based visit'\r\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\r\n end as service_category_2\r\n , case \r\n when med.place_of_service_code = '11' then 'office-based visit'\r\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\r\n end as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_office_based') }} as prof\r\n on med.claim_id = prof.claim_id\r\n and med.claim_line_number = prof.claim_line_number\r\nwhere \r\n (med.place_of_service_code = '11' and med.ccs_category = '227') -- consultation eval and preventative care\r\n or med.place_of_service_code in ('02', '10') -- telehealth", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_office_based", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__office_based_visit_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_2\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_3\n , '_int_office_based_visit_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n (med.place_of_service_code = '11' and med.ccs_category = '227') -- consultation eval and preventative care\n or med.place_of_service_code in ('02', '10') -- telehealth", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospice_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospice_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospice_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospice_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospice_institutional"], "alias": "_int_outpatient_hospice_institutional", "checksum": {"name": "sha256", "checksum": "f68b347357fb07e8e73592a9594cbc5d105e4810533de98b538c55f25c350e97"}, "config": {"enabled": true, "alias": "_int_outpatient_hospice_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospice_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.658142, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospice_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , 'outpatient' as service_category_1\r\n , 'outpatient hospice' as service_category_2\r\n , 'outpatient hospice' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\r\n on med.claim_id = outpatient.claim_id\r\nwhere \r\n substring(med.bill_type_code, 1, 2) in ('81')\r\n or (\r\n med.hcpcs_code in ('Q5001', 'Q5002', 'Q5003', 'Q5009')\r\n and substring(med.bill_type_code, 1, 2) not in ('31', '32', '33')\r\n )\r\n or med.revenue_center_code in ('0651', '0652')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospice_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient hospice' as service_category_2\n , 'outpatient hospice' as service_category_3\n , '_int_outpatient_hospice_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('81')\n or (\n med.hcpcs_code in ('Q5001', 'Q5002', 'Q5003', 'Q5009')\n and substring(med.bill_type_code, 1, 2) not in ('31', '32', '33')\n )\n or med.revenue_center_code in ('0651', '0652')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospice_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospice_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospice_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospice_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospice_professional"], "alias": "_int_outpatient_hospice_professional", "checksum": {"name": "sha256", "checksum": "98476933b3188d5e21cff6546680135a3d6ffcd41e11b348680d43fe37207a91"}, "config": {"enabled": true, "alias": "_int_outpatient_hospice_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospice_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6601455, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospice_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'outpatient' as service_category_1 \r\n, 'outpatient hospice' as service_category_2\r\n, 'outpatient hospice' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere \r\nmed.hcpcs_code in ('Q5001','Q5002','Q5003','Q5009')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospice_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient hospice' as service_category_2\n, 'outpatient hospice' as service_category_3\n, '_int_outpatient_hospice_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere \nmed.hcpcs_code in ('Q5001','Q5002','Q5003','Q5009')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospital_or_clinic_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospital_or_clinic_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospital_or_clinic_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospital_or_clinic_institutional"], "alias": "_int_outpatient_hospital_or_clinic_institutional", "checksum": {"name": "sha256", "checksum": "9339236f4d9050d491235385f0f3e725d18143e4a0a19b42db739634094ac4dc"}, "config": {"enabled": true, "alias": "_int_outpatient_hospital_or_clinic_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospital_or_clinic_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6811578, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\n select distinct \r\n m.claim_id\r\n , 'outpatient hospital or clinic' as service_category_2\r\n , 'outpatient hospital or clinic' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\n from {{ ref('service_category__stg_medical_claim') }} as m\r\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as o\r\n on m.claim_id = o.claim_id\r\n where \r\n substring(m.bill_type_code, 1, 2) in ('13', '71', '73')\r\n\r\n union all\r\n\r\n select distinct\r\n m.claim_id\r\n , 'outpatient hospital or clinic' as service_category_2\r\n , 'outpatient hospital or clinic' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\n from {{ ref('service_category__stg_medical_claim') }} as m\r\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as o\r\n on m.claim_id = o.claim_id\r\n where \r\n m.ccs_category = '227' -- Consultation, evaluation, and preventative care\r\n)\r\n\r\nselect distinct\r\n claim_id\r\n , 'outpatient' as service_category_1\r\n , service_category_2\r\n , service_category_3\r\n , source_model_name\r\n , tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospital_or_clinic_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as m\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n substring(m.bill_type_code, 1, 2) in ('13', '71', '73')\n\n union all\n\n select distinct\n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as m\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n m.ccs_category = '227' -- Consultation, evaluation, and preventative care\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_hospital_or_clinic_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospital_or_clinic_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospital_or_clinic_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_hospital_or_clinic_professional"], "alias": "_int_outpatient_hospital_or_clinic_professional", "checksum": {"name": "sha256", "checksum": "4a718e95d896143f90e3bcb4d82dc6557dd7b5cd6c3a2d0066af335a30871cd2"}, "config": {"enabled": true, "alias": "_int_outpatient_hospital_or_clinic_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_hospital_or_clinic_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6841419, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'outpatient' as service_category_1\r\n , 'outpatient hospital or clinic' as service_category_2\r\n , 'outpatient hospital or clinic' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_professional') }} as prof\r\n on med.claim_id = prof.claim_id\r\n and med.claim_line_number = prof.claim_line_number\r\nwhere \r\n med.place_of_service_code in ('15', '17', '19', '22', '49', '50', '60', '71', '72')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_hospital_or_clinic_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('15', '17', '19', '22', '49', '50', '60', '71', '72')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_physical_therapy_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_physical_therapy_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_physical_therapy_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_physical_therapy_institutional"], "alias": "service_category__outpatient_physical_therapy_institutional", "checksum": {"name": "sha256", "checksum": "a4e7117fd7c288b28616fd34ae1e1f430583ca3da865ea98e1d83169c8714813"}, "config": {"enabled": true, "alias": "service_category__outpatient_physical_therapy_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_physical_therapy_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.732021, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n ,'outpatient' as service_category_1 \r\n , 'outpatient pt/ot/st' as service_category_2\r\n , 'outpatient pt/ot/st' as service_category_3\r\n ,'{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\r\nwhere ccs_category in ('213','212','215')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_physical_therapy_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n ,'outpatient' as service_category_1 \n , 'outpatient pt/ot/st' as service_category_2\n , 'outpatient pt/ot/st' as service_category_3\n ,'service_category__outpatient_physical_therapy_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere ccs_category in ('213','212','215')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_physical_therapy_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_physical_therapy_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_physical_therapy_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_physical_therapy_professional"], "alias": "service_category__outpatient_physical_therapy_professional", "checksum": {"name": "sha256", "checksum": "d160939ecc139a9cf1a5a599cc741dbf670b986a398bc2464ab72014500332ba"}, "config": {"enabled": true, "alias": "service_category__outpatient_physical_therapy_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_physical_therapy_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7340214, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'outpatient' as service_category_1 \r\n, 'outpatient pt/ot/st' as service_category_2\r\n, 'outpatient pt/ot/st' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere (ccs_category in ('213','212','215')\r\nOR\r\nmed.primary_specialty_description IN (\r\n 'Occupational Health'\r\n ,'Occupational Medicine'\r\n ,'Occupational Therapist in Private Practice'\r\n ,'Occupational Therapy Assistant'\r\n ,'Physical Therapist'\r\n ,'Physical Therapist in Private Practice'\r\n ,'Physical Therapy Assistant'\r\n ,'Speech Language Pathologist'\r\n ,'Speech-Language Assistant'\r\n ))\r\nAND\r\nplace_of_service_code <> '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_physical_therapy_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient pt/ot/st' as service_category_2\n, 'outpatient pt/ot/st' as service_category_3\n, 'service_category__outpatient_physical_therapy_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (ccs_category in ('213','212','215')\nOR\nmed.primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nAND\nplace_of_service_code <> '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_psychiatric_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_psychiatric_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_psychiatric_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_psychiatric_institutional"], "alias": "_int_outpatient_psychiatric_institutional", "checksum": {"name": "sha256", "checksum": "88cad2b9171892eefbece8b2f424d4556367a1f0f418e9a8cc4a1425f68250db"}, "config": {"enabled": true, "alias": "_int_outpatient_psychiatric_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_psychiatric_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6861417, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nwith multiple_sources as (\r\n\r\nselect distinct \r\n m.claim_id\r\n, 'outpatient psychiatric' as service_category_2\r\n, 'outpatient psychiatric' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} m\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} i on m.claim_id = i.claim_id\r\nwhere substring(m.bill_type_code, 1, 2) in ('52')\r\n\r\nunion all\r\n\r\nselect distinct \r\n m.claim_id\r\n, 'outpatient psychiatric' as service_category_2\r\n, 'outpatient psychiatric' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} m\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} i on m.claim_id = i.claim_id\r\nwhere m.primary_taxonomy_code in ('283Q00000X'\r\n ,'273R00000X')\r\n)\r\n\r\nselect distinct claim_id\r\n,'outpatient' as service_category_1 \r\n,service_category_2\r\n,service_category_3\r\n,source_model_name\r\n,tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_psychiatric_institutional.sql", "compiled": true, "compiled_code": "\nwith multiple_sources as (\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim m\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere substring(m.bill_type_code, 1, 2) in ('52')\n\nunion all\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim m\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere m.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')\n)\n\nselect distinct claim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_psychiatric_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_psychiatric_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_psychiatric_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_psychiatric_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_psychiatric_professional"], "alias": "_int_outpatient_psychiatric_professional", "checksum": {"name": "sha256", "checksum": "5fce36730b7debc50039102b511a88ca43be92157fb4961e0b9e3b4f769485fd"}, "config": {"enabled": true, "alias": "_int_outpatient_psychiatric_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_psychiatric_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6881418, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n claim_id\r\n, claim_line_number\r\n, claim_line_id\r\n, 'outpatient' as service_category_1 \r\n, 'outpatient psychiatric' as service_category_2\r\n, 'outpatient psychiatric' as service_category_3\r\n, '{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\n and place_of_service_code in ('52','53','57','58')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_psychiatric_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n, '_int_outpatient_psychiatric_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('52','53','57','58')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_radiology_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_radiology_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_radiology_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_radiology_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_radiology_institutional"], "alias": "service_category__outpatient_radiology_institutional", "checksum": {"name": "sha256", "checksum": "a3a95c086a2d308beaffd6a171a24a2dffd5576931bd4d7f8a1eb519e115bb8e"}, "config": {"enabled": true, "alias": "service_category__outpatient_radiology_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_radiology_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7360215, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, 'outpatient' as service_category_1 \r\n, 'outpatient radiology' as service_category_2\r\n, case when med.modality = 'Nuclear medicine' then 'pet'\r\n when med.modality = 'Magnetic resonance' then 'mri'\r\n when med.modality = 'Computerized tomography' then 'ct'\r\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\r\n else 'general' \r\n end as service_category_3\r\n, '{{ this.name }}' as source_model_name \r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\r\nwhere med.modality is not null", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_radiology_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_institutional' as source_model_name \n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_radiology_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_radiology_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_radiology_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_radiology_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_radiology_professional"], "alias": "service_category__outpatient_radiology_professional", "checksum": {"name": "sha256", "checksum": "50f34a30f88173d4807cf29c26872b4f3f7481af38baae15f2bb2bc33b8a101a"}, "config": {"enabled": true, "alias": "service_category__outpatient_radiology_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_radiology_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7380211, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n, med.claim_line_number\r\n, med.claim_line_id\r\n, 'outpatient' as service_category_1 \r\n, 'outpatient radiology' as service_category_2\r\n, case when med.modality = 'Nuclear medicine' then 'pet'\r\n when med.modality = 'Magnetic resonance' then 'mri'\r\n when med.modality = 'Computerized tomography' then 'ct'\r\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\r\n else 'general' \r\n end as service_category_3\r\n, '{{ this.name }}' as source_model_name \r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\r\nwhere med.modality is not null\r\nand\r\nplace_of_service_code <> '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_radiology_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_professional' as source_model_name \n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null\nand\nplace_of_service_code <> '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_rehab_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_rehab_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_rehab_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_rehab_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_rehab_institutional"], "alias": "service_category__outpatient_rehab_institutional", "checksum": {"name": "sha256", "checksum": "04044b20cbf46aa71021ce82ba60a93bb1d7c11a9c6de64213e12a2a77712d2d"}, "config": {"enabled": true, "alias": "service_category__outpatient_rehab_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "flagging outpatient claims for outpatient rehab service categories", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_rehab_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7480056, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_rehab_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\n select distinct \r\n m.claim_id\r\n , 'outpatient rehabilitation' as service_category_2\r\n , 'outpatient rehabilitation' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\n from {{ ref('service_category__stg_medical_claim') }} as m\r\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as i\r\n on m.claim_id = i.claim_id\r\n where \r\n m.primary_taxonomy_code in (\r\n '283X00000X'\r\n , '273Y00000X'\r\n , '261QR0400X'\r\n , '315D00000X'\r\n , '261QR0401X'\r\n , '208100000X'\r\n , '225400000X'\r\n , '324500000X'\r\n , '2278P1005X'\r\n , '261QR0405X'\r\n , '2081S0010X'\r\n , '261QR0404X'\r\n )\r\n)\r\n\r\nselect distinct\r\n claim_id\r\n , 'outpatient' as service_category_1\r\n , service_category_2\r\n , service_category_3\r\n , source_model_name\r\n , tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_rehab_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient rehabilitation' as service_category_2\n , 'outpatient rehabilitation' as service_category_3\n , 'service_category__outpatient_rehab_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as m\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as i\n on m.claim_id = i.claim_id\n where \n m.primary_taxonomy_code in (\n '283X00000X'\n , '273Y00000X'\n , '261QR0400X'\n , '315D00000X'\n , '261QR0401X'\n , '208100000X'\n , '225400000X'\n , '324500000X'\n , '2278P1005X'\n , '261QR0405X'\n , '2081S0010X'\n , '261QR0404X'\n )\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_rehab_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_rehab_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_rehab_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_rehab_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_rehab_professional"], "alias": "_int_outpatient_rehab_professional", "checksum": {"name": "sha256", "checksum": "f5143583072bbeea9e3d62846494e735436113f7ebc852e425e1170f03fed31a"}, "config": {"enabled": true, "alias": "_int_outpatient_rehab_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_outpatient_rehab_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6901422, "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_rehab_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n claim_id\r\n, claim_line_number\r\n, claim_line_id\r\n, 'outpatient' as service_category_1 \r\n, 'outpatient rehabilitation' as service_category_2\r\n, 'outpatient rehabilitation' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\n and place_of_service_code in ('62')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_rehab_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient rehabilitation' as service_category_2\n, 'outpatient rehabilitation' as service_category_3\n,'_int_outpatient_rehab_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('62')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_substance_use_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_substance_use_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_substance_use_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_substance_use_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_substance_use_institutional"], "alias": "service_category__outpatient_substance_use_institutional", "checksum": {"name": "sha256", "checksum": "9fc1a73f7fb8f80dcc3012f8ac86caaa78b99c94d4a593eb595b0e8ab99277a7"}, "config": {"enabled": true, "alias": "service_category__outpatient_substance_use_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_substance_use_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7400055, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , 'outpatient' as service_category_1\r\n , 'outpatient substance use' as service_category_2\r\n , 'outpatient substance use' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} as o\r\n on med.claim_id = o.claim_id\r\nwhere \r\n med.default_ccsr_category_description_op in (\r\n 'MBD026'\r\n , 'SYM008'\r\n , 'MBD025'\r\n , 'SYM009'\r\n , 'MBD034'\r\n )\r\n or med.primary_taxonomy_code in (\r\n '324500000X'\r\n , '261QR0405X'\r\n , '101YA0400X'\r\n )", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_substance_use_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as o\n on med.claim_id = o.claim_id\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n or med.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_substance_use_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_substance_use_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_substance_use_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_substance_use_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_substance_use_professional"], "alias": "service_category__outpatient_substance_use_professional", "checksum": {"name": "sha256", "checksum": "83807ca2f34b5c2d05773dcbfa6d1faf69636d452a8f4223d38386de5e26f43e"}, "config": {"enabled": true, "alias": "service_category__outpatient_substance_use_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_substance_use_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7420056, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct\r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , 'outpatient' as service_category_1\r\n , 'outpatient substance use' as service_category_2\r\n , 'outpatient substance use' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as med\r\ninner join {{ ref('service_category__stg_professional') }} as prof\r\n on med.claim_id = prof.claim_id\r\n and med.claim_line_number = prof.claim_line_number\r\nwhere \r\n med.default_ccsr_category_description_op in (\r\n 'MBD026'\r\n , 'SYM008'\r\n , 'MBD025'\r\n , 'SYM009'\r\n , 'MBD034'\r\n )\r\n and med.place_of_service_code <> '11'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_substance_use_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n and med.place_of_service_code <> '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_surgery_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_surgery_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_surgery_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_surgery_institutional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_surgery_institutional"], "alias": "service_category__outpatient_surgery_institutional", "checksum": {"name": "sha256", "checksum": "5e2eb1c18cae85a884e6db88fe8ace5c55f6c16c24dafbe64397b9e9a817f87e"}, "config": {"enabled": true, "alias": "service_category__outpatient_surgery_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_surgery_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7440054, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id --claim level\r\n , 'outpatient' as service_category_1 \r\n , 'outpatient surgery' as service_category_2\r\n , 'outpatient surgery' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_outpatient_institutional') }} o on med.claim_id = o.claim_id\r\nwhere\r\nccs_category between '1' and '176'\r\nor\r\nccs_category in ('229','230','231','232','244')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_surgery_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id --claim level\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere\nccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__outpatient_surgery_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__outpatient_surgery_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_surgery_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_surgery_professional.sql", "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__outpatient_surgery_professional"], "alias": "service_category__outpatient_surgery_professional", "checksum": {"name": "sha256", "checksum": "a18043f59b38f21e4154838d9ea32efd79a71825c47184601622c6fd011b736e"}, "config": {"enabled": true, "alias": "service_category__outpatient_surgery_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__outpatient_surgery_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7460058, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , 'outpatient' as service_category_1 \r\n , 'outpatient surgery' as service_category_2\r\n , 'outpatient surgery' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere\r\n(ccs_category between '1' and '176'\r\nor\r\nccs_category in ('229','230','231','232','244'))\r\nand\r\nplace_of_service_code in ('15','17','19','22','49','50','60','71','72')", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__outpatient_surgery_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\n(ccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244'))\nand\nplace_of_service_code in ('15','17','19','22','49','50','60','71','72')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__pharmacy_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__pharmacy_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__pharmacy_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__pharmacy_institutional.sql", "unique_id": "model.the_tuva_project.service_category__pharmacy_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__pharmacy_institutional"], "alias": "service_category__pharmacy_institutional", "checksum": {"name": "sha256", "checksum": "b62b5e49037b19f1bb61b6b49eb46b66c88557d85e9e1f62ef5e0f5f3134ae59"}, "config": {"enabled": true, "alias": "service_category__pharmacy_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__pharmacy_institutional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.727014, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__pharmacy_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\n select distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , 'outpatient' as service_category_1\r\n , 'pharmacy' as service_category_2\r\n , 'pharmacy' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\n from {{ ref('service_category__stg_medical_claim') }} as med\r\n inner join {{ ref('service_category__stg_outpatient_institutional') }} as outpatient\r\n on med.claim_id = outpatient.claim_id\r\n where \r\n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\r\n or med.revenue_center_code = '0547'\r\n or med.ccs_category = '240') -- medications\r\n\r\n union all\r\n\r\n select distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , 'inpatient' as service_category_1\r\n , 'pharmacy' as service_category_2\r\n , 'pharmacy' as service_category_3\r\n , '{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\n from {{ ref('service_category__stg_medical_claim') }} as med\r\n inner join {{ ref('service_category__stg_inpatient_institutional') }} as outpatient\r\n on med.claim_id = outpatient.claim_id\r\n where \r\n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\r\n or med.revenue_center_code = '0547')\r\n)\r\n\r\nselect \r\n claim_id\r\n , claim_line_number\r\n , service_category_1\r\n , service_category_2\r\n , service_category_3\r\n , source_model_name\r\n , tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_outpatient_institutional", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__pharmacy_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as med\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547'\n or med.ccs_category = '240') -- medications\n\n union all\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'inpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as med\n inner join dev_thuxuan.test.service_category__stg_inpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547')\n)\n\nselect \n claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__pharmacy_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__pharmacy_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__pharmacy_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__pharmacy_professional.sql", "unique_id": "model.the_tuva_project.service_category__pharmacy_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__pharmacy_professional"], "alias": "service_category__pharmacy_professional", "checksum": {"name": "sha256", "checksum": "b481c888451a5eff6e8665d1d24109acf92e22f9f967bbb86f0bb87eb384e0c5"}, "config": {"enabled": true, "alias": "service_category__pharmacy_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "service_category__pharmacy_professional", "materialized": "table", "tags": ["service_category_grouper"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7300222, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n med.claim_id\r\n , med.claim_line_number\r\n , med.claim_line_id\r\n , case when place_of_service_code = '11' then 'office-based' else 'outpatient' end as service_category_1\r\n , 'pharmacy' as service_category_2\r\n , 'pharmacy' as service_category_3\r\n ,'{{ this.name }}' as source_model_name\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} med\r\ninner join {{ ref('service_category__stg_professional') }} prof on med.claim_id = prof.claim_id \r\nand\r\nmed.claim_line_number = prof.claim_line_number\r\nwhere\r\nccs_category = '240' --medications", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__pharmacy_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , case when place_of_service_code = '11' then 'office-based' else 'outpatient' end as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n ,'service_category__pharmacy_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\nccs_category = '240' --medications", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__urgent_care_institutional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__urgent_care_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__urgent_care_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__urgent_care_institutional.sql", "unique_id": "model.the_tuva_project.service_category__urgent_care_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__urgent_care_institutional"], "alias": "_int_urgent_care_institutional", "checksum": {"name": "sha256", "checksum": "8e59b458600ad6b9116c794757564f4ecf7c0f93d0ae6f01bac80a3fcaa5f73b"}, "config": {"enabled": true, "alias": "_int_urgent_care_institutional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_urgent_care_institutional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6971471, "relation_name": "dev_thuxuan.claims_preprocessing._int_urgent_care_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_sources as (\r\nselect distinct \r\n a.claim_id\r\n, 'urgent care' as service_category_2\r\n, 'urgent care' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} a\r\nwhere claim_type = 'institutional'\r\n and revenue_center_code = '0456'\r\n and substring(bill_type_code, 1, 2) in ('13','71','73')\r\n \r\nunion all\r\n\r\nselect distinct \r\n a.claim_id\r\n, 'urgent care' as service_category_2\r\n, 'urgent care' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} a\r\nwhere claim_type = 'institutional'\r\n and hcpcs_code in ('S9088','99051','S9083')\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n,'outpatient' as service_category_1 \r\n,service_category_2\r\n,service_category_3\r\n,source_model_name\r\n,tuva_last_run\r\nfrom multiple_sources", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__urgent_care_institutional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and revenue_center_code = '0456'\n and substring(bill_type_code, 1, 2) in ('13','71','73')\n \nunion all\n\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__urgent_care_professional": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__urgent_care_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\intermediate\\service_category__urgent_care_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\intermediate\\service_category__urgent_care_professional.sql", "unique_id": "model.the_tuva_project.service_category__urgent_care_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "intermediate", "service_category__urgent_care_professional"], "alias": "_int_urgent_care_professional", "checksum": {"name": "sha256", "checksum": "cd35c9b0a7ab0d7cec0a18eee8a0f983b9844c8f7a2e36ff3d0eebdd427f8426"}, "config": {"enabled": true, "alias": "_int_urgent_care_professional", "schema": "claims_preprocessing", "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "service categories flagged by corresponding codes and value sets", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"schema": "claims_preprocessing", "alias": "_int_urgent_care_professional", "materialized": "table", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.6991472, "relation_name": "dev_thuxuan.claims_preprocessing._int_urgent_care_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith multiple_source as (\r\nselect distinct\r\n claim_id\r\n , claim_line_number\r\n , claim_line_id\r\n, 'urgent care' as service_category_2\r\n, 'urgent care' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\n and place_of_service_code in ('20')\r\n\r\nunion all\r\n\r\nselect distinct\r\n claim_id\r\n , claim_line_number\r\n , claim_line_id\r\n, 'urgent care' as service_category_2\r\n, 'urgent care' as service_category_3\r\n,'{{ this.name }}' as source_model_name\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }}\r\nwhere claim_type = 'professional'\r\nand hcpcs_code in ('S9088','99051','S9083')\r\n)\r\n\r\nselect distinct \r\nclaim_id\r\n,claim_line_number\r\n,claim_line_id\r\n,'outpatient' as service_category_1 \r\n,service_category_2\r\n,service_category_3\r\n,source_model_name\r\n,tuva_last_run\r\nfrom multiple_source", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\intermediate\\service_category__urgent_care_professional.sql", "compiled": true, "compiled_code": "\n\nwith multiple_source as (\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('20')\n\nunion all\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\nand hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,claim_line_number\n,claim_line_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_inpatient_institutional": {"database": "dev_thuxuan", "schema": "test", "name": "service_category__stg_inpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\staging\\service_category__stg_inpatient_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\staging\\service_category__stg_inpatient_institutional.sql", "unique_id": "model.the_tuva_project.service_category__stg_inpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_inpatient_institutional"], "alias": "service_category__stg_inpatient_institutional", "checksum": {"name": "sha256", "checksum": "348bbc2686d62e9e1c4dbe8e0f7c143422403d62f9dc09a944d2f6905d5cf2c0"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7510056, "relation_name": "dev_thuxuan.test.service_category__stg_inpatient_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith drg_requirement as (\r\n select distinct\r\n mc.claim_id\r\n from {{ ref('service_category__stg_medical_claim') }} as mc\r\n left join {{ ref('terminology__ms_drg') }} as msdrg\r\n on mc.ms_drg_code = msdrg.ms_drg_code\r\n left join {{ ref('terminology__apr_drg') }} as aprdrg\r\n on mc.apr_drg_code = aprdrg.apr_drg_code\r\n where mc.claim_type = 'institutional'\r\n and (\r\n msdrg.ms_drg_code is not null\r\n or aprdrg.apr_drg_code is not null\r\n )\r\n)\r\n\r\n, bill_type_requirement as (\r\n select distinct\r\n claim_id\r\n from {{ ref('service_category__stg_medical_claim') }}\r\n where claim_type = 'institutional'\r\n and substring(bill_type_code, 1, 2) in (\r\n '11' -- hospital inpatient \r\n , '12' -- hospital inpatient \r\n , '21' -- SNF inpatient\r\n , '82' -- inpatient hospice\r\n )\r\n)\r\n\r\nselect distinct\r\n a.claim_id\r\n , 'inpatient' as service_type\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as a\r\ninner join bill_type_requirement as d\r\n on a.claim_id = d.claim_id\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct\r\n a.claim_id\r\n , 'inpatient' as service_type\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} as a\r\ninner join drg_requirement as c\r\n on a.claim_id = c.claim_id", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\staging\\service_category__stg_inpatient_institutional.sql", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from dev_thuxuan.test.service_category__stg_medical_claim as mc\n left join dev_thuxuan.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join dev_thuxuan.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from dev_thuxuan.test.service_category__stg_medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n , '21' -- SNF inpatient\n , '82' -- inpatient hospice\n )\n)\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_medical_claim": {"database": "dev_thuxuan", "schema": "test", "name": "service_category__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\staging\\service_category__stg_medical_claim.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\staging\\service_category__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.service_category__stg_medical_claim", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_medical_claim"], "alias": "service_category__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "c3ce2e451e0ad29f0e746a01d02c008e171217bcf7f740e63ba4e27d28720f95"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper_base", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper_base", "claims_preprocessing"], "description": "Staging med claims for sc grouper", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper_base", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7500055, "relation_name": "dev_thuxuan.test.service_category__stg_medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect\r\n m.apr_drg_code\r\n , m.claim_id\r\n , m.claim_line_number\r\n , {{ dbt.concat([\"m.claim_id\", \"'|'\", \"cast(m.claim_line_number as \" ~ dbt.type_string() ~ \")\"]) }} as claim_line_id\r\n , m.claim_type\r\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\r\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\r\n , m.admission_date\r\n , m.discharge_date\r\n , m.claim_start_date\r\n , m.claim_end_date\r\n , m.claim_line_start_date\r\n , m.claim_line_end_date\r\n , m.bill_type_code\r\n , bt.bill_type_description\r\n , m.hcpcs_code\r\n , c.ccs_category\r\n , c.ccs_category_description\r\n , m.ms_drg_code\r\n , drg.ms_drg_description\r\n , m.place_of_service_code\r\n , pos.place_of_service_description\r\n , m.revenue_center_code\r\n , r.revenue_center_description\r\n , m.diagnosis_code_1\r\n , dx.default_ccsr_category_ip\r\n , dx.default_ccsr_category_op\r\n , dx.default_ccsr_category_description_ip\r\n , dx.default_ccsr_category_description_op\r\n , p.primary_taxonomy_code\r\n , p.primary_specialty_description\r\n , rend.primary_specialty_description as rend_primary_specialty_description\r\n , n.modality\r\n , m.data_source\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('normalized_input__medical_claim') }} m\r\nleft join {{ ref('ccsr__dxccsr_v2023_1_cleaned_map') }} dx on m.diagnosis_code_1 = dx.icd_10_cm_code\r\nleft join {{ ref('terminology__provider') }} p on m.facility_id = p.npi\r\nleft join {{ ref('terminology__ccs_services_procedures') }} c on m.hcpcs_code = c.hcpcs_code\r\nleft join {{ ref('terminology__nitos') }} n on m.hcpcs_code = n.hcpcs_code\r\nleft join {{ ref('terminology__ms_drg') }} drg on m.ms_drg_code = drg.ms_drg_code\r\nleft join {{ ref('terminology__revenue_center') }} r on m.revenue_center_code = r.revenue_center_code\r\nleft join {{ ref('terminology__place_of_service') }} pos on m.place_of_service_code = pos.place_of_service_code\r\nleft join {{ ref('terminology__bill_type') }} bt on m.bill_type_code = bt.bill_type_code\r\nleft join {{ ref('terminology__provider')}} rend on m.rendering_id = rend.npi", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_cleaned_map", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__ccs_services_procedures", "package": null, "version": null}, {"name": "terminology__nitos", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__revenue_center", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\staging\\service_category__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n m.apr_drg_code\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , rend.primary_specialty_description as rend_primary_specialty_description\n , n.modality\n , m.data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim m\nleft join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join dev_thuxuan.terminology.provider p on m.facility_id = p.npi\nleft join dev_thuxuan.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join dev_thuxuan.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join dev_thuxuan.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join dev_thuxuan.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join dev_thuxuan.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join dev_thuxuan.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join dev_thuxuan.terminology.provider rend on m.rendering_id = rend.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_office_based": {"database": "dev_thuxuan", "schema": "test", "name": "service_category__stg_office_based", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\staging\\service_category__stg_office_based.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\staging\\service_category__stg_office_based.sql", "unique_id": "model.the_tuva_project.service_category__stg_office_based", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_office_based"], "alias": "service_category__stg_office_based", "checksum": {"name": "sha256", "checksum": "95e2bbbc921ac4cad17f4b0188ec5fdba4f1be8adf47a0eb3db7b929bcc80111"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7560122, "relation_name": "dev_thuxuan.test.service_category__stg_office_based", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n a.claim_id\r\n , a.claim_line_number\r\n , a.claim_line_id\r\n , 'office based' as service_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} a\r\ninner join {{ ref('service_category__stg_professional') }} p on a.claim_id = p.claim_id \r\nand\r\na.claim_line_number = p.claim_line_number\r\nwhere a.place_of_service_code in ( '11' -- office\r\n,'02' --telehealth \r\n,'10' --telehealth\r\n)", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_professional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\staging\\service_category__stg_office_based.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id\n , 'office based' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\ninner join dev_thuxuan.test.service_category__stg_professional p on a.claim_id = p.claim_id \nand\na.claim_line_number = p.claim_line_number\nwhere a.place_of_service_code in ( '11' -- office\n,'02' --telehealth \n,'10' --telehealth\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_outpatient_institutional": {"database": "dev_thuxuan", "schema": "test", "name": "service_category__stg_outpatient_institutional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\staging\\service_category__stg_outpatient_institutional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\staging\\service_category__stg_outpatient_institutional.sql", "unique_id": "model.the_tuva_project.service_category__stg_outpatient_institutional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_outpatient_institutional"], "alias": "service_category__stg_outpatient_institutional", "checksum": {"name": "sha256", "checksum": "1edaa608c4534aa1ef84cc8d7f0916cf3b5b1597de4c3f45248269ebc85007ae"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7520056, "relation_name": "dev_thuxuan.test.service_category__stg_outpatient_institutional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n a.claim_id\r\n, 'outpatient' as service_type\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} a\r\nleft join {{ ref('service_category__stg_inpatient_institutional') }} i on a.claim_id = i.claim_id\r\nwhere i.claim_id is null\r\nand\r\na.claim_type = 'institutional'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}, {"name": "service_category__stg_inpatient_institutional", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_inpatient_institutional"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\staging\\service_category__stg_outpatient_institutional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n, 'outpatient' as service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nleft join dev_thuxuan.test.service_category__stg_inpatient_institutional i on a.claim_id = i.claim_id\nwhere i.claim_id is null\nand\na.claim_type = 'institutional'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.service_category__stg_professional": {"database": "dev_thuxuan", "schema": "test", "name": "service_category__stg_professional", "resource_type": "model", "package_name": "the_tuva_project", "path": "claims_preprocessing\\service_category\\staging\\service_category__stg_professional.sql", "original_file_path": "models\\claims_preprocessing\\service_category\\staging\\service_category__stg_professional.sql", "unique_id": "model.the_tuva_project.service_category__stg_professional", "fqn": ["the_tuva_project", "claims_preprocessing", "service_category", "staging", "service_category__stg_professional"], "alias": "service_category__stg_professional", "checksum": {"name": "sha256", "checksum": "669fac42b5e26779dc3f9ed69773410928cf82e9aa3415a8c9573e2e11330e68"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["service_category_grouper", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["service_category_grouper", "claims_preprocessing"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\claims_preprocessing\\service_category\\service_category_models.yml", "build_path": null, "unrendered_config": {"materialized": "view", "tags": ["service_category_grouper", "claims_preprocessing"], "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7530055, "relation_name": "dev_thuxuan.test.service_category__stg_professional", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect distinct \r\n a.claim_id\r\n , a.claim_line_number\r\n , a.claim_line_id as claim_line_id\r\n , 'professional' as service_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('service_category__stg_medical_claim') }} a\r\nwhere a.claim_type = 'professional'", "language": "sql", "refs": [{"name": "service_category__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.service_category__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\service_category\\staging\\service_category__stg_professional.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id as claim_line_id\n , 'professional' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nwhere a.claim_type = 'professional'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": {"database": "dev_thuxuan", "schema": "clinical_concept_library", "name": "clinical_concept_library__value_set_member_relevant_fields", "resource_type": "model", "package_name": "the_tuva_project", "path": "clinical_concept_library\\clinical_concept_library__value_set_member_relevant_fields.sql", "original_file_path": "models\\clinical_concept_library\\clinical_concept_library__value_set_member_relevant_fields.sql", "unique_id": "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__value_set_member_relevant_fields"], "alias": "value_set_member_relevant_fields", "checksum": {"name": "sha256", "checksum": "15df01ae61d29bd3b1ea2114844dc134eb20b6640e6886fa82c271f02d0c46a9"}, "config": {"enabled": true, "alias": "value_set_member_relevant_fields", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["clinical_concept_library"], "description": "This model creates one record per value set member, but it includes relevant fields for each value set member taken from the clnical_concepts and coding_systems tables.\n", "columns": {"concept_id": {"name": "concept_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_name": {"name": "concept_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_type": {"name": "concept_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "value_set_member_id": {"name": "value_set_member_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_id": {"name": "coding_system_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "include_descendants": {"name": "include_descendants", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_name": {"name": "coding_system_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\clinical_concept_library\\clinical_concept_library_models.yml", "build_path": null, "unrendered_config": {"schema": "clinical_concept_library", "alias": "value_set_member_relevant_fields", "tags": ["clinical_concept_library"], "materialized": "table", "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7600055, "relation_name": "dev_thuxuan.clinical_concept_library.value_set_member_relevant_fields", "raw_code": "with value_set_member_relevant_fields as (\r\nselect \r\n aa.concept_id,\r\n aa.concept_name,\r\n aa.concept_type,\r\n \r\n bb.value_set_member_id,\r\n bb.code,\r\n bb.coding_system_id,\r\n bb.include_descendants,\r\n\r\n cc.coding_system_name\r\n \r\nfrom {{ ref('clinical_concept_library__clinical_concepts') }} aa\r\n\r\nleft join {{ ref('clinical_concept_library__value_set_members') }} bb\r\non aa.concept_id = bb.concept_id\r\n\r\nleft join {{ ref('clinical_concept_library__coding_systems') }} cc\r\non bb.coding_system_id = cc.coding_system_id\r\n)\r\n\r\n\r\nselect *\r\nfrom value_set_member_relevant_fields", "language": "sql", "refs": [{"name": "clinical_concept_library__clinical_concepts", "package": null, "version": null}, {"name": "clinical_concept_library__value_set_members", "package": null, "version": null}, {"name": "clinical_concept_library__coding_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.clinical_concept_library__clinical_concepts", "seed.the_tuva_project.clinical_concept_library__value_set_members", "seed.the_tuva_project.clinical_concept_library__coding_systems"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\clinical_concept_library\\clinical_concept_library__value_set_member_relevant_fields.sql", "compiled": true, "compiled_code": "with value_set_member_relevant_fields as (\nselect \n aa.concept_id,\n aa.concept_name,\n aa.concept_type,\n \n bb.value_set_member_id,\n bb.code,\n bb.coding_system_id,\n bb.include_descendants,\n\n cc.coding_system_name\n \nfrom dev_thuxuan.clinical_concept_library.clinical_concepts aa\n\nleft join dev_thuxuan.clinical_concept_library.value_set_members bb\non aa.concept_id = bb.concept_id\n\nleft join dev_thuxuan.clinical_concept_library.coding_systems cc\non bb.coding_system_id = cc.coding_system_id\n)\n\n\nselect *\nfrom value_set_member_relevant_fields", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__patient_risk_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\final\\cms_hcc__patient_risk_factors.sql", "original_file_path": "models\\cms_hcc\\final\\cms_hcc__patient_risk_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_factors", "fqn": ["the_tuva_project", "cms_hcc", "final", "cms_hcc__patient_risk_factors"], "alias": "patient_risk_factors", "checksum": {"name": "sha256", "checksum": "3f9d22464422f4992bdd6615bafd03c09b7197b64fd2cc28f63f6dba61a0fd34"}, "config": {"enabled": true, "alias": "patient_risk_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "This final model displays the contributing demographic and disease risk factors, interactions, and HCCs for each enrollee in the payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status_default": {"name": "enrollment_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_dual_status_default": {"name": "medicaid_dual_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec_default": {"name": "orec_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status_default": {"name": "institutional_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "risk_factor_description": {"name": "risk_factor_description", "description": "Description of the risk factor.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "patient_risk_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7630055, "relation_name": "dev_thuxuan.cms_hcc.patient_risk_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nwith demographic_factors as (\r\n\r\n select\r\n patient_id\r\n /* concatenate demographic risk factors */\r\n\r\n , {{ dbt.concat(\r\n [\r\n \"gender\",\r\n \"', '\",\r\n \"age_group\",\r\n \"' Years'\",\r\n \"', '\",\r\n \"enrollment_status\",\r\n \"' Enrollee'\",\r\n \"', '\",\r\n \"CASE\"\r\n \" WHEN medicaid_status = 'Yes' THEN 'Medicaid'\"\r\n \" ELSE 'Non-Medicaid'\"\r\n \" END\",\r\n \"', '\",\r\n \"dual_status\",\r\n \"' Dual'\",\r\n \"', '\",\r\n \"orec\",\r\n \"', '\",\r\n \"CASE\"\r\n \" WHEN institutional_status = 'Yes' THEN 'Institutional'\"\r\n \" ELSE 'Non-Institutional'\"\r\n \" END\"\r\n ]\r\n ) }} as description\r\n\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, demographic_defaults as (\r\n\r\n select\r\n patient_id\r\n , model_version\r\n , enrollment_status_default\r\n , medicaid_dual_status_default\r\n , orec_default\r\n , institutional_status_default\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, disease_factors as (\r\n\r\n select\r\n patient_id\r\n , {{ dbt.concat([\"hcc_description\", \"' (HCC '\", \"hcc_code\", \"')'\"]) }} as description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_disease_factors') }}\r\n\r\n)\r\n\r\n, enrollment_interactions as (\r\n\r\n select\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_enrollment_interaction_factors') }}\r\n\r\n)\r\n\r\n, disabled_interactions as (\r\n\r\n select\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_disabled_interaction_factors') }}\r\n\r\n)\r\n\r\n, disease_interactions as (\r\n\r\n select\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_disease_interaction_factors') }}\r\n\r\n)\r\n\r\n, hcc_counts as (\r\n\r\n select\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_hcc_count_factors') }}\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from demographic_factors\r\n union all\r\n select * from disease_factors\r\n union all\r\n select * from enrollment_interactions\r\n union all\r\n select * from disabled_interactions\r\n union all\r\n select * from disease_interactions\r\n union all\r\n select * from hcc_counts\r\n\r\n)\r\n\r\n, add_defaults as (\r\n\r\n select\r\n unioned.patient_id\r\n , demographic_defaults.enrollment_status_default\r\n , demographic_defaults.medicaid_dual_status_default\r\n , demographic_defaults.orec_default\r\n , demographic_defaults.institutional_status_default\r\n , unioned.description as risk_factor_description\r\n , unioned.coefficient\r\n , unioned.factor_type\r\n , unioned.model_version\r\n , unioned.payment_year\r\n from unioned\r\n left join demographic_defaults\r\n on unioned.patient_id = demographic_defaults.patient_id\r\n and unioned.model_version = demographic_defaults.model_version\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n {% if target.type == 'fabric' %}\r\n , cast(enrollment_status_default as bit) as enrollment_status_default\r\n , cast(medicaid_dual_status_default as bit) as medicaid_dual_status_default\r\n , cast(orec_default as bit) as orec_default\r\n , cast(institutional_status_default as bit) as institutional_status_default\r\n {% else %}\r\n , cast(enrollment_status_default as boolean) as enrollment_status_default\r\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\r\n , cast(orec_default as boolean) as orec_default\r\n , cast(institutional_status_default as boolean) as institutional_status_default\r\n {% endif %}\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(risk_factor_description as {{ dbt.type_string() }}) as risk_factor_description\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from add_defaults\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , enrollment_status_default\r\n , medicaid_dual_status_default\r\n , orec_default\r\n , institutional_status_default\r\n , factor_type\r\n , risk_factor_description\r\n , coefficient\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_disease_factors", "package": null, "version": null}, {"name": "cms_hcc__int_enrollment_interaction_factors", "package": null, "version": null}, {"name": "cms_hcc__int_disabled_interaction_factors", "package": null, "version": null}, {"name": "cms_hcc__int_disease_interaction_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_count_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\final\\cms_hcc__patient_risk_factors.sql", "compiled": true, "compiled_code": "\nwith demographic_factors as (\n\n select\n patient_id\n /* concatenate demographic risk factors */\n\n , gender || ', ' || age_group || ' Years' || ', ' || enrollment_status || ' Enrollee' || ', ' || CASE WHEN medicaid_status = 'Yes' THEN 'Medicaid' ELSE 'Non-Medicaid' END || ', ' || dual_status || ' Dual' || ', ' || orec || ', ' || CASE WHEN institutional_status = 'Yes' THEN 'Institutional' ELSE 'Non-Institutional' END as description\n\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, demographic_defaults as (\n\n select\n patient_id\n , model_version\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, disease_factors as (\n\n select\n patient_id\n , hcc_description || ' (HCC ' || hcc_code || ')' as description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_disease_factors\n\n)\n\n, enrollment_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_enrollment_interaction_factors\n\n)\n\n, disabled_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_disabled_interaction_factors\n\n)\n\n, disease_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_disease_interaction_factors\n\n)\n\n, hcc_counts as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_hcc_count_factors\n\n)\n\n, unioned as (\n\n select * from demographic_factors\n union all\n select * from disease_factors\n union all\n select * from enrollment_interactions\n union all\n select * from disabled_interactions\n union all\n select * from disease_interactions\n union all\n select * from hcc_counts\n\n)\n\n, add_defaults as (\n\n select\n unioned.patient_id\n , demographic_defaults.enrollment_status_default\n , demographic_defaults.medicaid_dual_status_default\n , demographic_defaults.orec_default\n , demographic_defaults.institutional_status_default\n , unioned.description as risk_factor_description\n , unioned.coefficient\n , unioned.factor_type\n , unioned.model_version\n , unioned.payment_year\n from unioned\n left join demographic_defaults\n on unioned.patient_id = demographic_defaults.patient_id\n and unioned.model_version = demographic_defaults.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast(factor_type as TEXT) as factor_type\n , cast(risk_factor_description as TEXT) as risk_factor_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from add_defaults\n\n)\n\nselect\n patient_id\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , factor_type\n , risk_factor_description\n , coefficient\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__patient_risk_scores": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_scores", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\final\\cms_hcc__patient_risk_scores.sql", "original_file_path": "models\\cms_hcc\\final\\cms_hcc__patient_risk_scores.sql", "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_scores", "fqn": ["the_tuva_project", "cms_hcc", "final", "cms_hcc__patient_risk_scores"], "alias": "patient_risk_scores", "checksum": {"name": "sha256", "checksum": "ae3627e2a36bc674d230a3429157e722296b09dac92b6997880a1ae7cb03095c"}, "config": {"enabled": true, "alias": "patient_risk_scores", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "This final model calculates the CMS HCC raw risk score, blended risk score, normalized risk score, and payment risk score for each enrollee in the payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "v24_risk_score": {"name": "v24_risk_score", "description": "The sum of all patient risk factors from model version CMS-HCC-V24. If payment year >= 2024 then the score may be weighted following CMS's transition plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "v28_risk_score": {"name": "v28_risk_score", "description": "The sum of all patient risk factors from model version CMS-HCC-V28. If payment year >= 2024 then the score may be weighted following CMS's transition plan.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "blended_risk_score": {"name": "blended_risk_score", "description": "The of sum v24_risk_score and v28_risk_score.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_risk_score": {"name": "normalized_risk_score", "description": "The blended risk score divided by the normalization adjustment factor for the corresponding HCC model version and payment year's rate announcement from CMS.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_risk_score": {"name": "payment_risk_score", "description": "The normalized risk score multiplied by the MA coding pattern adjustment factor for the corresponding HCC model version and payment year's rate announcement from CMS.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_risk_score_weighted_by_months": {"name": "payment_risk_score_weighted_by_months", "description": "Payment risk score multiplied by member_months.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "Member months derived from the finanicial_pmpm mart utilizing payment year eligibility.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "patient_risk_scores", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7680054, "relation_name": "dev_thuxuan.cms_hcc.patient_risk_scores", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nwith seed_adjustment_rates as (\r\n\r\n select\r\n model_version\r\n , payment_year\r\n , normalization_factor\r\n , ma_coding_pattern_adjustment\r\n from {{ ref('cms_hcc__adjustment_rates') }}\r\n\r\n)\r\n\r\n, risk_factors as (\r\n\r\n select\r\n patient_id\r\n , coefficient\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__patient_risk_factors') }}\r\n\r\n)\r\n\r\n, member_months as (\r\n\r\n select\r\n patient_id\r\n , cast({{ substring('year_month', 1, 4) }} as integer) as eligible_year\r\n , COUNT(1) as member_months\r\n from {{ ref('cms_hcc__stg_core__member_months') }}\r\n group by\r\n patient_id\r\n , cast({{ substring('year_month', 1, 4) }} as integer)\r\n)\r\n\r\n, raw_score as (\r\n\r\n select\r\n patient_id\r\n , sum(coefficient) as risk_score\r\n , model_version\r\n , payment_year\r\n from risk_factors\r\n group by\r\n patient_id\r\n , model_version\r\n , payment_year\r\n\r\n)\r\n\r\n/*\r\n CMS Guidance for the transition from v24 to v28:\r\n\r\n PY2024 risk scores will be blended using 67% of the risk score calculated\r\n from v24 and 33% from v28.\r\n\r\n PY2025 risk scores will be blended using 33% of the risk score calculated\r\n from v24 and 67% from v28.\r\n\r\n PY2026 risk scores will be 100% from v28.\r\n\r\n Prior payment years will still be calculated from v24 only.\r\n*/\r\n, transition_scores as (\r\n\r\n select\r\n patient_id\r\n , risk_score\r\n , case\r\n when payment_year <= 2023 and model_version = 'CMS-HCC-V24' then risk_score\r\n when payment_year = 2024 and model_version = 'CMS-HCC-V24' then risk_score * 0.67\r\n when payment_year = 2025 and model_version = 'CMS-HCC-V24' then risk_score * 0.33\r\n when payment_year >= 2026 and model_version = 'CMS-HCC-V24' then 0\r\n end as v24_risk_score\r\n , case\r\n when payment_year <= 2023 and model_version = 'CMS-HCC-V28' then 0\r\n when payment_year = 2024 and model_version = 'CMS-HCC-V28' then risk_score * 0.33\r\n when payment_year = 2025 and model_version = 'CMS-HCC-V28' then risk_score * 0.67\r\n when payment_year >= 2026 and model_version = 'CMS-HCC-V28' then risk_score\r\n end as v28_risk_score\r\n , model_version\r\n , payment_year\r\n from raw_score\r\n\r\n)\r\n\r\n/*\r\n Grouping by patient to create a single row per patient.\r\n*/\r\n, transition_scores_grouped as (\r\n\r\n select\r\n patient_id\r\n , max(v24_risk_score) as v24_risk_score\r\n , max(v28_risk_score) as v28_risk_score\r\n , payment_year\r\n from transition_scores\r\n group by\r\n patient_id\r\n , payment_year\r\n\r\n)\r\n\r\n, blended as (\r\n\r\n select\r\n patient_id\r\n , v24_risk_score\r\n , v28_risk_score\r\n , v24_risk_score + v28_risk_score as blended_risk_score\r\n , payment_year\r\n from transition_scores_grouped\r\n\r\n)\r\n\r\n, normalized as (\r\n\r\n select\r\n blended.patient_id\r\n , blended.v24_risk_score\r\n , blended.v28_risk_score\r\n , blended.blended_risk_score\r\n , blended.blended_risk_score / seed_adjustment_rates.normalization_factor as normalized_risk_score\r\n , blended.payment_year\r\n from blended\r\n left join seed_adjustment_rates\r\n on blended.payment_year = seed_adjustment_rates.payment_year\r\n\r\n)\r\n\r\n, payment as (\r\n\r\n select\r\n normalized.patient_id\r\n , normalized.v24_risk_score\r\n , normalized.v28_risk_score\r\n , normalized.blended_risk_score\r\n , normalized.normalized_risk_score\r\n , normalized.normalized_risk_score * (1 - seed_adjustment_rates.ma_coding_pattern_adjustment) as payment_risk_score\r\n , normalized.payment_year\r\n from normalized\r\n left join seed_adjustment_rates\r\n on normalized.payment_year = seed_adjustment_rates.payment_year\r\n\r\n)\r\n\r\n, weighted_score as (\r\n\r\n select\r\n payment.patient_id\r\n , payment.v24_risk_score\r\n , payment.v28_risk_score\r\n , payment.blended_risk_score\r\n , payment.normalized_risk_score\r\n , payment.payment_risk_score\r\n , member_months.member_months\r\n , payment.payment_risk_score * member_months.member_months as payment_risk_score_weighted_by_months\r\n , payment.payment_year\r\n from payment\r\n left join member_months\r\n on payment.patient_id = member_months.patient_id\r\n and payment.payment_year = member_months.eligible_year\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , round(cast(v24_risk_score as {{ dbt.type_numeric() }}),3) as v24_risk_score\r\n , round(cast(v28_risk_score as {{ dbt.type_numeric() }}),3) as v28_risk_score\r\n , round(cast(blended_risk_score as {{ dbt.type_numeric() }}),3) as blended_risk_score\r\n , round(cast(normalized_risk_score as {{ dbt.type_numeric() }}),3) as normalized_risk_score\r\n , round(cast(payment_risk_score as {{ dbt.type_numeric() }}),3) as payment_risk_score\r\n , round(cast(payment_risk_score_weighted_by_months as {{ dbt.type_numeric() }}),3) as payment_risk_score_weighted_by_months\r\n , cast(member_months as integer) as member_months\r\n , cast(payment_year as integer) as payment_year\r\n from weighted_score\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , v24_risk_score\r\n , v28_risk_score\r\n , blended_risk_score\r\n , normalized_risk_score\r\n , payment_risk_score\r\n , payment_risk_score_weighted_by_months\r\n , member_months\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__adjustment_rates", "package": null, "version": null}, {"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}, {"name": "cms_hcc__stg_core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.substring", "macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["seed.the_tuva_project.cms_hcc__adjustment_rates", "model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.cms_hcc__stg_core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\final\\cms_hcc__patient_risk_scores.sql", "compiled": true, "compiled_code": "\nwith __dbt__cte___stg_member_months as (\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.member_months\n), seed_adjustment_rates as (\n\n select\n model_version\n , payment_year\n , normalization_factor\n , ma_coding_pattern_adjustment\n from dev_thuxuan.cms_hcc._value_set_adjustment_rates\n\n)\n\n, risk_factors as (\n\n select\n patient_id\n , coefficient\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc.patient_risk_factors\n\n)\n\n, member_months as (\n\n select\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer) as eligible_year\n , COUNT(1) as member_months\n from __dbt__cte___stg_member_months\n group by\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer)\n)\n\n, raw_score as (\n\n select\n patient_id\n , sum(coefficient) as risk_score\n , model_version\n , payment_year\n from risk_factors\n group by\n patient_id\n , model_version\n , payment_year\n\n)\n\n/*\n CMS Guidance for the transition from v24 to v28:\n\n PY2024 risk scores will be blended using 67% of the risk score calculated\n from v24 and 33% from v28.\n\n PY2025 risk scores will be blended using 33% of the risk score calculated\n from v24 and 67% from v28.\n\n PY2026 risk scores will be 100% from v28.\n\n Prior payment years will still be calculated from v24 only.\n*/\n, transition_scores as (\n\n select\n patient_id\n , risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V24' then risk_score\n when payment_year = 2024 and model_version = 'CMS-HCC-V24' then risk_score * 0.67\n when payment_year = 2025 and model_version = 'CMS-HCC-V24' then risk_score * 0.33\n when payment_year >= 2026 and model_version = 'CMS-HCC-V24' then 0\n end as v24_risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V28' then 0\n when payment_year = 2024 and model_version = 'CMS-HCC-V28' then risk_score * 0.33\n when payment_year = 2025 and model_version = 'CMS-HCC-V28' then risk_score * 0.67\n when payment_year >= 2026 and model_version = 'CMS-HCC-V28' then risk_score\n end as v28_risk_score\n , model_version\n , payment_year\n from raw_score\n\n)\n\n/*\n Grouping by patient to create a single row per patient.\n*/\n, transition_scores_grouped as (\n\n select\n patient_id\n , max(v24_risk_score) as v24_risk_score\n , max(v28_risk_score) as v28_risk_score\n , payment_year\n from transition_scores\n group by\n patient_id\n , payment_year\n\n)\n\n, blended as (\n\n select\n patient_id\n , v24_risk_score\n , v28_risk_score\n , v24_risk_score + v28_risk_score as blended_risk_score\n , payment_year\n from transition_scores_grouped\n\n)\n\n, normalized as (\n\n select\n blended.patient_id\n , blended.v24_risk_score\n , blended.v28_risk_score\n , blended.blended_risk_score\n , blended.blended_risk_score / seed_adjustment_rates.normalization_factor as normalized_risk_score\n , blended.payment_year\n from blended\n left join seed_adjustment_rates\n on blended.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, payment as (\n\n select\n normalized.patient_id\n , normalized.v24_risk_score\n , normalized.v28_risk_score\n , normalized.blended_risk_score\n , normalized.normalized_risk_score\n , normalized.normalized_risk_score * (1 - seed_adjustment_rates.ma_coding_pattern_adjustment) as payment_risk_score\n , normalized.payment_year\n from normalized\n left join seed_adjustment_rates\n on normalized.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, weighted_score as (\n\n select\n payment.patient_id\n , payment.v24_risk_score\n , payment.v28_risk_score\n , payment.blended_risk_score\n , payment.normalized_risk_score\n , payment.payment_risk_score\n , member_months.member_months\n , payment.payment_risk_score * member_months.member_months as payment_risk_score_weighted_by_months\n , payment.payment_year\n from payment\n left join member_months\n on payment.patient_id = member_months.patient_id\n and payment.payment_year = member_months.eligible_year\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(v24_risk_score as numeric(28,6)),3) as v24_risk_score\n , round(cast(v28_risk_score as numeric(28,6)),3) as v28_risk_score\n , round(cast(blended_risk_score as numeric(28,6)),3) as blended_risk_score\n , round(cast(normalized_risk_score as numeric(28,6)),3) as normalized_risk_score\n , round(cast(payment_risk_score as numeric(28,6)),3) as payment_risk_score\n , round(cast(payment_risk_score_weighted_by_months as numeric(28,6)),3) as payment_risk_score_weighted_by_months\n , cast(member_months as integer) as member_months\n , cast(payment_year as integer) as payment_year\n from weighted_score\n\n)\n\nselect\n patient_id\n , v24_risk_score\n , v28_risk_score\n , blended_risk_score\n , normalized_risk_score\n , payment_risk_score\n , payment_risk_score_weighted_by_months\n , member_months\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_hcc__stg_core__member_months", "sql": " __dbt__cte___stg_member_months as (\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.member_months\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_demographic_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_demographic_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_demographic_factors.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_demographic_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_demographic_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_demographic_factors"], "alias": "_int_demographic_factors", "checksum": {"name": "sha256", "checksum": "69be604dd7ffc31827fb4092ba399d6391f7e230c8dbed3dae9bac8938bd4148"}, "config": {"enabled": true, "alias": "_int_demographic_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Demographic and enrollment risk relative factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Indicates whether the patient is a \"Continuing\" or \"New\" enrollee.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Indicates whether the patient is \"Female\" or \"Male\".", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "Indicates what age group the patient is in. (e.g. \"60-64\"). CMS guidance: Age is calculated as of Feb 1 of the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Indicates whether the patient is enrolled in Medicaid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Indicates whether the patient has \"Full\", \"Partial\", or \"Non\" dual status.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Indicates the Original Reason for Entitlement Code (OREC) \"Aged\", \"Disabled\", or \"ESRD\".\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Indicates whether the patient resided in an institution for at least 90 days.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status_default": {"name": "enrollment_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_dual_status_default": {"name": "medicaid_dual_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec_default": {"name": "orec_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status_default": {"name": "institutional_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_demographic_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7711217, "relation_name": "dev_thuxuan.cms_hcc._int_demographic_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith members as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , enrollment_status_default\r\n , medicaid_dual_status_default\r\n , orec_default\r\n , institutional_status_default\r\n , payment_year\r\n from {{ ref('cms_hcc__int_members') }}\r\n\r\n)\r\n\r\n, seed_demographic_factors as (\r\n\r\n select\r\n model_version\r\n , factor_type\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , coefficient\r\n from {{ ref('cms_hcc__demographic_factors') }}\r\n where plan_segment is null /* data not available */\r\n\r\n)\r\n\r\n, v24_new_enrollees as (\r\n\r\n select\r\n members.patient_id\r\n , members.enrollment_status\r\n , members.gender\r\n , members.age_group\r\n , members.medicaid_status\r\n , members.dual_status\r\n , members.orec\r\n , members.institutional_status\r\n , members.enrollment_status_default\r\n , members.medicaid_dual_status_default\r\n , members.orec_default\r\n , members.institutional_status_default\r\n , members.payment_year\r\n , seed_demographic_factors.model_version\r\n , seed_demographic_factors.factor_type\r\n , seed_demographic_factors.coefficient\r\n from members\r\n inner join seed_demographic_factors\r\n on members.enrollment_status = seed_demographic_factors.enrollment_status\r\n and members.gender = seed_demographic_factors.gender\r\n and members.age_group = seed_demographic_factors.age_group\r\n and members.medicaid_status = seed_demographic_factors.medicaid_status\r\n and members.orec = seed_demographic_factors.orec\r\n where members.enrollment_status = 'New'\r\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\r\n\r\n)\r\n\r\n, v24_continuining_enrollees as (\r\n\r\n select\r\n members.patient_id\r\n , members.enrollment_status\r\n , members.gender\r\n , members.age_group\r\n , members.medicaid_status\r\n , members.dual_status\r\n , members.orec\r\n , members.institutional_status\r\n , members.enrollment_status_default\r\n , members.medicaid_dual_status_default\r\n , members.orec_default\r\n , members.institutional_status_default\r\n , members.payment_year\r\n , seed_demographic_factors.model_version\r\n , seed_demographic_factors.factor_type\r\n , seed_demographic_factors.coefficient\r\n from members\r\n inner join seed_demographic_factors\r\n on members.enrollment_status = seed_demographic_factors.enrollment_status\r\n and members.gender = seed_demographic_factors.gender\r\n and members.age_group = seed_demographic_factors.age_group\r\n and members.medicaid_status = seed_demographic_factors.medicaid_status\r\n and members.dual_status = seed_demographic_factors.dual_status\r\n and members.orec = seed_demographic_factors.orec\r\n and members.institutional_status = seed_demographic_factors.institutional_status\r\n where members.enrollment_status = 'Continuing'\r\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\r\n\r\n)\r\n\r\n, v28_new_enrollees as (\r\n\r\n select\r\n members.patient_id\r\n , members.enrollment_status\r\n , members.gender\r\n , members.age_group\r\n , members.medicaid_status\r\n , members.dual_status\r\n , members.orec\r\n , members.institutional_status\r\n , members.enrollment_status_default\r\n , members.medicaid_dual_status_default\r\n , members.orec_default\r\n , members.institutional_status_default\r\n , members.payment_year\r\n , seed_demographic_factors.model_version\r\n , seed_demographic_factors.factor_type\r\n , seed_demographic_factors.coefficient\r\n from members\r\n inner join seed_demographic_factors\r\n on members.enrollment_status = seed_demographic_factors.enrollment_status\r\n and members.gender = seed_demographic_factors.gender\r\n and members.age_group = seed_demographic_factors.age_group\r\n and members.medicaid_status = seed_demographic_factors.medicaid_status\r\n and members.orec = seed_demographic_factors.orec\r\n where members.enrollment_status = 'New'\r\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\r\n\r\n)\r\n\r\n, v28_continuining_enrollees as (\r\n\r\n select\r\n members.patient_id\r\n , members.enrollment_status\r\n , members.gender\r\n , members.age_group\r\n , members.medicaid_status\r\n , members.dual_status\r\n , members.orec\r\n , members.institutional_status\r\n , members.enrollment_status_default\r\n , members.medicaid_dual_status_default\r\n , members.orec_default\r\n , members.institutional_status_default\r\n , members.payment_year\r\n , seed_demographic_factors.model_version\r\n , seed_demographic_factors.factor_type\r\n , seed_demographic_factors.coefficient\r\n from members\r\n inner join seed_demographic_factors\r\n on members.enrollment_status = seed_demographic_factors.enrollment_status\r\n and members.gender = seed_demographic_factors.gender\r\n and members.age_group = seed_demographic_factors.age_group\r\n and members.medicaid_status = seed_demographic_factors.medicaid_status\r\n and members.dual_status = seed_demographic_factors.dual_status\r\n and members.orec = seed_demographic_factors.orec\r\n and members.institutional_status = seed_demographic_factors.institutional_status\r\n where members.enrollment_status = 'Continuing'\r\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from v24_new_enrollees\r\n union all\r\n select * from v24_continuining_enrollees\r\n union all\r\n select * from v28_new_enrollees\r\n union all\r\n select * from v28_continuining_enrollees\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(enrollment_status as {{ dbt.type_string() }}) as enrollment_status\r\n , cast(gender as {{ dbt.type_string() }}) as gender\r\n , cast(age_group as {{ dbt.type_string() }}) as age_group\r\n , cast(medicaid_status as {{ dbt.type_string() }}) as medicaid_status\r\n , cast(dual_status as {{ dbt.type_string() }}) as dual_status\r\n , cast(orec as {{ dbt.type_string() }}) as orec\r\n , cast(institutional_status as {{ dbt.type_string() }}) as institutional_status\r\n {% if target.type == 'fabric' %}\r\n , cast(enrollment_status_default as bit) as enrollment_status_default\r\n , cast(medicaid_dual_status_default as bit) as medicaid_dual_status_default\r\n , cast(orec_default as bit) as orec_default\r\n , cast(institutional_status_default as bit) as institutional_status_default\r\n {% else %}\r\n , cast(enrollment_status_default as boolean) as enrollment_status_default\r\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\r\n , cast(orec_default as boolean) as orec_default\r\n , cast(institutional_status_default as boolean) as institutional_status_default\r\n {% endif %}\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from unioned\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , enrollment_status_default\r\n , medicaid_dual_status_default\r\n , orec_default\r\n , institutional_status_default\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_members", "package": null, "version": null}, {"name": "cms_hcc__demographic_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_members", "seed.the_tuva_project.cms_hcc__demographic_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_demographic_factors.sql", "compiled": true, "compiled_code": "\n\nwith members as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n from dev_thuxuan.cms_hcc._int_members\n\n)\n\n, seed_demographic_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_demographic_factors\n where plan_segment is null /* data not available */\n\n)\n\n, v24_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v24_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v28_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, v28_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, unioned as (\n\n select * from v24_new_enrollees\n union all\n select * from v24_continuining_enrollees\n union all\n select * from v28_new_enrollees\n union all\n select * from v28_continuining_enrollees\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_disabled_interaction_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_disabled_interaction_factors.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_disabled_interaction_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_disabled_interaction_factors"], "alias": "_int_disabled_interaction_factors", "checksum": {"name": "sha256", "checksum": "bb7334a46c4c24e1b5ec730fea92ae01b26f86829fcd3b9c6f3cb214fcc23f5e"}, "config": {"enabled": true, "alias": "_int_disabled_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Disabled and disease interaction factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disabled and disease interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_disabled_interaction_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7741272, "relation_name": "dev_thuxuan.cms_hcc._int_disabled_interaction_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith demographics as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , institutional_status\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, hcc_hierarchy as (\r\n\r\n select\r\n patient_id\r\n , hcc_code\r\n , model_version\r\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\r\n\r\n)\r\n\r\n, seed_interaction_factors as (\r\n\r\n select\r\n model_version\r\n , factor_type\r\n , enrollment_status\r\n , institutional_status\r\n , short_name\r\n , description\r\n , hcc_code\r\n , coefficient\r\n from {{ ref('cms_hcc__disabled_interaction_factors') }}\r\n\r\n)\r\n\r\n, demographics_with_hccs as (\r\n\r\n select\r\n demographics.patient_id\r\n , demographics.enrollment_status\r\n , demographics.institutional_status\r\n , demographics.model_version\r\n , demographics.payment_year\r\n , hcc_hierarchy.hcc_code\r\n from demographics\r\n inner join hcc_hierarchy\r\n on demographics.patient_id = hcc_hierarchy.patient_id\r\n and demographics.model_version = hcc_hierarchy.model_version\r\n\r\n)\r\n\r\n, interactions as (\r\n\r\n select\r\n demographics_with_hccs.patient_id\r\n , demographics_with_hccs.model_version\r\n , demographics_with_hccs.payment_year\r\n , seed_interaction_factors.factor_type\r\n , seed_interaction_factors.description\r\n , seed_interaction_factors.coefficient\r\n from demographics_with_hccs\r\n inner join seed_interaction_factors\r\n on demographics_with_hccs.enrollment_status = seed_interaction_factors.enrollment_status\r\n and demographics_with_hccs.institutional_status = seed_interaction_factors.institutional_status\r\n and demographics_with_hccs.hcc_code = seed_interaction_factors.hcc_code\r\n and demographics_with_hccs.model_version = seed_interaction_factors.model_version\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\nselect\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(description as {{ dbt.type_string() }}) as description\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\nfrom interactions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}, {"name": "cms_hcc__disabled_interaction_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disabled_interaction_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_disabled_interaction_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , institutional_status\n , short_name\n , description\n , hcc_code\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_disabled_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors\n on demographics_with_hccs.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics_with_hccs.institutional_status = seed_interaction_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_interaction_factors.hcc_code\n and demographics_with_hccs.model_version = seed_interaction_factors.model_version\n\n)\n\n, add_data_types as (\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\nfrom interactions\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_disease_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_disease_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_disease_factors.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_disease_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_disease_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_disease_factors"], "alias": "_int_disease_factors", "checksum": {"name": "sha256", "checksum": "60cc48c746b9acb0f084556be562643b95bf8c385a39f02666dfd29d103b4d7c"}, "config": {"enabled": true, "alias": "_int_disease_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Disease factor values for every enrollee's final payment-eligible HCC after the hierarchy has been applied and necessary HCCs dropped for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_disease_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.776128, "relation_name": "dev_thuxuan.cms_hcc._int_disease_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith demographics as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, hcc_hierarchy as (\r\n\r\n select\r\n patient_id\r\n , hcc_code\r\n , model_version\r\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\r\n\r\n)\r\n\r\n, seed_disease_factors as (\r\n\r\n select\r\n model_version\r\n , factor_type\r\n , enrollment_status\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , hcc_code\r\n , description\r\n , coefficient\r\n from {{ ref('cms_hcc__disease_factors') }}\r\n\r\n)\r\n\r\n, demographics_with_hccs as (\r\n\r\n select\r\n demographics.patient_id\r\n , demographics.enrollment_status\r\n , demographics.gender\r\n , demographics.age_group\r\n , demographics.medicaid_status\r\n , demographics.dual_status\r\n , demographics.orec\r\n , demographics.institutional_status\r\n , demographics.model_version\r\n , demographics.payment_year\r\n , hcc_hierarchy.hcc_code\r\n from demographics\r\n inner join hcc_hierarchy\r\n on demographics.patient_id = hcc_hierarchy.patient_id\r\n and demographics.model_version = hcc_hierarchy.model_version\r\n\r\n)\r\n\r\n, disease_factors as (\r\n\r\n select\r\n demographics_with_hccs.patient_id\r\n , demographics_with_hccs.hcc_code\r\n , demographics_with_hccs.model_version\r\n , demographics_with_hccs.payment_year\r\n , seed_disease_factors.factor_type\r\n , seed_disease_factors.description\r\n , seed_disease_factors.coefficient\r\n from demographics_with_hccs\r\n inner join seed_disease_factors\r\n on demographics_with_hccs.enrollment_status = seed_disease_factors.enrollment_status\r\n and demographics_with_hccs.medicaid_status = seed_disease_factors.medicaid_status\r\n and demographics_with_hccs.dual_status = seed_disease_factors.dual_status\r\n and demographics_with_hccs.orec = seed_disease_factors.orec\r\n and demographics_with_hccs.institutional_status = seed_disease_factors.institutional_status\r\n and demographics_with_hccs.hcc_code = seed_disease_factors.hcc_code\r\n and demographics_with_hccs.model_version = seed_disease_factors.model_version\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(description as {{ dbt.type_string() }}) as hcc_description\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from disease_factors\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , hcc_code\r\n , hcc_description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}, {"name": "cms_hcc__disease_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_disease_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_disease_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , hcc_code\n , description\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_disease_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.gender\n , demographics.age_group\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, disease_factors as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.hcc_code\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_disease_factors.factor_type\n , seed_disease_factors.description\n , seed_disease_factors.coefficient\n from demographics_with_hccs\n inner join seed_disease_factors\n on demographics_with_hccs.enrollment_status = seed_disease_factors.enrollment_status\n and demographics_with_hccs.medicaid_status = seed_disease_factors.medicaid_status\n and demographics_with_hccs.dual_status = seed_disease_factors.dual_status\n and demographics_with_hccs.orec = seed_disease_factors.orec\n and demographics_with_hccs.institutional_status = seed_disease_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_disease_factors.hcc_code\n and demographics_with_hccs.model_version = seed_disease_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(description as TEXT) as hcc_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_factors\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_disease_interaction_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_disease_interaction_factors.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_disease_interaction_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_disease_interaction_factors"], "alias": "_int_disease_interaction_factors", "checksum": {"name": "sha256", "checksum": "77782562a534045d65be9e12788f9a96823f349ae7654c3ff6780ce1e7248062"}, "config": {"enabled": true, "alias": "_int_disease_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Disease interaction factor values for final payment-eligible HCC after the hierarchy has been applied and necessary HCCs dropped for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_1": {"name": "hcc_code_1", "description": "HCC code 1 of the interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_2": {"name": "hcc_code_2", "description": "HCC code 2 of the interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disease interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_disease_interaction_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7791278, "relation_name": "dev_thuxuan.cms_hcc._int_disease_interaction_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith demographics as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, hcc_hierarchy as (\r\n\r\n select\r\n patient_id\r\n , hcc_code\r\n , model_version\r\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\r\n\r\n)\r\n\r\n, seed_interaction_factors as (\r\n\r\n select\r\n model_version\r\n , factor_type\r\n , enrollment_status\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , short_name\r\n , description\r\n , hcc_code_1\r\n , hcc_code_2\r\n , coefficient\r\n from {{ ref('cms_hcc__disease_interaction_factors') }}\r\n\r\n)\r\n\r\n, demographics_with_hccs as (\r\n\r\n select\r\n demographics.patient_id\r\n , demographics.enrollment_status\r\n , demographics.medicaid_status\r\n , demographics.dual_status\r\n , demographics.orec\r\n , demographics.institutional_status\r\n , demographics.model_version\r\n , demographics.payment_year\r\n , hcc_hierarchy.hcc_code\r\n from demographics\r\n inner join hcc_hierarchy\r\n on demographics.patient_id = hcc_hierarchy.patient_id\r\n and demographics.model_version = hcc_hierarchy.model_version\r\n\r\n)\r\n\r\n, demographics_with_interactions as (\r\n\r\n select\r\n demographics_with_hccs.patient_id\r\n , demographics_with_hccs.model_version\r\n , demographics_with_hccs.payment_year\r\n , interactions_code_1.factor_type\r\n , interactions_code_1.description\r\n , interactions_code_1.hcc_code_1\r\n , interactions_code_1.hcc_code_2\r\n , interactions_code_1.coefficient\r\n from demographics_with_hccs\r\n inner join seed_interaction_factors as interactions_code_1\r\n on demographics_with_hccs.enrollment_status = interactions_code_1.enrollment_status\r\n and demographics_with_hccs.medicaid_status = interactions_code_1.medicaid_status\r\n and demographics_with_hccs.dual_status = interactions_code_1.dual_status\r\n and demographics_with_hccs.orec = interactions_code_1.orec\r\n and demographics_with_hccs.institutional_status = interactions_code_1.institutional_status\r\n and demographics_with_hccs.hcc_code = interactions_code_1.hcc_code_1\r\n and demographics_with_hccs.model_version = interactions_code_1.model_version\r\n\r\n)\r\n\r\n, disease_interactions as (\r\n\r\n select\r\n demographics_with_interactions.patient_id\r\n , demographics_with_interactions.factor_type\r\n , demographics_with_interactions.hcc_code_1\r\n , demographics_with_interactions.hcc_code_2\r\n , demographics_with_interactions.description\r\n , demographics_with_interactions.coefficient\r\n , demographics_with_interactions.model_version\r\n , demographics_with_interactions.payment_year\r\n from demographics_with_interactions\r\n inner join demographics_with_hccs as interactions_code_2\r\n on demographics_with_interactions.patient_id = interactions_code_2.patient_id\r\n and demographics_with_interactions.hcc_code_2 = interactions_code_2.hcc_code\r\n and demographics_with_interactions.model_version = interactions_code_2.model_version\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(hcc_code_1 as {{ dbt.type_string() }}) as hcc_code_1\r\n , cast(hcc_code_2 as {{ dbt.type_string() }}) as hcc_code_2\r\n , cast(description as {{ dbt.type_string() }}) as description\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from disease_interactions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , hcc_code_1\r\n , hcc_code_2\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}, {"name": "cms_hcc__disease_interaction_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_interaction_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_disease_interaction_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , short_name\n , description\n , hcc_code_1\n , hcc_code_2\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_disease_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, demographics_with_interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , interactions_code_1.factor_type\n , interactions_code_1.description\n , interactions_code_1.hcc_code_1\n , interactions_code_1.hcc_code_2\n , interactions_code_1.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors as interactions_code_1\n on demographics_with_hccs.enrollment_status = interactions_code_1.enrollment_status\n and demographics_with_hccs.medicaid_status = interactions_code_1.medicaid_status\n and demographics_with_hccs.dual_status = interactions_code_1.dual_status\n and demographics_with_hccs.orec = interactions_code_1.orec\n and demographics_with_hccs.institutional_status = interactions_code_1.institutional_status\n and demographics_with_hccs.hcc_code = interactions_code_1.hcc_code_1\n and demographics_with_hccs.model_version = interactions_code_1.model_version\n\n)\n\n, disease_interactions as (\n\n select\n demographics_with_interactions.patient_id\n , demographics_with_interactions.factor_type\n , demographics_with_interactions.hcc_code_1\n , demographics_with_interactions.hcc_code_2\n , demographics_with_interactions.description\n , demographics_with_interactions.coefficient\n , demographics_with_interactions.model_version\n , demographics_with_interactions.payment_year\n from demographics_with_interactions\n inner join demographics_with_hccs as interactions_code_2\n on demographics_with_interactions.patient_id = interactions_code_2.patient_id\n and demographics_with_interactions.hcc_code_2 = interactions_code_2.hcc_code\n and demographics_with_interactions.model_version = interactions_code_2.model_version\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code_1 as TEXT) as hcc_code_1\n , cast(hcc_code_2 as TEXT) as hcc_code_2\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_interactions\n\n)\n\nselect\n patient_id\n , hcc_code_1\n , hcc_code_2\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_eligible_conditions": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_eligible_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_eligible_conditions.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_eligible_conditions.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_eligible_conditions", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_eligible_conditions"], "alias": "_int_eligible_conditions", "checksum": {"name": "sha256", "checksum": "bc7cbc2ed90d1ac496ef551125042a906f7ece0111c3cb28e466bd54b98020b0"}, "config": {"enabled": true, "alias": "_int_eligible_conditions", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Conditions from eligible risk-adjustable claims per claim type for the collection year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_code": {"name": "condition_code", "description": "The condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_eligible_conditions", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7811282, "relation_name": "dev_thuxuan.cms_hcc._int_eligible_conditions", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n/*\r\nSteps for staging condition data:\r\n 1) Filter to risk-adjustable claims per claim type for the collection year.\r\n 2) Gather diagnosis codes from condition for the eligible claims.\r\n 3) Map and filter diagnosis codes to HCCs\r\n\r\nClaims filtering logic:\r\n - Professional:\r\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\r\n - Inpatient:\r\n - Bill type code in (11X, 41X)\r\n - Outpatient:\r\n - Bill type code in (12X, 13X, 43X, 71X, 73X, 76X, 77X, 85X)\r\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\r\n\r\nJinja is used to set payment year variable.\r\n - The payment_year var has been set here so it gets compiled.\r\n - The collection year is one year prior to the payment year.\r\n*/\r\n\r\n{% set payment_year = var('cms_hcc_payment_year') | int() -%}\r\n{% set collection_year = payment_year - 1 -%}\r\n\r\nwith medical_claims as (\r\n\r\n select\r\n claim_id\r\n , claim_line_number\r\n , claim_type\r\n , patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , bill_type_code\r\n , hcpcs_code\r\n from {{ ref('cms_hcc__stg_core__medical_claim') }}\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n claim_id\r\n , patient_id\r\n , code\r\n from {{ ref('cms_hcc__stg_core__condition') }}\r\n where code_type = 'icd-10-cm'\r\n\r\n)\r\n\r\n, cpt_hcpcs_list as (\r\n\r\n select\r\n payment_year\r\n , hcpcs_cpt_code\r\n from {{ ref('cms_hcc__cpt_hcpcs') }}\r\n\r\n)\r\n\r\n, professional_claims as (\r\n\r\n select\r\n medical_claims.claim_id\r\n , medical_claims.claim_line_number\r\n , medical_claims.claim_type\r\n , medical_claims.patient_id\r\n , medical_claims.claim_start_date\r\n , medical_claims.claim_end_date\r\n , medical_claims.bill_type_code\r\n , medical_claims.hcpcs_code\r\n from medical_claims\r\n inner join cpt_hcpcs_list\r\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\r\n where claim_type = 'professional'\r\n and {{ date_part('year', 'claim_end_date') }} = {{ collection_year }}\r\n and cpt_hcpcs_list.payment_year = {{ payment_year }}\r\n\r\n)\r\n\r\n\r\n, inpatient_claims as (\r\n\r\n select\r\n medical_claims.claim_id\r\n , medical_claims.claim_line_number\r\n , medical_claims.claim_type\r\n , medical_claims.patient_id\r\n , medical_claims.claim_start_date\r\n , medical_claims.claim_end_date\r\n , medical_claims.bill_type_code\r\n , medical_claims.hcpcs_code\r\n from medical_claims\r\n where claim_type = 'institutional'\r\n {% if target.type == 'fabric' %}\r\n and YEAR(claim_end_date) = {{ collection_year }}\r\n {% else %}\r\n and extract(year from claim_end_date) = {{ collection_year }}\r\n {% endif %}\r\n and substring(bill_type_code, 1, 2) in ('11','41')\r\n\r\n)\r\n\r\n, outpatient_claims as (\r\n\r\n select\r\n medical_claims.claim_id\r\n , medical_claims.claim_line_number\r\n , medical_claims.claim_type\r\n , medical_claims.patient_id\r\n , medical_claims.claim_start_date\r\n , medical_claims.claim_end_date\r\n , medical_claims.bill_type_code\r\n , medical_claims.hcpcs_code\r\n from medical_claims\r\n inner join cpt_hcpcs_list\r\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\r\n where claim_type = 'institutional'\r\n {% if target.type == 'fabric' %}\r\n and YEAR(claim_end_date) = {{ collection_year }}\r\n {% else %}\r\n and extract(year from claim_end_date) = {{ collection_year }}\r\n {% endif %}\r\n and cpt_hcpcs_list.payment_year = {{ payment_year }}\r\n and substring(bill_type_code, 1, 2) in ('12','13','43','71','73','76','77','85')\r\n\r\n)\r\n\r\n, eligible_claims as (\r\n\r\n select * from professional_claims\r\n union all\r\n select * from inpatient_claims\r\n union all\r\n select * from outpatient_claims\r\n\r\n)\r\n\r\n, eligible_conditions as (\r\n\r\n select distinct\r\n eligible_claims.claim_id\r\n , eligible_claims.patient_id\r\n , conditions.code\r\n from eligible_claims\r\n inner join conditions\r\n on eligible_claims.claim_id = conditions.claim_id\r\n and eligible_claims.patient_id = conditions.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(code as {{ dbt.type_string() }}) as condition_code\r\n , cast('{{ payment_year }}' as integer) as payment_year\r\n from eligible_conditions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , condition_code\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__stg_core__medical_claim", "package": null, "version": null}, {"name": "cms_hcc__stg_core__condition", "package": null, "version": null}, {"name": "cms_hcc__cpt_hcpcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__stg_core__medical_claim", "model.the_tuva_project.cms_hcc__stg_core__condition", "seed.the_tuva_project.cms_hcc__cpt_hcpcs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_eligible_conditions.sql", "compiled": true, "compiled_code": "\n/*\nSteps for staging condition data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs\n\nClaims filtering logic:\n - Professional:\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n - Inpatient:\n - Bill type code in (11X, 41X)\n - Outpatient:\n - Bill type code in (12X, 13X, 43X, 71X, 73X, 76X, 77X, 85X)\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - The collection year is one year prior to the payment year.\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), medical_claims as (\n\n select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, conditions as (\n\n select\n claim_id\n , patient_id\n , code\n from __dbt__cte___stg_condition\n where code_type = 'icd-10-cm'\n\n)\n\n, cpt_hcpcs_list as (\n\n select\n payment_year\n , hcpcs_cpt_code\n from dev_thuxuan.cms_hcc._value_set_cpt_hcpcs\n\n)\n\n, professional_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'professional'\n and date_part('year', claim_end_date) = 2023\n and cpt_hcpcs_list.payment_year = 2024\n\n)\n\n\n, inpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and substring(bill_type_code, 1, 2) in ('11','41')\n\n)\n\n, outpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and cpt_hcpcs_list.payment_year = 2024\n and substring(bill_type_code, 1, 2) in ('12','13','43','71','73','76','77','85')\n\n)\n\n, eligible_claims as (\n\n select * from professional_claims\n union all\n select * from inpatient_claims\n union all\n select * from outpatient_claims\n\n)\n\n, eligible_conditions as (\n\n select distinct\n eligible_claims.claim_id\n , eligible_claims.patient_id\n , conditions.code\n from eligible_claims\n inner join conditions\n on eligible_claims.claim_id = conditions.claim_id\n and eligible_claims.patient_id = conditions.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(code as TEXT) as condition_code\n , cast('2024' as integer) as payment_year\n from eligible_conditions\n\n)\n\nselect\n patient_id\n , condition_code\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n)"}, {"id": "model.the_tuva_project.cms_hcc__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_enrollment_interaction_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_enrollment_interaction_factors.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_enrollment_interaction_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_enrollment_interaction_factors"], "alias": "_int_enrollment_interaction_factors", "checksum": {"name": "sha256", "checksum": "1da4291b9f54c5779672c3849bf0113ca14c1b9589d340e7e227ed4022b2ba78"}, "config": {"enabled": true, "alias": "_int_enrollment_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Enrollment interaction factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the enrollment interaction.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_enrollment_interaction_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.784128, "relation_name": "dev_thuxuan.cms_hcc._int_enrollment_interaction_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith demographics as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, seed_interaction_factors as (\r\n\r\n select\r\n model_version\r\n , factor_type\r\n , gender\r\n , enrollment_status\r\n , medicaid_status\r\n , dual_status\r\n , institutional_status\r\n , description\r\n , coefficient\r\n from {{ ref('cms_hcc__enrollment_interaction_factors') }}\r\n\r\n)\r\n\r\n/*\r\n Originally disabled interactions for non-institutional members >= 65\r\n*/\r\n, non_institutional_interactions as (\r\n\r\n select\r\n demographics.patient_id\r\n , demographics.model_version\r\n , demographics.payment_year\r\n , seed_interaction_factors.factor_type\r\n , seed_interaction_factors.description\r\n , seed_interaction_factors.coefficient\r\n from demographics\r\n inner join seed_interaction_factors\r\n on demographics.gender = seed_interaction_factors.gender\r\n and demographics.enrollment_status = seed_interaction_factors.enrollment_status\r\n and demographics.medicaid_status = seed_interaction_factors.medicaid_status\r\n and demographics.dual_status = seed_interaction_factors.dual_status\r\n and demographics.institutional_status = seed_interaction_factors.institutional_status\r\n and demographics.model_version = seed_interaction_factors.model_version\r\n where demographics.institutional_status = 'No'\r\n and demographics.orec = 'Disabled'\r\n and demographics.age_group in (\r\n '65-69'\r\n , '70-74'\r\n , '75-79'\r\n , '80-84'\r\n , '85-89'\r\n , '90-94'\r\n , '>=95'\r\n )\r\n\r\n)\r\n\r\n/*\r\n Medicaid interactions for institutional members\r\n*/\r\n, institutional_interactions as (\r\n\r\n select\r\n demographics.patient_id\r\n , demographics.model_version\r\n , demographics.payment_year\r\n , seed_interaction_factors.factor_type\r\n , seed_interaction_factors.description\r\n , seed_interaction_factors.coefficient\r\n from demographics\r\n inner join seed_interaction_factors\r\n on demographics.enrollment_status = seed_interaction_factors.enrollment_status\r\n and demographics.institutional_status = seed_interaction_factors.institutional_status\r\n and demographics.model_version = seed_interaction_factors.model_version\r\n where demographics.institutional_status = 'Yes'\r\n and demographics.medicaid_status = 'Yes'\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from non_institutional_interactions\r\n union all\r\n select * from institutional_interactions\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(description as {{ dbt.type_string() }}) as description\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from unioned\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__enrollment_interaction_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_enrollment_interaction_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , gender\n , enrollment_status\n , medicaid_status\n , dual_status\n , institutional_status\n , description\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_enrollment_interaction_factors\n\n)\n\n/*\n Originally disabled interactions for non-institutional members >= 65\n*/\n, non_institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.gender = seed_interaction_factors.gender\n and demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.medicaid_status = seed_interaction_factors.medicaid_status\n and demographics.dual_status = seed_interaction_factors.dual_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'No'\n and demographics.orec = 'Disabled'\n and demographics.age_group in (\n '65-69'\n , '70-74'\n , '75-79'\n , '80-84'\n , '85-89'\n , '90-94'\n , '>=95'\n )\n\n)\n\n/*\n Medicaid interactions for institutional members\n*/\n, institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'Yes'\n and demographics.medicaid_status = 'Yes'\n\n)\n\n, unioned as (\n\n select * from non_institutional_interactions\n union all\n select * from institutional_interactions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_hcc_count_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_hcc_count_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_hcc_count_factors.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_hcc_count_factors.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_count_factors", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_hcc_count_factors"], "alias": "_int_hcc_count_factors", "checksum": {"name": "sha256", "checksum": "57f02526327cfa6caad5937fc0bdbab5f920ddc66be0eb606788ea916a572a29"}, "config": {"enabled": true, "alias": "_int_hcc_count_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Final payment-eligible HCC count factor values for the corresponding HCC model version and payment year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "HCC counts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Relative factor value that correspond to the CMS HCC model's risk indicators.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of risk factor, e.g. Demographic, Disease, etc.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_hcc_count_factors", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.786128, "relation_name": "dev_thuxuan.cms_hcc._int_hcc_count_factors", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith demographics as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_demographic_factors') }}\r\n\r\n)\r\n\r\n, seed_payment_hcc_count_factors as (\r\n\r\n select\r\n model_version\r\n , factor_type\r\n , enrollment_status\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , payment_hcc_count\r\n , description\r\n , coefficient\r\n from {{ ref('cms_hcc__payment_hcc_count_factors') }}\r\n\r\n)\r\n\r\n, hcc_hierarchy as (\r\n\r\n select\r\n patient_id\r\n , hcc_code\r\n , model_version\r\n from {{ ref('cms_hcc__int_hcc_hierarchy') }}\r\n\r\n)\r\n\r\n, demographics_with_hcc_counts as (\r\n\r\n select\r\n demographics.patient_id\r\n , demographics.enrollment_status\r\n , demographics.medicaid_status\r\n , demographics.dual_status\r\n , demographics.orec\r\n , demographics.institutional_status\r\n , demographics.model_version\r\n , demographics.payment_year\r\n , count(hcc_hierarchy.hcc_code) as hcc_count\r\n from demographics\r\n inner join hcc_hierarchy\r\n on demographics.patient_id = hcc_hierarchy.patient_id\r\n and demographics.model_version = hcc_hierarchy.model_version\r\n group by\r\n demographics.patient_id\r\n , demographics.enrollment_status\r\n , demographics.medicaid_status\r\n , demographics.dual_status\r\n , demographics.orec\r\n , demographics.institutional_status\r\n , demographics.model_version\r\n , demographics.payment_year\r\n\r\n)\r\n\r\n, hcc_counts_normalized as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , model_version\r\n , payment_year\r\n , case\r\n when hcc_count >= 10 then '>=10'\r\n else cast(hcc_count as {{ dbt.type_string() }})\r\n end as hcc_count_string\r\n from demographics_with_hcc_counts\r\n\r\n)\r\n\r\n, hcc_counts as (\r\n\r\n select\r\n hcc_counts_normalized.patient_id\r\n , hcc_counts_normalized.model_version\r\n , hcc_counts_normalized.payment_year\r\n , seed_payment_hcc_count_factors.factor_type\r\n , seed_payment_hcc_count_factors.description\r\n , seed_payment_hcc_count_factors.coefficient\r\n from hcc_counts_normalized\r\n inner join seed_payment_hcc_count_factors\r\n on hcc_counts_normalized.enrollment_status = seed_payment_hcc_count_factors.enrollment_status\r\n and hcc_counts_normalized.medicaid_status = seed_payment_hcc_count_factors.medicaid_status\r\n and hcc_counts_normalized.dual_status = seed_payment_hcc_count_factors.dual_status\r\n and hcc_counts_normalized.orec = seed_payment_hcc_count_factors.orec\r\n and hcc_counts_normalized.institutional_status = seed_payment_hcc_count_factors.institutional_status\r\n and hcc_counts_normalized.hcc_count_string = seed_payment_hcc_count_factors.payment_hcc_count\r\n and hcc_counts_normalized.model_version = seed_payment_hcc_count_factors.model_version\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(description as {{ dbt.type_string() }}) as description\r\n , round(cast(coefficient as {{ dbt.type_numeric() }}),3) as coefficient\r\n , cast(factor_type as {{ dbt.type_string() }}) as factor_type\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from hcc_counts\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , description\r\n , coefficient\r\n , factor_type\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}, {"name": "cms_hcc__payment_hcc_count_factors", "package": null, "version": null}, {"name": "cms_hcc__int_hcc_hierarchy", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_hcc_count_factors.sql", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, seed_payment_hcc_count_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , payment_hcc_count\n , description\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_payment_hcc_count_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, demographics_with_hcc_counts as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , count(hcc_hierarchy.hcc_code) as hcc_count\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n group by\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n\n)\n\n, hcc_counts_normalized as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n , case\n when hcc_count >= 10 then '>=10'\n else cast(hcc_count as TEXT)\n end as hcc_count_string\n from demographics_with_hcc_counts\n\n)\n\n, hcc_counts as (\n\n select\n hcc_counts_normalized.patient_id\n , hcc_counts_normalized.model_version\n , hcc_counts_normalized.payment_year\n , seed_payment_hcc_count_factors.factor_type\n , seed_payment_hcc_count_factors.description\n , seed_payment_hcc_count_factors.coefficient\n from hcc_counts_normalized\n inner join seed_payment_hcc_count_factors\n on hcc_counts_normalized.enrollment_status = seed_payment_hcc_count_factors.enrollment_status\n and hcc_counts_normalized.medicaid_status = seed_payment_hcc_count_factors.medicaid_status\n and hcc_counts_normalized.dual_status = seed_payment_hcc_count_factors.dual_status\n and hcc_counts_normalized.orec = seed_payment_hcc_count_factors.orec\n and hcc_counts_normalized.institutional_status = seed_payment_hcc_count_factors.institutional_status\n and hcc_counts_normalized.hcc_count_string = seed_payment_hcc_count_factors.payment_hcc_count\n and hcc_counts_normalized.model_version = seed_payment_hcc_count_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from hcc_counts\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_hcc_hierarchy", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_hcc_hierarchy.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_hcc_hierarchy.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_hcc_hierarchy"], "alias": "_int_hcc_hierarchy", "checksum": {"name": "sha256", "checksum": "f47263e7e8e60e98764011666f8b61adb8c85f3ce58114b85171c23c599cffc9"}, "config": {"enabled": true, "alias": "_int_hcc_hierarchy", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "HCC hierarchy for the corresponding HCC model version and payment year applied to the mapped payment-eligible HCCs.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_hcc_hierarchy", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7891276, "relation_name": "dev_thuxuan.cms_hcc._int_hcc_hierarchy", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n/*\r\n Staging HCCs that will be used in disease factor calculations.\r\n Final output for each CMS model version includes:\r\n - hccs without a hierarchy\r\n - lower-level hccs with hierarchy where top-level hcc is missing\r\n - top-level hccs from hierarchy\r\n*/\r\n\r\nwith hcc_mapping as (\r\n\r\n select distinct\r\n patient_id\r\n , hcc_code\r\n , model_version\r\n , payment_year\r\n from {{ ref('cms_hcc__int_hcc_mapping') }}\r\n\r\n)\r\n\r\n, seed_hcc_hierarchy as (\r\n\r\n select\r\n model_version\r\n , hcc_code\r\n , description\r\n , hccs_to_exclude\r\n from {{ ref('cms_hcc__disease_hierarchy') }}\r\n\r\n)\r\n\r\n/*\r\n selecting hccs that do not have a hierarchy\r\n all codes in this cte are included in final output\r\n*/\r\n, hccs_without_hierarchy as (\r\n\r\n select distinct\r\n hcc_mapping.patient_id\r\n , hcc_mapping.model_version\r\n , hcc_mapping.payment_year\r\n , hcc_mapping.hcc_code\r\n from hcc_mapping\r\n left join seed_hcc_hierarchy as hcc_top_level\r\n on hcc_mapping.hcc_code = hcc_top_level.hcc_code\r\n and hcc_mapping.model_version = hcc_top_level.model_version\r\n left join seed_hcc_hierarchy as hcc_exclusions\r\n on hcc_mapping.hcc_code = hcc_exclusions.hccs_to_exclude\r\n and hcc_mapping.model_version = hcc_exclusions.model_version\r\n where hcc_top_level.hcc_code is null\r\n and hcc_exclusions.hccs_to_exclude is null\r\n\r\n)\r\n\r\n/*\r\n selecting hccs that have a hierarchy to be evaluated in the next cte\r\n*/\r\n, hccs_with_hierarchy as (\r\n\r\n select\r\n hcc_mapping.patient_id\r\n , hcc_mapping.model_version\r\n , hcc_mapping.payment_year\r\n , hcc_mapping.hcc_code\r\n , seed_hcc_hierarchy.hcc_code as top_level_hcc\r\n from hcc_mapping\r\n inner join seed_hcc_hierarchy\r\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hccs_to_exclude\r\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\r\n\r\n)\r\n\r\n/*\r\n applying hcc hierarchy and grouping by patient and hcc\r\n to account for multiple hcc combinations\r\n minimum HCC is included following CMS's severity logic\r\n*/\r\n, hierarchy_applied as (\r\n\r\n select\r\n hccs_with_hierarchy.patient_id\r\n , hccs_with_hierarchy.model_version\r\n , hccs_with_hierarchy.payment_year\r\n , hccs_with_hierarchy.hcc_code\r\n , min(hcc_mapping.hcc_code) as top_level_hcc\r\n from hccs_with_hierarchy\r\n left join hcc_mapping\r\n on hcc_mapping.patient_id = hccs_with_hierarchy.patient_id\r\n and hcc_mapping.hcc_code = hccs_with_hierarchy.top_level_hcc\r\n and hcc_mapping.model_version = hccs_with_hierarchy.model_version\r\n group by\r\n hccs_with_hierarchy.patient_id\r\n , hccs_with_hierarchy.model_version\r\n , hccs_with_hierarchy.payment_year\r\n , hccs_with_hierarchy.hcc_code\r\n\r\n)\r\n\r\n/*\r\n selecting lower-level hccs in hierarchy\r\n all codes in this cte are included in final output\r\n*/\r\n, lower_level_inclusions as (\r\n\r\n select distinct\r\n patient_id\r\n , model_version\r\n , payment_year\r\n , case\r\n when top_level_hcc is not null then top_level_hcc\r\n else hcc_code\r\n end as hcc_code\r\n from hierarchy_applied\r\n\r\n)\r\n\r\n/*\r\n selecting top-level hccs not in previous steps\r\n all codes in this cte are included in final output\r\n*/\r\n, top_level_inclusions as (\r\n\r\n select distinct\r\n hcc_mapping.patient_id\r\n , hcc_mapping.model_version\r\n , hcc_mapping.payment_year\r\n , hcc_mapping.hcc_code\r\n from hcc_mapping\r\n inner join seed_hcc_hierarchy\r\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hcc_code\r\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\r\n left join lower_level_inclusions\r\n on hcc_mapping.patient_id = lower_level_inclusions.patient_id\r\n and hcc_mapping.hcc_code = lower_level_inclusions.hcc_code\r\n and hcc_mapping.model_version = lower_level_inclusions.model_version\r\n left join hierarchy_applied\r\n on hcc_mapping.patient_id = hierarchy_applied.patient_id\r\n and hcc_mapping.hcc_code = hierarchy_applied.hcc_code\r\n and hcc_mapping.model_version = hierarchy_applied.model_version\r\n where lower_level_inclusions.hcc_code is null\r\n and hierarchy_applied.top_level_hcc is null\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from hccs_without_hierarchy\r\n union all\r\n select * from lower_level_inclusions\r\n union all\r\n select * from top_level_inclusions\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n from unioned\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , model_version\r\n , payment_year\r\n , hcc_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_hcc_mapping", "package": null, "version": null}, {"name": "cms_hcc__disease_hierarchy", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__int_hcc_mapping", "seed.the_tuva_project.cms_hcc__disease_hierarchy"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_hcc_hierarchy.sql", "compiled": true, "compiled_code": "\n/*\n Staging HCCs that will be used in disease factor calculations.\n Final output for each CMS model version includes:\n - hccs without a hierarchy\n - lower-level hccs with hierarchy where top-level hcc is missing\n - top-level hccs from hierarchy\n*/\n\nwith hcc_mapping as (\n\n select distinct\n patient_id\n , hcc_code\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_hcc_mapping\n\n)\n\n, seed_hcc_hierarchy as (\n\n select\n model_version\n , hcc_code\n , description\n , hccs_to_exclude\n from dev_thuxuan.cms_hcc._value_set_disease_hierarchy\n\n)\n\n/*\n selecting hccs that do not have a hierarchy\n all codes in this cte are included in final output\n*/\n, hccs_without_hierarchy as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n left join seed_hcc_hierarchy as hcc_top_level\n on hcc_mapping.hcc_code = hcc_top_level.hcc_code\n and hcc_mapping.model_version = hcc_top_level.model_version\n left join seed_hcc_hierarchy as hcc_exclusions\n on hcc_mapping.hcc_code = hcc_exclusions.hccs_to_exclude\n and hcc_mapping.model_version = hcc_exclusions.model_version\n where hcc_top_level.hcc_code is null\n and hcc_exclusions.hccs_to_exclude is null\n\n)\n\n/*\n selecting hccs that have a hierarchy to be evaluated in the next cte\n*/\n, hccs_with_hierarchy as (\n\n select\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n , seed_hcc_hierarchy.hcc_code as top_level_hcc\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hccs_to_exclude\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n\n)\n\n/*\n applying hcc hierarchy and grouping by patient and hcc\n to account for multiple hcc combinations\n minimum HCC is included following CMS's severity logic\n*/\n, hierarchy_applied as (\n\n select\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n , min(hcc_mapping.hcc_code) as top_level_hcc\n from hccs_with_hierarchy\n left join hcc_mapping\n on hcc_mapping.patient_id = hccs_with_hierarchy.patient_id\n and hcc_mapping.hcc_code = hccs_with_hierarchy.top_level_hcc\n and hcc_mapping.model_version = hccs_with_hierarchy.model_version\n group by\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n\n)\n\n/*\n selecting lower-level hccs in hierarchy\n all codes in this cte are included in final output\n*/\n, lower_level_inclusions as (\n\n select distinct\n patient_id\n , model_version\n , payment_year\n , case\n when top_level_hcc is not null then top_level_hcc\n else hcc_code\n end as hcc_code\n from hierarchy_applied\n\n)\n\n/*\n selecting top-level hccs not in previous steps\n all codes in this cte are included in final output\n*/\n, top_level_inclusions as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hcc_code\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n left join lower_level_inclusions\n on hcc_mapping.patient_id = lower_level_inclusions.patient_id\n and hcc_mapping.hcc_code = lower_level_inclusions.hcc_code\n and hcc_mapping.model_version = lower_level_inclusions.model_version\n left join hierarchy_applied\n on hcc_mapping.patient_id = hierarchy_applied.patient_id\n and hcc_mapping.hcc_code = hierarchy_applied.hcc_code\n and hcc_mapping.model_version = hierarchy_applied.model_version\n where lower_level_inclusions.hcc_code is null\n and hierarchy_applied.top_level_hcc is null\n\n)\n\n, unioned as (\n\n select * from hccs_without_hierarchy\n union all\n select * from lower_level_inclusions\n union all\n select * from top_level_inclusions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n , cast(hcc_code as TEXT) as hcc_code\n from unioned\n\n)\n\nselect\n patient_id\n , model_version\n , payment_year\n , hcc_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_hcc_mapping": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_hcc_mapping", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_hcc_mapping.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_hcc_mapping.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_mapping", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_hcc_mapping"], "alias": "_int_hcc_mapping", "checksum": {"name": "sha256", "checksum": "f4dfeb0c413b50052d2bd251d4a35dde91c85e0004400911b8f36979cf651839"}, "config": {"enabled": true, "alias": "_int_hcc_mapping", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Eligible conditions mapped to HCC codes for the corresponding HCC model version and payment year\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_code": {"name": "condition_code", "description": "Condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_hcc_mapping", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7911327, "relation_name": "dev_thuxuan.cms_hcc._int_hcc_mapping", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n/*\r\nSteps for staging the medical claim data:\r\n 1) Filter to risk-adjustable claims per claim type for the collection year.\r\n 2) Gather diagnosis codes from Condition for the eligible claims.\r\n 3) Map and filter diagnosis codes to HCCs for each CMS model version\r\n 4) Union results from each CMS model version\r\n (note: some payment years may not have results for v28)\r\n*/\r\n\r\nwith conditions as (\r\n\r\n select\r\n patient_id\r\n , condition_code\r\n , payment_year\r\n from {{ ref('cms_hcc__int_eligible_conditions') }}\r\n\r\n)\r\n\r\n, seed_hcc_mapping as (\r\n\r\n select\r\n payment_year\r\n , diagnosis_code\r\n , cms_hcc_v24\r\n , cms_hcc_v24_flag\r\n , cms_hcc_v28\r\n , cms_hcc_v28_flag\r\n from {{ ref('cms_hcc__icd_10_cm_mappings') }}\r\n\r\n)\r\n\r\n/* casting hcc_code to avoid formatting changes during union */\r\n, v24_mapped as (\r\n\r\n select distinct\r\n conditions.patient_id\r\n , conditions.condition_code\r\n , conditions.payment_year\r\n , 'CMS-HCC-V24' as model_version\r\n , cast(seed_hcc_mapping.cms_hcc_v24 as {{ dbt.type_string() }}) as hcc_code\r\n from conditions\r\n inner join seed_hcc_mapping\r\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\r\n and conditions.payment_year = seed_hcc_mapping.payment_year\r\n where cms_hcc_v24_flag = 'Yes'\r\n\r\n)\r\n\r\n, v28_mapped as (\r\n\r\n select distinct\r\n conditions.patient_id\r\n , conditions.condition_code\r\n , conditions.payment_year\r\n , 'CMS-HCC-V28' as model_version\r\n , cast(seed_hcc_mapping.cms_hcc_v28 as {{ dbt.type_string() }}) as hcc_code\r\n from conditions\r\n inner join seed_hcc_mapping\r\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\r\n and conditions.payment_year = seed_hcc_mapping.payment_year\r\n where cms_hcc_v28_flag = 'Yes'\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from v24_mapped\r\n union all\r\n select * from v28_mapped\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(condition_code as {{ dbt.type_string() }}) as condition_code\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(model_version as {{ dbt.type_string() }}) as model_version\r\n , cast(payment_year as integer) as payment_year\r\n from unioned\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , condition_code\r\n , hcc_code\r\n , model_version\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__int_eligible_conditions", "package": null, "version": null}, {"name": "cms_hcc__icd_10_cm_mappings", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__int_eligible_conditions", "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_hcc_mapping.sql", "compiled": true, "compiled_code": "\n/*\nSteps for staging the medical claim data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from Condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs for each CMS model version\n 4) Union results from each CMS model version\n (note: some payment years may not have results for v28)\n*/\n\nwith conditions as (\n\n select\n patient_id\n , condition_code\n , payment_year\n from dev_thuxuan.cms_hcc._int_eligible_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n payment_year\n , diagnosis_code\n , cms_hcc_v24\n , cms_hcc_v24_flag\n , cms_hcc_v28\n , cms_hcc_v28_flag\n from dev_thuxuan.cms_hcc._value_set_icd_10_cm_mappings\n\n)\n\n/* casting hcc_code to avoid formatting changes during union */\n, v24_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V24' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v24 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v24_flag = 'Yes'\n\n)\n\n, v28_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V28' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v28 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v28_flag = 'Yes'\n\n)\n\n, unioned as (\n\n select * from v24_mapped\n union all\n select * from v28_mapped\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(condition_code as TEXT) as condition_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , condition_code\n , hcc_code\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__int_members": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__int_members", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\intermediate\\cms_hcc__int_members.sql", "original_file_path": "models\\cms_hcc\\intermediate\\cms_hcc__int_members.sql", "unique_id": "model.the_tuva_project.cms_hcc__int_members", "fqn": ["the_tuva_project", "cms_hcc", "intermediate", "cms_hcc__int_members"], "alias": "_int_members", "checksum": {"name": "sha256", "checksum": "89f8cb650fd8e491707e10b03c4af8c72d5f72cb813f42c01b7b5ace77c36cb3"}, "config": {"enabled": true, "alias": "_int_members", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Transformed eligibility data into the demographic risk segments required for the CMS HCC and risk calculations.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Indicates whether the patient is a \"Continuing\" or \"New\" enrollee.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Indicates whether the patient is \"Female\" or \"Male\".", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "Indicates what age group the patient is in. (e.g. \"60-64\"). CMS guidance: Age is calculated as of Feb 1 of the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Indicates whether the patient is enrolled in Medicaid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Indicates whether the patient has \"Full\", \"Partial\", or \"Non\" dual status.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Indicates the Original Reason for Entitlement Code (OREC) \"Aged\", \"Disabled\", or \"ESRD\". If available, current Medicare Status is used when OREC is missing.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Indicates whether the patient resided in an institution for at least 90 days.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status_default": {"name": "enrollment_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_dual_status_default": {"name": "medicaid_dual_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec_default": {"name": "orec_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status_default": {"name": "institutional_status_default", "description": "Indicates the input data was missing and a default status was used.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "model_version": {"name": "model_version", "description": "CMS HCC model version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The payment year the HCC and risk scores are being calculated for.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_int_members", "tags": "cms_hcc", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7941325, "relation_name": "dev_thuxuan.cms_hcc._int_members", "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n/*\r\nSteps for transforming eligibility data into member demographics:\r\n 1) Determine enrollment status using eligibility from the collection year.\r\n 2) Roll up to latest eligibility record for enrollment statuses.\r\n 3) Add age groups based on the payment year.\r\n 4) Determine other statuses.\r\n\r\nJinja is used to set payment year variable.\r\n - The payment_year var has been set here so it gets compiled.\r\n - CMS guidance: Age is calculated as of Feb 1 of the payment year.\r\n - The collection year is one year prior to the payment year.\r\n*/\r\n\r\n{% set payment_year = var('cms_hcc_payment_year') | int() -%}\r\n{% set payment_year_age_date = payment_year ~ '-02-01' -%}\r\n{% set collection_year = payment_year - 1 -%}\r\n{% set collection_year_start = \"'\" ~ collection_year ~ \"-01-01'\" %}\r\n{% set collection_year_end = \"'\" ~ payment_year ~ \"-12-31'\" %}\r\n\r\nwith stg_eligibility as (\r\n\r\n select\r\n patient_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , original_reason_entitlement_code\r\n , dual_status_code\r\n , medicare_status_code\r\n , row_number() over(\r\n partition by patient_id\r\n order by enrollment_end_date desc\r\n ) as row_num /* used to dedupe eligibility */\r\n from {{ ref('cms_hcc__stg_core__eligibility') }}\r\n where (\r\n /* Include members with any overlap in the collection or payment year */\r\n enrollment_start_date <= {{ collection_year_end }}\r\n and enrollment_end_date >= {{ collection_year_start }}\r\n )\r\n\r\n)\r\n\r\n, stg_patient as (\r\n\r\n select\r\n patient_id\r\n , sex\r\n , birth_date\r\n , floor({{ datediff('birth_date', \"'\"~payment_year_age_date~\"'\", 'hour') }} / 8766.0) as payment_year_age\r\n , death_date\r\n from {{ ref('cms_hcc__stg_core__patient') }}\r\n\r\n)\r\n\r\n/* create proxy enrollment dates if outside of the collection year */\r\n, cap_collection_start_end_dates as (\r\n\r\n select\r\n patient_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , case\r\n when enrollment_start_date < {{ try_to_cast_date(collection_year_start, 'YYYY-MM-DD') }}\r\n then {{ try_to_cast_date(collection_year_start, 'YYYY-MM-DD') }}\r\n else enrollment_start_date\r\n end as proxy_enrollment_start_date\r\n , case\r\n when enrollment_end_date > {{ try_to_cast_date(collection_year_end, 'YYYY-MM-DD') }}\r\n then {{ try_to_cast_date(collection_year_end, 'YYYY-MM-DD') }}\r\n else enrollment_end_date\r\n end as proxy_enrollment_end_date\r\n from stg_eligibility\r\n where (\r\n /* filter to members with eligibility in collection or payment year */\r\n {% if target.type == 'fabric' %}\r\n YEAR(enrollment_start_date)\r\n between {{ collection_year }}\r\n and {{ payment_year }}\r\n or YEAR(enrollment_end_date)\r\n between {{ collection_year }}\r\n and {{ payment_year }}\r\n {% else %}\r\n extract(year from enrollment_start_date)\r\n between {{ collection_year }}\r\n and {{ payment_year }}\r\n or extract(year from enrollment_end_date)\r\n between {{ collection_year }}\r\n and {{ payment_year }}\r\n {% endif %}\r\n )\r\n\r\n)\r\n\r\n, calculate_prior_coverage as (\r\n\r\n select patient_id\r\n , sum({{ datediff('proxy_enrollment_start_date', 'proxy_enrollment_end_date', 'month') }} + 1) as coverage_months /* include starting month */\r\n from cap_collection_start_end_dates\r\n group by patient_id\r\n\r\n)\r\n\r\n/*\r\n CMS guidance: A \u201cNew Enrollee\u201d status is when a beneficiary has less than\r\n 12 months of coverage prior to the payment year.\r\n*/\r\n, add_enrollment as (\r\n\r\n select\r\n patient_id\r\n , case\r\n when coverage_months < 12 then 'New'\r\n else 'Continuing'\r\n end as enrollment_status\r\n from calculate_prior_coverage\r\n\r\n)\r\n\r\n, latest_eligibility as (\r\n\r\n select\r\n stg_eligibility.patient_id\r\n , stg_patient.sex as gender\r\n , stg_patient.payment_year_age\r\n , stg_eligibility.original_reason_entitlement_code\r\n , stg_eligibility.dual_status_code\r\n , stg_eligibility.medicare_status_code\r\n /* Defaulting to \"New\" enrollment status when missing */\r\n , case\r\n when add_enrollment.enrollment_status is null then 'New'\r\n else add_enrollment.enrollment_status\r\n end as enrollment_status\r\n {% if target.type == 'fabric' %}\r\n , case\r\n when add_enrollment.enrollment_status is null then 1\r\n else 0\r\n end as enrollment_status_default\r\n {% else %}\r\n , case\r\n when add_enrollment.enrollment_status is null then TRUE\r\n else FALSE\r\n end as enrollment_status_default\r\n {% endif %}\r\n from stg_eligibility\r\n left join add_enrollment\r\n on stg_eligibility.patient_id = add_enrollment.patient_id\r\n left join stg_patient\r\n on stg_eligibility.patient_id = stg_patient.patient_id\r\n where stg_eligibility.row_num = 1\r\n\r\n)\r\n\r\n, add_age_group as (\r\n\r\n select\r\n patient_id\r\n , gender\r\n , payment_year_age\r\n , original_reason_entitlement_code\r\n , dual_status_code\r\n , medicare_status_code\r\n , enrollment_status\r\n , enrollment_status_default\r\n , case\r\n when enrollment_status = 'Continuing' and payment_year_age between 0 and 34 then '0-34'\r\n when enrollment_status = 'Continuing' and payment_year_age between 35 and 44 then '35-44'\r\n when enrollment_status = 'Continuing' and payment_year_age between 45 and 54 then '45-54'\r\n when enrollment_status = 'Continuing' and payment_year_age between 55 and 59 then '55-59'\r\n when enrollment_status = 'Continuing' and payment_year_age between 60 and 64 then '60-64'\r\n when enrollment_status = 'Continuing' and payment_year_age between 65 and 69 then '65-69'\r\n when enrollment_status = 'Continuing' and payment_year_age between 70 and 74 then '70-74'\r\n when enrollment_status = 'Continuing' and payment_year_age between 75 and 79 then '75-79'\r\n when enrollment_status = 'Continuing' and payment_year_age between 80 and 84 then '80-84'\r\n when enrollment_status = 'Continuing' and payment_year_age between 85 and 89 then '85-89'\r\n when enrollment_status = 'Continuing' and payment_year_age between 90 and 94 then '90-94'\r\n when enrollment_status = 'Continuing' and payment_year_age >= 95 then '>=95'\r\n when enrollment_status = 'New' and payment_year_age between 0 and 34 then '0-34'\r\n when enrollment_status = 'New' and payment_year_age between 35 and 44 then '35-44'\r\n when enrollment_status = 'New' and payment_year_age between 45 and 54 then '45-54'\r\n when enrollment_status = 'New' and payment_year_age between 55 and 59 then '55-59'\r\n when enrollment_status = 'New' and payment_year_age between 60 and 64 then '60-64'\r\n when enrollment_status = 'New' and payment_year_age = 65 then '65'\r\n when enrollment_status = 'New' and payment_year_age = 66 then '66'\r\n when enrollment_status = 'New' and payment_year_age = 67 then '67'\r\n when enrollment_status = 'New' and payment_year_age = 68 then '68'\r\n when enrollment_status = 'New' and payment_year_age = 69 then '69'\r\n when enrollment_status = 'New' and payment_year_age between 70 and 74 then '70-74'\r\n when enrollment_status = 'New' and payment_year_age between 75 and 79 then '75-79'\r\n when enrollment_status = 'New' and payment_year_age between 80 and 84 then '80-84'\r\n when enrollment_status = 'New' and payment_year_age between 85 and 89 then '85-89'\r\n when enrollment_status = 'New' and payment_year_age between 90 and 94 then '90-94'\r\n when enrollment_status = 'New' and payment_year_age >= 95 then '>=95'\r\n end as age_group\r\n from latest_eligibility\r\n\r\n)\r\n\r\n, add_status_logic as (\r\n\r\n select\r\n patient_id\r\n , enrollment_status\r\n , case\r\n when gender = 'female' then 'Female'\r\n when gender = 'male' then 'Male'\r\n else null\r\n end as gender\r\n , age_group\r\n , case\r\n when dual_status_code in ('01','02','03','04','05','06','08') then 'Yes'\r\n else 'No'\r\n end as medicaid_status\r\n , case\r\n when dual_status_code in ('02','04','08') then 'Full'\r\n when dual_status_code in ('01','03','05','06') then 'Partial'\r\n else 'Non'\r\n end as dual_status\r\n /*\r\n The CMS-HCC model does not have factors for ESRD for these edge-cases,\r\n we default to 'Aged'. When OREC is missing, latest Medicare status is\r\n used, if available.\r\n */\r\n , case\r\n when original_reason_entitlement_code in ('0','2') then 'Aged'\r\n when original_reason_entitlement_code in ('1','3') then 'Disabled'\r\n when original_reason_entitlement_code is null and medicare_status_code in ('10','11','31') then 'Aged'\r\n when original_reason_entitlement_code is null and medicare_status_code in ('20','21') then 'Disabled'\r\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 'Aged'\r\n end as orec\r\n /* Defaulting everyone to non-institutional until logic is added */\r\n , cast('No' as {{ dbt.type_string() }}) as institutional_status\r\n , enrollment_status_default\r\n , case\r\n {% if target.type == 'fabric' %}\r\n when dual_status_code is null then 1\r\n else 0\r\n {% else %}\r\n when dual_status_code is null then TRUE\r\n else FALSE\r\n {% endif %}\r\n end as medicaid_dual_status_default\r\n /* Setting default true when OREC or Medicare Status is ESRD, or null */\r\n , case\r\n {% if target.type == 'fabric' %}\r\n when original_reason_entitlement_code in ('2') then 1\r\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then 1\r\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 1\r\n else 0\r\n {% else %}\r\n when original_reason_entitlement_code in ('2') then TRUE\r\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then TRUE\r\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then TRUE\r\n else FALSE\r\n {% endif %}\r\n end as orec_default\r\n /* Setting default true until institutional logic is added */\r\n {% if target.type == 'fabric' %}\r\n , 1 as institutional_status_default\r\n {% else %}\r\n , TRUE as institutional_status_default\r\n {% endif %}\r\n from add_age_group\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(enrollment_status as {{ dbt.type_string() }}) as enrollment_status\r\n , cast(gender as {{ dbt.type_string() }}) as gender\r\n , cast(age_group as {{ dbt.type_string() }}) as age_group\r\n , cast(medicaid_status as {{ dbt.type_string() }}) as medicaid_status\r\n , cast(dual_status as {{ dbt.type_string() }}) as dual_status\r\n , cast(orec as {{ dbt.type_string() }}) as orec\r\n , cast(institutional_status as {{ dbt.type_string() }}) as institutional_status\r\n {% if target.type == 'fabric' %}\r\n , cast(enrollment_status_default as bit) as enrollment_status_default\r\n , cast(medicaid_dual_status_default as bit) as medicaid_dual_status_default\r\n , cast(orec_default as bit) as orec_default\r\n , cast(institutional_status_default as bit) as institutional_status_default\r\n {% else %}\r\n , cast(enrollment_status_default as boolean) as enrollment_status_default\r\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\r\n , cast(orec_default as boolean) as orec_default\r\n , cast(institutional_status_default as boolean) as institutional_status_default\r\n {% endif %}\r\n , cast('{{ payment_year }}' as integer) as payment_year\r\n from add_status_logic\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , enrollment_status\r\n , gender\r\n , age_group\r\n , medicaid_status\r\n , dual_status\r\n , orec\r\n , institutional_status\r\n , enrollment_status_default\r\n , medicaid_dual_status_default\r\n , orec_default\r\n , institutional_status_default\r\n , payment_year\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "cms_hcc__stg_core__eligibility", "package": null, "version": null}, {"name": "cms_hcc__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__stg_core__eligibility", "model.the_tuva_project.cms_hcc__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\intermediate\\cms_hcc__int_members.sql", "compiled": true, "compiled_code": "\n/*\nSteps for transforming eligibility data into member demographics:\n 1) Determine enrollment status using eligibility from the collection year.\n 2) Roll up to latest eligibility record for enrollment statuses.\n 3) Add age groups based on the payment year.\n 4) Determine other statuses.\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - CMS guidance: Age is calculated as of Feb 1 of the payment year.\n - The collection year is one year prior to the payment year.\n*/\n\n\n\n\nwith __dbt__cte___stg_eligibility as (\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), stg_eligibility as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , row_number() over(\n partition by patient_id\n order by enrollment_end_date desc\n ) as row_num /* used to dedupe eligibility */\n from __dbt__cte___stg_eligibility\n where (\n /* Include members with any overlap in the collection or payment year */\n enrollment_start_date <= '2024-12-31'\n and enrollment_end_date >= '2023-01-01'\n )\n\n)\n\n, stg_patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , floor(datediff(\n hour,\n birth_date,\n '2024-02-01'\n ) / 8766.0) as payment_year_age\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n/* create proxy enrollment dates if outside of the collection year */\n, cap_collection_start_end_dates as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , case\n when enrollment_start_date < try_cast( '2023-01-01' as date )\n then try_cast( '2023-01-01' as date )\n else enrollment_start_date\n end as proxy_enrollment_start_date\n , case\n when enrollment_end_date > try_cast( '2024-12-31' as date )\n then try_cast( '2024-12-31' as date )\n else enrollment_end_date\n end as proxy_enrollment_end_date\n from stg_eligibility\n where (\n /* filter to members with eligibility in collection or payment year */\n \n extract(year from enrollment_start_date)\n between 2023\n and 2024\n or extract(year from enrollment_end_date)\n between 2023\n and 2024\n \n )\n\n)\n\n, calculate_prior_coverage as (\n\n select patient_id\n , sum(datediff(\n month,\n proxy_enrollment_start_date,\n proxy_enrollment_end_date\n ) + 1) as coverage_months /* include starting month */\n from cap_collection_start_end_dates\n group by patient_id\n\n)\n\n/*\n CMS guidance: A \u201cNew Enrollee\u201d status is when a beneficiary has less than\n 12 months of coverage prior to the payment year.\n*/\n, add_enrollment as (\n\n select\n patient_id\n , case\n when coverage_months < 12 then 'New'\n else 'Continuing'\n end as enrollment_status\n from calculate_prior_coverage\n\n)\n\n, latest_eligibility as (\n\n select\n stg_eligibility.patient_id\n , stg_patient.sex as gender\n , stg_patient.payment_year_age\n , stg_eligibility.original_reason_entitlement_code\n , stg_eligibility.dual_status_code\n , stg_eligibility.medicare_status_code\n /* Defaulting to \"New\" enrollment status when missing */\n , case\n when add_enrollment.enrollment_status is null then 'New'\n else add_enrollment.enrollment_status\n end as enrollment_status\n \n , case\n when add_enrollment.enrollment_status is null then TRUE\n else FALSE\n end as enrollment_status_default\n \n from stg_eligibility\n left join add_enrollment\n on stg_eligibility.patient_id = add_enrollment.patient_id\n left join stg_patient\n on stg_eligibility.patient_id = stg_patient.patient_id\n where stg_eligibility.row_num = 1\n\n)\n\n, add_age_group as (\n\n select\n patient_id\n , gender\n , payment_year_age\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , enrollment_status\n , enrollment_status_default\n , case\n when enrollment_status = 'Continuing' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'Continuing' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'Continuing' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'Continuing' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'Continuing' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'Continuing' and payment_year_age between 65 and 69 then '65-69'\n when enrollment_status = 'Continuing' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'Continuing' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'Continuing' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'Continuing' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'Continuing' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'Continuing' and payment_year_age >= 95 then '>=95'\n when enrollment_status = 'New' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'New' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'New' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'New' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'New' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'New' and payment_year_age = 65 then '65'\n when enrollment_status = 'New' and payment_year_age = 66 then '66'\n when enrollment_status = 'New' and payment_year_age = 67 then '67'\n when enrollment_status = 'New' and payment_year_age = 68 then '68'\n when enrollment_status = 'New' and payment_year_age = 69 then '69'\n when enrollment_status = 'New' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'New' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'New' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'New' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'New' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'New' and payment_year_age >= 95 then '>=95'\n end as age_group\n from latest_eligibility\n\n)\n\n, add_status_logic as (\n\n select\n patient_id\n , enrollment_status\n , case\n when gender = 'female' then 'Female'\n when gender = 'male' then 'Male'\n else null\n end as gender\n , age_group\n , case\n when dual_status_code in ('01','02','03','04','05','06','08') then 'Yes'\n else 'No'\n end as medicaid_status\n , case\n when dual_status_code in ('02','04','08') then 'Full'\n when dual_status_code in ('01','03','05','06') then 'Partial'\n else 'Non'\n end as dual_status\n /*\n The CMS-HCC model does not have factors for ESRD for these edge-cases,\n we default to 'Aged'. When OREC is missing, latest Medicare status is\n used, if available.\n */\n , case\n when original_reason_entitlement_code in ('0','2') then 'Aged'\n when original_reason_entitlement_code in ('1','3') then 'Disabled'\n when original_reason_entitlement_code is null and medicare_status_code in ('10','11','31') then 'Aged'\n when original_reason_entitlement_code is null and medicare_status_code in ('20','21') then 'Disabled'\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 'Aged'\n end as orec\n /* Defaulting everyone to non-institutional until logic is added */\n , cast('No' as TEXT) as institutional_status\n , enrollment_status_default\n , case\n \n when dual_status_code is null then TRUE\n else FALSE\n \n end as medicaid_dual_status_default\n /* Setting default true when OREC or Medicare Status is ESRD, or null */\n , case\n \n when original_reason_entitlement_code in ('2') then TRUE\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then TRUE\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then TRUE\n else FALSE\n \n end as orec_default\n /* Setting default true until institutional logic is added */\n \n , TRUE as institutional_status_default\n \n from add_age_group\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast('2024' as integer) as payment_year\n from add_status_logic\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.cms_hcc__stg_core__eligibility", "sql": " __dbt__cte___stg_eligibility as (\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility\n)"}, {"id": "model.the_tuva_project.cms_hcc__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__condition": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\staging\\cms_hcc__stg_core__condition.sql", "original_file_path": "models\\cms_hcc\\staging\\cms_hcc__stg_core__condition.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__condition", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__condition"], "alias": "_stg_condition", "checksum": {"name": "sha256", "checksum": "8867fe4af76755aeb495d0edd87446e7943e4688de00bd512655636f0716d454"}, "config": {"enabled": true, "alias": "_stg_condition", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging conditions from core.", "columns": {"claim_id": {"name": "claim_id", "description": "Unique claim_id for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "The type of condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "The condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_condition", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.7961326, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nselect\r\n claim_id\r\n , patient_id\r\n , recorded_date\r\n , condition_type\r\n , normalized_code_type as code_type\r\n , normalized_code as code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\staging\\cms_hcc__stg_core__condition.sql", "compiled": true, "compiled_code": "\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__eligibility": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__stg_core__eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\staging\\cms_hcc__stg_core__eligibility.sql", "original_file_path": "models\\cms_hcc\\staging\\cms_hcc__stg_core__eligibility.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__eligibility", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__eligibility"], "alias": "_stg_eligibility", "checksum": {"name": "sha256", "checksum": "0eda573c42880661c0e42e732798c5864d41fd5e5fdab443892b8ec506c1cd4c"}, "config": {"enabled": true, "alias": "_stg_eligibility", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging eligibility from core.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_eligibility", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.798133, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , original_reason_entitlement_code\r\n , dual_status_code\r\n , medicare_status_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__eligibility') }}", "language": "sql", "refs": [{"name": "core__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\staging\\cms_hcc__stg_core__eligibility.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__medical_claim": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__stg_core__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\staging\\cms_hcc__stg_core__medical_claim.sql", "original_file_path": "models\\cms_hcc\\staging\\cms_hcc__stg_core__medical_claim.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__medical_claim"], "alias": "_stg_medical_claim", "checksum": {"name": "sha256", "checksum": "bb40f56f0581df95a17999713976c2d3a483f87b2b2281af9d42641e3ee00e1c"}, "config": {"enabled": true, "alias": "_stg_medical_claim", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging medical claims from core.", "columns": {"claim_id": {"name": "claim_id", "description": "Unique identifier for each claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "Start date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "HCPCS level 1 or level 2 code for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_medical_claim", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.8011324, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , claim_type\r\n , patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , bill_type_code\r\n , hcpcs_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medical_claim') }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\staging\\cms_hcc__stg_core__medical_claim.sql", "compiled": true, "compiled_code": "\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__member_months": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__stg_core__member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\staging\\cms_hcc__stg_core__member_months.sql", "original_file_path": "models\\cms_hcc\\staging\\cms_hcc__stg_core__member_months.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__member_months", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__member_months"], "alias": "_stg_member_months", "checksum": {"name": "sha256", "checksum": "46df1224e23014cf390daf9db5d4826a976a6dbea8e476a383acfe9bdb6f240f"}, "config": {"enabled": true, "alias": "_stg_member_months", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging member months from financial_pmpm", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_member_months", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.8056364, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('financial_pmpm_enabled', var('claims_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__member_months') }}", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\staging\\cms_hcc__stg_core__member_months.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.member_months", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.cms_hcc__stg_core__patient": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "cms_hcc\\staging\\cms_hcc__stg_core__patient.sql", "original_file_path": "models\\cms_hcc\\staging\\cms_hcc__stg_core__patient.sql", "unique_id": "model.the_tuva_project.cms_hcc__stg_core__patient", "fqn": ["the_tuva_project", "cms_hcc", "staging", "cms_hcc__stg_core__patient"], "alias": "_stg_patient", "checksum": {"name": "sha256", "checksum": "98d5b5cf2d9f92d235aeba9103659699493db4a97495612137cfb181f30759e2"}, "config": {"enabled": true, "alias": "_stg_patient", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["cms_hcc"], "description": "Staging patient from core.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "Biological sex of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "Date the patient was born.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "The death date of the patient if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\cms_hcc\\cms_hcc_models.yml", "build_path": null, "unrendered_config": {"schema": "cms_hcc", "alias": "_stg_patient", "tags": "cms_hcc", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.803132, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('cms_hcc_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , sex\r\n , birth_date\r\n , death_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\staging\\cms_hcc__stg_core__patient.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__condition": {"database": "dev_thuxuan", "schema": "core", "name": "core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__condition.sql", "original_file_path": "models\\core\\final\\core__condition.sql", "unique_id": "model.the_tuva_project.core__condition", "fqn": ["the_tuva_project", "core", "final", "core__condition"], "alias": "condition", "checksum": {"name": "sha256", "checksum": "94ce76bb7b3379b78a4d6c0b7cbd840d47e211406b391d9dcee60fa3674c290a"}, "config": {"enabled": true, "alias": "condition", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The core condition table contains information related to medical conditions patients have, including problems, admitting diagnosis codes, and billable diagnosis codes.\n", "columns": {"condition_id": {"name": "condition_id", "description": "Unique identifier for each condition in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date when the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "onset_date": {"name": "onset_date", "description": "Date when the condition first occurred.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "resolved_date": {"name": "resolved_date", "description": "Date when the condition was resolved.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of the record (e.g., condition, test, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition i.e. problem, admitting, or billing.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_rank": {"name": "condition_rank", "description": "The numerical ranking of a diagnosis code in a claim. Principle diagnosis code is given a ranking of 1. Claims data typically has a strict ranking of conditions whereas medical records will often not have this information or the information won't be accurate.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "present_on_admit_code": {"name": "present_on_admit_code", "description": "The present_on_admit_code related to the condition.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__present_on_admission.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "present_on_admit_description": {"name": "present_on_admit_description", "description": "The description of the present_on_admit_code for the condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "condition", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.8166413, "relation_name": "dev_thuxuan.core.condition", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith all_conditions as (\r\n {% if var('clinical_enabled'\r\n , var('tuva_marts_enabled'\r\n , False)) == true and var('claims_enabled'\r\n , var('tuva_marts_enabled'\r\n , False)) == true -%}\r\n\r\nselect *\r\nfrom {{ ref('core__stg_claims_condition') }}\r\nunion all\r\nselect *\r\nfrom {{ ref('core__stg_clinical_condition') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect *\r\nfrom {{ ref('core__stg_clinical_condition') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect *\r\nfrom {{ ref('core__stg_claims_condition') }}\r\n\r\n{%- endif %}\r\n)\r\n\r\n\r\n{# is the default code that gets executed as long as an enable_normalize_engine var is false or not defined #}\r\n{% if var('enable_normalize_engine',false) != true %}\r\nselect\r\n all_conditions.condition_id\r\n , all_conditions.patient_id\r\n , all_conditions.encounter_id\r\n , all_conditions.claim_id\r\n , all_conditions.recorded_date\r\n , all_conditions.onset_date\r\n , all_conditions.resolved_date\r\n , all_conditions.status\r\n , all_conditions.condition_type\r\n , all_conditions.source_code_type\r\n , all_conditions.source_code\r\n , all_conditions.source_description\r\n , case\r\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\r\n when icd10.icd_10_cm is not null then 'icd-10-cm'\r\n when icd9.icd_9_cm is not null then 'icd-9-cm'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n else null end as normalized_code_type\r\n , coalesce(\r\n all_conditions.normalized_code\r\n , icd10.icd_10_cm\r\n , icd9.icd_9_cm\r\n , snomed_ct.snomed_ct) as normalized_code\r\n , coalesce(\r\n all_conditions.normalized_description\r\n , icd10.short_description\r\n , icd9.short_description\r\n , snomed_ct.description) as normalized_description\r\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\r\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\r\n end as mapping_method\r\n , all_conditions.condition_rank\r\n , all_conditions.present_on_admit_code\r\n , all_conditions.present_on_admit_description\r\n , all_conditions.data_source\r\n , all_conditions.tuva_last_run\r\nfrom\r\nall_conditions\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10\r\n on all_conditions.source_code_type = 'icd-10-cm'\r\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9\r\n on all_conditions.source_code_type = 'icd-9-cm'\r\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\r\nleft join {{ ref('terminology__snomed_ct') }} snomed_ct\r\n on all_conditions.source_code_type = 'snomed-ct'\r\n and all_conditions.source_code = snomed_ct.snomed_ct\r\n\r\n\r\n\r\n{# This code is only exectued if an enable_normalize_engine var is defined and set to true\r\n it expects a seed file called #}\r\n{% else %}\r\nselect\r\n all_conditions.condition_id\r\n , all_conditions.patient_id\r\n , all_conditions.encounter_id\r\n , all_conditions.claim_id\r\n , all_conditions.recorded_date\r\n , all_conditions.onset_date\r\n , all_conditions.resolved_date\r\n , all_conditions.status\r\n , all_conditions.condition_type\r\n , all_conditions.source_code_type\r\n , all_conditions.source_code\r\n , all_conditions.source_description\r\n , case\r\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\r\n when icd10.icd_10_cm is not null then 'icd-10-cm'\r\n when icd9.icd_9_cm is not null then 'icd-9-cm'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n else custom_mapped.normalized_code_type end as normalized_code_type\r\n , coalesce(\r\n all_conditions.normalized_code\r\n , icd10.icd_10_cm\r\n , icd9.icd_9_cm\r\n , snomed_ct.snomed_ct\r\n , custom_mapped.normalized_code\r\n ) as NORMALIZED_CODE\r\n , coalesce(\r\n all_conditions.normalized_description\r\n , icd10.short_description\r\n , icd9.short_description\r\n , snomed_ct.description\r\n , custom_mapped.normalized_description\r\n ) as normalized_description\r\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\r\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\r\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\r\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\r\n end as mapping_method\r\n , all_conditions.condition_rank\r\n , all_conditions.present_on_admit_code\r\n , all_conditions.present_on_admit_description\r\n , all_conditions.data_source\r\n , all_conditions.tuva_last_run\r\nfrom\r\nall_conditions\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10\r\n on all_conditions.source_code_type = 'icd-10-cm'\r\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9\r\n on all_conditions.source_code_type = 'icd-9-cm'\r\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\r\nleft join {{ ref('terminology__snomed_ct') }} snomed_ct\r\n on all_conditions.source_code_type = 'snomed-ct'\r\n and all_conditions.source_code = snomed_ct.snomed_ct\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(all_conditions.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( all_conditions.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (all_conditions.source_code = custom_mapped.source_code\r\n or ( all_conditions.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (all_conditions.source_description = custom_mapped.source_description\r\n or ( all_conditions.source_description is null and custom_mapped.source_description is null)\r\n )\r\n and not (all_conditions.source_code is null and all_conditions.source_description is null)\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_condition", "package": null, "version": null}, {"name": "core__stg_clinical_condition", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_clinical_condition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__snomed_ct"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__condition.sql", "compiled": true, "compiled_code": "\n\n\nwith all_conditions as (\n select *\nfrom dev_thuxuan.test.core__stg_claims_condition\nunion all\nselect *\nfrom dev_thuxuan.test.core__stg_clinical_condition\n\n\n)\n\n\n\n\nselect\n all_conditions.condition_id\n , all_conditions.patient_id\n , all_conditions.encounter_id\n , all_conditions.claim_id\n , all_conditions.recorded_date\n , all_conditions.onset_date\n , all_conditions.resolved_date\n , all_conditions.status\n , all_conditions.condition_type\n , all_conditions.source_code_type\n , all_conditions.source_code\n , all_conditions.source_description\n , case\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\n when icd10.icd_10_cm is not null then 'icd-10-cm'\n when icd9.icd_9_cm is not null then 'icd-9-cm'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n all_conditions.normalized_code\n , icd10.icd_10_cm\n , icd9.icd_9_cm\n , snomed_ct.snomed_ct) as normalized_code\n , coalesce(\n all_conditions.normalized_description\n , icd10.short_description\n , icd9.short_description\n , snomed_ct.description) as normalized_description\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_conditions.condition_rank\n , all_conditions.present_on_admit_code\n , all_conditions.present_on_admit_description\n , all_conditions.data_source\n , all_conditions.tuva_last_run\nfrom\nall_conditions\nleft join dev_thuxuan.terminology.icd_10_cm icd10\n on all_conditions.source_code_type = 'icd-10-cm'\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\nleft join dev_thuxuan.terminology.icd_9_cm icd9\n on all_conditions.source_code_type = 'icd-9-cm'\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on all_conditions.source_code_type = 'snomed-ct'\n and all_conditions.source_code = snomed_ct.snomed_ct\n\n\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__eligibility": {"database": "dev_thuxuan", "schema": "core", "name": "core__eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__eligibility.sql", "original_file_path": "models\\core\\final\\core__eligibility.sql", "unique_id": "model.the_tuva_project.core__eligibility", "fqn": ["the_tuva_project", "core", "final", "core__eligibility"], "alias": "eligibility", "checksum": {"name": "sha256", "checksum": "40a7e07c415aa12f2c27b6cd23f2eb48368e6cfd79f21df4312e297abdbf0941"}, "config": {"enabled": true, "alias": "eligibility", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The eligibility table contains information on patient health plan and supplemental insurance eligibility.\n", "columns": {"eligibility_id": {"name": "eligibility_id", "description": "Unique identifier for each eligibility row in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_id": {"name": "subscriber_id", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_start_date": {"name": "enrollment_start_date", "description": "Date the patient's insurance eligibility began.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_end_date": {"name": "enrollment_end_date", "description": "Date the patient's insurance eligibility ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_type": {"name": "payer_type", "description": "Type of payer (e.g. commercial, medicare, medicaid, etc.).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__payer_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "Original reason for Medicare entitlement code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_code": {"name": "dual_status_code", "description": "Indicates whether the patient is dually eligible for Medicare and Medicaid.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_code": {"name": "medicare_status_code", "description": "Indicates how the patient became eligible for Medicare.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "subscriber_relation": {"name": "subscriber_relation", "description": "Identifier that links a patient to a particular insurance product or health plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "eligibility", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.8216574, "relation_name": "dev_thuxuan.core.eligibility", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect * from {{ ref('core__stg_claims_eligibility')}}", "language": "sql", "refs": [{"name": "core__stg_claims_eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__eligibility.sql", "compiled": true, "compiled_code": "\n\n\nselect * from dev_thuxuan.test.core__stg_claims_eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__encounter": {"database": "dev_thuxuan", "schema": "core", "name": "core__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__encounter.sql", "original_file_path": "models\\core\\final\\core__encounter.sql", "unique_id": "model.the_tuva_project.core__encounter", "fqn": ["the_tuva_project", "core", "final", "core__encounter"], "alias": "encounter", "checksum": {"name": "sha256", "checksum": "26134199db490865a446cd98584f00ee5225b0f0e0debc01989b0d0cb5451c22"}, "config": {"enabled": true, "alias": "encounter", "schema": "core", "database": null, "tags": ["core", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core", "encounters"], "description": "The encounter table contains information about patients visits (i.e. encounters). This includes acute inpatient, emergency department, office visits, SNF stays, etc.\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_data_source_id": {"name": "patient_data_source_id", "description": "Identifier for the source system from which patient data originated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__encounter_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "Date when the encounter started.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the encounter ended.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Length of the encounter calculated as encounter_end_date - encounter_start_date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_id": {"name": "attending_provider_id", "description": "ID for the attending provider on the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "attending_provider_name": {"name": "attending_provider_name", "description": "Name of the attending provider on the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_flag": {"name": "observation_flag", "description": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_flag": {"name": "lab_flag", "description": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dme_flag": {"name": "dme_flag", "description": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_flag": {"name": "ambulance_flag", "description": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_flag": {"name": "pharmacy_flag", "description": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_flag": {"name": "ed_flag", "description": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_flag": {"name": "delivery_flag", "description": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "delivery_type": {"name": "delivery_type", "description": "Type of delivery that occurred during the encounter, if applicable.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_flag": {"name": "newborn_flag", "description": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nicu_flag": {"name": "nicu_flag", "description": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_count": {"name": "claim_count", "description": "The number of claims associated with the encounter or record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inst_claim_count": {"name": "inst_claim_count", "description": "Number of institutional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prof_claim_count": {"name": "prof_claim_count", "description": "Number of professional claims generated from the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_model": {"name": "source_model", "description": "Indicates the DBT source relation name from which data is derived.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_source_type": {"name": "encounter_source_type", "description": "Indicates whether the encounter is from a claims or clinical data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "encounter", "tags": ["core", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.8266573, "relation_name": "dev_thuxuan.core.encounter", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', false) == true and var('claims_enabled', false) == true -%}\r\n\r\nselect *\r\n,'claim' as encounter_source_type\r\n from {{ ref('core__stg_claims_encounter') }}\r\nunion all\r\n\r\nselect *\r\n,'clinical' as encounter_source_type\r\n from {{ ref('core__stg_clinical_encounter') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect *\r\n,'clinical' as encounter_source_type\r\n from {{ ref('core__stg_clinical_encounter') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect *\r\n,'claim' as encounter_source_type from {{ ref('core__stg_claims_encounter') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_encounter", "package": null, "version": null}, {"name": "core__stg_clinical_encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_encounter", "model.the_tuva_project.core__stg_clinical_encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__encounter.sql", "compiled": true, "compiled_code": "\n\nselect *\n,'claim' as encounter_source_type\n from dev_thuxuan.test.core__stg_claims_encounter\nunion all\n\nselect *\n,'clinical' as encounter_source_type\n from dev_thuxuan.test.core__stg_clinical_encounter\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__lab_result": {"database": "dev_thuxuan", "schema": "core", "name": "core__lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__lab_result.sql", "original_file_path": "models\\core\\final\\core__lab_result.sql", "unique_id": "model.the_tuva_project.core__lab_result", "fqn": ["the_tuva_project", "core", "final", "core__lab_result"], "alias": "lab_result", "checksum": {"name": "sha256", "checksum": "bc516e21de1430ad0aed1f5573f0e0c00ad78087f465001d2d16029bf440e771"}, "config": {"enabled": true, "alias": "lab_result", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The lab result table contains information about lab test results, including the LOINC code and description, units, reference range, and result.\n", "columns": {"lab_result_id": {"name": "lab_result_id", "description": "Unique identifier for each lab result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "accession_number": {"name": "accession_number", "description": "The lab order number from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_component": {"name": "source_component", "description": "The description for the component of the test from the source system.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_component": {"name": "normalized_component", "description": "The normalized component.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__loinc.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of the record (e.g., condition, test, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the record (e.g., lab test, observation, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "collection_date": {"name": "collection_date", "description": "Date the test was collected.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_abnormal_flag": {"name": "source_abnormal_flag", "description": "Indicates whether the result is abnormal or normal.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_abnormal_flag": {"name": "normalized_abnormal_flag", "description": "Normalized abnormal flag.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specimen": {"name": "specimen", "description": "The type of specimen e.g. blood, plasma, urine.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ordering_practitioner_id": {"name": "ordering_practitioner_id", "description": "Unique identifier for the practitioner who ordered the lab test.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "lab_result", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.829657, "relation_name": "dev_thuxuan.core.lab_result", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) != true %}\r\n\r\n\r\nselect\r\n labs.lab_result_id\r\n , labs.patient_id\r\n , labs.encounter_id\r\n , labs.accession_number\r\n , labs.source_code_type\r\n , labs.source_code\r\n , labs.source_description\r\n , labs.source_component\r\n , case\r\n when labs.normalized_code_type is not null then labs.normalized_code_type\r\n when loinc.loinc is not null then 'loinc'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n else null end as normalized_code_type\r\n , coalesce(\r\n labs.normalized_code\r\n , loinc.loinc\r\n , snomed_ct.snomed_ct\r\n ) as normalized_code\r\n , coalesce(\r\n labs.normalized_description\r\n , loinc.long_common_name\r\n , snomed_ct.description\r\n ) normalized_description\r\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\r\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\r\n end as mapping_method\r\n , labs.normalized_component\r\n , labs.status\r\n , labs.result\r\n , labs.result_date\r\n , labs.collection_date\r\n , labs.source_units\r\n , labs.normalized_units\r\n , labs.source_reference_range_low\r\n , labs.source_reference_range_high\r\n , labs.normalized_reference_range_low\r\n , labs.normalized_reference_range_high\r\n , labs.source_abnormal_flag\r\n , labs.normalized_abnormal_flag\r\n , labs.specimen\r\n , labs.ordering_practitioner_id\r\n , labs.data_source\r\n , labs.tuva_last_run\r\nFrom {{ ref('core__stg_clinical_lab_result')}} as labs\r\nleft join {{ ref('terminology__loinc') }} loinc\r\n on labs.source_code_type = 'loinc'\r\n and labs.source_code = loinc.loinc\r\nleft join {{ref('terminology__snomed_ct')}} snomed_ct\r\n on labs.source_code_type = 'snomed-ct'\r\n and labs.source_code = snomed_ct.snomed_ct\r\n\r\n {% else %}\r\n\r\nselect\r\n labs.lab_result_id\r\n , labs.patient_id\r\n , labs.encounter_id\r\n , labs.accession_number\r\n , labs.source_code_type\r\n , labs.source_code\r\n , labs.source_description\r\n , labs.source_component\r\n , case\r\n when labs.normalized_code_type is not null then labs.normalized_code_type\r\n when loinc.loinc is not null then 'loinc'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n else custom_mapped.normalized_code_type end as normalized_code_type\r\n , coalesce(\r\n labs.normalized_code\r\n , loinc.loinc\r\n , snomed_ct.snomed_ct\r\n , custom_mapped.normalized_code\r\n ) as normalized_code\r\n , coalesce(\r\n labs.normalized_description\r\n , loinc.long_common_name\r\n , snomed_ct.description\r\n , custom_mapped.normalized_description\r\n ) normalized_description\r\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\r\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\r\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\r\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\r\n end as mapping_method\r\n , labs.normalized_component\r\n , labs.status\r\n , labs.result\r\n , labs.result_date\r\n , labs.collection_date\r\n , labs.source_units\r\n , labs.normalized_units\r\n , labs.source_reference_range_low\r\n , labs.source_reference_range_high\r\n , labs.normalized_reference_range_low\r\n , labs.normalized_reference_range_high\r\n , labs.source_abnormal_flag\r\n , labs.normalized_abnormal_flag\r\n , labs.specimen\r\n , labs.ordering_practitioner_id\r\n , labs.data_source\r\n , labs.tuva_last_run\r\nFrom {{ ref('core__stg_clinical_lab_result')}} as labs\r\nleft join {{ ref('terminology__loinc') }} loinc\r\n on labs.source_code_type = 'loinc'\r\n and labs.source_code = loinc.loinc\r\nleft join {{ref('terminology__snomed_ct')}} snomed_ct\r\n on labs.source_code_type = 'snomed-ct'\r\n and labs.source_code = snomed_ct.snomed_ct\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(labs.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( labs.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (labs.source_code = custom_mapped.source_code\r\n or ( labs.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (labs.source_description = custom_mapped.source_description\r\n or ( labs.source_description is null and custom_mapped.source_description is null)\r\n )\r\n and not (labs.source_code is null and labs.source_description is null)\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_clinical_lab_result", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_clinical_lab_result", "seed.the_tuva_project.terminology__loinc", "seed.the_tuva_project.terminology__snomed_ct"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__lab_result.sql", "compiled": true, "compiled_code": "\n\n\n\n\nselect\n labs.lab_result_id\n , labs.patient_id\n , labs.encounter_id\n , labs.accession_number\n , labs.source_code_type\n , labs.source_code\n , labs.source_description\n , labs.source_component\n , case\n when labs.normalized_code_type is not null then labs.normalized_code_type\n when loinc.loinc is not null then 'loinc'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n labs.normalized_code\n , loinc.loinc\n , snomed_ct.snomed_ct\n ) as normalized_code\n , coalesce(\n labs.normalized_description\n , loinc.long_common_name\n , snomed_ct.description\n ) normalized_description\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , labs.normalized_component\n , labs.status\n , labs.result\n , labs.result_date\n , labs.collection_date\n , labs.source_units\n , labs.normalized_units\n , labs.source_reference_range_low\n , labs.source_reference_range_high\n , labs.normalized_reference_range_low\n , labs.normalized_reference_range_high\n , labs.source_abnormal_flag\n , labs.normalized_abnormal_flag\n , labs.specimen\n , labs.ordering_practitioner_id\n , labs.data_source\n , labs.tuva_last_run\nFrom dev_thuxuan.test.core__stg_clinical_lab_result as labs\nleft join dev_thuxuan.terminology.loinc loinc\n on labs.source_code_type = 'loinc'\n and labs.source_code = loinc.loinc\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on labs.source_code_type = 'snomed-ct'\n and labs.source_code = snomed_ct.snomed_ct\n\n ", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__location": {"database": "dev_thuxuan", "schema": "core", "name": "core__location", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__location.sql", "original_file_path": "models\\core\\final\\core__location.sql", "unique_id": "model.the_tuva_project.core__location", "fqn": ["the_tuva_project", "core", "final", "core__location"], "alias": "location", "checksum": {"name": "sha256", "checksum": "25c3cd44422b697cd1494783c2e87d160c7aa163ddc1b175e23379583ee15845"}, "config": {"enabled": true, "alias": "location", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The location table contains information on practice and facility locations where patients receive medical care.\n", "columns": {"location_id": {"name": "location_id", "description": "Unique identifier for each location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "The national provider identifier associated with the record e.g. facility_npi, provider_npi", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "name": {"name": "name", "description": "The name of the location.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_type": {"name": "facility_type", "description": "The type of facility e.g. acute care hospital.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_organization": {"name": "parent_organization", "description": "The parent organization associated with the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The street address of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "location", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9244814, "relation_name": "dev_thuxuan.core.location", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_location') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_location') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_location') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_location') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_location", "package": null, "version": null}, {"name": "core__stg_clinical_location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_clinical_location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__location.sql", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_location\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_location\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__medical_claim": {"database": "dev_thuxuan", "schema": "core", "name": "core__medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__medical_claim.sql", "original_file_path": "models\\core\\final\\core__medical_claim.sql", "unique_id": "model.the_tuva_project.core__medical_claim", "fqn": ["the_tuva_project", "core", "final", "core__medical_claim"], "alias": "medical_claim", "checksum": {"name": "sha256", "checksum": "41428bc0eb9047a2b8a1eec6c3d57d9b04073f32fda2e28989dc59c2f23aebb7"}, "config": {"enabled": true, "alias": "medical_claim", "schema": "core", "database": null, "tags": ["core", "encounters"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core", "encounters"], "description": "The medical claim table contains information on services rendered to patients and billed by the provider to the insurer as claims.\n", "columns": {"medical_claim_id": {"name": "medical_claim_id", "description": "Unique identifier for each row in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_group": {"name": "encounter_group", "description": "Categorization of the encounter into groups based on predefined criteria.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__claim_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "The date when the healthcare service was provided. Format: YYYY-MM-DD.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "End date for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_start_date": {"name": "claim_line_start_date", "description": "Start date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_end_date": {"name": "claim_line_end_date", "description": "End date for the claim line.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "Admission date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Discharge date for the claim (inpatient claims only).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_1": {"name": "service_category_1", "description": "The broader service category this claim belongs to.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/service_categories/service_category__service_categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_2": {"name": "service_category_2", "description": "The more specific service category this claim belongs to.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/service_categories/service_category__service_categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_3": {"name": "service_category_3", "description": "The most specific service category this claim belongs to.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_code": {"name": "admit_source_code", "description": "Indicates where the patient was before the healthcare encounter (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_source.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "Description of the admit_source_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_code": {"name": "admit_type_code", "description": "Indicates the type of admission (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__admit_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "Description of the admit_type_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "Description of the discharge_disposition_code for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_code": {"name": "place_of_service_code", "description": "Place of service for the claim (professional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__place_of_service.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_description": {"name": "place_of_service_description", "description": "Place of service description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_code": {"name": "bill_type_code", "description": "Bill type code for the claim (institutional claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__bill_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_description": {"name": "bill_type_description", "description": "Bill type description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "MS-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "Description of the ms_drg_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_code": {"name": "apr_drg_code", "description": "APR-DRG for the claim (inpatient claims only).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__apr_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "Description of the APR-DRG code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_code": {"name": "revenue_center_code", "description": "Revenue center code for the claim line (institutional only and typically multiple codes per claim).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__revenue_center.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_description": {"name": "revenue_center_description", "description": "Revenue center description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_unit_quantity": {"name": "service_unit_quantity", "description": "The number of units for the particular revenue center code.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "The CPT or HCPCS code representing the procedure or service provided. These codes are used to describe medical, surgical, and diagnostic services.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "1st modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "2nd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "3rd modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "4th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "5th modifier for HCPCS code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_id": {"name": "rendering_id", "description": "Rendering ID for the claim (typically represents the physician or entity providing services).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_tin": {"name": "rendering_tin", "description": "Rendering provider tax identification number (TIN).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rendering_name": {"name": "rendering_name", "description": "Rendering provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_id": {"name": "billing_id", "description": "Billing ID for the claim (typically represents organization billing the claim).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_tin": {"name": "billing_tin", "description": "Billing provider tax identification number (TIN).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "billing_name": {"name": "billing_name", "description": "Billing provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "Facility ID for the claim (typically represents the facility where services were performed).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "Facility name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_cost_amount": {"name": "total_cost_amount", "description": "The total amount paid on the claim by different parties.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_flag": {"name": "enrollment_flag", "description": "Flag indicating if the claim has corresponding enrollment during the same time period the service occurred.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "medical_claim", "tags": ["core", "encounters"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9304764, "relation_name": "dev_thuxuan.core.medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\n\r\nselect * from {{ ref('core__stg_claims_medical_claim')}}", "language": "sql", "refs": [{"name": "core__stg_claims_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nselect * from dev_thuxuan.test.core__stg_claims_medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__medication": {"database": "dev_thuxuan", "schema": "core", "name": "core__medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__medication.sql", "original_file_path": "models\\core\\final\\core__medication.sql", "unique_id": "model.the_tuva_project.core__medication", "fqn": ["the_tuva_project", "core", "final", "core__medication"], "alias": "medication", "checksum": {"name": "sha256", "checksum": "56ae199c46cf2db67af28e0ea8fd9c63bc5eb10a6fd9ed4be2c74b9d2842ba48"}, "config": {"enabled": true, "alias": "medication", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The medication table contains information on medications ordered and/or administered during a patient encounter.\n", "columns": {"medication_id": {"name": "medication_id", "description": "Unique identifier for each medication in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_date": {"name": "prescribing_date", "description": "Date the medication was prescribed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://www.nlm.nih.gov/research/umls/rxnorm/index.html"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code associated with the medication.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description for the NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_mapping_method": {"name": "ndc_mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "RxNorm code associated with the medication.", "meta": {"terminology": "https://www.nlm.nih.gov/research/umls/rxnorm/index.html"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "Description for the RxNorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_mapping_method": {"name": "rxnorm_mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_code": {"name": "atc_code", "description": "ATC code for the medication.", "meta": {"terminology": "https://www.who.int/tools/atc-ddd-toolkit/atc-classification"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_description": {"name": "atc_description", "description": "Description for the ATC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_mapping_method": {"name": "atc_mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "route": {"name": "route", "description": "The route used to administer the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "strength": {"name": "strength", "description": "The strength of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "The quantity of the medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity_unit": {"name": "quantity_unit", "description": "The units for the quantity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "The number of days supply included.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "medication", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9344773, "relation_name": "dev_thuxuan.core.medication", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith source_mapping as (\r\n{% if var('enable_normalize_engine',false) != true %}\r\n select\r\n meds.medication_id\r\n , meds.patient_id\r\n , meds.encounter_id\r\n , meds.dispensing_date\r\n , meds.prescribing_date\r\n , meds.source_code_type\r\n , meds.source_code\r\n , meds.source_description\r\n , coalesce(\r\n meds.ndc_code\r\n , ndc.ndc\r\n ) as ndc_code\r\n , coalesce(\r\n meds.ndc_description\r\n , ndc.fda_description\r\n , ndc.rxnorm_description\r\n ) as ndc_description\r\n , case\r\n when meds.ndc_code is not null then 'manual'\r\n when ndc.ndc is not null then 'automatic'\r\n end as ndc_mapping_method\r\n , coalesce(\r\n meds.rxnorm_code\r\n , rxatc.rxcui\r\n ) as rxnorm_code\r\n , coalesce(\r\n meds.rxnorm_description\r\n , rxatc.rxnorm_description\r\n ) as rxnorm_description\r\n , case\r\n when meds.rxnorm_code is not null then 'manual'\r\n when rxatc.rxcui is not null then 'automatic'\r\n end as rxnorm_mapping_method\r\n , coalesce(\r\n meds.atc_code\r\n , rxatc.atc_3_code\r\n ) as atc_code\r\n , coalesce(\r\n meds.atc_description\r\n , rxatc.atc_4_name\r\n ) as atc_description\r\n , case\r\n when meds.atc_code is not null then 'manual'\r\n when rxatc.atc_3_name is not null then 'automatic'\r\n end as atc_mapping_method\r\n , meds.route\r\n , meds.strength\r\n , meds.quantity\r\n , meds.quantity_unit\r\n , meds.days_supply\r\n , meds.practitioner_id\r\n , meds.data_source\r\n , meds.tuva_last_run\r\nfrom {{ ref('core__stg_clinical_medication')}} meds\r\n left join {{ref('terminology__ndc')}} ndc\r\n on meds.source_code_type = 'ndc'\r\n and meds.source_code = ndc.ndc\r\n left join {{ref('terminology__rxnorm_to_atc')}} rxatc\r\n on meds.source_code_type = 'rxnorm'\r\n and meds.source_code = rxatc.rxcui\r\n\r\n\r\n{% else %}\r\n\r\n select\r\n meds.medication_id\r\n , meds.patient_id\r\n , meds.encounter_id\r\n , meds.dispensing_date\r\n , meds.prescribing_date\r\n , meds.source_code_type\r\n , meds.source_code\r\n , meds.source_description\r\n , coalesce(\r\n meds.ndc_code\r\n , ndc.ndc\r\n , custom_mapped_ndc.normalized_code\r\n ) as ndc_code\r\n , coalesce(\r\n meds.ndc_description\r\n , ndc.fda_description\r\n , ndc.rxnorm_description\r\n , custom_mapped_ndc.normalized_description\r\n ) as ndc_description\r\n , case\r\n when meds.ndc_code is not null then 'manual'\r\n when ndc.ndc is not null then 'automatic'\r\n when custom_mapped_ndc.not_mapped is not null then custom_mapped_ndc.not_mapped\r\n when custom_mapped_ndc.normalized_code is not null then 'custom'\r\n end as ndc_mapping_method\r\n , coalesce(\r\n meds.rxnorm_code\r\n , rxatc.rxcui\r\n , custom_mapped_rxnorm.normalized_code\r\n ) as rxnorm_code\r\n , coalesce(\r\n meds.rxnorm_code\r\n , rxatc.rxnorm_description\r\n , custom_mapped_rxnorm.normalized_description\r\n ) as rxnorm_description\r\n , case\r\n when meds.rxnorm_code is not null then 'manual'\r\n when rxatc.rxcui is not null then 'automatic'\r\n when custom_mapped_rxnorm.not_mapped is not null then custom_mapped_rxnorm.not_mapped\r\n when custom_mapped_rxnorm.normalized_code is not null then 'custom'\r\n end as rxnorm_mapping_method\r\n , coalesce(\r\n meds.atc_code\r\n , rxatc.atc_3_code\r\n , custom_mapped_atc.normalized_code\r\n ) as atc_code\r\n , coalesce(\r\n meds.atc_description\r\n , rxatc.atc_3_name\r\n , custom_mapped_atc.normalized_description\r\n ) as atc_description\r\n , case\r\n when meds.atc_code is not null then 'manual'\r\n when rxatc.atc_3_code is not null then 'automatic'\r\n when custom_mapped_atc.not_mapped is not null then custom_mapped_atc.not_mapped\r\n when custom_mapped_atc.normalized_code is not null then 'custom'\r\n end as atc_mapping_method\r\n , meds.route\r\n , meds.strength\r\n , meds.quantity\r\n , meds.quantity_unit\r\n , meds.days_supply\r\n , meds.practitioner_id\r\n , meds.data_source\r\n , meds.tuva_last_run\r\nfrom {{ ref('core__stg_clinical_medication')}} meds\r\n left join {{ref('terminology__ndc')}} ndc\r\n on meds.source_code_type = 'ndc'\r\n and meds.source_code = ndc.ndc\r\n left join {{ref('terminology__rxnorm_to_atc')}} rxatc\r\n on meds.source_code_type = 'rxnorm'\r\n and meds.source_code = rxatc.rxcui\r\n left join {{ ref('custom_mapped') }} custom_mapped_ndc\r\n on custom_mapped_ndc.normalized_code_type = 'ndc'\r\n and ( lower(meds.source_code_type) = lower(custom_mapped_ndc.source_code_type)\r\n or ( meds.source_code_type is null and custom_mapped_ndc.source_code_type is null)\r\n )\r\n and (meds.source_code = custom_mapped_ndc.source_code\r\n or ( meds.source_code is null and custom_mapped_ndc.source_code is null)\r\n )\r\n and (meds.source_description = custom_mapped_ndc.source_description\r\n or ( meds.source_description is null and custom_mapped_ndc.source_description is null)\r\n )\r\n and not (meds.source_code is null and meds.source_description is null)\r\n left join {{ ref('custom_mapped') }} custom_mapped_rxnorm\r\n on custom_mapped_rxnorm.normalized_code_type = 'rxnorm'\r\n and ( lower(meds.source_code_type) = lower(custom_mapped_rxnorm.source_code_type)\r\n or ( meds.source_code_type is null and custom_mapped_rxnorm.source_code_type is null)\r\n )\r\n and (meds.source_code = custom_mapped_rxnorm.source_code\r\n or ( meds.source_code is null and custom_mapped_rxnorm.source_code is null)\r\n )\r\n and (meds.source_description = custom_mapped_rxnorm.source_description\r\n or ( meds.source_description is null and custom_mapped_rxnorm.source_description is null)\r\n )\r\n and not (meds.source_code is null and meds.source_description is null)\r\n left join {{ ref('custom_mapped') }} custom_mapped_atc\r\n on custom_mapped_atc.normalized_code_type = 'atc'\r\n and ( lower(meds.source_code_type) = lower(custom_mapped_atc.source_code_type)\r\n or ( meds.source_code_type is null and custom_mapped_atc.source_code_type is null)\r\n )\r\n and (meds.source_code = custom_mapped_atc.source_code\r\n or ( meds.source_code is null and custom_mapped_atc.source_code is null)\r\n )\r\n and (meds.source_description = custom_mapped_atc.source_description\r\n or ( meds.source_description is null and custom_mapped_atc.source_description is null)\r\n )\r\n and not (meds.source_code is null and meds.source_description is null)\r\n{% endif %}\r\n )\r\n\r\n\r\n-- add auto rxnorm + atc\r\nselect\r\n sm.medication_id\r\n , sm.patient_id\r\n , sm.encounter_id\r\n , sm.dispensing_date\r\n , sm.prescribing_date\r\n , sm.source_code_type\r\n , sm.source_code\r\n , sm.source_description\r\n , sm.ndc_code\r\n , sm.ndc_description\r\n , sm.ndc_mapping_method\r\n , coalesce(\r\n sm.rxnorm_code\r\n , ndc.rxcui\r\n ) as rxnorm_code\r\n , coalesce(\r\n sm.rxnorm_description\r\n , ndc.rxnorm_description\r\n ) as rxnorm_description\r\n , case\r\n when sm.rxnorm_mapping_method is not null then sm.rxnorm_mapping_method\r\n when ndc.rxcui is not null then 'automatic'\r\n end as rxnorm_mapping_method\r\n , coalesce(\r\n sm.atc_code\r\n , rxatc.atc_3_code\r\n ) as atc_code\r\n , coalesce(\r\n sm.atc_description\r\n , rxatc.atc_3_name\r\n ) as atc_description\r\n , case\r\n when sm.atc_mapping_method is not null then sm.atc_mapping_method\r\n when rxatc.atc_3_name is not null then 'automatic'\r\n end as atc_mapping_method\r\n , sm.route\r\n , sm.strength\r\n , sm.quantity\r\n , sm.quantity_unit\r\n , sm.days_supply\r\n , sm.practitioner_id\r\n , sm.data_source\r\n , sm.tuva_last_run\r\nfrom source_mapping sm\r\n left join {{ref('terminology__ndc')}} ndc\r\n on sm.ndc_code = ndc.ndc\r\n left join {{ref('terminology__rxnorm_to_atc')}} rxatc\r\n on coalesce( sm.rxnorm_code, ndc.rxcui ) = rxatc.rxcui", "language": "sql", "refs": [{"name": "core__stg_clinical_medication", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_clinical_medication", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__medication.sql", "compiled": true, "compiled_code": "\n\n\nwith source_mapping as (\n\n select\n meds.medication_id\n , meds.patient_id\n , meds.encounter_id\n , meds.dispensing_date\n , meds.prescribing_date\n , meds.source_code_type\n , meds.source_code\n , meds.source_description\n , coalesce(\n meds.ndc_code\n , ndc.ndc\n ) as ndc_code\n , coalesce(\n meds.ndc_description\n , ndc.fda_description\n , ndc.rxnorm_description\n ) as ndc_description\n , case\n when meds.ndc_code is not null then 'manual'\n when ndc.ndc is not null then 'automatic'\n end as ndc_mapping_method\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxcui\n ) as rxnorm_code\n , coalesce(\n meds.rxnorm_description\n , rxatc.rxnorm_description\n ) as rxnorm_description\n , case\n when meds.rxnorm_code is not null then 'manual'\n when rxatc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n meds.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n meds.atc_description\n , rxatc.atc_4_name\n ) as atc_description\n , case\n when meds.atc_code is not null then 'manual'\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , meds.route\n , meds.strength\n , meds.quantity\n , meds.quantity_unit\n , meds.days_supply\n , meds.practitioner_id\n , meds.data_source\n , meds.tuva_last_run\nfrom dev_thuxuan.test.core__stg_clinical_medication meds\n left join dev_thuxuan.terminology.ndc ndc\n on meds.source_code_type = 'ndc'\n and meds.source_code = ndc.ndc\n left join dev_thuxuan.terminology.rxnorm_to_atc rxatc\n on meds.source_code_type = 'rxnorm'\n and meds.source_code = rxatc.rxcui\n\n\n\n )\n\n\n-- add auto rxnorm + atc\nselect\n sm.medication_id\n , sm.patient_id\n , sm.encounter_id\n , sm.dispensing_date\n , sm.prescribing_date\n , sm.source_code_type\n , sm.source_code\n , sm.source_description\n , sm.ndc_code\n , sm.ndc_description\n , sm.ndc_mapping_method\n , coalesce(\n sm.rxnorm_code\n , ndc.rxcui\n ) as rxnorm_code\n , coalesce(\n sm.rxnorm_description\n , ndc.rxnorm_description\n ) as rxnorm_description\n , case\n when sm.rxnorm_mapping_method is not null then sm.rxnorm_mapping_method\n when ndc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n sm.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n sm.atc_description\n , rxatc.atc_3_name\n ) as atc_description\n , case\n when sm.atc_mapping_method is not null then sm.atc_mapping_method\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , sm.route\n , sm.strength\n , sm.quantity\n , sm.quantity_unit\n , sm.days_supply\n , sm.practitioner_id\n , sm.data_source\n , sm.tuva_last_run\nfrom source_mapping sm\n left join dev_thuxuan.terminology.ndc ndc\n on sm.ndc_code = ndc.ndc\n left join dev_thuxuan.terminology.rxnorm_to_atc rxatc\n on coalesce( sm.rxnorm_code, ndc.rxcui ) = rxatc.rxcui", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__member_months": {"database": "dev_thuxuan", "schema": "core", "name": "core__member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__member_months.sql", "original_file_path": "models\\core\\final\\core__member_months.sql", "unique_id": "model.the_tuva_project.core__member_months", "fqn": ["the_tuva_project", "core", "final", "core__member_months"], "alias": "member_months", "checksum": {"name": "sha256", "checksum": "84b38a497532d590c083cbd5ab75a5ec0a548edd87c7227e022ffae75d0c42c4"}, "config": {"enabled": true, "alias": "member_months", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "Creates member months from eligibility data", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider": {"name": "payer_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the payer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "description": "Name of the practice for the payer attributed provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "description": "Name of the organization for the payer attributed provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "description": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider": {"name": "custom_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the user.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "description": "Name of the practice for the attributed provider assigned by the user.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "description": "Name of the organization for the attributed provider assigned by the user.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "description": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "member_months", "tags": ["core"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9364777, "relation_name": "dev_thuxuan.core.member_months", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n\r\n\r\nwith month_start_and_end_dates as (\r\n select\r\n {{ dbt.concat([\"year\",\r\n dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , min(full_date) as month_start_date\r\n , max(full_date) as month_end_date\r\n from {{ ref('reference_data__calendar')}}\r\n group by year, month, year_month\r\n),\r\n\r\n\r\nfinal_before_attribution_fields as (\r\nselect distinct\r\n a.patient_id\r\n , year_month\r\n , a.payer\r\n , a.{{ quote_column('plan') }}\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__eligibility') }} a\r\ninner join month_start_and_end_dates b\r\n on a.enrollment_start_date <= b.month_end_date\r\n and a.enrollment_end_date >= b.month_start_date\r\n),\r\n\r\n\r\nadd_attribution_fields as (\r\nselect\r\n a.patient_id\r\n , a.year_month\r\n , a.payer\r\n , a.{{ quote_column('plan') }}\r\n , a.data_source\r\n , a.tuva_last_run\r\n \r\n , b.payer_attributed_provider\r\n , b.payer_attributed_provider_practice\r\n , b.payer_attributed_provider_organization\r\n , b.payer_attributed_provider_lob\r\n , b.custom_attributed_provider\r\n , b.custom_attributed_provider_practice\r\n , b.custom_attributed_provider_organization\r\n , b.custom_attributed_provider_lob\r\n\r\nfrom final_before_attribution_fields a\r\nleft join {{ ref('financial_pmpm__stg_provider_attribution') }} b\r\non a.patient_id = b.patient_id\r\nand a.year_month = b.year_month\r\nand a.payer = b.payer\r\nand a.{{ quote_column('plan') }} = b.{{ quote_column('plan') }}\r\nand a.data_source = b.data_source\r\n)\r\n\r\n\r\nselect *\r\nfrom add_attribution_fields", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "financial_pmpm__stg_provider_attribution", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.right", "macro.the_tuva_project.quote_column"], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.financial_pmpm__stg_provider_attribution"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__member_months.sql", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__financial_pmpm__stg_provider_attribution as (\n\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution\n), month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from dev_thuxuan.reference_data.calendar\n group by year, month, year_month\n),\n\n\nfinal_before_attribution_fields as (\nselect distinct\n a.patient_id\n , year_month\n , a.payer\n , a.plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date\n),\n\n\nadd_attribution_fields as (\nselect\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.tuva_last_run\n \n , b.payer_attributed_provider\n , b.payer_attributed_provider_practice\n , b.payer_attributed_provider_organization\n , b.payer_attributed_provider_lob\n , b.custom_attributed_provider\n , b.custom_attributed_provider_practice\n , b.custom_attributed_provider_organization\n , b.custom_attributed_provider_lob\n\nfrom final_before_attribution_fields a\nleft join __dbt__cte__financial_pmpm__stg_provider_attribution b\non a.patient_id = b.patient_id\nand a.year_month = b.year_month\nand a.payer = b.payer\nand a.plan = b.plan\nand a.data_source = b.data_source\n)\n\n\nselect *\nfrom add_attribution_fields", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.financial_pmpm__stg_provider_attribution", "sql": " __dbt__cte__financial_pmpm__stg_provider_attribution as (\n\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__observation": {"database": "dev_thuxuan", "schema": "core", "name": "core__observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__observation.sql", "original_file_path": "models\\core\\final\\core__observation.sql", "unique_id": "model.the_tuva_project.core__observation", "fqn": ["the_tuva_project", "core", "final", "core__observation"], "alias": "observation", "checksum": {"name": "sha256", "checksum": "7704449ef5263db9aa2b22d616426ddca1c4371ebc679c0c14aad8feb6e210e0"}, "config": {"enabled": true, "alias": "observation", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The observation table contains information on measurements other than lab tests e.g. blood pressure, height, and weight.\n", "columns": {"observation_id": {"name": "observation_id", "description": "Unique identifier for each observation in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "panel_id": {"name": "panel_id", "description": "Unique identifier for the panel.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "Date the observation was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_type": {"name": "observation_type", "description": "Type of observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "The result of the record (e.g., lab test, observation, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_units": {"name": "source_units", "description": "Source units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_units": {"name": "normalized_units", "description": "Normalized units of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_low": {"name": "source_reference_range_low", "description": "The low end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_reference_range_high": {"name": "source_reference_range_high", "description": "The high end of the reference range from the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_low": {"name": "normalized_reference_range_low", "description": "The normalized low end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_reference_range_high": {"name": "normalized_reference_range_high", "description": "The normalized high end of the reference range.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "observation", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.939477, "relation_name": "dev_thuxuan.core.observation", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) != true %}\r\nselect\r\n obs.observation_id\r\n , obs.patient_id\r\n , obs.encounter_id\r\n , obs.panel_id\r\n , obs.observation_date\r\n , obs.observation_type\r\n , obs.source_code_type\r\n , obs.source_code\r\n , obs.source_description\r\n , case\r\n when obs.normalized_code_type is not null then obs.normalized_code_type\r\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\r\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\r\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\r\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\r\n when hcpcs.hcpcs is not null then 'hcpcs'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n when loinc.loinc is not null then 'loinc'\r\n end as normalized_code_type\r\n , coalesce(\r\n obs.normalized_code\r\n , icd10cm.icd_10_cm\r\n , icd9cm.icd_9_cm\r\n , icd10pcs.icd_10_pcs\r\n , icd9pcs.icd_9_pcs\r\n , hcpcs.hcpcs\r\n , snomed_ct.snomed_ct\r\n , loinc.loinc\r\n ) as normalized_code\r\n , coalesce(\r\n obs.normalized_description\r\n , icd10cm.short_description\r\n , icd9cm.short_description\r\n , icd10pcs.description\r\n , icd9pcs.short_description\r\n , hcpcs.short_description\r\n , snomed_ct.description\r\n , loinc.long_common_name\r\n ) as normalized_description\r\n , case\r\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\r\n when coalesce(\r\n icd10cm.icd_10_cm\r\n , icd9cm.icd_9_cm\r\n , icd10pcs.icd_10_pcs\r\n , icd9pcs.icd_9_pcs\r\n , hcpcs.hcpcs\r\n , snomed_ct.snomed_ct\r\n , loinc.loinc) is not null then 'automatic'\r\n end as mapping_method\r\n , obs.result\r\n , obs.source_units\r\n , obs.normalized_units\r\n , obs.source_reference_range_low\r\n , obs.source_reference_range_high\r\n , obs.normalized_reference_range_low\r\n , obs.normalized_reference_range_high\r\n , obs.data_source\r\n , obs.tuva_last_run\r\nfrom {{ ref('core__stg_clinical_observation')}} obs\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on obs.source_code_type = 'icd-10-cm'\r\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on obs.source_code_type = 'icd-9-cm'\r\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\r\nleft join {{ ref('terminology__icd_10_pcs') }} icd10pcs\r\n on obs.source_code_type = 'icd-10-pcs'\r\n and obs.source_code = icd10pcs.icd_10_pcs\r\nleft join {{ ref('terminology__icd_9_pcs') }} icd9pcs\r\n on obs.source_code_type = 'icd-9-pcs'\r\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\r\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\r\n on obs.source_code_type = 'hcpcs'\r\n and obs.source_code = hcpcs.hcpcs\r\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\r\n on obs.source_code_type = 'snomed-ct'\r\n and obs.source_code = snomed_ct.snomed_ct\r\nleft join {{ ref('terminology__loinc') }} loinc\r\n on obs.source_code_type = 'loinc'\r\n and obs.source_code = loinc.loinc\r\n\r\n{% else %}\r\n\r\nselect\r\n obs.observation_id\r\n , obs.patient_id\r\n , obs.encounter_id\r\n , obs.panel_id\r\n , obs.observation_date\r\n , obs.observation_type\r\n , obs.source_code_type\r\n , obs.source_code\r\n , obs.source_description\r\n , case\r\n when obs.normalized_code_type is not null then obs.normalized_code_type\r\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\r\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\r\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\r\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\r\n when hcpcs.hcpcs is not null then 'hcpcs'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n when loinc.loinc is not null then 'loinc'\r\n else custom_mapped.normalized_code_type end as normalized_code_type\r\n , coalesce(\r\n obs.normalized_code\r\n , icd10cm.icd_10_cm\r\n , icd9cm.icd_9_cm\r\n , icd10pcs.icd_10_pcs\r\n , icd9pcs.icd_9_pcs\r\n , hcpcs.hcpcs\r\n , snomed_ct.snomed_ct\r\n , loinc.loinc\r\n , custom_mapped.normalized_code\r\n ) as normalized_code\r\n , coalesce(\r\n obs.normalized_description\r\n , icd10cm.short_description\r\n , icd9cm.short_description\r\n , icd10pcs.description\r\n , icd9pcs.short_description\r\n , hcpcs.short_description\r\n , snomed_ct.description\r\n , loinc.long_common_name\r\n , custom_mapped.normalized_description\r\n ) as normalized_description\r\n , case\r\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\r\n when coalesce(\r\n icd10cm.icd_10_cm\r\n , icd9cm.icd_9_cm\r\n , icd10pcs.icd_10_pcs\r\n , icd9pcs.icd_9_pcs\r\n , hcpcs.hcpcs\r\n , snomed_ct.snomed_ct\r\n , loinc.loinc) is not null then 'automatic'\r\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\r\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\r\n end as mapping_method\r\n , obs.result\r\n , obs.source_units\r\n , obs.normalized_units\r\n , obs.source_reference_range_low\r\n , obs.source_reference_range_high\r\n , obs.normalized_reference_range_low\r\n , obs.normalized_reference_range_high\r\n , obs.data_source\r\n , obs.tuva_last_run\r\nfrom {{ ref('core__stg_clinical_observation')}} obs\r\nleft join {{ ref('terminology__icd_10_cm') }} icd10cm\r\n on obs.source_code_type = 'icd-10-cm'\r\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\r\nleft join {{ ref('terminology__icd_9_cm') }} icd9cm\r\n on obs.source_code_type = 'icd-9-cm'\r\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\r\nleft join {{ ref('terminology__icd_10_pcs') }} icd10pcs\r\n on obs.source_code_type = 'icd-10-pcs'\r\n and obs.source_code = icd10pcs.icd_10_pcs\r\nleft join {{ ref('terminology__icd_9_pcs') }} icd9pcs\r\n on obs.source_code_type = 'icd-9-pcs'\r\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\r\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\r\n on obs.source_code_type = 'hcpcs'\r\n and obs.source_code = hcpcs.hcpcs\r\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\r\n on obs.source_code_type = 'snomed-ct'\r\n and obs.source_code = snomed_ct.snomed_ct\r\nleft join {{ ref('terminology__loinc') }} loinc\r\n on obs.source_code_type = 'loinc'\r\n and obs.source_code = loinc.loinc\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(obs.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( obs.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (obs.source_code = custom_mapped.source_code\r\n or ( obs.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (obs.source_description = custom_mapped.source_description\r\n or ( obs.source_description is null and custom_mapped.source_description is null)\r\n )\r\n and not (obs.source_code is null and obs.source_description is null)\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_clinical_observation", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_clinical_observation", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__snomed_ct", "seed.the_tuva_project.terminology__loinc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__observation.sql", "compiled": true, "compiled_code": "\n\n\nselect\n obs.observation_id\n , obs.patient_id\n , obs.encounter_id\n , obs.panel_id\n , obs.observation_date\n , obs.observation_type\n , obs.source_code_type\n , obs.source_code\n , obs.source_description\n , case\n when obs.normalized_code_type is not null then obs.normalized_code_type\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n when loinc.loinc is not null then 'loinc'\n end as normalized_code_type\n , coalesce(\n obs.normalized_code\n , icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc\n ) as normalized_code\n , coalesce(\n obs.normalized_description\n , icd10cm.short_description\n , icd9cm.short_description\n , icd10pcs.description\n , icd9pcs.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , loinc.long_common_name\n ) as normalized_description\n , case\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\n when coalesce(\n icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc) is not null then 'automatic'\n end as mapping_method\n , obs.result\n , obs.source_units\n , obs.normalized_units\n , obs.source_reference_range_low\n , obs.source_reference_range_high\n , obs.normalized_reference_range_low\n , obs.normalized_reference_range_high\n , obs.data_source\n , obs.tuva_last_run\nfrom dev_thuxuan.test.core__stg_clinical_observation obs\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on obs.source_code_type = 'icd-10-cm'\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on obs.source_code_type = 'icd-9-cm'\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\nleft join dev_thuxuan.terminology.icd_10_pcs icd10pcs\n on obs.source_code_type = 'icd-10-pcs'\n and obs.source_code = icd10pcs.icd_10_pcs\nleft join dev_thuxuan.terminology.icd_9_pcs icd9pcs\n on obs.source_code_type = 'icd-9-pcs'\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\nleft join dev_thuxuan.terminology.hcpcs_level_2 hcpcs\n on obs.source_code_type = 'hcpcs'\n and obs.source_code = hcpcs.hcpcs\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on obs.source_code_type = 'snomed-ct'\n and obs.source_code = snomed_ct.snomed_ct\nleft join dev_thuxuan.terminology.loinc loinc\n on obs.source_code_type = 'loinc'\n and obs.source_code = loinc.loinc\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__patient": {"database": "dev_thuxuan", "schema": "core", "name": "core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__patient.sql", "original_file_path": "models\\core\\final\\core__patient.sql", "unique_id": "model.the_tuva_project.core__patient", "fqn": ["the_tuva_project", "core", "final", "core__patient"], "alias": "patient", "checksum": {"name": "sha256", "checksum": "91ee630a4a580f22cbd30dd748007dbe543ffc36b46d4c4e4b70a3fac167275f"}, "config": {"enabled": true, "alias": "patient", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The patient table contains demographic and geographic information on patients.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "race": {"name": "race", "description": "The patient's race.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "Date the patient died if there is one.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_flag": {"name": "death_flag", "description": "A flag indicating if the patient has died.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "The first name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "The last name of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "social_security_number": {"name": "social_security_number", "description": "The social security number of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "address": {"name": "address", "description": "The street address of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "city": {"name": "city", "description": "The city of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "zip_code": {"name": "zip_code", "description": "The zip code of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "county": {"name": "county", "description": "The county for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "The latitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "The longitude of the record (e.g., facility location, patient, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "phone": {"name": "phone", "description": "The phone number for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "The age of the patient calculated based on their date of birth and the last time the tuva project was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "The decade age group the patient falls into based on their calculated age.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "patient", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.942477, "relation_name": "dev_thuxuan.core.patient", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_patient') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_patient') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_patient') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_patient') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_patient", "package": null, "version": null}, {"name": "core__stg_clinical_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_patient", "model.the_tuva_project.core__stg_clinical_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__patient.sql", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_patient\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_patient\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__pharmacy_claim": {"database": "dev_thuxuan", "schema": "core", "name": "core__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__pharmacy_claim.sql", "original_file_path": "models\\core\\final\\core__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.core__pharmacy_claim", "fqn": ["the_tuva_project", "core", "final", "core__pharmacy_claim"], "alias": "pharmacy_claim", "checksum": {"name": "sha256", "checksum": "78711b940ffc41f4aa9dcdc0eafd9d8d8753cc313dec22d5282e7b10936dce37"}, "config": {"enabled": true, "alias": "pharmacy_claim", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The pharmacy claim table contains information on prescription drugs that were filled and billed to the insurer.\n", "columns": {"pharmacy_claim_id": {"name": "pharmacy_claim_id", "description": "Unique identifier for each row in the table.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Indicates the line number for the particular line of the claim.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_id": {"name": "prescribing_provider_id", "description": "ID for the provider that wrote the prescription (e.g. priamry care physician).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_name": {"name": "prescribing_provider_name", "description": "Prescribing provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_id": {"name": "dispensing_provider_id", "description": "ID for the provider that dispensed the prescription (e.g. pharmacy).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_name": {"name": "dispensing_provider_name", "description": "Dispensing provider name.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code associated with the medication.", "meta": {"terminology": "https://www.fda.gov/drugs/drug-approvals-and-databases/national-drug-code-directory"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description for the NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "The quantity of the medication.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "The number of days supply included.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the prescription.", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "The date the claim was paid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total amount allowed (includes amount paid by the insurer and patient).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coinsurance_amount": {"name": "coinsurance_amount", "description": "The total coinsurance charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "copayment_amount": {"name": "copayment_amount", "description": "The total copayment charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deductible_amount": {"name": "deductible_amount", "description": "The total amount charged on the claim by the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "in_network_flag": {"name": "in_network_flag", "description": "Flag indicating if the claim was in or out of network.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "pharmacy_claim", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9475327, "relation_name": "dev_thuxuan.core.pharmacy_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\nselect * from {{ ref('core__stg_claims_pharmacy_claim')}}", "language": "sql", "refs": [{"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__practitioner": {"database": "dev_thuxuan", "schema": "core", "name": "core__practitioner", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__practitioner.sql", "original_file_path": "models\\core\\final\\core__practitioner.sql", "unique_id": "model.the_tuva_project.core__practitioner", "fqn": ["the_tuva_project", "core", "final", "core__practitioner"], "alias": "practitioner", "checksum": {"name": "sha256", "checksum": "402fa1015c25b4347c00bde3d71b875be57fe24318ae1e40bcd349c6bf38f949"}, "config": {"enabled": true, "alias": "practitioner", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The practitioner table contains information on the providers in the dataset e.g. physicians, physicians assistants, etc.\n", "columns": {"practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "npi": {"name": "npi", "description": "The national provider identifier associated with the record e.g. facility_npi, provider_npi", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the healthcare provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_affiliation": {"name": "practice_affiliation", "description": "Practice affiliation of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty": {"name": "specialty", "description": "Specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sub_specialty": {"name": "sub_specialty", "description": "Sub specialty of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "practitioner", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9505324, "relation_name": "dev_thuxuan.core.practitioner", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true-%}\r\n\r\nselect * from {{ ref('core__stg_claims_practitioner') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_practitioner') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_practitioner') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_practitioner') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_practitioner", "package": null, "version": null}, {"name": "core__stg_clinical_practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_practitioner", "model.the_tuva_project.core__stg_clinical_practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__practitioner.sql", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_practitioner\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_practitioner\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__procedure": {"database": "dev_thuxuan", "schema": "core", "name": "core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\final\\core__procedure.sql", "original_file_path": "models\\core\\final\\core__procedure.sql", "unique_id": "model.the_tuva_project.core__procedure", "fqn": ["the_tuva_project", "core", "final", "core__procedure"], "alias": "procedure", "checksum": {"name": "sha256", "checksum": "e275bf8959d2fcc54801bdb31e0adb10988ae89ffa584e756b357179d0235bc5"}, "config": {"enabled": true, "alias": "procedure", "schema": "core", "database": null, "tags": ["core"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["core"], "description": "The procedure table contains information on procedures that were performed on patients in the dataset.\n", "columns": {"procedure_id": {"name": "procedure_id", "description": "The unique identifier for the performed procedure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "Unique identifier for each encounter in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date": {"name": "procedure_date", "description": "Date when the procedure was performed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_description": {"name": "source_description", "description": "Description of the source code in the source system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "The normalized type of code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__code_type.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "The normalized code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_description": {"name": "normalized_description", "description": "Normalized description of the code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mapping_method": {"name": "mapping_method", "description": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_1": {"name": "modifier_1", "description": "First modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_2": {"name": "modifier_2", "description": "Second modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_3": {"name": "modifier_3", "description": "Third modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_4": {"name": "modifier_4", "description": "Fourth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_5": {"name": "modifier_5", "description": "Fifth modifier for the procedure code.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__hcpcs_level_2.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practitioner_id": {"name": "practitioner_id", "description": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc).", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "core__stg_claims_medical_claim": {"name": "core__stg_claims_medical_claim", "description": "Staging core medical claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_medical_claim", "tags": ["core_stage_claims", "encounters"], "materialized": "table"}}, "core__stg_claims_encounter": {"name": "core__stg_claims_encounter", "description": "Staging core claims encounters", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_encounter", "tags": ["core_stage_claims", "encounters"], "materialized": "table"}}, "core__stg_claims_location": {"name": "core__stg_claims_location", "description": "Staging core claims locations", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_location", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_patient": {"name": "core__stg_claims_patient", "description": "Staging core claims patients", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_patient", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_condition": {"name": "core__stg_claims_condition", "description": "Staging core claims conditions", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_condition", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_procedure": {"name": "core__stg_claims_procedure", "description": "Staging core claims procedures", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_procedure", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_pharmacy_claim": {"name": "core__stg_claims_pharmacy_claim", "description": "Staging core pharmacy claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_pharmacy_claim", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_eligibility": {"name": "core__stg_claims_eligibility", "description": "Staging core eligibility", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_eligibility", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_claims_practitioner": {"name": "core__stg_claims_practitioner", "description": "Staging core providers in the claims dataset", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_claims_practitioner", "tags": "core_stage_claims", "materialized": "table"}}, "core__stg_clinical_condition": {"name": "core__stg_clinical_condition", "description": "Staging core clinical conditions", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_condition", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_encounter": {"name": "core__stg_clinical_encounter", "description": "Staging core clinical encounters", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_encounter", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_lab_result": {"name": "core__stg_clinical_lab_result", "description": "Staging core clinical lab results", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_lab_result", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_location": {"name": "core__stg_clinical_location", "description": "Staging core clinical locations", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_location", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_medication": {"name": "core__stg_clinical_medication", "description": "Staging core clinical medications", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_medication", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_observation": {"name": "core__stg_clinical_observation", "description": "Staging core clinical observations", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_observation", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_patient": {"name": "core__stg_clinical_patient", "description": "Staging core clinical patients", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_patient", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_practitioner": {"name": "core__stg_clinical_practitioner", "description": "Staging core clinical providers", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_practitioner", "tags": "core_stage_clinical", "materialized": "view"}}, "core__stg_clinical_procedure": {"name": "core__stg_clinical_procedure", "description": "Staging core clinical procedures", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "config": {"schema": "core", "alias": "_stg_clinical_procedure", "tags": "core_stage_clinical", "materialized": "view"}}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": "the_tuva_project://models\\core\\core_models.yml", "build_path": null, "unrendered_config": {"schema": "core", "alias": "procedure", "tags": "core", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866316.9755166, "relation_name": "dev_thuxuan.core.procedure", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith all_procedures as (\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_procedure') }}\r\nunion all\r\nselect * from {{ ref('core__stg_clinical_procedure') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_clinical_procedure') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect * from {{ ref('core__stg_claims_procedure') }}\r\n\r\n{%- endif %}\r\n)\r\n\r\n{% if var('enable_normalize_engine',false) != true %}\r\n\r\nselect\r\n all_procedures.procedure_id\r\n , all_procedures.patient_id\r\n , all_procedures.encounter_id\r\n , all_procedures.claim_id\r\n , all_procedures.procedure_date\r\n , all_procedures.source_code_type\r\n , all_procedures.source_code\r\n , all_procedures.source_description\r\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\r\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\r\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\r\n when hcpcs.hcpcs is not null then 'hcpcs'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n end as normalized_code_type\r\n , coalesce(all_procedures.normalized_code\r\n , icd10.icd_10_pcs\r\n , icd9.icd_9_pcs\r\n , hcpcs.hcpcs\r\n ,snomed_ct.snomed_ct ) as normalized_code\r\n , coalesce(all_procedures.normalized_description\r\n , icd10.description\r\n , icd9.short_description\r\n , hcpcs.short_description\r\n , snomed_ct.description) normalized_description\r\n , case when coalesce(all_procedures.normalized_code, all_procedures.normalized_description) is not null then 'manual'\r\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\r\n end as mapping_method\r\n , all_procedures.modifier_1\r\n , all_procedures.modifier_2\r\n , all_procedures.modifier_3\r\n , all_procedures.modifier_4\r\n , all_procedures.modifier_5\r\n , all_procedures.practitioner_id\r\n , all_procedures.data_source\r\n , all_procedures.tuva_last_run\r\nfrom all_procedures\r\nleft join {{ ref('terminology__icd_10_pcs') }} icd10\r\n on all_procedures.source_code_type = 'icd-10-pcs'\r\n and all_procedures.source_code = icd10.icd_10_pcs\r\nleft join {{ ref('terminology__icd_9_pcs') }} icd9\r\n on all_procedures.source_code_type = 'icd-9-pcs'\r\n and all_procedures.source_code = icd9.icd_9_pcs\r\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\r\n on all_procedures.source_code_type = 'hcpcs'\r\n and all_procedures.source_code = hcpcs.hcpcs\r\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\r\n on all_procedures.source_code_type = 'snomed-ct'\r\n and all_procedures.source_code = snomed_ct.snomed_ct\r\n\r\n\r\n{% else %}\r\n\r\n\r\nselect\r\n all_procedures.procedure_id\r\n , all_procedures.patient_id\r\n , all_procedures.encounter_id\r\n , all_procedures.claim_id\r\n , all_procedures.procedure_date\r\n , all_procedures.source_code_type\r\n , all_procedures.source_code\r\n , all_procedures.source_description\r\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\r\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\r\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\r\n when hcpcs.hcpcs is not null then 'hcpcs'\r\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\r\n else custom_mapped.normalized_code_type end as normalized_code_type\r\n , coalesce(all_procedures.normalized_code\r\n , icd10.icd_10_pcs\r\n , icd9.icd_9_pcs\r\n , hcpcs.hcpcs\r\n ,snomed_ct.snomed_ct\r\n ,custom_mapped.normalized_code ) as normalized_code\r\n , coalesce(all_procedures.normalized_description\r\n , icd10.description\r\n , icd9.short_description\r\n , hcpcs.short_description\r\n , snomed_ct.description\r\n , custom_mapped.normalized_description) as normalized_description\r\n , case when coalesce(all_procedures.normalized_code ,all_procedures.normalized_description) is not null then 'manual'\r\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\r\n when custom_mapped.not_mapped is not null then custom_mapped.not_mapped\r\n when coalesce(custom_mapped.normalized_code,custom_mapped.normalized_description) is not null then 'custom'\r\n end as mapping_method\r\n , all_procedures.modifier_1\r\n , all_procedures.modifier_2\r\n , all_procedures.modifier_3\r\n , all_procedures.modifier_4\r\n , all_procedures.modifier_5\r\n , all_procedures.practitioner_id\r\n , all_procedures.data_source\r\n , all_procedures.tuva_last_run\r\nfrom all_procedures\r\nleft join {{ ref('terminology__icd_10_pcs') }} icd10\r\n on all_procedures.source_code_type = 'icd-10-pcs'\r\n and all_procedures.source_code = icd10.icd_10_pcs\r\nleft join {{ ref('terminology__icd_9_pcs') }} icd9\r\n on all_procedures.source_code_type = 'icd-9-pcs'\r\n and all_procedures.source_code = icd9.icd_9_pcs\r\nleft join {{ ref('terminology__hcpcs_level_2') }} hcpcs\r\n on all_procedures.source_code_type = 'hcpcs'\r\n and all_procedures.source_code = hcpcs.hcpcs\r\nleft join {{ ref('terminology__snomed_ct')}} snomed_ct\r\n on all_procedures.source_code_type = 'snomed-ct'\r\n and all_procedures.source_code = snomed_ct.snomed_ct\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(all_procedures.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( all_procedures.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (all_procedures.source_code = custom_mapped.source_code\r\n or ( all_procedures.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (all_procedures.source_description = custom_mapped.source_description\r\n or ( all_procedures.source_description is null and custom_mapped.source_description is null)\r\n )\r\n and not (all_procedures.source_code is null and all_procedures.source_description is null)\r\n\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__stg_claims_procedure", "package": null, "version": null}, {"name": "core__stg_clinical_procedure", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "terminology__snomed_ct", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.core__stg_clinical_procedure", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__snomed_ct"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\final\\core__procedure.sql", "compiled": true, "compiled_code": "\n\n\nwith all_procedures as (\nselect * from dev_thuxuan.test.core__stg_claims_procedure\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_procedure\n\n\n)\n\n\n\nselect\n all_procedures.procedure_id\n , all_procedures.patient_id\n , all_procedures.encounter_id\n , all_procedures.claim_id\n , all_procedures.procedure_date\n , all_procedures.source_code_type\n , all_procedures.source_code\n , all_procedures.source_description\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n end as normalized_code_type\n , coalesce(all_procedures.normalized_code\n , icd10.icd_10_pcs\n , icd9.icd_9_pcs\n , hcpcs.hcpcs\n ,snomed_ct.snomed_ct ) as normalized_code\n , coalesce(all_procedures.normalized_description\n , icd10.description\n , icd9.short_description\n , hcpcs.short_description\n , snomed_ct.description) normalized_description\n , case when coalesce(all_procedures.normalized_code, all_procedures.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_procedures.modifier_1\n , all_procedures.modifier_2\n , all_procedures.modifier_3\n , all_procedures.modifier_4\n , all_procedures.modifier_5\n , all_procedures.practitioner_id\n , all_procedures.data_source\n , all_procedures.tuva_last_run\nfrom all_procedures\nleft join dev_thuxuan.terminology.icd_10_pcs icd10\n on all_procedures.source_code_type = 'icd-10-pcs'\n and all_procedures.source_code = icd10.icd_10_pcs\nleft join dev_thuxuan.terminology.icd_9_pcs icd9\n on all_procedures.source_code_type = 'icd-9-pcs'\n and all_procedures.source_code = icd9.icd_9_pcs\nleft join dev_thuxuan.terminology.hcpcs_level_2 hcpcs\n on all_procedures.source_code_type = 'hcpcs'\n and all_procedures.source_code = hcpcs.hcpcs\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on all_procedures.source_code_type = 'snomed-ct'\n and all_procedures.source_code = snomed_ct.snomed_ct\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_condition": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_condition.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_condition.sql", "unique_id": "model.the_tuva_project.core__stg_claims_condition", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_condition"], "alias": "core__stg_claims_condition", "checksum": {"name": "sha256", "checksum": "4b9c7e4321f6874ec15954ed470d8c49f14914b59a677042312e16d8d04e1c47"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.3852463, "relation_name": "dev_thuxuan.test.core__stg_claims_condition", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the condition table in core.\r\n-- *************************************************\r\n\r\nwith unpivot_cte as (\r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_1 as source_code\r\n , 1 as diagnosis_rank\r\n , diagnosis_poa_1 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere diagnosis_code_1 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n\t , discharge_date\r\n\t , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_2 as source_code\r\n , 2 as diagnosis_rank\r\n , diagnosis_poa_2 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_2 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_3 as source_code\r\n , 3 as diagnosis_rank\r\n , diagnosis_poa_3 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_3 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_4 as source_code\r\n , 4 as diagnosis_rank\r\n , diagnosis_poa_4 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_4 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_5 as source_code\r\n , 5 as diagnosis_rank\r\n , diagnosis_poa_5 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_5 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_6 as source_code\r\n , 6 as diagnosis_rank\r\n , diagnosis_poa_6 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_6 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_7 as source_code\r\n , 7 as diagnosis_rank\r\n , diagnosis_poa_7 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_7 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_8 as source_code\r\n , 8 as diagnosis_rank\r\n , diagnosis_poa_8 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_8 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_9 as source_code\r\n , 9 as diagnosis_rank\r\n , diagnosis_poa_9 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_9 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_10 as source_code\r\n , 10 as diagnosis_rank\r\n , diagnosis_poa_10 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_10 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_11 as source_code\r\n , 11 as diagnosis_rank\r\n , diagnosis_poa_11 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_11 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_12 as source_code\r\n , 12 as diagnosis_rank\r\n , diagnosis_poa_12 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_12 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_13 as source_code\r\n , 13 as diagnosis_rank\r\n , diagnosis_poa_13 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_13 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_14 as source_code\r\n , 14 as diagnosis_rank\r\n , diagnosis_poa_14 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_14 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_15 as source_code\r\n , 15 as diagnosis_rank\r\n , diagnosis_poa_15 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_15 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_16 as source_code\r\n , 16 as diagnosis_rank\r\n , diagnosis_poa_16 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_16 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_17 as source_code\r\n , 17 as diagnosis_rank\r\n , diagnosis_poa_17 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_17 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_18 as source_code\r\n , 18 as diagnosis_rank\r\n , diagnosis_poa_18 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_18 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_19 as source_code\r\n , 19 as diagnosis_rank\r\n , diagnosis_poa_19 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_19 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_20 as source_code\r\n , 20 as diagnosis_rank\r\n , diagnosis_poa_20 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_20 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_21 as source_code\r\n , 21 as diagnosis_rank\r\n , diagnosis_poa_21 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_21 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_22 as source_code\r\n , 22 as diagnosis_rank\r\n , diagnosis_poa_22 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_22 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_23 as source_code\r\n , 23 as diagnosis_rank\r\n , diagnosis_poa_23 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_23 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_24 as source_code\r\n , 24 as diagnosis_rank\r\n , diagnosis_poa_24 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_24 is not null\r\n\r\nunion all \r\n\r\nselect\r\n claim_id\r\n , claim_line_number\r\n , patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as recorded_date\r\n , 'discharge_diagnosis' as condition_type\r\n , diagnosis_code_type as source_code_type\r\n , diagnosis_code_25 as source_code\r\n , 25 as diagnosis_rank\r\n , diagnosis_poa_25 as present_on_admit_code\r\n , data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere diagnosis_code_25 is not null\r\n\r\n)\r\n\r\nselect distinct\r\n{{ dbt.safe_cast(\r\n dbt.concat([\r\n \"CAST(unpivot_cte.data_source AS \" ~ dbt.type_string() ~ \")\",\r\n \"'_'\",\r\n \"CAST(unpivot_cte.claim_id AS \" ~ dbt.type_string() ~ \")\",\r\n \"'_'\",\r\n \"CAST(unpivot_cte.diagnosis_rank AS \" ~ dbt.type_string() ~ \")\",\r\n \"'_'\",\r\n \"CAST(unpivot_cte.source_code AS \" ~ dbt.type_string() ~ \")\",\r\n ]), api.Column.translate_type(\"string\"))\r\n }} as condition_id\r\n\r\n , cast(unpivot_cte.patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\r\n , cast(unpivot_cte.claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , {{ try_to_cast_date('unpivot_cte.recorded_date', 'YYYY-MM-DD') }} as recorded_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as onset_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as resolved_date\r\n , cast('active' as {{ dbt.type_string() }} ) as status\r\n , cast(unpivot_cte.condition_type as {{ dbt.type_string() }} ) as condition_type\r\n , cast(unpivot_cte.source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(unpivot_cte.source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(\r\n case\r\n when icd.icd_10_cm is not null then 'icd-10-cm'\r\n end as {{ dbt.type_string() }}\r\n ) as normalized_code_type\r\n , cast(icd.icd_10_cm as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(icd.long_description as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(unpivot_cte.diagnosis_rank as {{ dbt.type_int() }} ) as condition_rank\r\n , cast(unpivot_cte.present_on_admit_code as {{ dbt.type_string() }} ) as present_on_admit_code\r\n , cast(poa.present_on_admit_description as {{ dbt.type_string() }} ) as present_on_admit_description\r\n , cast(unpivot_cte.data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom unpivot_cte\r\n--inner join {{ ref('encounters__combined_claim_line_crosswalk') }} x on unpivot_cte.claim_id = x.claim_id\r\n--and\r\n--unpivot_cte.claim_line_number = x.claim_line_number\r\n--and\r\n--x.claim_line_attribution_number = 1\r\nleft join {{ ref('terminology__icd_10_cm') }} icd\r\n on unpivot_cte.source_code = icd.icd_10_cm\r\nleft join {{ ref('terminology__present_on_admission') }} as poa\r\n on unpivot_cte.present_on_admit_code = poa.present_on_admit_code", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__present_on_admission", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.safe_cast", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__present_on_admission"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_condition.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the condition table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_1 as source_code\n , 1 as diagnosis_rank\n , diagnosis_poa_1 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere diagnosis_code_1 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n\t , discharge_date\n\t , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_2 as source_code\n , 2 as diagnosis_rank\n , diagnosis_poa_2 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_2 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_3 as source_code\n , 3 as diagnosis_rank\n , diagnosis_poa_3 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_3 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_4 as source_code\n , 4 as diagnosis_rank\n , diagnosis_poa_4 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_4 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_5 as source_code\n , 5 as diagnosis_rank\n , diagnosis_poa_5 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_5 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_6 as source_code\n , 6 as diagnosis_rank\n , diagnosis_poa_6 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_6 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_7 as source_code\n , 7 as diagnosis_rank\n , diagnosis_poa_7 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_7 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_8 as source_code\n , 8 as diagnosis_rank\n , diagnosis_poa_8 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_8 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_9 as source_code\n , 9 as diagnosis_rank\n , diagnosis_poa_9 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_9 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_10 as source_code\n , 10 as diagnosis_rank\n , diagnosis_poa_10 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_10 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_11 as source_code\n , 11 as diagnosis_rank\n , diagnosis_poa_11 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_11 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_12 as source_code\n , 12 as diagnosis_rank\n , diagnosis_poa_12 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_12 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_13 as source_code\n , 13 as diagnosis_rank\n , diagnosis_poa_13 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_13 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_14 as source_code\n , 14 as diagnosis_rank\n , diagnosis_poa_14 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_14 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_15 as source_code\n , 15 as diagnosis_rank\n , diagnosis_poa_15 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_15 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_16 as source_code\n , 16 as diagnosis_rank\n , diagnosis_poa_16 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_16 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_17 as source_code\n , 17 as diagnosis_rank\n , diagnosis_poa_17 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_17 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_18 as source_code\n , 18 as diagnosis_rank\n , diagnosis_poa_18 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_18 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_19 as source_code\n , 19 as diagnosis_rank\n , diagnosis_poa_19 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_19 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_20 as source_code\n , 20 as diagnosis_rank\n , diagnosis_poa_20 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_20 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_21 as source_code\n , 21 as diagnosis_rank\n , diagnosis_poa_21 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_21 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_22 as source_code\n , 22 as diagnosis_rank\n , diagnosis_poa_22 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_22 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_23 as source_code\n , 23 as diagnosis_rank\n , diagnosis_poa_23 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_23 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_24 as source_code\n , 24 as diagnosis_rank\n , diagnosis_poa_24 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_24 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_25 as source_code\n , 25 as diagnosis_rank\n , diagnosis_poa_25 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(CAST(unpivot_cte.data_source AS TEXT) || '_' || CAST(unpivot_cte.claim_id AS TEXT) || '_' || CAST(unpivot_cte.diagnosis_rank AS TEXT) || '_' || CAST(unpivot_cte.source_code AS TEXT) as TEXT)\n as condition_id\n\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.recorded_date as date ) as recorded_date\n , try_cast( null as date ) as onset_date\n , try_cast( null as date ) as resolved_date\n , cast('active' as TEXT ) as status\n , cast(unpivot_cte.condition_type as TEXT ) as condition_type\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_cm is not null then 'icd-10-cm'\n end as TEXT\n ) as normalized_code_type\n , cast(icd.icd_10_cm as TEXT ) as normalized_code\n , cast(icd.long_description as TEXT ) as normalized_description\n , cast(unpivot_cte.diagnosis_rank as integer ) as condition_rank\n , cast(unpivot_cte.present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(poa.present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join dev_thuxuan.terminology.icd_10_cm icd\n on unpivot_cte.source_code = icd.icd_10_cm\nleft join dev_thuxuan.terminology.present_on_admission as poa\n on unpivot_cte.present_on_admit_code = poa.present_on_admit_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_eligibility": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_eligibility.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_eligibility.sql", "unique_id": "model.the_tuva_project.core__stg_claims_eligibility", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_eligibility"], "alias": "core__stg_claims_eligibility", "checksum": {"name": "sha256", "checksum": "bfe640c5493aa2345aec6350b715a2de3b3692ab805d74bd82d8ee8b9247aef7"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4009206, "relation_name": "dev_thuxuan.test.core__stg_claims_eligibility", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the eligibility table in core.\r\n-- *************************************************\r\n\r\n\r\n\r\n\r\nselect\r\n {{ dbt.concat([\r\n \"member_id\",\r\n \"'-'\",\r\n \"enrollment_start_date\",\r\n \"'-'\",\r\n \"enrollment_end_date\",\r\n \"'-'\",\r\n \"payer\",\r\n \"'-'\",\r\n quote_column('plan'),\r\n ]) }} as eligibility_id\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(member_id as {{ dbt.type_string() }} ) as member_id\r\n , cast(subscriber_id as {{ dbt.type_string() }} ) as subscriber_id\r\n , cast(birth_date as date) as birth_date\r\n , cast(death_date as date) as death_date\r\n , cast(enrollment_start_date as date ) as enrollment_start_date\r\n , cast(enrollment_end_date as date ) as enrollment_end_date\r\n , cast(payer as {{ dbt.type_string() }} ) as payer\r\n , cast(payer_type as {{ dbt.type_string() }} ) as payer_type\r\n , {{ quote_column('plan') }}\r\n , cast(original_reason_entitlement_code as {{ dbt.type_string() }} ) as original_reason_entitlement_code\r\n , cast(dual_status_code as {{ dbt.type_string() }} ) as dual_status_code\r\n , cast(medicare_status_code as {{ dbt.type_string() }} ) as medicare_status_code\r\n , cast(subscriber_relation as {{ dbt.type_string() }} ) as subscriber_relation\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__eligibility') }}", "language": "sql", "refs": [{"name": "normalized_input__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.normalized_input__eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_eligibility.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the eligibility table in core.\n-- *************************************************\n\n\n\n\nselect\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(subscriber_id as TEXT ) as subscriber_id\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(enrollment_start_date as date ) as enrollment_start_date\n , cast(enrollment_end_date as date ) as enrollment_end_date\n , cast(payer as TEXT ) as payer\n , cast(payer_type as TEXT ) as payer_type\n , plan\n , cast(original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(dual_status_code as TEXT ) as dual_status_code\n , cast(medicare_status_code as TEXT ) as medicare_status_code\n , cast(subscriber_relation as TEXT ) as subscriber_relation\n , cast(data_source as TEXT ) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_encounter": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_encounter.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_encounter.sql", "unique_id": "model.the_tuva_project.core__stg_claims_encounter", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_encounter"], "alias": "core__stg_claims_encounter", "checksum": {"name": "sha256", "checksum": "3a9f13cfd6499ccad522181b3a6118e8766cb7ccc051f761afe9a52b90a29c20"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "materialized": "table", "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4089234, "relation_name": "dev_thuxuan.test.core__stg_claims_encounter", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the encounter table in core using dbt_utils.union_relations.\r\n-- *************************************************\r\n\r\n{{ config(materialized='table') }}\r\n\r\nWITH base AS (\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('acute_inpatient__encounter_grain')\r\n , ref('emergency_department__encounter_grain')\r\n , ref('inpatient_hospice__encounter_grain')\r\n , ref('inpatient_psych__encounter_grain')\r\n , ref('inpatient_rehab__encounter_grain')\r\n , ref('inpatient_snf__encounter_grain')\r\n , ref('inpatient_substance_use__encounter_grain')\r\n , ref('urgent_care__encounter_grain')\r\n , ref('office_visit__encounter_grain')\r\n , ref('outpatient_hospice__encounter_grain')\r\n , ref('outpatient_hospital_or_clinic__encounter_grain')\r\n , ref('outpatient_injections__encounter_grain')\r\n , ref('outpatient_psych__encounter_grain')\r\n , ref('outpatient_ptotst__encounter_grain')\r\n , ref('outpatient_surgery__encounter_grain')\r\n , ref('outpatient_radiology__encounter_grain')\r\n , ref('outpatient_rehab__encounter_grain')\r\n , ref('outpatient_substance_use__encounter_grain')\r\n , ref('home_health__encounter_grain')\r\n , ref('dialysis__encounter_grain')\r\n , ref('asc__encounter_grain')\r\n , ref('ambulance__encounter_grain')\r\n , ref('dme__encounter_grain')\r\n , ref('lab__encounter_grain')\r\n , ref('orphaned_claim__encounter_grain')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n)\r\n\r\nSELECT\r\n cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(p.patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(encounter_type as {{ dbt.type_string() }} ) as encounter_type\r\n , cast(encounter_group as {{ dbt.type_string() }} ) as encounter_group\r\n , {{ try_to_cast_date('encounter_start_date', 'YYYY-MM-DD') }} as encounter_start_date\r\n , {{ try_to_cast_date('encounter_end_date', 'YYYY-MM-DD') }} as encounter_end_date\r\n , cast(length_of_stay as {{ dbt.type_int() }} ) as length_of_stay\r\n , cast(admit_source_code as {{ dbt.type_string() }} ) as admit_source_code\r\n , cast(admit_source_description as {{ dbt.type_string() }} ) as admit_source_description\r\n , cast(admit_type_code as {{ dbt.type_string() }} ) as admit_type_code\r\n , cast(admit_type_description as {{ dbt.type_string() }} ) as admit_type_description\r\n , cast(discharge_disposition_code as {{ dbt.type_string() }} ) as discharge_disposition_code\r\n , cast(discharge_disposition_description as {{ dbt.type_string() }} ) as discharge_disposition_description\r\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_id\r\n , cast(null as {{ dbt.type_string() }} ) as attending_provider_name\r\n , cast(facility_id as {{ dbt.type_string() }} ) as facility_id\r\n , cast(facility_name as {{ dbt.type_string() }} ) as facility_name\r\n , cast(facility_type as {{ dbt.type_string() }} ) as facility_type\r\n , cast(observation_flag as {{ dbt.type_int() }} ) as observation_flag\r\n , cast(lab_flag as {{ dbt.type_int() }} ) as lab_flag\r\n , cast(dme_flag as {{ dbt.type_int() }} ) as dme_flag\r\n , cast(ambulance_flag as {{ dbt.type_int() }} ) as ambulance_flag\r\n , cast(pharmacy_flag as {{ dbt.type_int() }} ) as pharmacy_flag\r\n , cast(ed_flag as {{ dbt.type_int() }} ) as ed_flag\r\n , cast(delivery_flag as {{ dbt.type_int() }} ) as delivery_flag\r\n , cast(delivery_type as {{ dbt.type_string() }} ) as delivery_type\r\n , cast(newborn_flag as {{ dbt.type_int() }} ) as newborn_flag\r\n , cast(nicu_flag as {{ dbt.type_int() }} ) as nicu_flag\r\n , cast(primary_diagnosis_code_type as {{ dbt.type_string() }} ) as primary_diagnosis_code_type\r\n , cast(primary_diagnosis_code as {{ dbt.type_string() }} ) as primary_diagnosis_code\r\n , cast(primary_diagnosis_description as {{ dbt.type_string() }} ) as primary_diagnosis_description\r\n , cast(ms_drg_code as {{ dbt.type_string() }} ) as ms_drg_code\r\n , cast(ms_drg_description as {{ dbt.type_string() }} ) as ms_drg_description\r\n , cast(apr_drg_code as {{ dbt.type_string() }} ) as apr_drg_code\r\n , cast(apr_drg_description as {{ dbt.type_string() }} ) as apr_drg_description\r\n , cast(total_paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\r\n , cast(total_allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\r\n , cast(total_charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\r\n , cast(claim_count as {{ dbt.type_int() }}) as claim_count\r\n , cast(inst_claim_count as {{ dbt.type_int() }}) as inst_claim_count\r\n , cast(prof_claim_count as {{ dbt.type_int() }}) as prof_claim_count\r\n , cast(_dbt_source_relation as {{ dbt.type_string() }}) as source_model\r\n , cast(base.data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nFROM base\r\ninner join {{ ref('encounters__patient_data_source_id') }} p on base.patient_data_source_id = p.patient_data_source_id", "language": "sql", "refs": [{"name": "acute_inpatient__encounter_grain", "package": null, "version": null}, {"name": "emergency_department__encounter_grain", "package": null, "version": null}, {"name": "inpatient_hospice__encounter_grain", "package": null, "version": null}, {"name": "inpatient_psych__encounter_grain", "package": null, "version": null}, {"name": "inpatient_rehab__encounter_grain", "package": null, "version": null}, {"name": "inpatient_snf__encounter_grain", "package": null, "version": null}, {"name": "inpatient_substance_use__encounter_grain", "package": null, "version": null}, {"name": "urgent_care__encounter_grain", "package": null, "version": null}, {"name": "office_visit__encounter_grain", "package": null, "version": null}, {"name": "outpatient_hospice__encounter_grain", "package": null, "version": null}, {"name": "outpatient_hospital_or_clinic__encounter_grain", "package": null, "version": null}, {"name": "outpatient_injections__encounter_grain", "package": null, "version": null}, {"name": "outpatient_psych__encounter_grain", "package": null, "version": null}, {"name": "outpatient_ptotst__encounter_grain", "package": null, "version": null}, {"name": "outpatient_surgery__encounter_grain", "package": null, "version": null}, {"name": "outpatient_radiology__encounter_grain", "package": null, "version": null}, {"name": "outpatient_rehab__encounter_grain", "package": null, "version": null}, {"name": "outpatient_substance_use__encounter_grain", "package": null, "version": null}, {"name": "home_health__encounter_grain", "package": null, "version": null}, {"name": "dialysis__encounter_grain", "package": null, "version": null}, {"name": "asc__encounter_grain", "package": null, "version": null}, {"name": "ambulance__encounter_grain", "package": null, "version": null}, {"name": "dme__encounter_grain", "package": null, "version": null}, {"name": "lab__encounter_grain", "package": null, "version": null}, {"name": "orphaned_claim__encounter_grain", "package": null, "version": null}, {"name": "encounters__patient_data_source_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations", "macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.encounters__patient_data_source_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_encounter.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the encounter table in core using dbt_utils.union_relations.\n-- *************************************************\n\n\n\nWITH base AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.acute_inpatient__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(\"DELIVERY_FLAG\" as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(\"DELIVERY_TYPE\" as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(\"NEWBORN_FLAG\" as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(\"NICU_FLAG\" as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.acute_inpatient__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.emergency_department__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.emergency_department__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_snf__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_snf__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.urgent_care__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.urgent_care__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.office_visit__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(null as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"BILLING_ID\" as character varying(16777216)) as \"BILLING_ID\" ,\n cast(\"PROVIDER_NAME\" as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(\"PROVIDER_SPECIALTY\" as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(\"CCS_CATEGORY\" as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(\"CCS_CATEGORY_DESCRIPTION\" as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.office_visit__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_injections__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_injections__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_ptotst__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_ptotst__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_surgery__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_surgery__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_radiology__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_radiology__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.home_health__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.home_health__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.dialysis__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.dialysis__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.asc__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.asc__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.ambulance__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.ambulance__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.dme__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.dme__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.lab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.lab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.orphaned_claim__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.orphaned_claim__encounter_grain\n\n \n )\n\n \n)\n\nSELECT\n cast(encounter_id as TEXT ) as encounter_id\n , cast(p.patient_id as TEXT ) as patient_id\n , cast(encounter_type as TEXT ) as encounter_type\n , cast(encounter_group as TEXT ) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer ) as length_of_stay\n , cast(admit_source_code as TEXT ) as admit_source_code\n , cast(admit_source_description as TEXT ) as admit_source_description\n , cast(admit_type_code as TEXT ) as admit_type_code\n , cast(admit_type_description as TEXT ) as admit_type_description\n , cast(discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(facility_id as TEXT ) as facility_id\n , cast(facility_name as TEXT ) as facility_name\n , cast(facility_type as TEXT ) as facility_type\n , cast(observation_flag as integer ) as observation_flag\n , cast(lab_flag as integer ) as lab_flag\n , cast(dme_flag as integer ) as dme_flag\n , cast(ambulance_flag as integer ) as ambulance_flag\n , cast(pharmacy_flag as integer ) as pharmacy_flag\n , cast(ed_flag as integer ) as ed_flag\n , cast(delivery_flag as integer ) as delivery_flag\n , cast(delivery_type as TEXT ) as delivery_type\n , cast(newborn_flag as integer ) as newborn_flag\n , cast(nicu_flag as integer ) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT ) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT ) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT ) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT ) as ms_drg_code\n , cast(ms_drg_description as TEXT ) as ms_drg_description\n , cast(apr_drg_code as TEXT ) as apr_drg_code\n , cast(apr_drg_description as TEXT ) as apr_drg_description\n , cast(total_paid_amount as numeric(28,6) ) as paid_amount\n , cast(total_allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(total_charge_amount as numeric(28,6) ) as charge_amount\n , cast(claim_count as integer) as claim_count\n , cast(inst_claim_count as integer) as inst_claim_count\n , cast(prof_claim_count as integer) as prof_claim_count\n , cast(_dbt_source_relation as TEXT) as source_model\n , cast(base.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nFROM base\ninner join dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id p on base.patient_data_source_id = p.patient_data_source_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_location": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_location", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_location.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_location.sql", "unique_id": "model.the_tuva_project.core__stg_claims_location", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_location"], "alias": "core__stg_claims_location", "checksum": {"name": "sha256", "checksum": "ffa7c2be027b30666fc656cbb3cfa4ea1ab6c29d347ed76cec8c095192b8ffcb"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4259815, "relation_name": "dev_thuxuan.test.core__stg_claims_location", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith all_providers_in_claims_dataset as (\r\nselect distinct facility_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct rendering_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct billing_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct prescribing_provider_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct dispensing_provider_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\r\n),\r\n\r\n\r\nprovider as (\r\nselect aa.*, bb.data_source\r\nfrom {{ ref('terminology__provider') }} aa\r\ninner join all_providers_in_claims_dataset bb\r\non aa.npi = bb.npi\r\nwhere lower(aa.entity_type_description) = 'organization'\r\n)\r\n\r\n\r\n\r\nselect \r\n cast(npi as {{ dbt.type_string() }} ) as location_id\r\n , cast(npi as {{ dbt.type_string() }} ) as npi\r\n , cast(provider_organization_name as {{ dbt.type_string() }} ) as name\r\n , cast(null as {{ dbt.type_string() }} ) as facility_type\r\n , cast(parent_organization_name as {{ dbt.type_string() }} ) as parent_organization\r\n , cast(practice_address_line_1 as {{ dbt.type_string() }} ) as address\r\n , cast(practice_city as {{ dbt.type_string() }} ) as city\r\n , cast(practice_state as {{ dbt.type_string() }} ) as state\r\n , cast(practice_zip_code as {{ dbt.type_string() }} ) as zip_code\r\n , cast(null as {{ dbt.type_float() }} ) as latitude\r\n , cast(null as {{ dbt.type_float() }} ) as longitude\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast( '{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom provider", "language": "sql", "refs": [{"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_location.sql", "compiled": true, "compiled_code": "\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom dev_thuxuan.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'organization'\n)\n\n\n\nselect \n cast(npi as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(provider_organization_name as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(parent_organization_name as TEXT ) as parent_organization\n , cast(practice_address_line_1 as TEXT ) as address\n , cast(practice_city as TEXT ) as city\n , cast(practice_state as TEXT ) as state\n , cast(practice_zip_code as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast( '2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom provider", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_medical_claim": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_medical_claim.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_medical_claim.sql", "unique_id": "model.the_tuva_project.core__stg_claims_medical_claim", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_medical_claim"], "alias": "core__stg_claims_medical_claim", "checksum": {"name": "sha256", "checksum": "3c642670124735b994e1b3f72bbbe7de877b7429c6991e12bf76227e415dbdae"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4349818, "relation_name": "dev_thuxuan.test.core__stg_claims_medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the medical_claim table\r\n-- in core. It adds these 4 fields to the input layer\r\n-- medical claim table:\r\n-- encounter_id\r\n-- service_category_1\r\n-- service_category_2\r\n-- *************************************************\r\n\r\nwith all_encounters as (\r\n select claim_id\r\n, claim_line_number\r\n, encounter_id\r\n, encounter_type\r\n, encounter_group\r\n from {{ ref('encounters__combined_claim_line_crosswalk') }}\r\n where claim_line_attribution_number = 1\r\n \r\n union all \r\n\r\n select \r\n claim_id\r\n, claim_line_number\r\n, encounter_id\r\n, encounter_type\r\n, encounter_group\r\n from {{ ref('encounters__orphaned_claims') }}\r\n)\r\n\r\n\r\nselect\r\n {{ dbt.concat([\r\n \"med.claim_id\",\r\n \"'-'\",\r\n \"med.claim_line_number\"\r\n ]) }} as medical_claim_id\r\n , cast(med.claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , cast(med.claim_line_number as {{ dbt.type_int() }} ) as claim_line_number\r\n , cast(x.encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(x.encounter_type as {{ dbt.type_string() }} ) as encounter_type\r\n , cast(x.encounter_group as {{ dbt.type_string() }} ) as encounter_group\r\n , cast(med.claim_type as {{ dbt.type_string() }} ) as claim_type\r\n , cast(med.patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(med.member_id as {{ dbt.type_string() }} ) as member_id\r\n , cast(med.payer as {{ dbt.type_string() }} ) as payer\r\n , med.{{ quote_column('plan') }}\r\n , {{ try_to_cast_date('med.claim_start_date', 'YYYY-MM-DD') }} as claim_start_date\r\n , {{ try_to_cast_date('med.claim_end_date', 'YYYY-MM-DD') }} as claim_end_date\r\n , {{ try_to_cast_date('med.claim_line_start_date', 'YYYY-MM-DD') }} as claim_line_start_date\r\n , {{ try_to_cast_date('med.claim_line_end_date', 'YYYY-MM-DD') }} as claim_line_end_date\r\n , {{ try_to_cast_date('med.admission_date', 'YYYY-MM-DD') }} as admission_date\r\n , {{ try_to_cast_date('med.discharge_date', 'YYYY-MM-DD') }} as discharge_date\r\n , cast(srv_group.service_category_1 as {{ dbt.type_string() }} ) as service_category_1\r\n , cast(srv_group.service_category_2 as {{ dbt.type_string() }} ) as service_category_2\r\n , cast(srv_group.service_category_3 as {{ dbt.type_string() }} ) as service_category_3\r\n , cast(med.admit_source_code as {{ dbt.type_string() }} ) as admit_source_code\r\n , cast(med.admit_source_description as {{ dbt.type_string() }} ) as admit_source_description\r\n , cast(med.admit_type_code as {{ dbt.type_string() }} ) as admit_type_code\r\n , cast(med.admit_type_description as {{ dbt.type_string() }} ) as admit_type_description\r\n , cast(med.discharge_disposition_code as {{ dbt.type_string() }} ) as discharge_disposition_code\r\n , cast(med.discharge_disposition_description as {{ dbt.type_string() }} ) as discharge_disposition_description\r\n , cast(med.place_of_service_code as {{ dbt.type_string() }} ) as place_of_service_code\r\n , cast(med.place_of_service_description as {{ dbt.type_string() }} ) as place_of_service_description\r\n , cast(med.bill_type_code as {{ dbt.type_string() }} ) as bill_type_code\r\n , cast(med.bill_type_description as {{ dbt.type_string() }} ) as bill_type_description\r\n , cast(med.ms_drg_code as {{ dbt.type_string() }} ) as ms_drg_code\r\n , cast(med.ms_drg_description as {{ dbt.type_string() }} ) as ms_drg_description\r\n , cast(med.apr_drg_code as {{ dbt.type_string() }} ) as apr_drg_code\r\n , cast(med.apr_drg_description as {{ dbt.type_string() }} ) as apr_drg_description\r\n , cast(med.revenue_center_code as {{ dbt.type_string() }} ) as revenue_center_code\r\n , cast(med.revenue_center_description as {{ dbt.type_string() }} ) as revenue_center_description\r\n , cast(med.service_unit_quantity as {{ dbt.type_numeric() }} ) as service_unit_quantity\r\n , cast(med.hcpcs_code as {{ dbt.type_string() }} ) as hcpcs_code\r\n , cast(med.hcpcs_modifier_1 as {{ dbt.type_string() }} ) as hcpcs_modifier_1\r\n , cast(med.hcpcs_modifier_2 as {{ dbt.type_string() }} ) as hcpcs_modifier_2\r\n , cast(med.hcpcs_modifier_3 as {{ dbt.type_string() }} ) as hcpcs_modifier_3\r\n , cast(med.hcpcs_modifier_4 as {{ dbt.type_string() }} ) as hcpcs_modifier_4\r\n , cast(med.hcpcs_modifier_5 as {{ dbt.type_string() }} ) as hcpcs_modifier_5\r\n , cast(med.rendering_id as {{ dbt.type_string() }} ) as rendering_id\r\n , cast(med.rendering_tin as {{ dbt.type_string() }} ) as rendering_tin\r\n , cast(med.rendering_name as {{ dbt.type_string() }} ) as rendering_name\r\n , cast(med.billing_id as {{ dbt.type_string() }} ) as billing_id\r\n , cast(med.billing_tin as {{ dbt.type_string() }} ) as billing_tin\r\n , cast(med.billing_name as {{ dbt.type_string() }} ) as billing_name\r\n , cast(med.facility_id as {{ dbt.type_string() }} ) as facility_id\r\n , cast(med.facility_name as {{ dbt.type_string() }} ) as facility_name\r\n , {{ try_to_cast_date('med.paid_date', 'YYYY-MM-DD') }} as paid_date\r\n , cast(med.paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\r\n , cast(med.allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\r\n , cast(med.charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\r\n , cast(med.coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\r\n , cast(med.copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\r\n , cast(med.deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\r\n , cast(med.total_cost_amount as {{ dbt.type_numeric() }} ) as total_cost_amount\r\n , cast(med.in_network_flag as int ) as in_network_flag\r\n , cast(\r\n case\r\n when enroll.claim_id is not null then 1\r\n else 0\r\n end as int) as enrollment_flag\r\n , cast(med.data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('normalized_input__medical_claim') }} as med\r\ninner join {{ ref('service_category__service_category_grouper') }} as srv_group\r\n on med.claim_id = srv_group.claim_id\r\n and med.claim_line_number = srv_group.claim_line_number\r\n and srv_group.duplicate_row_number = 1\r\ninner join all_encounters as x\r\n on med.claim_id = x.claim_id\r\n and med.claim_line_number = x.claim_line_number\r\nleft join {{ ref('claims_enrollment__flag_claims_with_enrollment') }} as enroll\r\n on med.claim_id = enroll.claim_id\r\n and med.claim_line_number = enroll.claim_line_number", "language": "sql", "refs": [{"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "encounters__orphaned_claims", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "claims_enrollment__flag_claims_with_enrollment", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.type_string", "macro.dbt.type_int", "macro.the_tuva_project.quote_column", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_medical_claim.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the medical_claim table\n-- in core. It adds these 4 fields to the input layer\n-- medical claim table:\n-- encounter_id\n-- service_category_1\n-- service_category_2\n-- *************************************************\n\nwith all_encounters as (\n select claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk\n where claim_line_attribution_number = 1\n \n union all \n\n select \n claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__orphaned_claims\n)\n\n\nselect\n med.claim_id || '-' || med.claim_line_number as medical_claim_id\n , cast(med.claim_id as TEXT ) as claim_id\n , cast(med.claim_line_number as integer ) as claim_line_number\n , cast(x.encounter_id as TEXT ) as encounter_id\n , cast(x.encounter_type as TEXT ) as encounter_type\n , cast(x.encounter_group as TEXT ) as encounter_group\n , cast(med.claim_type as TEXT ) as claim_type\n , cast(med.patient_id as TEXT ) as patient_id\n , cast(med.member_id as TEXT ) as member_id\n , cast(med.payer as TEXT ) as payer\n , med.plan\n , try_cast( med.claim_start_date as date ) as claim_start_date\n , try_cast( med.claim_end_date as date ) as claim_end_date\n , try_cast( med.claim_line_start_date as date ) as claim_line_start_date\n , try_cast( med.claim_line_end_date as date ) as claim_line_end_date\n , try_cast( med.admission_date as date ) as admission_date\n , try_cast( med.discharge_date as date ) as discharge_date\n , cast(srv_group.service_category_1 as TEXT ) as service_category_1\n , cast(srv_group.service_category_2 as TEXT ) as service_category_2\n , cast(srv_group.service_category_3 as TEXT ) as service_category_3\n , cast(med.admit_source_code as TEXT ) as admit_source_code\n , cast(med.admit_source_description as TEXT ) as admit_source_description\n , cast(med.admit_type_code as TEXT ) as admit_type_code\n , cast(med.admit_type_description as TEXT ) as admit_type_description\n , cast(med.discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(med.discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(med.place_of_service_code as TEXT ) as place_of_service_code\n , cast(med.place_of_service_description as TEXT ) as place_of_service_description\n , cast(med.bill_type_code as TEXT ) as bill_type_code\n , cast(med.bill_type_description as TEXT ) as bill_type_description\n , cast(med.ms_drg_code as TEXT ) as ms_drg_code\n , cast(med.ms_drg_description as TEXT ) as ms_drg_description\n , cast(med.apr_drg_code as TEXT ) as apr_drg_code\n , cast(med.apr_drg_description as TEXT ) as apr_drg_description\n , cast(med.revenue_center_code as TEXT ) as revenue_center_code\n , cast(med.revenue_center_description as TEXT ) as revenue_center_description\n , cast(med.service_unit_quantity as numeric(28,6) ) as service_unit_quantity\n , cast(med.hcpcs_code as TEXT ) as hcpcs_code\n , cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n , cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n , cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n , cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n , cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n , cast(med.rendering_id as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(med.rendering_name as TEXT ) as rendering_name\n , cast(med.billing_id as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(med.billing_name as TEXT ) as billing_name\n , cast(med.facility_id as TEXT ) as facility_id\n , cast(med.facility_name as TEXT ) as facility_name\n , try_cast( med.paid_date as date ) as paid_date\n , cast(med.paid_amount as numeric(28,6) ) as paid_amount\n , cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(med.charge_amount as numeric(28,6) ) as charge_amount\n , cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast(\n case\n when enroll.claim_id is not null then 1\n else 0\n end as int) as enrollment_flag\n , cast(med.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim as med\ninner join dev_thuxuan.claims_preprocessing.service_category_grouper as srv_group\n on med.claim_id = srv_group.claim_id\n and med.claim_line_number = srv_group.claim_line_number\n and srv_group.duplicate_row_number = 1\ninner join all_encounters as x\n on med.claim_id = x.claim_id\n and med.claim_line_number = x.claim_line_number\nleft join dev_thuxuan.claims_preprocessing.flag_claims_with_enrollment as enroll\n on med.claim_id = enroll.claim_id\n and med.claim_line_number = enroll.claim_line_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_patient": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_patient.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_patient.sql", "unique_id": "model.the_tuva_project.core__stg_claims_patient", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_patient"], "alias": "core__stg_claims_patient", "checksum": {"name": "sha256", "checksum": "49a399d1d753c3909dc2c1f6b0c140b631afc2cf70827d39f70034a8093db49d"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4539828, "relation_name": "dev_thuxuan.test.core__stg_claims_patient", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the patient table in core.\r\n-- *************************************************\r\n\r\nwith patient_stage as(\r\n select\r\n patient_id\r\n ,first_name\r\n ,last_name\r\n ,gender\r\n ,race\r\n ,birth_date\r\n ,death_date\r\n ,death_flag\r\n ,social_security_number\r\n ,address\r\n ,city\r\n ,state\r\n ,zip_code\r\n ,phone\r\n ,data_source\r\n ,row_number() over (\r\n\t partition by patient_id\r\n\t order by case when enrollment_end_date is null\r\n then cast ('2050-01-01' as date)\r\n else enrollment_end_date end DESC)\r\n as row_sequence\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }}) as tuva_last_run_datetime\r\n , cast(substring('{{ var('tuva_last_run')}}',1,10) as date) as tuva_last_run_date\r\n from {{ ref('normalized_input__eligibility')}}\r\n)\r\n\r\nselect\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(first_name as {{ dbt.type_string() }}) as first_name\r\n , cast(last_name as {{ dbt.type_string() }}) as last_name\r\n , cast(gender as {{ dbt.type_string() }}) as sex\r\n , cast(race as {{ dbt.type_string() }}) as race\r\n , cast(birth_date as date) as birth_date\r\n , cast(death_date as date) as death_date\r\n , cast(death_flag as int) as death_flag\r\n , cast(social_security_number as {{ dbt.type_string() }}) as social_security_number\r\n , cast(address as {{ dbt.type_string() }}) as address\r\n , cast(city as {{ dbt.type_string() }}) as city\r\n , cast(state as {{ dbt.type_string() }}) as state\r\n , cast(zip_code as {{ dbt.type_string() }}) as zip_code\r\n , cast(null as {{ dbt.type_string() }}) as county\r\n , cast(null as {{ dbt.type_float() }}) as latitude \r\n , cast(null as {{ dbt.type_float() }}) as longitude\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) as age\r\n , cast(\r\n CASE\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 10 THEN '0-9'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 20 THEN '10-19'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 30 THEN '20-29'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 40 THEN '30-39'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 50 THEN '40-49'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 60 THEN '50-59'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 70 THEN '60-69'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 80 THEN '70-79'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 90 THEN '80-89'\r\n ELSE '90+'\r\n END as {{ dbt.type_string() }}\r\n ) AS age_group\r\n , tuva_last_run_datetime as tuva_last_run\r\nfrom patient_stage\r\nwhere row_sequence = 1", "language": "sql", "refs": [{"name": "normalized_input__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_timestamp", "macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.datediff", "macro.dbt.type_int"], "nodes": ["model.the_tuva_project.normalized_input__eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_patient.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the patient table in core.\n-- *************************************************\n\nwith patient_stage as(\n select\n patient_id\n ,first_name\n ,last_name\n ,gender\n ,race\n ,birth_date\n ,death_date\n ,death_flag\n ,social_security_number\n ,address\n ,city\n ,state\n ,zip_code\n ,phone\n ,data_source\n ,row_number() over (\n\t partition by patient_id\n\t order by case when enrollment_end_date is null\n then cast ('2050-01-01' as date)\n else enrollment_end_date end DESC)\n as row_sequence\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp) as tuva_last_run_datetime\n , cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run_date\n from dev_thuxuan.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(first_name as TEXT) as first_name\n , cast(last_name as TEXT) as last_name\n , cast(gender as TEXT) as sex\n , cast(race as TEXT) as race\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(death_flag as int) as death_flag\n , cast(social_security_number as TEXT) as social_security_number\n , cast(address as TEXT) as address\n , cast(city as TEXT) as city\n , cast(state as TEXT) as state\n , cast(zip_code as TEXT) as zip_code\n , cast(null as TEXT) as county\n , cast(null as float) as latitude \n , cast(null as float) as longitude\n , cast(data_source as TEXT) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nfrom patient_stage\nwhere row_sequence = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_pharmacy_claim": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_pharmacy_claim.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.core__stg_claims_pharmacy_claim", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_pharmacy_claim"], "alias": "core__stg_claims_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "6cd66eeaaf9d6c842eeaf44d1b2a5560f36f40d6fe3edaa06cb6c0beddc2bf52"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4669816, "relation_name": "dev_thuxuan.test.core__stg_claims_pharmacy_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the pharmacy_claim\r\n-- table in core.\r\n-- *************************************************\r\n\r\n\r\n\r\n\r\nselect\r\n {{ dbt.concat([\r\n \"cast(claim_id as \" ~ dbt.type_string() ~ \")\",\r\n \"'-'\",\r\n \"cast(claim_line_number as \" ~ dbt.type_string() ~ \")\"\r\n ]) }} as pharmacy_claim_id\r\n , cast(claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , cast(claim_line_number as integer ) as claim_line_number\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(member_id as {{ dbt.type_string() }} ) as member_id\r\n , cast(payer as {{ dbt.type_string() }} ) as payer\r\n , {{ quote_column('plan') }}\r\n , cast(prescribing_provider_id as {{ dbt.type_string() }} ) as prescribing_provider_id\r\n , cast(prescribing_provider_name as {{ dbt.type_string() }} ) as prescribing_provider_name\r\n , cast(dispensing_provider_id as {{ dbt.type_string() }} ) as dispensing_provider_id\r\n , cast(dispensing_provider_name as {{ dbt.type_string() }} ) as dispensing_provider_name\r\n , cast(dispensing_date as date ) as dispensing_date\r\n , cast(ndc_code as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(ndc_description as {{ dbt.type_string() }} ) as ndc_description\r\n , cast(quantity as integer ) as quantity\r\n , cast(days_supply as integer ) as days_supply\r\n , cast(refills as integer ) as refills\r\n , cast(paid_date as date ) as paid_date\r\n , cast(paid_amount as {{ dbt.type_numeric() }}) as paid_amount\r\n , cast(allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\r\n , cast(charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\r\n , cast(coinsurance_amount as {{ dbt.type_numeric() }} ) as coinsurance_amount\r\n , cast(copayment_amount as {{ dbt.type_numeric() }} ) as copayment_amount\r\n , cast(deductible_amount as {{ dbt.type_numeric() }} ) as deductible_amount\r\n , cast(in_network_flag as int ) as in_network_flag\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('normalized_input__pharmacy_claim') }} pharm", "language": "sql", "refs": [{"name": "normalized_input__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.the_tuva_project.quote_column", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.normalized_input__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the pharmacy_claim\n-- table in core.\n-- *************************************************\n\n\n\n\nselect\n cast(claim_id as TEXT) || '-' || cast(claim_line_number as TEXT) as pharmacy_claim_id\n , cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as integer ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , plan\n , cast(prescribing_provider_id as TEXT ) as prescribing_provider_id\n , cast(prescribing_provider_name as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_id as TEXT ) as dispensing_provider_id\n , cast(dispensing_provider_name as TEXT ) as dispensing_provider_name\n , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(quantity as integer ) as quantity\n , cast(days_supply as integer ) as days_supply\n , cast(refills as integer ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6)) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_pharmacy_claim pharm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_practitioner": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_practitioner", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_practitioner.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_practitioner.sql", "unique_id": "model.the_tuva_project.core__stg_claims_practitioner", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_practitioner"], "alias": "core__stg_claims_practitioner", "checksum": {"name": "sha256", "checksum": "09081e72d89bca3f90379420483af68cf67c3aa559958dffa9537f4eef493326"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4759817, "relation_name": "dev_thuxuan.test.core__stg_claims_practitioner", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the provider table \r\n-- in core. It includes data about all providers\r\n-- present in the raw claims dataset.\r\n-- *************************************************\r\n\r\n\r\nwith all_providers_in_claims_dataset as (\r\nselect distinct facility_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct rendering_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct billing_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_medical_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct prescribing_provider_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct dispensing_provider_id as npi, data_source\r\nfrom {{ ref('core__stg_claims_pharmacy_claim') }}\r\n),\r\n\r\n\r\nprovider as (\r\nselect aa.*, bb.data_source\r\nfrom {{ ref('terminology__provider') }} aa\r\ninner join all_providers_in_claims_dataset bb\r\non aa.npi = bb.npi\r\nwhere lower(aa.entity_type_description) = 'individual'\r\n)\r\n\r\n\r\n\r\nselect \r\n cast(npi as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(npi as {{ dbt.type_string() }} ) as npi\r\n , cast(provider_first_name as {{ dbt.type_string() }} ) as provider_first_name\r\n , cast(provider_last_name as {{ dbt.type_string() }} ) as provider_last_name\r\n , cast(parent_organization_name as {{ dbt.type_string() }} ) as practice_affiliation\r\n , cast(primary_specialty_description as {{ dbt.type_string() }} ) as specialty\r\n , cast(null as {{ dbt.type_string() }} ) as sub_specialty\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom provider", "language": "sql", "refs": [{"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_medical_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "core__stg_claims_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_practitioner.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the provider table \n-- in core. It includes data about all providers\n-- present in the raw claims dataset.\n-- *************************************************\n\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom dev_thuxuan.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'individual'\n)\n\n\n\nselect \n cast(npi as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(provider_first_name as TEXT ) as provider_first_name\n , cast(provider_last_name as TEXT ) as provider_last_name\n , cast(parent_organization_name as TEXT ) as practice_affiliation\n , cast(primary_specialty_description as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom provider", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_claims_procedure": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_claims_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_claims_procedure.sql", "original_file_path": "models\\core\\staging\\core__stg_claims_procedure.sql", "unique_id": "model.the_tuva_project.core__stg_claims_procedure", "fqn": ["the_tuva_project", "core", "staging", "core__stg_claims_procedure"], "alias": "core__stg_claims_procedure", "checksum": {"name": "sha256", "checksum": "cedb14c91875fee5a8af16e32d44fd6353ecc66d3289ef0bc092904914b04ebb"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.4839852, "relation_name": "dev_thuxuan.test.core__stg_claims_procedure", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n-- *************************************************\r\n-- This dbt model creates the procedure table in core.\r\n-- *************************************************\r\n\r\nwith unpivot_cte as (\r\n\r\nselect\r\n claim_id as claim_id\r\n , claim_line_number as procedure_sequence_id\r\n , patient_id as patient_id\r\n , coalesce(admission_date\r\n , claim_start_date\r\n , discharge_date\r\n , claim_end_date\r\n ) as procedure_date\r\n , 'hcpcs' as source_code_type\r\n , hcpcs_code as source_code\r\n , rendering_id as practitioner_npi\r\n , hcpcs_modifier_1 as modifier_1\r\n , hcpcs_modifier_2 as modifier_2\r\n , hcpcs_modifier_3 as modifier_3\r\n , hcpcs_modifier_4 as modifier_4\r\n , hcpcs_modifier_5 as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }}\r\nwhere hcpcs_code is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 1 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_1 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_1 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_1 is not null\r\n \r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 2 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_2 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_2 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_2 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 3 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_3 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_3 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_3 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 4 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_4 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_4 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_4 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 5 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_5 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_5 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_5 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 6 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_6 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_6 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_6 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 7 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_7 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_7 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_7 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 8 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_8 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_8 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_8 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 9 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_9 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_9 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_9 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 10 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_10 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_10 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_10 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 11 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_11 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_11 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_11 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 12 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_12 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_12 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_12 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 13 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_13 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_13 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_13 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 14 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_14 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_14 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_14 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 15 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_15 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_15 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_15 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 16 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_16 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_16 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_16 is not null\r\n \r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 17 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_17 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_17 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_17 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 18 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_18 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_18 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_18 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 19 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_19 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_19 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_19 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 20 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_20 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_20 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_20 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 21 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_21 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_21 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_21 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 22 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_22 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_22 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_22 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 23 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_23 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_23 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_23 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 24 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_24 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_24 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_24 is not null\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect\r\n claim_id as claim_id\r\n , 25 as procedure_sequence_id\r\n , patient_id as patient_id\r\n , procedure_date_25 as procedure_date\r\n , procedure_code_type as source_code_type\r\n , procedure_code_25 as source_code\r\n , rendering_id as practitioner_npi\r\n , null as modifier_1\r\n , null as modifier_2\r\n , null as modifier_3\r\n , null as modifier_4\r\n , null as modifier_5\r\n , data_source as data_source\r\nfrom {{ ref('normalized_input__medical_claim') }} \r\nwhere procedure_code_25 is not null\r\n\r\n)\r\n\r\nselect distinct\r\n{{ dbt.safe_cast(\r\n dbt.concat([\r\n \"unpivot_cte.data_source\",\r\n \"'_'\",\r\n \"unpivot_cte.claim_id\",\r\n \"'_'\",\r\n \"unpivot_cte.procedure_sequence_id\",\r\n \"'_'\",\r\n \"unpivot_cte.source_code\",\r\n \"case when unpivot_cte.modifier_1 is not null then CONCAT('_', unpivot_cte.modifier_1) else '' end\",\r\n \"case when unpivot_cte.modifier_2 is not null then CONCAT('_', unpivot_cte.modifier_2) else '' end\",\r\n \"case when unpivot_cte.modifier_3 is not null then CONCAT('_', unpivot_cte.modifier_3) else '' end\",\r\n \"case when unpivot_cte.modifier_4 is not null then CONCAT('_', unpivot_cte.modifier_4) else '' end\",\r\n \"case when unpivot_cte.modifier_5 is not null then CONCAT('_', unpivot_cte.modifier_5) else '' end\",\r\n \"case when unpivot_cte.practitioner_npi is not null then CONCAT('_', unpivot_cte.practitioner_npi) else '' end\"\r\n ]), api.Column.translate_type(\"string\"))\r\n }} as procedure_id\r\n , cast(unpivot_cte.patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\r\n , cast(unpivot_cte.claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , {{ try_to_cast_date('unpivot_cte.procedure_date', 'YYYY-MM-DD') }} as procedure_date\r\n , cast(unpivot_cte.source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(unpivot_cte.source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_description\r\n , cast(\r\n case\r\n when icd.icd_10_pcs is not null then 'icd-10-pcs'\r\n when hcpcs.hcpcs is not null then 'hcpcs'\r\n end\r\n as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast (\r\n coalesce (\r\n icd.icd_10_pcs\r\n , hcpcs.hcpcs\r\n )\r\n as {{ dbt.type_string() }} ) as normalized_code\r\n , cast (\r\n coalesce (\r\n icd.description\r\n , hcpcs.short_description\r\n )\r\n as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(unpivot_cte.modifier_1 as {{ dbt.type_string() }} ) as modifier_1\r\n , cast(unpivot_cte.modifier_2 as {{ dbt.type_string() }} ) as modifier_2\r\n , cast(unpivot_cte.modifier_3 as {{ dbt.type_string() }} ) as modifier_3\r\n , cast(unpivot_cte.modifier_4 as {{ dbt.type_string() }} ) as modifier_4\r\n , cast(unpivot_cte.modifier_5 as {{ dbt.type_string() }} ) as modifier_5\r\n , cast(unpivot_cte.practitioner_npi as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(unpivot_cte.data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom unpivot_cte\r\n--inner join {{ ref('encounters__combined_claim_line_crosswalk') }} x on unpivot_cte.claim_id = x.claim_id\r\n--and\r\n--unpivot_cte.claim_line_number = x.claim_line_number\r\n--and\r\n--x.claim_line_attribution_number = 1\r\nleft join {{ ref('terminology__icd_10_pcs') }} as icd\r\n on unpivot_cte.source_code = icd.icd_10_pcs\r\nleft join {{ ref('terminology__hcpcs_level_2') }} as hcpcs\r\n on unpivot_cte.source_code = hcpcs.hcpcs", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "normalized_input__medical_claim", "package": null, "version": null}, {"name": "encounters__combined_claim_line_crosswalk", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.safe_cast", "macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_claims_procedure.sql", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the procedure table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id as claim_id\n , claim_line_number as procedure_sequence_id\n , patient_id as patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as procedure_date\n , 'hcpcs' as source_code_type\n , hcpcs_code as source_code\n , rendering_id as practitioner_npi\n , hcpcs_modifier_1 as modifier_1\n , hcpcs_modifier_2 as modifier_2\n , hcpcs_modifier_3 as modifier_3\n , hcpcs_modifier_4 as modifier_4\n , hcpcs_modifier_5 as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere hcpcs_code is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 1 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_1 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_1 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_1 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 2 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_2 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_2 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_2 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 3 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_3 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_3 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_3 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 4 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_4 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_4 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_4 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 5 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_5 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_5 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_5 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 6 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_6 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_6 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_6 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 7 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_7 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_7 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_7 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 8 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_8 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_8 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_8 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 9 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_9 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_9 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_9 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 10 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_10 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_10 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_10 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 11 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_11 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_11 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_11 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 12 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_12 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_12 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_12 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 13 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_13 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_13 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_13 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 14 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_14 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_14 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_14 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 15 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_15 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_15 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_15 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 16 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_16 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_16 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_16 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 17 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_17 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_17 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_17 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 18 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_18 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_18 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_18 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 19 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_19 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_19 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_19 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 20 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_20 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_20 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_20 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 21 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_21 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_21 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_21 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 22 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_22 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_22 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_22 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 23 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_23 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_23 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_23 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 24 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_24 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_24 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_24 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 25 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_25 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_25 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(unpivot_cte.data_source || '_' || unpivot_cte.claim_id || '_' || unpivot_cte.procedure_sequence_id || '_' || unpivot_cte.source_code || case when unpivot_cte.modifier_1 is not null then CONCAT('_', unpivot_cte.modifier_1) else '' end || case when unpivot_cte.modifier_2 is not null then CONCAT('_', unpivot_cte.modifier_2) else '' end || case when unpivot_cte.modifier_3 is not null then CONCAT('_', unpivot_cte.modifier_3) else '' end || case when unpivot_cte.modifier_4 is not null then CONCAT('_', unpivot_cte.modifier_4) else '' end || case when unpivot_cte.modifier_5 is not null then CONCAT('_', unpivot_cte.modifier_5) else '' end || case when unpivot_cte.practitioner_npi is not null then CONCAT('_', unpivot_cte.practitioner_npi) else '' end as TEXT)\n as procedure_id\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.procedure_date as date ) as procedure_date\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n end\n as TEXT ) as normalized_code_type\n , cast (\n coalesce (\n icd.icd_10_pcs\n , hcpcs.hcpcs\n )\n as TEXT ) as normalized_code\n , cast (\n coalesce (\n icd.description\n , hcpcs.short_description\n )\n as TEXT ) as normalized_description\n , cast(unpivot_cte.modifier_1 as TEXT ) as modifier_1\n , cast(unpivot_cte.modifier_2 as TEXT ) as modifier_2\n , cast(unpivot_cte.modifier_3 as TEXT ) as modifier_3\n , cast(unpivot_cte.modifier_4 as TEXT ) as modifier_4\n , cast(unpivot_cte.modifier_5 as TEXT ) as modifier_5\n , cast(unpivot_cte.practitioner_npi as TEXT ) as practitioner_id\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join dev_thuxuan.terminology.icd_10_pcs as icd\n on unpivot_cte.source_code = icd.icd_10_pcs\nleft join dev_thuxuan.terminology.hcpcs_level_2 as hcpcs\n on unpivot_cte.source_code = hcpcs.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_condition": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_condition.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_condition.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_condition", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_condition"], "alias": "core__stg_clinical_condition", "checksum": {"name": "sha256", "checksum": "bcfab95997b76ac5e9983168cc557658be494638cce4f4ec9e172f2f9cc138bf"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.506647, "relation_name": "dev_thuxuan.test.core__stg_clinical_condition", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n cast(condition_id as {{ dbt.type_string() }} ) as condition_id\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , {{ try_to_cast_date('recorded_date', 'YYYY-MM-DD') }} as recorded_date\r\n , {{ try_to_cast_date('onset_date', 'YYYY-MM-DD') }} as onset_date\r\n , {{ try_to_cast_date('resolved_date', 'YYYY-MM-DD') }} as resolved_date\r\n , cast(status as {{ dbt.type_string() }} ) as status\r\n , cast(condition_type as {{ dbt.type_string() }} ) as condition_type\r\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\r\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(condition_rank as {{ dbt.type_int() }} ) as condition_rank\r\n , cast(present_on_admit_code as {{ dbt.type_string() }} ) as present_on_admit_code\r\n , cast(present_on_admit_description as {{ dbt.type_string() }} ) as present_on_admit_description\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('condition') }}", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_condition.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(condition_id as TEXT ) as condition_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( recorded_date as date ) as recorded_date\n , try_cast( onset_date as date ) as onset_date\n , try_cast( resolved_date as date ) as resolved_date\n , cast(status as TEXT ) as status\n , cast(condition_type as TEXT ) as condition_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(condition_rank as integer ) as condition_rank\n , cast(present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_encounter": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_encounter.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_encounter.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_encounter", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_encounter"], "alias": "core__stg_clinical_encounter", "checksum": {"name": "sha256", "checksum": "fa2dcc7cfc0ab883b0e54d3b57bea4c63497794dd83a14ff2511239d98c2cdfa"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.515647, "relation_name": "dev_thuxuan.test.core__stg_clinical_encounter", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n cast(encounter_id as {{ dbt.type_string() }}) as encounter_id\r\n , cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(encounter_type as {{ dbt.type_string() }}) as encounter_type\r\n , cast('clinical' as {{ dbt.type_string() }}) as encounter_group\r\n , {{ try_to_cast_date('encounter_start_date', 'YYYY-MM-DD') }} as encounter_start_date\r\n , {{ try_to_cast_date('encounter_end_date', 'YYYY-MM-DD') }} as encounter_end_date\r\n , cast(length_of_stay as {{ dbt.type_int() }}) as length_of_stay\r\n , cast(admit_source_code as {{ dbt.type_string() }}) as admit_source_code\r\n , cast(admit_source_description as {{ dbt.type_string() }}) as admit_source_description\r\n , cast(admit_type_code as {{ dbt.type_string() }}) as admit_type_code\r\n , cast(admit_type_description as {{ dbt.type_string() }}) as admit_type_description\r\n , cast(discharge_disposition_code as {{ dbt.type_string() }}) as discharge_disposition_code\r\n , cast(discharge_disposition_description as {{ dbt.type_string() }}) as discharge_disposition_description\r\n , cast(attending_provider_id as {{ dbt.type_string() }}) as attending_provider_id\r\n , cast(attending_provider_name as {{ dbt.type_string() }}) as attending_provider_name\r\n , cast(facility_id as {{ dbt.type_string() }}) as facility_id\r\n , cast(facility_name as {{ dbt.type_string() }}) as facility_name\r\n , cast(null as {{ dbt.type_string() }}) as facility_type\r\n , cast(null as {{ dbt.type_int() }}) as observation_flag\r\n , cast(null as {{ dbt.type_int() }}) as lab_flag\r\n , cast(null as {{ dbt.type_int() }}) as dme_flag\r\n , cast(null as {{ dbt.type_int() }}) as ambulance_flag\r\n , cast(null as {{ dbt.type_int() }}) as pharmacy_flag\r\n , cast(null as {{ dbt.type_int() }}) as ed_flag\r\n , cast(null as {{ dbt.type_int() }}) as delivery_flag\r\n , cast(null as {{ dbt.type_string() }}) as delivery_type\r\n , cast(null as {{ dbt.type_int() }}) as newborn_flag\r\n , cast(null as {{ dbt.type_int() }}) as nicu_flag\r\n , cast(primary_diagnosis_code_type as {{ dbt.type_string() }}) as primary_diagnosis_code_type\r\n , cast(primary_diagnosis_code as {{ dbt.type_string() }}) as primary_diagnosis_code\r\n , cast(primary_diagnosis_description as {{ dbt.type_string() }}) as primary_diagnosis_description\r\n , cast(ms_drg_code as {{ dbt.type_string() }}) as ms_drg_code\r\n , cast(ms_drg_description as {{ dbt.type_string() }}) as ms_drg_description\r\n , cast(apr_drg_code as {{ dbt.type_string() }}) as apr_drg_code\r\n , cast(apr_drg_description as {{ dbt.type_string() }}) as apr_drg_description\r\n , cast(paid_amount as {{ dbt.type_numeric() }} ) as paid_amount\r\n , cast(allowed_amount as {{ dbt.type_numeric() }} ) as allowed_amount\r\n , cast(charge_amount as {{ dbt.type_numeric() }} ) as charge_amount\r\n , cast(null as {{ dbt.type_int() }}) as claim_count\r\n , cast(null as {{ dbt.type_int() }}) as inst_claim_count\r\n , cast(null as {{ dbt.type_int() }}) as prof_claim_count\r\n , cast(null as {{ dbt.type_string() }}) as source_model\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast('{{ var('tuva_last_run') }}' as {{ dbt.type_timestamp() }}) as tuva_last_run\r\nfrom {{ ref('encounter') }}", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_numeric", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(encounter_id as TEXT) as encounter_id\n , cast(patient_id as TEXT) as patient_id\n , cast(encounter_type as TEXT) as encounter_type\n , cast('clinical' as TEXT) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer) as length_of_stay\n , cast(admit_source_code as TEXT) as admit_source_code\n , cast(admit_source_description as TEXT) as admit_source_description\n , cast(admit_type_code as TEXT) as admit_type_code\n , cast(admit_type_description as TEXT) as admit_type_description\n , cast(discharge_disposition_code as TEXT) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT) as discharge_disposition_description\n , cast(attending_provider_id as TEXT) as attending_provider_id\n , cast(attending_provider_name as TEXT) as attending_provider_name\n , cast(facility_id as TEXT) as facility_id\n , cast(facility_name as TEXT) as facility_name\n , cast(null as TEXT) as facility_type\n , cast(null as integer) as observation_flag\n , cast(null as integer) as lab_flag\n , cast(null as integer) as dme_flag\n , cast(null as integer) as ambulance_flag\n , cast(null as integer) as pharmacy_flag\n , cast(null as integer) as ed_flag\n , cast(null as integer) as delivery_flag\n , cast(null as TEXT) as delivery_type\n , cast(null as integer) as newborn_flag\n , cast(null as integer) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT) as ms_drg_code\n , cast(ms_drg_description as TEXT) as ms_drg_description\n , cast(apr_drg_code as TEXT) as apr_drg_code\n , cast(apr_drg_description as TEXT) as apr_drg_description\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(null as integer) as claim_count\n , cast(null as integer) as inst_claim_count\n , cast(null as integer) as prof_claim_count\n , cast(null as TEXT) as source_model\n , cast(data_source as TEXT) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp) as tuva_last_run\nfrom tuva.input_layer.encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_lab_result": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_lab_result.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_lab_result.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_lab_result", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_lab_result"], "alias": "core__stg_clinical_lab_result", "checksum": {"name": "sha256", "checksum": "5ba7c6ccdd692123791b12400b25b104a6f6be130f6af3146ef454f89451e481"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.5286472, "relation_name": "dev_thuxuan.test.core__stg_clinical_lab_result", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n cast(lab_result_id as {{ dbt.type_string() }} ) as lab_result_id\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(accession_number as {{ dbt.type_string() }} ) as accession_number\r\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\r\n , cast(source_component as {{ dbt.type_string() }} ) as source_component\r\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(normalized_component as {{ dbt.type_string() }} ) as normalized_component\r\n , cast(status as {{ dbt.type_string() }} ) as status\r\n , cast(result as {{ dbt.type_string() }} ) as result\r\n , {{ try_to_cast_date('result_date', 'YYYY-MM-DD') }} as result_date\r\n , {{ try_to_cast_date('collection_date', 'YYYY-MM-DD') }} as collection_date\r\n , cast(source_units as {{ dbt.type_string() }} ) as source_units\r\n , cast(normalized_units as {{ dbt.type_string() }} ) as normalized_units\r\n , cast(source_reference_range_low as {{ dbt.type_string() }} ) as source_reference_range_low\r\n , cast(source_reference_range_high as {{ dbt.type_string() }} ) as source_reference_range_high\r\n , cast(normalized_reference_range_low as {{ dbt.type_string() }} ) as normalized_reference_range_low\r\n , cast(normalized_reference_range_high as {{ dbt.type_string() }} ) as normalized_reference_range_high\r\n , cast(source_abnormal_flag as {{ dbt.type_string() }} ) as source_abnormal_flag\r\n , cast(normalized_abnormal_flag as {{ dbt.type_string() }} ) as normalized_abnormal_flag\r\n , cast(specimen as {{ dbt.type_string() }} ) as specimen\r\n , cast(ordering_practitioner_id as {{ dbt.type_string() }} ) as ordering_practitioner_id\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('lab_result') }}", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_lab_result.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(lab_result_id as TEXT ) as lab_result_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(accession_number as TEXT ) as accession_number\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(source_component as TEXT ) as source_component\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(normalized_component as TEXT ) as normalized_component\n , cast(status as TEXT ) as status\n , cast(result as TEXT ) as result\n , try_cast( result_date as date ) as result_date\n , try_cast( collection_date as date ) as collection_date\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(source_abnormal_flag as TEXT ) as source_abnormal_flag\n , cast(normalized_abnormal_flag as TEXT ) as normalized_abnormal_flag\n , cast(specimen as TEXT ) as specimen\n , cast(ordering_practitioner_id as TEXT ) as ordering_practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.lab_result", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_location": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_location", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_location.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_location.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_location", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_location"], "alias": "core__stg_clinical_location", "checksum": {"name": "sha256", "checksum": "6a259b80d51e583fc2fbedac359791c1461e2f34e9b72802d2b4e40d81d027f4"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.538647, "relation_name": "dev_thuxuan.test.core__stg_clinical_location", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False))\r | as_bool\n )\r\n}}\r\n\r\nselect\r\n cast(location_id as {{ dbt.type_string() }} ) as location_id\r\n , cast(npi as {{ dbt.type_string() }} ) as npi\r\n , cast(name as {{ dbt.type_string() }} ) as name\r\n , cast(facility_type as {{ dbt.type_string() }} ) as facility_type\r\n , cast(parent_organization as {{ dbt.type_string() }} ) as parent_organization\r\n , cast(address as {{ dbt.type_string() }} ) as address\r\n , cast(city as {{ dbt.type_string() }} ) as city\r\n , cast(state as {{ dbt.type_string() }} ) as state\r\n , cast(zip_code as {{ dbt.type_string() }} ) as zip_code\r\n , cast(latitude as {{ dbt.type_float() }} ) as latitude\r\n , cast(longitude as {{ dbt.type_float() }} ) as longitude\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('location') }}", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_float", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_location.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(location_id as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(name as TEXT ) as name\n , cast(facility_type as TEXT ) as facility_type\n , cast(parent_organization as TEXT ) as parent_organization\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.location", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_medication": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_medication.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_medication.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_medication", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_medication"], "alias": "core__stg_clinical_medication", "checksum": {"name": "sha256", "checksum": "d0117d9ac0a0b90934eaf6fc6534275c94d3f6588782dba17b751d803473d39b"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.5456471, "relation_name": "dev_thuxuan.test.core__stg_clinical_medication", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n cast(medication_id as {{ dbt.type_string() }} ) as medication_id\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , {{ try_to_cast_date('dispensing_date', 'YYYY-MM-DD') }} as dispensing_date\r\n , {{ try_to_cast_date('prescribing_date', 'YYYY-MM-DD') }} as prescribing_date\r\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\r\n , cast(ndc_code as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(ndc_description as {{ dbt.type_string() }} ) as ndc_description\r\n , cast(rxnorm_code as {{ dbt.type_string() }} ) as rxnorm_code\r\n , cast(rxnorm_description as {{ dbt.type_string() }} ) as rxnorm_description \r\n , cast(atc_code as {{ dbt.type_string() }} ) as atc_code\r\n , cast(atc_description as {{ dbt.type_string() }} ) as atc_description\r\n , cast(route as {{ dbt.type_string() }} ) as route\r\n , cast(strength as {{ dbt.type_string() }} ) as strength\r\n , cast(quantity as {{ dbt.type_int() }} ) as quantity\r\n , cast(quantity_unit as {{ dbt.type_string() }} ) as quantity_unit\r\n , cast(days_supply as {{ dbt.type_int() }} ) as days_supply\r\n , cast(practitioner_id as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('medication') }}", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_medication.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(medication_id as TEXT ) as medication_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , try_cast( dispensing_date as date ) as dispensing_date\n , try_cast( prescribing_date as date ) as prescribing_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(rxnorm_code as TEXT ) as rxnorm_code\n , cast(rxnorm_description as TEXT ) as rxnorm_description \n , cast(atc_code as TEXT ) as atc_code\n , cast(atc_description as TEXT ) as atc_description\n , cast(route as TEXT ) as route\n , cast(strength as TEXT ) as strength\n , cast(quantity as integer ) as quantity\n , cast(quantity_unit as TEXT ) as quantity_unit\n , cast(days_supply as integer ) as days_supply\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.medication", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_observation": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_observation.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_observation.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_observation", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_observation"], "alias": "core__stg_clinical_observation", "checksum": {"name": "sha256", "checksum": "ad5f9b17ef794de5c2f85baa048133d4228140714b206b10dcd3cd21c171a48f"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.5546496, "relation_name": "dev_thuxuan.test.core__stg_clinical_observation", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n cast(observation_id as {{ dbt.type_string() }} ) as observation_id\r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(panel_id as {{ dbt.type_string() }} ) as panel_id\r\n , {{ try_to_cast_date('observation_date', 'YYYY-MM-DD') }} as observation_date\r\n , cast(observation_type as {{ dbt.type_string() }} ) as observation_type\r\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\r\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(result as {{ dbt.type_string() }} ) as result\r\n , cast(source_units as {{ dbt.type_string() }} ) as source_units\r\n , cast(normalized_units as {{ dbt.type_string() }} ) as normalized_units\r\n , cast(source_reference_range_low as {{ dbt.type_string() }} ) as source_reference_range_low\r\n , cast(source_reference_range_high as {{ dbt.type_string() }} ) as source_reference_range_high\r\n , cast(normalized_reference_range_low as {{ dbt.type_string() }} ) as normalized_reference_range_low\r\n , cast(normalized_reference_range_high as {{ dbt.type_string() }} ) as normalized_reference_range_high\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('observation') }}", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_observation.sql", "compiled": true, "compiled_code": "\n\n\nselect\n cast(observation_id as TEXT ) as observation_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(panel_id as TEXT ) as panel_id\n , try_cast( observation_date as date ) as observation_date\n , cast(observation_type as TEXT ) as observation_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(result as TEXT ) as result\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.observation", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_patient": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_patient.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_patient.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_patient", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_patient"], "alias": "core__stg_clinical_patient", "checksum": {"name": "sha256", "checksum": "4494ed6cd568ea374aa85ff7e10ed526a95274299312d9e340d90eac6a66e8a4"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.563647, "relation_name": "dev_thuxuan.test.core__stg_clinical_patient", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nwith tuva_last_run as(\r\n select\r\n cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run_datetime\r\n , cast(substring('{{ var('tuva_last_run')}}',1,10) as date ) as tuva_last_run_date\r\n)\r\nSELECT\r\n cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(first_name as {{ dbt.type_string() }} ) as first_name\r\n , cast(last_name as {{ dbt.type_string() }} ) as last_name\r\n , cast(sex as {{ dbt.type_string() }} ) as sex\r\n , cast(race as {{ dbt.type_string() }} ) as race\r\n , {{ try_to_cast_date('birth_date', 'YYYY-MM-DD') }} as birth_date\r\n , {{ try_to_cast_date('death_date', 'YYYY-MM-DD') }} as death_date\r\n , cast(death_flag as {{ dbt.type_int() }} ) as death_flag\r\n , cast(social_security_number as {{ dbt.type_string() }} ) as social_security_number\r\n , cast(address as {{ dbt.type_string() }} ) as address\r\n , cast(city as {{ dbt.type_string() }} ) as city\r\n , cast(state as {{ dbt.type_string() }} ) as state\r\n , cast(zip_code as {{ dbt.type_string() }} ) as zip_code\r\n , cast(county as {{ dbt.type_string() }} ) as county\r\n , cast(latitude as {{ dbt.type_float() }} ) as latitude\r\n , cast(longitude as {{ dbt.type_float() }} ) as longitude\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) as age\r\n , cast(\r\n CASE\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 10 THEN '0-9'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 20 THEN '10-19'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 30 THEN '20-29'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 40 THEN '30-39'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 50 THEN '40-49'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 60 THEN '50-59'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 70 THEN '60-69'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 80 THEN '70-79'\r\n WHEN cast(floor({{ datediff('birth_date', 'tuva_last_run_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) < 90 THEN '80-89'\r\n ELSE '90+'\r\n END as {{ dbt.type_string() }}\r\n ) AS age_group\r\n , tuva_last_run_datetime as tuva_last_run\r\nFROM {{ ref('patient') }}\r\ncross join tuva_last_run", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_timestamp", "macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_int", "macro.dbt.type_float", "macro.dbt.datediff"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_patient.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n select\n cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run_datetime\n , cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date ) as tuva_last_run_date\n)\nSELECT\n cast(patient_id as TEXT ) as patient_id\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(sex as TEXT ) as sex\n , cast(race as TEXT ) as race\n , try_cast( birth_date as date ) as birth_date\n , try_cast( death_date as date ) as death_date\n , cast(death_flag as integer ) as death_flag\n , cast(social_security_number as TEXT ) as social_security_number\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(county as TEXT ) as county\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nFROM tuva.input_layer.patient\ncross join tuva_last_run", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_practitioner": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_practitioner", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_practitioner.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_practitioner.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_practitioner", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_practitioner"], "alias": "core__stg_clinical_practitioner", "checksum": {"name": "sha256", "checksum": "b64d46371c768da23f692131b68d66bef2a8492afaa5f68e5bd94aa70f5557cb"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.5766468, "relation_name": "dev_thuxuan.test.core__stg_clinical_practitioner", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n cast(practitioner_id as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(npi as {{ dbt.type_string() }} ) as npi\r\n , cast(first_name as {{ dbt.type_string() }} ) as first_name\r\n , cast(last_name as {{ dbt.type_string() }} ) as last_name\r\n , cast(practice_affiliation as {{ dbt.type_string() }} ) as practice_affiliation\r\n , cast(specialty as {{ dbt.type_string() }} ) as specialty\r\n , cast(sub_specialty as {{ dbt.type_string() }} ) as sub_specialty\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('practitioner') }}", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_practitioner.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(practitioner_id as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(practice_affiliation as TEXT ) as practice_affiliation\n , cast(specialty as TEXT ) as specialty\n , cast(sub_specialty as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.practitioner", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.core__stg_clinical_procedure": {"database": "dev_thuxuan", "schema": "test", "name": "core__stg_clinical_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "core\\staging\\core__stg_clinical_procedure.sql", "original_file_path": "models\\core\\staging\\core__stg_clinical_procedure.sql", "unique_id": "model.the_tuva_project.core__stg_clinical_procedure", "fqn": ["the_tuva_project", "core", "staging", "core__stg_clinical_procedure"], "alias": "core__stg_clinical_procedure", "checksum": {"name": "sha256", "checksum": "4c9bb4f3ddd1136ac2ea875328b04be6603eb75b8ef44410761ce36054d29471"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1A9A89"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1A9A89"}, "patch_path": null, "build_path": null, "unrendered_config": {"enabled": true, "bind": false, "docs": {"node_color": "#1A9A89"}}, "created_at": 1729866309.583647, "relation_name": "dev_thuxuan.test.core__stg_clinical_procedure", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n cast(procedure_id as {{ dbt.type_string() }} ) as procedure_id \r\n , cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(encounter_id as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(claim_id as {{ dbt.type_string() }} ) as claim_id\r\n , {{ try_to_cast_date('procedure_date', 'YYYY-MM-DD') }} as procedure_date\r\n , cast(source_code_type as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(source_code as {{ dbt.type_string() }} ) as source_code\r\n , cast(source_description as {{ dbt.type_string() }} ) as source_description\r\n , cast(normalized_code_type as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(normalized_code as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(normalized_description as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(modifier_1 as {{ dbt.type_string() }} ) as modifier_1\r\n , cast(modifier_2 as {{ dbt.type_string() }} ) as modifier_2\r\n , cast(modifier_3 as {{ dbt.type_string() }} ) as modifier_3\r\n , cast(modifier_4 as {{ dbt.type_string() }} ) as modifier_4\r\n , cast(modifier_5 as {{ dbt.type_string() }} ) as modifier_5\r\n , cast(practitioner_id as {{ dbt.type_string() }} ) as practitioner_id\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n , cast('{{ var('tuva_last_run')}}' as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\nfrom {{ ref('procedure') }}", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_timestamp"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\staging\\core__stg_clinical_procedure.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(procedure_id as TEXT ) as procedure_id \n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( procedure_date as date ) as procedure_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(modifier_1 as TEXT ) as modifier_1\n , cast(modifier_2 as TEXT ) as modifier_2\n , cast(modifier_3 as TEXT ) as modifier_3\n , cast(modifier_4 as TEXT ) as modifier_4\n , cast(modifier_5 as TEXT ) as modifier_5\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__crosswalk_field_to_mart_sk", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\final\\data_quality__crosswalk_field_to_mart_sk.sql", "original_file_path": "models\\data_quality\\dqi\\final\\data_quality__crosswalk_field_to_mart_sk.sql", "unique_id": "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__crosswalk_field_to_mart_sk"], "alias": "crosswalk_field_to_mart_sk", "checksum": {"name": "sha256", "checksum": "64fdd44e72cd5d1a6c3fe4960618a75f204d24f959478c92a0d547239dbf7af1"}, "config": {"enabled": true, "alias": "crosswalk_field_to_mart_sk", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "crosswalk_field_to_mart_sk", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1296065, "relation_name": "dev_thuxuan.data_quality.crosswalk_field_to_mart_sk", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('clinical_enabled', False))\r\n) }}\r\n\r\n{#\r\nThis code ensures all fields that have atomic level data quality checks\r\nrun against them are included in the SUMMARY_SK creation list even if they are not mapped to\r\nany downstream marts, and thus not in the crosswalk fields to marts.\r\n#}\r\n\r\nwith results as (\r\n\r\n select distinct\r\n table_name as input_layer_table_name\r\n , claim_type\r\n , field_name\r\n , cast(NULL as {{ dbt.type_string() }}) AS mart_name\r\n from {{ ref('data_quality__data_quality_detail') }}\r\n\r\n union all\r\n\r\n select\r\n input_layer_table_name\r\n , claim_type\r\n , field_name\r\n , mart_name\r\n from {{ ref('data_quality__crosswalk_field_to_mart') }}\r\n\r\n)\r\n\r\n, final as (\r\n\r\n select\r\n input_layer_table_name\r\n , claim_type\r\n , field_name\r\n , mart_name\r\n , DENSE_RANK () OVER (ORDER BY input_layer_table_name, claim_type, field_name) as table_claim_type_field_sk\r\n\t, '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from results\r\n group by\r\n input_layer_table_name\r\n , claim_type\r\n , field_name\r\n , mart_name\r\n\r\n)\r\n\r\nselect * from final", "language": "sql", "refs": [{"name": "data_quality__data_quality_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_to_mart", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_to_mart"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\final\\data_quality__crosswalk_field_to_mart_sk.sql", "compiled": true, "compiled_code": "\n\n\n\nwith results as (\n\n select distinct\n table_name as input_layer_table_name\n , claim_type\n , field_name\n , cast(NULL as TEXT) AS mart_name\n from dev_thuxuan.data_quality.data_quality_detail\n\n union all\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n from dev_thuxuan.data_quality._value_set_crosswalk_field_to_mart\n\n)\n\n, final as (\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n , DENSE_RANK () OVER (ORDER BY input_layer_table_name, claim_type, field_name) as table_claim_type_field_sk\n\t, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from results\n group by\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_detail": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_detail", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\final\\data_quality__data_quality_detail.sql", "original_file_path": "models\\data_quality\\dqi\\final\\data_quality__data_quality_detail.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_detail", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__data_quality_detail"], "alias": "data_quality_detail", "checksum": {"name": "sha256", "checksum": "0cf971f5d9c3ec059ed52d01fa3a6d3bd630a22e240d6aab18c2ad64755f41de"}, "config": {"enabled": true, "alias": "data_quality_detail", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"data_source": {"name": "data_source", "description": "User-configured field that indicates the data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_date": {"name": "source_date", "description": "The source date relevant to the field_name (e.g. field_name = death_date means the source_date = death_date)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Name of the input table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_key": {"name": "drill_down_key", "description": "Key for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_value": {"name": "drill_down_value", "description": "Value for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "The claim type (e.g. institutional or professional) or data type (e.g. clinical or claims)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_name": {"name": "field_name", "description": "Name of the input table column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bucket_name": {"name": "bucket_name", "description": "Category of data quality test result", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_reason": {"name": "invalid_reason", "description": "Reason row failed data quality test(s)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_value": {"name": "field_value", "description": "The source column value being tested", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_detail", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1145627, "relation_name": "dev_thuxuan.data_quality.data_quality_detail", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',False))\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', False) == true and var('claims_enabled', False) == true -%}\r\nSELECT\r\n data_source,\r\n\tsource_date,\r\n\ttable_name,\r\n\tdrill_down_key,\r\n\tdrill_down_value,\r\n\tclaim_type,\r\n\tfield_name,\r\n\tbucket_name,\r\n\tinvalid_reason,\r\n\tfield_value,\r\n\tsummary_sk,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n data_source,\r\n\tsource_date,\r\n\ttable_name,\r\n\tdrill_down_key,\r\n\tdrill_down_value,\r\n\t'CLINICAL' AS claim_type,\r\n\tfield_name,\r\n\tbucket_name,\r\n\tinvalid_reason,\r\n\tfield_value,\r\n\tsummary_sk,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_clinical_detail') }}\r\n\r\n{% elif var('claims_enabled', False) == true -%}\r\n\r\nSELECT\r\n data_source,\r\n\tsource_date,\r\n\ttable_name,\r\n\tdrill_down_key,\r\n\tdrill_down_value,\r\n\tclaim_type,\r\n\tfield_name,\r\n\tbucket_name,\r\n\tinvalid_reason,\r\n\tfield_value,\r\n\tsummary_sk,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\r\n\r\n{% elif var('clinical_enabled', False) == true -%}\r\n\r\nSELECT\r\n data_source,\r\n\tsource_date,\r\n\ttable_name,\r\n\tdrill_down_key,\r\n\tdrill_down_value,\r\n\t'clinical' as claim_type,\r\n\tfield_name,\r\n\tbucket_name,\r\n\tinvalid_reason,\r\n\tfield_value,\r\n\tsummary_sk,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_clinical_detail') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_claims_detail", "model.the_tuva_project.data_quality__data_quality_clinical_detail"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\final\\data_quality__data_quality_detail.sql", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\tclaim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\n\nunion all\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\t'CLINICAL' AS claim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_clinical_detail\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_for_pbi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_for_pbi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\final\\data_quality__data_quality_for_pbi.sql", "original_file_path": "models\\data_quality\\dqi\\final\\data_quality__data_quality_for_pbi.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_for_pbi", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__data_quality_for_pbi"], "alias": "data_quality_for_pbi", "checksum": {"name": "sha256", "checksum": "ec2a6ade91263b9641a7586a9c6d0628e933dca66c42e7eb9220d52faf3d89f4"}, "config": {"enabled": true, "alias": "data_quality_for_pbi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Name of the input table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "The claim type (e.g. institutional or professional) or data type (e.g. clinical or claims)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_name": {"name": "field_name", "description": "Name of the input table column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bucket_name": {"name": "bucket_name", "description": "Category of data quality test result", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_reason": {"name": "invalid_reason", "description": "Reason row failed data quality test(s)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_key": {"name": "drill_down_key", "description": "Key for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drill_down_value": {"name": "drill_down_value", "description": "Value for drill down", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_value": {"name": "field_value", "description": "The source column value being tested", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "frequency": {"name": "frequency", "description": "Count of frequency", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_for_pbi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1175625, "relation_name": "dev_thuxuan.data_quality.data_quality_for_pbi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',False))\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', False) == true and var('claims_enabled', False) == true -%}\r\n\r\nSELECT\r\n data_source,\r\n field_name,\r\n table_name,\r\n claim_type,\r\n bucket_name,\r\n field_value,\r\n drill_down_key,\r\n drill_down_value,\r\n invalid_reason,\r\n summary_sk,\r\n frequency,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_for_pbi') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n data_source,\r\n field_name,\r\n table_name,\r\n 'CLINICAL' AS claim_type,\r\n bucket_name,\r\n field_value,\r\n drill_down_key,\r\n drill_down_value,\r\n invalid_reason,\r\n summary_sk,\r\n frequency,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_clinical_for_pbi') }}\r\n\r\n{% elif var('claims_enabled', False) == true -%}\r\n\r\nSELECT\r\n data_source,\r\n field_name,\r\n table_name,\r\n claim_type,\r\n bucket_name,\r\n field_value,\r\n drill_down_key,\r\n drill_down_value,\r\n invalid_reason,\r\n summary_sk,\r\n frequency,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_for_pbi') }}\r\n\r\n{% elif var('clinical_enabled', False) == true -%}\r\n\r\nSELECT\r\n data_source,\r\n field_name,\r\n table_name,\r\n 'CLINICAL' AS claim_type,\r\n bucket_name,\r\n field_value,\r\n drill_down_key,\r\n drill_down_value,\r\n invalid_reason,\r\n summary_sk,\r\n frequency,\r\n\t'{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_clinical_for_pbi') }}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "data_quality__data_quality_claims_for_pbi", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_for_pbi", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\final\\data_quality__data_quality_for_pbi.sql", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_for_pbi\n\nunion all\n\nSELECT\n data_source,\n field_name,\n table_name,\n 'CLINICAL' AS claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_clinical_for_pbi\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__quality_trend": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__quality_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\final\\data_quality__quality_trend.sql", "original_file_path": "models\\data_quality\\dqi\\final\\data_quality__quality_trend.sql", "unique_id": "model.the_tuva_project.data_quality__quality_trend", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__quality_trend"], "alias": "quality_trend", "checksum": {"name": "sha256", "checksum": "a065621cbfc11563c280c4d4c422758ccb68b3507e1bb2cdb99dc650f8af1a69"}, "config": {"enabled": true, "alias": "quality_trend", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"first_day_of_month": {"name": "first_day_of_month", "description": "The first day of a given month in date format", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "valid_num": {"name": "valid_num", "description": "Number of rows valid", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fill_num": {"name": "fill_num", "description": "Number of rows filled", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denom": {"name": "denom", "description": "The denominator for the data quality tests", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "quality_trend", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.120606, "relation_name": "dev_thuxuan.data_quality.quality_trend", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',False))\r\n )\r\n}}\r\n\r\n\r\nwith cte as (\r\nselect {{ try_to_cast_date('d.source_date' ) }} as source_date_type\r\n ,summary_sk\r\n ,SUM(CASE WHEN bucket_name = 'valid' THEN 1 ELSE 0 END) as valid_num\r\n ,SUM(CASE WHEN bucket_name <> 'null' THEN 1 ELSE 0 END) as fill_num\r\n ,COUNT(drill_down_value) as denom\r\nfrom {{ ref('data_quality__data_quality_detail') }} d\r\ngroup by\r\n {{ try_to_cast_date('d.source_date') }}\r\n ,summary_sk\r\n\r\n)\r\n\r\nselect\r\n c.first_day_of_month\r\n , summary_sk\r\n , sum(valid_num) as valid_num\r\n , sum(fill_num) as fill_num\r\n , sum(denom) as denom\r\nfrom cte\r\nleft join {{ ref('reference_data__calendar') }} c on cte.source_date_type = c.full_date\r\ngroup by\r\n c.first_day_of_month\r\n , summary_sk", "language": "sql", "refs": [{"name": "data_quality__data_quality_detail", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.try_to_cast_date"], "nodes": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\final\\data_quality__quality_trend.sql", "compiled": true, "compiled_code": "\n\n\nwith cte as (\nselect try_cast( d.source_date as date ) as source_date_type\n ,summary_sk\n ,SUM(CASE WHEN bucket_name = 'valid' THEN 1 ELSE 0 END) as valid_num\n ,SUM(CASE WHEN bucket_name <> 'null' THEN 1 ELSE 0 END) as fill_num\n ,COUNT(drill_down_value) as denom\nfrom dev_thuxuan.data_quality.data_quality_detail d\ngroup by\n try_cast( d.source_date as date )\n ,summary_sk\n\n)\n\nselect\n c.first_day_of_month\n , summary_sk\n , sum(valid_num) as valid_num\n , sum(fill_num) as fill_num\n , sum(denom) as denom\nfrom cte\nleft join dev_thuxuan.reference_data.calendar c on cte.source_date_type = c.full_date\ngroup by\n c.first_day_of_month\n , summary_sk", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__raw_summary": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__raw_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\final\\data_quality__raw_summary.sql", "original_file_path": "models\\data_quality\\dqi\\final\\data_quality__raw_summary.sql", "unique_id": "model.the_tuva_project.data_quality__raw_summary", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__raw_summary"], "alias": "raw_summary", "checksum": {"name": "sha256", "checksum": "166ee234cf313fc44695562a084030e824b780572514a1562cf234a5384f2aad"}, "config": {"enabled": true, "alias": "raw_summary", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"source": {"name": "source", "description": "Whether info came from raw data or input_layer", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Table data check was run on", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "row_count": {"name": "row_count", "description": "Number of rows in table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "unique_check": {"name": "unique_check", "description": "Number of unique values in the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "unique_check_desc": {"name": "unique_check_desc", "description": "Explanation of what the unique check is on that specific table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_order": {"name": "table_order", "description": "Column used to sort the result set in a logical order", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "raw_summary", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1246054, "relation_name": "dev_thuxuan.data_quality.raw_summary", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith cte as (\r\n select \r\n 'input_layer' as source\r\n , 'eligibility' as table_name\r\n , count(*) as row_count\r\n , count(distinct patient_id) as unique_check\r\n , 'Unique Patient Count' as unique_check_desc\r\n , 2 as table_order\r\n from {{ ref('eligibility') }}\r\n\r\n union all\r\n\r\n select \r\n 'raw_data' as source\r\n , 'eligibility' as table_name\r\n , null as row_count\r\n , null as unique_check\r\n , 'Unique Patient Count' as unique_check_desc\r\n , 1 as table_order\r\n from {{ ref('eligibility') }}\r\n\r\n union all\r\n\r\n select \r\n 'input_layer' as source\r\n , 'medical_claim' as table_name\r\n , count(*) as row_count\r\n , count(distinct claim_id) as unique_check\r\n , 'Unique Claim Count' as unique_check_desc\r\n , 4 as table_order\r\n from {{ ref('medical_claim') }}\r\n\r\n union all\r\n\r\n select \r\n 'raw_data' as source\r\n , 'medical_claim' as table_name\r\n , null as row_count\r\n , null as unique_check\r\n , 'Unique Claim Count' as unique_check_desc\r\n , 3 as table_order\r\n from {{ ref('medical_claim') }}\r\n\r\n union all\r\n\r\n select \r\n 'input_layer' as source\r\n , 'pharmacy_claim' as table_name\r\n , count(*) as row_count\r\n , count(distinct claim_id) as unique_check\r\n , 'Unique Claim Count' as unique_check_desc\r\n , 6 as table_order\r\n from {{ ref('pharmacy_claim') }}\r\n\r\n union all\r\n\r\n select \r\n 'raw_data' as source\r\n , 'pharmacy_claim' as table_name\r\n , null as row_count\r\n , null as unique_check\r\n , 'Unique Claim Count' as unique_check_desc\r\n , 5 as table_order\r\n from {{ ref('pharmacy_claim') }}\r\n)\r\n\r\nselect\r\n cte.*\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom cte", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\final\\data_quality__raw_summary.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n 'input_layer' as source\n , 'eligibility' as table_name\n , count(*) as row_count\n , count(distinct patient_id) as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 2 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'raw_data' as source\n , 'eligibility' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 1 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'input_layer' as source\n , 'medical_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 4 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'medical_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 3 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'input_layer' as source\n , 'pharmacy_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 6 as table_order\n from tuva.input_layer.pharmacy_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'pharmacy_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 5 as table_order\n from tuva.input_layer.pharmacy_claim\n)\n\nselect\n cte.*\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__summary": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\final\\data_quality__summary.sql", "original_file_path": "models\\data_quality\\dqi\\final\\data_quality__summary.sql", "unique_id": "model.the_tuva_project.data_quality__summary", "fqn": ["the_tuva_project", "data_quality", "dqi", "final", "data_quality__summary"], "alias": "summary", "checksum": {"name": "sha256", "checksum": "05f0ec557830ea9955657e4c1da4953170dbd6e076546eeaf75645958d15dfa2"}, "config": {"enabled": true, "alias": "summary", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {"summary_sk": {"name": "summary_sk", "description": "Surrogate key for summary table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_claim_type_field_sk": {"name": "table_claim_type_field_sk", "description": "Surrogate key for claim type field.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "table_name": {"name": "table_name", "description": "Name of the input table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_type": {"name": "claim_type", "description": "The claim type (e.g. institutional or professional) or data type (e.g. clinical or claims)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "field_name": {"name": "field_name", "description": "Name of the input table column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "red": {"name": "red", "description": "Percentage to show data quality check as red (bad)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "green": {"name": "green", "description": "Percentage to show data quality check as green (good)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "valid_num": {"name": "valid_num", "description": "Number of rows valid", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fill_num": {"name": "fill_num", "description": "Number of rows filled", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denom": {"name": "denom", "description": "The denominator for the data quality tests", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "summary", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1276057, "relation_name": "dev_thuxuan.data_quality.summary", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',False))\r\n )\r\n}}\r\n\r\nWITH CTE AS (\r\n SELECT DISTINCT fm.field_name\r\n ,fm.input_layer_table_name\r\n ,fm.claim_type\r\n ,table_claim_type_field_sk\r\n FROM {{ ref('data_quality__crosswalk_field_to_mart_sk') }} fm\r\n)\r\n\r\nSELECT\r\n summary_sk,\r\n fm.table_claim_type_field_sk,\r\n data_source,\r\n x.table_name,\r\n x.claim_type,\r\n x.field_name,\r\n sct.red,\r\n sct.green,\r\n sum(case when bucket_name = 'valid' then 1 else 0 end) as valid_num,\r\n sum(case when bucket_name <> 'null' then 1 else 0 end) as fill_num,\r\n count(drill_down_value) as denom,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n {{ ref('data_quality__data_quality_detail') }} x\r\nLEFT JOIN CTE fm\r\n on x.field_name = fm.field_name\r\n and\r\n fm.input_layer_table_name = x.table_name\r\n and\r\n fm.claim_type = x.claim_type\r\nLEFT JOIN {{ ref('data_quality__crosswalk_field_info') }} sct\r\n on x.field_name = sct.field_name\r\n and\r\n sct.input_layer_table_name = x.table_name\r\n and\r\n sct.claim_type = x.claim_type\r\nGROUP BY\r\n summary_sk,\r\n data_source,\r\n fm.table_claim_type_field_sk,\r\n x.claim_type,\r\n x.table_name,\r\n x.field_name,\r\n sct.red,\r\n sct.green", "language": "sql", "refs": [{"name": "data_quality__crosswalk_field_to_mart_sk", "package": null, "version": null}, {"name": "data_quality__data_quality_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_info", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\final\\data_quality__summary.sql", "compiled": true, "compiled_code": "\n\nWITH CTE AS (\n SELECT DISTINCT fm.field_name\n ,fm.input_layer_table_name\n ,fm.claim_type\n ,table_claim_type_field_sk\n FROM dev_thuxuan.data_quality.crosswalk_field_to_mart_sk fm\n)\n\nSELECT\n summary_sk,\n fm.table_claim_type_field_sk,\n data_source,\n x.table_name,\n x.claim_type,\n x.field_name,\n sct.red,\n sct.green,\n sum(case when bucket_name = 'valid' then 1 else 0 end) as valid_num,\n sum(case when bucket_name <> 'null' then 1 else 0 end) as fill_num,\n count(drill_down_value) as denom,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n dev_thuxuan.data_quality.data_quality_detail x\nLEFT JOIN CTE fm\n on x.field_name = fm.field_name\n and\n fm.input_layer_table_name = x.table_name\n and\n fm.claim_type = x.claim_type\nLEFT JOIN dev_thuxuan.data_quality._value_set_crosswalk_field_info sct\n on x.field_name = sct.field_name\n and\n sct.input_layer_table_name = x.table_name\n and\n sct.claim_type = x.claim_type\nGROUP BY\n summary_sk,\n data_source,\n fm.table_claim_type_field_sk,\n x.claim_type,\n x.table_name,\n x.field_name,\n sct.red,\n sct.green", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_address": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_address", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_address.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_address.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_address", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_address"], "alias": "eligibility_address", "checksum": {"name": "sha256", "checksum": "9fcb4685254cd9497b7e7d78d57d0768d1b403339e69d74eb6db3fa1b17d4eab"}, "config": {"enabled": true, "alias": "eligibility_address", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_address", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1316066, "relation_name": "dev_thuxuan.data_quality.eligibility_address", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'eligibility' as table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'ADDRESS' AS field_name\r\n ,case when m.address is null then 'null'\r\n else 'valid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,CAST(address as {{ dbt.type_string() }}) AS field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_address.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'eligibility' as table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ADDRESS' AS field_name\n ,case when m.address is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(address as TEXT) AS field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_birth_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_birth_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_birth_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_birth_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_birth_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_birth_date"], "alias": "eligibility_birth_date", "checksum": {"name": "sha256", "checksum": "c5c31d235bf28b3263a846c2fa3f07fc5107d945b3fb8d15763a46dc9e25ad5c"}, "config": {"enabled": true, "alias": "eligibility_birth_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_birth_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1336064, "relation_name": "dev_thuxuan.data_quality.eligibility_birth_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nWITH base as (\r\n SELECT * \r\n FROM {{ ref('eligibility')}}\r\n\r\n),\r\nunique_field as (\r\n SELECT DISTINCT member_id\r\n ,cast(birth_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n FROM base\r\n),\r\nclaim_grain as (\r\n SELECT member_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n GROUP BY member_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nSELECT\r\n member_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} AS field_aggregated\r\nFROM\r\n unique_field\r\nGROUP BY\r\n data_source,\r\n member_id\r\n)\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'BIRTH_DATE' AS field_name\r\n ,CASE \r\n WHEN cg.frequency > 1 THEN 'multiple'\r\n WHEN m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) THEN 'invalid'\r\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'invalid'\r\n WHEN m.birth_date IS NULL THEN 'null'\r\n ELSE 'valid' \r\n END AS bucket_name\r\n ,CASE \r\n WHEN cg.frequency > 1 THEN 'multiple'\r\n WHEN m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) THEN 'future'\r\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'too old'\r\n else null\r\n END AS invalid_reason\r\n,CAST({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) AS field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM base m\r\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_birth_date.sql", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n SELECT DISTINCT member_id\n ,cast(birth_date as TEXT) as field\n ,data_source\n FROM base\n),\nclaim_grain as (\n SELECT member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n GROUP BY member_id\n ,data_source\n),\nclaim_agg as (\nSELECT\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) AS field_aggregated\nFROM\n unique_field\nGROUP BY\n data_source,\n member_id\n)\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'BIRTH_DATE' AS field_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) THEN 'invalid'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'invalid'\n WHEN m.birth_date IS NULL THEN 'null'\n ELSE 'valid' \n END AS bucket_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) THEN 'future'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'too old'\n else null\n END AS invalid_reason\n,CAST(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) AS field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_city": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_city", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_city.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_city.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_city", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_city"], "alias": "eligibility_city", "checksum": {"name": "sha256", "checksum": "a4a13dd607bc833c2d0f658c5bddeed153a1d28d2c2de8dea868ccf00e190c47"}, "config": {"enabled": true, "alias": "eligibility_city", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_city", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1366026, "relation_name": "dev_thuxuan.data_quality.eligibility_city", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'CITY' AS field_name\r\n ,case when m.race is null then 'null'\r\n else 'valid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,CAST(city as {{ dbt.type_string() }}) AS field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_city.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'CITY' AS field_name\n ,case when m.race is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(city as TEXT) AS field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_data_source"], "alias": "eligibility_data_source", "checksum": {"name": "sha256", "checksum": "cf6000f2897afd1b6c0cae2f20503f9ebb6e452cb2ff8da18e3a27da74a4a68d"}, "config": {"enabled": true, "alias": "eligibility_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.138603, "relation_name": "dev_thuxuan.data_quality.eligibility_data_source", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'DATA_SOURCE' AS field_name\r\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_death_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_death_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_death_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_death_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_death_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_death_date"], "alias": "eligibility_death_date", "checksum": {"name": "sha256", "checksum": "c87692cb1d8992be8968ccaaae08acd8cc538f5beb420011bb15dfb1a643407f"}, "config": {"enabled": true, "alias": "eligibility_death_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_death_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1406033, "relation_name": "dev_thuxuan.data_quality.eligibility_death_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nWITH base as (\r\n SELECT * \r\n FROM {{ ref('eligibility')}}\r\n\r\n),\r\nunique_field as (\r\n select distinct member_id\r\n ,cast(death_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select member_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by member_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n member_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n data_source,\r\n member_id\r\n)\r\nselect distinct\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'DEATH_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.death_date <= m.birth_date then 'invalid'\r\n when m.death_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.death_date <= m.birth_date then 'death date before birth date'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_death_date.sql", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n select distinct member_id\n ,cast(death_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by member_id\n ,data_source\n),\nclaim_agg as (\nselect\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n data_source,\n member_id\n)\nselect distinct\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date <= m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date <= m.birth_date then 'death date before birth date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_death_flag": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_death_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_death_flag.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_death_flag.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_death_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_death_flag"], "alias": "eligibility_death_flag", "checksum": {"name": "sha256", "checksum": "0b1920411c7904c1e29c614bfa211cfb316f1b847477ada6314944c87350288c"}, "config": {"enabled": true, "alias": "eligibility_death_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_death_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1426036, "relation_name": "dev_thuxuan.data_quality.eligibility_death_flag", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'DEATH_FLAG' AS field_name\r\n ,case\r\n when m.death_flag in (1,0) then 'valid'\r\n when m.death_flag is null then 'null'\r\n else 'invalid'\r\n end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(death_flag as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_death_flag.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_FLAG' AS field_name\n ,case\n when m.death_flag in (1,0) then 'valid'\n when m.death_flag is null then 'null'\n else 'invalid'\n end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(death_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_dual_status_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_dual_status_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_dual_status_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_dual_status_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_dual_status_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_dual_status_code"], "alias": "eligibility_dual_status_code", "checksum": {"name": "sha256", "checksum": "3c7591120866f0b9b7e95d26e0c2a67f097374c4d3cf636948475bdcd1f594fb"}, "config": {"enabled": true, "alias": "eligibility_dual_status_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_dual_status_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1446028, "relation_name": "dev_thuxuan.data_quality.eligibility_dual_status_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'DUAL_STATUS_CODE' AS field_name\r\n ,case when m.dual_status_code is null then 'null'\r\n when term.dual_status_code is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.dual_status_code is not null and term.dual_status_code is null then 'Dual Status Code does not join to Terminology Medicare Dual Eligibility table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.dual_status_code\", \"'|'\", \"coalesce(term.dual_status_description,'')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('terminology__medicare_dual_eligibility')}} term on m.dual_status_code = term.dual_status_code", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__medicare_dual_eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_dual_eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_dual_status_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DUAL_STATUS_CODE' AS field_name\n ,case when m.dual_status_code is null then 'null'\n when term.dual_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.dual_status_code is not null and term.dual_status_code is null then 'Dual Status Code does not join to Terminology Medicare Dual Eligibility table'\n else null\n end as invalid_reason\n , m.dual_status_code || '|' || coalesce(term.dual_status_description,'') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.medicare_dual_eligibility term on m.dual_status_code = term.dual_status_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_end_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_end_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_end_date"], "alias": "eligibility_end_date", "checksum": {"name": "sha256", "checksum": "35e3b01d58b9effff54f9634f03922cf54166310d57fcc754645eb345e60144a"}, "config": {"enabled": true, "alias": "eligibility_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1476035, "relation_name": "dev_thuxuan.data_quality.eligibility_end_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID' AS drill_down_key\r\n ,coalesce(m.member_id,'NULL') AS drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'ENROLLMENT_END_DATE' AS field_name\r\n ,case\r\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.enrollment_end_date < m.enrollment_start_date then 'invalid'\r\n when m.enrollment_end_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n\r\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.enrollment_end_date < m.enrollment_start_date then 'end date before start date'\r\n else null\r\n end as invalid_reason\r\n ,cast(enrollment_end_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_end_date.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id,'NULL') AS drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_END_DATE' AS field_name\n ,case\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_end_date < m.enrollment_start_date then 'invalid'\n when m.enrollment_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.enrollment_end_date < m.enrollment_start_date then 'end date before start date'\n else null\n end as invalid_reason\n ,cast(enrollment_end_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_first_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_first_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_first_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_first_name.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_first_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_first_name"], "alias": "eligibility_first_name", "checksum": {"name": "sha256", "checksum": "3f455d7baac7e378d93f59a20d6b6b798f49e34aca555432fd58c0635a5251df"}, "config": {"enabled": true, "alias": "eligibility_first_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_first_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.149603, "relation_name": "dev_thuxuan.data_quality.eligibility_first_name", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'FIRST_NAME' AS field_name\r\n ,case when m.first_name is null then 'null'\r\n else 'valid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(first_name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_first_name.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'FIRST_NAME' AS field_name\n ,case when m.first_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(first_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_gender": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_gender", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_gender.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_gender.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_gender", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_gender"], "alias": "eligibility_gender", "checksum": {"name": "sha256", "checksum": "49722075d021146f5b2bedc317d0ab67ba22301f0b8fa2aab8d71ce4a58be8c5"}, "config": {"enabled": true, "alias": "eligibility_gender", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_gender", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1516032, "relation_name": "dev_thuxuan.data_quality.eligibility_gender", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'GENDER' AS field_name\r\n ,case when m.gender is null then 'null'\r\n when term.gender is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.gender is not null and term.gender is null then 'Gender does not join to Terminology Gender table'\r\n else null\r\n end as invalid_reason\r\n ,cast(m.gender as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('terminology__gender')}} term on m.gender = term.gender", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__gender", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__gender"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_gender.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'GENDER' AS field_name\n ,case when m.gender is null then 'null'\n when term.gender is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.gender is not null and term.gender is null then 'Gender does not join to Terminology Gender table'\n else null\n end as invalid_reason\n ,cast(m.gender as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.gender term on m.gender = term.gender", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_last_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_last_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_last_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_last_name.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_last_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_last_name"], "alias": "eligibility_last_name", "checksum": {"name": "sha256", "checksum": "13707b6a68b9d59f3f66c05048fcace6cddacbafb9ffe3dfea928eefdf24d71a"}, "config": {"enabled": true, "alias": "eligibility_last_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_last_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1546032, "relation_name": "dev_thuxuan.data_quality.eligibility_last_name", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'LAST_NAME' AS field_name\r\n ,case when m.last_name is null then 'null'\r\n else 'valid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(last_name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_last_name.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'LAST_NAME' AS field_name\n ,case when m.last_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(last_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_medicare_status_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_medicare_status_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_medicare_status_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_medicare_status_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_medicare_status_code"], "alias": "eligibility_medicare_status_code", "checksum": {"name": "sha256", "checksum": "6c453b81434a06dc499a3679f46f4a4a4ae0eb4201d021e0e82fbe678f36435b"}, "config": {"enabled": true, "alias": "eligibility_medicare_status_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_medicare_status_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.156603, "relation_name": "dev_thuxuan.data_quality.eligibility_medicare_status_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'MEDICARE_STATUS_CODE' AS field_name\r\n ,case when m.medicare_status_code is null then 'null'\r\n when term.medicare_status_code is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.medicare_status_code is not null and term.medicare_status_code is null then 'Medicare Status Code does not join to Terminology Medicare Status table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.medicare_status_code\", \"'|'\", \"coalesce(term.medicare_status_description,'')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('terminology__medicare_status')}} term on m.medicare_status_code = term.medicare_status_code", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__medicare_status", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_status"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_medicare_status_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEDICARE_STATUS_CODE' AS field_name\n ,case when m.medicare_status_code is null then 'null'\n when term.medicare_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.medicare_status_code is not null and term.medicare_status_code is null then 'Medicare Status Code does not join to Terminology Medicare Status table'\n else null\n end as invalid_reason\n , m.medicare_status_code || '|' || coalesce(term.medicare_status_description,'') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.medicare_status term on m.medicare_status_code = term.medicare_status_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_member_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_member_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_member_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_member_id.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_member_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_member_id"], "alias": "eligibility_member_id", "checksum": {"name": "sha256", "checksum": "f8ca01858a6510243eca50688bc9f82c9507d4cc95a39ebabd75d967535ba907"}, "config": {"enabled": true, "alias": "eligibility_member_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_member_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1586032, "relation_name": "dev_thuxuan.data_quality.eligibility_member_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'MEMBER_ID' AS field_name\r\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_member_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_original_reason_entitlement_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_original_reason_entitlement_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_original_reason_entitlement_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_original_reason_entitlement_code"], "alias": "eligibility_original_reason_entitlement_code", "checksum": {"name": "sha256", "checksum": "c1f52c73717d8cf80d213fa6421089dae00010fb5b668c392b577216ff3b65a5"}, "config": {"enabled": true, "alias": "eligibility_original_reason_entitlement_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_original_reason_entitlement_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1606033, "relation_name": "dev_thuxuan.data_quality.eligibility_original_reason_entitlement_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'ORIGINAL_REASON_ENTITLEMENT_CODE' AS field_name\r\n ,case when m.original_reason_entitlement_code is null then 'null'\r\n when term.original_reason_entitlement_code is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.original_reason_entitlement_code is not null and term.original_reason_entitlement_code is null then 'Original Reason Entitlement Code does not join to Terminology Original Reason Entitlement Code table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.original_reason_entitlement_code\", \"'|'\", \"coalesce(term.original_reason_entitlement_description,'')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('terminology__medicare_orec')}} term on m.original_reason_entitlement_code = term.original_reason_entitlement_code", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__medicare_orec", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_orec"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_original_reason_entitlement_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ORIGINAL_REASON_ENTITLEMENT_CODE' AS field_name\n ,case when m.original_reason_entitlement_code is null then 'null'\n when term.original_reason_entitlement_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.original_reason_entitlement_code is not null and term.original_reason_entitlement_code is null then 'Original Reason Entitlement Code does not join to Terminology Original Reason Entitlement Code table'\n else null\n end as invalid_reason\n , m.original_reason_entitlement_code || '|' || coalesce(term.original_reason_entitlement_description,'') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.medicare_orec term on m.original_reason_entitlement_code = term.original_reason_entitlement_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_patient_id"], "alias": "eligibility_patient_id", "checksum": {"name": "sha256", "checksum": "9833cc01a2d879bdf896668e7bdf909426bb9827d45efb55792dc0e63cfa4bf8"}, "config": {"enabled": true, "alias": "eligibility_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1626036, "relation_name": "dev_thuxuan.data_quality.eligibility_patient_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'PATIENT_ID' AS field_name\r\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_payer": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_payer.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_payer.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_payer", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_payer"], "alias": "eligibility_payer", "checksum": {"name": "sha256", "checksum": "6e38ef8a789601a897c33f0d5ad65a430b369ed9b9ec2af3be40a393cde38d4f"}, "config": {"enabled": true, "alias": "eligibility_payer", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_payer", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1676326, "relation_name": "dev_thuxuan.data_quality.eligibility_payer", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'PAYER' AS field_name\r\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(payer as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_payer.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_payer_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_payer_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_payer_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_payer_type.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_payer_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_payer_type"], "alias": "eligibility_payer_type", "checksum": {"name": "sha256", "checksum": "bfcd3b8b0b8f41b8ea7540871ab6e6c60343d05b3e40ac06206d9400c602dbbb"}, "config": {"enabled": true, "alias": "eligibility_payer_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_payer_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1646032, "relation_name": "dev_thuxuan.data_quality.eligibility_payer_type", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'PAYER_TYPE' AS field_name\r\n ,case when m.payer_type is null then 'null'\r\n when term.payer_type is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.payer_type is not null and term.payer_type is null then 'Payer Type does not join to Terminology Payer Type table'\r\n else null\r\n end as invalid_reason\r\n ,cast(m.payer_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('terminology__payer_type')}} term on m.payer_type = term.payer_type", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__payer_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_payer_type.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER_TYPE' AS field_name\n ,case when m.payer_type is null then 'null'\n when term.payer_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.payer_type is not null and term.payer_type is null then 'Payer Type does not join to Terminology Payer Type table'\n else null\n end as invalid_reason\n ,cast(m.payer_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.payer_type term on m.payer_type = term.payer_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_phone": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_phone", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_phone.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_phone.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_phone", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_phone"], "alias": "eligibility_phone", "checksum": {"name": "sha256", "checksum": "07a50c320667576386c55fab67dfccecbcd09e834fc21c8135f602c1792eb384"}, "config": {"enabled": true, "alias": "eligibility_phone", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_phone", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1706188, "relation_name": "dev_thuxuan.data_quality.eligibility_phone", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'PHONE' AS field_name\r\n ,case when m.phone is null then 'null'\r\n else 'valid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(phone as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_phone.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PHONE' AS field_name\n ,case when m.phone is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(phone as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_plan": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_plan.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_plan.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_plan", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_plan"], "alias": "eligibility_plan", "checksum": {"name": "sha256", "checksum": "3e83ce77b3a264598b0d191a574e1c9c71d9ad042a0f6d0b4663b8274fd4ef3f"}, "config": {"enabled": true, "alias": "eligibility_plan", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_plan", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.173619, "relation_name": "dev_thuxuan.data_quality.eligibility_plan", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'PLAN' AS field_name\r\n ,case when m.{{ quote_column('plan') }} is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(m.{{ quote_column('plan') }} as {{ dbt.type_string() }}) as field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_plan.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(m.plan as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_race": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_race", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_race.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_race.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_race", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_race"], "alias": "eligibility_race", "checksum": {"name": "sha256", "checksum": "4e1d17c95322ba5df1e2b9f4a66e10992f779c7493e69aceaddd7d7f166c270c"}, "config": {"enabled": true, "alias": "eligibility_race", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_race", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1756191, "relation_name": "dev_thuxuan.data_quality.eligibility_race", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'RACE' AS field_name\r\n ,case when m.race is null then 'null'\r\n when r.description is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.race is not null and r.description is null then 'Race does not join to terminology race table'\r\n else null\r\n end as invalid_reason\r\n ,cast(race as {{ dbt.type_string() }}) as field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('terminology__race')}} r on m.race=r.description", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__race", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__race"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_race.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'RACE' AS field_name\n ,case when m.race is null then 'null'\n when r.description is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.race is not null and r.description is null then 'Race does not join to terminology race table'\n else null\n end as invalid_reason\n ,cast(race as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.race r on m.race=r.description", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_start_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_start_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_start_date"], "alias": "eligibility_start_date", "checksum": {"name": "sha256", "checksum": "e5ca242b0a350c22f646e328a361897d59cd5faf5cdb1159d21f227943c7a8c7"}, "config": {"enabled": true, "alias": "eligibility_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1776187, "relation_name": "dev_thuxuan.data_quality.eligibility_start_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'ENROLLMENT_START_DATE' AS field_name\r\n ,case\r\n when m.enrollment_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.enrollment_start_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when m.enrollment_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'too old'\r\n else null\r\n end as invalid_reason\r\n ,cast(enrollment_start_date as {{ dbt.type_string() }}) as field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_start_date.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_START_DATE' AS field_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n ,cast(enrollment_start_date as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_state": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_state", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_state.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_state.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_state", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_state"], "alias": "eligibility_state", "checksum": {"name": "sha256", "checksum": "3925abb3516ee8544bf9b1e9863690213f9844fba5ede3fcbc6610b99198c5fa"}, "config": {"enabled": true, "alias": "eligibility_state", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_state", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1796186, "relation_name": "dev_thuxuan.data_quality.eligibility_state", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT \r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'STATE' AS field_name\r\n ,case when m.state is null then 'null'\r\n when term.ssa_fips_state_name is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.state is not null and term.ssa_fips_state_name is null then 'State does not join to Terminology SSA_FIPS_STATE table'\r\n else null\r\n end as invalid_reason\r\n ,cast(state as {{ dbt.type_string() }}) as field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m\r\nleft join {{ ref('reference_data__ssa_fips_state')}} as term on m.state = term.ssa_fips_state_name", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "reference_data__ssa_fips_state", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__ssa_fips_state"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_state.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'STATE' AS field_name\n ,case when m.state is null then 'null'\n when term.ssa_fips_state_name is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.state is not null and term.ssa_fips_state_name is null then 'State does not join to Terminology SSA_FIPS_STATE table'\n else null\n end as invalid_reason\n ,cast(state as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.reference_data.ssa_fips_state as term on m.state = term.ssa_fips_state_name", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_zip_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_zip_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_zip_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_zip_code.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_zip_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "eligibility", "data_quality__eligibility_zip_code"], "alias": "eligibility_zip_code", "checksum": {"name": "sha256", "checksum": "7285fb9762e9dff9b7e31816f3903d48e1e65511266d0c7232e0cba11c7b7a0e"}, "config": {"enabled": true, "alias": "eligibility_zip_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_zip_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.181619, "relation_name": "dev_thuxuan.data_quality.eligibility_zip_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n ,coalesce(cast(m.enrollment_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'ELIGIBILITY' AS table_name\r\n ,'Member ID | Enrollment Start Date' AS drill_down_key\r\n ,coalesce(m.member_id, 'NULL') as drill_down_value\r\n ,'ELIGIBILITY' AS claim_type\r\n ,'ZIP_CODE' AS field_name\r\n {% if target.type == 'fabric' %}\r\n ,case when m.zip_code is null then 'null'\r\n when len(m.zip_code) in (5,9,10) then 'valid'\r\n else 'invalid' end as bucket_name\r\n ,case\r\n when m.zip_code is not null and len(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\r\n else null\r\n end as invalid_reason\r\n {% else %}\r\n ,case when m.zip_code is null then 'null'\r\n when length(m.zip_code) in (5,9,10) then 'valid'\r\n else 'invalid' end as bucket_name\r\n ,case\r\n when m.zip_code is not null and length(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\r\n else null\r\n end as invalid_reason\r\n {% endif %}\r\n ,cast(zip_code as {{ dbt.type_string() }}) as field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility')}} m", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\eligibility\\data_quality__eligibility_zip_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ZIP_CODE' AS field_name\n \n ,case when m.zip_code is null then 'null'\n when length(m.zip_code) in (5,9,10) then 'valid'\n else 'invalid' end as bucket_name\n ,case\n when m.zip_code is not null and length(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\n else null\n end as invalid_reason\n \n ,cast(zip_code as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_allowed_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_allowed_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_allowed_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_allowed_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_allowed_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_allowed_amount"], "alias": "claim_allowed_amount", "checksum": {"name": "sha256", "checksum": "e4064866d6cacd6ea79774c118074374c6a41400fd41adfcddfaeb93ae3d8133"}, "config": {"enabled": true, "alias": "claim_allowed_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_allowed_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1836038, "relation_name": "dev_thuxuan.data_quality.claim_allowed_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'ALLOWED_AMOUNT' AS field_name\r\n , case when m.allowed_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(allowed_amount as {{ dbt.type_string() }}) as field_value\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_allowed_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_charge_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_charge_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_charge_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_charge_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_charge_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_charge_amount"], "alias": "claim_charge_amount", "checksum": {"name": "sha256", "checksum": "a3fcc252d6ea0750b614f0a9abd5276f3e0d1c1d863c07f969df7d1890a0e7d7"}, "config": {"enabled": true, "alias": "claim_charge_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_charge_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1856034, "relation_name": "dev_thuxuan.data_quality.claim_charge_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'CHARGE_AMOUNT' AS field_name\r\n , case when m.charge_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(charge_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_charge_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_id"], "alias": "claim_claim_id", "checksum": {"name": "sha256", "checksum": "1844e6a631cdcb5cf242028d4595a6a2052941b5bf7cbaf239d89d0bdf57b7ce"}, "config": {"enabled": true, "alias": "claim_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.187603, "relation_name": "dev_thuxuan.data_quality.claim_claim_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' as drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'CLAIM_ID' AS field_name\r\n ,case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_ID' AS field_name\n ,case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_line_end_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_claim_line_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_end_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_line_end_date"], "alias": "claim_claim_line_end_date", "checksum": {"name": "sha256", "checksum": "15b0065e65f686f93ac172d534c3f550c19e5c77eb353c88e97311ec8691bdb5"}, "config": {"enabled": true, "alias": "claim_claim_line_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_line_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1906035, "relation_name": "dev_thuxuan.data_quality.claim_claim_line_end_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith tuva_last_run as(\r\n\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n\r\n)\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'CLAIM_LINE_END_DATE' AS field_name\r\n , case\r\n when m.claim_line_end_date > tuva_last_run then 'invalid'\r\n when m.claim_line_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.claim_line_end_date > m.claim_line_end_date then 'invalid'\r\n when m.claim_line_end_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.claim_line_end_date > tuva_last_run then 'future'\r\n when m.claim_line_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when m.claim_line_end_date > m.claim_end_date then 'line date greater than claim date'\r\n else null\r\n end as invalid_reason\r\n , cast(claim_line_end_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_end_date.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_END_DATE' AS field_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'invalid'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_end_date > m.claim_line_end_date then 'invalid'\n when m.claim_line_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'future'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_end_date > m.claim_end_date then 'line date greater than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_end_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_line_number": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_claim_line_number", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_number.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_number.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_number", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_line_number"], "alias": "claim_claim_line_number", "checksum": {"name": "sha256", "checksum": "9c5765a1be7d5a1e710102d495307ed44a096e1d6950e287f08d6cfb5fdb0244"}, "config": {"enabled": true, "alias": "claim_claim_line_number", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_line_number", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1926086, "relation_name": "dev_thuxuan.data_quality.claim_claim_line_number", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' as drill_down_key\r\n ,coalesce(claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'CLAIM_LINE_NUMBER' AS field_name\r\n ,case when m.claim_line_number is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_number.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_LINE_NUMBER' AS field_name\n ,case when m.claim_line_number is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_line_start_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_claim_line_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_start_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_line_start_date"], "alias": "claim_claim_line_start_date", "checksum": {"name": "sha256", "checksum": "d4c9ce7fcd0894ddc5abb9efc45f7ffda3eb88b59a45584f56b3f6e84a9cd98f"}, "config": {"enabled": true, "alias": "claim_claim_line_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_line_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1946084, "relation_name": "dev_thuxuan.data_quality.claim_claim_line_start_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith tuva_last_run as(\r\n\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n\r\n)\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'CLAIM_LINE_START_DATE' AS field_name\r\n , case\r\n when m.claim_line_start_date > tuva_last_run then 'invalid'\r\n when m.claim_line_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp = \"cte.tuva_last_run\") }} then 'invalid'\r\n when m.claim_line_start_date < m.claim_start_date then 'invalid'\r\n when m.claim_line_start_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.claim_line_start_date > tuva_last_run then 'future'\r\n when m.claim_line_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp = \"cte.tuva_last_run\" ) }} then 'too old'\r\n when m.claim_line_start_date < m.claim_start_date then 'line date less than than claim date'\r\n else null\r\n end as invalid_reason\r\n , cast(claim_line_start_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_line_start_date.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_START_DATE' AS field_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'invalid'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_start_date < m.claim_start_date then 'invalid'\n when m.claim_line_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'future'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_start_date < m.claim_start_date then 'line date less than than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_claim_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_claim_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_type.sql", "unique_id": "model.the_tuva_project.data_quality__claim_claim_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_claim_type"], "alias": "claim_claim_type", "checksum": {"name": "sha256", "checksum": "33d1d39e657fd8fb49a327059524d48823970cea376943160f39a04ef1752308"}, "config": {"enabled": true, "alias": "claim_claim_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_claim_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1966155, "relation_name": "dev_thuxuan.data_quality.claim_claim_type", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' as drill_down_key\r\n,coalesce(claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'CLAIM_TYPE' AS field_name\r\n ,case when m.claim_type is null then 'null'\r\n when term.claim_type is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.claim_type is not null and term.claim_type is null then 'Claim Type does not join to Terminology Claim Type table'\r\n else null\r\n end as invalid_reason\r\n ,cast(m.claim_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m\r\nleft join {{ ref('terminology__claim_type')}} term on m.claim_type = term.claim_type", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__claim_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__claim_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_claim_type.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_TYPE' AS field_name\n ,case when m.claim_type is null then 'null'\n when term.claim_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.claim_type is not null and term.claim_type is null then 'Claim Type does not join to Terminology Claim Type table'\n else null\n end as invalid_reason\n ,cast(m.claim_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join dev_thuxuan.terminology.claim_type term on m.claim_type = term.claim_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_coinsurance_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_coinsurance_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_coinsurance_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_coinsurance_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_coinsurance_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_coinsurance_amount"], "alias": "claim_coninsurance_amount", "checksum": {"name": "sha256", "checksum": "f76ce47623e30010a87cc8d671b4dbeeff3fc22f51205b700f35011bdca4a90b"}, "config": {"enabled": true, "alias": "claim_coninsurance_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_coninsurance_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1996107, "relation_name": "dev_thuxuan.data_quality.claim_coninsurance_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'COINSURANCE_AMOUNT' AS field_name\r\n , case when m.coinsurance_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(coinsurance_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_coinsurance_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_copayment_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_copayment_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_copayment_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_copayment_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_copayment_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_copayment_amount"], "alias": "claim_copayment_amount", "checksum": {"name": "sha256", "checksum": "78917c8d276346dfb9014db18734f1885236640cc5ee9590aeec3a932243a867"}, "config": {"enabled": true, "alias": "claim_copayment_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_copayment_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.201611, "relation_name": "dev_thuxuan.data_quality.claim_copayment_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'COPAYMENT_AMOUNT' AS field_name\r\n , case when m.copayment_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(copayment_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_copayment_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__claim_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_data_source"], "alias": "claim_data_source", "checksum": {"name": "sha256", "checksum": "690accad9615e05328251449e2956f4dba0953f02429aae4430c99ac53ce19b9"}, "config": {"enabled": true, "alias": "claim_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.203611, "relation_name": "dev_thuxuan.data_quality.claim_data_source", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' as drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'DATA_SOURCE' AS field_name\r\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_deductible_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_deductible_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_deductible_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_deductible_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_deductible_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_deductible_amount"], "alias": "claim_deductible_amount", "checksum": {"name": "sha256", "checksum": "3366c34e90a70e69d0090e3e03c12961c9e71516879834a16aa267ea96e15eeb"}, "config": {"enabled": true, "alias": "claim_deductible_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_deductible_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2056115, "relation_name": "dev_thuxuan.data_quality.claim_deductible_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'DEDUCTIBLE_AMOUNT' AS field_name\r\n , case when m.deductible_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(deductible_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_deductible_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_diagnosis_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_diagnosis_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_diagnosis_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_diagnosis_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_diagnosis_code_type"], "alias": "claim_diagnosis_code_type", "checksum": {"name": "sha256", "checksum": "ccd6289f6887e81529e6bb5d4c9388dfe506f299f26d4bb92578004f286d18b3"}, "config": {"enabled": true, "alias": "claim_diagnosis_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_diagnosis_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2081285, "relation_name": "dev_thuxuan.data_quality.claim_diagnosis_code_type", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' as drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'DIAGNOSIS_CODE_TYPE' AS field_name\r\n ,case when m.diagnosis_code_type is null then 'null'\r\n when term.code_type is null then 'invalid'\r\n else 'valid' end as bucket_name\r\n ,case\r\n when m.diagnosis_code_type is not null and term.code_type is null then 'Diagnosis Code Type does not join to Terminology Code Type table'\r\n else null\r\n end as invalid_reason\r\n ,cast(m.diagnosis_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m\r\nleft join {{ ref('reference_data__code_type')}} term on m.diagnosis_code_type = term.code_type", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_diagnosis_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DIAGNOSIS_CODE_TYPE' AS field_name\n ,case when m.diagnosis_code_type is null then 'null'\n when term.code_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.diagnosis_code_type is not null and term.code_type is null then 'Diagnosis Code Type does not join to Terminology Code Type table'\n else null\n end as invalid_reason\n ,cast(m.diagnosis_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join dev_thuxuan.reference_data.code_type term on m.diagnosis_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_hcpcs_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_hcpcs_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_hcpcs_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_hcpcs_code.sql", "unique_id": "model.the_tuva_project.data_quality__claim_hcpcs_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_hcpcs_code"], "alias": "claim_hcpcs_code", "checksum": {"name": "sha256", "checksum": "185e68515345ba1e1397d3a52dafc57988c834d16e905d138fec5bec09aec748"}, "config": {"enabled": true, "alias": "claim_hcpcs_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_hcpcs_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2101288, "relation_name": "dev_thuxuan.data_quality.claim_hcpcs_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'HCPCS_CODE' AS field_name\r\n , case\r\n when term.hcpcs is not null then 'valid'\r\n when m.hcpcs_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case\r\n when m.hcpcs_code is not null and term.hcpcs is null then 'HCPCS does not join to Terminology HCPCS_LEVEL_2 table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.hcpcs_code\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('medical_claim')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} as term on m.hcpcs_code = term.hcpcs", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_hcpcs_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'HCPCS_CODE' AS field_name\n , case\n when term.hcpcs is not null then 'valid'\n when m.hcpcs_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.hcpcs_code is not null and term.hcpcs is null then 'HCPCS does not join to Terminology HCPCS_LEVEL_2 table'\n else null\n end as invalid_reason\n , m.hcpcs_code || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join dev_thuxuan.terminology.hcpcs_level_2 as term on m.hcpcs_code = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_member_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_member_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_member_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_member_id.sql", "unique_id": "model.the_tuva_project.data_quality__claim_member_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_member_id"], "alias": "claim_member_id", "checksum": {"name": "sha256", "checksum": "e9a051fcdc1e56c84d5f2c7d9bd7e6e442cd07140a83ca133f8d9eff89e3db70"}, "config": {"enabled": true, "alias": "claim_member_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_member_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.212129, "relation_name": "dev_thuxuan.data_quality.claim_member_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'MEMBER_ID' AS field_name\r\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_member_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_paid_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_paid_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_paid_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_paid_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_paid_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_paid_amount"], "alias": "claim_paid_amount", "checksum": {"name": "sha256", "checksum": "45bc4b8ad220ac8bcdf3cacabe47e420aab4f90e9c4dab590bed55b2de2ce16d"}, "config": {"enabled": true, "alias": "claim_paid_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_paid_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.214129, "relation_name": "dev_thuxuan.data_quality.claim_paid_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'PAID_AMOUNT' AS field_name\r\n , case when m.paid_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(paid_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_paid_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_paid_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_paid_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_paid_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_paid_date.sql", "unique_id": "model.the_tuva_project.data_quality__claim_paid_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_paid_date"], "alias": "claim_paid_date", "checksum": {"name": "sha256", "checksum": "688260db9aa46334ad26405b6a71bb113ef009e77f2067677c88c48347652ad1"}, "config": {"enabled": true, "alias": "claim_paid_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_paid_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.217126, "relation_name": "dev_thuxuan.data_quality.claim_paid_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith tuva_last_run as(\r\n\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n\r\n)\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'PAID_DATE' AS field_name\r\n , case\r\n when m.paid_date > tuva_last_run then 'invalid'\r\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.paid_date < m.claim_start_date then 'invalid'\r\n when m.paid_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.paid_date > tuva_last_run then 'future'\r\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when m.paid_date < m.claim_start_date then 'paid date before claim start date'\r\n else null\r\n end as invalid_reason\r\n , cast(claim_line_start_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_paid_date.sql", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date < m.claim_start_date then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.paid_date < m.claim_start_date then 'paid date before claim start date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__claim_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_patient_id"], "alias": "claim_patient_id", "checksum": {"name": "sha256", "checksum": "786bfbee855a7c1adb16326fef2e2171e678b917a63a49c7c18419813a6fc213"}, "config": {"enabled": true, "alias": "claim_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.219126, "relation_name": "dev_thuxuan.data_quality.claim_patient_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n,coalesce(claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'PATIENT_ID' AS field_name\r\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_payer": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_payer.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_payer.sql", "unique_id": "model.the_tuva_project.data_quality__claim_payer", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_payer"], "alias": "claim_payer", "checksum": {"name": "sha256", "checksum": "dd6edb4b4e33dddc92e57c84b7d23f45a9575369860f0359acd5ea04dfdc5c6c"}, "config": {"enabled": true, "alias": "claim_payer", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_payer", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.221126, "relation_name": "dev_thuxuan.data_quality.claim_payer", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain \r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n,coalesce(claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'PAYER' AS field_name\r\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(payer as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_payer.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_plan": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_plan.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_plan.sql", "unique_id": "model.the_tuva_project.data_quality__claim_plan", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_plan"], "alias": "claim_plan", "checksum": {"name": "sha256", "checksum": "92ec07593ecddd712c5a5374827e0a2c2814e7f900a87f292464ae404404dbbd"}, "config": {"enabled": true, "alias": "claim_plan", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_plan", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2231262, "relation_name": "dev_thuxuan.data_quality.claim_plan", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n,coalesce(claim_id, 'NULL') AS drill_down_value\r\n ,m.claim_type as claim_type\r\n ,'PLAN' AS field_name\r\n ,case when m.{{ quote_column('plan') }} is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast({{ quote_column('plan') }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_plan.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(plan as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_total_cost_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_total_cost_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_total_cost_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_total_cost_amount.sql", "unique_id": "model.the_tuva_project.data_quality__claim_total_cost_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "data_quality__claim_total_cost_amount"], "alias": "claim_total_cost_amount", "checksum": {"name": "sha256", "checksum": "93a88b185047ea291c7796a7c3477d3ff69ff404637be5a36d57dc56ec37a2e4"}, "config": {"enabled": true, "alias": "claim_total_cost_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_total_cost_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2251265, "relation_name": "dev_thuxuan.data_quality.claim_total_cost_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'TOTAL_COST_AMOUNT' AS field_name\r\n , case when m.total_cost_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(total_cost_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\data_quality__claim_total_cost_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'TOTAL_COST_AMOUNT' AS field_name\n , case when m.total_cost_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(total_cost_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_admission_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_admission_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admission_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admission_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_admission_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_admission_date"], "alias": "institutional_admission_date", "checksum": {"name": "sha256", "checksum": "8e579340fca7bfb7cf007c70704819110ddce0334e91f20fa52456d97760f43d"}, "config": {"enabled": true, "alias": "institutional_admission_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_admission_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2291262, "relation_name": "dev_thuxuan.data_quality.institutional_admission_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n)\r\n, tuva_last_run as(\r\n\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n\r\n)\r\n,unique_field as (\r\n select distinct claim_id\r\n ,cast(admission_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'ADMISSION_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.admission_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.admission_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.admission_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.admission_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.admission_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n else null\r\n end as invalid_reason\r\n ,cast(substring(agg.field_aggregated, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admission_date.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(admission_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'ADMISSION_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.admission_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(substring(agg.field_aggregated, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_admit_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_admit_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admit_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admit_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_admit_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_admit_source_code"], "alias": "institutional_admit_source_code", "checksum": {"name": "sha256", "checksum": "217d79beb37b7699f397cb0f849502e04bd8bb2d9d85f42d7c79d6b8c6a3866a"}, "config": {"enabled": true, "alias": "institutional_admit_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_admit_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2321262, "relation_name": "dev_thuxuan.data_quality.institutional_admit_source_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"base.admit_source_code\", \"'|'\", \"coalesce(term.admit_source_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__admit_source')}} as term on base.admit_source_code = term.admit_source_code\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'ADMIT_SOURCE_CODE' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.admit_source_code is not null then 'valid'\r\n when m.admit_source_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.admit_source_code is not null\r\n and term.admit_source_code is null\r\n and cg. frequency = 1\r\n then 'Admit source code does not join to Terminology Admit Source table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__admit_source')}} as term on m.admit_source_code = term.admit_source_code\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_source"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admit_source_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_source_code || '|' || coalesce(term.admit_source_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.admit_source as term on base.admit_source_code = term.admit_source_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_source_code is not null\n and term.admit_source_code is null\n and cg. frequency = 1\n then 'Admit source code does not join to Terminology Admit Source table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.admit_source as term on m.admit_source_code = term.admit_source_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_admit_type_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_admit_type_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admit_type_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admit_type_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_admit_type_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_admit_type_code"], "alias": "institutional_admit_type_code", "checksum": {"name": "sha256", "checksum": "3fc6c7d2a7967107d1666f712f743e06dbe7c79b9447250a2f5718ea395123e5"}, "config": {"enabled": true, "alias": "institutional_admit_type_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_admit_type_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.234126, "relation_name": "dev_thuxuan.data_quality.institutional_admit_type_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"base.admit_type_code\", \"'|'\", \"coalesce(term.admit_type_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__admit_type')}} as term on base.admit_type_code = term.admit_type_code\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Member ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'ADMIT_TYPE_CODE' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.admit_type_code is not null then 'valid'\r\n when m.admit_type_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.admit_type_code is not null\r\n and term.admit_type_code is null\r\n and cg.frequency = 1\r\n then 'Admit Type Code does not join to Terminology Admit Type table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__admit_type')}} as term on m.admit_type_code = term.admit_type_code\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_admit_type_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_type_code || '|' || coalesce(term.admit_type_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.admit_type as term on base.admit_type_code = term.admit_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Member ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_type_code is not null\n and term.admit_type_code is null\n and cg.frequency = 1\n then 'Admit Type Code does not join to Terminology Admit Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.admit_type as term on m.admit_type_code = term.admit_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_apr_drg_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_apr_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_apr_drg_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_apr_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_apr_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_apr_drg_code"], "alias": "institutional_apr_drg_code", "checksum": {"name": "sha256", "checksum": "01bfe4686022823b16ab0fc6dd391edcb0b30369a568c149d07c39404cb05413"}, "config": {"enabled": true, "alias": "institutional_apr_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_apr_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2361262, "relation_name": "dev_thuxuan.data_quality.institutional_apr_drg_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"base.apr_drg_code\", \"'|'\", \"coalesce(term.apr_drg_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__apr_drg')}} as term on base.apr_drg_code = term.apr_drg_code\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'APR_DRG_CODE' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.apr_drg_code is not null then 'valid'\r\n when m.apr_drg_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.apr_drg_code is not null\r\n and term.apr_drg_code is null\r\n then 'APR DRG Code does not join to Terminology APR DRG table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__apr_drg')}} as term on m.apr_drg_code = term.apr_drg_code\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_apr_drg_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.apr_drg_code || '|' || coalesce(term.apr_drg_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.apr_drg as term on base.apr_drg_code = term.apr_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'APR_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.apr_drg_code is not null\n and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology APR DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.apr_drg as term on m.apr_drg_code = term.apr_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_billing_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_billing_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_billing_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_billing_npi.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_billing_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_billing_npi"], "alias": "institutional_billing_npi", "checksum": {"name": "sha256", "checksum": "396e77a81c8c54184c4f940bb4c2916af9f42691f51ff1fc02546725dd65c5d1"}, "config": {"enabled": true, "alias": "institutional_billing_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_billing_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2401261, "relation_name": "dev_thuxuan.data_quality.institutional_billing_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\nunique_field as (\r\n select distinct claim_id\r\n ,cast(billing_npi as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'BILLING_NPI' AS field_name\r\n ,case when cg.frequency > 1 then 'multiple'\r\n when term.npi is not null then 'valid'\r\n when m.billing_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n ,case\r\n when cg.frequency = 1\r\n and m.billing_npi is not null\r\n and term.npi is null\r\n then 'NPI is not in Terminology Provider table'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__provider')}} as term on m.billing_npi = term.npi\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_billing_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(billing_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'BILLING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.billing_npi is not null\n and term.npi is null\n then 'NPI is not in Terminology Provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.provider as term on m.billing_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_bill_type_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_bill_type_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_bill_type_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_bill_type_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_bill_type_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_bill_type_code"], "alias": "institutional_bill_type_code", "checksum": {"name": "sha256", "checksum": "19dfa290cb783a26275fbddf702b32e4c8783073b4056a34672173c96f9cfca2"}, "config": {"enabled": true, "alias": "institutional_bill_type_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_bill_type_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.238126, "relation_name": "dev_thuxuan.data_quality.institutional_bill_type_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', false)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"base.bill_type_code\", \"'|'\", \"coalesce(term.bill_type_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__bill_type')}} as term on base.bill_type_code = term.bill_type_code\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'BILL_TYPE_CODE' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.bill_type_code is not null then 'valid'\r\n when m.bill_type_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.bill_type_code is not null\r\n and term.bill_type_code is null\r\n and cg.frequency = 1\r\n then 'Bill Type Code does not join to Terminology Bill_Type table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__bill_type')}} as term on m.bill_type_code = term.bill_type_code\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__bill_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_bill_type_code.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.bill_type_code || '|' || coalesce(term.bill_type_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.bill_type as term on base.bill_type_code = term.bill_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'BILL_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.bill_type_code is not null then 'valid'\n when m.bill_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.bill_type_code is not null\n and term.bill_type_code is null\n and cg.frequency = 1\n then 'Bill Type Code does not join to Terminology Bill_Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.bill_type as term on m.bill_type_code = term.bill_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_claim_end_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_claim_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_claim_end_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_claim_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_claim_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_claim_end_date"], "alias": "institutional_claim_end_date", "checksum": {"name": "sha256", "checksum": "a40eca52608ac91d8091afc3db103d3caa59c6ebf3080ba097ff7d351de0d8a3"}, "config": {"enabled": true, "alias": "institutional_claim_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_claim_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.242126, "relation_name": "dev_thuxuan.data_quality.institutional_claim_end_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n)\r\n, tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n,unique_field as (\r\n select distinct claim_id\r\n ,cast(claim_end_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'CLAIM_END_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.claim_end_date < m.claim_start_date then 'invalid'\r\n when m.claim_end_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when m.claim_end_date < m.claim_start_date then 'claim end date before claim start date'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_claim_end_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before claim start date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_claim_start_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_claim_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_claim_start_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_claim_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_claim_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_claim_start_date"], "alias": "institutional_claim_start_date", "checksum": {"name": "sha256", "checksum": "f9c330d35a1c7067fdb9349e33ff0732709798a25be11011b528ded26e9df8c1"}, "config": {"enabled": true, "alias": "institutional_claim_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_claim_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2451262, "relation_name": "dev_thuxuan.data_quality.institutional_claim_start_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n)\r\n, tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n,unique_field as (\r\n select distinct claim_id\r\n ,cast(claim_start_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'CLAIM_START_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.claim_start_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_claim_start_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_diagnosis_code_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_1.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_diagnosis_code_1"], "alias": "institutional_diagnosis_code_1", "checksum": {"name": "sha256", "checksum": "79e2c9409cdb27c89d69217ebf6e826d1335b74bb5c61b76ec1b13a7712b4962"}, "config": {"enabled": true, "alias": "institutional_diagnosis_code_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_diagnosis_code_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2478662, "relation_name": "dev_thuxuan.data_quality.institutional_diagnosis_code_1", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"diagnosis_code_1\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__icd_10_cm')}} as term on base.diagnosis_code_1 = term.icd_10_cm\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'DIAGNOSIS_CODE_1' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.icd_10_cm is not null then 'valid'\r\n when m.diagnosis_code_1 is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.diagnosis_code_1 is not null\r\n and term.icd_10_cm is null\r\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_1 = term.icd_10_cm\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_1.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_cm as term on base.diagnosis_code_1 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_diagnosis_code_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_2.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_diagnosis_code_2"], "alias": "institutional_diagnosis_code_2", "checksum": {"name": "sha256", "checksum": "62c920619324261c415749b05a9ae3a4dd5ead126bcb47bb3c69294fe7348da8"}, "config": {"enabled": true, "alias": "institutional_diagnosis_code_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_diagnosis_code_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.250489, "relation_name": "dev_thuxuan.data_quality.institutional_diagnosis_code_2", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"diagnosis_code_2\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__icd_10_cm')}} as term on base.diagnosis_code_2 = term.icd_10_cm\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'DIAGNOSIS_CODE_2' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.icd_10_cm is not null then 'valid'\r\n when m.diagnosis_code_2 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.diagnosis_code_2 is not null\r\n and term.icd_10_cm is null\r\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_2 = term.icd_10_cm\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_2.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_cm as term on base.diagnosis_code_2 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_diagnosis_code_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_3.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_diagnosis_code_3"], "alias": "institutional_diagnosis_code_3", "checksum": {"name": "sha256", "checksum": "8bfe5b00e0600e074f4678a4dee699ed27152e55889b92f9ce044c5f53f9c554"}, "config": {"enabled": true, "alias": "institutional_diagnosis_code_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_diagnosis_code_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2525747, "relation_name": "dev_thuxuan.data_quality.institutional_diagnosis_code_3", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"diagnosis_code_3\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__icd_10_cm')}} as term on base.diagnosis_code_3 = term.icd_10_cm\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'DIAGNOSIS_CODE_3' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.icd_10_cm is not null then 'valid'\r\n when m.diagnosis_code_3 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.diagnosis_code_3 is not null\r\n and term.icd_10_cm is null\r\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_3 = term.icd_10_cm\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_diagnosis_code_3.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_cm as term on base.diagnosis_code_3 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_discharge_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_discharge_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_discharge_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_discharge_date.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_discharge_date"], "alias": "institutional_discharge_date", "checksum": {"name": "sha256", "checksum": "a8e6459ba26dd6660a20bc849b68c43827b1f09a36f5017b1c5d95420b737684"}, "config": {"enabled": true, "alias": "institutional_discharge_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_discharge_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.254645, "relation_name": "dev_thuxuan.data_quality.institutional_discharge_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n)\r\n, tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n,unique_field as (\r\n select distinct claim_id\r\n ,cast(discharge_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'DISCHARGE_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.discharge_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.discharge_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.discharge_date < m.admission_date then 'invalid'\r\n when m.discharge_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.discharge_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.discharge_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when m.discharge_date < m.admission_date then 'discharge date before admission date'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_discharge_date.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(discharge_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DISCHARGE_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.discharge_date < m.admission_date then 'invalid'\n when m.discharge_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.discharge_date < m.admission_date then 'discharge date before admission date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_discharge_disposition_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_discharge_disposition_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_discharge_disposition_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_discharge_disposition_code"], "alias": "institutional_discharge_disposition_code", "checksum": {"name": "sha256", "checksum": "305dab8efc95928c3fdab2c8934e7dc3edd9a018aef7a5d8bad87fc8d33e6740"}, "config": {"enabled": true, "alias": "institutional_discharge_disposition_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_discharge_disposition_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2567208, "relation_name": "dev_thuxuan.data_quality.institutional_discharge_disposition_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"base.discharge_disposition_code\", \"'|'\", \"coalesce(term.discharge_disposition_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__discharge_disposition')}} as term on base.discharge_disposition_code = term.discharge_disposition_code\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.discharge_disposition_code is not null then 'valid'\r\n when m.discharge_disposition_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.discharge_disposition_code is not null\r\n and term.discharge_disposition_code is null\r\n then 'Discharge Disposition Code does not join to Terminology Discharge_Disposition Table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__discharge_disposition')}} as term on m.discharge_disposition_code = term.discharge_disposition_code\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_discharge_disposition_code.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.discharge_disposition_code || '|' || coalesce(term.discharge_disposition_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.discharge_disposition as term on base.discharge_disposition_code = term.discharge_disposition_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.discharge_disposition_code is not null\n and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology Discharge_Disposition Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.discharge_disposition as term on m.discharge_disposition_code = term.discharge_disposition_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_facility_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_facility_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_facility_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_facility_npi.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_facility_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_facility_npi"], "alias": "institutional_facility_npi", "checksum": {"name": "sha256", "checksum": "f753cc0a221e5ffd597531314f54c24c479cfebe4bcb23f24fff32722f23b1ac"}, "config": {"enabled": true, "alias": "institutional_facility_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_facility_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2587955, "relation_name": "dev_thuxuan.data_quality.institutional_facility_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\nunique_field as (\r\n select distinct claim_id\r\n ,cast(facility_npi as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'FACILITY_NPI' AS field_name\r\n ,case when cg.frequency > 1 then 'multiple'\r\n when term.npi is not null then 'valid'\r\n when m.facility_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n ,case\r\n when cg.frequency = 1\r\n and m.facility_npi is not null\r\n and term.npi is null\r\n then 'NPI not in Terminology Provider Table'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__provider')}} as term on m.facility_npi = term.npi\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_facility_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'FACILITY_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.facility_npi is not null\n and term.npi is null\n then 'NPI not in Terminology Provider Table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.provider as term on m.facility_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_ms_drg_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_ms_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_ms_drg_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_ms_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_ms_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_ms_drg_code"], "alias": "institutional_ms_drg_code", "checksum": {"name": "sha256", "checksum": "52f6732fa28d34734e541ee01d28b028edb67f51750c2e5127a251ede39e4835"}, "config": {"enabled": true, "alias": "institutional_ms_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_ms_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2271264, "relation_name": "dev_thuxuan.data_quality.institutional_ms_drg_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"base.ms_drg_code\", \"'|'\", \"coalesce(term.ms_drg_description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__ms_drg')}} as term on base.ms_drg_code = term.ms_drg_code\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\r\n)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'MS_DRG_CODE' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.ms_drg_code is not null then 'valid'\r\n when m.ms_drg_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.ms_drg_code is not null\r\n and term.ms_drg_code is null\r\n then 'MS DRG does not join to Terminology MS DRG table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__ms_drg')}} as term on m.ms_drg_code = term.ms_drg_code\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_ms_drg_code.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.ms_drg_code || '|' || coalesce(term.ms_drg_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.ms_drg as term on base.ms_drg_code = term.ms_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'MS_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.ms_drg_code is not null\n and term.ms_drg_code is null\n then 'MS DRG does not join to Terminology MS DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.ms_drg as term on m.ms_drg_code = term.ms_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_present_on_admission_1": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_present_on_admission_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_1.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_present_on_admission_1"], "alias": "institutional_present_on_admission_1", "checksum": {"name": "sha256", "checksum": "450aa4e24eb1ae3a9fd99a07af4fdb4659863dd4fdfdf3d64d31df51009ab0b3"}, "config": {"enabled": true, "alias": "institutional_present_on_admission_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_present_on_admission_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2613282, "relation_name": "dev_thuxuan.data_quality.institutional_present_on_admission_1", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n\r\n),\r\nunique_field as (\r\n select distinct claim_id\r\n ,cast(diagnosis_poa_1 as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'DIAGNOSIS_POA_1' AS field_name\r\n ,case when cg.frequency > 1 then 'multiple'\r\n when m.diagnosis_poa_1 in ('y','n') then 'valid'\r\n when m.diagnosis_poa_1 is null then 'null'\r\n else 'invalid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_1.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_1' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_1 in ('y','n') then 'valid'\n when m.diagnosis_poa_1 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_present_on_admission_2": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_present_on_admission_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_2.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_present_on_admission_2"], "alias": "institutional_present_on_admission_2", "checksum": {"name": "sha256", "checksum": "9df77c0d9b5e9aa4c7bb04ad5737c61a262cca766dc457c352989e4bdce70fdf"}, "config": {"enabled": true, "alias": "institutional_present_on_admission_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_present_on_admission_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.263328, "relation_name": "dev_thuxuan.data_quality.institutional_present_on_admission_2", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\nunique_field as (\r\n select distinct claim_id\r\n ,cast(diagnosis_poa_2 as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'DIAGNOSIS_POA_2' AS field_name\r\n ,case when cg.frequency > 1 then 'multiple'\r\n when m.diagnosis_poa_2 in ('y','n') then 'valid'\r\n when m.diagnosis_poa_2 is null then 'null'\r\n else 'invalid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_2.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_2' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_2 in ('y','n') then 'valid'\n when m.diagnosis_poa_2 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_present_on_admission_3": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_present_on_admission_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_3.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_present_on_admission_3"], "alias": "institutional_present_on_admission_3", "checksum": {"name": "sha256", "checksum": "af0fb6d723909866688f88873e6915944a0a8f60f65af7dc1a7c6ea4a3c8577f"}, "config": {"enabled": true, "alias": "institutional_present_on_admission_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_present_on_admission_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.265328, "relation_name": "dev_thuxuan.data_quality.institutional_present_on_admission_3", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\nunique_field as (\r\n select distinct claim_id\r\n ,cast(diagnosis_poa_3 as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'DIAGNOSIS_POA_3' AS field_name\r\n ,case when cg.frequency > 1 then 'multiple'\r\n when m.diagnosis_poa_3 in ('y','n') then 'valid'\r\n when m.diagnosis_poa_3 is null then 'null'\r\n else 'invalid' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_present_on_admission_3.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_3' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_3 in ('y','n') then 'valid'\n when m.diagnosis_poa_3 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_code_1": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_procedure_code_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_1.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_code_1"], "alias": "institutional_procedure_code_1", "checksum": {"name": "sha256", "checksum": "342f6705c7de03ac6ab7a5a67097dfe9288e192c7106b5e092f617f261c767fd"}, "config": {"enabled": true, "alias": "institutional_procedure_code_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_code_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.267328, "relation_name": "dev_thuxuan.data_quality.institutional_procedure_code_1", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"procedure_code_1\", \"'|'\", \"coalesce(term.description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__icd_10_pcs')}} as term on base.procedure_code_1 = term.icd_10_pcs\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'PROCEDURE_CODE_1' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.icd_10_pcs is not null then 'valid'\r\n when m.procedure_code_1 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.procedure_code_1 is not null\r\n and term.icd_10_pcs is null\r\n then 'procedure code does not join to terminology procedure code table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__icd_10_pcs')}} as term on m.procedure_code_1 = term.icd_10_pcs\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_1.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_1 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_1 is not null\n and term.icd_10_pcs is null\n then 'procedure code does not join to terminology procedure code table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_pcs as term on m.procedure_code_1 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_code_2": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_procedure_code_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_2.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_code_2"], "alias": "institutional_procedure_code_2", "checksum": {"name": "sha256", "checksum": "1198f2609e6063bd73802e2989b45bbf87afa767334d5bed8097965f60282aa2"}, "config": {"enabled": true, "alias": "institutional_procedure_code_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_code_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.269328, "relation_name": "dev_thuxuan.data_quality.institutional_procedure_code_2", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"procedure_code_2\", \"'|'\", \"coalesce(term.description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__icd_10_pcs')}} as term on base.procedure_code_1 = term.icd_10_pcs\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n\t)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'PROCEDURE_CODE_2' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.icd_10_pcs is not null then 'valid'\r\n when m.procedure_code_2 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.procedure_code_2 is not null\r\n and term.icd_10_pcs is null\r\n then 'Procedure Code does not join to Terminology Procedure Code Table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__icd_10_pcs')}} as term on m.procedure_code_2 = term.icd_10_pcs\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_2.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_2 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_2 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_pcs as term on m.procedure_code_2 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_code_3": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_procedure_code_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_3.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_code_3"], "alias": "institutional_procedure_code_3", "checksum": {"name": "sha256", "checksum": "4ece3a6823aa29644bd51ca418a6f8e0c751de71cb6ac7c78f2d42d8c8c4c33d"}, "config": {"enabled": true, "alias": "institutional_procedure_code_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_code_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2723281, "relation_name": "dev_thuxuan.data_quality.institutional_procedure_code_3", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n),\r\n\r\nunique_field as (\r\n select distinct claim_id\r\n , {{ dbt.concat([\"procedure_code_3\", \"'|'\", \"coalesce(term.description, '')\"]) }} as field\r\n , data_source\r\n from base\r\n left join {{ ref('terminology__icd_10_pcs')}} as term on base.procedure_code_3 = term.icd_10_pcs\r\n),\r\n\r\nclaim_grain as (\r\n select claim_id\r\n , data_source\r\n , count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n , data_source\r\n),\r\n\r\nclaim_agg as (\r\nselect\r\n claim_id\r\n , data_source\r\n , {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id\r\n , data_source\r\n)\r\n\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID' AS drill_down_key\r\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'PROCEDURE_CODE_3' AS field_name\r\n , case when cg.frequency > 1 then 'multiple'\r\n when term.icd_10_pcs is not null then 'valid'\r\n when m.procedure_code_3 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when cg.frequency = 1\r\n and m.procedure_code_3 is not null\r\n and term.icd_10_pcs is null\r\n then 'Procedure Code does not join to Terminology Procedure Code Table'\r\n else null\r\n end as invalid_reason\r\n , cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__icd_10_pcs')}} as term on m.procedure_code_3 = term.icd_10_pcs\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.listagg", "macro.dbt.type_string", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_code_3.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_3 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_pcs as term on base.procedure_code_3 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_3 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_pcs as term on m.procedure_code_3 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_date_1": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_procedure_date_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_1.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_1.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_date_1"], "alias": "institutional_procedure_date_1", "checksum": {"name": "sha256", "checksum": "e4b717a3b302bdc762e81b801771eb1bfeb9333b90e8709fa439039a2dbb989a"}, "config": {"enabled": true, "alias": "institutional_procedure_date_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_date_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2743282, "relation_name": "dev_thuxuan.data_quality.institutional_procedure_date_1", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n)\r\n, tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n, unique_field as (\r\n select distinct claim_id\r\n ,cast(procedure_date_1 as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'PROCEDURE_DATE_1' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.procedure_date_1 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.procedure_date_1 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'invalid'\r\n when m.procedure_date_1 is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.procedure_date_1 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.procedure_date_1 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_1.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(procedure_date_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_1' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_1 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_date_2": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_procedure_date_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_2.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_2.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_date_2"], "alias": "institutional_procedure_date_2", "checksum": {"name": "sha256", "checksum": "61df6e2cd7cf705e99f3523fca6b03e191c21e739b60af1480baea3b05b61052"}, "config": {"enabled": true, "alias": "institutional_procedure_date_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_date_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.276328, "relation_name": "dev_thuxuan.data_quality.institutional_procedure_date_2", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n)\r\n, tuva_last_run as(\r\n\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n\r\n)\r\n,unique_field as (\r\n select distinct claim_id\r\n ,cast(procedure_date_2 as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'PROCEDURE_DATE_2' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.procedure_date_2 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.procedure_date_2 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'invalid'\r\n when m.procedure_date_2 is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.procedure_date_2 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.procedure_date_2 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\r\n when m.procedure_date_2 is null then null\r\n else 'valid'\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_2.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_2' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_2 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n when m.procedure_date_2 is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_procedure_date_3": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_procedure_date_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_3.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_3.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_procedure_date_3"], "alias": "institutional_procedure_date_3", "checksum": {"name": "sha256", "checksum": "cc7cb4fc99742c5adf19babaad8cf1a4df3508fab9b2036d08ef01f4e1213f3d"}, "config": {"enabled": true, "alias": "institutional_procedure_date_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_procedure_date_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2793455, "relation_name": "dev_thuxuan.data_quality.institutional_procedure_date_3", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\nselect *\r\nfrom {{ ref('data_quality__stg_institutional_inpatient') }}\r\n)\r\n, tuva_last_run as(\r\n\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n\r\n)\r\n\r\n,unique_field as (\r\n select distinct claim_id\r\n ,cast(procedure_date_3 as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'PROCEDURE_DATE_3' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.procedure_date_3 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.procedure_date_3 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'invalid'\r\n when m.procedure_date_3 is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.procedure_date_3 > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.procedure_date_3 < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "data_quality__stg_institutional_inpatient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_procedure_date_3.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_3' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_3 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "sql": " __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_rendering_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_rendering_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_rendering_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_rendering_npi.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_rendering_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_rendering_npi"], "alias": "institutional_rendering_npi", "checksum": {"name": "sha256", "checksum": "fcf47dd7fe93b7f1a865407b972aaf1103dca0325e5107c50a821d99f41b3a63"}, "config": {"enabled": true, "alias": "institutional_rendering_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_rendering_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.282324, "relation_name": "dev_thuxuan.data_quality.institutional_rendering_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n),\r\nunique_field as (\r\n select distinct claim_id\r\n ,cast(facility_npi as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect distinct -- to bring to claim_id grain\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\r\n ,'institutional' AS claim_type\r\n ,'RENDERING_NPI' AS field_name\r\n ,case when cg.frequency > 1 then 'multiple'\r\n when term.npi is not null then 'valid'\r\n when m.rendering_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n ,case\r\n when cg.frequency = 1\r\n and m.rendering_npi is not null\r\n and term.npi is null\r\n then 'provider npi does not join to terminology provider table'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join {{ ref('terminology__provider')}} as term on m.rendering_npi = term.npi\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_rendering_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'RENDERING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.rendering_npi is not null\n and term.npi is null\n then 'provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.provider as term on m.rendering_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_revenue_center_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_revenue_center_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_revenue_center_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_revenue_center_code.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_revenue_center_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_revenue_center_code"], "alias": "institutional_revenue_center_code", "checksum": {"name": "sha256", "checksum": "60fc60c94f569c2e35a86ef70b1c4c6a5e994e830567bc9916ea5e2971596d27"}, "config": {"enabled": true, "alias": "institutional_revenue_center_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_revenue_center_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2853417, "relation_name": "dev_thuxuan.data_quality.institutional_revenue_center_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'institutional' AS claim_type\r\n , 'REVENUE_CENTER_CODE' AS field_name\r\n , case\r\n when term.revenue_center_code is not null then 'valid'\r\n when m.revenue_center_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.revenue_center_code is not null\r\n and term.revenue_center_code is null\r\n then 'Revenue center code does not join to Terminology Revenue Center table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.revenue_center_code\", \"'|'\", \"coalesce(term.revenue_center_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('medical_claim')}} m\r\nleft join {{ ref('terminology__revenue_center')}} as term on m.revenue_center_code = term.revenue_center_code", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__revenue_center"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_revenue_center_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'institutional' AS claim_type\n , 'REVENUE_CENTER_CODE' AS field_name\n , case\n when term.revenue_center_code is not null then 'valid'\n when m.revenue_center_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.revenue_center_code is not null\n and term.revenue_center_code is null\n then 'Revenue center code does not join to Terminology Revenue Center table'\n else null\n end as invalid_reason\n , m.revenue_center_code || '|' || coalesce(term.revenue_center_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join dev_thuxuan.terminology.revenue_center as term on m.revenue_center_code = term.revenue_center_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__institutional_service_unit_quantity": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__institutional_service_unit_quantity", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_service_unit_quantity.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_service_unit_quantity.sql", "unique_id": "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "institutional", "data_quality__institutional_service_unit_quantity"], "alias": "institutional_service_unit_quantity", "checksum": {"name": "sha256", "checksum": "a7bfb362207c4e4e64978de1d37b2439eaf0a163563bb3b6b7c4d673c945a33f"}, "config": {"enabled": true, "alias": "institutional_service_unit_quantity", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "institutional_service_unit_quantity", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2873414, "relation_name": "dev_thuxuan.data_quality.institutional_service_unit_quantity", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , m.claim_type as claim_type\r\n , 'service_unit_quantity' as field_name\r\n , case when m.service_unit_quantity is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(service_unit_quantity as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}} m", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\institutional\\data_quality__institutional_service_unit_quantity.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'service_unit_quantity' as field_name\n , case when m.service_unit_quantity is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(service_unit_quantity as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_billing_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_billing_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_billing_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_billing_npi.sql", "unique_id": "model.the_tuva_project.data_quality__professional_billing_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_billing_npi"], "alias": "professional_billing_npi", "checksum": {"name": "sha256", "checksum": "cee8e9094c96425e0d1d4bfe323cdecedec47ddee6f05f761ab1cab6fe1f5215"}, "config": {"enabled": true, "alias": "professional_billing_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_billing_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.289341, "relation_name": "dev_thuxuan.data_quality.professional_billing_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'BILLING_NPI' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.billing_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.billing_npi is not null\r\n and term.npi is null\r\n then 'Billing NPI does not join to Terminology Provider Table'\r\n else null\r\n end as invalid_reason\r\n , cast(m.billing_npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__provider')}} as term on m.billing_npi = term.npi", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_billing_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'BILLING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.billing_npi is not null\n and term.npi is null\n then 'Billing NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.billing_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.provider as term on m.billing_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_claim_end_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_claim_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_claim_end_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_claim_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__professional_claim_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_claim_end_date"], "alias": "professional_claim_end_date", "checksum": {"name": "sha256", "checksum": "119c9f622014af44aaafaba6cbf6ecae6089b8a42c9022e881e81d3f87a7708c"}, "config": {"enabled": true, "alias": "professional_claim_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_claim_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2973526, "relation_name": "dev_thuxuan.data_quality.professional_claim_end_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'institutional'\r\n)\r\n, tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n ,unique_field as (\r\n select distinct claim_id\r\n ,cast(claim_end_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\r\n ,'professional' AS claim_type\r\n ,'CLAIM_END_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.claim_end_date < m.claim_start_date then 'invalid'\r\n when m.claim_end_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.claim_end_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n when m.claim_end_date < m.claim_start_date then 'claim end date before start date'\r\n when m.claim_end_date is null then null\r\n else 'valid'\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_claim_end_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n ,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before start date'\n when m.claim_end_date is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_claim_start_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_claim_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_claim_start_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_claim_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__professional_claim_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_claim_start_date"], "alias": "professional_claim_start_date", "checksum": {"name": "sha256", "checksum": "baf9f4bd10bf739190e965abb686a36128203bfb7191bc7f33bb410cbcdd4085"}, "config": {"enabled": true, "alias": "professional_claim_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_claim_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3003528, "relation_name": "dev_thuxuan.data_quality.professional_claim_start_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n, tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n, unique_field as (\r\n select distinct claim_id\r\n ,cast(claim_start_date as {{ dbt.type_string() }}) as field\r\n ,data_source\r\n from base\r\n),\r\nclaim_grain as (\r\n select claim_id\r\n ,data_source\r\n ,count(*) as frequency\r\n from unique_field\r\n group by claim_id\r\n ,data_source\r\n),\r\nclaim_agg as (\r\nselect\r\n claim_id,\r\n data_source,\r\n {{ dbt.listagg(measure=\"coalesce(field, 'null')\", delimiter_text=\"', '\", order_by_clause=\"order by field desc\") }} as field_aggregated\r\nfrom\r\n unique_field\r\ngroup by\r\n claim_id,\r\n data_source\r\n\t)\r\nselect\r\n m.data_source\r\n ,coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n ,'MEDICAL_CLAIM' AS table_name\r\n ,'Claim ID' AS drill_down_key\r\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\r\n ,'professional' AS claim_type\r\n ,'CLAIM_START_DATE' AS field_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.claim_start_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when cg.frequency > 1 then 'multiple'\r\n when m.claim_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.claim_start_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n else null\r\n end as invalid_reason\r\n ,cast({{ substring('agg.field_aggregated', 1, 255) }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\r\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.listagg", "macro.dbt.dateadd", "macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_claim_start_date.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_diagnosis_code_1": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_diagnosis_code_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_1.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_1.sql", "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_diagnosis_code_1"], "alias": "professional_diagnosis_code_1", "checksum": {"name": "sha256", "checksum": "47b7406ad3eeb80eeafceeb7dc356cff223b4cfd8263b1fe77043d6eb34a2777"}, "config": {"enabled": true, "alias": "professional_diagnosis_code_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_diagnosis_code_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.302353, "relation_name": "dev_thuxuan.data_quality.professional_diagnosis_code_1", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'DIAGNOSIS_CODE_1' AS field_name\r\n , case when term.icd_10_cm is not null then 'valid'\r\n when m.diagnosis_code_1 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.diagnosis_code_1 is not null\r\n and term.icd_10_cm is null\r\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.diagnosis_code_1\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_1 = term.icd_10_cm", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_1.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_diagnosis_code_2": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_diagnosis_code_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_2.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_2.sql", "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_diagnosis_code_2"], "alias": "professional_diagnosis_code_2", "checksum": {"name": "sha256", "checksum": "fe5cce9d631e41f46ae83a409204c25f7774a018125e768060523b0d7aede5ea"}, "config": {"enabled": true, "alias": "professional_diagnosis_code_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_diagnosis_code_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.304353, "relation_name": "dev_thuxuan.data_quality.professional_diagnosis_code_2", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'DIAGNOSIS_CODE_2' AS field_name\r\n , case when term.icd_10_cm is not null then 'valid'\r\n when m.diagnosis_code_2 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.diagnosis_code_2 is not null\r\n and term.icd_10_cm is null\r\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.diagnosis_code_2\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_2 = term.icd_10_cm", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_2.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_diagnosis_code_3": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_diagnosis_code_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_3.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_3.sql", "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_diagnosis_code_3"], "alias": "professional_diagnosis_code_3", "checksum": {"name": "sha256", "checksum": "91c2325d1c61c48aafa95cfc05208dac91471ec55f70c59a1c2887e03650181e"}, "config": {"enabled": true, "alias": "professional_diagnosis_code_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_diagnosis_code_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3058581, "relation_name": "dev_thuxuan.data_quality.professional_diagnosis_code_3", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'DIAGNOSIS_CODE_3' AS field_name\r\n , case when term.icd_10_cm is not null then 'valid'\r\n when m.diagnosis_code_3 is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.diagnosis_code_3 is not null\r\n and term.icd_10_cm is null\r\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.diagnosis_code_3\", \"'|'\", \"coalesce(term.short_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__icd_10_cm')}} as term on m.diagnosis_code_3 = term.icd_10_cm", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_diagnosis_code_3.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_facility_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_facility_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_facility_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_facility_npi.sql", "unique_id": "model.the_tuva_project.data_quality__professional_facility_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_facility_npi"], "alias": "professional_facility_npi", "checksum": {"name": "sha256", "checksum": "95cfbcce5651d527d8508d1680da1b372a97773e91321296e306f0218692601b"}, "config": {"enabled": true, "alias": "professional_facility_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_facility_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2933714, "relation_name": "dev_thuxuan.data_quality.professional_facility_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'FACILITY_NPI' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.facility_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.facility_npi is not null\r\n and term.npi is null\r\n then 'Facility NPI does not join to Terminology Provider Table'\r\n else null\r\n end as invalid_reason\r\n , cast(m.facility_npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__provider')}} as term on m.facility_npi = term.npi", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_facility_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'FACILITY_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.facility_npi is not null\n and term.npi is null\n then 'Facility NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.facility_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.provider as term on m.facility_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_place_of_service_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_place_of_service_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_place_of_service_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_place_of_service_code.sql", "unique_id": "model.the_tuva_project.data_quality__professional_place_of_service_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_place_of_service_code"], "alias": "professional_place_of_service_code", "checksum": {"name": "sha256", "checksum": "f151f094172e07707dc74bf9177dc6d9bf6ae694eb775acae590d09fa70df0ce"}, "config": {"enabled": true, "alias": "professional_place_of_service_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_place_of_service_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.295353, "relation_name": "dev_thuxuan.data_quality.professional_place_of_service_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'PLACE_OF_SERVICE_CODE' AS field_name\r\n , case when term.place_of_service_code is not null then 'valid'\r\n when m.place_of_service_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.place_of_service_code is not null\r\n and term.place_of_service_code is null\r\n then 'Place of Service Code does not join to Terminology Place of Service table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.place_of_service_code\", \"'|'\", \"coalesce(term.place_of_service_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__place_of_service')}} as term on m.place_of_service_code = term.place_of_service_code", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__place_of_service"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_place_of_service_code.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'PLACE_OF_SERVICE_CODE' AS field_name\n , case when term.place_of_service_code is not null then 'valid'\n when m.place_of_service_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.place_of_service_code is not null\n and term.place_of_service_code is null\n then 'Place of Service Code does not join to Terminology Place of Service table'\n else null\n end as invalid_reason\n , m.place_of_service_code || '|' || coalesce(term.place_of_service_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.place_of_service as term on m.place_of_service_code = term.place_of_service_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__professional_rendering_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__professional_rendering_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_rendering_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_rendering_npi.sql", "unique_id": "model.the_tuva_project.data_quality__professional_rendering_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "medical", "professional", "data_quality__professional_rendering_npi"], "alias": "professional_rendering_npi", "checksum": {"name": "sha256", "checksum": "7002cc51e470614fa629e643f298e4257e6596b70c7ff6194b00f8c97b90b06c"}, "config": {"enabled": true, "alias": "professional_rendering_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "professional_rendering_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.2913694, "relation_name": "dev_thuxuan.data_quality.professional_rendering_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nwith base as (\r\n select *\r\n from {{ ref('medical_claim')}}\r\n where claim_type = 'professional'\r\n)\r\n\r\nselect\r\n m.data_source\r\n , coalesce(cast(m.claim_start_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'MEDICAL_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'professional' AS claim_type\r\n , 'RENDERING_NPI' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.rendering_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.rendering_npi is not null\r\n and term.npi is null\r\n then 'Rendering Provider NPI does not join to Terminology Provider table'\r\n else null\r\n end as invalid_reason\r\n , cast(m.rendering_npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom base m\r\nleft join {{ ref('terminology__provider')}} as term on m.rendering_npi = term.npi", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\medical\\professional\\data_quality__professional_rendering_npi.sql", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'RENDERING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.rendering_npi is not null\n and term.npi is null\n then 'Rendering Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.rendering_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.provider as term on m.rendering_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_allowed_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_allowed_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_allowed_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_allowed_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_allowed_amount"], "alias": "pharmacy_allowed_amount", "checksum": {"name": "sha256", "checksum": "8cbcda7e8ed87e34f9c15fd3f82806331182423758a0353f72449e4c8e2c0cfe"}, "config": {"enabled": true, "alias": "pharmacy_allowed_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_allowed_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3078635, "relation_name": "dev_thuxuan.data_quality.pharmacy_allowed_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'ALLOWED_AMOUNT' AS field_name\r\n , case when m.allowed_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(allowed_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_allowed_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_claim_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_claim_id"], "alias": "pharmacy_claim_id", "checksum": {"name": "sha256", "checksum": "ef16cd194a45238628d8ac2cb1866b3338d7dabcc542b917fd40e347bc180970"}, "config": {"enabled": true, "alias": "pharmacy_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3108659, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'CLAIM_ID' AS field_name\r\n , case\r\n when m.claim_id is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_claim_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_ID' AS field_name\n , case\n when m.claim_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_line_number": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_line_number", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_claim_line_number.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_claim_line_number.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_claim_line_number"], "alias": "pharmacy_claim_line_number", "checksum": {"name": "sha256", "checksum": "05e3dfd8e21d36c6679c8ab989f0209054143fe1a7bba1cc6f510d66e6bbec09"}, "config": {"enabled": true, "alias": "pharmacy_claim_line_number", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_line_number", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.312867, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_line_number", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'CLAIM_LINE_NUMBER' AS field_name\r\n , case\r\n when m.claim_line_number is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_claim_line_number.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_LINE_NUMBER' AS field_name\n , case\n when m.claim_line_number is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_coinsurance_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_coinsurance_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_coinsurance_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_coinsurance_amount"], "alias": "pharmacy_coinsurance_amount", "checksum": {"name": "sha256", "checksum": "b81deca5950436ce7606e05ff1d3a3795626e8e6ba61db13b8378400554ec329"}, "config": {"enabled": true, "alias": "pharmacy_coinsurance_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_coinsurance_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3148668, "relation_name": "dev_thuxuan.data_quality.pharmacy_coinsurance_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'COINSURANCE_AMOUNT' AS field_name\r\n , case when m.coinsurance_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(coinsurance_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_coinsurance_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_copayment_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_copayment_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_copayment_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_copayment_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_copayment_amount"], "alias": "pharmacy_copayment_amount", "checksum": {"name": "sha256", "checksum": "8c63dba02d2d4291172fab11b70121146db46c3ae4cd7e96bee88baea1d03d34"}, "config": {"enabled": true, "alias": "pharmacy_copayment_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_copayment_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3168666, "relation_name": "dev_thuxuan.data_quality.pharmacy_copayment_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'COPAYMENT_AMOUNT' AS field_name\r\n , case when m.copayment_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(copayment_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_copayment_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_data_source"], "alias": "pharmacy_data_source", "checksum": {"name": "sha256", "checksum": "a4e4d9fd26e5ba6dccf3e4096af5a7cea1a43f7e7be16fc10d7af3835229557d"}, "config": {"enabled": true, "alias": "pharmacy_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3188667, "relation_name": "dev_thuxuan.data_quality.pharmacy_data_source", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'DATA_SOURCE' AS field_name\r\n , case\r\n when m.data_source is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DATA_SOURCE' AS field_name\n , case\n when m.data_source is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_days_supply": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_days_supply", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_days_supply.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_days_supply.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_days_supply", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_days_supply"], "alias": "pharmacy_days_supply", "checksum": {"name": "sha256", "checksum": "1e362c89c2d446cf13d7d16c7ed4a4544d8a95953e41479e43af8c077901ee0f"}, "config": {"enabled": true, "alias": "pharmacy_days_supply", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_days_supply", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3208666, "relation_name": "dev_thuxuan.data_quality.pharmacy_days_supply", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'DAYS_SUPPLY' AS field_name\r\n , case\r\n when m.days_supply is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(days_supply as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_days_supply.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DAYS_SUPPLY' AS field_name\n , case\n when m.days_supply is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_deductible_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_deductible_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_deductible_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_deductible_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_deductible_amount"], "alias": "pharmacy_deductible_amount", "checksum": {"name": "sha256", "checksum": "913cf1dc40ea3b058e81b99be9b27536a694465cb0aa6b1c7230b0b1c9129764"}, "config": {"enabled": true, "alias": "pharmacy_deductible_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_deductible_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3228662, "relation_name": "dev_thuxuan.data_quality.pharmacy_deductible_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'DEDUCTIBLE_AMOUNT' AS field_name\r\n , case when m.deductible_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(deductible_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_deductible_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_dispensing_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_dispensing_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_dispensing_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_dispensing_date.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_dispensing_date"], "alias": "pharmacy_dispensing_date", "checksum": {"name": "sha256", "checksum": "cd2465b04d113b1327777c4369f92ef96e7ee2d7c3e3691bec96cca8ba8da0ee"}, "config": {"enabled": true, "alias": "pharmacy_dispensing_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_dispensing_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3258631, "relation_name": "dev_thuxuan.data_quality.pharmacy_dispensing_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\nwith tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'DISPENSING_DATE' AS field_name\r\n , case\r\n when m.dispensing_date > tuva_last_run then 'invalid'\r\n when m.dispensing_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.dispensing_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.dispensing_date > tuva_last_run then 'future'\r\n when m.dispensing_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n else null\r\n end as invalid_reason\r\n , cast(dispensing_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_dispensing_date.sql", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_DATE' AS field_name\n , case\n when m.dispensing_date > tuva_last_run then 'invalid'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > tuva_last_run then 'future'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_dispensing_provider_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_dispensing_provider_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_dispensing_provider_npi.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_dispensing_provider_npi"], "alias": "pharmacy_dispensing_provider_npi", "checksum": {"name": "sha256", "checksum": "56b0c895564dd8a6f4fb8da3391555583ac4401abae6869d3afc1779482e8e89"}, "config": {"enabled": true, "alias": "pharmacy_dispensing_provider_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_dispensing_provider_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3288634, "relation_name": "dev_thuxuan.data_quality.pharmacy_dispensing_provider_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'DISPENSING_PROVIDER_NPI' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.dispensing_provider_npi is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case\r\n when m.dispensing_provider_npi is not null\r\n and term.npi is null\r\n then 'dispensing provider npi does not join to terminology provider table'\r\n else null\r\n end as invalid_reason\r\n , cast(m.dispensing_provider_npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m\r\nleft join {{ ref('terminology__provider')}} as term on m.dispensing_provider_npi = term.npi", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_dispensing_provider_npi.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.dispensing_provider_npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.dispensing_provider_npi is not null\n and term.npi is null\n then 'dispensing provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n , cast(m.dispensing_provider_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join dev_thuxuan.terminology.provider as term on m.dispensing_provider_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_member_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_member_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_member_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_member_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_member_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_member_id"], "alias": "pharmacy_member_id", "checksum": {"name": "sha256", "checksum": "36856a40648ab0ad131c24349f0589e66173fae7581aa2132ec6bb54ed1a7a44"}, "config": {"enabled": true, "alias": "pharmacy_member_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_member_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3308637, "relation_name": "dev_thuxuan.data_quality.pharmacy_member_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'MEMBER_ID' AS field_name\r\n , case\r\n when m.member_id is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(member_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_member_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'MEMBER_ID' AS field_name\n , case\n when m.member_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_ndc_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_ndc_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_ndc_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_ndc_code.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_ndc_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_ndc_code"], "alias": "pharmacy_ndc_code", "checksum": {"name": "sha256", "checksum": "1075a3f737b7e66ebc41ac8f895ec604d451a77234e9bb2d23ece7448739a7fe"}, "config": {"enabled": true, "alias": "pharmacy_ndc_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_ndc_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.332864, "relation_name": "dev_thuxuan.data_quality.pharmacy_ndc_code", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'NDC_CODE' AS field_name\r\n , case when term.ndc is not null then 'valid'\r\n when m.ndc_code is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.ndc_code is not null\r\n and term.ndc is null\r\n then 'NDC Code does not join to Terminology NDC table'\r\n else null\r\n end as invalid_reason\r\n , {{ dbt.concat([\"m.ndc_code\", \"'|'\", \"coalesce(term.rxnorm_description, term.fda_description, '')\"]) }} as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m\r\nleft join {{ ref('terminology__ndc')}} as term on m.ndc_code = term.ndc", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_ndc_code.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'NDC_CODE' AS field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.ndc_code is not null\n and term.ndc is null\n then 'NDC Code does not join to Terminology NDC table'\n else null\n end as invalid_reason\n , m.ndc_code || '|' || coalesce(term.rxnorm_description, term.fda_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join dev_thuxuan.terminology.ndc as term on m.ndc_code = term.ndc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_paid_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_paid_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_paid_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_paid_amount.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_paid_amount"], "alias": "pharmacy_paid_amount", "checksum": {"name": "sha256", "checksum": "509dc82124dd133ac35e33845d097df3f5ac7814b1c072e4f4ae15bebaa24a5d"}, "config": {"enabled": true, "alias": "pharmacy_paid_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_paid_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.334864, "relation_name": "dev_thuxuan.data_quality.pharmacy_paid_amount", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PAID_AMOUNT' AS field_name\r\n , case when m.paid_amount is null then 'null'\r\n else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(paid_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_paid_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_paid_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_paid_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_paid_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_paid_date.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_paid_date"], "alias": "pharmacy_paid_date", "checksum": {"name": "sha256", "checksum": "816d134762e9612a492bb79e7ef3decd46ae4d62d9d6f7847fe125f62b4f0709"}, "config": {"enabled": true, "alias": "pharmacy_paid_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_paid_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.336864, "relation_name": "dev_thuxuan.data_quality.pharmacy_paid_date", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\nwith tuva_last_run as(\r\n select cast(substring('{{ var('tuva_last_run') }}',1,10) as date) as tuva_last_run\r\n)\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PAID_DATE' AS field_name\r\n , case\r\n when m.paid_date > tuva_last_run then 'invalid'\r\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'invalid'\r\n when m.paid_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.paid_date > tuva_last_run then 'future'\r\n when m.paid_date < {{ dbt.dateadd(datepart=\"year\", interval=-10, from_date_or_timestamp=\"cte.tuva_last_run\") }} then 'too old'\r\n else null\r\n end as invalid_reason\r\n , cast(paid_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m\r\ncross join tuva_last_run cte", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.dateadd"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_paid_date.sql", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(paid_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_patient_id"], "alias": "pharmacy_patient_id", "checksum": {"name": "sha256", "checksum": "75501c068447c76f1b4e0817630c7a9d9710c24ff382fa5268be9658cad928af"}, "config": {"enabled": true, "alias": "pharmacy_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3388636, "relation_name": "dev_thuxuan.data_quality.pharmacy_patient_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PATIENT_ID' AS field_name\r\n , case\r\n when m.patient_id is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PATIENT_ID' AS field_name\n , case\n when m.patient_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_payer": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_payer.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_payer.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_payer", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_payer"], "alias": "pharmacy_payer", "checksum": {"name": "sha256", "checksum": "b5316decf087f3d2bb2b34e0777d653f10f9bf297418fb6ea9867f8a71131a2b"}, "config": {"enabled": true, "alias": "pharmacy_payer", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_payer", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.341866, "relation_name": "dev_thuxuan.data_quality.pharmacy_payer", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PAYER' AS field_name\r\n , case\r\n when m.payer is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(payer as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_payer.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAYER' AS field_name\n , case\n when m.payer is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(payer as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_plan": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_plan.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_plan.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_plan", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_plan"], "alias": "pharmacy_plan", "checksum": {"name": "sha256", "checksum": "8ad6f84ba0b9b86c2ef1de9512965fab46c75bae77f8103a304a68dc85896c6e"}, "config": {"enabled": true, "alias": "pharmacy_plan", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_plan", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3438666, "relation_name": "dev_thuxuan.data_quality.pharmacy_plan", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PLAN' AS field_name\r\n , case\r\n when m.{{ quote_column('plan') }} is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast({{ quote_column('plan') }} as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_plan.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PLAN' AS field_name\n , case\n when m.plan is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(plan as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_prescribing_provider_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_prescribing_provider_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_prescribing_provider_npi.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_prescribing_provider_npi"], "alias": "pharmacy_prescribing_provider_npi", "checksum": {"name": "sha256", "checksum": "ab6591e0961380585f0e32792cc71ad67d54d3693c05471e885f008bc87cd49a"}, "config": {"enabled": true, "alias": "pharmacy_prescribing_provider_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_prescribing_provider_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3458633, "relation_name": "dev_thuxuan.data_quality.pharmacy_prescribing_provider_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT DISTINCT -- to bring to claim_ID grain\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PRESCRIBING_PROVIDER_NPI' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.prescribing_provider_npi is not null then 'invalid'\r\n else 'null' end as bucket_name\r\n , case\r\n when m.prescribing_provider_npi is not null\r\n and term.npi is null\r\n then 'Prescribing Provider NPI does not join to Terminology Provider table'\r\n else null\r\n end as invalid_reason\r\n , cast(m.prescribing_provider_npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m\r\nleft join {{ ref('terminology__provider')}} as term on m.prescribing_provider_npi = term.npi", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_prescribing_provider_npi.sql", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PRESCRIBING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.prescribing_provider_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.prescribing_provider_npi is not null\n and term.npi is null\n then 'Prescribing Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.prescribing_provider_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join dev_thuxuan.terminology.provider as term on m.prescribing_provider_npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_quantity": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_quantity", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_quantity.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_quantity.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_quantity", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_quantity"], "alias": "pharmacy_quantity", "checksum": {"name": "sha256", "checksum": "a1122421f7d2f2a40257183072324d1172c112137136c98f1511baa778d3b4f1"}, "config": {"enabled": true, "alias": "pharmacy_quantity", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_quantity", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3488636, "relation_name": "dev_thuxuan.data_quality.pharmacy_quantity", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'PAID_DATE' AS field_name\r\n , case\r\n when m.quantity is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(quantity as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_quantity.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.quantity is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_refills": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_refills", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_refills.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_refills.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_refills", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "claims", "pharmacy", "data_quality__pharmacy_refills"], "alias": "pharmacy_refills", "checksum": {"name": "sha256", "checksum": "38703e88c980e676bfd19a3a8d19c41e3b1db4e1c92d4467cf58151218e04168"}, "config": {"enabled": true, "alias": "pharmacy_refills", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_refills", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3508637, "relation_name": "dev_thuxuan.data_quality.pharmacy_refills", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(cast(m.paid_date as {{ dbt.type_string() }}),cast('1900-01-01' as {{ dbt.type_string() }})) as source_date\r\n , 'PHARMACY_CLAIM' AS table_name\r\n , 'Claim ID | Claim Line Number' AS drill_down_key\r\n , {{ dbt.concat([\"coalesce(cast(m.claim_id as \" ~ dbt.type_string() ~ \"), 'null')\",\r\n \"'|'\",\r\n \"coalesce(cast(m.claim_line_number as \" ~ dbt.type_string() ~ \"), 'null')\"]) }} as drill_down_value\r\n , 'PHARMACY' AS claim_type\r\n , 'REFILLS' AS field_name\r\n , case\r\n when m.refills is null then 'null' else 'valid' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(refills as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim')}} m", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\claims\\pharmacy\\data_quality__pharmacy_refills.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'REFILLS' AS field_name\n , case\n when m.refills is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(refills as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_claim_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_claim_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_claim_id"], "alias": "condition_claim_id", "checksum": {"name": "sha256", "checksum": "4330a6dccf95953ddd5699ae88183d3e97c596e81d9042d40a3e3d1a3efff825"}, "config": {"enabled": true, "alias": "condition_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.352864, "relation_name": "dev_thuxuan.data_quality.condition_claim_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'CLAIM_ID' AS field_name\r\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(claim_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_claim_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' AS field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_condition_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_condition_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_condition_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_condition_id"], "alias": "condition_condition_id", "checksum": {"name": "sha256", "checksum": "073a003d51782b9e5816b40dd6dbc05a0accc3e4bb6e4184a3a587a13d0eaf73"}, "config": {"enabled": true, "alias": "condition_condition_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_condition_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.354867, "relation_name": "dev_thuxuan.data_quality.condition_condition_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'CONDITION_ID' AS field_name\r\n , case when m.condition_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(condition_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_ID' AS field_name\n , case when m.condition_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_condition_rank": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_condition_rank", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_rank.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_rank.sql", "unique_id": "model.the_tuva_project.data_quality__condition_condition_rank", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_condition_rank"], "alias": "condition_condition_rank", "checksum": {"name": "sha256", "checksum": "1e6e4280f473804b145706df72b0e1b5058f4f3919c7106266f62fd23a6fa5d8"}, "config": {"enabled": true, "alias": "condition_condition_rank", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_condition_rank", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3578634, "relation_name": "dev_thuxuan.data_quality.condition_condition_rank", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'CONDITION_RANK' AS field_name\r\n , case when m.condition_rank is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(condition_rank as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_rank.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_RANK' AS field_name\n , case when m.condition_rank is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_rank as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_condition_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_condition_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_type.sql", "unique_id": "model.the_tuva_project.data_quality__condition_condition_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_condition_type"], "alias": "condition_condition_type", "checksum": {"name": "sha256", "checksum": "e9bd72c391434d2b272a2ec16130af61f3da791dc347595002cc3539d8f90694"}, "config": {"enabled": true, "alias": "condition_condition_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_condition_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.359373, "relation_name": "dev_thuxuan.data_quality.condition_condition_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'CONDITION_TYPE' AS field_name\r\n , case when m.condition_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(condition_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_condition_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_TYPE' AS field_name\n , case when m.condition_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__condition_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_data_source"], "alias": "condition_data_source", "checksum": {"name": "sha256", "checksum": "c012c5cab7c5137b9fdc79b773d8b1b5c6cde6476cdc983bd88368f85c2b979f"}, "config": {"enabled": true, "alias": "condition_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.361373, "relation_name": "dev_thuxuan.data_quality.condition_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' AS field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_encounter_id"], "alias": "condition_encounter_id", "checksum": {"name": "sha256", "checksum": "1f13d3a26e8dbaa7c05d441b35ba9b18318cace36289b2c5a9d5feafe442786e"}, "config": {"enabled": true, "alias": "condition_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.363373, "relation_name": "dev_thuxuan.data_quality.condition_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'ENCOUNTER_ID' AS field_name\r\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(encounter_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_encounter_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' AS field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_normalized_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_normalized_code"], "alias": "condition_normalized_code", "checksum": {"name": "sha256", "checksum": "489ed93c80b5ba9d33cfeb32643d394e77758223e8d9697177238a4444993636"}, "config": {"enabled": true, "alias": "condition_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3693738, "relation_name": "dev_thuxuan.data_quality.condition_normalized_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' AS field_name\r\n , case when term.icd_10_cm is not null then 'valid'\r\n when m.normalized_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code is not null and term.icd_10_cm is null\r\n then 'Normalized code does not join to Terminology icd_10_cm table'\r\n else null end as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m\r\nleft join {{ ref('terminology__icd_10_cm')}} term on m.normalized_code = term.icd_10_cm", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_cm is null\n then 'Normalized code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join dev_thuxuan.terminology.icd_10_cm term on m.normalized_code = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_normalized_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_normalized_code_type"], "alias": "condition_normalized_code_type", "checksum": {"name": "sha256", "checksum": "4ad80ee062b49aefda1ad8ab4b8b67a8e900ade68339366745185dbfde5ddd42"}, "config": {"enabled": true, "alias": "condition_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3663735, "relation_name": "dev_thuxuan.data_quality.condition_normalized_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE_TYPE' AS field_name\r\n , case when term.code_type is not null then 'valid'\r\n when m.normalized_code_type is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code_type is not null and term.code_type is null\r\n then 'Normalized Code Type does not join to Terminology code_type table'\r\n else null end as invalid_reason\r\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m\r\nleft join {{ ref('reference_data__code_type')}} as term on m.normalized_code_type = term.code_type", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join dev_thuxuan.reference_data.code_type as term on m.normalized_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_normalized_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__condition_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_normalized_description"], "alias": "condition_normalized_description", "checksum": {"name": "sha256", "checksum": "f85febb3ef50bcbbc265784e83dd5507b830ad7f406306fec612b24301c585f2"}, "config": {"enabled": true, "alias": "condition_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.371374, "relation_name": "dev_thuxuan.data_quality.condition_normalized_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_DESCRIPTION' AS field_name\r\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_normalized_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_onset_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_onset_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_onset_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_onset_date.sql", "unique_id": "model.the_tuva_project.data_quality__condition_onset_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_onset_date"], "alias": "condition_onset_date", "checksum": {"name": "sha256", "checksum": "cb14f177478647d7b8d163336a790e436218b8d95fed1ac74b35ce5af2ecfb5a"}, "config": {"enabled": true, "alias": "condition_onset_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_onset_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3744302, "relation_name": "dev_thuxuan.data_quality.condition_onset_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'ONSET_DATE' AS field_name\r\n ,case\r\n when m.onset_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.onset_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.onset_date > m.resolved_date then 'invalid'\r\n when m.onset_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when m.onset_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.onset_date <= cast('1901-01-01' as date) then 'too old'\r\n WHEN m.onset_date < m.resolved_date THEN 'Onset date after resolved date'\r\n else null\r\n end as invalid_reason\r\n ,cast(onset_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_onset_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ONSET_DATE' AS field_name\n ,case\n when m.onset_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.onset_date <= cast('1901-01-01' as date) then 'invalid'\n when m.onset_date > m.resolved_date then 'invalid'\n when m.onset_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.onset_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.onset_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.onset_date < m.resolved_date THEN 'Onset date after resolved date'\n else null\n end as invalid_reason\n ,cast(onset_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__condition_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_patient_id"], "alias": "condition_patient_id", "checksum": {"name": "sha256", "checksum": "eb58b6876033117a47b4ccbb683f908d58830e194c05b7be3cd7950e170ab88f"}, "config": {"enabled": true, "alias": "condition_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.37643, "relation_name": "dev_thuxuan.data_quality.condition_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date) ) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'PATIENT_ID' AS field_name\r\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date) ) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_present_on_admit_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_present_on_admit_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_present_on_admit_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_present_on_admit_code.sql", "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_present_on_admit_code"], "alias": "condition_present_on_admit_code", "checksum": {"name": "sha256", "checksum": "3270ce5c34bcb31f352c6755f1e794de6205365759eaf2c0ec882134619c7f8c"}, "config": {"enabled": true, "alias": "condition_present_on_admit_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_present_on_admit_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3784268, "relation_name": "dev_thuxuan.data_quality.condition_present_on_admit_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'PRESENT_ON_ADMIT_CODE' AS field_name\r\n ,case when term.present_on_admit_code is not null then 'valid'\r\n when m.present_on_admit_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n ,case when m.present_on_admit_code is not null and term.present_on_admit_code is null\r\n then 'Present On Admit Code does not join to Terminology present_on_admission table'\r\n else null\r\n end as invalid_reason\r\n ,cast(m.present_on_admit_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m\r\nleft join {{ ref('terminology__present_on_admission')}} term on m.present_on_admit_code = term.present_on_admit_code", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}, {"name": "terminology__present_on_admission", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition", "seed.the_tuva_project.terminology__present_on_admission"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_present_on_admit_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_CODE' AS field_name\n ,case when term.present_on_admit_code is not null then 'valid'\n when m.present_on_admit_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.present_on_admit_code is not null and term.present_on_admit_code is null\n then 'Present On Admit Code does not join to Terminology present_on_admission table'\n else null\n end as invalid_reason\n ,cast(m.present_on_admit_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join dev_thuxuan.terminology.present_on_admission term on m.present_on_admit_code = term.present_on_admit_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_present_on_admit_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_present_on_admit_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_present_on_admit_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_present_on_admit_description.sql", "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_present_on_admit_description"], "alias": "condition_present_on_admit_description", "checksum": {"name": "sha256", "checksum": "2afd387cb7d433f28d8103179d72b28f950863cfbeda022847a86072f2e1b3de"}, "config": {"enabled": true, "alias": "condition_present_on_admit_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_present_on_admit_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3804307, "relation_name": "dev_thuxuan.data_quality.condition_present_on_admit_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'PRESENT_ON_ADMIT_DESCRIPTION' AS field_name\r\n ,case when m.present_on_admit_description is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(substring(present_on_admit_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_present_on_admit_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_DESCRIPTION' AS field_name\n ,case when m.present_on_admit_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(present_on_admit_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_recorded_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_recorded_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_recorded_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_recorded_date.sql", "unique_id": "model.the_tuva_project.data_quality__condition_recorded_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_recorded_date"], "alias": "condition_recorded_date", "checksum": {"name": "sha256", "checksum": "877613f913b570292f38d15ff35b4dae7a4ed3e1e634280feaa199df8c5162cf"}, "config": {"enabled": true, "alias": "condition_recorded_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_recorded_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3824306, "relation_name": "dev_thuxuan.data_quality.condition_recorded_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'RECORDED_DATE' AS field_name\r\n ,CASE\r\n when m.recorded_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.recorded_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.recorded_date < m.onset_date then 'invalid'\r\n when m.recorded_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n ,case\r\n when m.recorded_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.recorded_date <= cast('1901-01-01' as date) then 'too old'\r\n WHEN m.recorded_date < m.onset_date THEN 'Recorded date before onset date'\r\n else null\r\n end as invalid_reason\r\n ,cast(recorded_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_recorded_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'RECORDED_DATE' AS field_name\n ,CASE\n when m.recorded_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.recorded_date <= cast('1901-01-01' as date) then 'invalid'\n when m.recorded_date < m.onset_date then 'invalid'\n when m.recorded_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.recorded_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.recorded_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.recorded_date < m.onset_date THEN 'Recorded date before onset date'\n else null\n end as invalid_reason\n ,cast(recorded_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_resolved_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_resolved_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_resolved_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_resolved_date.sql", "unique_id": "model.the_tuva_project.data_quality__condition_resolved_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_resolved_date"], "alias": "condition_resolved_date", "checksum": {"name": "sha256", "checksum": "ab9829ab1c62ea452fa49f35c259eada5daebd966dfcb51e68d95662adaa4c48"}, "config": {"enabled": true, "alias": "condition_resolved_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_resolved_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3844304, "relation_name": "dev_thuxuan.data_quality.condition_resolved_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'RESOLVED_DATE' AS field_name\r\n , CASE\r\n when m.resolved_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.resolved_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.resolved_date < m.onset_date then 'invalid'\r\n when m.resolved_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.resolved_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.resolved_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.resolved_date < m.onset_date THEN 'Resolved date before onset date'\r\n else null\r\n end as invalid_reason\r\n , cast(resolved_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_resolved_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'RESOLVED_DATE' AS field_name\n , CASE\n when m.resolved_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.resolved_date <= cast('1901-01-01' as date) then 'invalid'\n when m.resolved_date < m.onset_date then 'invalid'\n when m.resolved_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.resolved_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.resolved_date <= cast('1901-01-01' as date) then 'too old'\n when m.resolved_date < m.onset_date THEN 'Resolved date before onset date'\n else null\n end as invalid_reason\n , cast(resolved_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__condition_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_source_code"], "alias": "condition_source_code", "checksum": {"name": "sha256", "checksum": "7b6e085a289995d321dbfc4330c81ac18df6f02dafa2febe67d27adeafbbde12"}, "config": {"enabled": true, "alias": "condition_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3874304, "relation_name": "dev_thuxuan.data_quality.condition_source_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n ,'CONDITION' AS table_name\r\n ,'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n ,'SOURCE_CODE' AS field_name\r\n ,case when m.source_code is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(source_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'SOURCE_CODE' AS field_name\n ,case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_source_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__condition_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_source_code_type"], "alias": "condition_source_code_type", "checksum": {"name": "sha256", "checksum": "147cf4511f19ee19d4b86876b58b83f683d8ce548f4fb4110f873c12e5e637ad"}, "config": {"enabled": true, "alias": "condition_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3894277, "relation_name": "dev_thuxuan.data_quality.condition_source_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE_TYPE' AS field_name\r\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' AS field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_source_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__condition_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_source_description"], "alias": "condition_source_description", "checksum": {"name": "sha256", "checksum": "3ef0d6af73ab20d4b90fbf7499a5d480a19955464dd7b44082521edb3c6803b1"}, "config": {"enabled": true, "alias": "condition_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.391433, "relation_name": "dev_thuxuan.data_quality.condition_source_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_DESCRIPTION' AS field_name\r\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_source_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' AS field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__condition_status": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__condition_status", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_status.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_status.sql", "unique_id": "model.the_tuva_project.data_quality__condition_status", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "condition", "data_quality__condition_status"], "alias": "condition_status", "checksum": {"name": "sha256", "checksum": "cf354617368a81800b403b7a70c1052d48c44eb96299c4ef99fcccddce74f286"}, "config": {"enabled": true, "alias": "condition_status", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "condition_status", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3934326, "relation_name": "dev_thuxuan.data_quality.condition_status", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\r\n , 'CONDITION' AS table_name\r\n , 'Condition ID' as drill_down_key\r\n , coalesce(condition_id, 'NULL') AS drill_down_value\r\n , 'STATUS' AS field_name\r\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(status as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('condition')}} m", "language": "sql", "refs": [{"name": "condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\condition\\data_quality__condition_status.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'STATUS' AS field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_admit_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_source_code"], "alias": "encounter_admit_source_code", "checksum": {"name": "sha256", "checksum": "4a4ebee7bc9e2849525bf98a80eeb95a198d7ce17587c33cc4ae8b4387835c80"}, "config": {"enabled": true, "alias": "encounter_admit_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3964326, "relation_name": "dev_thuxuan.data_quality.encounter_admit_source_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ADMIT_SOURCE_CODE' AS field_name\r\n , case when term.admit_source_code is not null then 'valid'\r\n when m.admit_source_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.admit_source_code is not null and term.admit_source_code is null\r\n then 'Admit source code does not join to Terminology admit source table'\r\n else null end as invalid_reason\r\n , cast(m.admit_source_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__admit_source')}} term on m.admit_source_code = term.admit_source_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__admit_source", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_source"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_source_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_source_code is not null and term.admit_source_code is null\n then 'Admit source code does not join to Terminology admit source table'\n else null end as invalid_reason\n , cast(m.admit_source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.admit_source term on m.admit_source_code = term.admit_source_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_source_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_admit_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_source_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_source_description"], "alias": "encounter_admit_source_description", "checksum": {"name": "sha256", "checksum": "db628bdc33c151944d657acb27c49c743ad25752d5aaa5a1c84c8b49fbe5e6e4"}, "config": {"enabled": true, "alias": "encounter_admit_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.3984327, "relation_name": "dev_thuxuan.data_quality.encounter_admit_source_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ADMIT_SOURCE_DESCRIPTION' AS field_name\r\n , case when m.admit_source_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(admit_source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_source_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_DESCRIPTION' AS field_name\n , case when m.admit_source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(admit_source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_type_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_admit_type_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_type_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_type_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_type_code"], "alias": "encounter_admit_type_code", "checksum": {"name": "sha256", "checksum": "97ea0d0f23b27edfed3bbb00287d1f239ed1b4cb4b72f90a0fd3b9698edb3868"}, "config": {"enabled": true, "alias": "encounter_admit_type_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_type_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4004326, "relation_name": "dev_thuxuan.data_quality.encounter_admit_type_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ADMIT_TYPE_CODE' AS field_name\r\n , case when term.admit_type_code is not null then 'valid'\r\n when m.admit_type_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.admit_type_code is not null and term.admit_type_code is null\r\n then 'Admit Type Code does not join to Terminology admit_type table'\r\n else null end as invalid_reason\r\n , cast(m.admit_type_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__admit_type')}} term on m.admit_type_code = term.admit_type_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__admit_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_type_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_type_code is not null and term.admit_type_code is null\n then 'Admit Type Code does not join to Terminology admit_type table'\n else null end as invalid_reason\n , cast(m.admit_type_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.admit_type term on m.admit_type_code = term.admit_type_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_admit_type_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_admit_type_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_type_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_type_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_admit_type_description"], "alias": "encounter_admit_type_description", "checksum": {"name": "sha256", "checksum": "dcfb3adfc9ff8839e2e34087b73a4439ad393e55dd2f053856643749c60268c5"}, "config": {"enabled": true, "alias": "encounter_admit_type_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_admit_type_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4024324, "relation_name": "dev_thuxuan.data_quality.encounter_admit_type_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n ,'ENCOUNTER' AS table_name\r\n ,'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n ,'ADMIT_TYPE_DESCRIPTION' AS field_name\r\n ,case when m.admit_type_description is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(substring(admit_type_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_admit_type_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'ADMIT_TYPE_DESCRIPTION' AS field_name\n ,case when m.admit_type_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(admit_type_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_allowed_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_allowed_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_allowed_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_allowed_amount.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_allowed_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_allowed_amount"], "alias": "encounter_allowed_amount", "checksum": {"name": "sha256", "checksum": "3660757c3ff0501263eaaa97853f33cac4db2038e76a7562da01988d5857d27a"}, "config": {"enabled": true, "alias": "encounter_allowed_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_allowed_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4051003, "relation_name": "dev_thuxuan.data_quality.encounter_allowed_amount", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ALLOWED_AMOUNT' AS field_name\r\n , case when m.allowed_amount is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(allowed_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_allowed_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_apr_drg_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_apr_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_apr_drg_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_apr_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_apr_drg_code"], "alias": "encounter_apr_drg_code", "checksum": {"name": "sha256", "checksum": "303bb09f17e4cec19e9884454d66644528461554d7820fff0b617a1eb3af561f"}, "config": {"enabled": true, "alias": "encounter_apr_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_apr_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4081113, "relation_name": "dev_thuxuan.data_quality.encounter_apr_drg_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n ,'ENCOUNTER' AS table_name\r\n ,'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n ,'APR_DRG_CODE' AS field_name\r\n ,case when term.apr_drg_code is not null then 'valid'\r\n when m.apr_drg_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n ,case when m.apr_drg_code is not null and term.apr_drg_code is null\r\n then 'APR DRG Code does not join to Terminology apr_drg table'\r\n else null end as invalid_reason\r\n ,cast(m.apr_drg_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__apr_drg')}} term on m.apr_drg_code = term.apr_drg_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_apr_drg_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'APR_DRG_CODE' AS field_name\n ,case when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.apr_drg_code is not null and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology apr_drg table'\n else null end as invalid_reason\n ,cast(m.apr_drg_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.apr_drg term on m.apr_drg_code = term.apr_drg_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_apr_drg_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_apr_drg_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_apr_drg_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_apr_drg_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_apr_drg_description"], "alias": "encounter_apr_drg_description", "checksum": {"name": "sha256", "checksum": "bdc74b2d3599beaa468142cda7352d93a92152880aaff9244b9f111c6f342b4b"}, "config": {"enabled": true, "alias": "encounter_apr_drg_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_apr_drg_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4101143, "relation_name": "dev_thuxuan.data_quality.encounter_apr_drg_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'APR_DRG_DESCRIPTION' AS field_name\r\n , case when m.apr_drg_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(apr_drg_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_apr_drg_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'APR_DRG_DESCRIPTION' AS field_name\n , case when m.apr_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(apr_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_attending_provider_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_attending_provider_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_attending_provider_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_attending_provider_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_attending_provider_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_attending_provider_id"], "alias": "encounter_attending_provider_id", "checksum": {"name": "sha256", "checksum": "e7c69a66561b36efbc65b8caad05a950ac42efe4f3c33cc66b104505a4797af8"}, "config": {"enabled": true, "alias": "encounter_attending_provider_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_attending_provider_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.413113, "relation_name": "dev_thuxuan.data_quality.encounter_attending_provider_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ATTENDING_PROVIDER_ID' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.attending_provider_id is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.attending_provider_id is not null and term.npi is null\r\n then 'Attending provider ID does not join to Terminology provider table'\r\n else null end as invalid_reason\r\n , cast(attending_provider_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__provider')}} term on m.attending_provider_id = term.npi", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_attending_provider_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ATTENDING_PROVIDER_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.attending_provider_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.attending_provider_id is not null and term.npi is null\n then 'Attending provider ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(attending_provider_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.provider term on m.attending_provider_id = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_charge_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_charge_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_charge_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_charge_amount.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_charge_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_charge_amount"], "alias": "encounter_charge_amount", "checksum": {"name": "sha256", "checksum": "e744c6952a2e44d452adc29feeaa5aa6a73b78332f52688239b12f7e3ddbcf76"}, "config": {"enabled": true, "alias": "encounter_charge_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_charge_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4161122, "relation_name": "dev_thuxuan.data_quality.encounter_charge_amount", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'CHARGE_AMOUNT' AS field_name\r\n , case when m.charge_amount is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(charge_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_charge_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_data_source"], "alias": "encounter_data_source", "checksum": {"name": "sha256", "checksum": "b3dad03a8b045e14fd2d72585857235f77923d784729dad2d071b43747b87808"}, "config": {"enabled": true, "alias": "encounter_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.418112, "relation_name": "dev_thuxuan.data_quality.encounter_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n ,'ENCOUNTER' AS table_name\r\n ,'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n ,'DATA_SOURCE' AS field_name\r\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_data_source.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_discharge_disposition_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_discharge_disposition_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_discharge_disposition_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_discharge_disposition_code"], "alias": "encounter_discharge_disposition_code", "checksum": {"name": "sha256", "checksum": "5ae68108bc3e6080a161291eea479e36373978566d9226f003be65cdd824ec08"}, "config": {"enabled": true, "alias": "encounter_discharge_disposition_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_discharge_disposition_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.421115, "relation_name": "dev_thuxuan.data_quality.encounter_discharge_disposition_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\r\n , case when term.discharge_disposition_code is not null then 'valid'\r\n when m.discharge_disposition_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.discharge_disposition_code is not null and term.discharge_disposition_code is null\r\n then 'Discharge Disposition Code does not join to Terminology discharge_disposition table'\r\n else null end as invalid_reason\r\n , cast(m.discharge_disposition_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__discharge_disposition')}} term on m.discharge_disposition_code = term.discharge_disposition_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_discharge_disposition_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.discharge_disposition_code is not null and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology discharge_disposition table'\n else null end as invalid_reason\n , cast(m.discharge_disposition_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.discharge_disposition term on m.discharge_disposition_code = term.discharge_disposition_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_discharge_disposition_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_discharge_disposition_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_discharge_disposition_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_discharge_disposition_description"], "alias": "encounter_discharge_disposition_description", "checksum": {"name": "sha256", "checksum": "917e6944829d49bfdc9892c5c0b7e6dcb80793a63c3871cbce17317072ea8f2e"}, "config": {"enabled": true, "alias": "encounter_discharge_disposition_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_discharge_disposition_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4231145, "relation_name": "dev_thuxuan.data_quality.encounter_discharge_disposition_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'DISCHARGE_DISPOSITION_DESCRIPTION' AS field_name\r\n , case when m.discharge_disposition_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(discharge_disposition_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_discharge_disposition_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_DESCRIPTION' AS field_name\n , case when m.discharge_disposition_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(discharge_disposition_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_end_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_encounter_end_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_end_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_end_date.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_end_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_end_date"], "alias": "encounter_encounter_end_date", "checksum": {"name": "sha256", "checksum": "8213c75427989914f313efd44506c998fd0362f6cfd734eb2be6163ad99e40d1"}, "config": {"enabled": true, "alias": "encounter_encounter_end_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_end_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4251146, "relation_name": "dev_thuxuan.data_quality.encounter_encounter_end_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_END_DATE' AS field_name\r\n , case\r\n when m.encounter_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.encounter_end_date < m.encounter_start_date then 'invalid'\r\n when m.encounter_end_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.encounter_end_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.encounter_end_date < m.encounter_start_date then 'Encounter end date before encounter start date'\r\n else null\r\n end as invalid_reason\r\n , cast(encounter_end_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_end_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_END_DATE' AS field_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_end_date < m.encounter_start_date then 'invalid'\n when m.encounter_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_end_date < m.encounter_start_date then 'Encounter end date before encounter start date'\n else null\n end as invalid_reason\n , cast(encounter_end_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_id"], "alias": "encounter_encounter_id", "checksum": {"name": "sha256", "checksum": "fc6cd182cf2d7f04252449b1a316f76308ce8a37cc9d5b4236800e04e81fba9b"}, "config": {"enabled": true, "alias": "encounter_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.427115, "relation_name": "dev_thuxuan.data_quality.encounter_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_ID' AS field_name\r\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' AS field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_start_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_encounter_start_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_start_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_start_date.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_start_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_start_date"], "alias": "encounter_encounter_start_date", "checksum": {"name": "sha256", "checksum": "1ae01e8d2f76ad09e49693d489ad4b72c62c4792179064ea6ec820873a9f2ba1"}, "config": {"enabled": true, "alias": "encounter_encounter_start_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_start_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4291148, "relation_name": "dev_thuxuan.data_quality.encounter_encounter_start_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_START_DATE' AS field_name\r\n , case\r\n when m.encounter_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.encounter_start_date > m.encounter_end_date then 'invalid'\r\n when m.encounter_start_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.encounter_start_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.encounter_start_date > m.encounter_end_date then 'Encounter start date after encounter end date'\r\n else null\r\n end as invalid_reason\r\n , cast(encounter_start_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_start_date.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_START_DATE' AS field_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_start_date > m.encounter_end_date then 'invalid'\n when m.encounter_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_start_date > m.encounter_end_date then 'Encounter start date after encounter end date'\n else null\n end as invalid_reason\n , cast(encounter_start_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_encounter_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_encounter_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_type.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_encounter_type"], "alias": "encounter_encounter_type", "checksum": {"name": "sha256", "checksum": "da55bace00f592fc5fdf4ae80f3d481a7ae82846d4e392ec8b20cd7c9d9567bc"}, "config": {"enabled": true, "alias": "encounter_encounter_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_encounter_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4311144, "relation_name": "dev_thuxuan.data_quality.encounter_encounter_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_TYPE' AS field_name\r\n , case when term.encounter_type is not null then 'valid'\r\n when m.encounter_type is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.encounter_type is not null and term.encounter_type is null\r\n then 'Encounter type does not join to Terminology encounter_type table'\r\n else null end as invalid_reason\r\n , cast(m.encounter_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__encounter_type')}} term on m.encounter_type = term.encounter_type", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__encounter_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__encounter_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_encounter_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_TYPE' AS field_name\n , case when term.encounter_type is not null then 'valid'\n when m.encounter_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.encounter_type is not null and term.encounter_type is null\n then 'Encounter type does not join to Terminology encounter_type table'\n else null end as invalid_reason\n , cast(m.encounter_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.encounter_type term on m.encounter_type = term.encounter_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_facility_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_facility_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_facility_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_facility_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_facility_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_facility_id"], "alias": "encounter_facility_id", "checksum": {"name": "sha256", "checksum": "83967c8fc40d06149edbdbc579080273b0d90844b50a83ed4f70ff82718ad2da"}, "config": {"enabled": true, "alias": "encounter_facility_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_facility_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4341142, "relation_name": "dev_thuxuan.data_quality.encounter_facility_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'FACILITY_ID' AS field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.facility_id is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.facility_id is not null and term.npi is null\r\n then 'Facility NPI does not join to Terminology provider table'\r\n else null end as invalid_reason\r\n , cast(facility_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__provider')}} term on m.facility_id = term.npi", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_facility_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'FACILITY_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.facility_id is not null and term.npi is null\n then 'Facility NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(facility_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.provider term on m.facility_id = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_length_of_stay": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_length_of_stay", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_length_of_stay.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_length_of_stay.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_length_of_stay", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_length_of_stay"], "alias": "encounter_length_of_stay", "checksum": {"name": "sha256", "checksum": "7e7349f81ef3f254e43546e15035d4201c53eda1ec6ef7aa513293181eb49cd3"}, "config": {"enabled": true, "alias": "encounter_length_of_stay", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_length_of_stay", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4361145, "relation_name": "dev_thuxuan.data_quality.encounter_length_of_stay", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n ,'ENCOUNTER' AS table_name\r\n ,'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n ,'LENGTH_OF_STAY' AS field_name\r\n ,case when m.length_of_stay is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(length_of_stay as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_length_of_stay.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'LENGTH_OF_STAY' AS field_name\n ,case when m.length_of_stay is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(length_of_stay as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_ms_drg_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_ms_drg_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_ms_drg_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_ms_drg_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_ms_drg_code"], "alias": "encounter_ms_drg_code", "checksum": {"name": "sha256", "checksum": "a0a76e147a897ffb3867617f9024eb007b3ae8d8ffbd76da260d2f86819aaf7c"}, "config": {"enabled": true, "alias": "encounter_ms_drg_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_ms_drg_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4391274, "relation_name": "dev_thuxuan.data_quality.encounter_ms_drg_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'MS_DRG_CODE' AS field_name\r\n , case when term.ms_drg_code is not null then 'valid'\r\n when m.ms_drg_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.ms_drg_code is not null and term.ms_drg_code is null\r\n then 'MS DRG Code does not join to Terminology ms_drg table'\r\n else null end as invalid_reason\r\n , cast(m.ms_drg_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__ms_drg')}} term on m.ms_drg_code = term.ms_drg_code", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_ms_drg_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_CODE' AS field_name\n , case when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ms_drg_code is not null and term.ms_drg_code is null\n then 'MS DRG Code does not join to Terminology ms_drg table'\n else null end as invalid_reason\n , cast(m.ms_drg_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.ms_drg term on m.ms_drg_code = term.ms_drg_code", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_ms_drg_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_ms_drg_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_ms_drg_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_ms_drg_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_ms_drg_description"], "alias": "encounter_ms_drg_description", "checksum": {"name": "sha256", "checksum": "dad87481fd9c6c338138d9e7bf14c2dd1ff4f3682ec2c3a76e85d292609e6912"}, "config": {"enabled": true, "alias": "encounter_ms_drg_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_ms_drg_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4421277, "relation_name": "dev_thuxuan.data_quality.encounter_ms_drg_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'MS_DRG_DESCRIPTION' AS field_name\r\n , case when m.ms_drg_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(ms_drg_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_ms_drg_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_DESCRIPTION' AS field_name\n , case when m.ms_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(ms_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_paid_amount": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_paid_amount", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_paid_amount.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_paid_amount.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_paid_amount", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_paid_amount"], "alias": "encounter_paid_amount", "checksum": {"name": "sha256", "checksum": "490fffd170b183742c898ab630b5b1c64b9ce218aa4faed9e3df3ed2bc09bcb5"}, "config": {"enabled": true, "alias": "encounter_paid_amount", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_paid_amount", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4441276, "relation_name": "dev_thuxuan.data_quality.encounter_paid_amount", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n ,'ENCOUNTER' AS table_name\r\n ,'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n ,'PAID_AMOUNT' AS field_name\r\n ,case when m.paid_amount is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(paid_amount as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_paid_amount.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PAID_AMOUNT' AS field_name\n ,case when m.paid_amount is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(paid_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_patient_id"], "alias": "encounter_patient_id", "checksum": {"name": "sha256", "checksum": "90eb911093a59e57d4d86ca64ee92df4ed6cd3dd4ff3b3906e8bf907716aa129"}, "config": {"enabled": true, "alias": "encounter_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4461286, "relation_name": "dev_thuxuan.data_quality.encounter_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n ,'ENCOUNTER' AS table_name\r\n ,'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n ,'PATIENT_ID' AS field_name\r\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_patient_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_primary_diagnosis_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_code.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_primary_diagnosis_code"], "alias": "encounter_primary_diagnosis_code", "checksum": {"name": "sha256", "checksum": "9a74f4ac49f910335ff21e74fdc4a37ecf9814d20d78e44b2430f1d6824d59a5"}, "config": {"enabled": true, "alias": "encounter_primary_diagnosis_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_primary_diagnosis_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4481275, "relation_name": "dev_thuxuan.data_quality.encounter_primary_diagnosis_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'PRIMARY_DIAGNOSIS_CODE' AS field_name\r\n , case when term.icd_10_cm is not null then 'valid'\r\n when m.primary_diagnosis_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.primary_diagnosis_code is not null and term.icd_10_cm is null\r\n then 'Primary diagnosis code does not join to Terminology icd_10_cm table'\r\n else null end as invalid_reason\r\n , cast(primary_diagnosis_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('terminology__icd_10_cm')}} term on m.primary_diagnosis_code = term.icd_10_cm", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__icd_10_cm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_code.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.primary_diagnosis_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code is not null and term.icd_10_cm is null\n then 'Primary diagnosis code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.icd_10_cm term on m.primary_diagnosis_code = term.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_primary_diagnosis_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_primary_diagnosis_code_type"], "alias": "encounter_primary_diagnosis_code_type", "checksum": {"name": "sha256", "checksum": "25e1b455fe6ed52b6682e69e686ae7d35a816ff0d6f8f1da775b845b2ce59772"}, "config": {"enabled": true, "alias": "encounter_primary_diagnosis_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_primary_diagnosis_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4501276, "relation_name": "dev_thuxuan.data_quality.encounter_primary_diagnosis_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'PRIMARY_DIAGNOSIS_CODE_TYPE' AS field_name\r\n , case when term.code_type is not null then 'valid'\r\n when m.primary_diagnosis_code_type is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.primary_diagnosis_code_type is not null and term.code_type is null\r\n then 'Primary Diagnosis Code Type does not join to Terminology code_type table'\r\n else null end as invalid_reason\r\n , cast(primary_diagnosis_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m\r\nleft join {{ ref('reference_data__code_type')}} term on m.primary_diagnosis_code_type = term.code_type", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_code_type.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.primary_diagnosis_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code_type is not null and term.code_type is null\n then 'Primary Diagnosis Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.reference_data.code_type term on m.primary_diagnosis_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounter_primary_diagnosis_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_description.sql", "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "encounter", "data_quality__encounter_primary_diagnosis_description"], "alias": "encounter_primary_diagnosis_description", "checksum": {"name": "sha256", "checksum": "126eee4fee800bfd78b809e28387a424cf890f0b552a720d1d22d9de68eb6f6a"}, "config": {"enabled": true, "alias": "encounter_primary_diagnosis_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounter_primary_diagnosis_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4531338, "relation_name": "dev_thuxuan.data_quality.encounter_primary_diagnosis_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\r\n , 'ENCOUNTER' AS table_name\r\n , 'Encounter ID' as drill_down_key\r\n , coalesce(encounter_id, 'NULL') AS drill_down_value\r\n , 'PRIMARY_DIAGNOSIS_DESCRIPTION' AS field_name\r\n , case when m.primary_diagnosis_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(primary_diagnosis_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('encounter')}} m", "language": "sql", "refs": [{"name": "encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\encounter\\data_quality__encounter_primary_diagnosis_description.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_DESCRIPTION' AS field_name\n , case when m.primary_diagnosis_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(primary_diagnosis_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_accession_number": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_accession_number", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_accession_number.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_accession_number.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_accession_number", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_accession_number"], "alias": "lab_result_accession_number", "checksum": {"name": "sha256", "checksum": "9c6338fa087877dca7d4f8fb8055b605fb16bc9cdfe9b7e3db8aa38dddb69653"}, "config": {"enabled": true, "alias": "lab_result_accession_number", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_accession_number", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.490114, "relation_name": "dev_thuxuan.data_quality.lab_result_accession_number", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'ACCESSION_NUMBER' AS field_name\r\n , case when m.accession_number is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(accession_number as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_accession_number.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ACCESSION_NUMBER' AS field_name\n , case when m.accession_number is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(accession_number as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_collection_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_collection_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_collection_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_collection_date.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_collection_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_collection_date"], "alias": "lab_result_collection_date", "checksum": {"name": "sha256", "checksum": "b08187f0ed9d9a5655c7b0dcfb00b89996b0e0e867857923a495df6582ef4468"}, "config": {"enabled": true, "alias": "lab_result_collection_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_collection_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4661276, "relation_name": "dev_thuxuan.data_quality.lab_result_collection_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'COLLECTION_DATE' AS field_name\r\n , case\r\n when m.collection_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.collection_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.collection_date > m.result_date then 'invalid'\r\n when m.collection_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.collection_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.collection_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.collection_date > m.result_date then 'Collection date after result date'\r\n else null\r\n end as invalid_reason\r\n , cast(collection_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_collection_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'COLLECTION_DATE' AS field_name\n , case\n when m.collection_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.collection_date <= cast('1901-01-01' as date) then 'invalid'\n when m.collection_date > m.result_date then 'invalid'\n when m.collection_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.collection_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.collection_date <= cast('1901-01-01' as date) then 'too old'\n when m.collection_date > m.result_date then 'Collection date after result date'\n else null\n end as invalid_reason\n , cast(collection_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_data_source"], "alias": "lab_result_data_source", "checksum": {"name": "sha256", "checksum": "31c830b018693fc918ef942333d6295a018d2b5dc0ae727e8d1c2ea41d5816a7"}, "config": {"enabled": true, "alias": "lab_result_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4971235, "relation_name": "dev_thuxuan.data_quality.lab_result_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' AS field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_encounter_id"], "alias": "lab_result_encounter_id", "checksum": {"name": "sha256", "checksum": "467e5568eeb1e378651b7316b734b97cede67a7e6dd888085f45921c4a641074"}, "config": {"enabled": true, "alias": "lab_result_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5121398, "relation_name": "dev_thuxuan.data_quality.lab_result_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_ID' as field_name\r\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_encounter_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_lab_result_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_lab_result_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_lab_result_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_lab_result_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_lab_result_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_lab_result_id"], "alias": "lab_result_lab_result_id", "checksum": {"name": "sha256", "checksum": "177f6eacaa765bed124ff54a3c753a64276a38b64e3cefd35232b2f1007968cc"}, "config": {"enabled": true, "alias": "lab_result_lab_result_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_lab_result_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4631279, "relation_name": "dev_thuxuan.data_quality.lab_result_lab_result_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'LAB_RESULT_ID' as field_name\r\n , case when m.lab_result_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(lab_result_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_lab_result_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'LAB_RESULT_ID' as field_name\n , case when m.lab_result_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(lab_result_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_abnormal_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_abnormal_flag.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_abnormal_flag.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_abnormal_flag"], "alias": "lab_result_normalized_abnormal_flag", "checksum": {"name": "sha256", "checksum": "af5692de9a1bcf9c8abc994cdda09abce6052baed91132e61b968b717905467c"}, "config": {"enabled": true, "alias": "lab_result_normalized_abnormal_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_abnormal_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4941235, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_abnormal_flag", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_ABNORMAL_FLAG' as field_name\r\n , case when m.normalized_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_abnormal_flag as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_abnormal_flag.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_ABNORMAL_FLAG' as field_name\n , case when m.normalized_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_abnormal_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_code"], "alias": "lab_result_normalized_code", "checksum": {"name": "sha256", "checksum": "6475a9605de23628615514ac765f905059b1b02f1d7d14e8bad2a05c7414ee5a"}, "config": {"enabled": true, "alias": "lab_result_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4831967, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' as field_name\r\n , case when term.loinc is not null then 'valid'\r\n when m.normalized_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code is not null and term.loinc is null\r\n then 'Normalized code does not join to Terminology loinc table'\r\n else null end as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m\r\nleft join {{ ref('terminology__loinc')}} term on m.normalized_code = term.loinc", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.loinc is null\n then 'Normalized code does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.terminology.loinc term on m.normalized_code = term.loinc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_code_type"], "alias": "lab_result_normalized_code_type", "checksum": {"name": "sha256", "checksum": "98e30fa75321386c680fa65068f23d2a5b743afaa7cafd9a2ce64842bd490a37"}, "config": {"enabled": true, "alias": "lab_result_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5013242, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE_TYPE' as field_name\r\n , case when term.code_type is not null then 'valid'\r\n when m.normalized_code_type is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code_type is not null and term.code_type is null\r\n then 'Normalized code type does not join to Terminology code_type table'\r\n else null end as invalid_reason\r\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m\r\nleft join {{ ref('reference_data__code_type')}} term on m.normalized_code_type = term.code_type", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.reference_data.code_type term on m.normalized_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_component": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_component", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_component.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_component.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_component", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_component"], "alias": "lab_result_normalized_component", "checksum": {"name": "sha256", "checksum": "f7838ed40ec98cb2d65ad000174e257e6d7623621a3f7b1d9a84b63a5bbbb5c5"}, "config": {"enabled": true, "alias": "lab_result_normalized_component", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_component", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4681275, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_component", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_COMPONENT' as field_name\r\n , case when term.loinc is not null then 'valid'\r\n when m.normalized_component is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_component is not null and term.loinc is null\r\n then 'Normalized component does not join to Terminology loinc table'\r\n else null end as invalid_reason\r\n , cast(normalized_component as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m\r\nleft join {{ ref('terminology__loinc')}} term on m.normalized_component = term.loinc", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "terminology__loinc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_component.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_COMPONENT' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_component is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_component is not null and term.loinc is null\n then 'Normalized component does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_component as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.terminology.loinc term on m.normalized_component = term.loinc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_description"], "alias": "lab_result_normalized_description", "checksum": {"name": "sha256", "checksum": "3a1c32148aab61f95849c28ad19b8e95d09714b0080c3aa51110c9d3359797c9"}, "config": {"enabled": true, "alias": "lab_result_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4771986, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_DESCRIPTION' AS field_name\r\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_reference_range_high.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_reference_range_high"], "alias": "lab_result_normalized_reference_range_high", "checksum": {"name": "sha256", "checksum": "5f1adcd1edcff56553c549b7760401ea948842b82d97ae0d4df638a6e0b87853"}, "config": {"enabled": true, "alias": "lab_result_normalized_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4812083, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_reference_range_high", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\r\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_reference_range_high as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_reference_range_low.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_reference_range_low"], "alias": "lab_result_normalized_reference_range_low", "checksum": {"name": "sha256", "checksum": "9fc48a6729f494490f6047a72c40c579a77132f878cb53ba2b08df883bf2142e"}, "config": {"enabled": true, "alias": "lab_result_normalized_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4791963, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_reference_range_low", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_REFERENCE_RANGE_LOW' as field_name\r\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_reference_range_low as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' as field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_normalized_units": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_normalized_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_units.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_units.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_normalized_units"], "alias": "lab_result_normalized_units", "checksum": {"name": "sha256", "checksum": "2b3a3f1ee319941dfa2a2632286e6ecab66b3c0ee29669966905cc323c433473"}, "config": {"enabled": true, "alias": "lab_result_normalized_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_normalized_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.499123, "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_units", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_UNITS' as field_name\r\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_units as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_normalized_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_ordering_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_ordering_practitioner_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_ordering_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_ordering_practitioner_id"], "alias": "lab_result_ordering_practitioner_id", "checksum": {"name": "sha256", "checksum": "861433d114e254a3a0631c8561bec47f89ac9c5157ee943dba673cb6447c4ae8"}, "config": {"enabled": true, "alias": "lab_result_ordering_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_ordering_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4701304, "relation_name": "dev_thuxuan.data_quality.lab_result_ordering_practitioner_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'ORDERING_PRACTITIONER_ID' as field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.ordering_practitioner_id is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.ordering_practitioner_id is not null and term.npi is null\r\n then 'Ordering practitioner ID does not join to Terminology provider table'\r\n else null end as invalid_reason\r\n , cast(ordering_practitioner_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m\r\nleft join {{ ref('terminology__provider')}} term on m.ordering_practitioner_id = term.npi", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_ordering_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ORDERING_PRACTITIONER_ID' as field_name\n , case when term.npi is not null then 'valid'\n when m.ordering_practitioner_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ordering_practitioner_id is not null and term.npi is null\n then 'Ordering practitioner ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(ordering_practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.terminology.provider term on m.ordering_practitioner_id = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_patient_id"], "alias": "lab_result_patient_id", "checksum": {"name": "sha256", "checksum": "ef93d6b9c9b70c253e0de39045694cae1d4df685e0cb044f5ba1c539c14aea7d"}, "config": {"enabled": true, "alias": "lab_result_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5081255, "relation_name": "dev_thuxuan.data_quality.lab_result_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'PATIENT_ID' AS field_name\r\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_result": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_result.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_result.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_result", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_result"], "alias": "lab_result_result", "checksum": {"name": "sha256", "checksum": "15d22610a481a6ea51b0baeeb3acc8c8836714ca9f4d0f47539302b8044cd58c"}, "config": {"enabled": true, "alias": "lab_result_result", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_result", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4731293, "relation_name": "dev_thuxuan.data_quality.lab_result_result", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'RESULT' AS field_name\r\n , case when m.result is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(result as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_result.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT' AS field_name\n , case when m.result is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(result as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_result_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_result_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_result_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_result_date.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_result_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_result_date"], "alias": "lab_result_result_date", "checksum": {"name": "sha256", "checksum": "bb600485ff0251b03bc475f0364c721da50178814350edd4a81b062514532f8d"}, "config": {"enabled": true, "alias": "lab_result_result_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_result_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4921246, "relation_name": "dev_thuxuan.data_quality.lab_result_result_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'RESULT_DATE' as field_name\r\n , case\r\n when m.result_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.result_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.result_date < m.collection_date then 'invalid'\r\n when m.result_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.result_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.result_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.result_date < m.collection_date then 'Result date before collection date'\r\n else null\r\n end as invalid_reason\r\n , cast(result_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_result_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT_DATE' as field_name\n , case\n when m.result_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.result_date <= cast('1901-01-01' as date) then 'invalid'\n when m.result_date < m.collection_date then 'invalid'\n when m.result_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.result_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.result_date <= cast('1901-01-01' as date) then 'too old'\n when m.result_date < m.collection_date then 'Result date before collection date'\n else null\n end as invalid_reason\n , cast(result_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_abnormal_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_abnormal_flag.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_abnormal_flag.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_abnormal_flag"], "alias": "lab_result_source_abnormal_flag", "checksum": {"name": "sha256", "checksum": "d45c74219c445d4da09d5553aee4ec8d9132355f36231a4e5c6dc554706c6c9f"}, "config": {"enabled": true, "alias": "lab_result_source_abnormal_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_abnormal_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4551272, "relation_name": "dev_thuxuan.data_quality.lab_result_source_abnormal_flag", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_ABNORMAL_FLAG' AS field_name\r\n , case when m.source_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_abnormal_flag as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_abnormal_flag.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_ABNORMAL_FLAG' AS field_name\n , case when m.source_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_abnormal_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_code"], "alias": "lab_result_source_code", "checksum": {"name": "sha256", "checksum": "249bebf49cadd1df1e3d51fc5128f8b0dc80baed47daddabd0f595a41fd7d7c7"}, "config": {"enabled": true, "alias": "lab_result_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5060306, "relation_name": "dev_thuxuan.data_quality.lab_result_source_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE' AS field_name\r\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' AS field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_code_type"], "alias": "lab_result_source_code_type", "checksum": {"name": "sha256", "checksum": "66828809c861d66fa4052dd2fc7f1d35ef8e12adb63a394cb90c5082141112d4"}, "config": {"enabled": true, "alias": "lab_result_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4752014, "relation_name": "dev_thuxuan.data_quality.lab_result_source_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE_TYPE' as field_name\r\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_component": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_component", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_component.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_component.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_component", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_component"], "alias": "lab_result_source_component", "checksum": {"name": "sha256", "checksum": "292c1576126a59a52388d6fcfffb7a245779c68cebc313038b2e86ce790b5887"}, "config": {"enabled": true, "alias": "lab_result_source_component", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_component", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5101285, "relation_name": "dev_thuxuan.data_quality.lab_result_source_component", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_COMPONENT' AS field_name\r\n , case when m.source_component is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_component as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_component.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_COMPONENT' AS field_name\n , case when m.source_component is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_component as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_description"], "alias": "lab_result_source_description", "checksum": {"name": "sha256", "checksum": "112880374bdae73b4a71bf7f90f3eba399926bf9700de75ea3a4a4321613cdfd"}, "config": {"enabled": true, "alias": "lab_result_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4861145, "relation_name": "dev_thuxuan.data_quality.lab_result_source_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_DESCRIPTION' as field_name\r\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_reference_range_high.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_reference_range_high"], "alias": "lab_result_source_reference_range_high", "checksum": {"name": "sha256", "checksum": "bc9c69921689222fe68052b221bf553b7288c980bed35ff769b8464d97673fa0"}, "config": {"enabled": true, "alias": "lab_result_source_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5034175, "relation_name": "dev_thuxuan.data_quality.lab_result_source_reference_range_high", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_REFERENCE_RANGE_HIGH' AS field_name\r\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_reference_range_high as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' AS field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_reference_range_low.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_reference_range_low"], "alias": "lab_result_source_reference_range_low", "checksum": {"name": "sha256", "checksum": "e63021e99b30c9f26b0594530738cf4ad4871a29690a817f4eb29c866c0f4581"}, "config": {"enabled": true, "alias": "lab_result_source_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4591284, "relation_name": "dev_thuxuan.data_quality.lab_result_source_reference_range_low", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_REFERENCE_RANGE_LOW' AS field_name\r\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_reference_range_low as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' AS field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_source_units": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_source_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_units.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_units.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_source_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_source_units"], "alias": "lab_result_source_units", "checksum": {"name": "sha256", "checksum": "f05d9ccd4296f6c7faaab26c4569b653e71bb2ecbcebb5830474bfa2125ae936"}, "config": {"enabled": true, "alias": "lab_result_source_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_source_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4611275, "relation_name": "dev_thuxuan.data_quality.lab_result_source_units", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n ,'LAB_RESULT' AS table_name\r\n ,'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n ,'SOURCE_UNITS' AS field_name\r\n ,case when m.source_units is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(source_units as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_source_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n ,'LAB_RESULT' AS table_name\n ,'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n ,'SOURCE_UNITS' AS field_name\n ,case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_specimen": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_specimen", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_specimen.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_specimen.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_specimen", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_specimen"], "alias": "lab_result_specimen", "checksum": {"name": "sha256", "checksum": "b880f53d49c0854b0c6ed97de10b8a94bdd8c355ee21d31083afef9b447efdcb"}, "config": {"enabled": true, "alias": "lab_result_specimen", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_specimen", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.4571276, "relation_name": "dev_thuxuan.data_quality.lab_result_specimen", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'SPECIMEN' as field_name\r\n , case when m.specimen is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(specimen as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_specimen.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SPECIMEN' as field_name\n , case when m.specimen is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specimen as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__lab_result_status": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__lab_result_status", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_status.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_status.sql", "unique_id": "model.the_tuva_project.data_quality__lab_result_status", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "lab_result", "data_quality__lab_result_status"], "alias": "lab_result_status", "checksum": {"name": "sha256", "checksum": "435b5dc59a616497e23b391e640c57ab62c5b2a51ae133c7f0301aa85a731ea6"}, "config": {"enabled": true, "alias": "lab_result_status", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "lab_result_status", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.488114, "relation_name": "dev_thuxuan.data_quality.lab_result_status", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\r\n , 'LAB_RESULT' AS table_name\r\n , 'Lab Result ID' as drill_down_key\r\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\r\n , 'STATUS' as field_name\r\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(status as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('lab_result')}} m", "language": "sql", "refs": [{"name": "lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\lab_result\\data_quality__lab_result_status.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'STATUS' as field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_address": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_address", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_address.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_address.sql", "unique_id": "model.the_tuva_project.data_quality__location_address", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_address"], "alias": "location_address", "checksum": {"name": "sha256", "checksum": "be46a09bb48bba8eb173ac1f13e5a17e99649c767dfe8646bce7cef6e6ad3eea"}, "config": {"enabled": true, "alias": "location_address", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_address", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5352721, "relation_name": "dev_thuxuan.data_quality.location_address", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'ADDRESS' AS field_name\r\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(address as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_address.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ADDRESS' AS field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_city": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_city", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_city.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_city.sql", "unique_id": "model.the_tuva_project.data_quality__location_city", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_city"], "alias": "location_city", "checksum": {"name": "sha256", "checksum": "14e8588df86de5ce3882750d906b87ad93e16d24e00698db56ea63194d952666"}, "config": {"enabled": true, "alias": "location_city", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_city", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5262723, "relation_name": "dev_thuxuan.data_quality.location_city", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'CITY' AS field_name\r\n , case when m.city is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(city as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_city.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'CITY' AS field_name\n , case when m.city is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(city as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__location_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_data_source"], "alias": "location_data_source", "checksum": {"name": "sha256", "checksum": "401cceafb22c267b137109ccae5818e3a362ba244561b1db922c0ab0b874e857"}, "config": {"enabled": true, "alias": "location_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.524272, "relation_name": "dev_thuxuan.data_quality.location_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' AS field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_facility_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_facility_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_facility_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_facility_type.sql", "unique_id": "model.the_tuva_project.data_quality__location_facility_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_facility_type"], "alias": "location_facility_type", "checksum": {"name": "sha256", "checksum": "5dd7a45b39e4c5905c5a6b472750ef905ef27edaac8294b0558129e3df11cb2d"}, "config": {"enabled": true, "alias": "location_facility_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_facility_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5202715, "relation_name": "dev_thuxuan.data_quality.location_facility_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n ,'LOCATION' AS table_name\r\n ,'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n ,'FACILITY_TYPE' AS field_name\r\n ,case when m.facility_type is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(facility_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_facility_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'FACILITY_TYPE' AS field_name\n ,case when m.facility_type is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(facility_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_latitude": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_latitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_latitude.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_latitude.sql", "unique_id": "model.the_tuva_project.data_quality__location_latitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_latitude"], "alias": "location_latitude", "checksum": {"name": "sha256", "checksum": "b19ec11e3a4cbf1b37a70bcdbc923f20b3606bb2bd0255a9144bcbdeab73a6cb"}, "config": {"enabled": true, "alias": "location_latitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_latitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5172744, "relation_name": "dev_thuxuan.data_quality.location_latitude", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'LATITUDE' as field_name\r\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(latitude as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_latitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_location_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_location_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_location_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_location_id.sql", "unique_id": "model.the_tuva_project.data_quality__location_location_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_location_id"], "alias": "location_location_id", "checksum": {"name": "sha256", "checksum": "779fa755ff26136d53111570c35d71057d286ee2ebc9e689067a6047f1333818"}, "config": {"enabled": true, "alias": "location_location_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_location_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.531272, "relation_name": "dev_thuxuan.data_quality.location_location_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n ,'LOCATION' AS table_name\r\n ,'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n ,'LOCATION_ID' AS field_name\r\n ,case when m.location_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(location_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_location_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'LOCATION_ID' AS field_name\n ,case when m.location_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(location_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_longitude": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_longitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_longitude.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_longitude.sql", "unique_id": "model.the_tuva_project.data_quality__location_longitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_longitude"], "alias": "location_longitude", "checksum": {"name": "sha256", "checksum": "3936ff08219c2cae13912a6caace47188bcf742d0365a5020f0bc20b6b869b99"}, "config": {"enabled": true, "alias": "location_longitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_longitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.533272, "relation_name": "dev_thuxuan.data_quality.location_longitude", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'LONGITUDE' as field_name\r\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(longitude as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_longitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_name.sql", "unique_id": "model.the_tuva_project.data_quality__location_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_name"], "alias": "location_name", "checksum": {"name": "sha256", "checksum": "1287c28c55c5eed111216d7b3fe5ae2b539eb8a13af35ccdf14967951af747bc"}, "config": {"enabled": true, "alias": "location_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5392723, "relation_name": "dev_thuxuan.data_quality.location_name", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'NAME' as field_name\r\n , case when m.name is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NAME' as field_name\n , case when m.name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_npi.sql", "unique_id": "model.the_tuva_project.data_quality__location_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_npi"], "alias": "location_npi", "checksum": {"name": "sha256", "checksum": "9d32827ae5bc7f7f014621c8c7775f39a466e5d3ccc8b1d07e3a8e51772cb86f"}, "config": {"enabled": true, "alias": "location_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5282722, "relation_name": "dev_thuxuan.data_quality.location_npi", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'NPI' as field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.npi is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.npi is not null and term.npi is null\r\n then 'NPI does not join to Terminology provider table'\r\n else null end as invalid_reason\r\n , cast(m.npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m\r\nleft join {{ ref('terminology__provider')}} term on m.npi = term.npi", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_npi.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m\nleft join dev_thuxuan.terminology.provider term on m.npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_parent_organization": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_parent_organization", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_parent_organization.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_parent_organization.sql", "unique_id": "model.the_tuva_project.data_quality__location_parent_organization", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_parent_organization"], "alias": "location_parent_organization", "checksum": {"name": "sha256", "checksum": "0f90484cc3571596241072ba7191cab3875f957569216ebd4e3c0e3e95c637b0"}, "config": {"enabled": true, "alias": "location_parent_organization", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_parent_organization", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.515129, "relation_name": "dev_thuxuan.data_quality.location_parent_organization", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'PARENT_ORGANIZATION' AS field_name\r\n , case when m.parent_organization is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(parent_organization as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_parent_organization.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'PARENT_ORGANIZATION' AS field_name\n , case when m.parent_organization is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(parent_organization as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_state": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_state", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_state.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_state.sql", "unique_id": "model.the_tuva_project.data_quality__location_state", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_state"], "alias": "location_state", "checksum": {"name": "sha256", "checksum": "a72fd688b226eada9d31ecff4cfa91093e5024163ca6088ee5d18a8ef2edfb98"}, "config": {"enabled": true, "alias": "location_state", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_state", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5372722, "relation_name": "dev_thuxuan.data_quality.location_state", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'STATE' as field_name\r\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(state as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_state.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__location_zip_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__location_zip_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_zip_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_zip_code.sql", "unique_id": "model.the_tuva_project.data_quality__location_zip_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "location", "data_quality__location_zip_code"], "alias": "location_zip_code", "checksum": {"name": "sha256", "checksum": "c618dee55e4b9549d017f5084989a728fb556225cc8c1faa38a81b8f85946256"}, "config": {"enabled": true, "alias": "location_zip_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "location_zip_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5222723, "relation_name": "dev_thuxuan.data_quality.location_zip_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'LOCATION' AS table_name\r\n , 'Location ID' as drill_down_key\r\n , coalesce(location_id, 'NULL') AS drill_down_value\r\n , 'ZIP_CODE' as field_name\r\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(zip_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('location')}} m", "language": "sql", "refs": [{"name": "location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\location\\data_quality__location_zip_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_atc_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_atc_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_atc_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_atc_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_atc_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_atc_code"], "alias": "medication_atc_code", "checksum": {"name": "sha256", "checksum": "744e8952302a93056aaa704281f68f99dd78ccc5a07705fc6a717b239b88d78b"}, "config": {"enabled": true, "alias": "medication_atc_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_atc_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.546433, "relation_name": "dev_thuxuan.data_quality.medication_atc_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'ATC_CODE' as field_name\r\n , case when coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is not null then 'valid'\r\n when m.atc_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.atc_code is not null and coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is null\r\n then 'ATC Code does not join to Terminology rxnorm_to_atc table on any atc level'\r\n else null end as invalid_reason\r\n , cast(atc_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m\r\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_1 on m.atc_code = term_1.atc_1_name\r\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_2 on m.atc_code = term_2.atc_2_name\r\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_3 on m.atc_code = term_3.atc_3_name\r\nleft join {{ ref('terminology__rxnorm_to_atc')}} term_4 on m.atc_code = term_4.atc_4_name", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_atc_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_CODE' as field_name\n , case when coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is not null then 'valid'\n when m.atc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.atc_code is not null and coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is null\n then 'ATC Code does not join to Terminology rxnorm_to_atc table on any atc level'\n else null end as invalid_reason\n , cast(atc_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_1 on m.atc_code = term_1.atc_1_name\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_2 on m.atc_code = term_2.atc_2_name\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_3 on m.atc_code = term_3.atc_3_name\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_4 on m.atc_code = term_4.atc_4_name", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_atc_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_atc_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_atc_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_atc_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_atc_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_atc_description"], "alias": "medication_atc_description", "checksum": {"name": "sha256", "checksum": "7f1277728f7333591032411dbb3056aa31a585a14c0c8b0d05b61138777eddf4"}, "config": {"enabled": true, "alias": "medication_atc_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_atc_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5670393, "relation_name": "dev_thuxuan.data_quality.medication_atc_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'ATC_DESCRIPTION' as field_name\r\n , case when m.atc_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(atc_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_atc_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_DESCRIPTION' as field_name\n , case when m.atc_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(atc_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__medication_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_data_source"], "alias": "medication_data_source", "checksum": {"name": "sha256", "checksum": "3c062018232c5972f140ee30bc381cbc2a6edb2dd61d35ef38fd7c0dd9da563d"}, "config": {"enabled": true, "alias": "medication_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5650387, "relation_name": "dev_thuxuan.data_quality.medication_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' AS field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_days_supply": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_days_supply", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_days_supply.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_days_supply.sql", "unique_id": "model.the_tuva_project.data_quality__medication_days_supply", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_days_supply"], "alias": "medication_days_supply", "checksum": {"name": "sha256", "checksum": "10dc2790cd710c7ec132f0955e510938b15fe2d202885411f5c23400e82dabd4"}, "config": {"enabled": true, "alias": "medication_days_supply", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_days_supply", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5529487, "relation_name": "dev_thuxuan.data_quality.medication_days_supply", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'DAYS_SUPPLY' AS field_name\r\n , case when m.days_supply is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(days_supply as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_days_supply.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DAYS_SUPPLY' AS field_name\n , case when m.days_supply is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_dispensing_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_dispensing_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_dispensing_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_dispensing_date.sql", "unique_id": "model.the_tuva_project.data_quality__medication_dispensing_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_dispensing_date"], "alias": "medication_dispensing_date", "checksum": {"name": "sha256", "checksum": "afb7590cc2e6995c66b8f80ad3dabb6a29f60b8a22d465a50e76f4e97c85599a"}, "config": {"enabled": true, "alias": "medication_dispensing_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_dispensing_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5489485, "relation_name": "dev_thuxuan.data_quality.medication_dispensing_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'DISPENSING_DATE' as field_name\r\n , case\r\n when m.dispensing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.dispensing_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.dispensing_date < m.prescribing_date then 'invalid'\r\n when m.dispensing_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.dispensing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.dispensing_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.dispensing_date < m.prescribing_date then 'Dispensing date before prescribing date'\r\n else null\r\n end as invalid_reason\r\n , cast(dispensing_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_dispensing_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DISPENSING_DATE' as field_name\n , case\n when m.dispensing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.dispensing_date < m.prescribing_date then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'too old'\n when m.dispensing_date < m.prescribing_date then 'Dispensing date before prescribing date'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_encounter_id"], "alias": "medication_encounter_id", "checksum": {"name": "sha256", "checksum": "3a52cbceb801896da14e09e2685800ac75ad0f15bb1e08fafd2fc9e608073a38"}, "config": {"enabled": true, "alias": "medication_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5619445, "relation_name": "dev_thuxuan.data_quality.medication_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_ID' as field_name\r\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_encounter_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_medication_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_medication_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_medication_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_medication_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_medication_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_medication_id"], "alias": "medication_medication_id", "checksum": {"name": "sha256", "checksum": "733bf8cb8b3692df99f4514351e2c66ce47d740ca8759bb809b0d0d1d8d55265"}, "config": {"enabled": true, "alias": "medication_medication_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_medication_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5760565, "relation_name": "dev_thuxuan.data_quality.medication_medication_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'MEDICATION_ID' AS field_name\r\n , case when m.medication_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(medication_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_medication_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'MEDICATION_ID' AS field_name\n , case when m.medication_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(medication_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_ndc_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_ndc_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_ndc_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_ndc_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_ndc_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_ndc_code"], "alias": "medication_ndc_code", "checksum": {"name": "sha256", "checksum": "875289fa4c3cd593783d0cf35dfff8fe890a1069f7a7b8df69ef68a594e6b33e"}, "config": {"enabled": true, "alias": "medication_ndc_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_ndc_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.574027, "relation_name": "dev_thuxuan.data_quality.medication_ndc_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'NDC_CODE' as field_name\r\n , case when m.ndc_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(ndc_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_ndc_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_CODE' as field_name\n , case when m.ndc_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(ndc_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_ndc_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_ndc_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_ndc_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_ndc_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_ndc_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_ndc_description"], "alias": "medication_ndc_description", "checksum": {"name": "sha256", "checksum": "45b271c8d2ca0fcc1b880ee951adf462ea9e290e8ce90ca0183b4e162f8b3575"}, "config": {"enabled": true, "alias": "medication_ndc_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_ndc_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5809455, "relation_name": "dev_thuxuan.data_quality.medication_ndc_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'NDC_DESCRIPTION' as field_name\r\n , case when term.ndc is not null then 'valid'\r\n when m.ndc_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.ndc_code is not null and term.ndc is null\r\n then 'NDC code type does not join to Terminology ndc table'\r\n else null end as invalid_reason\r\n , cast(substring(ndc_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m\r\nleft join {{ ref('terminology__ndc')}} term on m.ndc_code = term.ndc", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_ndc_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_DESCRIPTION' as field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ndc_code is not null and term.ndc is null\n then 'NDC code type does not join to Terminology ndc table'\n else null end as invalid_reason\n , cast(substring(ndc_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join dev_thuxuan.terminology.ndc term on m.ndc_code = term.ndc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_patient_id"], "alias": "medication_patient_id", "checksum": {"name": "sha256", "checksum": "9e0f45d5fc922ae8b617383dce2d47d8038865021c3f4f4563190e7fc94d0170"}, "config": {"enabled": true, "alias": "medication_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.556949, "relation_name": "dev_thuxuan.data_quality.medication_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'PATIENT_ID' as field_name\r\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_practitioner_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_practitioner_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__medication_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_practitioner_id"], "alias": "medication_practitioner_id", "checksum": {"name": "sha256", "checksum": "c0c59b2aebeff9a94002208236aa3878707a8ce4c548f8764dd2fbe120634068"}, "config": {"enabled": true, "alias": "medication_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5849452, "relation_name": "dev_thuxuan.data_quality.medication_practitioner_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'PRACTITIONER_ID' as field_name\r\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(practitioner_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_prescribing_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_prescribing_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_prescribing_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_prescribing_date.sql", "unique_id": "model.the_tuva_project.data_quality__medication_prescribing_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_prescribing_date"], "alias": "medication_prescribing_date", "checksum": {"name": "sha256", "checksum": "44b598d10f66df86198347f39f570bd975053d502d4683b5275c566a260a01a8"}, "config": {"enabled": true, "alias": "medication_prescribing_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_prescribing_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5509484, "relation_name": "dev_thuxuan.data_quality.medication_prescribing_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'PRESCRIBING_DATE' as field_name\r\n , case\r\n when m.prescribing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.prescribing_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.prescribing_date > m.dispensing_date then 'invalid'\r\n when m.prescribing_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.prescribing_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.prescribing_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.prescribing_date > m.dispensing_date then 'Prescribing date after dispensing date'\r\n else null\r\n end as invalid_reason\r\n , cast(prescribing_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_prescribing_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRESCRIBING_DATE' as field_name\n , case\n when m.prescribing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.prescribing_date > m.dispensing_date then 'invalid'\n when m.prescribing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.prescribing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'too old'\n when m.prescribing_date > m.dispensing_date then 'Prescribing date after dispensing date'\n else null\n end as invalid_reason\n , cast(prescribing_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_quantity": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_quantity", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_quantity.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_quantity.sql", "unique_id": "model.the_tuva_project.data_quality__medication_quantity", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_quantity"], "alias": "medication_quantity", "checksum": {"name": "sha256", "checksum": "a069fead57b423bfe56a05cdb2e043df26f2298d40a03323b92045a50ee8de9d"}, "config": {"enabled": true, "alias": "medication_quantity", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_quantity", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5829456, "relation_name": "dev_thuxuan.data_quality.medication_quantity", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'QUANTITY' as field_name\r\n , case when m.quantity is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(quantity as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_quantity.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY' as field_name\n , case when m.quantity is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_quantity_unit": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_quantity_unit", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_quantity_unit.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_quantity_unit.sql", "unique_id": "model.the_tuva_project.data_quality__medication_quantity_unit", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_quantity_unit"], "alias": "medication_quantity_unit", "checksum": {"name": "sha256", "checksum": "5b9ed80bb5ec32310ac2515088b74dd70ddd1ec6cec3642a061d05367b6b917f"}, "config": {"enabled": true, "alias": "medication_quantity_unit", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_quantity_unit", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5700572, "relation_name": "dev_thuxuan.data_quality.medication_quantity_unit", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'QUANTITY_UNIT' as field_name\r\n , case when m.quantity_unit is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(quantity_unit as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_quantity_unit.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY_UNIT' as field_name\n , case when m.quantity_unit is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity_unit as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_route": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_route", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_route.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_route.sql", "unique_id": "model.the_tuva_project.data_quality__medication_route", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_route"], "alias": "medication_route", "checksum": {"name": "sha256", "checksum": "28b65ba5bf0af7c60ad634f90e1b5e42b0cc846ef7c8dd0ca26ac6396fe29990"}, "config": {"enabled": true, "alias": "medication_route", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_route", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5869453, "relation_name": "dev_thuxuan.data_quality.medication_route", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'ROUTE' as field_name\r\n , case when m.route is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(route as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_route.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ROUTE' as field_name\n , case when m.route is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(route as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_rxnorm_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_rxnorm_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_rxnorm_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_rxnorm_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_rxnorm_code"], "alias": "medication_rxnorm_code", "checksum": {"name": "sha256", "checksum": "a6b54fff08d8bd04cbf9a4afb0ab6f73035e12f6cee6689851de67cd87b9ee88"}, "config": {"enabled": true, "alias": "medication_rxnorm_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_rxnorm_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5412724, "relation_name": "dev_thuxuan.data_quality.medication_rxnorm_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'RXNORM_CODE' as field_name\r\n , case when term.rxcui is not null then 'valid'\r\n when m.rxnorm_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.rxnorm_code is not null and term.rxcui is null\r\n then 'RX norm code does not join to Terminology rxnorm_to_atc table'\r\n else null end as invalid_reason\r\n , cast(rxnorm_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m\r\nleft join {{ ref('terminology__rxnorm_to_atc')}} term on m.rxnorm_code = term.rxcui", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_rxnorm_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_CODE' as field_name\n , case when term.rxcui is not null then 'valid'\n when m.rxnorm_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.rxnorm_code is not null and term.rxcui is null\n then 'RX norm code does not join to Terminology rxnorm_to_atc table'\n else null end as invalid_reason\n , cast(rxnorm_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join dev_thuxuan.terminology.rxnorm_to_atc term on m.rxnorm_code = term.rxcui", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_rxnorm_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_rxnorm_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_rxnorm_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_rxnorm_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_rxnorm_description"], "alias": "medication_rxnorm_description", "checksum": {"name": "sha256", "checksum": "00f659a1c68e954fafabe03406b8460bc213c1a4dc920fc5680bf103ee987df3"}, "config": {"enabled": true, "alias": "medication_rxnorm_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_rxnorm_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5589485, "relation_name": "dev_thuxuan.data_quality.medication_rxnorm_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'RXNORM_DESCRIPTION' as field_name\r\n , case when m.rxnorm_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(rxnorm_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_rxnorm_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_DESCRIPTION' as field_name\n , case when m.rxnorm_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(rxnorm_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__medication_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_source_code"], "alias": "medication_source_code", "checksum": {"name": "sha256", "checksum": "b188e60479803289fa224b105ea9d3c8d8ccae2039ec80bd23a46c627cf1176a"}, "config": {"enabled": true, "alias": "medication_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5432723, "relation_name": "dev_thuxuan.data_quality.medication_source_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE' as field_name\r\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_source_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__medication_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_source_code_type"], "alias": "medication_source_code_type", "checksum": {"name": "sha256", "checksum": "ca21f03e09288568c06e0768dbb6918006f10cd5116ee9dd2246544f882b4abb"}, "config": {"enabled": true, "alias": "medication_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5789464, "relation_name": "dev_thuxuan.data_quality.medication_source_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE_TYPE' as field_name\r\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_source_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__medication_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_source_description"], "alias": "medication_source_description", "checksum": {"name": "sha256", "checksum": "1db3a7873364930cfceab3b7beeb3bdfa17d27c5fc8c06a1c25d2787007adc9b"}, "config": {"enabled": true, "alias": "medication_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5720365, "relation_name": "dev_thuxuan.data_quality.medication_source_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_DESCRIPTION' as field_name\r\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medication_strength": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medication_strength", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_strength.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_strength.sql", "unique_id": "model.the_tuva_project.data_quality__medication_strength", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "medication", "data_quality__medication_strength"], "alias": "medication_strength", "checksum": {"name": "sha256", "checksum": "9f35a1a13dc084a66144e3b835c91df37d126d6e14ca7c3220a15d12a6be8b35"}, "config": {"enabled": true, "alias": "medication_strength", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medication_strength", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5549488, "relation_name": "dev_thuxuan.data_quality.medication_strength", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\r\n , 'MEDICATION' AS table_name\r\n , 'Medication ID' as drill_down_key\r\n , coalesce(medication_id, 'NULL') AS drill_down_value\r\n , 'STRENGTH' as field_name\r\n , case when m.strength is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(strength as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medication')}} m", "language": "sql", "refs": [{"name": "medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\medication\\data_quality__medication_strength.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'STRENGTH' as field_name\n , case when m.strength is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(strength as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__observation_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_data_source"], "alias": "observation_data_source", "checksum": {"name": "sha256", "checksum": "117ae2f110f55f66300b7590337a87f11be5985fcdb6586deaa7124b0dd1f13e"}, "config": {"enabled": true, "alias": "observation_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6029503, "relation_name": "dev_thuxuan.data_quality.observation_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' as field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_encounter_id"], "alias": "observation_encounter_id", "checksum": {"name": "sha256", "checksum": "53d638ce2277a8b933b43218908ebb44241a92fb9baed517a6fb83e193123d91"}, "config": {"enabled": true, "alias": "observation_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6204636, "relation_name": "dev_thuxuan.data_quality.observation_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n ,'OBSERVATION' AS table_name\r\n ,'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n ,'ENCOUNTER_ID' as field_name\r\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(encounter_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_encounter_id.sql", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' as field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_code"], "alias": "observation_normalized_code", "checksum": {"name": "sha256", "checksum": "7a6825d8288ad40b1a4184b04b18b93c04a80d508ccfa3b2fc2e9b4e794f3ecb"}, "config": {"enabled": true, "alias": "observation_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5979505, "relation_name": "dev_thuxuan.data_quality.observation_normalized_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' as field_name\r\n , case when m.normalized_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when m.normalized_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_code_type"], "alias": "observation_normalized_code_type", "checksum": {"name": "sha256", "checksum": "9cab1a56b74c618cd8b7f616512741026645546bb1c4e9f9b5d3164374ef0383"}, "config": {"enabled": true, "alias": "observation_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6295934, "relation_name": "dev_thuxuan.data_quality.observation_normalized_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE_TYPE' AS field_name\r\n , case when m.normalized_code_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when m.normalized_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_description"], "alias": "observation_normalized_description", "checksum": {"name": "sha256", "checksum": "a4b5df3210b00e0aab586529bad0302d448e6be82f143f2abeb838df99d6ef13"}, "config": {"enabled": true, "alias": "observation_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6009502, "relation_name": "dev_thuxuan.data_quality.observation_normalized_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_DESCRIPTION' as field_name\r\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' as field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_normalized_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_reference_range_high.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_reference_range_high"], "alias": "observation_normalized_reference_range_high", "checksum": {"name": "sha256", "checksum": "d3a0050cc40bbecb141ab0b8b9b480d9b4342e2c159a66f928fab9d96e552da5"}, "config": {"enabled": true, "alias": "observation_normalized_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5919507, "relation_name": "dev_thuxuan.data_quality.observation_normalized_reference_range_high", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\r\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_reference_range_high as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_normalized_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_reference_range_low.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_reference_range_low"], "alias": "observation_normalized_reference_range_low", "checksum": {"name": "sha256", "checksum": "8013e9d86b4cee9129b495959d92b3a54b9069f71df393508ee4a7b5a1b37818"}, "config": {"enabled": true, "alias": "observation_normalized_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6164637, "relation_name": "dev_thuxuan.data_quality.observation_normalized_reference_range_low", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_REFERENCE_RANGE_LOW' AS field_name\r\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_reference_range_low as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' AS field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_normalized_units": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_normalized_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_units.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_units.sql", "unique_id": "model.the_tuva_project.data_quality__observation_normalized_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_normalized_units"], "alias": "observation_normalized_units", "checksum": {"name": "sha256", "checksum": "775bcc6f672c815eee659ccee3e133a497b9ff645ca4f7cbddc714190f9a4269"}, "config": {"enabled": true, "alias": "observation_normalized_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_normalized_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6275938, "relation_name": "dev_thuxuan.data_quality.observation_normalized_units", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_UNITS' as field_name\r\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(normalized_units as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_normalized_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_observation_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_observation_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_date.sql", "unique_id": "model.the_tuva_project.data_quality__observation_observation_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_observation_date"], "alias": "observation_observation_date", "checksum": {"name": "sha256", "checksum": "18b45a6413c966883927f51f871ca9e50f265fecb98de98a80ae051fc1ef6314"}, "config": {"enabled": true, "alias": "observation_observation_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_observation_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6184638, "relation_name": "dev_thuxuan.data_quality.observation_observation_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'OBSERVATION_DATE' as field_name\r\n , case\r\n when m.observation_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.observation_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.observation_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.observation_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.observation_date <= cast('1901-01-01' as date) then 'too old'\r\n else null\r\n end as invalid_reason\r\n , cast(observation_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_DATE' as field_name\n , case\n when m.observation_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.observation_date <= cast('1901-01-01' as date) then 'invalid'\n when m.observation_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.observation_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.observation_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(observation_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_observation_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_observation_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_observation_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_observation_id"], "alias": "observation_observation_id", "checksum": {"name": "sha256", "checksum": "2154166926421557664186f8532f0ec8c1fe768c3b679ffb054acd98d871aef2"}, "config": {"enabled": true, "alias": "observation_observation_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_observation_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6074603, "relation_name": "dev_thuxuan.data_quality.observation_observation_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'OBSERVATION_ID' as field_name\r\n , case when m.observation_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(observation_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_ID' as field_name\n , case when m.observation_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_observation_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_observation_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_type.sql", "unique_id": "model.the_tuva_project.data_quality__observation_observation_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_observation_type"], "alias": "observation_observation_type", "checksum": {"name": "sha256", "checksum": "39bfd873b556066d57f802f2103cff127de8ebd92b97fe367c34db8302b4fdf1"}, "config": {"enabled": true, "alias": "observation_observation_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_observation_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5959506, "relation_name": "dev_thuxuan.data_quality.observation_observation_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'OBSERVATION_TYPE' as field_name\r\n , case when m.observation_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(observation_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_observation_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_TYPE' as field_name\n , case when m.observation_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_panel_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_panel_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_panel_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_panel_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_panel_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_panel_id"], "alias": "observation_panel_id", "checksum": {"name": "sha256", "checksum": "66c195c532c4d09dd8efff1b11f5f0862f518e9be3b9ad584cf246dfa9b2495d"}, "config": {"enabled": true, "alias": "observation_panel_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_panel_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6049504, "relation_name": "dev_thuxuan.data_quality.observation_panel_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'PANEL_ID' as field_name\r\n , case when m.panel_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(panel_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_panel_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PANEL_ID' as field_name\n , case when m.panel_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(panel_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__observation_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_patient_id"], "alias": "observation_patient_id", "checksum": {"name": "sha256", "checksum": "24d6d184ebf8bad164e5229bd297a8567efdcbf598028c8dafec92b46a28fdfd"}, "config": {"enabled": true, "alias": "observation_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6315937, "relation_name": "dev_thuxuan.data_quality.observation_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'PATIENT_ID' as field_name\r\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_result": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_result.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_result.sql", "unique_id": "model.the_tuva_project.data_quality__observation_result", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_result"], "alias": "observation_result", "checksum": {"name": "sha256", "checksum": "2dd20593ac019e521eabe1f0bcb7088be8b288f7a492e3d7b5ecb3bb3f7e1f9d"}, "config": {"enabled": true, "alias": "observation_result", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_result", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6114633, "relation_name": "dev_thuxuan.data_quality.observation_result", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n ,'OBSERVATION' AS table_name\r\n ,'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n ,'RESULT' as field_name\r\n ,case when m.result is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(substring(result, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_result.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'RESULT' as field_name\n ,case when m.result is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(result, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_code"], "alias": "observation_source_code", "checksum": {"name": "sha256", "checksum": "40c932aa0acb701e54fd7455c2b042809fb677ea892b8dd43d57d0b6399d7bd5"}, "config": {"enabled": true, "alias": "observation_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5899456, "relation_name": "dev_thuxuan.data_quality.observation_source_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE' as field_name\r\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_code_type"], "alias": "observation_source_code_type", "checksum": {"name": "sha256", "checksum": "4b0cfe447d8a13e882b12c5bc47f5b2670f10d64d2c31f9ad7afdf6a9feafd2d"}, "config": {"enabled": true, "alias": "observation_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6134634, "relation_name": "dev_thuxuan.data_quality.observation_source_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE_TYPE' as field_name\r\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_description"], "alias": "observation_source_description", "checksum": {"name": "sha256", "checksum": "f3395b2b6d362817080829bc90897d865654d9d97d485f92a81d3d45006d5713"}, "config": {"enabled": true, "alias": "observation_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6224635, "relation_name": "dev_thuxuan.data_quality.observation_source_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_DESCRIPTION' as field_name\r\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_reference_range_high": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_source_reference_range_high", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_reference_range_high.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_reference_range_high.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_high", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_reference_range_high"], "alias": "observation_source_reference_range_high", "checksum": {"name": "sha256", "checksum": "277af88f66f2862b6f10467c7026db0784d321409f5d0059ef6b64170e83fb76"}, "config": {"enabled": true, "alias": "observation_source_reference_range_high", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_reference_range_high", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6244636, "relation_name": "dev_thuxuan.data_quality.observation_source_reference_range_high", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_REFERENCE_RANGE_HIGH' as field_name\r\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_reference_range_high as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_reference_range_high.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' as field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_reference_range_low": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_source_reference_range_low", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_reference_range_low.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_reference_range_low.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_low", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_reference_range_low"], "alias": "observation_source_reference_range_low", "checksum": {"name": "sha256", "checksum": "c8cc190363b91d8ebd8f392e48d7505bf82a5a7aa4f76b1f176be4da19d89a98"}, "config": {"enabled": true, "alias": "observation_source_reference_range_low", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_reference_range_low", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.60946, "relation_name": "dev_thuxuan.data_quality.observation_source_reference_range_low", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS table_name\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_REFERENCE_RANGE_LOW' as field_name\r\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_reference_range_low as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_reference_range_low.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' as field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__observation_source_units": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__observation_source_units", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_units.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_units.sql", "unique_id": "model.the_tuva_project.data_quality__observation_source_units", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "observation", "data_quality__observation_source_units"], "alias": "observation_source_units", "checksum": {"name": "sha256", "checksum": "f8333dd3a57b75468d51e48e1e7258d48d819e19bdee885160a62e2c2a41630c"}, "config": {"enabled": true, "alias": "observation_source_units", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "observation_source_units", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.5939505, "relation_name": "dev_thuxuan.data_quality.observation_source_units", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\r\n , 'OBSERVATION' AS TABLE_NAME\r\n , 'Observation ID' as drill_down_key\r\n , coalesce(observation_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_UNITS' as field_name\r\n , case when m.source_units is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_units as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('observation')}} m", "language": "sql", "refs": [{"name": "observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\observation\\data_quality__observation_source_units.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS TABLE_NAME\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_UNITS' as field_name\n , case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_address": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_address", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_address.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_address.sql", "unique_id": "model.the_tuva_project.data_quality__patient_address", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_address"], "alias": "patient_address", "checksum": {"name": "sha256", "checksum": "8c489485190a248c9872bea91857825c48392b8f3b9c73a7422360b2b9a2f0f7"}, "config": {"enabled": true, "alias": "patient_address", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_address", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6485908, "relation_name": "dev_thuxuan.data_quality.patient_address", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'ADDRESS' as field_name\r\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(address as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_address.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ADDRESS' as field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_birth_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_birth_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_birth_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_birth_date.sql", "unique_id": "model.the_tuva_project.data_quality__patient_birth_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_birth_date"], "alias": "patient_birth_date", "checksum": {"name": "sha256", "checksum": "ac85b28abc5c1db1c3e7437f06a4e872a5e2f6a8b802a6a43f0299b0113185dd"}, "config": {"enabled": true, "alias": "patient_birth_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_birth_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.661764, "relation_name": "dev_thuxuan.data_quality.patient_birth_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'BIRTH_DATE' AS field_name\r\n , case\r\n when m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.birth_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.birth_date > m.death_date then 'invalid'\r\n when m.birth_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.birth_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.birth_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.birth_date > m.death_date then 'Birth date after death date'\r\n else null\r\n end as invalid_reason\r\n , cast(birth_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_birth_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'BIRTH_DATE' AS field_name\n , case\n when m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.birth_date <= cast('1901-01-01' as date) then 'invalid'\n when m.birth_date > m.death_date then 'invalid'\n when m.birth_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.birth_date <= cast('1901-01-01' as date) then 'too old'\n when m.birth_date > m.death_date then 'Birth date after death date'\n else null\n end as invalid_reason\n , cast(birth_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_city": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_city", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_city.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_city.sql", "unique_id": "model.the_tuva_project.data_quality__patient_city", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_city"], "alias": "patient_city", "checksum": {"name": "sha256", "checksum": "39deb2911c2fa37d2db403738f926e73d91381616bd309429bda106810a0cb7c"}, "config": {"enabled": true, "alias": "patient_city", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_city", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6375942, "relation_name": "dev_thuxuan.data_quality.patient_city", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n ,'PATIENT' AS table_name\r\n ,'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n ,'CITY' AS field_name\r\n ,case when m.city is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(city as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_city.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'CITY' AS field_name\n ,case when m.city is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(city as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_county": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_county", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_county.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_county.sql", "unique_id": "model.the_tuva_project.data_quality__patient_county", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_county"], "alias": "patient_county", "checksum": {"name": "sha256", "checksum": "b154c6146a1e40e8b92be6424d48c464b83b3827f356388a055c86165950a5f8"}, "config": {"enabled": true, "alias": "patient_county", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_county", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6425908, "relation_name": "dev_thuxuan.data_quality.patient_county", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n ,'PATIENT' AS table_name\r\n ,'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n ,'COUNTY' as field_name\r\n ,case when m.county is not null then 'valid' else 'null' end as bucket_name\r\n ,cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n ,cast(county as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_county.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'COUNTY' as field_name\n ,case when m.county is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(county as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__patient_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_data_source"], "alias": "patient_data_source", "checksum": {"name": "sha256", "checksum": "d2929b65392afb401e3aca0abe00a02a51db9edbaa8198cf76efc5b1be6aa4be"}, "config": {"enabled": true, "alias": "patient_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6505907, "relation_name": "dev_thuxuan.data_quality.patient_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' as field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_death_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_death_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_death_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_death_date.sql", "unique_id": "model.the_tuva_project.data_quality__patient_death_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_death_date"], "alias": "patient_death_date", "checksum": {"name": "sha256", "checksum": "87c739e4331584d6ca61fb6ebf657982bd3d3812e01c9c8f9187924bd8b7fa5b"}, "config": {"enabled": true, "alias": "patient_death_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_death_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6637642, "relation_name": "dev_thuxuan.data_quality.patient_death_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'DEATH_DATE' AS field_name\r\n , case\r\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.death_date > m.birth_date then 'invalid'\r\n when m.death_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.death_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\r\n when m.death_date > m.birth_date then 'Death date after birth date'\r\n else null\r\n end as invalid_reason\r\n , cast(death_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_death_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_DATE' AS field_name\n , case\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date > m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date > m.birth_date then 'Death date after birth date'\n else null\n end as invalid_reason\n , cast(death_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_death_flag": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_death_flag", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_death_flag.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_death_flag.sql", "unique_id": "model.the_tuva_project.data_quality__patient_death_flag", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_death_flag"], "alias": "patient_death_flag", "checksum": {"name": "sha256", "checksum": "d2660a27fa3cc9655137231e96372c783c7d3afcc9500d00365e07c765f0c4d7"}, "config": {"enabled": true, "alias": "patient_death_flag", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_death_flag", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6465907, "relation_name": "dev_thuxuan.data_quality.patient_death_flag", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'DEATH_FLAG' as field_name\r\n , case when m.death_flag is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(death_flag as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_death_flag.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_FLAG' as field_name\n , case when m.death_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(death_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_first_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_first_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_first_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_first_name.sql", "unique_id": "model.the_tuva_project.data_quality__patient_first_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_first_name"], "alias": "patient_first_name", "checksum": {"name": "sha256", "checksum": "f028252fa68b87dcb7e7c5f2e6e6437f0e31cc1ddb14d087bc8ca9c120c92c2f"}, "config": {"enabled": true, "alias": "patient_first_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_first_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6555972, "relation_name": "dev_thuxuan.data_quality.patient_first_name", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'FIRST_NAME' as field_name\r\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(first_name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_first_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_last_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_last_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_last_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_last_name.sql", "unique_id": "model.the_tuva_project.data_quality__patient_last_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_last_name"], "alias": "patient_last_name", "checksum": {"name": "sha256", "checksum": "98e1c93e51f44fe62a23d9dd854455efb0529cef9ed11a66ee6f97f62b2866e7"}, "config": {"enabled": true, "alias": "patient_last_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_last_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.657755, "relation_name": "dev_thuxuan.data_quality.patient_last_name", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'LAST_NAME' AS field_name\r\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(last_name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_last_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' AS field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_latitude": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_latitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_latitude.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_latitude.sql", "unique_id": "model.the_tuva_project.data_quality__patient_latitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_latitude"], "alias": "patient_latitude", "checksum": {"name": "sha256", "checksum": "6bd2f5f1f92788e702a13adda394c4710bf800ff563a13872b50ae9f0fcf16a7"}, "config": {"enabled": true, "alias": "patient_latitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_latitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.659764, "relation_name": "dev_thuxuan.data_quality.patient_latitude", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'LATITUDE' as field_name\r\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(latitude as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_latitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_longitude": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_longitude", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_longitude.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_longitude.sql", "unique_id": "model.the_tuva_project.data_quality__patient_longitude", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_longitude"], "alias": "patient_longitude", "checksum": {"name": "sha256", "checksum": "a7188a1f405a0f6f811f0d6dc4309949d529e8997473cd2d19294030b82ba1db"}, "config": {"enabled": true, "alias": "patient_longitude", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_longitude", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.639594, "relation_name": "dev_thuxuan.data_quality.patient_longitude", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'LONGITUDE' as field_name\r\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(longitude as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_longitude.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__patient_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_patient_id"], "alias": "patient_patient_id", "checksum": {"name": "sha256", "checksum": "c225d27d9f8d6e01777338a47a61eeb1020c5668bfd96edf36cb00b569d1ce03"}, "config": {"enabled": true, "alias": "patient_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6667638, "relation_name": "dev_thuxuan.data_quality.patient_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'PATIENT_ID' as field_name\r\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_race": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_race", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_race.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_race.sql", "unique_id": "model.the_tuva_project.data_quality__patient_race", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_race"], "alias": "patient_race", "checksum": {"name": "sha256", "checksum": "5da441c0307da9046cc5b0bd9d82ca4726100ddd3d69a75d70f3d9958fa3953b"}, "config": {"enabled": true, "alias": "patient_race", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_race", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6445906, "relation_name": "dev_thuxuan.data_quality.patient_race", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'RACE' as field_name\r\n , case when term.description is not null then 'valid'\r\n when m.race is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.race is not null and term.description is null\r\n then 'Race description does not join to Terminology race table'\r\n else null end as invalid_reason\r\n , cast(race as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m\r\nleft join {{ ref('terminology__race')}} term on m.race = term.description", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}, {"name": "terminology__race", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient", "seed.the_tuva_project.terminology__race"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_race.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'RACE' as field_name\n , case when term.description is not null then 'valid'\n when m.race is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.race is not null and term.description is null\n then 'Race description does not join to Terminology race table'\n else null end as invalid_reason\n , cast(race as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join dev_thuxuan.terminology.race term on m.race = term.description", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_sex": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_sex", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_sex.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_sex.sql", "unique_id": "model.the_tuva_project.data_quality__patient_sex", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_sex"], "alias": "patient_sex", "checksum": {"name": "sha256", "checksum": "40160afff8a5db4e6a5976cb87bb2a703d8ab4c715751b9e116f0969ad8aff27"}, "config": {"enabled": true, "alias": "patient_sex", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_sex", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.633594, "relation_name": "dev_thuxuan.data_quality.patient_sex", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'SEX' as field_name\r\n , case when term.gender is not null then 'valid'\r\n when m.sex is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.sex is not null and term.gender is null\r\n then 'Sex does not join to Terminology gender table'\r\n else null end as invalid_reason\r\n , cast(sex as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m\r\nleft join {{ ref('terminology__gender')}} term on m.sex = term.gender", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}, {"name": "terminology__gender", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient", "seed.the_tuva_project.terminology__gender"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_sex.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'SEX' as field_name\n , case when term.gender is not null then 'valid'\n when m.sex is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.sex is not null and term.gender is null\n then 'Sex does not join to Terminology gender table'\n else null end as invalid_reason\n , cast(sex as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join dev_thuxuan.terminology.gender term on m.sex = term.gender", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_state": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_state", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_state.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_state.sql", "unique_id": "model.the_tuva_project.data_quality__patient_state", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_state"], "alias": "patient_state", "checksum": {"name": "sha256", "checksum": "abb1d3fe5da70e28e9443ae3fde690efaeb47bd187030ba7625f39d1fa3c1ef1"}, "config": {"enabled": true, "alias": "patient_state", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_state", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.635594, "relation_name": "dev_thuxuan.data_quality.patient_state", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'STATE' as field_name\r\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(state as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_state.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__patient_zip_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__patient_zip_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_zip_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_zip_code.sql", "unique_id": "model.the_tuva_project.data_quality__patient_zip_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "patient", "data_quality__patient_zip_code"], "alias": "patient_zip_code", "checksum": {"name": "sha256", "checksum": "9d6bfe9f3443f48aa1d92c112149a666ad3c4a677ee36211fc19fb3bbf6d16ee"}, "config": {"enabled": true, "alias": "patient_zip_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "patient_zip_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6535907, "relation_name": "dev_thuxuan.data_quality.patient_zip_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PATIENT' AS table_name\r\n , 'Patient ID' as drill_down_key\r\n , coalesce(patient_id, 'NULL') AS drill_down_value\r\n , 'ZIP_CODE' as field_name\r\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(zip_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('patient')}} m", "language": "sql", "refs": [{"name": "patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\patient\\data_quality__patient_zip_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_data_source"], "alias": "practitioner_data_source", "checksum": {"name": "sha256", "checksum": "a96e904e1e6fa5ddd85ecb9e1b06ed4f0ff666c8c56b00ab4ce6b1cc1652d1f6"}, "config": {"enabled": true, "alias": "practitioner_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6777647, "relation_name": "dev_thuxuan.data_quality.practitioner_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' as field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_first_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_first_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_first_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_first_name.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_first_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_first_name"], "alias": "practitioner_first_name", "checksum": {"name": "sha256", "checksum": "272bcc5a0cbf7e9aa50a259cd529f1f5b51b18c94dfa2ba0241cf3a29daea921"}, "config": {"enabled": true, "alias": "practitioner_first_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_first_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6817644, "relation_name": "dev_thuxuan.data_quality.practitioner_first_name", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'FIRST_NAME' as field_name\r\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(first_name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_first_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_last_name": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_last_name", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_last_name.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_last_name.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_last_name", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_last_name"], "alias": "practitioner_last_name", "checksum": {"name": "sha256", "checksum": "aa33b56e668682f55a183fbcc79587e1934f4f359ac6c04c5247fd8ea5dedc5e"}, "config": {"enabled": true, "alias": "practitioner_last_name", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_last_name", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6727648, "relation_name": "dev_thuxuan.data_quality.practitioner_last_name", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'LAST_NAME' as field_name\r\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(last_name as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_last_name.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' as field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_npi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_npi.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_npi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_npi"], "alias": "practitioner_npi", "checksum": {"name": "sha256", "checksum": "2ecff3e98536e8f0e8ef5715369355c07b031cca5f10d3123c2bee9587eeab69"}, "config": {"enabled": true, "alias": "practitioner_npi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_npi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6797643, "relation_name": "dev_thuxuan.data_quality.practitioner_npi", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'NPI' as field_name\r\n , case when term.npi is not null then 'valid'\r\n when m.npi is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.npi is not null and term.npi is null\r\n then 'NPI does not join to Terminology provider table'\r\n else null end as invalid_reason\r\n , cast(m.npi as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m\r\nleft join {{ ref('terminology__provider')}} term on m.npi = term.npi", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_npi.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m\nleft join dev_thuxuan.terminology.provider term on m.npi = term.npi", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_practice_affiliation": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_practice_affiliation", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_practice_affiliation.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_practice_affiliation.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_practice_affiliation"], "alias": "practitioner_practice_affiliation", "checksum": {"name": "sha256", "checksum": "7c9dbd14899189d5597a027c4d3b61a9b4a9fe19f858dc1c451a362433c53bcd"}, "config": {"enabled": true, "alias": "practitioner_practice_affiliation", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_practice_affiliation", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6687639, "relation_name": "dev_thuxuan.data_quality.practitioner_practice_affiliation", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'PRACTICE_AFFILIATION' AS field_name\r\n , case when m.practice_affiliation is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(practice_affiliation as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_practice_affiliation.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTICE_AFFILIATION' AS field_name\n , case when m.practice_affiliation is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practice_affiliation as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_practitioner_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_practitioner_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_practitioner_id"], "alias": "practitioner_practitioner_id", "checksum": {"name": "sha256", "checksum": "129d01bf2701dcc582a7a9972e0544d26b55737ceb1244e52f0d14dfcdd480f3"}, "config": {"enabled": true, "alias": "practitioner_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6747644, "relation_name": "dev_thuxuan.data_quality.practitioner_practitioner_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'PRACTITIONER_ID' as field_name\r\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(practitioner_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_specialty": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_specialty", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_specialty.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_specialty.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_specialty", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_specialty"], "alias": "practitioner_specialty", "checksum": {"name": "sha256", "checksum": "a347c068bd459658378cf41c2da7b54bfe9ec8da04934ed4131262a69ff9def6"}, "config": {"enabled": true, "alias": "practitioner_specialty", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_specialty", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6837642, "relation_name": "dev_thuxuan.data_quality.practitioner_specialty", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'SPECIALTY' as field_name\r\n , case when m.specialty is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(specialty as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_specialty.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SPECIALTY' as field_name\n , case when m.specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specialty as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__practitioner_sub_specialty": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__practitioner_sub_specialty", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_sub_specialty.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_sub_specialty.sql", "unique_id": "model.the_tuva_project.data_quality__practitioner_sub_specialty", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "practitioner", "data_quality__practitioner_sub_specialty"], "alias": "practitioner_sub_specialty", "checksum": {"name": "sha256", "checksum": "b74e6b257512a817e32f266c50fce1c83542075379f2fb1453b70a4c56bb743d"}, "config": {"enabled": true, "alias": "practitioner_sub_specialty", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "practitioner_sub_specialty", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.670764, "relation_name": "dev_thuxuan.data_quality.practitioner_sub_specialty", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n {% if target.type == 'bigquery' %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as timestamp)) as date) as source_date\r\n {% else %}\r\n , cast(coalesce({{ dbt.current_timestamp() }}, cast('1900-01-01' as date)) as date) as source_date\r\n {% endif %}\r\n , 'PRACTITIONER' AS table_name\r\n , 'Practitioner ID' as drill_down_key\r\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\r\n , 'SUB_SPECIALTY' as field_name\r\n , case when m.sub_specialty is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(sub_specialty as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('practitioner')}} m", "language": "sql", "refs": [{"name": "practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.type_string"], "nodes": ["model.input_layer.practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\practitioner\\data_quality__practitioner_sub_specialty.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SUB_SPECIALTY' as field_name\n , case when m.sub_specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(sub_specialty as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_claim_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_claim_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_claim_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_claim_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_claim_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_claim_id"], "alias": "procedure_claim_id", "checksum": {"name": "sha256", "checksum": "a1977e8040c06ad57e4f89c786270efc83b79fbe5962f45933402b508377ddc6"}, "config": {"enabled": true, "alias": "procedure_claim_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_claim_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6944716, "relation_name": "dev_thuxuan.data_quality.procedure_claim_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'CLAIM_ID' as field_name\r\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(claim_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_claim_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' as field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_data_source.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_data_source.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_data_source"], "alias": "procedure_data_source", "checksum": {"name": "sha256", "checksum": "07477cd16f4dce2274622de1cdaac991736499134fea2ba22a7c3f46ab0d6441"}, "config": {"enabled": true, "alias": "procedure_data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7044683, "relation_name": "dev_thuxuan.data_quality.procedure_data_source", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'DATA_SOURCE' as field_name\r\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(data_source as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_data_source.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_encounter_id"], "alias": "procedure_encounter_id", "checksum": {"name": "sha256", "checksum": "1b067e87062b82d5bfa976b139d7a267edbed4ce0f35cf44516d200ab667c1fc"}, "config": {"enabled": true, "alias": "procedure_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7119792, "relation_name": "dev_thuxuan.data_quality.procedure_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'ENCOUNTER_ID' as field_name\r\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(encounter_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_encounter_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_1": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_modifier_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_1.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_1.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_1", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_1"], "alias": "procedure_modifier_1", "checksum": {"name": "sha256", "checksum": "8b98fa99c2b9fe7f7011b37bac77d6f54aa0ca8af18443f87ead2c6775c14f38"}, "config": {"enabled": true, "alias": "procedure_modifier_1", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_1", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7219741, "relation_name": "dev_thuxuan.data_quality.procedure_modifier_1", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as SOURCE_DATE\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'MODIFIER_1' as field_name\r\n , case when term.hcpcs is not null then 'valid'\r\n when m.modifier_1 is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.modifier_1 is not null and term.hcpcs is null\r\n then 'Modifier 1 does not join to Terminology hcpcs_level_2 table'\r\n else null end as invalid_reason\r\n , cast(modifier_1 as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_1 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_1.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as SOURCE_DATE\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_1' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_1 is not null and term.hcpcs is null\n then 'Modifier 1 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_1 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_1 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_2": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_modifier_2", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_2.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_2.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_2", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_2"], "alias": "procedure_modifier_2", "checksum": {"name": "sha256", "checksum": "b446a4649add77dac27a5a1470e814d6fa81165d5c85cfebd2c80ea83001bc20"}, "config": {"enabled": true, "alias": "procedure_modifier_2", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_2", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7259743, "relation_name": "dev_thuxuan.data_quality.procedure_modifier_2", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'MODIFIER_2' as field_name\r\n , case when term.hcpcs is not null then 'valid'\r\n when m.modifier_2 is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.modifier_2 is not null and term.hcpcs is null\r\n then 'Modifier 2 does not join to Terminology hcpcs_level_2 table'\r\n else null end as invalid_reason\r\n , cast(modifier_2 as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_2 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_2.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_2' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_2 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_2 is not null and term.hcpcs is null\n then 'Modifier 2 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_2 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_2 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_3": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_modifier_3", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_3.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_3.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_3", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_3"], "alias": "procedure_modifier_3", "checksum": {"name": "sha256", "checksum": "0fe4df6564965f5ec3d4e0af20b0dc56759393cd728b619c40aa76659f52a4ac"}, "config": {"enabled": true, "alias": "procedure_modifier_3", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_3", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7239742, "relation_name": "dev_thuxuan.data_quality.procedure_modifier_3", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'MODIFIER_3' as field_name\r\n , case when term.hcpcs is not null then 'valid'\r\n when m.modifier_3 is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.modifier_3 is not null and term.hcpcs is null\r\n then 'Modifier 3 does not join to Terminology hcpcs_level_2 table'\r\n else null end as invalid_reason\r\n , cast(modifier_3 as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_3 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_3.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_3' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_3 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_3 is not null and term.hcpcs is null\n then 'Modifier 3 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_3 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_3 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_4": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_modifier_4", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_4.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_4.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_4", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_4"], "alias": "procedure_modifier_4", "checksum": {"name": "sha256", "checksum": "6181209514fb3d537949e4047c7aeba3297b2de0c538e6647463bfb4479b9cfc"}, "config": {"enabled": true, "alias": "procedure_modifier_4", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_4", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7159793, "relation_name": "dev_thuxuan.data_quality.procedure_modifier_4", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n ,coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n ,'PROCEDURE' AS table_name\r\n ,'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n ,'MODIFIER_4' as field_name\r\n ,case when term.hcpcs is not null then 'valid'\r\n when m.modifier_4 is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n ,case when m.modifier_4 is not null and term.hcpcs is null\r\n then 'Modifier 4 does not join to Terminology hcpcs_level_2 table'\r\n else null end as invalid_reason\r\n ,cast(modifier_4 as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_4 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_4.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n ,'PROCEDURE' AS table_name\n ,'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n ,'MODIFIER_4' as field_name\n ,case when term.hcpcs is not null then 'valid'\n when m.modifier_4 is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.modifier_4 is not null and term.hcpcs is null\n then 'Modifier 4 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n ,cast(modifier_4 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_4 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_modifier_5": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_modifier_5", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_5.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_5.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_5", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_modifier_5"], "alias": "procedure_modifier_5", "checksum": {"name": "sha256", "checksum": "561a7d636a634a44e11e7ea0ac9a84a56949bab9635fd9283b4110f88496d6e0"}, "config": {"enabled": true, "alias": "procedure_modifier_5", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_modifier_5", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7139792, "relation_name": "dev_thuxuan.data_quality.procedure_modifier_5", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'MODIFIER_5' as field_name\r\n , case when term.hcpcs is not null then 'valid'\r\n when m.modifier_5 is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.modifier_5 is not null and term.hcpcs is null\r\n then 'Modifier 5 does not join to Terminology hcpcs_level_2 table'\r\n else null end as invalid_reason\r\n , cast(modifier_5 as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.modifier_5 = term.hcpcs", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_modifier_5.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_5' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_5 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_5 is not null and term.hcpcs is null\n then 'Modifier 5 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_5 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_5 = term.hcpcs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_normalized_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_normalized_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_code.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_normalized_code"], "alias": "procedure_normalized_code", "checksum": {"name": "sha256", "checksum": "703d5b808dba81ffb0e85d392d96a82386f1d62a1c86e7d4231a881a795c82f1"}, "config": {"enabled": true, "alias": "procedure_normalized_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_normalized_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7179792, "relation_name": "dev_thuxuan.data_quality.procedure_normalized_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\nwith icd9 as (\r\n SELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' as field_name\r\n , case when term.icd_9_pcs is not null then 'valid'\r\n when m.normalized_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code is not null and term.icd_9_pcs is null\r\n then 'Normalized code does not join to Terminology icd_9_pcs table'\r\n else null end as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\n from {{ ref('procedure')}} m\r\n left join {{ ref('terminology__icd_9_pcs')}} term on m.normalized_code = term.icd_9_pcs\r\n where\r\n m.normalized_code_type = 'icd-9-pcs'\r\n),\r\nicd10 as (\r\n SELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' as field_name\r\n , case when term.icd_10_pcs is not null then 'valid'\r\n when m.normalized_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code is not null and term.icd_10_pcs is null\r\n then 'Normalized code does not join to Terminology icd_10_pcs table'\r\n else null end as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__icd_10_pcs')}} term on m.normalized_code = term.icd_10_pcs\r\nwhere\r\n m.normalized_code_type = 'icd_10_pcs'\r\n),\r\nhcpcs_level_2 as (\r\n SELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' as field_name\r\n , case when term.hcpcs is not null then 'valid'\r\n when m.normalized_code is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code is not null and term.hcpcs is null\r\n then 'Normalized code does not join to Terminology hcpcs_level_2 table'\r\n else null end as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('terminology__hcpcs_level_2')}} term on m.normalized_code = term.hcpcs\r\nwhere\r\n m.normalized_code_type = 'hcpcs_level_2'\r\n),\r\n\r\nothers as (\r\n SELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE' as field_name\r\n , 'null' as bucket_name\r\n , 'code type does not have a matching code terminology table' as invalid_reason\r\n , cast(normalized_code as {{ dbt.type_string() }}) as field_value\r\nfrom {{ ref('procedure')}} m\r\nwhere\r\n m.normalized_code_type not in ('icd-9-pcs', 'icd-10-pcs','hcpcs_level_2')\r\n)\r\n\r\nSELECT *, '{{ var('tuva_last_run')}}' as tuva_last_run FROM icd9\r\n\r\nunion all\r\n\r\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run FROM icd10\r\n\r\nunion all\r\n\r\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run FROM hcpcs_level_2\r\n\r\nunion all\r\n\r\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run FROM others", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}, {"name": "procedure", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "procedure", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__hcpcs_level_2"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_code.sql", "compiled": true, "compiled_code": "\n\nwith icd9 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_9_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_9_pcs is null\n then 'Normalized code does not join to Terminology icd_9_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n from tuva.input_layer.procedure m\n left join dev_thuxuan.terminology.icd_9_pcs term on m.normalized_code = term.icd_9_pcs\n where\n m.normalized_code_type = 'icd-9-pcs'\n),\nicd10 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_10_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_pcs is null\n then 'Normalized code does not join to Terminology icd_10_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.icd_10_pcs term on m.normalized_code = term.icd_10_pcs\nwhere\n m.normalized_code_type = 'icd_10_pcs'\n),\nhcpcs_level_2 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.hcpcs is null\n then 'Normalized code does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.normalized_code = term.hcpcs\nwhere\n m.normalized_code_type = 'hcpcs_level_2'\n),\n\nothers as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , 'null' as bucket_name\n , 'code type does not have a matching code terminology table' as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nwhere\n m.normalized_code_type not in ('icd-9-pcs', 'icd-10-pcs','hcpcs_level_2')\n)\n\nSELECT *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM icd9\n\nunion all\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM icd10\n\nunion all\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM hcpcs_level_2\n\nunion all\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM others", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_normalized_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_normalized_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_normalized_code_type"], "alias": "procedure_normalized_code_type", "checksum": {"name": "sha256", "checksum": "1704051cf3c1fd73453ea6ad065b273eab4e0ac2ad17abaec30748b236fe0d0e"}, "config": {"enabled": true, "alias": "procedure_normalized_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_normalized_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.685764, "relation_name": "dev_thuxuan.data_quality.procedure_normalized_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_CODE_TYPE' as field_name\r\n , case when term.code_type is not null then 'valid'\r\n when m.normalized_code_type is not null then 'invalid'\r\n else 'null'\r\n end as bucket_name\r\n , case when m.normalized_code_type is not null and term.code_type is null\r\n then 'Normalized code type does not join to Terminology code_type table'\r\n else null end as invalid_reason\r\n , cast(normalized_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m\r\nleft join {{ ref('reference_data__code_type')}} term on m.normalized_code_type = term.code_type", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}, {"name": "reference_data__code_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure", "seed.the_tuva_project.reference_data__code_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.reference_data.code_type term on m.normalized_code_type = term.code_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_normalized_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_normalized_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_description.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_normalized_description"], "alias": "procedure_normalized_description", "checksum": {"name": "sha256", "checksum": "6bd2f0a619f2f0ffb98adf3b90bebb3f45a485d3b4c9e1cdd61187675e85e194"}, "config": {"enabled": true, "alias": "procedure_normalized_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_normalized_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6884544, "relation_name": "dev_thuxuan.data_quality.procedure_normalized_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'NORMALIZED_DESCRIPTION' AS field_name\r\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(normalized_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_normalized_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_patient_id"], "alias": "procedure_patient_id", "checksum": {"name": "sha256", "checksum": "1bc9ef2922b8a91e82a08d0bbe484483293c603bd100bb4c3819a17df7d0fc1a"}, "config": {"enabled": true, "alias": "procedure_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.706979, "relation_name": "dev_thuxuan.data_quality.procedure_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'PATIENT_ID' AS field_name\r\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(patient_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_practitioner_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_practitioner_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_practitioner_id"], "alias": "procedure_practitioner_id", "checksum": {"name": "sha256", "checksum": "354dcde745a8db49a78c3a238a0fa0ac7b626409fcfe3b3d7edf77810e76e72b"}, "config": {"enabled": true, "alias": "procedure_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7024739, "relation_name": "dev_thuxuan.data_quality.procedure_practitioner_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'PRACTITIONER_ID' AS field_name\r\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(practitioner_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_practitioner_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' AS field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_procedure_date": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_procedure_date", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_procedure_date.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_procedure_date.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_date", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_procedure_date"], "alias": "procedure_procedure_date", "checksum": {"name": "sha256", "checksum": "055eef19df8a3f6bd312bb0d9463184bd1f39ec26f63e3c88f1f4a50ce782ac1"}, "config": {"enabled": true, "alias": "procedure_procedure_date", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_procedure_date", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7099822, "relation_name": "dev_thuxuan.data_quality.procedure_procedure_date", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'PROCEDURE_DATE' as field_name\r\n , case\r\n when m.procedure_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'invalid'\r\n when m.procedure_date <= cast('1901-01-01' as date) then 'invalid'\r\n when m.procedure_date is null then 'null'\r\n else 'valid'\r\n end as bucket_name\r\n , case\r\n when m.procedure_date > cast(substring('{{ var('tuva_last_run') }}',1,10) as date) then 'future'\r\n when m.procedure_date <= cast('1901-01-01' as date) then 'too old'\r\n else null\r\n end as invalid_reason\r\n , cast(procedure_date as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_procedure_date.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_DATE' as field_name\n , case\n when m.procedure_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date <= cast('1901-01-01' as date) then 'invalid'\n when m.procedure_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.procedure_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(procedure_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_procedure_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_procedure_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_procedure_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_procedure_id.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_procedure_id"], "alias": "procedure_procedure_id", "checksum": {"name": "sha256", "checksum": "eb535651cf3b21921c3070a7590f875430c98ab3b9e60e4c8dcabbed376c9f7e"}, "config": {"enabled": true, "alias": "procedure_procedure_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_procedure_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6924717, "relation_name": "dev_thuxuan.data_quality.procedure_procedure_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'PROCEDURE_ID' AS field_name\r\n , case when m.procedure_id is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(procedure_id as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_procedure_id.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_ID' AS field_name\n , case when m.procedure_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(procedure_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_source_code": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_source_code", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_code.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_code.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_source_code", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_source_code"], "alias": "procedure_source_code", "checksum": {"name": "sha256", "checksum": "e69ef3667ec350f39e5a0380bf987cffa5654818e3ce974aca57c31ffd371ab4"}, "config": {"enabled": true, "alias": "procedure_source_code", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_source_code", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6964734, "relation_name": "dev_thuxuan.data_quality.procedure_source_code", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE' as field_name\r\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_code.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_source_code_type": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_source_code_type", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_code_type.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_code_type.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_source_code_type", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_source_code_type"], "alias": "procedure_source_code_type", "checksum": {"name": "sha256", "checksum": "3b2bf85b79fee29dd3d368978a6dea4927e3514d8afbda11b409b018894f394c"}, "config": {"enabled": true, "alias": "procedure_source_code_type", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_source_code_type", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.6984718, "relation_name": "dev_thuxuan.data_quality.procedure_source_code_type", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_CODE_TYPE' as field_name\r\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(source_code_type as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_code_type.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__procedure_source_description": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__procedure_source_description", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_description.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_description.sql", "unique_id": "model.the_tuva_project.data_quality__procedure_source_description", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "atomic_checks", "clinical", "procedure", "data_quality__procedure_source_description"], "alias": "procedure_source_description", "checksum": {"name": "sha256", "checksum": "09ef06e7dfbce1c79ef34e986025036ae316441d9289235e6bc8595d0b100a6b"}, "config": {"enabled": true, "alias": "procedure_source_description", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "procedure_source_description", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7004716, "relation_name": "dev_thuxuan.data_quality.procedure_source_description", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled', False)\r\n) }}\r\n\r\n\r\nSELECT\r\n m.data_source\r\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\r\n , 'PROCEDURE' AS table_name\r\n , 'Procedure ID' as drill_down_key\r\n , coalesce(procedure_id, 'NULL') AS drill_down_value\r\n , 'SOURCE_DESCRIPTION' as field_name\r\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\r\n , cast(null as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(substring(source_description, 1, 255) as {{ dbt.type_string() }}) as field_value\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('procedure')}} m", "language": "sql", "refs": [{"name": "procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.input_layer.procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\atomic_checks\\clinical\\procedure\\data_quality__procedure_source_description.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__unique_value_examples": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__unique_value_examples", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\data_quality__unique_value_examples.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\data_quality__unique_value_examples.sql", "unique_id": "model.the_tuva_project.data_quality__unique_value_examples", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "data_quality__unique_value_examples"], "alias": "unique_value_examples", "checksum": {"name": "sha256", "checksum": "efd043064296f57229c15668d633193a583439a5cfd804a2048d02bd1136e665"}, "config": {"enabled": true, "alias": "unique_value_examples", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "unique_value_examples", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7279744, "relation_name": "dev_thuxuan.data_quality.unique_value_examples", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_condition_condition_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_encounter_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_lab_result_lab_result_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_location_location_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_medication_medication_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_observation_observation_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_patient_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_practitioner_practitioner_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__primary_keys_procedure_procedure_id') }}", "language": "sql", "refs": [{"name": "data_quality__primary_keys_condition_condition_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_location_location_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_medication_medication_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_observation_observation_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_patient_patient_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__primary_keys_procedure_procedure_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "model.the_tuva_project.data_quality__primary_keys_location_location_id", "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\data_quality__unique_value_examples.sql", "compiled": true, "compiled_code": "\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_condition_condition_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_encounter_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_location_location_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_medication_medication_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_observation_observation_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_patient_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_procedure_procedure_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_condition_condition_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_condition_condition_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_condition_condition_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_condition_condition_id"], "alias": "primary_keys_condition_condition_id", "checksum": {"name": "sha256", "checksum": "cee1dcb735338059c290435993c04f060c5bb82f9e76a784b171670f71df0958"}, "config": {"enabled": true, "alias": "primary_keys_condition_condition_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_condition_condition_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7299747, "relation_name": "dev_thuxuan.data_quality.primary_keys_condition_condition_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__condition_condition_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__condition_condition_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__condition_condition_id') }} a\r\n inner JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__condition_condition_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__condition_condition_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_condition_condition_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.condition_condition_id a\n inner JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_encounter_encounter_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_encounter_encounter_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_encounter_encounter_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_encounter_encounter_id"], "alias": "primary_keys_encounter_encounter_id", "checksum": {"name": "sha256", "checksum": "c7980e280583cabdaa2590e4bafe47caa7deed82e2e934046dc054eae442a158"}, "config": {"enabled": true, "alias": "primary_keys_encounter_encounter_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_encounter_encounter_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7319741, "relation_name": "dev_thuxuan.data_quality.primary_keys_encounter_encounter_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__encounter_encounter_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__encounter_encounter_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__encounter_encounter_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__encounter_encounter_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_encounter_encounter_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.encounter_encounter_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_lab_result_lab_result_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_lab_result_lab_result_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_lab_result_lab_result_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_lab_result_lab_result_id"], "alias": "primary_keys_lab_result_lab_result_id", "checksum": {"name": "sha256", "checksum": "b96f5af277e1b727d170dff5e97e86171bf49a56a5b6145bfed2772738abbc8e"}, "config": {"enabled": true, "alias": "primary_keys_lab_result_lab_result_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_lab_result_lab_result_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7349741, "relation_name": "dev_thuxuan.data_quality.primary_keys_lab_result_lab_result_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__lab_result_lab_result_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__lab_result_lab_result_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__lab_result_lab_result_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__lab_result_lab_result_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_lab_result_lab_result_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.lab_result_lab_result_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_location_location_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_location_location_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_location_location_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_location_location_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_location_location_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_location_location_id"], "alias": "primary_keys_location_location_id", "checksum": {"name": "sha256", "checksum": "8a657027761330e5a418e422fd470f71de0e05fe0695ad1323203109bb2c9622"}, "config": {"enabled": true, "alias": "primary_keys_location_location_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_location_location_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7369742, "relation_name": "dev_thuxuan.data_quality.primary_keys_location_location_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__location_location_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__location_location_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__location_location_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__location_location_id", "package": null, "version": null}, {"name": "data_quality__location_location_id", "package": null, "version": null}, {"name": "data_quality__location_location_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__location_location_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_location_location_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.location_location_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_medication_medication_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_medication_medication_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_medication_medication_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_medication_medication_id"], "alias": "primary_keys_medication_medication_id", "checksum": {"name": "sha256", "checksum": "a336444bade3f58ff140a61f0d3c7e5f5b312d0e9be9237f986d3c3a4f0c1b31"}, "config": {"enabled": true, "alias": "primary_keys_medication_medication_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_medication_medication_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.738974, "relation_name": "dev_thuxuan.data_quality.primary_keys_medication_medication_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__medication_medication_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__medication_medication_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__medication_medication_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__medication_medication_id", "package": null, "version": null}, {"name": "data_quality__medication_medication_id", "package": null, "version": null}, {"name": "data_quality__medication_medication_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__medication_medication_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_medication_medication_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.medication_medication_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_observation_observation_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_observation_observation_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_observation_observation_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_observation_observation_id"], "alias": "primary_keys_observation_observation_id", "checksum": {"name": "sha256", "checksum": "7caf06895169d24eadddf1e5928ecac03e56d760039e70afa187a4605799aba1"}, "config": {"enabled": true, "alias": "primary_keys_observation_observation_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_observation_observation_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7409747, "relation_name": "dev_thuxuan.data_quality.primary_keys_observation_observation_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__observation_observation_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__observation_observation_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__observation_observation_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__observation_observation_id", "package": null, "version": null}, {"name": "data_quality__observation_observation_id", "package": null, "version": null}, {"name": "data_quality__observation_observation_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__observation_observation_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_observation_observation_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.observation_observation_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_patient_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_patient_patient_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_patient_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_patient_patient_id"], "alias": "primary_keys_patient_patient_id", "checksum": {"name": "sha256", "checksum": "439f4e2c39345298e06b1852d2892b8567ac7e4ededb7928f11c5603437fb323"}, "config": {"enabled": true, "alias": "primary_keys_patient_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_patient_patient_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7429745, "relation_name": "dev_thuxuan.data_quality.primary_keys_patient_patient_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__patient_patient_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__patient_patient_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__patient_patient_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__patient_patient_id", "package": null, "version": null}, {"name": "data_quality__patient_patient_id", "package": null, "version": null}, {"name": "data_quality__patient_patient_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__patient_patient_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_patient_patient_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.patient_patient_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_practitioner_practitioner_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_practitioner_practitioner_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_practitioner_practitioner_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_practitioner_practitioner_id"], "alias": "primary_keys_practitioner_practitioner_id", "checksum": {"name": "sha256", "checksum": "8cfa632c2a0bff2279f78e589e3731596f361d55bb809cbf87c70a937fea2c0a"}, "config": {"enabled": true, "alias": "primary_keys_practitioner_practitioner_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_practitioner_practitioner_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7449746, "relation_name": "dev_thuxuan.data_quality.primary_keys_practitioner_practitioner_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__practitioner_practitioner_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__practitioner_practitioner_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__practitioner_practitioner_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__practitioner_practitioner_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_practitioner_practitioner_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.practitioner_practitioner_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_keys_procedure_procedure_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_procedure_procedure_id.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_procedure_procedure_id.sql", "unique_id": "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "concepts", "primary_keys", "data_quality__primary_keys_procedure_procedure_id"], "alias": "primary_keys_procedure_procedure_id", "checksum": {"name": "sha256", "checksum": "d27daef36f003e20f28094471994746d05001511acaad56016f594f7862b1895"}, "config": {"enabled": true, "alias": "primary_keys_procedure_procedure_id", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_keys_procedure_procedure_id", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7479744, "relation_name": "dev_thuxuan.data_quality.primary_keys_procedure_procedure_id", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH valid_conditions AS (\r\n SELECT\r\n *\r\n FROM\r\n {{ ref('data_quality__procedure_procedure_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n, uniqueness_check as (\r\n SELECT\r\n field_value,\r\n COUNT(*) AS duplicate_count\r\n FROM\r\n valid_conditions\r\n GROUP BY\r\n field_value\r\n HAVING\r\n COUNT(*) > 1\r\n)\r\n\r\n, random_sample AS (\r\n SELECT\r\n data_source,\r\n source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n field_value,\r\n bucket_name,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__procedure_procedure_id') }}\r\n WHERE\r\n bucket_name = 'valid'\r\n)\r\n\r\n, duplicates_summary AS (\r\n SELECT\r\n a.data_source,\r\n a.source_date,\r\n a.table_name,\r\n a.drill_down_key,\r\n a.drill_down_value,\r\n a.field_name,\r\n a.field_value,\r\n a.bucket_name,\r\n b.duplicate_count,\r\n row_number() over (order by drill_down_key) as row_number_value\r\n FROM\r\n {{ ref('data_quality__procedure_procedure_id') }} a\r\n JOIN\r\n uniqueness_check b on a.field_value = b.field_value\r\n)\r\n\r\nSELECT\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n duplicates_summary\r\nwhere row_number_value <= 5\r\n\r\nunion all\r\n\r\nSELECT\r\n *,\r\n 0 as duplicate_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM\r\n random_sample\r\nWHERE\r\n row_number_value <= 5\r\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "language": "sql", "refs": [{"name": "data_quality__procedure_procedure_id", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_id", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__procedure_procedure_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\concepts\\primary_keys\\data_quality__primary_keys_procedure_procedure_id.sql", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.procedure_procedure_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_type_summary": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_type_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__claim_type_summary.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__claim_type_summary.sql", "unique_id": "model.the_tuva_project.data_quality__claim_type_summary", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "claims", "data_quality__claim_type_summary"], "alias": "claim_type_summary", "checksum": {"name": "sha256", "checksum": "a73a81bfc25ec742b4e466b2589d6eecfb5daab69a251091dd2dfbf002aed9f4"}, "config": {"enabled": true, "alias": "claim_type_summary", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_type_summary", "tags": ["data_quality"], "materialized": "table", "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7499745, "relation_name": "dev_thuxuan.data_quality.claim_type_summary", "raw_code": "{% if var('claims_enabled', False) == true -%}\r\n\r\nselect\r\n data_source\r\n ,claim_type\r\n ,count(distinct claim_id) as claim_count\r\n ,sum(paid_amount) as paid_amount\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('medical_claim')}}\r\ngroup by\r\n data_source\r\n ,claim_type\r\n\r\n{% else -%}\r\n\r\nselect\r\n null as data_source\r\n , null as claim_type\r\n , null as claim_count\r\n , null as paid_amount\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n\r\n{{ limit_zero()}}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__claim_type_summary.sql", "compiled": true, "compiled_code": "select\n data_source\n ,claim_type\n ,count(distinct claim_id) as claim_count\n ,sum(paid_amount) as paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim\ngroup by\n data_source\n ,claim_type\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_claims_detail": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_claims_detail", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__data_quality_claims_detail.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__data_quality_claims_detail.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_detail", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "claims", "data_quality__data_quality_claims_detail"], "alias": "data_quality_claims_detail", "checksum": {"name": "sha256", "checksum": "202d86985ea63ecb4d1659957b3de1699536038547030f0fedf8c473aa0fc7b9"}, "config": {"enabled": true, "alias": "data_quality_claims_detail", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_claims_detail", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7529743, "relation_name": "dev_thuxuan.data_quality.data_quality_claims_detail", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',False)\r\n )\r\n}}\r\n\r\nWITH unioned_data as (\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_allowed_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_charge_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_claim_id') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_claim_line_end_date') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_claim_line_number') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_claim_line_start_date') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_claim_type') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_coinsurance_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_copayment_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_deductible_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_diagnosis_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_hcpcs_code') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_member_id') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_paid_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_paid_date') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_payer') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_plan') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__claim_total_cost_amount') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_address') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_birth_date') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_city') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_death_date') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_death_flag') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_dual_status_code') }}\r\n\r\nunion all\r\n\r\nSELECT\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_end_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_first_name') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_gender') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_last_name') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_medicare_status_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_member_id') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_original_reason_entitlement_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_payer_type') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_payer') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_phone') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_plan') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_race') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_start_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_state') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__eligibility_zip_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_ms_drg_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_admission_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_admit_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_admit_type_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_apr_drg_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_bill_type_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_billing_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_claim_end_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_claim_start_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_diagnosis_code_1') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_diagnosis_code_2') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_diagnosis_code_3') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_discharge_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_discharge_disposition_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_facility_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_present_on_admission_1') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_present_on_admission_2') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_present_on_admission_3') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_procedure_code_1') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_procedure_code_2') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_procedure_code_3') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_procedure_date_1') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_procedure_date_2') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_procedure_date_3') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_rendering_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_revenue_center_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__institutional_service_unit_quantity') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_allowed_amount') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_claim_id') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_claim_line_number') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_coinsurance_amount') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_copayment_amount') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_days_supply') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_deductible_amount') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_dispensing_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_dispensing_provider_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_member_id') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_ndc_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_paid_amount') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_paid_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_payer') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_plan') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_prescribing_provider_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_quantity') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__pharmacy_refills') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_billing_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_facility_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_place_of_service_code') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_rendering_npi') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_claim_end_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_claim_start_date') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_diagnosis_code_1') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_diagnosis_code_2') }}\r\n\r\nunion all\r\n\r\nSELECT cast(data_source as {{ dbt.type_string() }}) as data_source\r\n\t, cast(source_date as {{ dbt.type_string() }}) as source_date\r\n\t, cast(table_name as {{ dbt.type_string() }}) as table_name\r\n\t, cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n\t, cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n\t, cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n\t, cast(field_name as {{ dbt.type_string() }}) as field_name\r\n\t, cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n\t, cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n\t, cast(field_value as {{ dbt.type_string() }}) as field_value\r\n\t, cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n\tFROM {{ ref('data_quality__professional_diagnosis_code_3') }}\r\n\r\n)\r\n\r\n\r\nselect\r\n cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(source_date as {{ dbt.type_string() }}) as source_date\r\n , cast(table_name as {{ dbt.type_string() }}) as table_name\r\n , cast(drill_down_key as {{ dbt.type_string() }}) as drill_down_key\r\n , cast(drill_down_value as {{ dbt.type_string() }}) as drill_down_value\r\n , cast(claim_type as {{ dbt.type_string() }}) as claim_type\r\n , cast(field_name as {{ dbt.type_string() }}) as field_name\r\n , cast(bucket_name as {{ dbt.type_string() }}) as bucket_name\r\n , cast(invalid_reason as {{ dbt.type_string() }}) as invalid_reason\r\n , cast(field_value as {{ dbt.type_string() }}) as field_value\r\n , cast(tuva_last_run as {{ dbt.type_string() }}) as tuva_last_run\r\n , dense_rank() over (\r\n order by data_source\r\n , table_name\r\n , claim_type\r\n , field_name\r\n ) as summary_sk\r\nfrom unioned_data", "language": "sql", "refs": [{"name": "data_quality__claim_allowed_amount", "package": null, "version": null}, {"name": "data_quality__claim_charge_amount", "package": null, "version": null}, {"name": "data_quality__claim_claim_id", "package": null, "version": null}, {"name": "data_quality__claim_claim_line_end_date", "package": null, "version": null}, {"name": "data_quality__claim_claim_line_number", "package": null, "version": null}, {"name": "data_quality__claim_claim_line_start_date", "package": null, "version": null}, {"name": "data_quality__claim_claim_type", "package": null, "version": null}, {"name": "data_quality__claim_coinsurance_amount", "package": null, "version": null}, {"name": "data_quality__claim_copayment_amount", "package": null, "version": null}, {"name": "data_quality__claim_data_source", "package": null, "version": null}, {"name": "data_quality__claim_deductible_amount", "package": null, "version": null}, {"name": "data_quality__claim_diagnosis_code_type", "package": null, "version": null}, {"name": "data_quality__claim_hcpcs_code", "package": null, "version": null}, {"name": "data_quality__claim_member_id", "package": null, "version": null}, {"name": "data_quality__claim_paid_amount", "package": null, "version": null}, {"name": "data_quality__claim_paid_date", "package": null, "version": null}, {"name": "data_quality__claim_patient_id", "package": null, "version": null}, {"name": "data_quality__claim_payer", "package": null, "version": null}, {"name": "data_quality__claim_plan", "package": null, "version": null}, {"name": "data_quality__claim_total_cost_amount", "package": null, "version": null}, {"name": "data_quality__eligibility_address", "package": null, "version": null}, {"name": "data_quality__eligibility_birth_date", "package": null, "version": null}, {"name": "data_quality__eligibility_city", "package": null, "version": null}, {"name": "data_quality__eligibility_data_source", "package": null, "version": null}, {"name": "data_quality__eligibility_death_date", "package": null, "version": null}, {"name": "data_quality__eligibility_death_flag", "package": null, "version": null}, {"name": "data_quality__eligibility_dual_status_code", "package": null, "version": null}, {"name": "data_quality__eligibility_end_date", "package": null, "version": null}, {"name": "data_quality__eligibility_first_name", "package": null, "version": null}, {"name": "data_quality__eligibility_gender", "package": null, "version": null}, {"name": "data_quality__eligibility_last_name", "package": null, "version": null}, {"name": "data_quality__eligibility_medicare_status_code", "package": null, "version": null}, {"name": "data_quality__eligibility_member_id", "package": null, "version": null}, {"name": "data_quality__eligibility_original_reason_entitlement_code", "package": null, "version": null}, {"name": "data_quality__eligibility_patient_id", "package": null, "version": null}, {"name": "data_quality__eligibility_payer_type", "package": null, "version": null}, {"name": "data_quality__eligibility_payer", "package": null, "version": null}, {"name": "data_quality__eligibility_phone", "package": null, "version": null}, {"name": "data_quality__eligibility_plan", "package": null, "version": null}, {"name": "data_quality__eligibility_race", "package": null, "version": null}, {"name": "data_quality__eligibility_start_date", "package": null, "version": null}, {"name": "data_quality__eligibility_state", "package": null, "version": null}, {"name": "data_quality__eligibility_zip_code", "package": null, "version": null}, {"name": "data_quality__institutional_ms_drg_code", "package": null, "version": null}, {"name": "data_quality__institutional_admission_date", "package": null, "version": null}, {"name": "data_quality__institutional_admit_source_code", "package": null, "version": null}, {"name": "data_quality__institutional_admit_type_code", "package": null, "version": null}, {"name": "data_quality__institutional_apr_drg_code", "package": null, "version": null}, {"name": "data_quality__institutional_bill_type_code", "package": null, "version": null}, {"name": "data_quality__institutional_billing_npi", "package": null, "version": null}, {"name": "data_quality__institutional_claim_end_date", "package": null, "version": null}, {"name": "data_quality__institutional_claim_start_date", "package": null, "version": null}, {"name": "data_quality__institutional_diagnosis_code_1", "package": null, "version": null}, {"name": "data_quality__institutional_diagnosis_code_2", "package": null, "version": null}, {"name": "data_quality__institutional_diagnosis_code_3", "package": null, "version": null}, {"name": "data_quality__institutional_discharge_date", "package": null, "version": null}, {"name": "data_quality__institutional_discharge_disposition_code", "package": null, "version": null}, {"name": "data_quality__institutional_facility_npi", "package": null, "version": null}, {"name": "data_quality__institutional_present_on_admission_1", "package": null, "version": null}, {"name": "data_quality__institutional_present_on_admission_2", "package": null, "version": null}, {"name": "data_quality__institutional_present_on_admission_3", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_code_1", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_code_2", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_code_3", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_date_1", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_date_2", "package": null, "version": null}, {"name": "data_quality__institutional_procedure_date_3", "package": null, "version": null}, {"name": "data_quality__institutional_rendering_npi", "package": null, "version": null}, {"name": "data_quality__institutional_revenue_center_code", "package": null, "version": null}, {"name": "data_quality__institutional_service_unit_quantity", "package": null, "version": null}, {"name": "data_quality__pharmacy_allowed_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_id", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_line_number", "package": null, "version": null}, {"name": "data_quality__pharmacy_coinsurance_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_copayment_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_data_source", "package": null, "version": null}, {"name": "data_quality__pharmacy_days_supply", "package": null, "version": null}, {"name": "data_quality__pharmacy_deductible_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_dispensing_date", "package": null, "version": null}, {"name": "data_quality__pharmacy_dispensing_provider_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_member_id", "package": null, "version": null}, {"name": "data_quality__pharmacy_ndc_code", "package": null, "version": null}, {"name": "data_quality__pharmacy_paid_amount", "package": null, "version": null}, {"name": "data_quality__pharmacy_paid_date", "package": null, "version": null}, {"name": "data_quality__pharmacy_patient_id", "package": null, "version": null}, {"name": "data_quality__pharmacy_payer", "package": null, "version": null}, {"name": "data_quality__pharmacy_plan", "package": null, "version": null}, {"name": "data_quality__pharmacy_prescribing_provider_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_quantity", "package": null, "version": null}, {"name": "data_quality__pharmacy_refills", "package": null, "version": null}, {"name": "data_quality__professional_billing_npi", "package": null, "version": null}, {"name": "data_quality__professional_facility_npi", "package": null, "version": null}, {"name": "data_quality__professional_place_of_service_code", "package": null, "version": null}, {"name": "data_quality__professional_rendering_npi", "package": null, "version": null}, {"name": "data_quality__professional_claim_end_date", "package": null, "version": null}, {"name": "data_quality__professional_claim_start_date", "package": null, "version": null}, {"name": "data_quality__professional_diagnosis_code_1", "package": null, "version": null}, {"name": "data_quality__professional_diagnosis_code_2", "package": null, "version": null}, {"name": "data_quality__professional_diagnosis_code_3", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.data_quality__claim_allowed_amount", "model.the_tuva_project.data_quality__claim_charge_amount", "model.the_tuva_project.data_quality__claim_claim_id", "model.the_tuva_project.data_quality__claim_claim_line_end_date", "model.the_tuva_project.data_quality__claim_claim_line_number", "model.the_tuva_project.data_quality__claim_claim_line_start_date", "model.the_tuva_project.data_quality__claim_claim_type", "model.the_tuva_project.data_quality__claim_coinsurance_amount", "model.the_tuva_project.data_quality__claim_copayment_amount", "model.the_tuva_project.data_quality__claim_data_source", "model.the_tuva_project.data_quality__claim_deductible_amount", "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__claim_member_id", "model.the_tuva_project.data_quality__claim_paid_amount", "model.the_tuva_project.data_quality__claim_paid_date", "model.the_tuva_project.data_quality__claim_patient_id", "model.the_tuva_project.data_quality__claim_payer", "model.the_tuva_project.data_quality__claim_plan", "model.the_tuva_project.data_quality__claim_total_cost_amount", "model.the_tuva_project.data_quality__eligibility_address", "model.the_tuva_project.data_quality__eligibility_birth_date", "model.the_tuva_project.data_quality__eligibility_city", "model.the_tuva_project.data_quality__eligibility_data_source", "model.the_tuva_project.data_quality__eligibility_death_date", "model.the_tuva_project.data_quality__eligibility_death_flag", "model.the_tuva_project.data_quality__eligibility_dual_status_code", "model.the_tuva_project.data_quality__eligibility_end_date", "model.the_tuva_project.data_quality__eligibility_first_name", "model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__eligibility_last_name", "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "model.the_tuva_project.data_quality__eligibility_member_id", "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "model.the_tuva_project.data_quality__eligibility_patient_id", "model.the_tuva_project.data_quality__eligibility_payer_type", "model.the_tuva_project.data_quality__eligibility_payer", "model.the_tuva_project.data_quality__eligibility_phone", "model.the_tuva_project.data_quality__eligibility_plan", "model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__eligibility_start_date", "model.the_tuva_project.data_quality__eligibility_state", "model.the_tuva_project.data_quality__eligibility_zip_code", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__institutional_admission_date", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_claim_end_date", "model.the_tuva_project.data_quality__institutional_claim_start_date", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__institutional_discharge_date", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__institutional_procedure_date_1", "model.the_tuva_project.data_quality__institutional_procedure_date_2", "model.the_tuva_project.data_quality__institutional_procedure_date_3", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "model.the_tuva_project.data_quality__pharmacy_claim_id", "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "model.the_tuva_project.data_quality__pharmacy_data_source", "model.the_tuva_project.data_quality__pharmacy_days_supply", "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_member_id", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.data_quality__pharmacy_paid_amount", "model.the_tuva_project.data_quality__pharmacy_paid_date", "model.the_tuva_project.data_quality__pharmacy_patient_id", "model.the_tuva_project.data_quality__pharmacy_payer", "model.the_tuva_project.data_quality__pharmacy_plan", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_quantity", "model.the_tuva_project.data_quality__pharmacy_refills", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.data_quality__professional_rendering_npi", "model.the_tuva_project.data_quality__professional_claim_end_date", "model.the_tuva_project.data_quality__professional_claim_start_date", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__data_quality_claims_detail.sql", "compiled": true, "compiled_code": "\n\nWITH unioned_data as (\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_allowed_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_charge_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_line_end_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_line_number\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_line_start_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_coninsurance_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_copayment_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_deductible_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_diagnosis_code_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_hcpcs_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_member_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_paid_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_paid_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_patient_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_payer\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_plan\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_total_cost_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_address\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_birth_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_city\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_death_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_death_flag\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_dual_status_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_first_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_gender\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_last_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_medicare_status_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_original_reason_entitlement_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_payer_type\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_phone\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_race\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_state\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_zip_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_ms_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_admission_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_admit_source_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_admit_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_apr_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_bill_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_diagnosis_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_discharge_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_discharge_disposition_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_present_on_admission_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_present_on_admission_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_present_on_admission_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_date_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_date_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_date_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_revenue_center_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_service_unit_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_allowed_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_claim_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_claim_line_number\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_coinsurance_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_copayment_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_data_source\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_days_supply\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_deductible_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_dispensing_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_dispensing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_ndc_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_paid_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_paid_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_prescribing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_refills\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_place_of_service_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_diagnosis_code_3\n\n)\n\n\nselect\n cast(data_source as TEXT) as data_source\n , cast(source_date as TEXT) as source_date\n , cast(table_name as TEXT) as table_name\n , cast(drill_down_key as TEXT) as drill_down_key\n , cast(drill_down_value as TEXT) as drill_down_value\n , cast(claim_type as TEXT) as claim_type\n , cast(field_name as TEXT) as field_name\n , cast(bucket_name as TEXT) as bucket_name\n , cast(invalid_reason as TEXT) as invalid_reason\n , cast(field_value as TEXT) as field_value\n , cast(tuva_last_run as TEXT) as tuva_last_run\n , dense_rank() over (\n order by data_source\n , table_name\n , claim_type\n , field_name\n ) as summary_sk\nfrom unioned_data", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_claims_for_pbi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__data_quality_claims_for_pbi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__data_quality_claims_for_pbi.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "claims", "data_quality__data_quality_claims_for_pbi"], "alias": "data_quality_claims_for_pbi", "checksum": {"name": "sha256", "checksum": "512cf2773ce8742df6d5289bbcb0795c81e47f0a005bbd8de8a63a7ca7196fc2"}, "config": {"enabled": true, "alias": "data_quality_claims_for_pbi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_claims_for_pbi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7549741, "relation_name": "dev_thuxuan.data_quality.data_quality_claims_for_pbi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',False)\r\n )\r\n}}\r\n\r\nWITH ranked_examples as (\r\n select\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n claim_type,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n drill_down_value as drill_down_value, --all claims\r\n field_value as field_value,\r\n count(drill_down_value) as frequency,\r\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\r\nWHERE bucket_name not in ('valid', 'null')\r\nGROUP BY\r\n data_source,\r\n field_name,\r\n table_name,\r\n claim_type,\r\n bucket_name,\r\n field_value,\r\n drill_down_key,\r\n drill_down_value,\r\n invalid_reason,\r\n summary_sk\r\n)\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n claim_type,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n max(drill_down_value) as drill_down_value, --1 sample claim\r\n null as field_value,\r\n count(drill_down_value) as frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\r\nWHERE bucket_name = 'null'\r\nGROUP BY\r\n data_source,\r\n field_name,\r\n table_name,\r\n claim_type,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n summary_sk\r\n\r\nunion all\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n claim_type,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n max(drill_down_value) as drill_down_value, --1 sample claim\r\n field_value as field_value,\r\n count(drill_down_value) as frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('data_quality__data_quality_claims_detail') }}\r\nWHERE bucket_name = 'valid'\r\nGROUP BY\r\n data_source,\r\n field_name,\r\n table_name,\r\n claim_type,\r\n bucket_name,\r\n field_value,\r\n invalid_reason,\r\n drill_down_key,\r\n summary_sk\r\n\r\nunion all\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n claim_type,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n drill_down_value as drill_down_value,\r\n field_value as field_value,\r\n frequency\r\n , '{{ var('tuva_last_run')}}'\r\nFROM ranked_examples\r\nWHERE rn <= 5 -- 5 Example claims per unique SK / field value\r\nunion all\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n claim_type,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n 'All Others' as drill_down_value,\r\n field_value as field_value,\r\n sum(frequency) as frequency\r\n , '{{ var('tuva_last_run')}}'\r\nFROM ranked_examples\r\nWHERE rn > 5 -- Aggregating all other rows\r\nGROUP BY\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n claim_type,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n field_value", "language": "sql", "refs": [{"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_claims_detail", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_claims_detail"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\union_processing\\claims\\data_quality__data_quality_claims_for_pbi.sql", "compiled": true, "compiled_code": "\n\nWITH ranked_examples as (\n select\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value, --all claims\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\nWHERE bucket_name not in ('valid', 'null')\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n)\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'null'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n field_value as field_value,\n count(drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'valid'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-25 14:34:26.237057+00:00'\nFROM ranked_examples\nWHERE rn <= 5 -- 5 Example claims per unique SK / field value\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-25 14:34:26.237057+00:00'\nFROM ranked_examples\nWHERE rn > 5 -- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_clinical_detail": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_clinical_detail", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\union_processing\\clinical\\data_quality__data_quality_clinical_detail.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\union_processing\\clinical\\data_quality__data_quality_clinical_detail.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_detail", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "clinical", "data_quality__data_quality_clinical_detail"], "alias": "data_quality_clinical_detail", "checksum": {"name": "sha256", "checksum": "dced978e4708727750c0986d747b5f372505efa32c7d6b29132e23d5ffa5ca0e"}, "config": {"enabled": true, "alias": "data_quality_clinical_detail", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_clinical_detail", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7569742, "relation_name": "dev_thuxuan.data_quality.data_quality_clinical_detail", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH CTE as (\r\nSELECT * FROM {{ ref('data_quality__condition_claim_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_condition_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_condition_rank') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_condition_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_normalized_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_normalized_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_normalized_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_onset_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_present_on_admit_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_present_on_admit_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_recorded_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_resolved_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_source_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_source_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__condition_status') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_admit_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_admit_source_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_admit_type_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_admit_type_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_allowed_amount') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_apr_drg_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_apr_drg_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_attending_provider_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_charge_amount') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_discharge_disposition_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_discharge_disposition_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_encounter_end_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_encounter_start_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_encounter_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_facility_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_length_of_stay') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_ms_drg_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_ms_drg_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_paid_amount') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_primary_diagnosis_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_primary_diagnosis_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__encounter_primary_diagnosis_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_practice_affiliation') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_sub_specialty') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_last_name') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_practitioner_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_npi') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_first_name') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__practitioner_specialty') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_parent_organization') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_latitude') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_facility_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_zip_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_city') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_npi') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_location_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_longitude') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_address') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_state') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__location_name') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_normalized_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_normalized_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_procedure_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_claim_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_source_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_source_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_practitioner_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_procedure_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_modifier_5') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_modifier_4') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_normalized_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_modifier_1') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_modifier_3') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__procedure_modifier_2') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_abnormal_flag') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_specimen') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_reference_range_low') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_units') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_lab_result_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_collection_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_component') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_ordering_practitioner_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_result') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_reference_range_low') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_reference_range_high') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_status') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_accession_number') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_result_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_abnormal_flag') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_units') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_normalized_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_reference_range_high') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_source_component') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__lab_result_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_sex') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_state') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_city') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_longitude') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_county') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_race') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_death_flag') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_address') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_zip_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_first_name') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_last_name') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_latitude') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_birth_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_death_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__patient_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_rxnorm_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_atc_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_dispensing_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_prescribing_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_days_supply') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_strength') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_patient_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_rxnorm_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_atc_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_quantity_unit') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_source_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_ndc_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_medication_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_source_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_ndc_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_quantity') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_practitioner_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__medication_route') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_source_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_normalized_reference_range_high') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_source_units') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_observation_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_normalized_code') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_normalized_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_data_source') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_panel_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_observation_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_source_reference_range_low') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_result') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_source_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_normalized_reference_range_low') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_observation_date') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_encounter_id') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_source_description') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_source_reference_range_high') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_normalized_units') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_normalized_code_type') }}\r\n\r\nunion all\r\n\r\nSELECT * FROM {{ ref('data_quality__observation_patient_id') }}\r\n\r\n)\r\n\r\nSELECT\r\n data_source,\r\n cast(source_date as {{ dbt.type_string() }}) as source_date,\r\n table_name,\r\n drill_down_key,\r\n drill_down_value,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n field_value,\r\n tuva_last_run,\r\n dense_rank() over (order by data_source, table_name, field_name) + 100000 as summary_sk\r\nFROM CTE", "language": "sql", "refs": [{"name": "data_quality__condition_claim_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_id", "package": null, "version": null}, {"name": "data_quality__condition_condition_rank", "package": null, "version": null}, {"name": "data_quality__condition_condition_type", "package": null, "version": null}, {"name": "data_quality__condition_data_source", "package": null, "version": null}, {"name": "data_quality__condition_encounter_id", "package": null, "version": null}, {"name": "data_quality__condition_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__condition_normalized_code", "package": null, "version": null}, {"name": "data_quality__condition_normalized_description", "package": null, "version": null}, {"name": "data_quality__condition_onset_date", "package": null, "version": null}, {"name": "data_quality__condition_patient_id", "package": null, "version": null}, {"name": "data_quality__condition_present_on_admit_code", "package": null, "version": null}, {"name": "data_quality__condition_present_on_admit_description", "package": null, "version": null}, {"name": "data_quality__condition_recorded_date", "package": null, "version": null}, {"name": "data_quality__condition_resolved_date", "package": null, "version": null}, {"name": "data_quality__condition_source_code", "package": null, "version": null}, {"name": "data_quality__condition_source_code_type", "package": null, "version": null}, {"name": "data_quality__condition_source_description", "package": null, "version": null}, {"name": "data_quality__condition_status", "package": null, "version": null}, {"name": "data_quality__encounter_admit_source_code", "package": null, "version": null}, {"name": "data_quality__encounter_admit_source_description", "package": null, "version": null}, {"name": "data_quality__encounter_admit_type_code", "package": null, "version": null}, {"name": "data_quality__encounter_admit_type_description", "package": null, "version": null}, {"name": "data_quality__encounter_allowed_amount", "package": null, "version": null}, {"name": "data_quality__encounter_apr_drg_code", "package": null, "version": null}, {"name": "data_quality__encounter_apr_drg_description", "package": null, "version": null}, {"name": "data_quality__encounter_attending_provider_id", "package": null, "version": null}, {"name": "data_quality__encounter_charge_amount", "package": null, "version": null}, {"name": "data_quality__encounter_data_source", "package": null, "version": null}, {"name": "data_quality__encounter_discharge_disposition_code", "package": null, "version": null}, {"name": "data_quality__encounter_discharge_disposition_description", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_end_date", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_id", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_start_date", "package": null, "version": null}, {"name": "data_quality__encounter_encounter_type", "package": null, "version": null}, {"name": "data_quality__encounter_facility_id", "package": null, "version": null}, {"name": "data_quality__encounter_length_of_stay", "package": null, "version": null}, {"name": "data_quality__encounter_ms_drg_code", "package": null, "version": null}, {"name": "data_quality__encounter_ms_drg_description", "package": null, "version": null}, {"name": "data_quality__encounter_paid_amount", "package": null, "version": null}, {"name": "data_quality__encounter_patient_id", "package": null, "version": null}, {"name": "data_quality__encounter_primary_diagnosis_code", "package": null, "version": null}, {"name": "data_quality__encounter_primary_diagnosis_code_type", "package": null, "version": null}, {"name": "data_quality__encounter_primary_diagnosis_description", "package": null, "version": null}, {"name": "data_quality__practitioner_practice_affiliation", "package": null, "version": null}, {"name": "data_quality__practitioner_sub_specialty", "package": null, "version": null}, {"name": "data_quality__practitioner_last_name", "package": null, "version": null}, {"name": "data_quality__practitioner_practitioner_id", "package": null, "version": null}, {"name": "data_quality__practitioner_data_source", "package": null, "version": null}, {"name": "data_quality__practitioner_npi", "package": null, "version": null}, {"name": "data_quality__practitioner_first_name", "package": null, "version": null}, {"name": "data_quality__practitioner_specialty", "package": null, "version": null}, {"name": "data_quality__location_parent_organization", "package": null, "version": null}, {"name": "data_quality__location_latitude", "package": null, "version": null}, {"name": "data_quality__location_facility_type", "package": null, "version": null}, {"name": "data_quality__location_zip_code", "package": null, "version": null}, {"name": "data_quality__location_data_source", "package": null, "version": null}, {"name": "data_quality__location_city", "package": null, "version": null}, {"name": "data_quality__location_npi", "package": null, "version": null}, {"name": "data_quality__location_location_id", "package": null, "version": null}, {"name": "data_quality__location_longitude", "package": null, "version": null}, {"name": "data_quality__location_address", "package": null, "version": null}, {"name": "data_quality__location_state", "package": null, "version": null}, {"name": "data_quality__location_name", "package": null, "version": null}, {"name": "data_quality__procedure_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__procedure_normalized_description", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_id", "package": null, "version": null}, {"name": "data_quality__procedure_claim_id", "package": null, "version": null}, {"name": "data_quality__procedure_source_code", "package": null, "version": null}, {"name": "data_quality__procedure_source_code_type", "package": null, "version": null}, {"name": "data_quality__procedure_source_description", "package": null, "version": null}, {"name": "data_quality__procedure_practitioner_id", "package": null, "version": null}, {"name": "data_quality__procedure_data_source", "package": null, "version": null}, {"name": "data_quality__procedure_patient_id", "package": null, "version": null}, {"name": "data_quality__procedure_procedure_date", "package": null, "version": null}, {"name": "data_quality__procedure_encounter_id", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_5", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_4", "package": null, "version": null}, {"name": "data_quality__procedure_normalized_code", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_1", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_3", "package": null, "version": null}, {"name": "data_quality__procedure_modifier_2", "package": null, "version": null}, {"name": "data_quality__lab_result_source_abnormal_flag", "package": null, "version": null}, {"name": "data_quality__lab_result_specimen", "package": null, "version": null}, {"name": "data_quality__lab_result_source_reference_range_low", "package": null, "version": null}, {"name": "data_quality__lab_result_source_units", "package": null, "version": null}, {"name": "data_quality__lab_result_lab_result_id", "package": null, "version": null}, {"name": "data_quality__lab_result_collection_date", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_component", "package": null, "version": null}, {"name": "data_quality__lab_result_ordering_practitioner_id", "package": null, "version": null}, {"name": "data_quality__lab_result_result", "package": null, "version": null}, {"name": "data_quality__lab_result_source_code_type", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_description", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_reference_range_low", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_reference_range_high", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_code", "package": null, "version": null}, {"name": "data_quality__lab_result_source_description", "package": null, "version": null}, {"name": "data_quality__lab_result_status", "package": null, "version": null}, {"name": "data_quality__lab_result_accession_number", "package": null, "version": null}, {"name": "data_quality__lab_result_result_date", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_abnormal_flag", "package": null, "version": null}, {"name": "data_quality__lab_result_data_source", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_units", "package": null, "version": null}, {"name": "data_quality__lab_result_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__lab_result_source_reference_range_high", "package": null, "version": null}, {"name": "data_quality__lab_result_source_code", "package": null, "version": null}, {"name": "data_quality__lab_result_patient_id", "package": null, "version": null}, {"name": "data_quality__lab_result_source_component", "package": null, "version": null}, {"name": "data_quality__lab_result_encounter_id", "package": null, "version": null}, {"name": "data_quality__patient_sex", "package": null, "version": null}, {"name": "data_quality__patient_state", "package": null, "version": null}, {"name": "data_quality__patient_city", "package": null, "version": null}, {"name": "data_quality__patient_longitude", "package": null, "version": null}, {"name": "data_quality__patient_county", "package": null, "version": null}, {"name": "data_quality__patient_race", "package": null, "version": null}, {"name": "data_quality__patient_death_flag", "package": null, "version": null}, {"name": "data_quality__patient_address", "package": null, "version": null}, {"name": "data_quality__patient_data_source", "package": null, "version": null}, {"name": "data_quality__patient_zip_code", "package": null, "version": null}, {"name": "data_quality__patient_first_name", "package": null, "version": null}, {"name": "data_quality__patient_last_name", "package": null, "version": null}, {"name": "data_quality__patient_latitude", "package": null, "version": null}, {"name": "data_quality__patient_birth_date", "package": null, "version": null}, {"name": "data_quality__patient_death_date", "package": null, "version": null}, {"name": "data_quality__patient_patient_id", "package": null, "version": null}, {"name": "data_quality__medication_rxnorm_code", "package": null, "version": null}, {"name": "data_quality__medication_source_code", "package": null, "version": null}, {"name": "data_quality__medication_atc_code", "package": null, "version": null}, {"name": "data_quality__medication_dispensing_date", "package": null, "version": null}, {"name": "data_quality__medication_prescribing_date", "package": null, "version": null}, {"name": "data_quality__medication_days_supply", "package": null, "version": null}, {"name": "data_quality__medication_strength", "package": null, "version": null}, {"name": "data_quality__medication_patient_id", "package": null, "version": null}, {"name": "data_quality__medication_rxnorm_description", "package": null, "version": null}, {"name": "data_quality__medication_encounter_id", "package": null, "version": null}, {"name": "data_quality__medication_data_source", "package": null, "version": null}, {"name": "data_quality__medication_atc_description", "package": null, "version": null}, {"name": "data_quality__medication_quantity_unit", "package": null, "version": null}, {"name": "data_quality__medication_source_description", "package": null, "version": null}, {"name": "data_quality__medication_ndc_code", "package": null, "version": null}, {"name": "data_quality__medication_medication_id", "package": null, "version": null}, {"name": "data_quality__medication_source_code_type", "package": null, "version": null}, {"name": "data_quality__medication_ndc_description", "package": null, "version": null}, {"name": "data_quality__medication_quantity", "package": null, "version": null}, {"name": "data_quality__medication_practitioner_id", "package": null, "version": null}, {"name": "data_quality__medication_route", "package": null, "version": null}, {"name": "data_quality__observation_source_code", "package": null, "version": null}, {"name": "data_quality__observation_normalized_reference_range_high", "package": null, "version": null}, {"name": "data_quality__observation_source_units", "package": null, "version": null}, {"name": "data_quality__observation_observation_type", "package": null, "version": null}, {"name": "data_quality__observation_normalized_code", "package": null, "version": null}, {"name": "data_quality__observation_normalized_description", "package": null, "version": null}, {"name": "data_quality__observation_data_source", "package": null, "version": null}, {"name": "data_quality__observation_panel_id", "package": null, "version": null}, {"name": "data_quality__observation_observation_id", "package": null, "version": null}, {"name": "data_quality__observation_source_reference_range_low", "package": null, "version": null}, {"name": "data_quality__observation_result", "package": null, "version": null}, {"name": "data_quality__observation_source_code_type", "package": null, "version": null}, {"name": "data_quality__observation_normalized_reference_range_low", "package": null, "version": null}, {"name": "data_quality__observation_observation_date", "package": null, "version": null}, {"name": "data_quality__observation_encounter_id", "package": null, "version": null}, {"name": "data_quality__observation_source_description", "package": null, "version": null}, {"name": "data_quality__observation_source_reference_range_high", "package": null, "version": null}, {"name": "data_quality__observation_normalized_units", "package": null, "version": null}, {"name": "data_quality__observation_normalized_code_type", "package": null, "version": null}, {"name": "data_quality__observation_patient_id", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.data_quality__condition_claim_id", "model.the_tuva_project.data_quality__condition_condition_id", "model.the_tuva_project.data_quality__condition_condition_rank", "model.the_tuva_project.data_quality__condition_condition_type", "model.the_tuva_project.data_quality__condition_data_source", "model.the_tuva_project.data_quality__condition_encounter_id", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__condition_normalized_description", "model.the_tuva_project.data_quality__condition_onset_date", "model.the_tuva_project.data_quality__condition_patient_id", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.data_quality__condition_present_on_admit_description", "model.the_tuva_project.data_quality__condition_recorded_date", "model.the_tuva_project.data_quality__condition_resolved_date", "model.the_tuva_project.data_quality__condition_source_code", "model.the_tuva_project.data_quality__condition_source_code_type", "model.the_tuva_project.data_quality__condition_source_description", "model.the_tuva_project.data_quality__condition_status", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__encounter_admit_source_description", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__encounter_admit_type_description", "model.the_tuva_project.data_quality__encounter_allowed_amount", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__encounter_apr_drg_description", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_charge_amount", "model.the_tuva_project.data_quality__encounter_data_source", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "model.the_tuva_project.data_quality__encounter_encounter_end_date", "model.the_tuva_project.data_quality__encounter_encounter_id", "model.the_tuva_project.data_quality__encounter_encounter_start_date", "model.the_tuva_project.data_quality__encounter_encounter_type", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__encounter_length_of_stay", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__encounter_ms_drg_description", "model.the_tuva_project.data_quality__encounter_paid_amount", "model.the_tuva_project.data_quality__encounter_patient_id", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "model.the_tuva_project.data_quality__practitioner_sub_specialty", "model.the_tuva_project.data_quality__practitioner_last_name", "model.the_tuva_project.data_quality__practitioner_practitioner_id", "model.the_tuva_project.data_quality__practitioner_data_source", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__practitioner_first_name", "model.the_tuva_project.data_quality__practitioner_specialty", "model.the_tuva_project.data_quality__location_parent_organization", "model.the_tuva_project.data_quality__location_latitude", "model.the_tuva_project.data_quality__location_facility_type", "model.the_tuva_project.data_quality__location_zip_code", "model.the_tuva_project.data_quality__location_data_source", "model.the_tuva_project.data_quality__location_city", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__location_location_id", "model.the_tuva_project.data_quality__location_longitude", "model.the_tuva_project.data_quality__location_address", "model.the_tuva_project.data_quality__location_state", "model.the_tuva_project.data_quality__location_name", "model.the_tuva_project.data_quality__procedure_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_description", "model.the_tuva_project.data_quality__procedure_procedure_id", "model.the_tuva_project.data_quality__procedure_claim_id", "model.the_tuva_project.data_quality__procedure_source_code", "model.the_tuva_project.data_quality__procedure_source_code_type", "model.the_tuva_project.data_quality__procedure_source_description", "model.the_tuva_project.data_quality__procedure_practitioner_id", "model.the_tuva_project.data_quality__procedure_data_source", "model.the_tuva_project.data_quality__procedure_patient_id", "model.the_tuva_project.data_quality__procedure_procedure_date", "model.the_tuva_project.data_quality__procedure_encounter_id", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_specimen", "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "model.the_tuva_project.data_quality__lab_result_source_units", "model.the_tuva_project.data_quality__lab_result_lab_result_id", "model.the_tuva_project.data_quality__lab_result_collection_date", "model.the_tuva_project.data_quality__lab_result_normalized_component", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__lab_result_result", "model.the_tuva_project.data_quality__lab_result_source_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_description", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_source_description", "model.the_tuva_project.data_quality__lab_result_status", "model.the_tuva_project.data_quality__lab_result_accession_number", "model.the_tuva_project.data_quality__lab_result_result_date", "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_data_source", "model.the_tuva_project.data_quality__lab_result_normalized_units", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "model.the_tuva_project.data_quality__lab_result_source_code", "model.the_tuva_project.data_quality__lab_result_patient_id", "model.the_tuva_project.data_quality__lab_result_source_component", "model.the_tuva_project.data_quality__lab_result_encounter_id", "model.the_tuva_project.data_quality__patient_sex", "model.the_tuva_project.data_quality__patient_state", "model.the_tuva_project.data_quality__patient_city", "model.the_tuva_project.data_quality__patient_longitude", "model.the_tuva_project.data_quality__patient_county", "model.the_tuva_project.data_quality__patient_race", "model.the_tuva_project.data_quality__patient_death_flag", "model.the_tuva_project.data_quality__patient_address", "model.the_tuva_project.data_quality__patient_data_source", "model.the_tuva_project.data_quality__patient_zip_code", "model.the_tuva_project.data_quality__patient_first_name", "model.the_tuva_project.data_quality__patient_last_name", "model.the_tuva_project.data_quality__patient_latitude", "model.the_tuva_project.data_quality__patient_birth_date", "model.the_tuva_project.data_quality__patient_death_date", "model.the_tuva_project.data_quality__patient_patient_id", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.data_quality__medication_source_code", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_dispensing_date", "model.the_tuva_project.data_quality__medication_prescribing_date", "model.the_tuva_project.data_quality__medication_days_supply", "model.the_tuva_project.data_quality__medication_strength", "model.the_tuva_project.data_quality__medication_patient_id", "model.the_tuva_project.data_quality__medication_rxnorm_description", "model.the_tuva_project.data_quality__medication_encounter_id", "model.the_tuva_project.data_quality__medication_data_source", "model.the_tuva_project.data_quality__medication_atc_description", "model.the_tuva_project.data_quality__medication_quantity_unit", "model.the_tuva_project.data_quality__medication_source_description", "model.the_tuva_project.data_quality__medication_ndc_code", "model.the_tuva_project.data_quality__medication_medication_id", "model.the_tuva_project.data_quality__medication_source_code_type", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__medication_quantity", "model.the_tuva_project.data_quality__medication_practitioner_id", "model.the_tuva_project.data_quality__medication_route", "model.the_tuva_project.data_quality__observation_source_code", "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "model.the_tuva_project.data_quality__observation_source_units", "model.the_tuva_project.data_quality__observation_observation_type", "model.the_tuva_project.data_quality__observation_normalized_code", "model.the_tuva_project.data_quality__observation_normalized_description", "model.the_tuva_project.data_quality__observation_data_source", "model.the_tuva_project.data_quality__observation_panel_id", "model.the_tuva_project.data_quality__observation_observation_id", "model.the_tuva_project.data_quality__observation_source_reference_range_low", "model.the_tuva_project.data_quality__observation_result", "model.the_tuva_project.data_quality__observation_source_code_type", "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "model.the_tuva_project.data_quality__observation_observation_date", "model.the_tuva_project.data_quality__observation_encounter_id", "model.the_tuva_project.data_quality__observation_source_description", "model.the_tuva_project.data_quality__observation_source_reference_range_high", "model.the_tuva_project.data_quality__observation_normalized_units", "model.the_tuva_project.data_quality__observation_normalized_code_type", "model.the_tuva_project.data_quality__observation_patient_id"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\union_processing\\clinical\\data_quality__data_quality_clinical_detail.sql", "compiled": true, "compiled_code": "\n\nWITH CTE as (\nSELECT * FROM dev_thuxuan.data_quality.condition_claim_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_condition_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_condition_rank\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_condition_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_onset_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_present_on_admit_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_present_on_admit_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_recorded_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_resolved_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_status\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_type_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_type_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_allowed_amount\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_apr_drg_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_apr_drg_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_attending_provider_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_charge_amount\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_discharge_disposition_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_discharge_disposition_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_end_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_start_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_facility_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_length_of_stay\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_ms_drg_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_ms_drg_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_paid_amount\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_primary_diagnosis_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_primary_diagnosis_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_primary_diagnosis_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_practice_affiliation\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_sub_specialty\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_last_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_npi\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_first_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_specialty\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_parent_organization\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_latitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_facility_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_zip_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_city\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_npi\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_location_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_longitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_address\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_state\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_procedure_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_claim_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_procedure_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_5\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_4\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_1\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_3\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_2\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_abnormal_flag\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_specimen\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_collection_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_component\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_ordering_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_result\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_status\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_accession_number\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_result_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_abnormal_flag\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_component\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_sex\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_state\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_city\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_longitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_county\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_race\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_death_flag\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_address\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_zip_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_first_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_last_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_latitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_birth_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_death_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_rxnorm_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_atc_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_dispensing_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_prescribing_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_days_supply\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_strength\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_rxnorm_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_atc_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_quantity_unit\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_ndc_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_medication_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_ndc_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_quantity\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_route\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_observation_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_panel_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_observation_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_result\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_observation_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_patient_id\n\n)\n\nSELECT\n data_source,\n cast(source_date as TEXT) as source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n bucket_name,\n invalid_reason,\n field_value,\n tuva_last_run,\n dense_rank() over (order by data_source, table_name, field_name) + 100000 as summary_sk\nFROM CTE", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_clinical_for_pbi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\intermediate\\union_processing\\clinical\\data_quality__data_quality_clinical_for_pbi.sql", "original_file_path": "models\\data_quality\\dqi\\intermediate\\union_processing\\clinical\\data_quality__data_quality_clinical_for_pbi.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "fqn": ["the_tuva_project", "data_quality", "dqi", "intermediate", "union_processing", "clinical", "data_quality__data_quality_clinical_for_pbi"], "alias": "data_quality_clinical_for_pbi", "checksum": {"name": "sha256", "checksum": "52f4045ab329805d21428dc12d82bc8f873790b815e19b8fdebe7e89aa92c74b"}, "config": {"enabled": true, "alias": "data_quality_clinical_for_pbi", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_clinical_for_pbi", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.758976, "relation_name": "dev_thuxuan.data_quality.data_quality_clinical_for_pbi", "raw_code": "{{ config(\r\n enabled = var('clinical_enabled',False)\r\n )\r\n}}\r\n\r\nWITH Ranked_Examples as (\r\n SELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n drill_down_value as drill_down_value,\r\n field_value as field_value,\r\n count(drill_down_value) as frequency,\r\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n FROM {{ ref('data_quality__data_quality_clinical_detail') }}\r\n where bucket_name not in ('valid', 'null')\r\n group by\r\n data_source,\r\n field_name,\r\n table_name,\r\n bucket_name,\r\n field_value,\r\n drill_down_key,\r\n drill_down_value,\r\n invalid_reason,\r\n summary_sk\r\n\r\n),\r\n\r\npk_examples as (\r\n SELECT\r\n detail.summary_sk,\r\n detail.data_source,\r\n detail.table_name,\r\n detail.field_name,\r\n detail.bucket_name,\r\n detail.invalid_reason,\r\n detail.drill_down_key,\r\n detail.drill_down_value as drill_down_value,\r\n detail.field_value as field_value,\r\n count(detail.drill_down_value) as frequency,\r\n row_number() over (partition by detail.summary_sk order by detail.summary_sk) as rn\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('data_quality__data_quality_clinical_detail') }} as detail\r\n left join {{ ref('data_quality__crosswalk_field_info')}} as field_info on detail.table_name = field_info.input_layer_table_name\r\n and detail.field_name = field_info.field_name\r\n where detail.bucket_name = 'valid'\r\n and field_info.unique_values_expected_flag = 1\r\n GROUP BY\r\n detail.data_source,\r\n detail.field_name,\r\n detail.table_name,\r\n detail.bucket_name,\r\n detail.field_value,\r\n detail.drill_down_key,\r\n detail.drill_down_value,\r\n detail.invalid_reason,\r\n detail.summary_sk\r\n\r\n)\r\n--- Null Values\r\n\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n max(drill_down_value) as drill_down_value,\r\n null as field_value,\r\n count(drill_down_value) as frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('data_quality__data_quality_clinical_detail') }}\r\nwhere bucket_name = 'null'\r\ngroup by\r\n data_source,\r\n field_name,\r\n table_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n summary_sk\r\n\r\nunion all\r\n\r\n--- Valid Values except PKs\r\n\r\nSELECT\r\n detail.summary_sk,\r\n detail.data_source,\r\n detail.table_name,\r\n detail.field_name,\r\n detail.bucket_name,\r\n detail.invalid_reason,\r\n detail.drill_down_key,\r\n max(detail.drill_down_value) as drill_down_value,\r\n detail.field_value as field_value,\r\n count(detail.drill_down_value) as frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('data_quality__data_quality_clinical_detail') }} as detail\r\nleft join {{ ref('data_quality__crosswalk_field_info') }} as field_info on detail.table_name = field_info.input_layer_table_name\r\n and detail.field_name = field_info.field_name\r\nWHERE\r\n detail.bucket_name = 'valid'\r\n and field_info.unique_values_expected_flag = 0 --- need to handle pks differently since every value is supposed to be unique\r\ngroup by\r\n detail.data_source,\r\n detail.field_name,\r\n detail.table_name,\r\n detail.bucket_name,\r\n detail.field_value,\r\n detail.invalid_reason,\r\n detail.drill_down_key,\r\n detail.summary_sk\r\n\r\nunion all\r\n\r\n-- 5 Examples of each invalid example\r\n\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n drill_down_value as drill_down_value,\r\n field_value as field_value,\r\n frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM Ranked_Examples\r\nWHERE rn <= 5\r\n\r\nunion all\r\n\r\n--- Aggregating all other invalid examples into single row\r\n\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n 'all others' as drill_down_value,\r\n field_value as field_value,\r\n sum(frequency) as frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM Ranked_Examples\r\nWHERE rn > 5 --- Aggregating all other rows\r\nGROUP BY\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n field_value\r\n\r\nunion all\r\n\r\n--- 5 Examples of valid primary key values\r\n\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n drill_down_value as drill_down_value,\r\n field_value as field_value,\r\n frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM pk_examples\r\nWHERE rn <= 5\r\n\r\nunion all\r\n\r\n--- Aggegating all other valid primary key value examples\r\n\r\nSELECT\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n 'All Others' as drill_down_value,\r\n 'All Others' as field_value,\r\n sum(frequency) as frequency\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM pk_examples\r\nWHERE rn > 5 --- Aggregating all other rows\r\nGROUP BY\r\n summary_sk,\r\n data_source,\r\n table_name,\r\n field_name,\r\n bucket_name,\r\n invalid_reason,\r\n drill_down_key,\r\n field_value", "language": "sql", "refs": [{"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_info", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__data_quality_clinical_detail", "package": null, "version": null}, {"name": "data_quality__crosswalk_field_info", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\intermediate\\union_processing\\clinical\\data_quality__data_quality_clinical_for_pbi.sql", "compiled": true, "compiled_code": "\n\nWITH Ranked_Examples as (\n SELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n FROM dev_thuxuan.data_quality.data_quality_clinical_detail\n where bucket_name not in ('valid', 'null')\n group by\n data_source,\n field_name,\n table_name,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n\n),\n\npk_examples as (\n SELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.drill_down_value as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency,\n row_number() over (partition by detail.summary_sk order by detail.summary_sk) as rn\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.data_quality.data_quality_clinical_detail as detail\n left join dev_thuxuan.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\n where detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 1\n GROUP BY\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.drill_down_key,\n detail.drill_down_value,\n detail.invalid_reason,\n detail.summary_sk\n\n)\n--- Null Values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value,\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality.data_quality_clinical_detail\nwhere bucket_name = 'null'\ngroup by\n data_source,\n field_name,\n table_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\n\n--- Valid Values except PKs\n\nSELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n max(detail.drill_down_value) as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality.data_quality_clinical_detail as detail\nleft join dev_thuxuan.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\nWHERE\n detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 0 --- need to handle pks differently since every value is supposed to be unique\ngroup by\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.summary_sk\n\nunion all\n\n-- 5 Examples of each invalid example\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggregating all other invalid examples into single row\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'all others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value\n\nunion all\n\n--- 5 Examples of valid primary key values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggegating all other valid primary key value examples\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n 'All Others' as field_value,\n sum(frequency) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__calendar_month": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__calendar_month", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__calendar_month.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__calendar_month.sql", "unique_id": "model.the_tuva_project.mart_review__calendar_month", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__calendar_month"], "alias": "mart_review__calendar_month", "checksum": {"name": "sha256", "checksum": "4128ece0c6bb7247a2caea25ae8d06047c750288de46a0511b208b7193ee6ed4"}, "config": {"enabled": true, "alias": "mart_review__calendar_month", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__calendar_month", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7971423, "relation_name": "dev_thuxuan.data_quality.mart_review__calendar_month", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect distinct\r\ncast(year_month_int as {{ dbt.type_string() }}) as year_month\r\n, full_date\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('reference_data__calendar') }} c\r\nwhere day = 1", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__calendar_month.sql", "compiled": true, "compiled_code": "\n\n\nselect distinct\ncast(year_month_int as TEXT) as year_month\n, full_date\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.reference_data.calendar c\nwhere day = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__claims_with_enrollment": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__claims_with_enrollment", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__claims_with_enrollment.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__claims_with_enrollment.sql", "unique_id": "model.the_tuva_project.mart_review__claims_with_enrollment", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__claims_with_enrollment"], "alias": "mart_review__claims_with_enrollment", "checksum": {"name": "sha256", "checksum": "25f4df0b1d93dc2e1748d42ecfa40a54987d3240778a2e81146764b464edc8d4"}, "config": {"enabled": true, "alias": "mart_review__claims_with_enrollment", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__claims_with_enrollment", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7681253, "relation_name": "dev_thuxuan.data_quality.mart_review__claims_with_enrollment", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith enrollment_stage as(\r\nSELECT\r\n mc.data_source,\r\n mc.year_month,\r\n SUM(CASE WHEN mm.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS claims_with_enrollment,\r\n COUNT(*) AS claims\r\nFROM {{ ref('mart_review__stg_medical_claim') }} mc\r\nLEFT JOIN {{ ref('core__member_months')}} mm\r\n ON mc.patient_id = mm.patient_id\r\n AND mc.data_source = mm.data_source\r\n AND mc.year_month = mm.year_month\r\nGROUP BY mc.data_source\r\n, mc.year_month\r\n)\r\n\r\nselect\r\n data_source\r\n , year_month\r\n , claims_with_enrollment\r\n , claims\r\n , cast(claims_with_enrollment / claims as {{ dbt.type_numeric()}} ) AS percentage_claims_with_enrollment\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom enrollment_stage", "language": "sql", "refs": [{"name": "mart_review__stg_medical_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__claims_with_enrollment.sql", "compiled": true, "compiled_code": "\n\nwith enrollment_stage as(\nSELECT\n mc.data_source,\n mc.year_month,\n SUM(CASE WHEN mm.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS claims_with_enrollment,\n COUNT(*) AS claims\nFROM dev_thuxuan.data_quality.mart_review__stg_medical_claim mc\nLEFT JOIN dev_thuxuan.core.member_months mm\n ON mc.patient_id = mm.patient_id\n AND mc.data_source = mm.data_source\n AND mc.year_month = mm.year_month\nGROUP BY mc.data_source\n, mc.year_month\n)\n\nselect\n data_source\n , year_month\n , claims_with_enrollment\n , claims\n , cast(claims_with_enrollment / claims as numeric(28,6) ) AS percentage_claims_with_enrollment\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom enrollment_stage", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__data_source": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__data_source", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__data_source.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__data_source.sql", "unique_id": "model.the_tuva_project.mart_review__data_source", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__data_source"], "alias": "mart_review__data_source", "checksum": {"name": "sha256", "checksum": "61a0fa6b7f886c9b1feac0dffddf8763b7dad578633fcae936d4a0e1afc4f945"}, "config": {"enabled": true, "alias": "mart_review__data_source", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__data_source", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7702258, "relation_name": "dev_thuxuan.data_quality.mart_review__data_source", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith data_sources as (\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__condition')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__eligibility')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__encounter')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__location')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__medical_claim')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__member_months')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__patient')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__pharmacy_claim')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__practitioner')}}\r\n\r\nUNION ALL\r\n\r\nSELECT DISTINCT data_source\r\nFROM {{ ref('core__procedure')}}\r\n)\r\n\r\nSELECT DISTINCT\r\n data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom data_sources", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__location", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "core__practitioner", "package": null, "version": null}, {"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__location", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__patient", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__practitioner", "model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__data_source.sql", "compiled": true, "compiled_code": "\n\nwith data_sources as (\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.condition\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.eligibility\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.encounter\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.location\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.medical_claim\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.member_months\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.patient\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.pharmacy_claim\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.practitioner\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.procedure\n)\n\nSELECT DISTINCT\n data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom data_sources", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__ed_classification": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__ed_classification", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__ed_classification.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__ed_classification.sql", "unique_id": "model.the_tuva_project.mart_review__ed_classification", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__ed_classification"], "alias": "mart_review__ed_classification", "checksum": {"name": "sha256", "checksum": "c5ac2a2395ee7798dd2864780b7f2c701884e8aee2d25e27388a638158614b75"}, "config": {"enabled": true, "alias": "mart_review__ed_classification", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__ed_classification", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7732234, "relation_name": "dev_thuxuan.data_quality.mart_review__ed_classification", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nWITH cte AS\r\n(\r\n SELECT DISTINCT location_id, npi, name\r\n FROM {{ ref('core__location')}}\r\n)\r\n\r\nSELECT\r\n e.encounter_id,\r\n case when s.encounter_id is null then 'Not Classified' else s.ed_classification_description end as ed_classification_description,\r\n CASE\r\n when s.encounter_id is null then 'Non-Avoidable'\r\n when cast(s.ed_classification_order as int) <= 3 then s.ed_classification_description\r\n ELSE 'Non-Avoidable' END AS avoidable_category,\r\n e.paid_amount,\r\n e.primary_diagnosis_code,\r\n e.primary_diagnosis_description,\r\n {{ dbt.concat([\r\n 'e.primary_diagnosis_code',\r\n \"'|'\",\r\n 'e.primary_diagnosis_description'\r\n ]) }} as primary_diagnosis_and_description,\r\n p.ccsr_parent_category,\r\n p.ccsr_category,\r\n p.ccsr_category_description,\r\n {{ dbt.concat([\r\n 'p.ccsr_category',\r\n \"'|'\",\r\n 'p.ccsr_category_description'\r\n ]) }} as ccsr_parent_category_and_description,\r\n b.body_system,\r\n e.facility_id,\r\n e.allowed_amount,\r\n e.charge_amount,\r\n e.data_source,\r\n e.length_of_stay,\r\n {{ dbt.concat([\r\n \"e.discharge_disposition_code\",\r\n \"'|'\",\r\n \"e.discharge_disposition_description\"\r\n ]) }} as discharge_code_and_description,\r\n {{ dbt.concat([\r\n \"e.patient_id\",\r\n \"'|'\",\r\n \"e.data_source\"\r\n ]) }} as patient_source_key,\r\n e.facility_name,\r\n e.encounter_start_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__encounter')}} e\r\nleft join {{ ref('ed_classification__summary') }} s on e.encounter_id = s.encounter_id\r\nleft join cte on e.facility_id = cte.location_id\r\nleft join {{ ref('ccsr__dx_vertical_pivot') }} as p\r\n on e.primary_diagnosis_code = p.code\r\n and p.ccsr_category_rank = 1\r\nleft join {{ ref('ccsr__dxccsr_v2023_1_body_systems') }} b on p.ccsr_parent_category = b.ccsr_parent_category\r\nwhere e.encounter_type = 'emergency department'", "language": "sql", "refs": [{"name": "core__location", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "ed_classification__summary", "package": null, "version": null}, {"name": "ccsr__dx_vertical_pivot", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_body_systems", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__location", "model.the_tuva_project.core__encounter", "model.the_tuva_project.ed_classification__summary", "model.the_tuva_project.ccsr__dx_vertical_pivot", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__ed_classification.sql", "compiled": true, "compiled_code": "\n\nWITH cte AS\n(\n SELECT DISTINCT location_id, npi, name\n FROM dev_thuxuan.core.location\n)\n\nSELECT\n e.encounter_id,\n case when s.encounter_id is null then 'Not Classified' else s.ed_classification_description end as ed_classification_description,\n CASE\n when s.encounter_id is null then 'Non-Avoidable'\n when cast(s.ed_classification_order as int) <= 3 then s.ed_classification_description\n ELSE 'Non-Avoidable' END AS avoidable_category,\n e.paid_amount,\n e.primary_diagnosis_code,\n e.primary_diagnosis_description,\n e.primary_diagnosis_code || '|' || e.primary_diagnosis_description as primary_diagnosis_and_description,\n p.ccsr_parent_category,\n p.ccsr_category,\n p.ccsr_category_description,\n p.ccsr_category || '|' || p.ccsr_category_description as ccsr_parent_category_and_description,\n b.body_system,\n e.facility_id,\n e.allowed_amount,\n e.charge_amount,\n e.data_source,\n e.length_of_stay,\n e.discharge_disposition_code || '|' || e.discharge_disposition_description as discharge_code_and_description,\n e.patient_id || '|' || e.data_source as patient_source_key,\n e.facility_name,\n e.encounter_start_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter e\nleft join dev_thuxuan.ed_classification.summary s on e.encounter_id = s.encounter_id\nleft join cte on e.facility_id = cte.location_id\nleft join dev_thuxuan.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\nleft join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems b on p.ccsr_parent_category = b.ccsr_parent_category\nwhere e.encounter_type = 'emergency department'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__enrollment_change": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__enrollment_change", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__enrollment_change.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__enrollment_change.sql", "unique_id": "model.the_tuva_project.mart_review__enrollment_change", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__enrollment_change"], "alias": "mart_review__enrollment_change", "checksum": {"name": "sha256", "checksum": "4458acf9a98a2d4410cec4ce8e079944e2efd09bfc5d676a42725ed98593d6cd"}, "config": {"enabled": true, "alias": "mart_review__enrollment_change", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__enrollment_change", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7752237, "relation_name": "dev_thuxuan.data_quality.mart_review__enrollment_change", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nWITH RankedMonths AS (\r\n SELECT\r\n patient_id,\r\n year_month,\r\n data_source,\r\n lag(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as prev_year_month,\r\n lead(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as next_year_month,\r\n year_month_date\r\n FROM {{ ref('mart_review__stg_member_month') }}\r\n),\r\nChanges AS (\r\n SELECT\r\n patient_id,\r\n data_source,\r\n year_month_date as change_month,\r\n case\r\n when prev_year_month is null\r\n or {{ dateadd('month', -1, 'year_month_date') }} != prev_year_month\r\n then 'added'\r\n end as change_type\r\nFROM RankedMonths\r\nunion all\r\nSELECT\r\n patient_id,\r\n data_source,\r\n {{ dateadd('month', 1, 'year_month_date') }} as change_month,\r\n case\r\n when next_year_month is null\r\n or {{ dateadd('month', 1, 'year_month_date') }} != next_year_month\r\n then 'removed'\r\n end as change_type\r\nFROM RankedMonths\r\n\r\n),\r\nFinal AS (\r\n SELECT\r\n {{ dbt.concat([\"patient_id\", \"'|'\", \"change_month\"]) }} as membermonthkey,\r\n data_source,\r\n patient_id,\r\n change_month,\r\n change_type\r\n FROM Changes\r\n WHERE change_type IS NOT NULL\r\n),\r\nResult AS (\r\n SELECT\r\n data_source,\r\n change_month,\r\n change_type,\r\n count(*) as member_count\r\n FROM Final\r\n GROUP BY data_source\r\n , change_month\r\n , change_type\r\n)\r\n\r\n\r\nSELECT * , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM Result", "language": "sql", "refs": [{"name": "mart_review__stg_member_month", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.mart_review__stg_member_month"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__enrollment_change.sql", "compiled": true, "compiled_code": "\n\nWITH RankedMonths AS (\n SELECT\n patient_id,\n year_month,\n data_source,\n lag(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as prev_year_month,\n lead(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as next_year_month,\n year_month_date\n FROM dev_thuxuan.data_quality.mart_review__stg_member_month\n),\nChanges AS (\n SELECT\n patient_id,\n data_source,\n year_month_date as change_month,\n case\n when prev_year_month is null\n or \n\n dateadd(\n month,\n -1,\n year_month_date\n )\n\n != prev_year_month\n then 'added'\n end as change_type\nFROM RankedMonths\nunion all\nSELECT\n patient_id,\n data_source,\n \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n as change_month,\n case\n when next_year_month is null\n or \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n != next_year_month\n then 'removed'\n end as change_type\nFROM RankedMonths\n\n),\nFinal AS (\n SELECT\n patient_id || '|' || change_month as membermonthkey,\n data_source,\n patient_id,\n change_month,\n change_type\n FROM Changes\n WHERE change_type IS NOT NULL\n),\nResult AS (\n SELECT\n data_source,\n change_month,\n change_type,\n count(*) as member_count\n FROM Final\n GROUP BY data_source\n , change_month\n , change_type\n)\n\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM Result", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__generics": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__generics", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__generics.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__generics.sql", "unique_id": "model.the_tuva_project.mart_review__generics", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__generics"], "alias": "mart_review__generics", "checksum": {"name": "sha256", "checksum": "aa713634f7e81cb7d98a3fc9aaae957457a07034d39d5fe77894efa23ab557fd"}, "config": {"enabled": true, "alias": "mart_review__generics", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__generics", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8066437, "relation_name": "dev_thuxuan.data_quality.mart_review__generics", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nselect *\r\nfrom {{ ref('pharmacy__generic_available_list') }}", "language": "sql", "refs": [{"name": "pharmacy__generic_available_list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__generic_available_list"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__generics.sql", "compiled": true, "compiled_code": "\n\nselect *\nfrom dev_thuxuan.pharmacy.generic_available_list", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__inpatient": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__inpatient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__inpatient.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__inpatient.sql", "unique_id": "model.the_tuva_project.mart_review__inpatient", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__inpatient"], "alias": "mart_review__inpatient", "checksum": {"name": "sha256", "checksum": "c6be8c5ede69ae5e161841c95597657f5b9d0a3ab0ab2c8783a6e4344c7c7a03"}, "config": {"enabled": true, "alias": "mart_review__inpatient", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__inpatient", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7772238, "relation_name": "dev_thuxuan.data_quality.mart_review__inpatient", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith cte as (\r\n select distinct\r\n location_id\r\n , npi\r\n , name\r\n from {{ ref('core__location') }}\r\n)\r\n\r\n, final as (\r\n select\r\n e.*\r\n , {{ dbt.concat(['e.patient_id', \"'|'\", 'e.data_source']) }} as patient_source_key\r\n , {{ dbt.concat(['e.encounter_id', \"'|'\", 'e.data_source']) }} as encounter_source_key\r\n , {{ dbt.concat(['e.ms_drg_code', \"'|'\", 'e.ms_drg_description']) }} as drgwithdescription\r\n , {{ dbt.concat(['e.primary_diagnosis_code', \"'|'\", 'e.primary_diagnosis_description']) }} as primary_diagnosis_and_description\r\n , {{ dbt.concat(['e.admit_source_code', \"'|'\", 'e.admit_source_description']) }} as admit_source_code_and_description\r\n , {{ dbt.concat(['e.admit_type_code', \"'|'\", 'e.admit_type_description']) }} as admit_type_code_and_description\r\n , {{ dbt.concat(['e.discharge_disposition_code', \"'|'\", 'e.discharge_disposition_description']) }} as discharge_code_and_description\r\n , p.ccsr_parent_category\r\n , p.ccsr_category\r\n , p.ccsr_category_description\r\n , {{ dbt.concat(['p.ccsr_category', \"'|'\", 'p.ccsr_category_description']) }} as ccsr_category_and_description\r\n , b.body_system\r\n , case \r\n when e.length_of_stay <= 1 then '1. 0-1 day'\r\n when e.length_of_stay <= 3 then '2. 2-3 days'\r\n when e.length_of_stay <= 5 then '3. 4-5 days'\r\n when e.length_of_stay <= 7 then '4. 6-7 days'\r\n when e.length_of_stay <= 14 then '5. 8-14 days'\r\n when e.length_of_stay <= 30 then '6. 15-30 days'\r\n else '7. 31+ Days'\r\n end as los_groups\r\n , weights.drg_weight\r\n from {{ ref('core__encounter') }} as e\r\n left join cte as l\r\n on e.facility_id = l.location_id\r\n left join {{ ref('ccsr__dx_vertical_pivot') }} as p\r\n on e.primary_diagnosis_code = p.code\r\n and p.ccsr_category_rank = 1\r\n left join {{ ref('ccsr__dxccsr_v2023_1_body_systems') }} as b\r\n on p.ccsr_parent_category = b.ccsr_parent_category\r\n left join {{ ref('terminology__ms_drg_weights_los')}} as weights\r\n on e.ms_drg_code = weights.ms_drg\r\n where e.encounter_type = 'acute inpatient'\r\n)\r\n\r\nselect * from final", "language": "sql", "refs": [{"name": "core__location", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "ccsr__dx_vertical_pivot", "package": null, "version": null}, {"name": "ccsr__dxccsr_v2023_1_body_systems", "package": null, "version": null}, {"name": "terminology__ms_drg_weights_los", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__location", "model.the_tuva_project.core__encounter", "model.the_tuva_project.ccsr__dx_vertical_pivot", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems", "seed.the_tuva_project.terminology__ms_drg_weights_los"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__inpatient.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n location_id\n , npi\n , name\n from dev_thuxuan.core.location\n)\n\n, final as (\n select\n e.*\n , e.patient_id || '|' || e.data_source as patient_source_key\n , e.encounter_id || '|' || e.data_source as encounter_source_key\n , e.ms_drg_code || '|' || e.ms_drg_description as drgwithdescription\n , e.primary_diagnosis_code || '|' || e.primary_diagnosis_description as primary_diagnosis_and_description\n , e.admit_source_code || '|' || e.admit_source_description as admit_source_code_and_description\n , e.admit_type_code || '|' || e.admit_type_description as admit_type_code_and_description\n , e.discharge_disposition_code || '|' || e.discharge_disposition_description as discharge_code_and_description\n , p.ccsr_parent_category\n , p.ccsr_category\n , p.ccsr_category_description\n , p.ccsr_category || '|' || p.ccsr_category_description as ccsr_category_and_description\n , b.body_system\n , case \n when e.length_of_stay <= 1 then '1. 0-1 day'\n when e.length_of_stay <= 3 then '2. 2-3 days'\n when e.length_of_stay <= 5 then '3. 4-5 days'\n when e.length_of_stay <= 7 then '4. 6-7 days'\n when e.length_of_stay <= 14 then '5. 8-14 days'\n when e.length_of_stay <= 30 then '6. 15-30 days'\n else '7. 31+ Days'\n end as los_groups\n , weights.drg_weight\n from dev_thuxuan.core.encounter as e\n left join cte as l\n on e.facility_id = l.location_id\n left join dev_thuxuan.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\n left join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems as b\n on p.ccsr_parent_category = b.ccsr_parent_category\n left join dev_thuxuan.terminology.ms_drg_weights_los as weights\n on e.ms_drg_code = weights.ms_drg\n where e.encounter_type = 'acute inpatient'\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__members_with_claims": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__members_with_claims", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__members_with_claims.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__members_with_claims.sql", "unique_id": "model.the_tuva_project.mart_review__members_with_claims", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__members_with_claims"], "alias": "mart_review__members_with_claims", "checksum": {"name": "sha256", "checksum": "9e2407a2abf6bb7e285738f797314f94a1978fc7f0c2c0fbe7c29d818f6f3889"}, "config": {"enabled": true, "alias": "mart_review__members_with_claims", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__members_with_claims", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7812114, "relation_name": "dev_thuxuan.data_quality.mart_review__members_with_claims", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nWITH medical_claim AS (\r\n SELECT\r\n data_source,\r\n patient_id,\r\n year_month,\r\n SUM(paid_amount) AS paid_amount\r\n FROM {{ ref('mart_review__stg_medical_claim') }}\r\n GROUP BY data_source\r\n , patient_id\r\n , year_month\r\n)\r\n\r\n,pharmacy_claim AS (\r\n SELECT\r\n data_source,\r\n patient_id,\r\n year_month,\r\n SUM(paid_amount) AS paid_amount\r\n FROM {{ ref('mart_review__stg_pharmacy_claim') }}\r\n GROUP BY data_source\r\n , patient_id\r\n , year_month\r\n)\r\n, final as(\r\nSELECT\r\n mm.data_source,\r\n mm.year_month,\r\n SUM(CASE WHEN mc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_medical_claims,\r\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_pharmacy_claims,\r\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1\r\n WHEN mc.patient_id is not null THEN 1 ELSE 0 END) AS members_with_claims,\r\n COUNT(*) AS total_member_months\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM {{ ref('core__member_months')}} mm\r\nLEFT JOIN medical_claim mc\r\n ON mm.patient_id = mc.patient_id\r\n AND mm.data_source = mc.data_source\r\n AND mm.year_month = mc.year_month\r\nLEFT JOIN pharmacy_claim pc\r\n ON mm.patient_id = pc.patient_id\r\n AND mm.data_source = pc.data_source\r\n AND mm.year_month = pc.year_month\r\nGROUP BY mm.data_source, mm.year_month\r\n)\r\n\r\nselect\r\n data_source\r\n , year_month\r\n , members_with_medical_claims\r\n , members_with_pharmacy_claims\r\n , members_with_claims\r\n , total_member_months\r\n , cast(members_with_claims/ total_member_months as {{ dbt.type_numeric()}}) as percent_members_with_claims\r\n , cast(members_with_medical_claims/ total_member_months as {{ dbt.type_numeric()}}) as percent_members_with_medical_claims\r\n , cast(members_with_pharmacy_claims/ total_member_months as {{ dbt.type_numeric()}}) as percent_members_with_pharmacy_claims\r\nfrom final", "language": "sql", "refs": [{"name": "mart_review__stg_medical_claim", "package": null, "version": null}, {"name": "mart_review__stg_pharmacy_claim", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.mart_review__stg_pharmacy_claim", "model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__members_with_claims.sql", "compiled": true, "compiled_code": "\n\nWITH medical_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM dev_thuxuan.data_quality.mart_review__stg_medical_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n\n,pharmacy_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM dev_thuxuan.data_quality.mart_review__stg_pharmacy_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n, final as(\nSELECT\n mm.data_source,\n mm.year_month,\n SUM(CASE WHEN mc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_medical_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_pharmacy_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1\n WHEN mc.patient_id is not null THEN 1 ELSE 0 END) AS members_with_claims,\n COUNT(*) AS total_member_months\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.core.member_months mm\nLEFT JOIN medical_claim mc\n ON mm.patient_id = mc.patient_id\n AND mm.data_source = mc.data_source\n AND mm.year_month = mc.year_month\nLEFT JOIN pharmacy_claim pc\n ON mm.patient_id = pc.patient_id\n AND mm.data_source = pc.data_source\n AND mm.year_month = pc.year_month\nGROUP BY mm.data_source, mm.year_month\n)\n\nselect\n data_source\n , year_month\n , members_with_medical_claims\n , members_with_pharmacy_claims\n , members_with_claims\n , total_member_months\n , cast(members_with_claims/ total_member_months as numeric(28,6)) as percent_members_with_claims\n , cast(members_with_medical_claims/ total_member_months as numeric(28,6)) as percent_members_with_medical_claims\n , cast(members_with_pharmacy_claims/ total_member_months as numeric(28,6)) as percent_members_with_pharmacy_claims\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__member_months": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__member_months", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__member_months.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__member_months.sql", "unique_id": "model.the_tuva_project.mart_review__member_months", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__member_months"], "alias": "mart_review__member_months", "checksum": {"name": "sha256", "checksum": "db896a01aee02b872cc63468e3edd74261ca0e97fef204f3c6d7eda14f7934eb"}, "config": {"enabled": true, "alias": "mart_review__member_months", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__member_months", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7791815, "relation_name": "dev_thuxuan.data_quality.mart_review__member_months", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nSELECT m.*,\r\n COALESCE(p.total_paid, 0) AS total_paid,\r\n COALESCE(p.medical_paid, 0) AS medical_paid,\r\n COALESCE(p.pharmacy_paid, 0) AS pharmacy_paid,\r\n {{ dbt.concat([\r\n 'm.patient_id',\r\n \"'|'\",\r\n 'm.data_source'\r\n ]) }} AS patient_data_source_key,\r\n {{ dbt.concat([\r\n 'm.patient_id',\r\n \"'|'\",\r\n 'm.data_source',\r\n \"'|'\",\r\n 'm.year_month'\r\n ]) }} AS member_month_key\r\nFROM {{ ref('core__member_months')}} m\r\nLEFT JOIN {{ ref('financial_pmpm__pmpm_prep') }} p ON m.patient_id = p.patient_id\r\n AND m.data_source = p.data_source\r\n AND m.year_month = p.year_month", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__member_months.sql", "compiled": true, "compiled_code": "\n\nSELECT m.*,\n COALESCE(p.total_paid, 0) AS total_paid,\n COALESCE(p.medical_paid, 0) AS medical_paid,\n COALESCE(p.pharmacy_paid, 0) AS pharmacy_paid,\n m.patient_id || '|' || m.data_source AS patient_data_source_key,\n m.patient_id || '|' || m.data_source || '|' || m.year_month AS member_month_key\nFROM dev_thuxuan.core.member_months m\nLEFT JOIN dev_thuxuan.financial_pmpm.pmpm_prep p ON m.patient_id = p.patient_id\n AND m.data_source = p.data_source\n AND m.year_month = p.year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__number_of_conditions": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__number_of_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__number_of_conditions.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__number_of_conditions.sql", "unique_id": "model.the_tuva_project.mart_review__number_of_conditions", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__number_of_conditions"], "alias": "mart_review__number_of_conditions", "checksum": {"name": "sha256", "checksum": "2681d9e1ea2ef73b50db383bcd77c1a6a40bf66e0936a0bd3f6b2607ca686158"}, "config": {"enabled": true, "alias": "mart_review__number_of_conditions", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__number_of_conditions", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7831314, "relation_name": "dev_thuxuan.data_quality.mart_review__number_of_conditions", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith xwalk as (\r\n select distinct patient_id, data_source\r\n from {{ ref('core__patient')}}\r\n),\r\ncte as (\r\n select l.patient_id,\r\n x.data_source,\r\n count(*) as numofconditions\r\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long') }} l\r\n left join xwalk x on l.patient_id = x.patient_id\r\n group by l.patient_id, x.data_source\r\n)\r\nselect p.patient_id,\r\n p.data_source,\r\n {{ dbt.concat([\r\n 'p.patient_id',\r\n \"'|'\",\r\n 'p.data_source']) }} as patient_source_key,\r\n coalesce(cte.numofconditions, 0) as numofconditions\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__patient')}} p\r\nleft join cte on p.patient_id = cte.patient_id and p.data_source = cte.data_source", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__patient", "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__number_of_conditions.sql", "compiled": true, "compiled_code": "\n\nwith xwalk as (\n select distinct patient_id, data_source\n from dev_thuxuan.core.patient\n),\ncte as (\n select l.patient_id,\n x.data_source,\n count(*) as numofconditions\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long l\n left join xwalk x on l.patient_id = x.patient_id\n group by l.patient_id, x.data_source\n)\nselect p.patient_id,\n p.data_source,\n p.patient_id || '|' || p.data_source as patient_source_key,\n coalesce(cte.numofconditions, 0) as numofconditions\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient p\nleft join cte on p.patient_id = cte.patient_id and p.data_source = cte.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__patient.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient.sql", "unique_id": "model.the_tuva_project.mart_review__patient", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient"], "alias": "mart_review__patient", "checksum": {"name": "sha256", "checksum": "c3c00f1db10e02cd42c6b03517ad8c161812ec0cc081eab4ade0e10d2ec4301c"}, "config": {"enabled": true, "alias": "mart_review__patient", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7851303, "relation_name": "dev_thuxuan.data_quality.mart_review__patient", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nSELECT *,\r\n {{ dbt.concat([\r\n 'patient_id',\r\n \"'|'\",\r\n 'data_source']) }} as patient_data_source_key\r\nFROM {{ ref('core__patient')}}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient.sql", "compiled": true, "compiled_code": "\n\nSELECT *,\n patient_id || '|' || data_source as patient_data_source_key\nFROM dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient_risk": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__patient_risk", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk.sql", "unique_id": "model.the_tuva_project.mart_review__patient_risk", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient_risk"], "alias": "mart_review__patient_risk", "checksum": {"name": "sha256", "checksum": "9f07ac9676e79f627b5f1391bf3a111c7c0e86d1b07b7e1c607ad06baa6d0cb3"}, "config": {"enabled": true, "alias": "mart_review__patient_risk", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient_risk", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7871304, "relation_name": "dev_thuxuan.data_quality.mart_review__patient_risk", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nWITH cte AS (\r\n SELECT \r\n payment_year,\r\n patient_id,\r\n model_version,\r\n patient_risk_sk,\r\n SUM(coefficient) AS risk_score\r\n FROM {{ ref('mart_review__patient_risk_factors') }}\r\n GROUP BY payment_year,\r\n patient_id,\r\n model_version,\r\n patient_risk_sk\r\n)\r\n\r\nSELECT \r\n CASE \r\n WHEN risk_score <= 0.5 THEN '.5'\r\n WHEN risk_score BETWEEN 0.5 AND 1.0 THEN '1'\r\n WHEN risk_score BETWEEN 1.0 AND 1.5 THEN '1.5'\r\n WHEN risk_score BETWEEN 1.5 AND 2.0 THEN '2'\r\n WHEN risk_score BETWEEN 2.0 AND 2.5 THEN '2.5'\r\n WHEN risk_score BETWEEN 2.5 AND 3.0 THEN '3'\r\n WHEN risk_score BETWEEN 3.0 AND 3.5 THEN '3.5'\r\n WHEN risk_score BETWEEN 3.5 AND 4.0 THEN '4'\r\n WHEN risk_score BETWEEN 4.0 AND 4.5 THEN '4.5'\r\n WHEN risk_score BETWEEN 4.5 AND 5.0 THEN '5'\r\n WHEN risk_score > 5.0 THEN '5+'\r\n ELSE null \r\n END AS risk_score_bucket,\r\n payment_year,\r\n patient_id,\r\n model_version,\r\n patient_risk_sk,\r\n risk_score\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nFROM cte", "language": "sql", "refs": [{"name": "mart_review__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.mart_review__patient_risk_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk.sql", "compiled": true, "compiled_code": "\n\n\nWITH cte AS (\n SELECT \n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n SUM(coefficient) AS risk_score\n FROM dev_thuxuan.data_quality.mart_review__patient_risk_factors\n GROUP BY payment_year,\n patient_id,\n model_version,\n patient_risk_sk\n)\n\nSELECT \n CASE \n WHEN risk_score <= 0.5 THEN '.5'\n WHEN risk_score BETWEEN 0.5 AND 1.0 THEN '1'\n WHEN risk_score BETWEEN 1.0 AND 1.5 THEN '1.5'\n WHEN risk_score BETWEEN 1.5 AND 2.0 THEN '2'\n WHEN risk_score BETWEEN 2.0 AND 2.5 THEN '2.5'\n WHEN risk_score BETWEEN 2.5 AND 3.0 THEN '3'\n WHEN risk_score BETWEEN 3.0 AND 3.5 THEN '3.5'\n WHEN risk_score BETWEEN 3.5 AND 4.0 THEN '4'\n WHEN risk_score BETWEEN 4.0 AND 4.5 THEN '4.5'\n WHEN risk_score BETWEEN 4.5 AND 5.0 THEN '5'\n WHEN risk_score > 5.0 THEN '5+'\n ELSE null \n END AS risk_score_bucket,\n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n risk_score\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient_risk_factors": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__patient_risk_factors", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk_factors.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk_factors.sql", "unique_id": "model.the_tuva_project.mart_review__patient_risk_factors", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient_risk_factors"], "alias": "mart_review__patient_risk_factors", "checksum": {"name": "sha256", "checksum": "6addc2f008bbf5ccb358dc0a8498afb38e62229ae94c2722e502c60d5f584a8e"}, "config": {"enabled": true, "alias": "mart_review__patient_risk_factors", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient_risk_factors", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8011389, "relation_name": "dev_thuxuan.data_quality.mart_review__patient_risk_factors", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect *\r\n,dense_rank() over (order by patient_id, model_version, payment_year ) as patient_risk_sk\r\nfrom {{ ref('cms_hcc__patient_risk_factors') }} p", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk_factors.sql", "compiled": true, "compiled_code": "\n\nselect *\n,dense_rank() over (order by patient_id, model_version, payment_year ) as patient_risk_sk\nfrom dev_thuxuan.cms_hcc.patient_risk_factors p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__patient_risk_scores": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__patient_risk_scores", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk_scores.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk_scores.sql", "unique_id": "model.the_tuva_project.mart_review__patient_risk_scores", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__patient_risk_scores"], "alias": "mart_review__patient_risk_scores", "checksum": {"name": "sha256", "checksum": "1449fe2af32808735e67b418be1c2de69a462469cd73db54046684b51040dd72"}, "config": {"enabled": true, "alias": "mart_review__patient_risk_scores", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__patient_risk_scores", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7991388, "relation_name": "dev_thuxuan.data_quality.mart_review__patient_risk_scores", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect *\r\nfrom {{ ref('cms_hcc__patient_risk_scores') }} p", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_scores"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__patient_risk_scores.sql", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom dev_thuxuan.cms_hcc.patient_risk_scores p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__pharmacy": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__pharmacy", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__pharmacy.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__pharmacy.sql", "unique_id": "model.the_tuva_project.mart_review__pharmacy", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__pharmacy"], "alias": "mart_review__pharmacy", "checksum": {"name": "sha256", "checksum": "a66527f64cdbf1c7b142f918481a717dc3af40b4c9952002246650af52036f77"}, "config": {"enabled": true, "alias": "mart_review__pharmacy", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__pharmacy", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7891338, "relation_name": "dev_thuxuan.data_quality.mart_review__pharmacy", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) \r\n | as_bool\r\n) }}\r\n\r\nselect\r\n p.claim_id\r\n , p.claim_line_number\r\n , p.patient_id\r\n , p.data_source\r\n , {{ dbt.concat(['p.patient_id', \"'|'\", 'p.data_source']) }} as patient_source_key\r\n , p.ndc_code\r\n , coalesce(n.fda_description, n.rxnorm_description) as ndc_description\r\n , p.paid_amount\r\n , p.allowed_amount\r\n , p.prescribing_provider_id\r\n , p.prescribing_provider_name\r\n , prac.specialty as prescribing_specialty\r\n , p.dispensing_provider_id\r\n , p.dispensing_provider_name\r\n , p.paid_date\r\n , p.dispensing_date\r\n , p.days_supply\r\n , p.paid_amount / p.days_supply as cost_per_day\r\n , (p.paid_amount / p.days_supply) * 30 as thirty_day_equivalent_cost\r\n , case \r\n when (p.paid_amount / p.days_supply) * 30 >= 950 then 1 \r\n else 0 \r\n end as specialty_tier -- $950 is the threshold set by CMS for CY 2024\r\n , n.rxcui\r\n , n.rxnorm_description\r\n , r.brand_name\r\n , r.brand_vs_generic\r\n , r.ingredient_name\r\n , a.atc_1_name\r\n , a.atc_2_name\r\n , a.atc_3_name\r\n , a.atc_4_name\r\n , pe.generic_available_total_opportunity\r\n , pe.generic_average_cost_per_unit * p.quantity as generic_cost_at_units\r\n , pe.brand_cost_per_unit * p.quantity as brand_paid_amount\r\n , pe.generic_available\r\n , pe.generic_available_sk\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('core__pharmacy_claim') }} as p\r\nleft join {{ ref('terminology__ndc') }} as n \r\n on p.ndc_code = n.ndc\r\nleft join {{ ref('terminology__rxnorm_brand_generic') }} as r \r\n on n.rxcui = r.product_rxcui\r\nleft join {{ ref('terminology__rxnorm_to_atc') }} as a \r\n on n.rxcui = a.rxcui\r\nleft join {{ ref('core__practitioner') }} as prac \r\n on p.prescribing_provider_id = prac.practitioner_id\r\nleft join {{ ref('pharmacy__pharmacy_claim_expanded') }} as pe \r\n on p.data_source = pe.data_source\r\n and p.claim_id = pe.claim_id\r\n and p.claim_line_number = pe.claim_line_number", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "terminology__rxnorm_brand_generic", "package": null, "version": null}, {"name": "terminology__rxnorm_to_atc", "package": null, "version": null}, {"name": "core__practitioner", "package": null, "version": null}, {"name": "pharmacy__pharmacy_claim_expanded", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "seed.the_tuva_project.terminology__rxnorm_to_atc", "model.the_tuva_project.core__practitioner", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__pharmacy.sql", "compiled": true, "compiled_code": "\n\nselect\n p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.data_source\n , p.patient_id || '|' || p.data_source as patient_source_key\n , p.ndc_code\n , coalesce(n.fda_description, n.rxnorm_description) as ndc_description\n , p.paid_amount\n , p.allowed_amount\n , p.prescribing_provider_id\n , p.prescribing_provider_name\n , prac.specialty as prescribing_specialty\n , p.dispensing_provider_id\n , p.dispensing_provider_name\n , p.paid_date\n , p.dispensing_date\n , p.days_supply\n , p.paid_amount / p.days_supply as cost_per_day\n , (p.paid_amount / p.days_supply) * 30 as thirty_day_equivalent_cost\n , case \n when (p.paid_amount / p.days_supply) * 30 >= 950 then 1 \n else 0 \n end as specialty_tier -- $950 is the threshold set by CMS for CY 2024\n , n.rxcui\n , n.rxnorm_description\n , r.brand_name\n , r.brand_vs_generic\n , r.ingredient_name\n , a.atc_1_name\n , a.atc_2_name\n , a.atc_3_name\n , a.atc_4_name\n , pe.generic_available_total_opportunity\n , pe.generic_average_cost_per_unit * p.quantity as generic_cost_at_units\n , pe.brand_cost_per_unit * p.quantity as brand_paid_amount\n , pe.generic_available\n , pe.generic_available_sk\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\nleft join dev_thuxuan.terminology.rxnorm_brand_generic as r \n on n.rxcui = r.product_rxcui\nleft join dev_thuxuan.terminology.rxnorm_to_atc as a \n on n.rxcui = a.rxcui\nleft join dev_thuxuan.core.practitioner as prac \n on p.prescribing_provider_id = prac.practitioner_id\nleft join dev_thuxuan.pharmacy.pharmacy_claim_expanded as pe \n on p.data_source = pe.data_source\n and p.claim_id = pe.claim_id\n and p.claim_line_number = pe.claim_line_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__pmpm": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__pmpm", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__pmpm.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__pmpm.sql", "unique_id": "model.the_tuva_project.mart_review__pmpm", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__pmpm"], "alias": "mart_review__pmpm", "checksum": {"name": "sha256", "checksum": "e4a6ff19cfc43aad3f9debb503ad07e722bb840e9b5e0b0cf934bfecc94941f8"}, "config": {"enabled": true, "alias": "mart_review__pmpm", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__pmpm", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7911336, "relation_name": "dev_thuxuan.data_quality.mart_review__pmpm", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nSELECT *,\r\n total_paid * member_months AS total_paid_absolute,\r\n medical_paid * member_months AS medical_paid_absolute,\r\n pharmacy_paid * member_months AS pharmacy_paid_absolute,\r\n inpatient_paid * member_months AS inpatient_paid_absolute,\r\n outpatient_paid * member_months AS outpatient_paid_absolute,\r\n office_based_paid * member_months AS office_based_paid_absolute,\r\n ancillary_paid * member_months AS ancillary_paid_absolute,\r\n other_paid * member_months AS other_paid_absolute,\r\n {{ dbt.concat([\r\n 'data_source',\r\n \"'|'\",\r\n 'year_month']) }} as data_source_month_key\r\nFROM {{ ref('financial_pmpm__pmpm_payer') }}", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_payer", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_payer"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__pmpm.sql", "compiled": true, "compiled_code": "\n\n\nSELECT *,\n total_paid * member_months AS total_paid_absolute,\n medical_paid * member_months AS medical_paid_absolute,\n pharmacy_paid * member_months AS pharmacy_paid_absolute,\n inpatient_paid * member_months AS inpatient_paid_absolute,\n outpatient_paid * member_months AS outpatient_paid_absolute,\n office_based_paid * member_months AS office_based_paid_absolute,\n ancillary_paid * member_months AS ancillary_paid_absolute,\n other_paid * member_months AS other_paid_absolute,\n data_source || '|' || year_month as data_source_month_key\nFROM dev_thuxuan.financial_pmpm.pmpm_payer", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__quality_measures_summary_long": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__quality_measures_summary_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__quality_measures_summary_long.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__quality_measures_summary_long.sql", "unique_id": "model.the_tuva_project.mart_review__quality_measures_summary_long", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__quality_measures_summary_long"], "alias": "mart_review__quality_measures_summary_long", "checksum": {"name": "sha256", "checksum": "13490e2ba0af45cf848091c5c174d167a159159e0b81ac4272aba8dcec178bae"}, "config": {"enabled": true, "alias": "mart_review__quality_measures_summary_long", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__quality_measures_summary_long", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.803139, "relation_name": "dev_thuxuan.data_quality.mart_review__quality_measures_summary_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect *\r\nfrom {{ ref('quality_measures__summary_long') }} s", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__summary_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__quality_measures_summary_long.sql", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom dev_thuxuan.quality_measures.summary_long s", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__quality_measures_value_set": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__quality_measures_value_set", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__quality_measures_value_set.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__quality_measures_value_set.sql", "unique_id": "model.the_tuva_project.mart_review__quality_measures_value_set", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__quality_measures_value_set"], "alias": "mart_review__quality_measures_value_set", "checksum": {"name": "sha256", "checksum": "b41f8f8de26f98627d4f216574f00e4eb60517c172685ee13c212a257467a517"}, "config": {"enabled": true, "alias": "mart_review__quality_measures_value_set", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__quality_measures_value_set", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8051393, "relation_name": "dev_thuxuan.data_quality.mart_review__quality_measures_value_set", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('quality_measures__measures') }} p", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__quality_measures_value_set.sql", "compiled": true, "compiled_code": "\n\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.quality_measures._value_set_measures p", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__readmissions": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__readmissions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__readmissions.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__readmissions.sql", "unique_id": "model.the_tuva_project.mart_review__readmissions", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__readmissions"], "alias": "mart_review__readmissions", "checksum": {"name": "sha256", "checksum": "5711bc000341507753c61241e1ac43699ebe85fea2a19a21a993de849ec8652f"}, "config": {"enabled": true, "alias": "mart_review__readmissions", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__readmissions", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7931426, "relation_name": "dev_thuxuan.data_quality.mart_review__readmissions", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nSELECT *\r\nFROM {{ ref('readmissions__readmission_summary') }}\r\nWHERE index_admission_flag = 1", "language": "sql", "refs": [{"name": "readmissions__readmission_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__readmission_summary"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__readmissions.sql", "compiled": true, "compiled_code": "\n\nSELECT *\nFROM dev_thuxuan.readmissions.readmission_summary\nWHERE index_admission_flag = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__service_categories_long": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__service_categories_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__service_categories_long.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__service_categories_long.sql", "unique_id": "model.the_tuva_project.mart_review__service_categories_long", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__service_categories_long"], "alias": "mart_review__service_categories_long", "checksum": {"name": "sha256", "checksum": "082fe9d9937e22b84663b495c5d67655bed8142353d9cccf209394ad2426141d"}, "config": {"enabled": true, "alias": "mart_review__service_categories_long", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__service_categories_long", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8086495, "relation_name": "dev_thuxuan.data_quality.mart_review__service_categories_long", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith encounters as (\r\n select\r\n cast(c.year_month_int as {{ dbt.type_string() }}) as year_month\r\n , mc.patient_id\r\n , service_category_1\r\n , service_category_2\r\n , count(distinct mc.encounter_id) as visits\r\n from {{ ref('mart_review__stg_medical_claim')}} as mc\r\n left join {{ ref('reference_data__calendar')}} c on mc.claim_start_date = c.full_date\r\n inner join {{ref ('core__encounter')}} as e\r\n on mc.encounter_id = e.encounter_id\r\n group by\r\n cast(c.year_month_int as {{ dbt.type_string() }})\r\n , mc.patient_id\r\n , service_category_1\r\n , service_category_2\r\n)\r\n\r\n\r\n select \r\n pmpm.year_month\r\n , pmpm.data_source\r\n , pmpm.service_category_1\r\n , pmpm.service_category_2\r\n , sum(total_paid) as paid_amt\r\n , sum(visits) as visits\r\n from {{ref('financial_pmpm__patient_spend_with_service_categories')}} as pmpm\r\n left join encounters\r\n on pmpm.year_month = encounters.year_month\r\n and pmpm.patient_id = encounters.patient_id\r\n and pmpm.service_category_1 = encounters.service_category_1\r\n and pmpm.service_category_2 = encounters.service_category_2\r\n group by\r\n pmpm.year_month\r\n , pmpm.data_source\r\n , pmpm.service_category_1\r\n , pmpm.service_category_2", "language": "sql", "refs": [{"name": "mart_review__stg_medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.mart_review__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__encounter", "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__service_categories_long.sql", "compiled": true, "compiled_code": "\n\nwith encounters as (\n select\n cast(c.year_month_int as TEXT) as year_month\n , mc.patient_id\n , service_category_1\n , service_category_2\n , count(distinct mc.encounter_id) as visits\n from dev_thuxuan.data_quality.mart_review__stg_medical_claim as mc\n left join dev_thuxuan.reference_data.calendar c on mc.claim_start_date = c.full_date\n inner join dev_thuxuan.core.encounter as e\n on mc.encounter_id = e.encounter_id\n group by\n cast(c.year_month_int as TEXT)\n , mc.patient_id\n , service_category_1\n , service_category_2\n)\n\n\n select \n pmpm.year_month\n , pmpm.data_source\n , pmpm.service_category_1\n , pmpm.service_category_2\n , sum(total_paid) as paid_amt\n , sum(visits) as visits\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories as pmpm\n left join encounters\n on pmpm.year_month = encounters.year_month\n and pmpm.patient_id = encounters.patient_id\n and pmpm.service_category_1 = encounters.service_category_1\n and pmpm.service_category_2 = encounters.service_category_2\n group by\n pmpm.year_month\n , pmpm.data_source\n , pmpm.service_category_1\n , pmpm.service_category_2", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__tuva_chronic_conditions": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__tuva_chronic_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\final\\mart_review__tuva_chronic_conditions.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\final\\mart_review__tuva_chronic_conditions.sql", "unique_id": "model.the_tuva_project.mart_review__tuva_chronic_conditions", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "final", "mart_review__tuva_chronic_conditions"], "alias": "mart_review__tuva_chronic_conditions", "checksum": {"name": "sha256", "checksum": "fcc5b657e8384390c55a64d1548c3eddfaa44fe35233bfe55f8aa42541df2924"}, "config": {"enabled": true, "alias": "mart_review__tuva_chronic_conditions", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__tuva_chronic_conditions", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.79514, "relation_name": "dev_thuxuan.data_quality.mart_review__tuva_chronic_conditions", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith cte as (\r\n select distinct\r\n patient_id\r\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long')}}\r\n)\r\n\r\n, patientxwalk as (\r\n select distinct\r\n patient_id\r\n , data_source\r\n from {{ ref('core__patient')}}\r\n)\r\n\r\n, result as (\r\n select\r\n l.patient_id\r\n , p.data_source\r\n , l.condition\r\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long')}} as l\r\n inner join patientxwalk as p\r\n on l.patient_id = p.patient_id\r\n\r\n union all\r\n\r\n select\r\n p.patient_id\r\n , p.data_source\r\n , 'No Chronic Conditions' as condition\r\n from {{ ref('core__patient')}} as p\r\n left join cte\r\n on p.patient_id = cte.patient_id\r\n where cte.patient_id is null\r\n)\r\n\r\nselect *\r\n , {{ dbt.concat([\r\n 'patient_id',\r\n \"'|'\",\r\n 'data_source']) }} as patient_source_key\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom result", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\final\\mart_review__tuva_chronic_conditions.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n patient_id\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, patientxwalk as (\n select distinct\n patient_id\n , data_source\n from dev_thuxuan.core.patient\n)\n\n, result as (\n select\n l.patient_id\n , p.data_source\n , l.condition\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long as l\n inner join patientxwalk as p\n on l.patient_id = p.patient_id\n\n union all\n\n select\n p.patient_id\n , p.data_source\n , 'No Chronic Conditions' as condition\n from dev_thuxuan.core.patient as p\n left join cte\n on p.patient_id = cte.patient_id\n where cte.patient_id is null\n)\n\nselect *\n , patient_id || '|' || data_source as patient_source_key\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom result", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__stg_medical_claim": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\stage\\mart_review__stg_medical_claim.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\stage\\mart_review__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.mart_review__stg_medical_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "stage", "mart_review__stg_medical_claim"], "alias": "mart_review__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "921917699232b865c98986303d3d115e30106a68ab9d210638963f04b149d383"}, "config": {"enabled": true, "alias": "mart_review__stg_medical_claim", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__stg_medical_claim", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8106494, "relation_name": "dev_thuxuan.data_quality.mart_review__stg_medical_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect mc.*,\r\ncast(c.year_month_int as {{ dbt.type_string() }}) as year_month\r\nFROM {{ ref('core__medical_claim')}} mc\r\nleft join {{ ref('reference_data__calendar') }} c on coalesce(mc.claim_line_start_date,mc.claim_start_date) = c.full_date", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\stage\\mart_review__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM dev_thuxuan.core.medical_claim mc\nleft join dev_thuxuan.reference_data.calendar c on coalesce(mc.claim_line_start_date,mc.claim_start_date) = c.full_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__stg_member_month": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__stg_member_month", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\stage\\mart_review__stg_member_month.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\stage\\mart_review__stg_member_month.sql", "unique_id": "model.the_tuva_project.mart_review__stg_member_month", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "stage", "mart_review__stg_member_month"], "alias": "mart_review__stg_member_month", "checksum": {"name": "sha256", "checksum": "afc6985d6dd71abe9ca4f756ead746d01b754359c6b399864eb28085b83bd63e"}, "config": {"enabled": true, "alias": "mart_review__stg_member_month", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__stg_member_month", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8146493, "relation_name": "dev_thuxuan.data_quality.mart_review__stg_member_month", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith cte as\r\n(\r\nselect distinct year_month_int\r\n,full_date\r\nfrom {{ ref('reference_data__calendar') }} c\r\nwhere day = 1\r\n\r\n)\r\n\r\nselect mm.*\r\n,c.year_month_int\r\n,c.full_date as year_month_date\r\nFROM {{ ref('core__member_months')}} mm\r\nleft join cte c on cast(mm.year_month as int) = c.year_month_int", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\stage\\mart_review__stg_member_month.sql", "compiled": true, "compiled_code": "\n\nwith cte as\n(\nselect distinct year_month_int\n,full_date\nfrom dev_thuxuan.reference_data.calendar c\nwhere day = 1\n\n)\n\nselect mm.*\n,c.year_month_int\n,c.full_date as year_month_date\nFROM dev_thuxuan.core.member_months mm\nleft join cte c on cast(mm.year_month as int) = c.year_month_int", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.mart_review__stg_pharmacy_claim": {"database": "dev_thuxuan", "schema": "data_quality", "name": "mart_review__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\mart_review\\stage\\mart_review__stg_pharmacy_claim.sql", "original_file_path": "models\\data_quality\\dqi\\mart_review\\stage\\mart_review__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.mart_review__stg_pharmacy_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "mart_review", "stage", "mart_review__stg_pharmacy_claim"], "alias": "mart_review__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "30bf95e0048a4e536f9e29060c2231a275dfe096d73d9591644af1b4f7694772"}, "config": {"enabled": true, "alias": "mart_review__stg_pharmacy_claim", "schema": "data_quality", "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\mart_review\\mart_review_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "mart_review__stg_pharmacy_claim", "tags": ["data_quality"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8126495, "relation_name": "dev_thuxuan.data_quality.mart_review__stg_pharmacy_claim", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect mc.*,\r\ncast(c.year_month_int as {{ dbt.type_string() }}) as year_month\r\nFROM {{ ref('core__pharmacy_claim')}} mc\r\nleft join {{ ref('reference_data__calendar') }} c on coalesce(mc.paid_date,mc.dispensing_date) = c.full_date", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\mart_review\\stage\\mart_review__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM dev_thuxuan.core.pharmacy_claim mc\nleft join dev_thuxuan.reference_data.calendar c on coalesce(mc.paid_date,mc.dispensing_date) = c.full_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_eligibility": {"database": "dev_thuxuan", "schema": "test", "name": "data_quality__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\stage\\data_quality__stg_eligibility.sql", "original_file_path": "models\\data_quality\\dqi\\stage\\data_quality__stg_eligibility.sql", "unique_id": "model.the_tuva_project.data_quality__stg_eligibility", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_eligibility"], "alias": "data_quality__stg_eligibility", "checksum": {"name": "sha256", "checksum": "743f16d1eda544efdedf765a7a4249950ea558fb3b666e38760919eb93c121cd"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7599745, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect * from {{ ref('eligibility')}}", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\stage\\data_quality__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\nselect * from tuva.input_layer.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_institutional_inpatient": {"database": "dev_thuxuan", "schema": "test", "name": "data_quality__stg_institutional_inpatient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\stage\\data_quality__stg_institutional_inpatient.sql", "original_file_path": "models\\data_quality\\dqi\\stage\\data_quality__stg_institutional_inpatient.sql", "unique_id": "model.the_tuva_project.data_quality__stg_institutional_inpatient", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_institutional_inpatient"], "alias": "data_quality__stg_institutional_inpatient", "checksum": {"name": "sha256", "checksum": "1754a526538bbeb8f73898c97202d5e9656f1f96c3cc117f72b5a05c7ccf5cd0"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7619748, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\n SELECT *\r\n FROM {{ ref('medical_claim') }}\r\n WHERE claim_type = 'institutional'\r\n AND {{ substring('bill_type_code', 1, 2) }} = '11'", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.substring"], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\stage\\data_quality__stg_institutional_inpatient.sql", "compiled": true, "compiled_code": "\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_medical_claim": {"database": "dev_thuxuan", "schema": "test", "name": "data_quality__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\stage\\data_quality__stg_medical_claim.sql", "original_file_path": "models\\data_quality\\dqi\\stage\\data_quality__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.data_quality__stg_medical_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_medical_claim"], "alias": "data_quality__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "3898e94f3bfed2b60105c6be56101726e8ced4c13489c930f415e717dbb4b122"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7629745, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect * from {{ ref('medical_claim')}}", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\stage\\data_quality__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect * from tuva.input_layer.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__stg_pharmacy_claim": {"database": "dev_thuxuan", "schema": "test", "name": "data_quality__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\dqi\\stage\\data_quality__stg_pharmacy_claim.sql", "original_file_path": "models\\data_quality\\dqi\\stage\\data_quality__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.data_quality__stg_pharmacy_claim", "fqn": ["the_tuva_project", "data_quality", "dqi", "stage", "data_quality__stg_pharmacy_claim"], "alias": "data_quality__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "00dc01cf099a1d40e973cf815691b54d5562ead8565f3339a25c140d864b248b"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["data_quality"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\dqi\\dqi_models.yml", "build_path": null, "unrendered_config": {"tags": ["data_quality"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.7639744, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect * from {{ ref('pharmacy_claim')}}", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\dqi\\stage\\data_quality__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect * from tuva.input_layer.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__analytics_checks_summary": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__analytics_checks_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__analytics_checks_summary.sql", "original_file_path": "models\\data_quality\\final\\data_quality__analytics_checks_summary.sql", "unique_id": "model.the_tuva_project.data_quality__analytics_checks_summary", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__analytics_checks_summary"], "alias": "analytics_checks_summary", "checksum": {"name": "sha256", "checksum": "918bf3cdbee5187a468d386da47f636cb746f4c9bf2a84e8dba364f44eef6a2d"}, "config": {"enabled": true, "alias": "analytics_checks_summary", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "the count of records that match the result of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "analytics_checks_summary", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0330482, "relation_name": "dev_thuxuan.data_quality.analytics_checks_summary", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith unioned_data as (\r\n\r\n -- Unioning multiple data quality checks, excluding the _loaded_at field\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('data_quality__readmissions')\r\n , ref('data_quality__chronic_conditions_none')\r\n , ref('data_quality__cms_hcc')\r\n , ref('data_quality__quality_measures')\r\n , ref('data_quality__encounters_missing_groups_union')\r\n , ref('data_quality__acute_inpatient')\r\n , ref('data_quality__ed_classification')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n\r\n)\r\n\r\nselect\r\n data_quality_check\r\n , result_count\r\n , coalesce(normally_zero ,1) as normally_zero\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom unioned_data", "language": "sql", "refs": [{"name": "data_quality__readmissions", "package": null, "version": null}, {"name": "data_quality__chronic_conditions_none", "package": null, "version": null}, {"name": "data_quality__cms_hcc", "package": null, "version": null}, {"name": "data_quality__quality_measures", "package": null, "version": null}, {"name": "data_quality__encounters_missing_groups_union", "package": null, "version": null}, {"name": "data_quality__acute_inpatient", "package": null, "version": null}, {"name": "data_quality__ed_classification", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.data_quality__readmissions", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__cms_hcc", "model.the_tuva_project.data_quality__quality_measures", "model.the_tuva_project.data_quality__encounters_missing_groups_union", "model.the_tuva_project.data_quality__acute_inpatient", "model.the_tuva_project.data_quality__ed_classification"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__analytics_checks_summary.sql", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_readmissions' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_readmissions\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.chronic_conditions_none' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"MEDICARE_LDS_REFERENCE\" as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(\"NORMALLY_ZERO\" as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.chronic_conditions_none\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_cms_hcc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_cms_hcc\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_quality_measures' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_quality_measures\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.encounters_missing_groups_union' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.encounters_missing_groups_union\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_acute_inpatient' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_acute_inpatient\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_ed_classification' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_ed_classification\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , coalesce(normally_zero ,1) as normally_zero\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned_data", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__analytics_populated": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__analytics_populated", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__analytics_populated.sql", "original_file_path": "models\\data_quality\\final\\data_quality__analytics_populated.sql", "unique_id": "model.the_tuva_project.data_quality__analytics_populated", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__analytics_populated"], "alias": "analytics_populated", "checksum": {"name": "sha256", "checksum": "93b8073d847ff1df49d3ca1a1d48851c102319aa1be34c448cb8405281a846dd"}, "config": {"enabled": true, "alias": "analytics_populated", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"table_name": {"name": "table_name", "description": "the name of the table's records being counted", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "record_count": {"name": "record_count", "description": "the total number of records belonging to the specific data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "analytics_populated", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.070048, "relation_name": "dev_thuxuan.data_quality.analytics_populated", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith tuva_chronic_condition_long as (\r\n select\r\n 'tuva_chronic_condition_long' as table_name\r\n , count(*) as record_count\r\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\n)\r\n\r\n, cms_hcc_patient_risk_factors as (\r\n select\r\n 'cms_hcc__patient_risk_factors' as table_name\r\n , count(*) as record_count\r\n from {{ ref('cms_hcc__patient_risk_factors') }}\r\n)\r\n\r\n, service_category_grouper as (\r\n select\r\n 'service_category__service_category_grouper' as table_name\r\n , count(*) as record_count\r\n from {{ ref('service_category__service_category_grouper') }}\r\n)\r\n\r\n, financial_pmpm_payer as (\r\n select\r\n 'financial_pmpm__pmpm_payer' as table_name\r\n , count(*) as record_count\r\n from {{ ref('financial_pmpm__pmpm_payer') }}\r\n)\r\n\r\n, readmission_summary as (\r\n select\r\n 'readmissions__readmission_summary' as table_name\r\n , count(*) as record_count\r\n from {{ ref('readmissions__readmission_summary') }}\r\n)\r\n\r\n, quality_measures_summary_long as (\r\n select\r\n 'quality_measures__summary_long' as table_name\r\n , count(*) as record_count\r\n from {{ ref('quality_measures__summary_long') }}\r\n)\r\n\r\n, acute_inpatient_visits as (\r\n select\r\n 'acute_inpatient_visits' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__encounter') }}\r\n where encounter_type = 'acute inpatient'\r\n)\r\n\r\n, ed_visits as (\r\n select\r\n 'ed_visits' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__encounter') }}\r\n where encounter_type = 'emergency department'\r\n)\r\n\r\n,final as (\r\nselect * from tuva_chronic_condition_long\r\nunion all\r\nselect * from cms_hcc_patient_risk_factors\r\nunion all\r\nselect * from service_category_grouper\r\nunion all\r\nselect * from financial_pmpm_payer\r\nunion all\r\nselect * from readmission_summary\r\nunion all\r\nselect * from quality_measures_summary_long\r\nunion all\r\nselect * from acute_inpatient_visits\r\nunion all\r\nselect * from ed_visits\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}, {"name": "service_category__service_category_grouper", "package": null, "version": null}, {"name": "financial_pmpm__pmpm_payer", "package": null, "version": null}, {"name": "readmissions__readmission_summary", "package": null, "version": null}, {"name": "quality_measures__summary_long", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.financial_pmpm__pmpm_payer", "model.the_tuva_project.readmissions__readmission_summary", "model.the_tuva_project.quality_measures__summary_long", "model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__analytics_populated.sql", "compiled": true, "compiled_code": "\n\nwith tuva_chronic_condition_long as (\n select\n 'tuva_chronic_condition_long' as table_name\n , count(*) as record_count\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, cms_hcc_patient_risk_factors as (\n select\n 'cms_hcc__patient_risk_factors' as table_name\n , count(*) as record_count\n from dev_thuxuan.cms_hcc.patient_risk_factors\n)\n\n, service_category_grouper as (\n select\n 'service_category__service_category_grouper' as table_name\n , count(*) as record_count\n from dev_thuxuan.claims_preprocessing.service_category_grouper\n)\n\n, financial_pmpm_payer as (\n select\n 'financial_pmpm__pmpm_payer' as table_name\n , count(*) as record_count\n from dev_thuxuan.financial_pmpm.pmpm_payer\n)\n\n, readmission_summary as (\n select\n 'readmissions__readmission_summary' as table_name\n , count(*) as record_count\n from dev_thuxuan.readmissions.readmission_summary\n)\n\n, quality_measures_summary_long as (\n select\n 'quality_measures__summary_long' as table_name\n , count(*) as record_count\n from dev_thuxuan.quality_measures.summary_long\n)\n\n, acute_inpatient_visits as (\n select\n 'acute_inpatient_visits' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.encounter\n where encounter_type = 'acute inpatient'\n)\n\n, ed_visits as (\n select\n 'ed_visits' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.encounter\n where encounter_type = 'emergency department'\n)\n\n,final as (\nselect * from tuva_chronic_condition_long\nunion all\nselect * from cms_hcc_patient_risk_factors\nunion all\nselect * from service_category_grouper\nunion all\nselect * from financial_pmpm_payer\nunion all\nselect * from readmission_summary\nunion all\nselect * from quality_measures_summary_long\nunion all\nselect * from acute_inpatient_visits\nunion all\nselect * from ed_visits\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__analytics_reference_summary": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__analytics_reference_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__analytics_reference_summary.sql", "original_file_path": "models\\data_quality\\final\\data_quality__analytics_reference_summary.sql", "unique_id": "model.the_tuva_project.data_quality__analytics_reference_summary", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__analytics_reference_summary"], "alias": "analytics_reference_summary", "checksum": {"name": "sha256", "checksum": "6b1319c6106171d56dde148c964f03c2cb727bbc581520ce3588329912c4a1e7"}, "config": {"enabled": true, "alias": "analytics_reference_summary", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "analytics_reference_summary", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0310483, "relation_name": "dev_thuxuan.data_quality.analytics_reference_summary", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith unioned_data as (\r\n\r\n -- Unioning multiple data quality checks, excluding the _loaded_at field\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('data_quality__readmissions_reference')\r\n , ref('data_quality__cms_hcc_reference')\r\n , ref('data_quality__chronic_conditions_prevalence')\r\n , ref('data_quality__quality_measures_reference')\r\n , ref('data_quality__acute_inpatient_reference')\r\n , ref('data_quality__acute_inpatient_prevelence')\r\n , ref('data_quality__encounters_cost_and_utilization')\r\n , ref('data_quality__ed_classification_reference')\r\n , ref('data_quality__service_categories_pmpm')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n\r\n)\r\n\r\nselect\r\n analytics_concept \r\n , analytics_measure\r\n , data_source_value\r\n , analytics_value\r\n , value_rank\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom unioned_data", "language": "sql", "refs": [{"name": "data_quality__readmissions_reference", "package": null, "version": null}, {"name": "data_quality__cms_hcc_reference", "package": null, "version": null}, {"name": "data_quality__chronic_conditions_prevalence", "package": null, "version": null}, {"name": "data_quality__quality_measures_reference", "package": null, "version": null}, {"name": "data_quality__acute_inpatient_reference", "package": null, "version": null}, {"name": "data_quality__acute_inpatient_prevelence", "package": null, "version": null}, {"name": "data_quality__encounters_cost_and_utilization", "package": null, "version": null}, {"name": "data_quality__ed_classification_reference", "package": null, "version": null}, {"name": "data_quality__service_categories_pmpm", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__quality_measures_reference", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__service_categories_pmpm"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__analytics_reference_summary.sql", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_readmissions_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_readmissions_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_cms_hcc_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_cms_hcc_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.chronic_conditions_prevalence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"PATIENTS\" as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(\"MEDICARE_LDS_CONDITION_RANK\" as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.chronic_conditions_prevalence\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_quality_measures_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_quality_measures_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_acute_inpatient_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_acute_inpatient_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_acute_inpatient_prevelence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_acute_inpatient_prevelence\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.encounters_cost_and_utilization' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.encounters_cost_and_utilization\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_ed_classification_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_ed_classification_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.service_categories_pmpm' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(\"TOTAL_PAID\" as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(\"MEMBER_MONTHS\" as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.service_categories_pmpm\n\n \n )\n\n \n\n)\n\nselect\n analytics_concept \n , analytics_measure\n , data_source_value\n , analytics_value\n , value_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned_data", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_date_trends": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_date_trends", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__claim_date_trends.sql", "original_file_path": "models\\data_quality\\final\\data_quality__claim_date_trends.sql", "unique_id": "model.the_tuva_project.data_quality__claim_date_trends", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__claim_date_trends"], "alias": "claim_date_trends", "checksum": {"name": "sha256", "checksum": "02c1e68577088047c8211cee79a8824d3e92337c3ec8240433018a4dbd311ebd"}, "config": {"enabled": true, "alias": "claim_date_trends", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "The count of distinct claims with a claim start date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "The count of distinct claims with a claim end date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admission_date": {"name": "admission_date", "description": "The count of distinct claims with a admission date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The count of distinct claims with a discharge date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid_date": {"name": "medical_paid_date", "description": "The count of distinct claims with a medical paid date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "The count of distinct claims with a dispensing date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid_date": {"name": "pharmacy_paid_date", "description": "The count of distinct claims with a pharmacy paid date in the corresponding year and month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "claim_date_trends", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0270474, "relation_name": "dev_thuxuan.data_quality.claim_date_trends", "raw_code": "{{ config(\r\n enabled = var('data_quality_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith date_stage as(\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'claim_start_date' as date_field\r\n , cast({{ date_part(\"year\", \"claim_start_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"claim_start_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('medical_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"claim_start_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"claim_start_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n union all\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'claim_end_date' as date_field\r\n , cast({{ date_part(\"year\", \"claim_end_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"claim_end_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('medical_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"claim_end_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"claim_end_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n union all\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'admission_date' as date_field\r\n , cast({{ date_part(\"year\", \"admission_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"admission_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('medical_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"admission_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"admission_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n union all\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'discharge_date' as date_field\r\n , cast({{ date_part(\"year\", \"discharge_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"discharge_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('medical_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"discharge_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"discharge_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n union all\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'medical paid_date' as date_field\r\n , cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('medical_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n union all\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'dispensing_date' as date_field\r\n , cast({{ date_part(\"year\", \"dispensing_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"dispensing_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('pharmacy_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"dispensing_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"dispensing_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n union all\r\n\r\n select\r\n date_field\r\n , {{ dbt.concat([\"year\", dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , result_count\r\n from\r\n (\r\n select\r\n 'pharmacy paid_date' as date_field\r\n , cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }}) as year\r\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }}) as month\r\n , count(distinct claim_id) as result_count\r\n from {{ ref('pharmacy_claim') }}\r\n group by\r\n cast({{ date_part(\"year\", \"paid_date\") }} as {{ dbt.type_string() }})\r\n , cast({{ date_part(\"month\", \"paid_date\") }} as {{ dbt.type_string() }})\r\n )x\r\n\r\n)\r\n\r\n\r\n, all_date_range as (\r\n select distinct\r\n replace(cal.year_month,'-','') as year_month\r\n from {{ ref('reference_data__calendar') }} cal\r\n where (cal.year_month >= (select min(year_month) from date_stage)\r\n and cal.year_month <= (select max(year_month) from date_stage))\r\n\r\n)\r\n\r\nselect\r\n cast(all_date.year_month as {{ dbt.type_int() }} ) as year_month\r\n , claim_start.result_count as claim_start_date\r\n , claim_end.result_count as claim_end_date\r\n , admission_date.result_count as admission_date\r\n , discharge_date.result_count as discharge_date\r\n , med_paid_date.result_count as medical_paid_date\r\n , dispensing_date.result_count as dispensing_date\r\n , pharm_paid_date.result_count as pharmacy_paid_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom all_date_range all_date\r\nleft join date_stage claim_start\r\n on all_date.year_month = claim_start.year_month\r\n and claim_start.date_field = 'claim_start_date'\r\nleft join date_stage claim_end\r\n on all_date.year_month = claim_end.year_month\r\n and claim_end.date_field = 'claim_end_date'\r\nleft join date_stage admission_date\r\n on all_date.year_month = admission_date.year_month\r\n and admission_date.date_field = 'admission_date'\r\nleft join date_stage discharge_date\r\n on all_date.year_month = discharge_date.year_month\r\n and discharge_date.date_field = 'discharge_date'\r\nleft join date_stage med_paid_date\r\n on all_date.year_month = med_paid_date.year_month\r\n and med_paid_date.date_field = 'medical paid_date'\r\nleft join date_stage dispensing_date\r\n on all_date.year_month = dispensing_date.year_month\r\n and dispensing_date.date_field = 'dispensing_date'\r\nleft join date_stage pharm_paid_date\r\n on all_date.year_month = pharm_paid_date.year_month\r\n and pharm_paid_date.date_field = 'pharmacy paid_date'", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat", "macro.dbt.right", "macro.the_tuva_project.date_part", "macro.dbt.type_string", "macro.dbt.type_int"], "nodes": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__claim_date_trends.sql", "compiled": true, "compiled_code": "\n\nwith date_stage as(\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_start_date' as date_field\n , cast(date_part('year', claim_start_date) as TEXT) as year\n , cast(date_part('month', claim_start_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_start_date) as TEXT)\n , cast(date_part('month', claim_start_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_end_date' as date_field\n , cast(date_part('year', claim_end_date) as TEXT) as year\n , cast(date_part('month', claim_end_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_end_date) as TEXT)\n , cast(date_part('month', claim_end_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'admission_date' as date_field\n , cast(date_part('year', admission_date) as TEXT) as year\n , cast(date_part('month', admission_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', admission_date) as TEXT)\n , cast(date_part('month', admission_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'discharge_date' as date_field\n , cast(date_part('year', discharge_date) as TEXT) as year\n , cast(date_part('month', discharge_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', discharge_date) as TEXT)\n , cast(date_part('month', discharge_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'medical paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'dispensing_date' as date_field\n , cast(date_part('year', dispensing_date) as TEXT) as year\n , cast(date_part('month', dispensing_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', dispensing_date) as TEXT)\n , cast(date_part('month', dispensing_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'pharmacy paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n)\n\n\n, all_date_range as (\n select distinct\n replace(cal.year_month,'-','') as year_month\n from dev_thuxuan.reference_data.calendar cal\n where (cal.year_month >= (select min(year_month) from date_stage)\n and cal.year_month <= (select max(year_month) from date_stage))\n\n)\n\nselect\n cast(all_date.year_month as integer ) as year_month\n , claim_start.result_count as claim_start_date\n , claim_end.result_count as claim_end_date\n , admission_date.result_count as admission_date\n , discharge_date.result_count as discharge_date\n , med_paid_date.result_count as medical_paid_date\n , dispensing_date.result_count as dispensing_date\n , pharm_paid_date.result_count as pharmacy_paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom all_date_range all_date\nleft join date_stage claim_start\n on all_date.year_month = claim_start.year_month\n and claim_start.date_field = 'claim_start_date'\nleft join date_stage claim_end\n on all_date.year_month = claim_end.year_month\n and claim_end.date_field = 'claim_end_date'\nleft join date_stage admission_date\n on all_date.year_month = admission_date.year_month\n and admission_date.date_field = 'admission_date'\nleft join date_stage discharge_date\n on all_date.year_month = discharge_date.year_month\n and discharge_date.date_field = 'discharge_date'\nleft join date_stage med_paid_date\n on all_date.year_month = med_paid_date.year_month\n and med_paid_date.date_field = 'medical paid_date'\nleft join date_stage dispensing_date\n on all_date.year_month = dispensing_date.year_month\n and dispensing_date.date_field = 'dispensing_date'\nleft join date_stage pharm_paid_date\n on all_date.year_month = pharm_paid_date.year_month\n and pharm_paid_date.date_field = 'pharmacy paid_date'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__core_populated": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__core_populated", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__core_populated.sql", "original_file_path": "models\\data_quality\\final\\data_quality__core_populated.sql", "unique_id": "model.the_tuva_project.data_quality__core_populated", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__core_populated"], "alias": "core_populated", "checksum": {"name": "sha256", "checksum": "0577d2ecf0cac22e212de75dcbea946bf8f467ef5e26dd9213e32f4c28791ba8"}, "config": {"enabled": true, "alias": "core_populated", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"table_name": {"name": "table_name", "description": "the name of the table's records being counted", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "record_count": {"name": "record_count", "description": "the total number of records belonging to the specific data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "core_populated", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0680478, "relation_name": "dev_thuxuan.data_quality.core_populated", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith medical as (\r\n select\r\n 'medical_claim' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__medical_claim') }}\r\n)\r\n\r\n, pharmacy as (\r\n select\r\n 'pharmacy_claim' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__pharmacy_claim') }}\r\n)\r\n\r\n, eligibility as (\r\n select\r\n 'eligibility' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__eligibility') }}\r\n)\r\n\r\n, member_months as (\r\n select\r\n 'member_months' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__member_months') }}\r\n)\r\n\r\n, patient as (\r\n select\r\n 'patient' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__patient') }}\r\n)\r\n\r\n, encounter as (\r\n select\r\n 'encounter' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__encounter') }}\r\n)\r\n\r\n, condition as (\r\n select\r\n 'condition' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__condition') }}\r\n)\r\n\r\n, procedure_cte as (\r\n select\r\n 'procedure' as table_name\r\n , count(*) as record_count\r\n from {{ ref('core__procedure') }}\r\n)\r\n\r\n,final as (\r\nselect * from medical\r\nunion all\r\nselect * from pharmacy\r\nunion all\r\nselect * from eligibility\r\nunion all\r\nselect * from member_months\r\nunion all\r\nselect * from patient\r\nunion all\r\nselect * from encounter\r\nunion all\r\nselect * from condition\r\nunion all\r\nselect * from procedure_cte\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}, {"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__condition", "package": null, "version": null}, {"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__patient", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__condition", "model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__core_populated.sql", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n 'medical_claim' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.medical_claim\n)\n\n, pharmacy as (\n select\n 'pharmacy_claim' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.pharmacy_claim\n)\n\n, eligibility as (\n select\n 'eligibility' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.eligibility\n)\n\n, member_months as (\n select\n 'member_months' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.member_months\n)\n\n, patient as (\n select\n 'patient' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.patient\n)\n\n, encounter as (\n select\n 'encounter' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.encounter\n)\n\n, condition as (\n select\n 'condition' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.condition\n)\n\n, procedure_cte as (\n select\n 'procedure' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.procedure\n)\n\n,final as (\nselect * from medical\nunion all\nselect * from pharmacy\nunion all\nselect * from eligibility\nunion all\nselect * from member_months\nunion all\nselect * from patient\nunion all\nselect * from encounter\nunion all\nselect * from condition\nunion all\nselect * from procedure_cte\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_loss": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_loss", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__data_loss.sql", "original_file_path": "models\\data_quality\\final\\data_quality__data_loss.sql", "unique_id": "model.the_tuva_project.data_quality__data_loss", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__data_loss"], "alias": "data_loss", "checksum": {"name": "sha256", "checksum": "750f165df4a432f857cc7364b94d5db9f92e4938b331eef8a08438f931bb601a"}, "config": {"enabled": true, "alias": "data_loss", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"table_name": {"name": "table_name", "description": "the name of the table's records being counted", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "metric": {"name": "metric", "description": "the name of the metric being analyzed", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "input_layer_value": {"name": "input_layer_value", "description": "the count of the metric found in the input layer schema of the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "core_value": {"name": "core_value", "description": "the count of the metric found in the core layer schema of the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_loss", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0660474, "relation_name": "dev_thuxuan.data_quality.data_loss", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith input_medical as (\r\n select\r\n cast('medical_claim' as {{ dbt.type_string() }}) as table_name\r\n , count(distinct patient_id) as patient_count\r\n , count(distinct claim_id) as claim_count\r\n , count(*) as record_count\r\n , sum(paid_amount) as paid_amount\r\n , sum(allowed_amount) as allowed_amount\r\n from {{ ref('medical_claim') }}\r\n)\r\n\r\n, input_pharmacy as (\r\n select\r\n cast('pharmacy_claim' as {{ dbt.type_string() }}) as table_name\r\n , count(distinct patient_id) as patient_count\r\n , count(distinct claim_id) as claim_count\r\n , count(*) as record_count\r\n , sum(paid_amount) as paid_amount\r\n , sum(allowed_amount) as allowed_amount\r\n from {{ ref('pharmacy_claim') }}\r\n)\r\n\r\n,input_eligibility as (\r\nselect\r\n cast('eligibility' as {{ dbt.type_string() }}) as table_name\r\n , count(distinct patient_id) as patient_count\r\n , count(distinct {{ dbt.concat([\r\n 'member_id'\r\n , \"'-'\"\r\n , 'enrollment_start_date'\r\n , \"'-'\"\r\n , 'enrollment_end_date'\r\n , \"'-'\"\r\n , 'payer'\r\n , \"'-'\"\r\n , quote_column('plan')\r\n ]) }}) as span_count\r\nfrom {{ ref('eligibility') }}\r\n)\r\n\r\n , input_member_months as (\r\n select\r\n cast('eligibility' as {{ dbt.type_string() }}) as table_name\r\n , count(*) as member_month_count\r\n from {{ ref('data_quality__eligibility_dq_stage') }} e\r\n)\r\n\r\n-- Core layer CTEs\r\n, core_medical as (\r\n select\r\n cast( 'medical_claim' as {{ dbt.type_string() }}) as table_name\r\n , count(distinct patient_id) as patient_count\r\n , count(distinct claim_id) as claim_count\r\n , count(*) as record_count\r\n , sum(paid_amount) as paid_amount\r\n , sum(allowed_amount) as allowed_amount\r\n from {{ ref('core__medical_claim') }}\r\n)\r\n\r\n, core_pharmacy as (\r\n select\r\n cast( 'pharmacy_claim' as {{ dbt.type_string() }}) as table_name\r\n , count(distinct patient_id) as patient_count\r\n , count(distinct claim_id) as claim_count\r\n , count(*) as record_count\r\n , sum(paid_amount) as paid_amount\r\n , sum(allowed_amount) as allowed_amount\r\n from {{ ref('core__pharmacy_claim') }}\r\n)\r\n\r\n, core_eligibility as (\r\n select\r\n cast('eligibility' as {{ dbt.type_string() }})as table_name\r\n , count(distinct patient_id) as patient_count\r\n , count(*) as span_count\r\n from {{ ref('core__eligibility') }}\r\n)\r\n\r\n, core_member_months as (\r\n select\r\n cast('member_months' as {{ dbt.type_string() }}) as table_name\r\n , count(*) as member_month_count\r\n from {{ ref('core__member_months') }}\r\n)\r\n\r\n,final as (\r\n-- Combining both input and core layers\r\nselect\r\n input.table_name\r\n , cast('Total Unique Patients' as {{ dbt.type_string() }}) as metric\r\n , input.patient_count as input_layer_value\r\n , core.patient_count as core_value\r\nfrom input_medical as input\r\ninner join core_medical as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Unique Claims' as {{ dbt.type_string() }}) as metric\r\n , input.claim_count as input_layer_value\r\n , core.claim_count as core_value\r\nfrom input_medical as input\r\ninner join core_medical as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Records' as {{ dbt.type_string() }}) as metric\r\n , input.record_count as input_layer_value\r\n , core.record_count as core_value\r\nfrom input_medical as input\r\ninner join core_medical as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Paid Amount' as {{ dbt.type_string() }}) as metric\r\n , input.paid_amount as input_layer_value\r\n , core.paid_amount as core_value\r\nfrom input_medical as input\r\ninner join core_medical as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Allowed Amount' as {{ dbt.type_string() }}) as metric\r\n , input.allowed_amount as input_layer_value\r\n , core.allowed_amount as core_value\r\nfrom input_medical as input\r\ninner join core_medical as core\r\n on input.table_name = core.table_name\r\n\r\n-- Pharmacy layer\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Unique Patients' as {{ dbt.type_string() }}) as metric\r\n , input.patient_count as input_layer_value\r\n , core.patient_count as core_value\r\nfrom input_pharmacy as input\r\ninner join core_pharmacy as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Unique Claims' as {{ dbt.type_string() }}) as metric\r\n , input.claim_count as input_layer_value\r\n , core.claim_count as core_value\r\nfrom input_pharmacy as input\r\ninner join core_pharmacy as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Records' as {{ dbt.type_string() }}) as metric\r\n , input.record_count as input_layer_value\r\n , core.record_count as core_value\r\nfrom input_pharmacy as input\r\ninner join core_pharmacy as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Paid Amount' as {{ dbt.type_string() }}) as metric\r\n , input.paid_amount as input_layer_value\r\n , core.paid_amount as core_value\r\nfrom input_pharmacy as input\r\ninner join core_pharmacy as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Allowed Amount' as {{ dbt.type_string() }}) as metric\r\n , input.allowed_amount as input_layer_value\r\n , core.allowed_amount as core_value\r\nfrom input_pharmacy as input\r\ninner join core_pharmacy as core\r\n on input.table_name = core.table_name\r\n\r\n-- Eligibility layer\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Unique Patients' as {{ dbt.type_string() }}) as metric\r\n , input.patient_count as input_layer_value\r\n , core.patient_count as core_value\r\nfrom input_eligibility as input\r\ninner join core_eligibility as core\r\n on input.table_name = core.table_name\r\n\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Unique Eligibility Spans' as {{ dbt.type_string() }}) as metric\r\n , input.span_count as input_layer_value\r\n , core.span_count as core_value\r\nfrom input_eligibility as input\r\ninner join core_eligibility as core\r\n on input.table_name = core.table_name\r\n\r\nunion all\r\n\r\nselect\r\n input.table_name\r\n , cast('Total Member Months' as {{ dbt.type_string() }}) as metric\r\n , input.member_month_count as input_layer_value\r\n , core.member_month_count as core_value\r\nfrom input_member_months as input\r\ninner join core_member_months as core\r\n on input.table_name = core.table_name\r\n\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "core__member_months", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column", "macro.dbt.concat"], "nodes": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "model.input_layer.eligibility", "model.the_tuva_project.data_quality__eligibility_dq_stage", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__member_months"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__data_loss.sql", "compiled": true, "compiled_code": "\n\nwith input_medical as (\n select\n cast('medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.medical_claim\n)\n\n, input_pharmacy as (\n select\n cast('pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.pharmacy_claim\n)\n\n,input_eligibility as (\nselect\n cast('eligibility' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan) as span_count\nfrom tuva.input_layer.eligibility\n)\n\n , input_member_months as (\n select\n cast('eligibility' as TEXT) as table_name\n , count(*) as member_month_count\n from dev_thuxuan.data_quality.data_quality__eligibility_dq_stage e\n)\n\n-- Core layer CTEs\n, core_medical as (\n select\n cast( 'medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from dev_thuxuan.core.medical_claim\n)\n\n, core_pharmacy as (\n select\n cast( 'pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from dev_thuxuan.core.pharmacy_claim\n)\n\n, core_eligibility as (\n select\n cast('eligibility' as TEXT)as table_name\n , count(distinct patient_id) as patient_count\n , count(*) as span_count\n from dev_thuxuan.core.eligibility\n)\n\n, core_member_months as (\n select\n cast('member_months' as TEXT) as table_name\n , count(*) as member_month_count\n from dev_thuxuan.core.member_months\n)\n\n,final as (\n-- Combining both input and core layers\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\n-- Pharmacy layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\n-- Eligibility layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Eligibility Spans' as TEXT) as metric\n , input.span_count as input_layer_value\n , core.span_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Member Months' as TEXT) as metric\n , input.member_month_count as input_layer_value\n , core.member_month_count as core_value\nfrom input_member_months as input\ninner join core_member_months as core\n on input.table_name = core.table_name\n\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__data_quality_test_summary": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__data_quality_test_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__data_quality_test_summary.sql", "original_file_path": "models\\data_quality\\final\\data_quality__data_quality_test_summary.sql", "unique_id": "model.the_tuva_project.data_quality__data_quality_test_summary", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__data_quality_test_summary"], "alias": "data_quality_test_summary", "checksum": {"name": "sha256", "checksum": "b63503f40a7cdd39c70eafc0df659304b70cd35b90223d3e2298044166b4f2ef"}, "config": {"enabled": true, "alias": "data_quality_test_summary", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "the count of records that match the result of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_test_summary", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0290477, "relation_name": "dev_thuxuan.data_quality.data_quality_test_summary", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith unioned_data as (\r\n\r\n -- Unioning multiple data quality checks, excluding the _loaded_at field\r\n {{ dbt_utils.union_relations(\r\n relations=[\r\n ref('data_quality__medical_claim_claim_line_fields')\r\n , ref('data_quality__medical_claim_date_checks')\r\n , ref('data_quality__medical_claim_inst_header_fields')\r\n , ref('data_quality__medical_claim_patient_id')\r\n , ref('data_quality__medical_claim_provider_npi')\r\n , ref('data_quality__pharmacy_claim_date_checks')\r\n , ref('data_quality__pharmacy_claim_ndc')\r\n , ref('data_quality__pharmacy_claim_npi')\r\n , ref('data_quality__pharmacy_claim_prescription_details')\r\n , ref('data_quality__pharmacy_claim_patient_id')\r\n , ref('data_quality__primary_key_check')\r\n , ref('data_quality__eligibility_date_checks')\r\n , ref('data_quality__eligibility_demographics')\r\n , ref('data_quality__eligibility_missing_patient_id')\r\n , ref('data_quality__eligibility_missing_payer')\r\n ],\r\n exclude=[\"_loaded_at\"]\r\n ) }}\r\n\r\n)\r\n\r\nselect\r\n data_quality_check\r\n , result_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom unioned_data\r\nwhere data_quality_check <> 'Percent of claims with secondary diagnosis'", "language": "sql", "refs": [{"name": "data_quality__medical_claim_claim_line_fields", "package": null, "version": null}, {"name": "data_quality__medical_claim_date_checks", "package": null, "version": null}, {"name": "data_quality__medical_claim_inst_header_fields", "package": null, "version": null}, {"name": "data_quality__medical_claim_patient_id", "package": null, "version": null}, {"name": "data_quality__medical_claim_provider_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_date_checks", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_ndc", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_npi", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_prescription_details", "package": null, "version": null}, {"name": "data_quality__pharmacy_claim_patient_id", "package": null, "version": null}, {"name": "data_quality__primary_key_check", "package": null, "version": null}, {"name": "data_quality__eligibility_date_checks", "package": null, "version": null}, {"name": "data_quality__eligibility_demographics", "package": null, "version": null}, {"name": "data_quality__eligibility_missing_patient_id", "package": null, "version": null}, {"name": "data_quality__eligibility_missing_payer", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations"], "nodes": ["model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__eligibility_date_checks", "model.the_tuva_project.data_quality__eligibility_demographics", "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "model.the_tuva_project.data_quality__eligibility_missing_payer"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__data_quality_test_summary.sql", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_claim_line_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_claim_line_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_inst_header_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_inst_header_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_provider_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_provider_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_ndc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_ndc\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_prescription_details' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_prescription_details\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.primary_key_check' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.primary_key_check\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_demographics' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_demographics\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_missing_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_missing_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_missing_payer' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_missing_payer\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned_data\nwhere data_quality_check <> 'Percent of claims with secondary diagnosis'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_trend": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__eligibility_trend.sql", "original_file_path": "models\\data_quality\\final\\data_quality__eligibility_trend.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_trend", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__eligibility_trend"], "alias": "eligibility_trend", "checksum": {"name": "sha256", "checksum": "3a1ccc222d23fa6421ee898b31b37b6d77225621f2acc6de811fd363ee955dcd"}, "config": {"enabled": true, "alias": "eligibility_trend", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "The year and month", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "The count of distinct members with eligibility in the corresponding year and month", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_trend", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0240479, "relation_name": "dev_thuxuan.data_quality.eligibility_trend", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith eligibility_spans as(\r\n select distinct\r\n {{ dbt.concat([\r\n \"member_id\",\r\n \"'-'\",\r\n \"enrollment_start_date\",\r\n \"'-'\",\r\n \"enrollment_end_date\",\r\n \"'-'\",\r\n \"payer\",\r\n \"'-'\",\r\n quote_column('plan'),\r\n ]) }} as eligibility_span_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n from {{ ref('eligibility') }}\r\n)\r\n, month_start_and_end_dates as (\r\n select\r\n {{ dbt.concat([\"year\",\r\n dbt.right(dbt.concat([\"'0'\", \"month\"]), 2)]) }} as year_month\r\n , min(full_date) as month_start_date\r\n , max(full_date) as month_end_date\r\n from {{ ref('reference_data__calendar')}}\r\n group by year, month, year_month\r\n)\r\n, member_months as (\r\n select distinct\r\n eligibility_span_id\r\n , year_month\r\n from eligibility_spans es\r\n inner join month_start_and_end_dates d\r\n on es.enrollment_start_date <= d.month_end_date\r\n and es.enrollment_end_date >= d.month_start_date\r\n)\r\n\r\n\r\nselect\r\n year_month\r\n , count(distinct eligibility_span_id) as member_months\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom member_months\r\ngroup by\r\n year_month", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.right"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__eligibility_trend.sql", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n, month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from dev_thuxuan.reference_data.calendar\n group by year, month, year_month\n)\n, member_months as (\n select distinct\n eligibility_span_id\n , year_month\n from eligibility_spans es\n inner join month_start_and_end_dates d\n on es.enrollment_start_date <= d.month_end_date\n and es.enrollment_end_date >= d.month_start_date\n)\n\n\nselect\n year_month\n , count(distinct eligibility_span_id) as member_months\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom member_months\ngroup by\n year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounters_cost_and_utilization_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__encounters_cost_and_utilization_trend.sql", "original_file_path": "models\\data_quality\\final\\data_quality__encounters_cost_and_utilization_trend.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__encounters_cost_and_utilization_trend"], "alias": "encounters_cost_and_utilization_trend", "checksum": {"name": "sha256", "checksum": "db75fa0442168139456cfae608d70509222eb793dbe072a19fd36792e30e8b1e"}, "config": {"enabled": true, "alias": "encounters_cost_and_utilization_trend", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_cost_and_utilization_trend", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.9975312, "relation_name": "dev_thuxuan.data_quality.encounters_cost_and_utilization_trend", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\r\n) }}\r\n\r\nwith member_months as (\r\n select\r\n year_month\r\n , count(1) as member_months\r\n from {{ ref('core__member_months') }}\r\n group by year_month\r\n)\r\n\r\n, encounters as (\r\n select\r\n cast(cal.year_month_int as {{ dbt.type_string() }}) as year_month\r\n , e.encounter_group\r\n , e.encounter_type\r\n , e.encounter_id\r\n , e.paid_amount\r\n from {{ ref('core__encounter') }} as e\r\n left join {{ ref('reference_data__calendar') }} as cal\r\n on e.encounter_start_date = cal.full_date\r\n)\r\n\r\n, pkpy_trend as (\r\n select\r\n enc.year_month\r\n , enc.encounter_group\r\n , enc.encounter_type\r\n , count(enc.encounter_id) / mm.member_months * 12000 as pkpy\r\n , sum(enc.paid_amount) / nullif(count(enc.encounter_id), 0) as paid_per\r\n from encounters as enc\r\n inner join member_months as mm\r\n on enc.year_month = mm.year_month\r\n group by\r\n enc.year_month\r\n , enc.encounter_group\r\n , enc.encounter_type\r\n , mm.member_months\r\n)\r\n\r\nselect\r\n pkpy_trend.year_month\r\n , pkpy_trend.encounter_group\r\n , pkpy_trend.encounter_type\r\n , pkpy_trend.pkpy\r\n , pkpy_trend.paid_per\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom pkpy_trend", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__encounter", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__encounters_cost_and_utilization_trend.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from dev_thuxuan.core.member_months\n group by year_month\n)\n\n, encounters as (\n select\n cast(cal.year_month_int as TEXT) as year_month\n , e.encounter_group\n , e.encounter_type\n , e.encounter_id\n , e.paid_amount\n from dev_thuxuan.core.encounter as e\n left join dev_thuxuan.reference_data.calendar as cal\n on e.encounter_start_date = cal.full_date\n)\n\n, pkpy_trend as (\n select\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , count(enc.encounter_id) / mm.member_months * 12000 as pkpy\n , sum(enc.paid_amount) / nullif(count(enc.encounter_id), 0) as paid_per\n from encounters as enc\n inner join member_months as mm\n on enc.year_month = mm.year_month\n group by\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , mm.member_months\n)\n\nselect\n pkpy_trend.year_month\n , pkpy_trend.encounter_group\n , pkpy_trend.encounter_type\n , pkpy_trend.pkpy\n , pkpy_trend.paid_per\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pkpy_trend", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medical_claim_volume_and_dollars", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__medical_claim_volume_and_dollars.sql", "original_file_path": "models\\data_quality\\final\\data_quality__medical_claim_volume_and_dollars.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__medical_claim_volume_and_dollars"], "alias": "medical_claim_volume_and_dollars", "checksum": {"name": "sha256", "checksum": "7ea6d490e7ab42c4399f89145dbfc0811da5081f4c944346a775586c52cbb486"}, "config": {"enabled": true, "alias": "medical_claim_volume_and_dollars", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "the year and month in format yyyymm", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_volume": {"name": "claim_volume", "description": "the unique count of claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_volume_and_dollars", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0630476, "relation_name": "dev_thuxuan.data_quality.medical_claim_volume_and_dollars", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith range_cte as (\r\n select\r\n min(claim_start_date) as first_date\r\n {% if target.type == 'fabric' %}\r\n , getdate() as last_date\r\n {% else %}\r\n , current_date as last_date\r\n {% endif %}\r\n from {{ ref('medical_claim') }} p\r\n)\r\n\r\n, date_cte as (\r\n select distinct\r\n year_month_int\r\n from {{ ref('reference_data__calendar') }} c\r\n inner join range_cte r\r\n on c.full_date between r.first_date and r.last_date\r\n)\r\n\r\n, medical_claim as (\r\n select\r\n c.year_month_int\r\n , count(distinct p.claim_id) as claim_volume\r\n , sum(p.paid_amount) as paid_amount\r\n from {{ ref('medical_claim') }} p\r\n left join {{ ref('reference_data__calendar') }} c\r\n on p.claim_start_date = c.full_date\r\n group by\r\n c.year_month_int\r\n)\r\n\r\nselect\r\n d.year_month_int as year_month\r\n , coalesce(claim_volume, 0) as claim_volume\r\n , coalesce(paid_amount, 0) as paid_amount\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom date_cte d\r\nleft join medical_claim m\r\n on d.year_month_int = m.year_month_int", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__medical_claim_volume_and_dollars.sql", "compiled": true, "compiled_code": "\n\nwith range_cte as (\n select\n min(claim_start_date) as first_date\n \n , current_date as last_date\n \n from tuva.input_layer.medical_claim p\n)\n\n, date_cte as (\n select distinct\n year_month_int\n from dev_thuxuan.reference_data.calendar c\n inner join range_cte r\n on c.full_date between r.first_date and r.last_date\n)\n\n, medical_claim as (\n select\n c.year_month_int\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n from tuva.input_layer.medical_claim p\n left join dev_thuxuan.reference_data.calendar c\n on p.claim_start_date = c.full_date\n group by\n c.year_month_int\n)\n\nselect\n d.year_month_int as year_month\n , coalesce(claim_volume, 0) as claim_volume\n , coalesce(paid_amount, 0) as paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom date_cte d\nleft join medical_claim m\n on d.year_month_int = m.year_month_int", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_volume_and_dollars", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__pharmacy_claim_volume_and_dollars.sql", "original_file_path": "models\\data_quality\\final\\data_quality__pharmacy_claim_volume_and_dollars.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__pharmacy_claim_volume_and_dollars"], "alias": "pharmacy_claim_volume_and_dollars", "checksum": {"name": "sha256", "checksum": "f4b1182e282ec36d8c218d234d6a7325cf485c9b3e30bd5022b94af5d155f6d4"}, "config": {"enabled": true, "alias": "pharmacy_claim_volume_and_dollars", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"year_month": {"name": "year_month", "description": "the year and month in format yyyymm", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_volume": {"name": "claim_volume", "description": "the unique count of claims", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total amount paid by the insurer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_volume_and_dollars", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0470479, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_volume_and_dollars", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nselect\r\n c.year_month_int as year_month\r\n , count(distinct p.claim_id) as claim_volume\r\n , sum(p.paid_amount) as paid_amount\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('pharmacy_claim') }} p\r\nleft join {{ ref('reference_data__calendar') }} c\r\n on coalesce(p.paid_date, p.dispensing_date) = c.full_date\r\ngroup by\r\n c.year_month_int", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__pharmacy_claim_volume_and_dollars.sql", "compiled": true, "compiled_code": "\n\nselect\n c.year_month_int as year_month\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim p\nleft join dev_thuxuan.reference_data.calendar c\n on coalesce(p.paid_date, p.dispensing_date) = c.full_date\ngroup by\n c.year_month_int", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__service_category_pmpm_trend": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__service_category_pmpm_trend", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\final\\data_quality__service_category_pmpm_trend.sql", "original_file_path": "models\\data_quality\\final\\data_quality__service_category_pmpm_trend.sql", "unique_id": "model.the_tuva_project.data_quality__service_category_pmpm_trend", "fqn": ["the_tuva_project", "data_quality", "final", "data_quality__service_category_pmpm_trend"], "alias": "service_category_pmpm_trend", "checksum": {"name": "sha256", "checksum": "275f507b617a3618a8daa1df1af8410361a9a7cd54816726fc90dba428d909d0"}, "config": {"enabled": true, "alias": "service_category_pmpm_trend", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "service_category_pmpm_trend", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.9995313, "relation_name": "dev_thuxuan.data_quality.service_category_pmpm_trend", "raw_code": "{{ config(enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool) }}\r\n\r\nwith member_months as (\r\n select\r\n year_month\r\n , count(1) as member_months\r\n from {{ ref('core__member_months') }}\r\n group by year_month\r\n)\r\n\r\n, service_categories as (\r\n select\r\n cast(c.year_month_int as {{ dbt.type_string() }}) as year_month\r\n , m.service_category_1\r\n , m.service_category_2\r\n , sum(m.paid_amount) as total_paid\r\n from {{ ref('core__medical_claim') }} as m\r\n left join {{ ref('reference_data__calendar') }} as c\r\n on m.claim_start_date = c.full_date\r\n group by\r\n cast(c.year_month_int as {{ dbt.type_string() }})\r\n , m.service_category_1\r\n , m.service_category_2\r\n)\r\n\r\nselect\r\n scat.year_month\r\n , scat.service_category_1\r\n , scat.service_category_2\r\n , scat.total_paid\r\n , scat.total_paid / mm.member_months as pmpm\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom service_categories as scat\r\ninner join member_months as mm\r\n on scat.year_month = mm.year_month", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "reference_data__calendar", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.reference_data__calendar"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\final\\data_quality__service_category_pmpm_trend.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from dev_thuxuan.core.member_months\n group by year_month\n)\n\n, service_categories as (\n select\n cast(c.year_month_int as TEXT) as year_month\n , m.service_category_1\n , m.service_category_2\n , sum(m.paid_amount) as total_paid\n from dev_thuxuan.core.medical_claim as m\n left join dev_thuxuan.reference_data.calendar as c\n on m.claim_start_date = c.full_date\n group by\n cast(c.year_month_int as TEXT)\n , m.service_category_1\n , m.service_category_2\n)\n\nselect\n scat.year_month\n , scat.service_category_1\n , scat.service_category_2\n , scat.total_paid\n , scat.total_paid / mm.member_months as pmpm\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_categories as scat\ninner join member_months as mm\n on scat.year_month = mm.year_month", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__acute_inpatient": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__acute_inpatient", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__acute_inpatient.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__acute_inpatient.sql", "unique_id": "model.the_tuva_project.data_quality__acute_inpatient", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__acute_inpatient"], "alias": "data_quality_acute_inpatient", "checksum": {"name": "sha256", "checksum": "f05d39214e5aba46d42f740d2ab7976b5d68db5f044b98097f55b3593fa9d8e0"}, "config": {"enabled": true, "alias": "data_quality_acute_inpatient", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_acute_inpatient", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0900476, "relation_name": "dev_thuxuan.data_quality.data_quality_acute_inpatient", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\n select count(*) as result_count\r\n ,'inpatient encounter missing professional claim' as data_quality_check\r\n from {{ ref('core__encounter') }}\r\n where encounter_type = 'acute inpatient'\r\n and prof_claim_count = 0 \r\n)\r\n\r\n\r\nselect data_quality_check\r\n,result_count\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom cte", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__acute_inpatient.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select count(*) as result_count\n ,'inpatient encounter missing professional claim' as data_quality_check\n from dev_thuxuan.core.encounter\n where encounter_type = 'acute inpatient'\n and prof_claim_count = 0 \n)\n\n\nselect data_quality_check\n,result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__acute_inpatient_prevelence": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__acute_inpatient_prevelence", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__acute_inpatient_prevelence.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__acute_inpatient_prevelence.sql", "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__acute_inpatient_prevelence"], "alias": "data_quality_acute_inpatient_prevelence", "checksum": {"name": "sha256", "checksum": "f76383e61afdf67116adfb0dc177bc6244dca6ad3d91a11616d0554b94d5cedf"}, "config": {"enabled": true, "alias": "data_quality_acute_inpatient_prevelence", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_acute_inpatient_prevelence", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0920525, "relation_name": "dev_thuxuan.data_quality.data_quality_acute_inpatient_prevelence", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith total_cte as (\r\nselect cast(count(*) as {{ dbt.type_numeric() }} ) as total_encounters\r\nfrom {{ ref('core__encounter') }}\r\nwhere encounter_type = 'acute inpatient'\r\n) \r\n\r\n,cte as (\r\nselect \r\n {{ dbt.concat([\r\n 'ms_drg_code',\r\n \"' - '\",\r\n 'ms_drg_description'\r\n ]) }} as ms_drg_code_and_description\r\n ,cast('acute inpatient drg distribution' as {{ dbt.type_string() }} ) as analytics_concept\r\n ,cast(count(*) as {{ dbt.type_numeric() }} )/total_encounters as encounter_percent\r\n ,total_encounters\r\n ,row_number() over (order by count(*) desc) as rank_nbr\r\nfrom {{ ref('core__encounter') }}\r\ncross join total_cte \r\nwhere encounter_type = 'acute inpatient'\r\nand\r\nms_drg_code is not null\r\ngroup by \r\n {{ dbt.concat([\r\n 'ms_drg_code',\r\n \"' - '\",\r\n 'ms_drg_description'\r\n ]) }},\r\n total_encounters\r\n)\r\n\r\nselect \r\n cte.analytics_concept\r\n ,ms_drg_code_and_description as analytics_measure\r\n ,encounter_percent as data_source_value\r\n ,m.analytics_value\r\n ,rank_nbr as value_rank\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join cte on\r\nm.analytics_concept = cte.analytics_concept\r\nand\r\ncte.rank_nbr = m.value_rank\r\nwhere m.analytics_concept = 'acute inpatient drg distribution'\r\nand rank_nbr < 11", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__acute_inpatient_prevelence.sql", "compiled": true, "compiled_code": "\n\nwith total_cte as (\nselect cast(count(*) as numeric(28,6) ) as total_encounters\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n) \n\n,cte as (\nselect \n ms_drg_code || ' - ' || ms_drg_description as ms_drg_code_and_description\n ,cast('acute inpatient drg distribution' as TEXT ) as analytics_concept\n ,cast(count(*) as numeric(28,6) )/total_encounters as encounter_percent\n ,total_encounters\n ,row_number() over (order by count(*) desc) as rank_nbr\nfrom dev_thuxuan.core.encounter\ncross join total_cte \nwhere encounter_type = 'acute inpatient'\nand\nms_drg_code is not null\ngroup by \n ms_drg_code || ' - ' || ms_drg_description,\n total_encounters\n)\n\nselect \n cte.analytics_concept\n ,ms_drg_code_and_description as analytics_measure\n ,encounter_percent as data_source_value\n ,m.analytics_value\n ,rank_nbr as value_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on\nm.analytics_concept = cte.analytics_concept\nand\ncte.rank_nbr = m.value_rank\nwhere m.analytics_concept = 'acute inpatient drg distribution'\nand rank_nbr < 11", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__acute_inpatient_reference": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__acute_inpatient_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__acute_inpatient_reference.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__acute_inpatient_reference.sql", "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__acute_inpatient_reference"], "alias": "data_quality_acute_inpatient_reference", "checksum": {"name": "sha256", "checksum": "31dbb7dbf36f2829427e5d7ed85d54ffc6819bf44fc61d0605f3c893394109d9"}, "config": {"enabled": true, "alias": "data_quality_acute_inpatient_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_acute_inpatient_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0880475, "relation_name": "dev_thuxuan.data_quality.data_quality_acute_inpatient_reference", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\nselect avg(length_of_stay) los\r\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end) deceased_encounters\r\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end)/count(*) as mortality_rate\r\nfrom {{ ref('core__encounter') }}\r\nwhere encounter_type = 'acute inpatient'\r\n)\r\n\r\n\r\n,long_cte as (\r\n select 'acute inpatient' as analytics_concept\r\n,'length of stay' as analytics_measure\r\n,los as data_source_value\r\nfrom cte\r\n\r\nunion all \r\n\r\n select 'acute inpatient' as analytics_concept\r\n,'mortality rate' as analytics_measure\r\n,mortality_rate as data_source_value\r\nfrom cte\r\n)\r\n\r\n\r\nselect m.analytics_concept\r\n,m.analytics_measure\r\n,data_source_value\r\n,m.analytics_value\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\r\nand\r\nm.analytics_concept = long_cte.analytics_concept\r\nwhere m.analytics_concept = 'acute inpatient'\r\nand\r\nm.analytics_measure = 'length of stay'\r\n\r\nunion all \r\n\r\nselect m.analytics_concept\r\n,m.analytics_measure\r\n,data_source_value\r\n,m.analytics_value\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\r\nand\r\nm.analytics_concept = long_cte.analytics_concept\r\nwhere m.analytics_concept = 'acute inpatient'\r\nand\r\nm.analytics_measure = 'mortality rate'", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__acute_inpatient_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(length_of_stay) los\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end) deceased_encounters\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end)/count(*) as mortality_rate\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n)\n\n\n,long_cte as (\n select 'acute inpatient' as analytics_concept\n,'length of stay' as analytics_measure\n,los as data_source_value\nfrom cte\n\nunion all \n\n select 'acute inpatient' as analytics_concept\n,'mortality rate' as analytics_measure\n,mortality_rate as data_source_value\nfrom cte\n)\n\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'length of stay'\n\nunion all \n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'mortality rate'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__chronic_conditions_none": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__chronic_conditions_none", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__chronic_conditions_none.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__chronic_conditions_none.sql", "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_none", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__chronic_conditions_none"], "alias": "chronic_conditions_none", "checksum": {"name": "sha256", "checksum": "d9d2c797890433a008522c3960e8f88f3aa433d18feb0f3187f61b35388c8634"}, "config": {"enabled": true, "alias": "chronic_conditions_none", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "chronic_conditions_none", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.9955306, "relation_name": "dev_thuxuan.data_quality.chronic_conditions_none", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith chronic_conditions as \r\n(\r\n select distinct patient_id \r\n from {{ ref('chronic_conditions__cms_chronic_conditions_long') }}\r\n)\r\n\r\n,results as (\r\n select \r\n cast('Percent of patients without chronic conditions' as {{dbt.type_string()}}) as data_quality_check\r\n , sum(case when cccw.patient_id is null then 1 else 0 end) / count(distinct e.patient_id) * 100 as result_count\r\n from {{ ref('core__patient') }} e\r\n left join chronic_conditions cccw \r\n on e.patient_id = cccw.patient_id\r\n)\r\n\r\nselect\r\n results.data_quality_check\r\n , results.result_count\r\n , ref_data.analytics_value as medicare_lds_reference\r\n , 0 as normally_zero \r\n , cast('{{ var('tuva_last_run') }}' as {{dbt.type_string()}}) as tuva_last_run\r\n \r\nfrom results\r\nleft join {{ ref('data_quality__reference_mart_analytics') }} as ref_data \r\n on results.data_quality_check = ref_data.analytics_measure", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}, {"name": "core__patient", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.core__patient", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__chronic_conditions_none.sql", "compiled": true, "compiled_code": "\n\nwith chronic_conditions as \n(\n select distinct patient_id \n from dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\n)\n\n,results as (\n select \n cast('Percent of patients without chronic conditions' as TEXT) as data_quality_check\n , sum(case when cccw.patient_id is null then 1 else 0 end) / count(distinct e.patient_id) * 100 as result_count\n from dev_thuxuan.core.patient e\n left join chronic_conditions cccw \n on e.patient_id = cccw.patient_id\n)\n\nselect\n results.data_quality_check\n , results.result_count\n , ref_data.analytics_value as medicare_lds_reference\n , 0 as normally_zero \n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT) as tuva_last_run\n \nfrom results\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics as ref_data \n on results.data_quality_check = ref_data.analytics_measure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__chronic_conditions_prevalence": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__chronic_conditions_prevalence", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__chronic_conditions_prevalence.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__chronic_conditions_prevalence.sql", "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__chronic_conditions_prevalence"], "alias": "chronic_conditions_prevalence", "checksum": {"name": "sha256", "checksum": "5219f29e044cebad1eefa48b56d7c1c1899380a7d9710d7e7cd49b5254a0a82b"}, "config": {"enabled": true, "alias": "chronic_conditions_prevalence", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "chronic_conditions_prevalence", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866316.9925306, "relation_name": "dev_thuxuan.data_quality.chronic_conditions_prevalence", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith condition_counts as (\r\n select\r\n condition\r\n , count(distinct patient_id) as patients\r\n from {{ ref('chronic_conditions__tuva_chronic_conditions_long') }}\r\n group by condition\r\n)\r\n, total_patients as (\r\n select \r\n count(distinct patient_id) as total_distinct_patients\r\n from {{ ref('core__eligibility') }}\r\n)\r\n\r\n, results_first as (\r\nselect\r\n conditions.condition\r\n , conditions.patients\r\n , CASE \r\n WHEN total_patients.total_distinct_patients = 0 THEN NULL\r\n ELSE (conditions.patients / total_patients.total_distinct_patients) * 100 \r\n END as percent_of_total\r\n\r\nfrom condition_counts as conditions\r\ncross join total_patients\r\n)\r\n\r\n,results_second as (\r\n select \r\n condition\r\n , patients\r\n , percent_of_total\r\n , ROW_NUMBER() OVER (ORDER BY percent_of_total desc) AS condition_rank\r\n from results_first\r\n)\r\n\r\n\r\nselect\r\n ref_data.analytics_concept\r\n , coalesce(results.condition, ref_data.analytics_measure) as analytics_measure\r\n , results.patients\r\n , results.condition_rank as value_rank\r\n , results.percent_of_total as data_source_value\r\n , ref_data.analytics_value\r\n , ref_data.value_rank as medicare_lds_condition_rank\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} ref_data\r\nleft join results_second as results on results.condition = ref_data.analytics_measure\r\nwhere ref_data.analytics_concept = 'chronic conditions top 10'", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}, {"name": "core__eligibility", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__eligibility", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__chronic_conditions_prevalence.sql", "compiled": true, "compiled_code": "\n\nwith condition_counts as (\n select\n condition\n , count(distinct patient_id) as patients\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n group by condition\n)\n, total_patients as (\n select \n count(distinct patient_id) as total_distinct_patients\n from dev_thuxuan.core.eligibility\n)\n\n, results_first as (\nselect\n conditions.condition\n , conditions.patients\n , CASE \n WHEN total_patients.total_distinct_patients = 0 THEN NULL\n ELSE (conditions.patients / total_patients.total_distinct_patients) * 100 \n END as percent_of_total\n\nfrom condition_counts as conditions\ncross join total_patients\n)\n\n,results_second as (\n select \n condition\n , patients\n , percent_of_total\n , ROW_NUMBER() OVER (ORDER BY percent_of_total desc) AS condition_rank\n from results_first\n)\n\n\nselect\n ref_data.analytics_concept\n , coalesce(results.condition, ref_data.analytics_measure) as analytics_measure\n , results.patients\n , results.condition_rank as value_rank\n , results.percent_of_total as data_source_value\n , ref_data.analytics_value\n , ref_data.value_rank as medicare_lds_condition_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data\nleft join results_second as results on results.condition = ref_data.analytics_measure\nwhere ref_data.analytics_concept = 'chronic conditions top 10'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__claim_percent": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__claim_percent", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__claim_percent.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__claim_percent.sql", "unique_id": "model.the_tuva_project.data_quality__claim_percent", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__claim_percent"], "alias": "data_quality_claim_percent", "checksum": {"name": "sha256", "checksum": "57ce0042608856a4b4922adba688388c45c1ed70ca2b883cad6ea97f3d23066b"}, "config": {"enabled": true, "alias": "data_quality_claim_percent", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_claim_percent", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1010528, "relation_name": "dev_thuxuan.data_quality.data_quality_claim_percent", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\r\n) }}\r\n\r\n\r\nwith cte as \r\n(\r\nselect sum(paid_amount) as paid_amount\r\n,claim_type\r\nfrom {{ ref('medical_claim') }}\r\ngroup by claim_type\r\n\r\nunion all\r\n\r\nselect sum(paid_amount) as paid_amount\r\n,'pharmacy' as claim_type\r\nfrom {{ ref('pharmacy_claim') }}\r\n)\r\n\r\n,total_cte as \r\n(\r\nselect sum(paid_amount) as total_paid_amount\r\nfrom cte\r\n)\r\n\r\nselect claim_type\r\n,paid_amount/total_paid_amount as percent_of_total_paid\r\nfrom cte\r\ncross join total_cte", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__claim_percent.sql", "compiled": true, "compiled_code": "\n\n\nwith cte as \n(\nselect sum(paid_amount) as paid_amount\n,claim_type\nfrom tuva.input_layer.medical_claim\ngroup by claim_type\n\nunion all\n\nselect sum(paid_amount) as paid_amount\n,'pharmacy' as claim_type\nfrom tuva.input_layer.pharmacy_claim\n)\n\n,total_cte as \n(\nselect sum(paid_amount) as total_paid_amount\nfrom cte\n)\n\nselect claim_type\n,paid_amount/total_paid_amount as percent_of_total_paid\nfrom cte\ncross join total_cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__cms_hcc": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__cms_hcc", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__cms_hcc.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__cms_hcc.sql", "unique_id": "model.the_tuva_project.data_quality__cms_hcc", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__cms_hcc"], "alias": "data_quality_cms_hcc", "checksum": {"name": "sha256", "checksum": "8be2cc8f750a88e36c5ecf039df9830572d5b27d01231c1dae81993d3ab547d4"}, "config": {"enabled": true, "alias": "data_quality_cms_hcc", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_cms_hcc", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0790515, "relation_name": "dev_thuxuan.data_quality.data_quality_cms_hcc", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\nselect max(case when factor_type = 'Demographic' then 1 else 0 end) demographic_factor\r\n,max(case when factor_type = 'Disease' then 1 else 0 end) as disease_factor\r\nfrom {{ ref('cms_hcc__patient_risk_factors') }}\r\n)\r\n\r\nselect 'missing cms-hcc demographic factor' as data_quality_check\r\n,case when demographic_factor = 0 then 1 else 0 end as result_count\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom cte \r\n\r\nunion all\r\n\r\nselect 'missing cms-hcc disease factor' as data_quality_check\r\n,case when disease_factor = 0 then 1 else 0 end as result_count\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom cte", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__cms_hcc.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect max(case when factor_type = 'Demographic' then 1 else 0 end) demographic_factor\n,max(case when factor_type = 'Disease' then 1 else 0 end) as disease_factor\nfrom dev_thuxuan.cms_hcc.patient_risk_factors\n)\n\nselect 'missing cms-hcc demographic factor' as data_quality_check\n,case when demographic_factor = 0 then 1 else 0 end as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte \n\nunion all\n\nselect 'missing cms-hcc disease factor' as data_quality_check\n,case when disease_factor = 0 then 1 else 0 end as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__cms_hcc_reference": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__cms_hcc_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__cms_hcc_reference.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__cms_hcc_reference.sql", "unique_id": "model.the_tuva_project.data_quality__cms_hcc_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__cms_hcc_reference"], "alias": "data_quality_cms_hcc_reference", "checksum": {"name": "sha256", "checksum": "f061a12552f9178f58058507810154661640f63632aaea1902a2edf65db74dc9"}, "config": {"enabled": true, "alias": "data_quality_cms_hcc_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_cms_hcc_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0810478, "relation_name": "dev_thuxuan.data_quality.data_quality_cms_hcc_reference", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\nselect avg(normalized_risk_score) data_source_value\r\n,cast('normalized risk score' as {{ dbt.type_string() }}) as analytics_measure\r\n,cast('cms-hcc' as {{ dbt.type_string() }}) as analytics_concept\r\nfrom {{ ref('cms_hcc__patient_risk_scores') }}\r\n)\r\n\r\nselect \r\n m.analytics_concept as analytics_concept\r\n,m.analytics_measure as analytics_measure\r\n,cte.data_source_value\r\n,m.analytics_value\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join cte on cte.analytics_measure = m.analytics_measure\r\nand\r\nm.analytics_concept = cte.analytics_concept\r\nwhere m.analytics_concept = 'cms-hcc'\r\nand\r\nm.analytics_measure = 'normalized risk score'", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_scores", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__cms_hcc_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(normalized_risk_score) data_source_value\n,cast('normalized risk score' as TEXT) as analytics_measure\n,cast('cms-hcc' as TEXT) as analytics_concept\nfrom dev_thuxuan.cms_hcc.patient_risk_scores\n)\n\nselect \n m.analytics_concept as analytics_concept\n,m.analytics_measure as analytics_measure\n,cte.data_source_value\n,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = 'cms-hcc'\nand\nm.analytics_measure = 'normalized risk score'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__dx_and_px": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__dx_and_px", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__dx_and_px.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__dx_and_px.sql", "unique_id": "model.the_tuva_project.data_quality__dx_and_px", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__dx_and_px"], "alias": "dx_and_px", "checksum": {"name": "sha256", "checksum": "ac135ce07c58762376df5b0859f445903419249aa1cc39b1fb5a82cd0f63d04c"}, "config": {"enabled": true, "alias": "dx_and_px", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of rows in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "dx_and_px", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.002531, "relation_name": "dev_thuxuan.data_quality.dx_and_px", "raw_code": "{{ config(\r\n enabled = var('data_quality_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith unpivot_diagnosis as(\r\n {{ dbt_utils.unpivot(\r\n relation=ref('medical_claim'),\r\n cast_to=type_string(),\r\n exclude=['claim_id', 'diagnosis_code_type'],\r\n field_name='diagnosis_column',\r\n value_name='diagnosis_code',\r\n remove=[ 'claim_line_number'\r\n , 'claim_type'\r\n , 'patient_id'\r\n , 'member_id'\r\n , 'payer'\r\n , 'plan'\r\n , 'claim_start_date'\r\n , 'claim_end_date'\r\n , 'claim_line_start_date'\r\n , 'claim_line_end_date'\r\n , 'admission_date'\r\n , 'discharge_date'\r\n , 'admit_source_code'\r\n , 'admit_type_code'\r\n , 'discharge_disposition_code'\r\n , 'place_of_service_code'\r\n , 'bill_type_code'\r\n , 'ms_drg_code'\r\n , 'apr_drg_code'\r\n , 'revenue_center_code'\r\n , 'service_unit_quantity'\r\n , 'hcpcs_code'\r\n , 'hcpcs_modifier_1'\r\n , 'hcpcs_modifier_2'\r\n , 'hcpcs_modifier_3'\r\n , 'hcpcs_modifier_4'\r\n , 'hcpcs_modifier_5'\r\n , 'rendering_npi'\r\n , 'rendering_tin'\r\n , 'billing_npi'\r\n , 'billing_tin'\r\n , 'facility_npi'\r\n , 'paid_date'\r\n , 'paid_amount'\r\n , 'allowed_amount'\r\n , 'charge_amount'\r\n , 'coinsurance_amount'\r\n , 'copayment_amount'\r\n , 'deductible_amount'\r\n , 'total_cost_amount'\r\n , 'diagnosis_poa_1'\r\n , 'diagnosis_poa_2'\r\n , 'diagnosis_poa_3'\r\n , 'diagnosis_poa_4'\r\n , 'diagnosis_poa_5'\r\n , 'diagnosis_poa_6'\r\n , 'diagnosis_poa_7'\r\n , 'diagnosis_poa_8'\r\n , 'diagnosis_poa_9'\r\n , 'diagnosis_poa_10'\r\n , 'diagnosis_poa_11'\r\n , 'diagnosis_poa_12'\r\n , 'diagnosis_poa_13'\r\n , 'diagnosis_poa_14'\r\n , 'diagnosis_poa_15'\r\n , 'diagnosis_poa_16'\r\n , 'diagnosis_poa_17'\r\n , 'diagnosis_poa_18'\r\n , 'diagnosis_poa_19'\r\n , 'diagnosis_poa_20'\r\n , 'diagnosis_poa_21'\r\n , 'diagnosis_poa_22'\r\n , 'diagnosis_poa_23'\r\n , 'diagnosis_poa_24'\r\n , 'diagnosis_poa_25'\r\n , 'procedure_code_type'\r\n , 'procedure_code_1'\r\n , 'procedure_code_2'\r\n , 'procedure_code_3'\r\n , 'procedure_code_4'\r\n , 'procedure_code_5'\r\n , 'procedure_code_6'\r\n , 'procedure_code_7'\r\n , 'procedure_code_8'\r\n , 'procedure_code_9'\r\n , 'procedure_code_10'\r\n , 'procedure_code_11'\r\n , 'procedure_code_12'\r\n , 'procedure_code_13'\r\n , 'procedure_code_14'\r\n , 'procedure_code_15'\r\n , 'procedure_code_16'\r\n , 'procedure_code_17'\r\n , 'procedure_code_18'\r\n , 'procedure_code_19'\r\n , 'procedure_code_20'\r\n , 'procedure_code_21'\r\n , 'procedure_code_22'\r\n , 'procedure_code_23'\r\n , 'procedure_code_24'\r\n , 'procedure_code_25'\r\n , 'procedure_date_1'\r\n , 'procedure_date_2'\r\n , 'procedure_date_3'\r\n , 'procedure_date_4'\r\n , 'procedure_date_5'\r\n , 'procedure_date_6'\r\n , 'procedure_date_7'\r\n , 'procedure_date_8'\r\n , 'procedure_date_9'\r\n , 'procedure_date_10'\r\n , 'procedure_date_11'\r\n , 'procedure_date_12'\r\n , 'procedure_date_13'\r\n , 'procedure_date_14'\r\n , 'procedure_date_15'\r\n , 'procedure_date_16'\r\n , 'procedure_date_17'\r\n , 'procedure_date_18'\r\n , 'procedure_date_19'\r\n , 'procedure_date_20'\r\n , 'procedure_date_21'\r\n , 'procedure_date_22'\r\n , 'procedure_date_23'\r\n , 'procedure_date_24'\r\n , 'procedure_date_25'\r\n , 'in_network_flag'\r\n , 'data_source'\r\n , 'file_name'\r\n , 'ingest_datetime']\r\n ) }}\r\n)\r\n, unpivot_procedure as(\r\n {{ dbt_utils.unpivot(\r\n relation=ref('medical_claim'),\r\n cast_to=type_string(),\r\n exclude=['claim_id', 'procedure_code_type'],\r\n field_name='procedure_column',\r\n value_name='procedure_code',\r\n remove=[ 'claim_line_number'\r\n , 'claim_type'\r\n , 'patient_id'\r\n , 'member_id'\r\n , 'payer'\r\n , 'plan'\r\n , 'claim_start_date'\r\n , 'claim_end_date'\r\n , 'claim_line_start_date'\r\n , 'claim_line_end_date'\r\n , 'admission_date'\r\n , 'discharge_date'\r\n , 'admit_source_code'\r\n , 'admit_type_code'\r\n , 'discharge_disposition_code'\r\n , 'place_of_service_code'\r\n , 'bill_type_code'\r\n , 'ms_drg_code'\r\n , 'apr_drg_code'\r\n , 'revenue_center_code'\r\n , 'service_unit_quantity'\r\n , 'hcpcs_code'\r\n , 'hcpcs_modifier_1'\r\n , 'hcpcs_modifier_2'\r\n , 'hcpcs_modifier_3'\r\n , 'hcpcs_modifier_4'\r\n , 'hcpcs_modifier_5'\r\n , 'rendering_npi'\r\n , 'rendering_tin'\r\n , 'billing_npi'\r\n , 'billing_tin'\r\n , 'facility_npi'\r\n , 'paid_date'\r\n , 'paid_amount'\r\n , 'allowed_amount'\r\n , 'charge_amount'\r\n , 'coinsurance_amount'\r\n , 'copayment_amount'\r\n , 'deductible_amount'\r\n , 'total_cost_amount'\r\n , 'diagnosis_code_type'\r\n , 'diagnosis_code_1'\r\n , 'diagnosis_code_2'\r\n , 'diagnosis_code_3'\r\n , 'diagnosis_code_4'\r\n , 'diagnosis_code_5'\r\n , 'diagnosis_code_6'\r\n , 'diagnosis_code_7'\r\n , 'diagnosis_code_8'\r\n , 'diagnosis_code_9'\r\n , 'diagnosis_code_10'\r\n , 'diagnosis_code_11'\r\n , 'diagnosis_code_12'\r\n , 'diagnosis_code_13'\r\n , 'diagnosis_code_14'\r\n , 'diagnosis_code_15'\r\n , 'diagnosis_code_16'\r\n , 'diagnosis_code_17'\r\n , 'diagnosis_code_18'\r\n , 'diagnosis_code_19'\r\n , 'diagnosis_code_20'\r\n , 'diagnosis_code_21'\r\n , 'diagnosis_code_22'\r\n , 'diagnosis_code_23'\r\n , 'diagnosis_code_24'\r\n , 'diagnosis_code_25'\r\n , 'diagnosis_poa_1'\r\n , 'diagnosis_poa_2'\r\n , 'diagnosis_poa_3'\r\n , 'diagnosis_poa_4'\r\n , 'diagnosis_poa_5'\r\n , 'diagnosis_poa_6'\r\n , 'diagnosis_poa_7'\r\n , 'diagnosis_poa_8'\r\n , 'diagnosis_poa_9'\r\n , 'diagnosis_poa_10'\r\n , 'diagnosis_poa_11'\r\n , 'diagnosis_poa_12'\r\n , 'diagnosis_poa_13'\r\n , 'diagnosis_poa_14'\r\n , 'diagnosis_poa_15'\r\n , 'diagnosis_poa_16'\r\n , 'diagnosis_poa_17'\r\n , 'diagnosis_poa_18'\r\n , 'diagnosis_poa_19'\r\n , 'diagnosis_poa_20'\r\n , 'diagnosis_poa_21'\r\n , 'diagnosis_poa_22'\r\n , 'diagnosis_poa_23'\r\n , 'diagnosis_poa_24'\r\n , 'diagnosis_poa_25'\r\n , 'procedure_date_1'\r\n , 'procedure_date_2'\r\n , 'procedure_date_3'\r\n , 'procedure_date_4'\r\n , 'procedure_date_5'\r\n , 'procedure_date_6'\r\n , 'procedure_date_7'\r\n , 'procedure_date_8'\r\n , 'procedure_date_9'\r\n , 'procedure_date_10'\r\n , 'procedure_date_11'\r\n , 'procedure_date_12'\r\n , 'procedure_date_13'\r\n , 'procedure_date_14'\r\n , 'procedure_date_15'\r\n , 'procedure_date_16'\r\n , 'procedure_date_17'\r\n , 'procedure_date_18'\r\n , 'procedure_date_19'\r\n , 'procedure_date_20'\r\n , 'procedure_date_21'\r\n , 'procedure_date_22'\r\n , 'procedure_date_23'\r\n , 'procedure_date_24'\r\n , 'procedure_date_25'\r\n , 'in_network_flag'\r\n , 'data_source'\r\n , 'file_name'\r\n , 'ingest_datetime'\r\n ]\r\n ) }}\r\n\r\n\r\n)\r\n\r\n, total_claims as(\r\n select\r\n cast(count(distinct claim_id) as integer ) as total_claims\r\n from {{ ref('medical_claim') }}\r\n)\r\n\r\n, claims_with_primary_dx as(\r\n select\r\n count(diagnosis_code_1) as distinct_claims_with_primary\r\n from {{ ref('medical_claim') }}\r\n)\r\n\r\n, secondary_dx_prep_cte as ( \r\n select\r\n tc.total_claims\r\n , cast(count(distinct claim_id) as integer) as secondary_dx_claim_count\r\n from unpivot_diagnosis\r\n cross join total_claims tc\r\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\r\n and\r\n cast(diagnosis_code as {{ dbt.type_string() }} ) is not null\r\n group by total_claims\r\n ) \r\n\r\n, claims_with_secondary_dx as (\r\n select\r\n total_claims\r\n , cast(secondary_dx_claim_count as integer ) as secondary_dx_claim_count\r\n , (cast(secondary_dx_claim_count as integer ) / cast(total_claims as integer )) * 100 as result_count\r\n , cast('Percent of claims with secondary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\r\n from\r\n secondary_dx_prep_cte\r\n\r\n)\r\n, missing_primary_dx as (\r\n select\r\n cast('missing primary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\r\n , cast(count(distinct claim_id) as integer ) as result_count\r\n from {{ ref('medical_claim') }} m\r\n where diagnosis_code_1 is null\r\n)\r\n, invalid_primary_dx as(\r\n select\r\n data_quality_check\r\n , count(distinct claim_id) as result_count\r\n from (\r\n select\r\n cast('invalid primary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\r\n , claim_id\r\n , diagnosis_code_type\r\n , diagnosis_column\r\n , diagnosis_code\r\n , icd_10_cm\r\n , icd_9_cm\r\n , case\r\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\r\n then 1\r\n else 0\r\n end as invalid_diagnosis\r\n from unpivot_diagnosis dx\r\n left join {{ ref('terminology__icd_10_cm') }} icd10\r\n on dx.diagnosis_code = icd10.icd_10_cm\r\n left join {{ ref('terminology__icd_9_cm') }} icd9\r\n on dx.diagnosis_code = icd9.icd_9_cm\r\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\r\n and diagnosis_code is not null\r\n )x\r\n where invalid_diagnosis = 1\r\n group by\r\n data_quality_check\r\n)\r\n, multiple_primary_dx as(\r\n\r\n select\r\n cast('multiple primary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\r\n , cast(count(*) as integer ) as result_count\r\n from\r\n (\r\n select\r\n claim_id\r\n , row_number() over (partition by claim_id order by claim_id) as row_nbr\r\n from unpivot_diagnosis\r\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\r\n group by\r\n claim_id\r\n )x\r\n where row_nbr > 1\r\n\r\n)\r\n, invalid_secondary_dx as(\r\n select\r\n data_quality_check\r\n , count(*) as result_count\r\n from (\r\n select\r\n cast('invalid secondary diagnosis' as {{ dbt.type_string() }}) as data_quality_check\r\n , claim_id\r\n , case\r\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\r\n then 1\r\n else 0\r\n end as invalid_diagnosis\r\n from unpivot_diagnosis dx\r\n left join {{ ref('terminology__icd_10_cm') }} icd10\r\n on dx.diagnosis_code = icd10.icd_10_cm\r\n left join {{ ref('terminology__icd_9_cm') }} icd9\r\n on dx.diagnosis_code = icd9.icd_9_cm\r\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\r\n and diagnosis_code is not null\r\n )x\r\n where invalid_diagnosis = 1\r\n group by\r\n data_quality_check\r\n)\r\n\r\n, invalid_procedure as(\r\n select\r\n data_quality_check\r\n , count(*) as result_count\r\n from (\r\n select\r\n cast('invalid procedure' as {{ dbt.type_string() }}) as data_quality_check\r\n , claim_id\r\n , case\r\n when icd10.icd_10_pcs is null and icd9.icd_9_pcs is null\r\n then 1\r\n else 0\r\n end as invalid_procedure\r\n from unpivot_procedure px\r\n left join {{ ref('terminology__icd_10_pcs') }} icd10\r\n on px.procedure_code = icd10.icd_10_pcs\r\n left join {{ ref('terminology__icd_9_pcs') }} icd9\r\n on px.procedure_code = icd9.icd_9_pcs\r\n where px.procedure_code is not null\r\n )x\r\n where invalid_procedure = 1\r\n group by\r\n data_quality_check\r\n)\r\n\r\n, final as (\r\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\r\n ,result_count\r\n from missing_primary_dx\r\n\r\n union all\r\n\r\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\r\n ,result_count\r\n from invalid_primary_dx\r\n\r\n union all\r\n\r\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\r\n ,result_count\r\n from multiple_primary_dx\r\n\r\n union all\r\n\r\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\r\n ,result_count\r\n from invalid_secondary_dx\r\n\r\n union all\r\n\r\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\r\n ,result_count\r\n from claims_with_secondary_dx\r\n\r\n union all\r\n\r\n select cast(data_quality_check as {{ dbt.type_string() }} ) as data_quality_check\r\n ,result_count\r\n from invalid_procedure\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "terminology__icd_9_cm", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "terminology__icd_9_pcs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt_utils.unpivot"], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__dx_and_px.sql", "compiled": true, "compiled_code": "\n\nwith unpivot_diagnosis as(\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_1' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_1\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_2' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_2\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_3' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_3\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_4' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_4\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_5' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_5\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_6' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_6\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_7' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_7\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_8' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_8\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_9' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_9\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_10' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_10\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_11' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_11\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_12' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_12\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_13' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_13\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_14' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_14\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_15' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_15\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_16' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_16\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_17' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_17\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_18' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_18\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_19' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_19\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_20' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_20\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_21' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_21\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_22' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_22\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_23' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_23\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_24' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_24\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_25' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_25\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n \n)\n, unpivot_procedure as(\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_1' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_1\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_2' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_2\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_3' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_3\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_4' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_4\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_5' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_5\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_6' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_6\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_7' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_7\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_8' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_8\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_9' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_9\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_10' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_10\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_11' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_11\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_12' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_12\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_13' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_13\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_14' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_14\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_15' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_15\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_16' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_16\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_17' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_17\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_18' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_18\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_19' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_19\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_20' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_20\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_21' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_21\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_22' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_22\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_23' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_23\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_24' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_24\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_25' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_25\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n \n\n\n)\n\n, total_claims as(\n select\n cast(count(distinct claim_id) as integer ) as total_claims\n from tuva.input_layer.medical_claim\n)\n\n, claims_with_primary_dx as(\n select\n count(diagnosis_code_1) as distinct_claims_with_primary\n from tuva.input_layer.medical_claim\n)\n\n, secondary_dx_prep_cte as ( \n select\n tc.total_claims\n , cast(count(distinct claim_id) as integer) as secondary_dx_claim_count\n from unpivot_diagnosis\n cross join total_claims tc\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and\n cast(diagnosis_code as TEXT ) is not null\n group by total_claims\n ) \n\n, claims_with_secondary_dx as (\n select\n total_claims\n , cast(secondary_dx_claim_count as integer ) as secondary_dx_claim_count\n , (cast(secondary_dx_claim_count as integer ) / cast(total_claims as integer )) * 100 as result_count\n , cast('Percent of claims with secondary diagnosis' as TEXT) as data_quality_check\n from\n secondary_dx_prep_cte\n\n)\n, missing_primary_dx as (\n select\n cast('missing primary diagnosis' as TEXT) as data_quality_check\n , cast(count(distinct claim_id) as integer ) as result_count\n from tuva.input_layer.medical_claim m\n where diagnosis_code_1 is null\n)\n, invalid_primary_dx as(\n select\n data_quality_check\n , count(distinct claim_id) as result_count\n from (\n select\n cast('invalid primary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , diagnosis_code_type\n , diagnosis_column\n , diagnosis_code\n , icd_10_cm\n , icd_9_cm\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join dev_thuxuan.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join dev_thuxuan.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n, multiple_primary_dx as(\n\n select\n cast('multiple primary diagnosis' as TEXT) as data_quality_check\n , cast(count(*) as integer ) as result_count\n from\n (\n select\n claim_id\n , row_number() over (partition by claim_id order by claim_id) as row_nbr\n from unpivot_diagnosis\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n group by\n claim_id\n )x\n where row_nbr > 1\n\n)\n, invalid_secondary_dx as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid secondary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join dev_thuxuan.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join dev_thuxuan.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n\n, invalid_procedure as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid procedure' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_pcs is null and icd9.icd_9_pcs is null\n then 1\n else 0\n end as invalid_procedure\n from unpivot_procedure px\n left join dev_thuxuan.terminology.icd_10_pcs icd10\n on px.procedure_code = icd10.icd_10_pcs\n left join dev_thuxuan.terminology.icd_9_pcs icd9\n on px.procedure_code = icd9.icd_9_pcs\n where px.procedure_code is not null\n )x\n where invalid_procedure = 1\n group by\n data_quality_check\n)\n\n, final as (\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from missing_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from multiple_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from claims_with_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_procedure\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__ed_classification": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__ed_classification", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__ed_classification.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__ed_classification.sql", "unique_id": "model.the_tuva_project.data_quality__ed_classification", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__ed_classification"], "alias": "data_quality_ed_classification", "checksum": {"name": "sha256", "checksum": "c17095c583327e0576622dd03f9536235664b3f2525adc5f4acee185fe7ab525"}, "config": {"enabled": true, "alias": "data_quality_ed_classification", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_ed_classification", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0940526, "relation_name": "dev_thuxuan.data_quality.data_quality_ed_classification", "raw_code": "{{ config(\r\n enabled = var('data_quality_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith cte as (\r\n select \r\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_preventable,\r\n max(case when ed_classification_description = 'Emergent, Primary Care Treatable' then 1 else 0 end) as pc_treatable,\r\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Not Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_not_preventable,\r\n max(case when ed_classification_description = 'Non-Emergent' then 1 else 0 end) as non_emergent\r\n from {{ ref('ed_classification__summary') }}\r\n)\r\n\r\n,final as (\r\nselect 'ed classification missing ed_care_needed_preventable' as data_quality_check,\r\n case when ed_care_needed_preventable = 0 then 1 else 0 end as result_count\r\nfrom cte\r\n\r\nunion all\r\n\r\nselect 'ed classification missing pc_treatable' as data_quality_check,\r\n case when pc_treatable = 0 then 1 else 0 end as result_count\r\nfrom cte\r\n\r\nunion all\r\n\r\nselect 'ed classification missing ed_care_needed_not_preventable' as data_quality_check,\r\n case when ed_care_needed_not_preventable = 0 then 1 else 0 end as result_count\r\nfrom cte\r\n\r\nunion all\r\n\r\nselect 'ed classification missing non_emergent' as data_quality_check,\r\n case when non_emergent = 0 then 1 else 0 end as result_count\r\nfrom cte\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "ed_classification__summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ed_classification__summary"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__ed_classification.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n max(case when ed_classification_description = 'Emergent, ED Care Needed, Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_preventable,\n max(case when ed_classification_description = 'Emergent, Primary Care Treatable' then 1 else 0 end) as pc_treatable,\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Not Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_not_preventable,\n max(case when ed_classification_description = 'Non-Emergent' then 1 else 0 end) as non_emergent\n from dev_thuxuan.ed_classification.summary\n)\n\n,final as (\nselect 'ed classification missing ed_care_needed_preventable' as data_quality_check,\n case when ed_care_needed_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing pc_treatable' as data_quality_check,\n case when pc_treatable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing ed_care_needed_not_preventable' as data_quality_check,\n case when ed_care_needed_not_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing non_emergent' as data_quality_check,\n case when non_emergent = 0 then 1 else 0 end as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__ed_classification_reference": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__ed_classification_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__ed_classification_reference.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__ed_classification_reference.sql", "unique_id": "model.the_tuva_project.data_quality__ed_classification_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__ed_classification_reference"], "alias": "data_quality_ed_classification_reference", "checksum": {"name": "sha256", "checksum": "a1c7f569e5aad498430ed8c3f57aa7384200d4ae2b7846b4b0a6d04d6b0d617c"}, "config": {"enabled": true, "alias": "data_quality_ed_classification_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_ed_classification_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0960524, "relation_name": "dev_thuxuan.data_quality.data_quality_ed_classification_reference", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith total_cte as \r\n(\r\nselect count(*) as total_encounters\r\nfrom {{ ref('core__encounter') }}\r\nwhere encounter_type = cast('emergency department' as {{dbt.type_string()}})\r\n) \r\n\r\n,final as (\r\nselect coalesce(cast(ed_classification_description as {{dbt.type_string()}}), cast('Not Classified' as {{dbt.type_string()}})) as ed_classification_description\r\n,count(*) as encounters\r\n,total_cte.total_encounters\r\n,count(*)/total_cte.total_encounters as percent_of_total\r\n,row_number() over (order by count(*) desc) as value_rank\r\nfrom {{ ref('core__encounter') }} e\r\ncross join total_cte\r\nleft join {{ ref('ed_classification__summary') }} s on e.encounter_id = s.encounter_id \r\nwhere encounter_type = cast('emergency department' as {{dbt.type_string()}})\r\ngroup by coalesce(cast(ed_classification_description as {{dbt.type_string()}}), cast('Not Classified' as {{dbt.type_string()}}))\r\n,total_cte.total_encounters\r\n)\r\n\r\n,actually_final as (\r\nselect cast('ed classification' as {{dbt.type_string()}}) as analytics_concept\r\n,ed_classification_description as analytics_measure\r\n,percent_of_total as data_source_value\r\n,value_rank as value_rank\r\nfrom final\r\n)\r\n\r\nselect m.analytics_concept\r\n,m.analytics_measure\r\n,data_source_value\r\n,m.analytics_value\r\n,m.value_rank\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join actually_final on actually_final.analytics_measure = m.analytics_measure\r\nand\r\nm.analytics_concept = actually_final.analytics_concept\r\nwhere m.analytics_concept = cast('ed classification' as {{dbt.type_string()}})", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "ed_classification__summary", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.ed_classification__summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__ed_classification_reference.sql", "compiled": true, "compiled_code": "\n\nwith total_cte as \n(\nselect count(*) as total_encounters\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = cast('emergency department' as TEXT)\n) \n\n,final as (\nselect coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT)) as ed_classification_description\n,count(*) as encounters\n,total_cte.total_encounters\n,count(*)/total_cte.total_encounters as percent_of_total\n,row_number() over (order by count(*) desc) as value_rank\nfrom dev_thuxuan.core.encounter e\ncross join total_cte\nleft join dev_thuxuan.ed_classification.summary s on e.encounter_id = s.encounter_id \nwhere encounter_type = cast('emergency department' as TEXT)\ngroup by coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT))\n,total_cte.total_encounters\n)\n\n,actually_final as (\nselect cast('ed classification' as TEXT) as analytics_concept\n,ed_classification_description as analytics_measure\n,percent_of_total as data_source_value\n,value_rank as value_rank\nfrom final\n)\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n,m.value_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join actually_final on actually_final.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = actually_final.analytics_concept\nwhere m.analytics_concept = cast('ed classification' as TEXT)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_date_checks": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_date_checks", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__eligibility_date_checks.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__eligibility_date_checks.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_date_checks", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_date_checks"], "alias": "eligibility_date_checks", "checksum": {"name": "sha256", "checksum": "dff485cbebb05d1e075be62b5b7bb884f13f8517d4f21690c945e776a7138851"}, "config": {"enabled": true, "alias": "eligibility_date_checks", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_date_checks", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0045311, "relation_name": "dev_thuxuan.data_quality.eligibility_date_checks", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith eligibility_spans as(\r\n select distinct\r\n {{ dbt.concat([\r\n \"member_id\",\r\n \"'-'\",\r\n \"enrollment_start_date\",\r\n \"'-'\",\r\n \"enrollment_end_date\",\r\n \"'-'\",\r\n \"payer\",\r\n \"'-'\",\r\n quote_column('plan'),\r\n ]) }} as eligibility_span_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n from {{ ref('eligibility') }}\r\n)\r\n\r\n, missing_start_date as (\r\n select\r\n 'Missing enrollment_start_date' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n where enrollment_start_date is null\r\n),\r\n\r\nmissing_end_date as (\r\n select\r\n 'Missing enrollment_end_date' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n where enrollment_end_date is null\r\n),\r\n\r\ninvalid_start_date as (\r\n select\r\n 'Enrollment_start_date populated with something other than a date' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n where enrollment_start_date is not null\r\n and not {{ try_to_cast_date('enrollment_start_date') }} is not null\r\n),\r\n\r\ninvalid_end_date as (\r\n select\r\n 'Enrollment_end_date populated with something other than a date' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n where enrollment_end_date is not null\r\n and not {{ try_to_cast_date('enrollment_end_date') }} is not null\r\n),\r\n\r\nstart_after_end as (\r\n select\r\n 'Enrollment_start_date after enrollment_end_date' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n where enrollment_start_date > enrollment_end_date\r\n),\r\n\r\nfuture_end_date as (\r\n select\r\n 'Future enrollment_end_date' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n {% if target.type == 'fabric' %}\r\n where enrollment_end_date > GETDATE()\r\n {% else %}\r\n where enrollment_end_date > current_date\r\n {% endif %}\r\n\r\n),\r\n\r\nnonsensical_dates as (\r\n select\r\n 'Nonsensical dates' as data_quality_check,\r\n count(*) as result_count\r\n from eligibility_spans\r\n where enrollment_start_date < '1900-01-01'\r\n or enrollment_end_date < '1900-01-01'\r\n or enrollment_start_date > '2100-01-01'\r\n)\r\n\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_start_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_end_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_start_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_end_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from start_after_end\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from future_end_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from nonsensical_dates", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.the_tuva_project.try_to_cast_date"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__eligibility_date_checks.sql", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n\n, missing_start_date as (\n select\n 'Missing enrollment_start_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is null\n),\n\nmissing_end_date as (\n select\n 'Missing enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is null\n),\n\ninvalid_start_date as (\n select\n 'Enrollment_start_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is not null\n and not try_cast( enrollment_start_date as date ) is not null\n),\n\ninvalid_end_date as (\n select\n 'Enrollment_end_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is not null\n and not try_cast( enrollment_end_date as date ) is not null\n),\n\nstart_after_end as (\n select\n 'Enrollment_start_date after enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date > enrollment_end_date\n),\n\nfuture_end_date as (\n select\n 'Future enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n \n where enrollment_end_date > current_date\n \n\n),\n\nnonsensical_dates as (\n select\n 'Nonsensical dates' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date < '1900-01-01'\n or enrollment_end_date < '1900-01-01'\n or enrollment_start_date > '2100-01-01'\n)\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_start_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_end_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_start_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_end_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from start_after_end\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from future_end_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from nonsensical_dates", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_demographics": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_demographics", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__eligibility_demographics.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__eligibility_demographics.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_demographics", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_demographics"], "alias": "eligibility_demographics", "checksum": {"name": "sha256", "checksum": "f73910b4157c658804d31c9e3a16cdcb2d22533956fb62fa0cdab3b9d2aa04c7"}, "config": {"enabled": true, "alias": "eligibility_demographics", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria (multiple birth dates\ncount unique members)\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_demographics", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0070508, "relation_name": "dev_thuxuan.data_quality.eligibility_demographics", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith eligibility_spans as(\r\n select distinct\r\n {{ dbt.concat([\r\n \"member_id\",\r\n \"'-'\",\r\n \"enrollment_start_date\",\r\n \"'-'\",\r\n \"enrollment_end_date\",\r\n \"'-'\",\r\n \"payer\",\r\n \"'-'\",\r\n quote_column('plan'),\r\n ]) }} as eligibility_span_id\r\n , patient_id\r\n , birth_date\r\n , gender\r\n from {{ ref('eligibility') }}\r\n)\r\n\r\n, missing_birth_date as(\r\n select\r\n 'Missing birthday' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n where birth_date is null\r\n)\r\n, invalid_birth_date as(\r\n select\r\n 'Birthday is not a valid date' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans e\r\n left join reference_data.calendar c\r\n on e.birth_date = c.full_date\r\n where c.full_date is null\r\n)\r\n, future_birth_date as(\r\n select\r\n 'Birthday is in the future' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n {% if target.type == 'fabric' %}\r\n where birth_date > GETDATE()\r\n {% else %}\r\n where birth_date > current_date\r\n {% endif %}\r\n)\r\n, past_birth_date as(\r\n select\r\n 'Birthday is too far in the past' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n {% if target.type == 'fabric' %}\r\n where cast(floor({{ datediff('birth_date', 'getdate()', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) > 110\r\n {% else %}\r\n where cast(floor({{ datediff('birth_date', 'current_date', 'hour') }} / 8760.0) as {{ dbt.type_int() }} ) > 110\r\n {% endif %}\r\n\r\n)\r\n, multiple_birth_date as(\r\n select\r\n 'Patient has multiple birthdays' as data_quality_check\r\n , count(distinct patient_id) as result_count\r\n from(\r\n select\r\n patient_id\r\n , birth_date\r\n , rank() over (partition by patient_id, birth_date order by birth_date) as rank_birth_date\r\n from eligibility_spans e\r\n where birth_date is not null\r\n )x\r\nwhere rank_birth_date > 1\r\n)\r\n, missing_gender as(\r\n select\r\n 'Missing gender' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n where birth_date is null\r\n)\r\n, invalid_gender as(\r\n select\r\n 'Patient gender does not join to terminology table' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n where birth_date is null\r\n)\r\n\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_birth_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_birth_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from future_birth_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from past_birth_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from multiple_birth_date\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from missing_gender\r\nunion all\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_gender", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat", "macro.dbt.datediff", "macro.dbt.type_int"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__eligibility_demographics.sql", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n , birth_date\n , gender\n from tuva.input_layer.eligibility\n)\n\n, missing_birth_date as(\n select\n 'Missing birthday' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_birth_date as(\n select\n 'Birthday is not a valid date' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join reference_data.calendar c\n on e.birth_date = c.full_date\n where c.full_date is null\n)\n, future_birth_date as(\n select\n 'Birthday is in the future' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where birth_date > current_date\n \n)\n, past_birth_date as(\n select\n 'Birthday is too far in the past' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where cast(floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8760.0) as integer ) > 110\n \n\n)\n, multiple_birth_date as(\n select\n 'Patient has multiple birthdays' as data_quality_check\n , count(distinct patient_id) as result_count\n from(\n select\n patient_id\n , birth_date\n , rank() over (partition by patient_id, birth_date order by birth_date) as rank_birth_date\n from eligibility_spans e\n where birth_date is not null\n )x\nwhere rank_birth_date > 1\n)\n, missing_gender as(\n select\n 'Missing gender' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_gender as(\n select\n 'Patient gender does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from future_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from past_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from multiple_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_gender\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_gender", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_missing_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_missing_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__eligibility_missing_patient_id.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__eligibility_missing_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_missing_patient_id"], "alias": "eligibility_missing_patient_id", "checksum": {"name": "sha256", "checksum": "56d9c464223e39c312de3d3da1d7352446e91f3a47301e666c038d0969fc92b1"}, "config": {"enabled": true, "alias": "eligibility_missing_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_missing_patient_id", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0130515, "relation_name": "dev_thuxuan.data_quality.eligibility_missing_patient_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\n\r\nwith eligibility_spans as(\r\n select distinct\r\n {{ dbt.concat([\r\n \"member_id\",\r\n \"'-'\",\r\n \"enrollment_start_date\",\r\n \"'-'\",\r\n \"enrollment_end_date\",\r\n \"'-'\",\r\n \"payer\",\r\n \"'-'\",\r\n quote_column('plan'),\r\n ]) }} as eligibility_span_id\r\n , patient_id\r\n from {{ ref('eligibility') }}\r\n)\r\n\r\nselect\r\n 'Missing patient_id' as data_quality_check\r\n ,count(*) as result_count\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom eligibility_spans\r\nwhere\r\n patient_id is null or patient_id = ''", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__eligibility_missing_patient_id.sql", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n from tuva.input_layer.eligibility\n)\n\nselect\n 'Missing patient_id' as data_quality_check\n ,count(*) as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom eligibility_spans\nwhere\n patient_id is null or patient_id = ''", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_missing_payer": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_missing_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__eligibility_missing_payer.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__eligibility_missing_payer.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_payer", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__eligibility_missing_payer"], "alias": "eligibility_missing_payer", "checksum": {"name": "sha256", "checksum": "ce6c928f3953215db166141d4874e9e92d12c8411f5e429c538ffa66dfdb9cca"}, "config": {"enabled": true, "alias": "eligibility_missing_payer", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {"data_quality_check": {"name": "data_quality_check", "description": "The name of the data quality check", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_count": {"name": "result_count", "description": "The number of eligibility spans in the input layer that match the data quality check criteria", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_ran": {"name": "tuva_last_ran", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "eligibility_missing_payer", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0150504, "relation_name": "dev_thuxuan.data_quality.eligibility_missing_payer", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith eligibility_spans as(\r\n select distinct\r\n {{ dbt.concat([\r\n \"member_id\",\r\n \"'-'\",\r\n \"enrollment_start_date\",\r\n \"'-'\",\r\n \"enrollment_end_date\",\r\n \"'-'\",\r\n \"payer\",\r\n \"'-'\",\r\n quote_column('plan'),\r\n ]) }} as eligibility_span_id\r\n , payer\r\n , payer_type\r\n from {{ ref('eligibility') }}\r\n)\r\n\r\n, missing_payer_type as(\r\n select\r\n 'Missing payer type' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n where payer_type is null\r\n)\r\n, missing_payer_name as(\r\n select\r\n 'Missing payer name' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans\r\n where payer is null\r\n)\r\n, invalid_payer_type as(\r\n select\r\n 'Payer type does not join to terminology table' as data_quality_check\r\n , count(distinct eligibility_span_id) as result_count\r\n from eligibility_spans e\r\n left join {{ ref('terminology__payer_type') }} pt\r\n on e.payer_type = pt.payer_type\r\n where pt.payer_type is null\r\n)\r\n\r\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from missing_payer_type\r\nunion all\r\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from missing_payer_name\r\nunion all\r\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from invalid_payer_type", "language": "sql", "refs": [{"name": "eligibility", "package": null, "version": null}, {"name": "terminology__payer_type", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt.concat"], "nodes": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__eligibility_missing_payer.sql", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , payer\n , payer_type\n from tuva.input_layer.eligibility\n)\n\n, missing_payer_type as(\n select\n 'Missing payer type' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer_type is null\n)\n, missing_payer_name as(\n select\n 'Missing payer name' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer is null\n)\n, invalid_payer_type as(\n select\n 'Payer type does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join dev_thuxuan.terminology.payer_type pt\n on e.payer_type = pt.payer_type\n where pt.payer_type is null\n)\n\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_payer_type\nunion all\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_payer_name\nunion all\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_payer_type", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_cost_and_utilization": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounters_cost_and_utilization", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__encounters_cost_and_utilization.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__encounters_cost_and_utilization.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__encounters_cost_and_utilization"], "alias": "encounters_cost_and_utilization", "checksum": {"name": "sha256", "checksum": "01db8a572164e06c05b95351467ea25263b87abbe6e58fb1c7850d4289e7c7b5"}, "config": {"enabled": true, "alias": "encounters_cost_and_utilization", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_cost_and_utilization", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0170507, "relation_name": "dev_thuxuan.data_quality.encounters_cost_and_utilization", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\r\n) }}\r\n\r\nwith member_months as (\r\n select \r\n count(1) as member_months \r\n from {{ ref('core__member_months') }}\r\n)\r\n,pkpy as (\r\nselect\r\n cast('encounters cost and utilization PKPY' as {{dbt.type_string()}}) as analytics_concept\r\n , enc.encounter_group\r\n , cast(enc.encounter_type as {{dbt.type_string()}}) as analytics_measure\r\n , count(enc.encounter_id) / avg(mm.member_months) * 12000 as data_source_value\r\nfrom {{ ref('core__encounter') }} as enc\r\ncross join member_months as mm\r\ngroup by\r\n enc.encounter_group\r\n , enc.encounter_type\r\n)\r\n,paid_per as (\r\nselect\r\n cast('encounters cost and utilization paid per' as {{dbt.type_string()}}) as analytics_concept\r\n , enc.encounter_group\r\n , cast(enc.encounter_type as {{dbt.type_string()}}) as analytics_measure\r\n , sum(enc.paid_amount) / count(enc.encounter_id) as data_source_value\r\nfrom {{ ref('core__encounter') }} as enc\r\ncross join member_months as mm\r\ngroup by\r\n enc.encounter_group\r\n , enc.encounter_type\r\n)\r\nselect\r\n pkpy.*\r\n ,ref_data.analytics_value\r\n ,cast('{{ var('tuva_last_run')}}' as {{dbt.type_string()}}) as tuva_last_run\r\nfrom pkpy\r\nleft join {{ ref('data_quality__reference_mart_analytics') }} ref_data on pkpy.analytics_concept = ref_data.analytics_concept and pkpy.analytics_measure = ref_data.analytics_measure\r\nunion all\r\nselect\r\n paid_per.*\r\n ,ref_data.analytics_value\r\n ,cast('{{ var('tuva_last_run')}}' as {{dbt.type_string()}}) as tuva_last_run\r\nfrom paid_per\r\nleft join {{ ref('data_quality__reference_mart_analytics') }} ref_data on paid_per.analytics_concept = paid_per.analytics_concept and paid_per.analytics_measure = paid_per.analytics_measure", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "core__encounter", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__encounters_cost_and_utilization.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select \n count(1) as member_months \n from dev_thuxuan.core.member_months\n)\n,pkpy as (\nselect\n cast('encounters cost and utilization PKPY' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , count(enc.encounter_id) / avg(mm.member_months) * 12000 as data_source_value\nfrom dev_thuxuan.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\n,paid_per as (\nselect\n cast('encounters cost and utilization paid per' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , sum(enc.paid_amount) / count(enc.encounter_id) as data_source_value\nfrom dev_thuxuan.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\nselect\n pkpy.*\n ,ref_data.analytics_value\n ,cast('2024-10-25 14:34:26.237057+00:00' as TEXT) as tuva_last_run\nfrom pkpy\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data on pkpy.analytics_concept = ref_data.analytics_concept and pkpy.analytics_measure = ref_data.analytics_measure\nunion all\nselect\n paid_per.*\n ,ref_data.analytics_value\n ,cast('2024-10-25 14:34:26.237057+00:00' as TEXT) as tuva_last_run\nfrom paid_per\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data on paid_per.analytics_concept = paid_per.analytics_concept and paid_per.analytics_measure = paid_per.analytics_measure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_missing_groups": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounters_missing_groups", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__encounters_missing_groups.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__encounters_missing_groups.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__encounters_missing_groups"], "alias": "encounters_missing_groups", "checksum": {"name": "sha256", "checksum": "c4bfeb57d32e56a12305fc6f0c82b758f3fcdd170f6f11d4eb92455cafce0bb6"}, "config": {"enabled": true, "alias": "encounters_missing_groups", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_missing_groups", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.021051, "relation_name": "dev_thuxuan.data_quality.encounters_missing_groups", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\r\n) }}\r\n\r\nwith expected_groups as (\r\n select 'inpatient' as encounter_group\r\n union all\r\n select 'outpatient'\r\n union all\r\n select 'office based'\r\n union all\r\n select 'other'\r\n)\r\n\r\n, actual_groups as (\r\n select distinct\r\n encounter_group\r\n from {{ ref('core__encounter') }}\r\n)\r\n\r\nselect\r\n e.encounter_group as missing_encounter_group\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom expected_groups e\r\n left join actual_groups a\r\n on e.encounter_group = a.encounter_group\r\nwhere a.encounter_group is null", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__encounters_missing_groups.sql", "compiled": true, "compiled_code": "\n\nwith expected_groups as (\n select 'inpatient' as encounter_group\n union all\n select 'outpatient'\n union all\n select 'office based'\n union all\n select 'other'\n)\n\n, actual_groups as (\n select distinct\n encounter_group\n from dev_thuxuan.core.encounter\n)\n\nselect\n e.encounter_group as missing_encounter_group\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom expected_groups e\n left join actual_groups a\n on e.encounter_group = a.encounter_group\nwhere a.encounter_group is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__encounters_missing_groups_union": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__encounters_missing_groups_union", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__encounters_missing_groups_union.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__encounters_missing_groups_union.sql", "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups_union", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__encounters_missing_groups_union"], "alias": "encounters_missing_groups_union", "checksum": {"name": "sha256", "checksum": "93e5d04370a926a0cb8b482c18869c84580284f43ac5d50e7c46a8a519726004"}, "config": {"enabled": true, "alias": "encounters_missing_groups_union", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "encounters_missing_groups_union", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0190508, "relation_name": "dev_thuxuan.data_quality.encounters_missing_groups_union", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\r\n) }}\r\n\r\nselect\r\n 'number of missing encounter groups' as data_quality_check\r\n , count(*) as result_count\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__encounters_missing_groups') }}", "language": "sql", "refs": [{"name": "data_quality__encounters_missing_groups", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.data_quality__encounters_missing_groups"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__encounters_missing_groups_union.sql", "compiled": true, "compiled_code": "\n\nselect\n 'number of missing encounter groups' as data_quality_check\n , count(*) as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality.encounters_missing_groups", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__financial_pmpm": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__financial_pmpm", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__financial_pmpm.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__financial_pmpm.sql", "unique_id": "model.the_tuva_project.data_quality__financial_pmpm", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__financial_pmpm"], "alias": "data_quality_financial_pmpm", "checksum": {"name": "sha256", "checksum": "eb857ac424f33c962c3b44e7d2231000b3fddf5ac7cb7f842c978fe729e785b2"}, "config": {"enabled": true, "alias": "data_quality_financial_pmpm", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_financial_pmpm", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0990524, "relation_name": "dev_thuxuan.data_quality.data_quality_financial_pmpm", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool\r\n) }}\r\n\r\nwith cte as (\r\nselect distinct cast(year_month_int as {{ dbt.type_string() }} ) as year_month\r\n,year as year_number\r\nfrom {{ ref('reference_data__calendar') }}\r\n)\r\n\r\nselect count(*) as member_months\r\n,sum(total_paid) / cast(count(*) as {{ dbt.type_numeric() }}) as total_pmpm\r\n,c.year_number as year_number\r\nfrom {{ ref('financial_pmpm__pmpm_prep') }} p \r\nleft join cte c on p.year_month = c.year_month \r\ngroup by c.year_number", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__financial_pmpm.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect distinct cast(year_month_int as TEXT ) as year_month\n,year as year_number\nfrom dev_thuxuan.reference_data.calendar\n)\n\nselect count(*) as member_months\n,sum(total_paid) / cast(count(*) as numeric(28,6)) as total_pmpm\n,c.year_number as year_number\nfrom dev_thuxuan.financial_pmpm.pmpm_prep p \nleft join cte c on p.year_month = c.year_month \ngroup by c.year_number", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medical_claim_claim_line_fields", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__medical_claim_claim_line_fields.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__medical_claim_claim_line_fields.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_claim_line_fields"], "alias": "medical_claim_claim_line_fields", "checksum": {"name": "sha256", "checksum": "d84b85c0d1c506be097ea6805d6e050416edad82cec26d8a5ab18fac5bab0f81"}, "config": {"enabled": true, "alias": "medical_claim_claim_line_fields", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_claim_line_fields", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0580478, "relation_name": "dev_thuxuan.data_quality.medical_claim_claim_line_fields", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith medical_claim as (\r\n select\r\n m.claim_id\r\n , max(case when hcpc.hcpcs is null and m.hcpcs_code is not null then 1 else 0 end) as invalid_hcpcs_code\r\n , max(case when m.claim_type = 'professional' and pos.place_of_service_code is null and m.place_of_service_code is not null then 1 else 0 end) as invalid_place_of_service_code\r\n , max(case when m.claim_type = 'institutional' and rev.revenue_center_code is null and m.revenue_center_code is not null then 1 else 0 end) as invalid_revenue_center_code\r\n , max(case when m.hcpcs_code is null then 1 else 0 end) as missing_hcpcs_code\r\n , max(case when m.claim_type = 'professional' and m.place_of_service_code is null then 1 else 0 end) as missing_place_of_service_code\r\n , max(case when m.claim_type = 'institutional' and m.revenue_center_code is null then 1 else 0 end) as missing_revenue_center_code\r\n from {{ ref('medical_claim') }} as m\r\n left join {{ ref('terminology__hcpcs_level_2') }} as hcpc\r\n on m.hcpcs_code = hcpc.hcpcs\r\n left join {{ ref('terminology__place_of_service') }} as pos\r\n on m.place_of_service_code = pos.place_of_service_code\r\n left join {{ ref('terminology__revenue_center') }} as rev\r\n on m.revenue_center_code = rev.revenue_center_code\r\n group by m.claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'invalid hcpcs_code' as data_quality_check\r\n , sum(invalid_hcpcs_code) as result_count\r\n from medical_claim\r\n \r\n union all\r\n\r\n select\r\n 'invalid place_of_service_code' as data_quality_check\r\n , sum(invalid_place_of_service_code) as result_count\r\n from medical_claim\r\n\r\n union all\r\n\r\n select\r\n 'invalid revenue_center_code' as data_quality_check\r\n , sum(invalid_revenue_center_code) as result_count\r\n from medical_claim\r\n\r\n union all\r\n\r\n select\r\n 'missing hcpcs_code' as data_quality_check\r\n , sum(missing_hcpcs_code) as result_count\r\n from medical_claim\r\n\r\n union all\r\n\r\n select\r\n 'missing place_of_service_code' as data_quality_check\r\n , sum(missing_place_of_service_code) as result_count\r\n from medical_claim\r\n\r\n union all\r\n\r\n select\r\n 'missing revenue_center_code' as data_quality_check\r\n , sum(missing_revenue_center_code) as result_count\r\n from medical_claim\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__hcpcs_level_2", "package": null, "version": null}, {"name": "terminology__place_of_service", "package": null, "version": null}, {"name": "terminology__revenue_center", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__revenue_center"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__medical_claim_claim_line_fields.sql", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when hcpc.hcpcs is null and m.hcpcs_code is not null then 1 else 0 end) as invalid_hcpcs_code\n , max(case when m.claim_type = 'professional' and pos.place_of_service_code is null and m.place_of_service_code is not null then 1 else 0 end) as invalid_place_of_service_code\n , max(case when m.claim_type = 'institutional' and rev.revenue_center_code is null and m.revenue_center_code is not null then 1 else 0 end) as invalid_revenue_center_code\n , max(case when m.hcpcs_code is null then 1 else 0 end) as missing_hcpcs_code\n , max(case when m.claim_type = 'professional' and m.place_of_service_code is null then 1 else 0 end) as missing_place_of_service_code\n , max(case when m.claim_type = 'institutional' and m.revenue_center_code is null then 1 else 0 end) as missing_revenue_center_code\n from tuva.input_layer.medical_claim as m\n left join dev_thuxuan.terminology.hcpcs_level_2 as hcpc\n on m.hcpcs_code = hcpc.hcpcs\n left join dev_thuxuan.terminology.place_of_service as pos\n on m.place_of_service_code = pos.place_of_service_code\n left join dev_thuxuan.terminology.revenue_center as rev\n on m.revenue_center_code = rev.revenue_center_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid hcpcs_code' as data_quality_check\n , sum(invalid_hcpcs_code) as result_count\n from medical_claim\n \n union all\n\n select\n 'invalid place_of_service_code' as data_quality_check\n , sum(invalid_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'invalid revenue_center_code' as data_quality_check\n , sum(invalid_revenue_center_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing hcpcs_code' as data_quality_check\n , sum(missing_hcpcs_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing place_of_service_code' as data_quality_check\n , sum(missing_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing revenue_center_code' as data_quality_check\n , sum(missing_revenue_center_code) as result_count\n from medical_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_date_checks": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medical_claim_date_checks", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__medical_claim_date_checks.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__medical_claim_date_checks.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_date_checks", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_date_checks"], "alias": "medical_claim_date_checks", "checksum": {"name": "sha256", "checksum": "e4f6c70b2a2dbb68ffbac205879ceeab6272deae86d39aa5385a50b7cfe6729e"}, "config": {"enabled": true, "alias": "medical_claim_date_checks", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_date_checks", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.053048, "relation_name": "dev_thuxuan.data_quality.medical_claim_date_checks", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nwith medical_claim as (\r\n select m.claim_id,\r\n max(case when claim_start_date is null then 1 else 0 end) as missing_claim_start_date,\r\n max(case when claim_end_date is null then 1 else 0 end) as missing_claim_end_date,\r\n max(case when claim_line_start_date is null then 1 else 0 end) as missing_claim_line_start_date,\r\n max(case when claim_line_end_date is null then 1 else 0 end) as missing_claim_line_end_date,\r\n max(case when admission_date is null and d.claim_id is not null then 1 else 0 end) as missing_admission_date,\r\n max(case when discharge_date is null and d.claim_id is not null then 1 else 0 end) as missing_discharge_date,\r\n max(case when paid_date is null then 1 else 0 end) as missing_paid_date,\r\n count(distinct case when d.claim_id is not null then claim_start_date else null end) as claim_start_count,\r\n count(distinct case when d.claim_id is not null then claim_end_date else null end) as claim_end_count,\r\n count(distinct case when d.claim_id is not null then admission_date else null end) as admission_date_count,\r\n count(distinct case when d.claim_id is not null then discharge_date else null end) as discharge_date_count\r\n from {{ ref('medical_claim')}} m\r\n left join {{ ref('data_quality__inpatient_dq_stage')}} d on m.claim_id = d.claim_id\r\n group by m.claim_id\r\n)\r\n\r\n,final as (\r\nselect 'missing claim_start_date' as data_quality_check,\r\n sum(missing_claim_start_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'missing claim_end_date' as data_quality_check,\r\n sum(missing_claim_end_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'missing claim_line_start_date' as data_quality_check,\r\n sum(missing_claim_line_start_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'missing claim_line_end_date' as data_quality_check,\r\n sum(missing_claim_line_end_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'missing admission_date' as data_quality_check,\r\n sum(missing_admission_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'missing discharge_date' as data_quality_check,\r\n sum(missing_discharge_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'missing medical_claim paid_date' as data_quality_check,\r\n sum(missing_paid_date) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect 'claim start multiple' as data_quality_check,\r\n count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere claim_start_count > 1\r\n\r\nunion all\r\n\r\nselect 'claim end multiple' as data_quality_check,\r\n count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere claim_end_count > 1\r\n\r\nunion all\r\n\r\nselect 'admission date multiple' as data_quality_check,\r\n count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere admission_date_count > 1\r\n\r\nunion all\r\n\r\nselect 'discharge date multiple' as data_quality_check,\r\n count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere discharge_date_count > 1\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "data_quality__inpatient_dq_stage", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__medical_claim_date_checks.sql", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select m.claim_id,\n max(case when claim_start_date is null then 1 else 0 end) as missing_claim_start_date,\n max(case when claim_end_date is null then 1 else 0 end) as missing_claim_end_date,\n max(case when claim_line_start_date is null then 1 else 0 end) as missing_claim_line_start_date,\n max(case when claim_line_end_date is null then 1 else 0 end) as missing_claim_line_end_date,\n max(case when admission_date is null and d.claim_id is not null then 1 else 0 end) as missing_admission_date,\n max(case when discharge_date is null and d.claim_id is not null then 1 else 0 end) as missing_discharge_date,\n max(case when paid_date is null then 1 else 0 end) as missing_paid_date,\n count(distinct case when d.claim_id is not null then claim_start_date else null end) as claim_start_count,\n count(distinct case when d.claim_id is not null then claim_end_date else null end) as claim_end_count,\n count(distinct case when d.claim_id is not null then admission_date else null end) as admission_date_count,\n count(distinct case when d.claim_id is not null then discharge_date else null end) as discharge_date_count\n from tuva.input_layer.medical_claim m\n left join dev_thuxuan.data_quality.data_quality__inpatient_dq_stage d on m.claim_id = d.claim_id\n group by m.claim_id\n)\n\n,final as (\nselect 'missing claim_start_date' as data_quality_check,\n sum(missing_claim_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_end_date' as data_quality_check,\n sum(missing_claim_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_start_date' as data_quality_check,\n sum(missing_claim_line_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_end_date' as data_quality_check,\n sum(missing_claim_line_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing admission_date' as data_quality_check,\n sum(missing_admission_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing discharge_date' as data_quality_check,\n sum(missing_discharge_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing medical_claim paid_date' as data_quality_check,\n sum(missing_paid_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'claim start multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_start_count > 1\n\nunion all\n\nselect 'claim end multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_end_count > 1\n\nunion all\n\nselect 'admission date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere admission_date_count > 1\n\nunion all\n\nselect 'discharge date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere discharge_date_count > 1\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medical_claim_inst_header_fields", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__medical_claim_inst_header_fields.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__medical_claim_inst_header_fields.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_inst_header_fields"], "alias": "medical_claim_inst_header_fields", "checksum": {"name": "sha256", "checksum": "589db287a5efe2d4a6f6cdd839f01971902c8444591aacf21c70b326c0a86808"}, "config": {"enabled": true, "alias": "medical_claim_inst_header_fields", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_inst_header_fields", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0560477, "relation_name": "dev_thuxuan.data_quality.medical_claim_inst_header_fields", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith inst_header as (\r\n select\r\n m.claim_id\r\n , max(case when m.claim_type = 'institutional' and btc.bill_type_code is null and m.bill_type_code is not null then 1 else 0 end) as invalid_bill_type_code\r\n , max(case when m.claim_type = 'institutional' and dd.discharge_disposition_code is null and m.discharge_disposition_code is not null then 1 else 0 end) as invalid_discharge_disposition_code\r\n , max(case when d.claim_id is not null and ms.ms_drg_code is null and m.ms_drg_code is not null then 1 else 0 end) as invalid_ms_drg_code\r\n , max(case when d.claim_id is not null and apr.apr_drg_code is null and m.apr_drg_code is not null then 1 else 0 end) as invalid_apr_drg_code\r\n , max(case when m.claim_type = 'institutional' and m.bill_type_code is null then 1 else 0 end) as missing_bill_type_code\r\n , max(case when m.claim_type = 'institutional' and m.discharge_disposition_code is null then 1 else 0 end) as missing_discharge_disposition_code\r\n , max(case when d.claim_id is not null and m.ms_drg_code is null then 1 else 0 end) as missing_ms_drg_code\r\n , max(case when d.claim_id is not null and m.apr_drg_code is null then 1 else 0 end) as missing_apr_drg_code\r\n , count(distinct case when m.claim_type = 'institutional' then m.bill_type_code else null end) as bill_type_code_count\r\n , count(distinct case when m.claim_type = 'institutional' then m.discharge_disposition_code else null end) as discharge_disposition_code_count\r\n , count(distinct case when d.claim_id is not null then m.ms_drg_code else null end) as ms_drg_code_count\r\n , count(distinct case when d.claim_id is not null then m.apr_drg_code else null end) as apr_drg_code_count\r\n from {{ ref('medical_claim') }} as m\r\n left join {{ ref('data_quality__inpatient_dq_stage') }} as d\r\n on m.claim_id = d.claim_id\r\n left join {{ ref('terminology__bill_type') }} as btc\r\n on m.bill_type_code = btc.bill_type_code\r\n left join {{ ref('terminology__ms_drg') }} as ms\r\n on m.ms_drg_code = ms.ms_drg_code\r\n left join {{ ref('terminology__apr_drg') }} as apr\r\n on m.ms_drg_code = apr.apr_drg_code\r\n left join {{ ref('terminology__discharge_disposition') }} as dd\r\n on m.discharge_disposition_code = dd.discharge_disposition_code\r\n group by m.claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'invalid bill_type_code' as data_quality_check\r\n , sum(invalid_bill_type_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'invalid ms_drg_code' as data_quality_check\r\n , sum(invalid_ms_drg_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'invalid apr_drg_code' as data_quality_check\r\n , sum(invalid_apr_drg_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'invalid discharge_disposition_code' as data_quality_check\r\n , sum(invalid_discharge_disposition_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'missing bill_type_code' as data_quality_check\r\n , sum(missing_bill_type_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'missing ms_drg_code' as data_quality_check\r\n , sum(missing_ms_drg_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'missing apr_drg_code' as data_quality_check\r\n , sum(missing_apr_drg_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'missing discharge_disposition_code' as data_quality_check\r\n , sum(missing_discharge_disposition_code) as result_count\r\n from inst_header\r\n\r\n union all\r\n\r\n select\r\n 'bill_type_code multiple' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\n from inst_header\r\n where bill_type_code_count > 1\r\n\r\n union all\r\n\r\n select\r\n 'ms_drg_code multiple' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\n from inst_header\r\n where ms_drg_code_count > 1\r\n\r\n union all\r\n\r\n select\r\n 'apr_drg_code multiple' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\n from inst_header\r\n where apr_drg_code_count > 1\r\n\r\n union all\r\n\r\n select\r\n 'discharge_disposition_code multiple' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\n from inst_header\r\n where discharge_disposition_code_count > 1\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "data_quality__inpatient_dq_stage", "package": null, "version": null}, {"name": "terminology__bill_type", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__medical_claim_inst_header_fields.sql", "compiled": true, "compiled_code": "\n\nwith inst_header as (\n select\n m.claim_id\n , max(case when m.claim_type = 'institutional' and btc.bill_type_code is null and m.bill_type_code is not null then 1 else 0 end) as invalid_bill_type_code\n , max(case when m.claim_type = 'institutional' and dd.discharge_disposition_code is null and m.discharge_disposition_code is not null then 1 else 0 end) as invalid_discharge_disposition_code\n , max(case when d.claim_id is not null and ms.ms_drg_code is null and m.ms_drg_code is not null then 1 else 0 end) as invalid_ms_drg_code\n , max(case when d.claim_id is not null and apr.apr_drg_code is null and m.apr_drg_code is not null then 1 else 0 end) as invalid_apr_drg_code\n , max(case when m.claim_type = 'institutional' and m.bill_type_code is null then 1 else 0 end) as missing_bill_type_code\n , max(case when m.claim_type = 'institutional' and m.discharge_disposition_code is null then 1 else 0 end) as missing_discharge_disposition_code\n , max(case when d.claim_id is not null and m.ms_drg_code is null then 1 else 0 end) as missing_ms_drg_code\n , max(case when d.claim_id is not null and m.apr_drg_code is null then 1 else 0 end) as missing_apr_drg_code\n , count(distinct case when m.claim_type = 'institutional' then m.bill_type_code else null end) as bill_type_code_count\n , count(distinct case when m.claim_type = 'institutional' then m.discharge_disposition_code else null end) as discharge_disposition_code_count\n , count(distinct case when d.claim_id is not null then m.ms_drg_code else null end) as ms_drg_code_count\n , count(distinct case when d.claim_id is not null then m.apr_drg_code else null end) as apr_drg_code_count\n from tuva.input_layer.medical_claim as m\n left join dev_thuxuan.data_quality.data_quality__inpatient_dq_stage as d\n on m.claim_id = d.claim_id\n left join dev_thuxuan.terminology.bill_type as btc\n on m.bill_type_code = btc.bill_type_code\n left join dev_thuxuan.terminology.ms_drg as ms\n on m.ms_drg_code = ms.ms_drg_code\n left join dev_thuxuan.terminology.apr_drg as apr\n on m.ms_drg_code = apr.apr_drg_code\n left join dev_thuxuan.terminology.discharge_disposition as dd\n on m.discharge_disposition_code = dd.discharge_disposition_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid bill_type_code' as data_quality_check\n , sum(invalid_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid ms_drg_code' as data_quality_check\n , sum(invalid_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid apr_drg_code' as data_quality_check\n , sum(invalid_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid discharge_disposition_code' as data_quality_check\n , sum(invalid_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing bill_type_code' as data_quality_check\n , sum(missing_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing ms_drg_code' as data_quality_check\n , sum(missing_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing apr_drg_code' as data_quality_check\n , sum(missing_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing discharge_disposition_code' as data_quality_check\n , sum(missing_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'bill_type_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where bill_type_code_count > 1\n\n union all\n\n select\n 'ms_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where ms_drg_code_count > 1\n\n union all\n\n select\n 'apr_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where apr_drg_code_count > 1\n\n union all\n\n select\n 'discharge_disposition_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where discharge_disposition_code_count > 1\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medical_claim_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__medical_claim_patient_id.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__medical_claim_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_patient_id", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_patient_id"], "alias": "medical_claim_patient_id", "checksum": {"name": "sha256", "checksum": "f507306dc35cbe58695448bcd59222d2ae019ed2eee8a8162adfa2ef63190da8"}, "config": {"enabled": true, "alias": "medical_claim_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_patient_id", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0510483, "relation_name": "dev_thuxuan.data_quality.medical_claim_patient_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith medical as (\r\n select\r\n claim_id\r\n , count(distinct p.patient_id) as patient_id_count\r\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\r\n , max(\r\n case \r\n when startdts.month_start_date is null then 1\r\n when enddts.month_start_date is null then 1\r\n else 0\r\n end\r\n ) as missing_eligibility\r\n from {{ ref('medical_claim') }} p\r\n left join {{ ref('data_quality__eligibility_dq_stage') }} startdts\r\n on p.patient_id = startdts.patient_id\r\n and p.claim_start_date between startdts.month_start_date and startdts.month_end_date\r\n left join {{ ref('data_quality__eligibility_dq_stage') }} enddts\r\n on p.patient_id = enddts.patient_id\r\n and p.claim_end_date between enddts.month_start_date and enddts.month_end_date\r\n group by\r\n claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'multiple medical_claim patient_ids' as data_quality_check\r\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\r\n from medical\r\n\r\n union all\r\n\r\n select\r\n 'missing medical_claim patient_id' as data_quality_check\r\n , sum(missing_patient_id) as result_count\r\n from medical\r\n\r\n union all\r\n\r\n select\r\n 'orphaned medical_claim claims' as data_quality_check\r\n , sum(missing_eligibility) as result_count\r\n from medical\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__medical_claim_patient_id.sql", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(\n case \n when startdts.month_start_date is null then 1\n when enddts.month_start_date is null then 1\n else 0\n end\n ) as missing_eligibility\n from tuva.input_layer.medical_claim p\n left join dev_thuxuan.data_quality.data_quality__eligibility_dq_stage startdts\n on p.patient_id = startdts.patient_id\n and p.claim_start_date between startdts.month_start_date and startdts.month_end_date\n left join dev_thuxuan.data_quality.data_quality__eligibility_dq_stage enddts\n on p.patient_id = enddts.patient_id\n and p.claim_end_date between enddts.month_start_date and enddts.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple medical_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from medical\n\n union all\n\n select\n 'missing medical_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from medical\n\n union all\n\n select\n 'orphaned medical_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from medical\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__medical_claim_provider_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__medical_claim_provider_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__medical_claim_provider_npi.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__medical_claim_provider_npi.sql", "unique_id": "model.the_tuva_project.data_quality__medical_claim_provider_npi", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__medical_claim_provider_npi"], "alias": "medical_claim_provider_npi", "checksum": {"name": "sha256", "checksum": "af756e2ba58c8506f304f0542844c89892aafd04b6afba3958723d80cf7d8280"}, "config": {"enabled": true, "alias": "medical_claim_provider_npi", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "medical_claim_provider_npi", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0600476, "relation_name": "dev_thuxuan.data_quality.medical_claim_provider_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n )\r\n}}\r\n\r\nwith medical_claim as (\r\n select\r\n m.claim_id\r\n , max(case when term.npi is null and m.rendering_npi is not null then 1 else 0 end) as invalid_rendering_npi\r\n , max(case when term2.npi is null and m.billing_npi is not null then 1 else 0 end) as invalid_billing_npi\r\n , max(case when term3.npi is null and m.facility_npi is not null then 1 else 0 end) as invalid_facility_npi\r\n\r\n , max(case when m.rendering_npi is null then 1 else 0 end) as missing_rendering_npi\r\n , max(case when m.billing_npi is null then 1 else 0 end) as missing_billing_npi\r\n , max(case when m.facility_npi is null then 1 else 0 end) as missing_facility_npi\r\n\r\n , count(distinct m.rendering_npi) as rendering_npi_count\r\n , count(distinct m.billing_npi) as billing_npi_count\r\n , count(distinct m.facility_npi) as facility_npi_count\r\n\r\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_rendering_npi\r\n , max(case when term3.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_facility_npi\r\n\r\n from {{ ref('medical_claim') }} as m\r\n left join {{ ref('terminology__provider') }} as term\r\n on m.rendering_npi = term.npi\r\n left join {{ ref('terminology__provider') }} as term2\r\n on m.billing_npi = term2.npi\r\n left join {{ ref('terminology__provider') }} as term3\r\n on m.facility_npi = term3.npi\r\n group by\r\n m.claim_id\r\n)\r\n\r\n,final as (\r\nselect\r\n 'invalid rendering_npi' as data_quality_check\r\n , sum(invalid_rendering_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'invalid billing_npi' as data_quality_check\r\n , sum(invalid_billing_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'invalid facility_npi' as data_quality_check\r\n , sum(invalid_facility_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'missing rendering_npi' as data_quality_check\r\n , sum(missing_rendering_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'missing billing_npi' as data_quality_check\r\n , sum(missing_billing_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'missing facility_npi' as data_quality_check\r\n , sum(missing_facility_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'wrong entity type rendering_npi' as data_quality_check\r\n , sum(wrong_entity_type_rendering_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'wrong entity type facility_npi' as data_quality_check\r\n , sum(wrong_entity_type_facility_npi) as result_count\r\nfrom medical_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'multiple rendering_npi values' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere rendering_npi_count > 1\r\n\r\nunion all\r\n\r\nselect\r\n 'multiple billing_npi values' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere billing_npi_count > 1\r\n\r\nunion all\r\n\r\nselect\r\n 'multiple facility_npi values' as data_quality_check\r\n , count(distinct claim_id) as result_count\r\nfrom medical_claim\r\nwhere facility_npi_count > 1\r\n)\r\n\r\nselect *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__medical_claim_provider_npi.sql", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.rendering_npi is not null then 1 else 0 end) as invalid_rendering_npi\n , max(case when term2.npi is null and m.billing_npi is not null then 1 else 0 end) as invalid_billing_npi\n , max(case when term3.npi is null and m.facility_npi is not null then 1 else 0 end) as invalid_facility_npi\n\n , max(case when m.rendering_npi is null then 1 else 0 end) as missing_rendering_npi\n , max(case when m.billing_npi is null then 1 else 0 end) as missing_billing_npi\n , max(case when m.facility_npi is null then 1 else 0 end) as missing_facility_npi\n\n , count(distinct m.rendering_npi) as rendering_npi_count\n , count(distinct m.billing_npi) as billing_npi_count\n , count(distinct m.facility_npi) as facility_npi_count\n\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_rendering_npi\n , max(case when term3.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_facility_npi\n\n from tuva.input_layer.medical_claim as m\n left join dev_thuxuan.terminology.provider as term\n on m.rendering_npi = term.npi\n left join dev_thuxuan.terminology.provider as term2\n on m.billing_npi = term2.npi\n left join dev_thuxuan.terminology.provider as term3\n on m.facility_npi = term3.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid rendering_npi' as data_quality_check\n , sum(invalid_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid billing_npi' as data_quality_check\n , sum(invalid_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid facility_npi' as data_quality_check\n , sum(invalid_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing rendering_npi' as data_quality_check\n , sum(missing_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing billing_npi' as data_quality_check\n , sum(missing_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing facility_npi' as data_quality_check\n , sum(missing_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type rendering_npi' as data_quality_check\n , sum(wrong_entity_type_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type facility_npi' as data_quality_check\n , sum(wrong_entity_type_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'multiple rendering_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere rendering_npi_count > 1\n\nunion all\n\nselect\n 'multiple billing_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere billing_npi_count > 1\n\nunion all\n\nselect\n 'multiple facility_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere facility_npi_count > 1\n)\n\nselect *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_date_checks", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__pharmacy_claim_date_checks.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__pharmacy_claim_date_checks.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_date_checks"], "alias": "pharmacy_claim_date_checks", "checksum": {"name": "sha256", "checksum": "b5085590b50fce7aa27d6008d9347a5a3de91fdd9a15b137e70cdbed0cd23856"}, "config": {"enabled": true, "alias": "pharmacy_claim_date_checks", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_date_checks", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.038048, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_date_checks", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith pharmacy_claim as (\r\n select\r\n claim_id\r\n , max(case when paid_date is null then 1 else 0 end) as missing_paid_date\r\n , max(case when dispensing_date is null then 1 else 0 end) as missing_dispensing_date\r\n from {{ ref('pharmacy_claim') }}\r\n group by\r\n claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'missing pharmacy_claim paid_date' as data_quality_check\r\n , sum(missing_paid_date) as result_count\r\n from pharmacy_claim\r\n\r\n union all\r\n\r\n select\r\n 'missing dispensing_date' as data_quality_check\r\n , sum(missing_dispensing_date) as result_count\r\n from pharmacy_claim\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__pharmacy_claim_date_checks.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when paid_date is null then 1 else 0 end) as missing_paid_date\n , max(case when dispensing_date is null then 1 else 0 end) as missing_dispensing_date\n from tuva.input_layer.pharmacy_claim\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing pharmacy_claim paid_date' as data_quality_check\n , sum(missing_paid_date) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing dispensing_date' as data_quality_check\n , sum(missing_dispensing_date) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_ndc": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_ndc", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__pharmacy_claim_ndc.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__pharmacy_claim_ndc.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_ndc"], "alias": "pharmacy_claim_ndc", "checksum": {"name": "sha256", "checksum": "a0c5c10f864d61f8f27ecdbf2294d8fa4cc8181f07fae3351637ec24977c3485"}, "config": {"enabled": true, "alias": "pharmacy_claim_ndc", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_ndc", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.040048, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_ndc", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith pharmacy_claim as (\r\n select\r\n claim_id\r\n , max(case when term.ndc is null and m.ndc_code is not null then 1 else 0 end) as invalid_ndc\r\n , max(case when m.ndc_code is null then 1 else 0 end) as missing_ndc\r\n from {{ ref('pharmacy_claim') }} m\r\n left join {{ ref('terminology__ndc') }} as term\r\n on m.ndc_code = term.ndc\r\n group by\r\n claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'missing ndc' as data_quality_check\r\n , sum(missing_ndc) as result_count\r\n from pharmacy_claim\r\n\r\n union all\r\n\r\n select\r\n 'invalid ndc' as data_quality_check\r\n , sum(invalid_ndc) as result_count\r\n from pharmacy_claim\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__pharmacy_claim_ndc.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when term.ndc is null and m.ndc_code is not null then 1 else 0 end) as invalid_ndc\n , max(case when m.ndc_code is null then 1 else 0 end) as missing_ndc\n from tuva.input_layer.pharmacy_claim m\n left join dev_thuxuan.terminology.ndc as term\n on m.ndc_code = term.ndc\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing ndc' as data_quality_check\n , sum(missing_ndc) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'invalid ndc' as data_quality_check\n , sum(invalid_ndc) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_npi": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_npi", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__pharmacy_claim_npi.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__pharmacy_claim_npi.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_npi", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_npi"], "alias": "pharmacy_claim_npi", "checksum": {"name": "sha256", "checksum": "e7c50070c0a2d86c0bb5fc79c4661d9e4463dc6847b4f25bc43635532540529b"}, "config": {"enabled": true, "alias": "pharmacy_claim_npi", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_npi", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0440478, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_npi", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n )\r\n}}\r\n\r\nwith pharmacy_claim as (\r\n select\r\n m.claim_id\r\n , max(case when term.npi is null and m.prescribing_provider_npi is not null then 1 else 0 end) as invalid_prescribing_npi\r\n , max(case when m.prescribing_provider_npi is null then 1 else 0 end) as missing_prescribing_npi\r\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_prescribing_npi\r\n , max(case when term2.npi is null and m.dispensing_provider_npi is not null then 1 else 0 end) as invalid_dispensing_npi\r\n , max(case when m.dispensing_provider_npi is null then 1 else 0 end) as missing_dispensing_npi\r\n , max(case when term2.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_dispensing_npi\r\n from {{ ref('pharmacy_claim') }} as m\r\n left join {{ ref('terminology__provider') }} as term\r\n on m.prescribing_provider_npi = term.npi\r\n left join {{ ref('terminology__provider') }} as term2\r\n on m.dispensing_provider_npi = term2.npi\r\n group by\r\n m.claim_id\r\n)\r\n\r\n,final as (\r\nselect\r\n 'invalid prescribing_npi' as data_quality_check\r\n , sum(invalid_prescribing_npi) as result_count\r\nfrom pharmacy_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'missing prescribing_npi' as data_quality_check\r\n , sum(missing_prescribing_npi) as result_count\r\nfrom pharmacy_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'wrong entity type prescribing_npi' as data_quality_check\r\n , sum(wrong_entity_type_prescribing_npi) as result_count\r\nfrom pharmacy_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'invalid dispensing_npi' as data_quality_check\r\n , sum(invalid_dispensing_npi) as result_count\r\nfrom pharmacy_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'missing dispensing_npi' as data_quality_check\r\n , sum(missing_dispensing_npi) as result_count\r\nfrom pharmacy_claim\r\n\r\nunion all\r\n\r\nselect\r\n 'wrong entity type dispensing_npi' as data_quality_check\r\n , sum(wrong_entity_type_dispensing_npi) as result_count\r\nfrom pharmacy_claim\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__pharmacy_claim_npi.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.prescribing_provider_npi is not null then 1 else 0 end) as invalid_prescribing_npi\n , max(case when m.prescribing_provider_npi is null then 1 else 0 end) as missing_prescribing_npi\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_prescribing_npi\n , max(case when term2.npi is null and m.dispensing_provider_npi is not null then 1 else 0 end) as invalid_dispensing_npi\n , max(case when m.dispensing_provider_npi is null then 1 else 0 end) as missing_dispensing_npi\n , max(case when term2.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_dispensing_npi\n from tuva.input_layer.pharmacy_claim as m\n left join dev_thuxuan.terminology.provider as term\n on m.prescribing_provider_npi = term.npi\n left join dev_thuxuan.terminology.provider as term2\n on m.dispensing_provider_npi = term2.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid prescribing_npi' as data_quality_check\n , sum(invalid_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing prescribing_npi' as data_quality_check\n , sum(missing_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type prescribing_npi' as data_quality_check\n , sum(wrong_entity_type_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'invalid dispensing_npi' as data_quality_check\n , sum(invalid_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing dispensing_npi' as data_quality_check\n , sum(missing_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type dispensing_npi' as data_quality_check\n , sum(wrong_entity_type_dispensing_npi) as result_count\nfrom pharmacy_claim\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_patient_id", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__pharmacy_claim_patient_id.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__pharmacy_claim_patient_id.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_patient_id"], "alias": "pharmacy_claim_patient_id", "checksum": {"name": "sha256", "checksum": "a7e63ac24d3fe87f5cef9463503575062fe3626b7544596099a665b8dff5790b"}, "config": {"enabled": true, "alias": "pharmacy_claim_patient_id", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_patient_id", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.036048, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_patient_id", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith pharmacy as (\r\n select\r\n claim_id\r\n , count(distinct p.patient_id) as patient_id_count\r\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\r\n , max(case when e.month_start_date is null then 1 else 0 end) as missing_eligibility\r\n from {{ ref('pharmacy_claim') }} p\r\n left join {{ ref('data_quality__eligibility_dq_stage') }} e\r\n on p.patient_id = e.patient_id\r\n and coalesce(p.paid_date, p.dispensing_date) between e.month_start_date and e.month_end_date\r\n group by\r\n claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'multiple pharmacy_claim patient_ids' as data_quality_check\r\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\r\n from pharmacy\r\n\r\n union all\r\n\r\n select\r\n 'missing pharmacy_claim patient_id' as data_quality_check\r\n , sum(missing_patient_id) as result_count\r\n from pharmacy\r\n\r\n union all\r\n\r\n select\r\n 'orphaned pharmacy_claim claims' as data_quality_check\r\n , sum(missing_eligibility) as result_count\r\n from pharmacy\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "data_quality__eligibility_dq_stage", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__pharmacy_claim_patient_id.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(case when e.month_start_date is null then 1 else 0 end) as missing_eligibility\n from tuva.input_layer.pharmacy_claim p\n left join dev_thuxuan.data_quality.data_quality__eligibility_dq_stage e\n on p.patient_id = e.patient_id\n and coalesce(p.paid_date, p.dispensing_date) between e.month_start_date and e.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple pharmacy_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from pharmacy\n\n union all\n\n select\n 'missing pharmacy_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from pharmacy\n\n union all\n\n select\n 'orphaned pharmacy_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from pharmacy\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__pharmacy_claim_prescription_details", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__pharmacy_claim_prescription_details.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__pharmacy_claim_prescription_details.sql", "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__pharmacy_claim_prescription_details"], "alias": "pharmacy_claim_prescription_details", "checksum": {"name": "sha256", "checksum": "b8900d873b9c68dac003be3a4273ab1484d7fda2c0795294aa7261880683dad8"}, "config": {"enabled": true, "alias": "pharmacy_claim_prescription_details", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "pharmacy_claim_prescription_details", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.042048, "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_prescription_details", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith pharmacy_claim as (\r\n select\r\n claim_id\r\n , max(case \r\n when quantity is null then 1\r\n when quantity = 0 then 1\r\n else 0\r\n end) as missing_quantity\r\n , max(case \r\n when days_supply is null then 1\r\n when days_supply = 0 then 1\r\n else 0\r\n end) as missing_days_supply\r\n , max(case \r\n when refills is null then 1\r\n else 0\r\n end) as missing_refills\r\n from {{ ref('pharmacy_claim') }} m\r\n group by\r\n claim_id\r\n)\r\n\r\n, final as (\r\n select\r\n 'missing quantity' as data_quality_check\r\n , sum(missing_quantity) as result_count\r\n from pharmacy_claim\r\n\r\n union all\r\n\r\n select\r\n 'missing days supply' as data_quality_check\r\n , sum(missing_days_supply) as result_count\r\n from pharmacy_claim\r\n\r\n union all\r\n\r\n select\r\n 'missing refills' as data_quality_check\r\n , sum(missing_refills) as result_count\r\n from pharmacy_claim\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__pharmacy_claim_prescription_details.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case \n when quantity is null then 1\n when quantity = 0 then 1\n else 0\n end) as missing_quantity\n , max(case \n when days_supply is null then 1\n when days_supply = 0 then 1\n else 0\n end) as missing_days_supply\n , max(case \n when refills is null then 1\n else 0\n end) as missing_refills\n from tuva.input_layer.pharmacy_claim m\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing quantity' as data_quality_check\n , sum(missing_quantity) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing days supply' as data_quality_check\n , sum(missing_days_supply) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing refills' as data_quality_check\n , sum(missing_refills) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__primary_key_check": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__primary_key_check", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__primary_key_check.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__primary_key_check.sql", "unique_id": "model.the_tuva_project.data_quality__primary_key_check", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__primary_key_check"], "alias": "primary_key_check", "checksum": {"name": "sha256", "checksum": "254b8da9f085250b9530b2bfca15c869e34ccd63558dbda4bdffe0def5002d28"}, "config": {"enabled": true, "alias": "primary_key_check", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "primary_key_check", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.049048, "relation_name": "dev_thuxuan.data_quality.primary_key_check", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n) }}\r\n\r\nwith pharmacy as (\r\n select\r\n claim_id\r\n , claim_line_number\r\n , data_source\r\n , count(*) as result_count\r\n from {{ ref('pharmacy_claim') }} p\r\n group by\r\n claim_id\r\n , claim_line_number\r\n , data_source\r\n having count(*) > 1\r\n)\r\n\r\n, medical as (\r\n select\r\n claim_id\r\n , claim_line_number\r\n , data_source\r\n , count(*) as result_count\r\n from {{ ref('medical_claim') }} p\r\n group by\r\n claim_id\r\n , claim_line_number\r\n , data_source\r\n having count(*) > 1\r\n)\r\n\r\n, eligibility as (\r\n select\r\n patient_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n , count(*) as result_count\r\n from {{ ref('eligibility') }} p\r\n group by\r\n patient_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n having count(*) > 1\r\n)\r\n\r\n, final as (\r\n select\r\n 'pk errors pharmacy claim' as data_quality_check\r\n , coalesce(sum(result_count), 0) as result_count\r\n from pharmacy\r\n\r\n union all\r\n\r\n select\r\n 'pk errors medical claim' as data_quality_check\r\n , coalesce(sum(result_count), 0) as result_count\r\n from medical\r\n\r\n union all\r\n\r\n select\r\n 'pk errors eligibility' as data_quality_check\r\n , coalesce(sum(result_count), 0) as result_count\r\n from eligibility\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "pharmacy_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.pharmacy_claim", "model.input_layer.medical_claim", "model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__primary_key_check.sql", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.pharmacy_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, medical as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.medical_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, eligibility as (\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n , count(*) as result_count\n from tuva.input_layer.eligibility p\n group by\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n having count(*) > 1\n)\n\n, final as (\n select\n 'pk errors pharmacy claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from pharmacy\n\n union all\n\n select\n 'pk errors medical claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from medical\n\n union all\n\n select\n 'pk errors eligibility' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from eligibility\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__quality_measures": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__quality_measures", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__quality_measures.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__quality_measures.sql", "unique_id": "model.the_tuva_project.data_quality__quality_measures", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__quality_measures"], "alias": "data_quality_quality_measures", "checksum": {"name": "sha256", "checksum": "a5f681e5d77ab4e4de1374d4da0d3fd1e217f16beceecdbd9fd4d03323f5fd0d"}, "config": {"enabled": true, "alias": "data_quality_quality_measures", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_quality_measures", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.086048, "relation_name": "dev_thuxuan.data_quality.data_quality_quality_measures", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\nselect sum(case when numerator_sum = 0 then 1 else 0 end) as numerator_zero_count\r\n,sum(case when denominator_sum = 0 then 1 else 0 end) as denominator_zero_count\r\nfrom {{ ref('quality_measures__summary_counts') }} \r\n)\r\n\r\n,final as (\r\nselect 'quality measure numerator zero' as data_quality_check\r\n,numerator_zero_count as result_count\r\nfrom cte \r\n\r\nunion all \r\n\r\nselect 'quality measure denominator zero' as data_quality_check\r\n,denominator_zero_count as result_count\r\nfrom cte\r\n)\r\n\r\nselect *\r\n, '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom final", "language": "sql", "refs": [{"name": "quality_measures__summary_counts", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__summary_counts"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__quality_measures.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect sum(case when numerator_sum = 0 then 1 else 0 end) as numerator_zero_count\n,sum(case when denominator_sum = 0 then 1 else 0 end) as denominator_zero_count\nfrom dev_thuxuan.quality_measures.summary_counts \n)\n\n,final as (\nselect 'quality measure numerator zero' as data_quality_check\n,numerator_zero_count as result_count\nfrom cte \n\nunion all \n\nselect 'quality measure denominator zero' as data_quality_check\n,denominator_zero_count as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__quality_measures_reference": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__quality_measures_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__quality_measures_reference.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__quality_measures_reference.sql", "unique_id": "model.the_tuva_project.data_quality__quality_measures_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__quality_measures_reference"], "alias": "data_quality_quality_measures_reference", "checksum": {"name": "sha256", "checksum": "41348b82fed3ea60fb4ab056a3302455746115b962d486c190f46652549a8379"}, "config": {"enabled": true, "alias": "data_quality_quality_measures_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_quality_measures_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0840478, "relation_name": "dev_thuxuan.data_quality.data_quality_quality_measures_reference", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\nselect \r\n cast('quality measures' as {{dbt.type_string()}}) as analytics_concept\r\n ,measure_name as analytics_measure\r\n ,performance_rate as data_source_value\r\nfrom {{ ref('quality_measures__summary_counts') }} r \r\n)\r\n\r\nselect \r\n m.analytics_concept as analytics_concept\r\n ,m.analytics_measure as analytics_measure\r\n ,cte.data_source_value\r\n ,m.analytics_value\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join cte on cte.analytics_measure = m.analytics_measure\r\nand\r\nm.analytics_concept = cte.analytics_concept\r\nwhere m.analytics_concept = cast('quality measures' as {{dbt.type_string()}})", "language": "sql", "refs": [{"name": "quality_measures__summary_counts", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__summary_counts", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__quality_measures_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('quality measures' as TEXT) as analytics_concept\n ,measure_name as analytics_measure\n ,performance_rate as data_source_value\nfrom dev_thuxuan.quality_measures.summary_counts r \n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('quality measures' as TEXT)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__readmissions": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__readmissions", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__readmissions.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__readmissions.sql", "unique_id": "model.the_tuva_project.data_quality__readmissions", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__readmissions"], "alias": "data_quality_readmissions", "checksum": {"name": "sha256", "checksum": "a219df65a2007ba1b63fdfb72b11ef73824d03a3254fba8a670604ccdd0b543e"}, "config": {"enabled": true, "alias": "data_quality_readmissions", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_readmissions", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0730486, "relation_name": "dev_thuxuan.data_quality.data_quality_readmissions", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\n\r\nwith disqualified_unpivot as (\r\n {{ dbt_utils.unpivot(\r\n relation=ref('readmissions__encounter_augmented'),\r\n cast_to=type_string(), \r\n exclude=['encounter_id'], \r\n field_name='disqualified_reason',\r\n value_name='flagvalue',\r\n remove=[\r\n 'encounter_id',\r\n 'patient_id',\r\n 'admit_date',\r\n 'discharge_date',\r\n 'discharge_disposition_code',\r\n 'facility_id',\r\n 'ms_drg_code',\r\n 'paid_amount',\r\n 'length_of_stay',\r\n 'index_admission_flag',\r\n 'planned_flag',\r\n 'specialty_cohort',\r\n 'died_flag',\r\n 'diagnosis_ccs',\r\n 'disqualified_encounter_flag',\r\n 'tuva_last_run'\r\n]\r\n ) }}\r\n)\r\n\r\n-- Using the transformed data to perform aggregation\r\nselect \r\n {{ dbt.concat([\"'inpatient encounter '\", \"d.disqualified_reason\"]) }} as data_quality_check\r\n , count(distinct encounter_id) as result_count\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom disqualified_unpivot d\r\nwhere cast(flagvalue as {{ dbt.type_int() }} ) = 1 \r\ngroup by disqualified_reason", "language": "sql", "refs": [{"name": "readmissions__encounter_augmented", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt_utils.unpivot", "macro.dbt.concat", "macro.dbt.type_int"], "nodes": ["model.the_tuva_project.readmissions__encounter_augmented"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__readmissions.sql", "compiled": true, "compiled_code": "\n\n\nwith disqualified_unpivot as (\n select\n encounter_id,\n\n cast('MISSING_ADMIT_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_ADMIT_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('ADMIT_AFTER_DISCHARGE_FLAG' as TEXT) as disqualified_reason,\n cast( \n ADMIT_AFTER_DISCHARGE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_PRIMARY_DIAGNOSIS_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_PRIMARY_DIAGNOSIS_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('NO_DIAGNOSIS_CCS_FLAG' as TEXT) as disqualified_reason,\n cast( \n NO_DIAGNOSIS_CCS_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG' as TEXT) as disqualified_reason,\n cast( \n OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n \n)\n\n-- Using the transformed data to perform aggregation\nselect \n 'inpatient encounter ' || d.disqualified_reason as data_quality_check\n , count(distinct encounter_id) as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom disqualified_unpivot d\nwhere cast(flagvalue as integer ) = 1 \ngroup by disqualified_reason", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__readmissions_reference": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__readmissions_reference", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__readmissions_reference.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__readmissions_reference.sql", "unique_id": "model.the_tuva_project.data_quality__readmissions_reference", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__readmissions_reference"], "alias": "data_quality_readmissions_reference", "checksum": {"name": "sha256", "checksum": "1b019e894074ce2c214434dfaebb5980c81e553520b9bd3a260b1aa9951561a7"}, "config": {"enabled": true, "alias": "data_quality_readmissions_reference", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "data_quality_readmissions_reference", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.075048, "relation_name": "dev_thuxuan.data_quality.data_quality_readmissions_reference", "raw_code": "{{ config(\r\n enabled = var('claims_enabled', var('tuva_marts_enabled', False)) | as_bool\r\n)}}\r\n\r\nwith cte as (\r\nselect \r\n cast('readmission rate' as {{dbt.type_string()}}) as analytics_measure\r\n ,cast('readmissions' as {{dbt.type_string()}}) as analytics_concept\r\n ,sum(unplanned_readmit_30_flag)/cast(count(*) as {{dbt.type_numeric() }} ) as data_source_value\r\nfrom {{ ref('readmissions__readmission_summary') }} r \r\nwhere index_admission_flag = 1\r\n)\r\n\r\nselect \r\n m.analytics_concept as analytics_concept\r\n ,m.analytics_measure as analytics_measure\r\n ,cte.data_source_value\r\n ,m.analytics_value\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('data_quality__reference_mart_analytics') }} m \r\nleft join cte on cte.analytics_measure = m.analytics_measure\r\nand\r\nm.analytics_concept = cte.analytics_concept\r\nwhere m.analytics_concept = cast('readmissions' as {{dbt.type_string()}})", "language": "sql", "refs": [{"name": "readmissions__readmission_summary", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.readmissions__readmission_summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__readmissions_reference.sql", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('readmission rate' as TEXT) as analytics_measure\n ,cast('readmissions' as TEXT) as analytics_concept\n ,sum(unplanned_readmit_30_flag)/cast(count(*) as numeric(28,6) ) as data_source_value\nfrom dev_thuxuan.readmissions.readmission_summary r \nwhere index_admission_flag = 1\n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('readmissions' as TEXT)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__service_categories_pmpm": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__service_categories_pmpm", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\intermediate\\data_quality__service_categories_pmpm.sql", "original_file_path": "models\\data_quality\\intermediate\\data_quality__service_categories_pmpm.sql", "unique_id": "model.the_tuva_project.data_quality__service_categories_pmpm", "fqn": ["the_tuva_project", "data_quality", "intermediate", "data_quality__service_categories_pmpm"], "alias": "service_categories_pmpm", "checksum": {"name": "sha256", "checksum": "64a7156a1a0eac313cc3f10656c0d156ec2b51e7a216098c2eddaa6f58809f57"}, "config": {"enabled": true, "alias": "service_categories_pmpm", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "alias": "service_categories_pmpm", "tags": ["data_quality_audit"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.0770543, "relation_name": "dev_thuxuan.data_quality.service_categories_pmpm", "raw_code": "{{ config(enabled = var('claims_enabled', var('tuva_marts_enabled', false)) | as_bool) }}\r\n\r\nwith member_months as (\r\n select\r\n count(1) as member_months\r\n from {{ ref('core__member_months') }} mm\r\n)\r\n\r\n, pmpm as (\r\n select\r\n cast('service categories pmpm' as {{dbt.type_string() }} ) as analytics_concept\r\n , mc.service_category_2 as analytics_measure\r\n , sum(mc.paid_amount) as total_paid\r\n , avg(mm.member_months) as member_months\r\n , case when avg(mm.member_months) = 0 then null\r\n else sum(mc.paid_amount) / avg(mm.member_months)\r\n end as data_source_value\r\n from {{ ref('core__medical_claim') }} mc\r\n cross join member_months mm\r\n group by\r\n mc.service_category_2\r\n)\r\n\r\nselect\r\n pmpm.*\r\n , ref_data.analytics_value\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom pmpm\r\nleft join {{ ref('data_quality__reference_mart_analytics') }} ref_data\r\n on pmpm.analytics_concept = ref_data.analytics_concept\r\n and pmpm.analytics_measure = ref_data.analytics_measure", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "core__medical_claim", "package": null, "version": null}, {"name": "data_quality__reference_mart_analytics", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.data_quality__reference_mart_analytics"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\intermediate\\data_quality__service_categories_pmpm.sql", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n count(1) as member_months\n from dev_thuxuan.core.member_months mm\n)\n\n, pmpm as (\n select\n cast('service categories pmpm' as TEXT ) as analytics_concept\n , mc.service_category_2 as analytics_measure\n , sum(mc.paid_amount) as total_paid\n , avg(mm.member_months) as member_months\n , case when avg(mm.member_months) = 0 then null\n else sum(mc.paid_amount) / avg(mm.member_months)\n end as data_source_value\n from dev_thuxuan.core.medical_claim mc\n cross join member_months mm\n group by\n mc.service_category_2\n)\n\nselect\n pmpm.*\n , ref_data.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pmpm\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data\n on pmpm.analytics_concept = ref_data.analytics_concept\n and pmpm.analytics_measure = ref_data.analytics_measure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__eligibility_dq_stage": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__eligibility_dq_stage", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\stage\\data_quality__eligibility_dq_stage.sql", "original_file_path": "models\\data_quality\\stage\\data_quality__eligibility_dq_stage.sql", "unique_id": "model.the_tuva_project.data_quality__eligibility_dq_stage", "fqn": ["the_tuva_project", "data_quality", "stage", "data_quality__eligibility_dq_stage"], "alias": "data_quality__eligibility_dq_stage", "checksum": {"name": "sha256", "checksum": "08da325b084c50fff4f484599d88146d12e29c37bffce7332c7d864cf649a31b"}, "config": {"enabled": true, "alias": null, "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "tags": ["data_quality_audit"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.1030529, "relation_name": "dev_thuxuan.data_quality.data_quality__eligibility_dq_stage", "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\nwith month_start_and_end_dates as (\r\n select\r\n year_month_int as year_month\r\n , min(full_date) as month_start_date\r\n , max(full_date) as month_end_date\r\n from {{ ref('reference_data__calendar')}}\r\n group by year_month_int\r\n)\r\n\r\nselect distinct\r\n a.patient_id\r\n , b.year_month\r\n , b.month_start_date\r\n , b.month_end_date\r\n , a.payer\r\n , a.{{ quote_column('plan') }}\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('eligibility') }} a\r\ninner join month_start_and_end_dates b\r\n on a.enrollment_start_date <= b.month_end_date\r\n and a.enrollment_end_date >= b.month_start_date", "language": "sql", "refs": [{"name": "reference_data__calendar", "package": null, "version": null}, {"name": "eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["seed.the_tuva_project.reference_data__calendar", "model.input_layer.eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\stage\\data_quality__eligibility_dq_stage.sql", "compiled": true, "compiled_code": "\n\nwith month_start_and_end_dates as (\n select\n year_month_int as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from dev_thuxuan.reference_data.calendar\n group by year_month_int\n)\n\nselect distinct\n a.patient_id\n , b.year_month\n , b.month_start_date\n , b.month_end_date\n , a.payer\n , a.plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.data_quality__inpatient_dq_stage": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__inpatient_dq_stage", "resource_type": "model", "package_name": "the_tuva_project", "path": "data_quality\\stage\\data_quality__inpatient_dq_stage.sql", "original_file_path": "models\\data_quality\\stage\\data_quality__inpatient_dq_stage.sql", "unique_id": "model.the_tuva_project.data_quality__inpatient_dq_stage", "fqn": ["the_tuva_project", "data_quality", "stage", "data_quality__inpatient_dq_stage"], "alias": "data_quality__inpatient_dq_stage", "checksum": {"name": "sha256", "checksum": "07d1873d8e414f4b0473f4e401feaf597f17b1e9f64369c989404a07b9a66347"}, "config": {"enabled": true, "alias": null, "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["data_quality_audit"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\data_quality\\data_quality_models.yml", "build_path": null, "unrendered_config": {"schema": "data_quality", "tags": ["data_quality_audit"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.105557, "relation_name": "dev_thuxuan.data_quality.data_quality__inpatient_dq_stage", "raw_code": "{{ config(\r\n enabled = var('claims_preprocessing_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith drg_requirement as (\r\n select distinct\r\n mc.claim_id\r\n from {{ ref('medical_claim') }} as mc\r\n left join {{ ref('terminology__ms_drg') }} as msdrg\r\n on mc.ms_drg_code = msdrg.ms_drg_code\r\n left join {{ ref('terminology__apr_drg') }} as aprdrg\r\n on mc.apr_drg_code = aprdrg.apr_drg_code\r\n where mc.claim_type = 'institutional'\r\n and (\r\n msdrg.ms_drg_code is not null\r\n or aprdrg.apr_drg_code is not null\r\n )\r\n)\r\n\r\n, bill_type_requirement as (\r\n select distinct\r\n claim_id\r\n from {{ ref('medical_claim') }}\r\n where claim_type = 'institutional'\r\n and substring(bill_type_code, 1, 2) in (\r\n '11' -- hospital inpatient \r\n , '12' -- hospital inpatient \r\n )\r\n)\r\n\r\nselect distinct\r\n a.claim_id\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('medical_claim') }} as a\r\ninner join bill_type_requirement as d\r\n on a.claim_id = d.claim_id\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect distinct\r\n a.claim_id\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('medical_claim') }} as a\r\ninner join drg_requirement as c\r\n on a.claim_id = c.claim_id", "language": "sql", "refs": [{"name": "medical_claim", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}, {"name": "terminology__apr_drg", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}, {"name": "medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__apr_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\stage\\data_quality__inpatient_dq_stage.sql", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from tuva.input_layer.medical_claim as mc\n left join dev_thuxuan.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join dev_thuxuan.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n )\n)\n\nselect distinct\n a.claim_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__summary": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification\\final\\ed_classification__summary.sql", "original_file_path": "models\\ed_classification\\final\\ed_classification__summary.sql", "unique_id": "model.the_tuva_project.ed_classification__summary", "fqn": ["the_tuva_project", "ed_classification", "final", "ed_classification__summary"], "alias": "summary", "checksum": {"name": "sha256", "checksum": "1399c187e04c725c688bee9b7084f8b29c6cd04bb4249897f44c5296eede509a"}, "config": {"enabled": true, "alias": "summary", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "ED Classification as a cube that can be summarized\n", "columns": {"encounter_id": {"name": "encounter_id", "description": "Unique identifier for the emergency_department encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_classification_description": {"name": "ed_classification_description", "description": "ED classification category.", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/ed_classification/ed_classification__categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ed_classification_order": {"name": "ed_classification_order", "description": "The order of the classification.", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/ed_classification/ed_classification__categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "Date when the patient was discharged.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Year and month of the encounter end date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_code": {"name": "primary_diagnosis_code", "description": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim.\n", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_diagnosis_description": {"name": "primary_diagnosis_description", "description": "Description of the primary diagnosis code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The total paid amount across all claims for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "The total allowed amount across all claims for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "charge_amount": {"name": "charge_amount", "description": "The total charge amount across all claims for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "The ID for the facility where the encounter occurred.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_name": {"name": "facility_name", "description": "The name of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_state": {"name": "facility_state", "description": "The state of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_city": {"name": "facility_city", "description": "The city of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_zip_code": {"name": "facility_zip_code", "description": "The zip code of the facility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_sex": {"name": "patient_sex", "description": "The sex of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_age": {"name": "patient_age", "description": "The age of the patient at the time of the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_zip_code": {"name": "patient_zip_code", "description": "The zip code for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_latitude": {"name": "patient_latitude", "description": "The latitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_longitude": {"name": "patient_longitude", "description": "The longitude for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_race": {"name": "patient_race", "description": "The race of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__race.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ed_classification\\ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "alias": "summary", "tags": "ed_classification", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.819649, "relation_name": "dev_thuxuan.ed_classification.summary", "raw_code": "{{ config(\r\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\nselect\r\n class.encounter_id\r\n , cat.classification_name as ed_classification_description\r\n , cat.classification_order as ed_classification_order\r\n , class.patient_id\r\n , class.encounter_end_date\r\n , {{ dbt.concat([date_part('year', 'class.encounter_end_date'),\r\n dbt.right(\r\n dbt.concat([\"'00'\", date_part('month', 'class.encounter_end_date')])\r\n , 2)]) }} as year_month\r\n , class.primary_diagnosis_code\r\n , class.primary_diagnosis_description\r\n , class.paid_amount\r\n , class.allowed_amount\r\n , class.charge_amount\r\n , class.facility_id\r\n , fac_prov.provider_organization_name as facility_name\r\n , practice_state as facility_state\r\n , practice_city as facility_city\r\n , practice_zip_code as facility_zip_code\r\n , pat.sex as patient_sex\r\n , floor({{ datediff('pat.birth_date', 'class.encounter_end_date', 'hour') }} / 8766.0) as patient_age\r\n , zip_code as patient_zip_code\r\n , latitude as patient_latitude\r\n , longitude as patient_longitude\r\n , race as patient_race\r\nfrom {{ ref('ed_classification__int_filter_encounter_with_classification') }} class\r\ninner join {{ ref('ed_classification__categories') }} cat\r\n on class.classification = cat.classification\r\nleft join {{ ref('terminology__provider') }} fac_prov \r\n on class.facility_id = fac_prov.npi\r\nleft join {{ ref('ed_classification__stg_patient') }} pat\r\n on class.patient_id = pat.patient_id", "language": "sql", "refs": [{"name": "ed_classification__int_filter_encounter_with_classification", "package": null, "version": null}, {"name": "ed_classification__categories", "package": null, "version": null}, {"name": "terminology__provider", "package": null, "version": null}, {"name": "ed_classification__stg_patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.right", "macro.dbt.datediff"], "nodes": ["model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "seed.the_tuva_project.ed_classification__categories", "seed.the_tuva_project.terminology__provider", "model.the_tuva_project.ed_classification__stg_patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ed_classification\\final\\ed_classification__summary.sql", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__ed_classification__stg_patient as (\n\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom dev_thuxuan.core.patient\n) select\n class.encounter_id\n , cat.classification_name as ed_classification_description\n , cat.classification_order as ed_classification_order\n , class.patient_id\n , class.encounter_end_date\n , date_part('year', class.encounter_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '00' || date_part('month', class.encounter_end_date),\n 2\n )\n end as year_month\n , class.primary_diagnosis_code\n , class.primary_diagnosis_description\n , class.paid_amount\n , class.allowed_amount\n , class.charge_amount\n , class.facility_id\n , fac_prov.provider_organization_name as facility_name\n , practice_state as facility_state\n , practice_city as facility_city\n , practice_zip_code as facility_zip_code\n , pat.sex as patient_sex\n , floor(datediff(\n hour,\n pat.birth_date,\n class.encounter_end_date\n ) / 8766.0) as patient_age\n , zip_code as patient_zip_code\n , latitude as patient_latitude\n , longitude as patient_longitude\n , race as patient_race\nfrom dev_thuxuan.ed_classification._int_filter_encounter_with_classification class\ninner join dev_thuxuan.ed_classification._value_set_categories cat\n on class.classification = cat.classification\nleft join dev_thuxuan.terminology.provider fac_prov \n on class.facility_id = fac_prov.npi\nleft join __dbt__cte__ed_classification__stg_patient pat\n on class.patient_id = pat.patient_id", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ed_classification__stg_patient", "sql": " __dbt__cte__ed_classification__stg_patient as (\n\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__int_filter_encounter_with_classification", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification\\intermediate\\ed_classification__int_filter_encounter_with_classification.sql", "original_file_path": "models\\ed_classification\\intermediate\\ed_classification__int_filter_encounter_with_classification.sql", "unique_id": "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "fqn": ["the_tuva_project", "ed_classification", "intermediate", "ed_classification__int_filter_encounter_with_classification"], "alias": "_int_filter_encounter_with_classification", "checksum": {"name": "sha256", "checksum": "957e5c16209eec1ea32bacfe72782ba0e54835625b1bd7cbfde214edc2466b6f"}, "config": {"enabled": true, "alias": "_int_filter_encounter_with_classification", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "Filter out ED visits that were not classified", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ed_classification\\ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "alias": "_int_filter_encounter_with_classification", "tags": "ed_classification", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8216493, "relation_name": "dev_thuxuan.ed_classification._int_filter_encounter_with_classification", "raw_code": "/*\r\nFilter conditions to those that were classified and pick the classification\r\nwith the greatest probability (that's the greatest logic). This logic removes\r\nany rows that were not classified.\r\n*/\r\n{{ config(\r\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n a.*\r\n , case greatest(edcnnpa, edcnpa, epct, noner, injury, psych, alcohol, drug)\r\n when edcnnpa then 'edcnnpa'\r\n when edcnpa then 'edcnpa'\r\n when epct then 'epct'\r\n when noner then 'noner'\r\n when injury then 'injury'\r\n when psych then 'psych'\r\n when alcohol then 'alcohol'\r\n when drug then 'drug'\r\n else 'unclassified'\r\n end as classification\r\nfrom {{ ref('ed_classification__int_map_primary_dx') }} a\r\nwhere ed_classification_capture = 1", "language": "sql", "refs": [{"name": "ed_classification__int_map_primary_dx", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ed_classification__int_map_primary_dx"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ed_classification\\intermediate\\ed_classification__int_filter_encounter_with_classification.sql", "compiled": true, "compiled_code": "/*\nFilter conditions to those that were classified and pick the classification\nwith the greatest probability (that's the greatest logic). This logic removes\nany rows that were not classified.\n*/\n\n\nselect\n a.*\n , case greatest(edcnnpa, edcnpa, epct, noner, injury, psych, alcohol, drug)\n when edcnnpa then 'edcnnpa'\n when edcnpa then 'edcnpa'\n when epct then 'epct'\n when noner then 'noner'\n when injury then 'injury'\n when psych then 'psych'\n when alcohol then 'alcohol'\n when drug then 'drug'\n else 'unclassified'\n end as classification\nfrom dev_thuxuan.ed_classification._int_by_provider_parent_organization a\nwhere ed_classification_capture = 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__int_map_primary_dx": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__int_map_primary_dx", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification\\intermediate\\ed_classification__int_map_primary_dx.sql", "original_file_path": "models\\ed_classification\\intermediate\\ed_classification__int_map_primary_dx.sql", "unique_id": "model.the_tuva_project.ed_classification__int_map_primary_dx", "fqn": ["the_tuva_project", "ed_classification", "intermediate", "ed_classification__int_map_primary_dx"], "alias": "_int_by_provider_parent_organization", "checksum": {"name": "sha256", "checksum": "0877b4a072661d4cfb43b0be26e3085401e870f4d2df058815f590467c8fcbe7"}, "config": {"enabled": true, "alias": "_int_by_provider_parent_organization", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "Map ED encounter primary dx to classification", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ed_classification\\ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "alias": "_int_by_provider_parent_organization", "tags": "ed_classification", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8236492, "relation_name": "dev_thuxuan.ed_classification._int_by_provider_parent_organization", "raw_code": "/*\r\nAll condition discharge diagnosis left join with probabilistic\r\nindicators of ED classification terminology\r\n*/\r\n\r\n{{ config(\r\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n{% set colnames = [\"edcnnpa\", \"edcnpa\", \"epct\", \"noner\", \"injury\", \"psych\", \"alcohol\", \"drug\"] %}\r\n\r\nwith condition as (\r\n select * \r\n from {{ ref('ed_classification__stg_encounter') }}\r\n where encounter_type = 'emergency department'\r\n)\r\n, icd9 as (\r\n select\r\n icd9 as code\r\n {% for colname in colnames %}\r\n , {{colname}}\r\n {% endfor %}\r\n , 1 as ed_classification_capture\r\n from {{ ref('ed_classification__johnston_icd9') }}\r\n)\r\n, icd10 as (\r\n select\r\n icd10 as code\r\n {% for colname in colnames %}\r\n , {{colname}}\r\n {% endfor %}\r\n , 1 as ed_classification_capture\r\n from {{ ref('ed_classification__johnston_icd10') }}\r\n)\r\n\r\nselect\r\n a.*\r\n {% for colname in colnames %}\r\n , icd10.{{colname}}\r\n {% endfor %}\r\n , coalesce(icd10.ed_classification_capture, 0) as ed_classification_capture\r\nfrom condition a\r\nleft join icd10\r\n on a.primary_diagnosis_code = icd10.code \r\n and a.primary_diagnosis_code_type = 'icd-10-cm'\r\n\r\nunion all\r\n\r\nselect\r\n a.*\r\n {% for colname in colnames %}\r\n , icd9.{{colname}}\r\n {% endfor %}\r\n , coalesce(icd9.ed_classification_capture, 0) ed_classification_capture\r\nfrom condition a\r\ninner join icd9\r\n on a.primary_diagnosis_code = icd9.code \r\n and a.primary_diagnosis_code_type = 'icd-9-cm'", "language": "sql", "refs": [{"name": "ed_classification__stg_encounter", "package": null, "version": null}, {"name": "ed_classification__johnston_icd9", "package": null, "version": null}, {"name": "ed_classification__johnston_icd10", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.ed_classification__stg_encounter", "seed.the_tuva_project.ed_classification__johnston_icd9", "seed.the_tuva_project.ed_classification__johnston_icd10"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ed_classification\\intermediate\\ed_classification__int_map_primary_dx.sql", "compiled": true, "compiled_code": "/*\nAll condition discharge diagnosis left join with probabilistic\nindicators of ED classification terminology\n*/\n\n\n\n\nwith __dbt__cte__ed_classification__stg_encounter as (\n\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom dev_thuxuan.core.encounter\n), condition as (\n select * \n from __dbt__cte__ed_classification__stg_encounter\n where encounter_type = 'emergency department'\n)\n, icd9 as (\n select\n icd9 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from dev_thuxuan.ed_classification._value_set_johnston_icd9\n)\n, icd10 as (\n select\n icd10 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from dev_thuxuan.ed_classification._value_set_johnston_icd10\n)\n\nselect\n a.*\n \n , icd10.edcnnpa\n \n , icd10.edcnpa\n \n , icd10.epct\n \n , icd10.noner\n \n , icd10.injury\n \n , icd10.psych\n \n , icd10.alcohol\n \n , icd10.drug\n \n , coalesce(icd10.ed_classification_capture, 0) as ed_classification_capture\nfrom condition a\nleft join icd10\n on a.primary_diagnosis_code = icd10.code \n and a.primary_diagnosis_code_type = 'icd-10-cm'\n\nunion all\n\nselect\n a.*\n \n , icd9.edcnnpa\n \n , icd9.edcnpa\n \n , icd9.epct\n \n , icd9.noner\n \n , icd9.injury\n \n , icd9.psych\n \n , icd9.alcohol\n \n , icd9.drug\n \n , coalesce(icd9.ed_classification_capture, 0) ed_classification_capture\nfrom condition a\ninner join icd9\n on a.primary_diagnosis_code = icd9.code \n and a.primary_diagnosis_code_type = 'icd-9-cm'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.ed_classification__stg_encounter", "sql": " __dbt__cte__ed_classification__stg_encounter as (\n\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom dev_thuxuan.core.encounter\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__stg_encounter": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__stg_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification\\staging\\ed_classification__stg_encounter.sql", "original_file_path": "models\\ed_classification\\staging\\ed_classification__stg_encounter.sql", "unique_id": "model.the_tuva_project.ed_classification__stg_encounter", "fqn": ["the_tuva_project", "ed_classification", "staging", "ed_classification__stg_encounter"], "alias": "ed_classification__stg_encounter", "checksum": {"name": "sha256", "checksum": "721e215ce66c7aae05a3a7609ea562512c353d3dfb95175ee3b2ccd2b4af6fce"}, "config": {"enabled": true, "alias": null, "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ed_classification\\ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "tags": "ed_classification", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8256495, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r\n | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n encounter_id\r\n , encounter_type\r\n , patient_id\r\n , encounter_end_date\r\n , facility_id\r\n , primary_diagnosis_code_type\r\n , primary_diagnosis_code\r\n , primary_diagnosis_description\r\n , paid_amount\r\n , allowed_amount\r\n , charge_amount\r\nfrom {{ ref('core__encounter') }}", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ed_classification\\staging\\ed_classification__stg_encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom dev_thuxuan.core.encounter", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.ed_classification__stg_patient": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__stg_patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "ed_classification\\staging\\ed_classification__stg_patient.sql", "original_file_path": "models\\ed_classification\\staging\\ed_classification__stg_patient.sql", "unique_id": "model.the_tuva_project.ed_classification__stg_patient", "fqn": ["the_tuva_project", "ed_classification", "staging", "ed_classification__stg_patient"], "alias": "ed_classification__stg_patient", "checksum": {"name": "sha256", "checksum": "93bf9eadd001ac5f3e55956ede7e67da0b6f74958c993f297531954824a8e919"}, "config": {"enabled": true, "alias": null, "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["ed_classification"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\ed_classification\\ed_classification_models.yml", "build_path": null, "unrendered_config": {"schema": "ed_classification", "tags": "ed_classification", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8276496, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('ed_classification_enabled',var('claims_enabled',var('tuva_marts_enabled',False)))\r | as_bool\n )\r\n}}\r\n\r\nselect\r\n patient_id\r\n , sex\r\n , birth_date\r\n , race\r\n , state\r\n , zip_code\r\n , latitude\r\n , longitude\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\ed_classification\\staging\\ed_classification__stg_patient.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__pmpm_payer": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__pmpm_payer", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\final\\financial_pmpm__pmpm_payer.sql", "original_file_path": "models\\financial_pmpm\\final\\financial_pmpm__pmpm_payer.sql", "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer", "fqn": ["the_tuva_project", "financial_pmpm", "final", "financial_pmpm__pmpm_payer"], "alias": "pmpm_payer", "checksum": {"name": "sha256", "checksum": "30a7456690893e650d2c6aa974ed28183664b4ab7e5be08f1679450fffc4e450"}, "config": {"enabled": true, "alias": "pmpm_payer", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Computes per member per month statistics for every service category by aggregating across patients from pmpm_prep. This version of the table computes at the payer grain.\n", "columns": {"year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "The sum of member months.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid": {"name": "total_paid", "description": "Total paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid": {"name": "medical_paid", "description": "Total medical paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_paid": {"name": "inpatient_paid", "description": "Total inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_paid": {"name": "outpatient_paid", "description": "Total outpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid": {"name": "office_visit_paid", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_paid": {"name": "ancillary_paid", "description": "Total ancillary paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid": {"name": "pharmacy_paid", "description": "Total pharmacy paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_paid": {"name": "other_paid", "description": "Total other paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_paid": {"name": "acute_inpatient_paid", "description": "Total acute inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_paid": {"name": "ambulance_paid", "description": "Total ambulance paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_paid": {"name": "ambulatory_surgery_paid", "description": "Total ambulatory surgery paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_paid": {"name": "dialysis_paid", "description": "Total dialysis paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_paid": {"name": "durable_medical_equipment_paid", "description": "Total durable medical equipment paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_paid": {"name": "emergency_department_paid", "description": "Total emergency department paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_paid": {"name": "home_health_paid", "description": "Total home health paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_paid": {"name": "hospice_paid", "description": "Total hospice paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_paid": {"name": "inpatient_psychiatric_paid", "description": "Total inpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_paid": {"name": "inpatient_rehabilitation_paid", "description": "Total inpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_paid": {"name": "lab_paid", "description": "Total lab paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid_2": {"name": "office_visit_paid_2", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_paid": {"name": "outpatient_hospital_or_clinic_paid", "description": "Total outpatient hospital or clinic paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_paid": {"name": "outpatient_psychiatric_paid", "description": "Total outpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_paid": {"name": "outpatient_rehabilitation_paid", "description": "Total outpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_paid": {"name": "skilled_nursing_paid", "description": "Total skilled nursing paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_paid": {"name": "urgent_care_paid", "description": "Total urgent care paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed": {"name": "total_allowed", "description": "Total allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_allowed": {"name": "medical_allowed", "description": "Total medical allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_allowed": {"name": "inpatient_allowed", "description": "Total inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_allowed": {"name": "outpatient_allowed", "description": "Total outpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed": {"name": "office_visit_allowed", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_allowed": {"name": "ancillary_allowed", "description": "Total ancillary allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_allowed": {"name": "pharmacy_allowed", "description": "Total pharmacy allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_allowed": {"name": "other_allowed", "description": "Total other allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_allowed": {"name": "acute_inpatient_allowed", "description": "Total acute inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_allowed": {"name": "ambulance_allowed", "description": "Total ambulance allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_allowed": {"name": "ambulatory_surgery_allowed", "description": "Total ambulatory surgery allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_allowed": {"name": "dialysis_allowed", "description": "Total dialysis allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_allowed": {"name": "durable_medical_equipment_allowed", "description": "Total durable medical equipment allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_allowed": {"name": "emergency_department_allowed", "description": "Total emergency department allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_allowed": {"name": "home_health_allowed", "description": "Total home health allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_allowed": {"name": "hospice_allowed", "description": "Total hospice allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_allowed": {"name": "inpatient_psychiatric_allowed", "description": "Total inpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_allowed": {"name": "inpatient_rehabilitation_allowed", "description": "Total inpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_allowed": {"name": "lab_allowed", "description": "Total lab allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed_2": {"name": "office_visit_allowed_2", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_allowed": {"name": "outpatient_hospital_or_clinic_allowed", "description": "Total outpatient hospital or clinic allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_allowed": {"name": "outpatient_psychiatric_allowed", "description": "Total outpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_allowed": {"name": "outpatient_rehabilitation_allowed", "description": "Total outpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_allowed": {"name": "skilled_nursing_allowed", "description": "Total skilled nursing allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_allowed": {"name": "urgent_care_allowed", "description": "Total urgent care allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "pmpm_payer", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8496485, "relation_name": "dev_thuxuan.financial_pmpm.pmpm_payer", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n)}}\r\n\r\nselect\r\n year_month\r\n , payer\r\n , data_source\r\n , count(1) as member_months\r\n , sum(total_paid) / count(1) as total_paid\r\n , sum(medical_paid) / count(1) as medical_paid\r\n , sum(inpatient_paid) / count(1) as inpatient_paid\r\n , sum(outpatient_paid) / count(1) as outpatient_paid\r\n , sum(office_based_paid) / count(1) as office_based_paid\r\n , sum(ancillary_paid) / count(1) as ancillary_paid\r\n , sum(other_paid) / count(1) as other_paid\r\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\r\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\r\n , sum(ambulance_paid) / count(1) as ambulance_paid\r\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\r\n , sum(dialysis_paid) / count(1) as dialysis_paid\r\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\r\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\r\n , sum(home_health_paid) / count(1) as home_health_paid\r\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\r\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\r\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\r\n , sum(lab_paid) / count(1) as lab_paid\r\n , sum(observation_paid) / count(1) as observation_paid\r\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\r\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\r\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\r\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\r\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\r\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\r\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\r\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\r\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\r\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\r\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\r\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\r\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\r\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\r\n , sum(total_allowed) / count(1) as total_allowed\r\n , sum(medical_allowed) / count(1) as medical_allowed\r\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\r\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\r\n , sum(office_based_allowed) / count(1) as office_based_allowed\r\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\r\n , sum(other_allowed) / count(1) as other_allowed\r\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\r\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\r\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\r\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\r\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\r\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\r\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\r\n , sum(home_health_allowed) / count(1) as home_health_allowed\r\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\r\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\r\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\r\n , sum(lab_allowed) / count(1) as lab_allowed\r\n , sum(observation_allowed) / count(1) as observation_allowed\r\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\r\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\r\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\r\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\r\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\r\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\r\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\r\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\r\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\r\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\r\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\r\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\r\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\r\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom {{ ref('financial_pmpm__pmpm_prep') }} a\r\ngroup by\r\n year_month\r\n, payer\r\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\final\\financial_pmpm__pmpm_payer.sql", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n, payer\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__pmpm_payer_plan", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\final\\financial_pmpm__pmpm_payer_plan.sql", "original_file_path": "models\\financial_pmpm\\final\\financial_pmpm__pmpm_payer_plan.sql", "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer_plan", "fqn": ["the_tuva_project", "financial_pmpm", "final", "financial_pmpm__pmpm_payer_plan"], "alias": "pmpm_payer_plan", "checksum": {"name": "sha256", "checksum": "ea95dc8f914ccc76b3224729740c2bc979c84b8bed3547c9e0662004bf5525c5"}, "config": {"enabled": true, "alias": "pmpm_payer_plan", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Computes per member per month statistics for every service category by aggregating across patients from pmpm_prep. This version of the table computes at the payer and plan grain.\n", "columns": {"year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_months": {"name": "member_months", "description": "The sum of member months.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid": {"name": "total_paid", "description": "Total paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid": {"name": "medical_paid", "description": "Total medical paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_paid": {"name": "inpatient_paid", "description": "Total inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_paid": {"name": "outpatient_paid", "description": "Total outpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid": {"name": "office_visit_paid", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_paid": {"name": "ancillary_paid", "description": "Total ancillary paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid": {"name": "pharmacy_paid", "description": "Total pharmacy paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_paid": {"name": "other_paid", "description": "Total other paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_paid": {"name": "acute_inpatient_paid", "description": "Total acute inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_paid": {"name": "ambulance_paid", "description": "Total ambulance paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_paid": {"name": "ambulatory_surgery_paid", "description": "Total ambulatory surgery paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_paid": {"name": "dialysis_paid", "description": "Total dialysis paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_paid": {"name": "durable_medical_equipment_paid", "description": "Total durable medical equipment paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_paid": {"name": "emergency_department_paid", "description": "Total emergency department paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_paid": {"name": "home_health_paid", "description": "Total home health paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_paid": {"name": "hospice_paid", "description": "Total hospice paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_paid": {"name": "inpatient_psychiatric_paid", "description": "Total inpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_paid": {"name": "inpatient_rehabilitation_paid", "description": "Total inpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_paid": {"name": "lab_paid", "description": "Total lab paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid_2": {"name": "office_visit_paid_2", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_paid": {"name": "outpatient_hospital_or_clinic_paid", "description": "Total outpatient hospital or clinic paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_paid": {"name": "outpatient_psychiatric_paid", "description": "Total outpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_paid": {"name": "outpatient_rehabilitation_paid", "description": "Total outpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_paid": {"name": "skilled_nursing_paid", "description": "Total skilled nursing paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_paid": {"name": "urgent_care_paid", "description": "Total urgent care paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed": {"name": "total_allowed", "description": "Total allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_allowed": {"name": "medical_allowed", "description": "Total medical allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_allowed": {"name": "inpatient_allowed", "description": "Total inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_allowed": {"name": "outpatient_allowed", "description": "Total outpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed": {"name": "office_visit_allowed", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_allowed": {"name": "ancillary_allowed", "description": "Total ancillary allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_allowed": {"name": "pharmacy_allowed", "description": "Total pharmacy allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_allowed": {"name": "other_allowed", "description": "Total other allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_allowed": {"name": "acute_inpatient_allowed", "description": "Total acute inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_allowed": {"name": "ambulance_allowed", "description": "Total ambulance allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_allowed": {"name": "ambulatory_surgery_allowed", "description": "Total ambulatory surgery allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_allowed": {"name": "dialysis_allowed", "description": "Total dialysis allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_allowed": {"name": "durable_medical_equipment_allowed", "description": "Total durable medical equipment allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_allowed": {"name": "emergency_department_allowed", "description": "Total emergency department allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_allowed": {"name": "home_health_allowed", "description": "Total home health allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_allowed": {"name": "hospice_allowed", "description": "Total hospice allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_allowed": {"name": "inpatient_psychiatric_allowed", "description": "Total inpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_allowed": {"name": "inpatient_rehabilitation_allowed", "description": "Total inpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_allowed": {"name": "lab_allowed", "description": "Total lab allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed_2": {"name": "office_visit_allowed_2", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_allowed": {"name": "outpatient_hospital_or_clinic_allowed", "description": "Total outpatient hospital or clinic allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_allowed": {"name": "outpatient_psychiatric_allowed", "description": "Total outpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_allowed": {"name": "outpatient_rehabilitation_allowed", "description": "Total outpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_allowed": {"name": "skilled_nursing_allowed", "description": "Total skilled nursing allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_allowed": {"name": "urgent_care_allowed", "description": "Total urgent care allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "pmpm_payer_plan", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8466492, "relation_name": "dev_thuxuan.financial_pmpm.pmpm_payer_plan", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n)}}\r\n\r\nselect\r\n year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n , count(1) as member_months\r\n , sum(total_paid) / count(1) as total_paid\r\n , sum(medical_paid) / count(1) as medical_paid\r\n , sum(inpatient_paid) / count(1) as inpatient_paid\r\n , sum(outpatient_paid) / count(1) as outpatient_paid\r\n , sum(office_based_paid) / count(1) as office_based_paid\r\n , sum(ancillary_paid) / count(1) as ancillary_paid\r\n , sum(other_paid) / count(1) as other_paid\r\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\r\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\r\n , sum(ambulance_paid) / count(1) as ambulance_paid\r\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\r\n , sum(dialysis_paid) / count(1) as dialysis_paid\r\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\r\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\r\n , sum(home_health_paid) / count(1) as home_health_paid\r\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\r\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\r\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\r\n , sum(lab_paid) / count(1) as lab_paid\r\n , sum(observation_paid) / count(1) as observation_paid\r\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\r\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\r\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\r\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\r\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\r\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\r\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\r\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\r\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\r\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\r\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\r\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\r\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\r\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\r\n , sum(total_allowed) / count(1) as total_allowed\r\n , sum(medical_allowed) / count(1) as medical_allowed\r\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\r\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\r\n , sum(office_based_allowed) / count(1) as office_based_allowed\r\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\r\n , sum(other_allowed) / count(1) as other_allowed\r\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\r\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\r\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\r\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\r\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\r\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\r\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\r\n , sum(home_health_allowed) / count(1) as home_health_allowed\r\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\r\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\r\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\r\n , sum(lab_allowed) / count(1) as lab_allowed\r\n , sum(observation_allowed) / count(1) as observation_allowed\r\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\r\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\r\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\r\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\r\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\r\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\r\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\r\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\r\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\r\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\r\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\r\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\r\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\r\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('financial_pmpm__pmpm_prep') }} a\r\ngroup by\r\n year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , data_source", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\final\\financial_pmpm__pmpm_payer_plan.sql", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , plan\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n , payer\n , plan\n , data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__pmpm_prep": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__pmpm_prep", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\final\\financial_pmpm__pmpm_prep.sql", "original_file_path": "models\\financial_pmpm\\final\\financial_pmpm__pmpm_prep.sql", "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_prep", "fqn": ["the_tuva_project", "financial_pmpm", "final", "financial_pmpm__pmpm_prep"], "alias": "pmpm_prep", "checksum": {"name": "sha256", "checksum": "080937830d3afb809ddc230ca65ac6ebdcd36da09e0a34be6eb07c679516a1bc"}, "config": {"enabled": true, "alias": "pmpm_prep", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Computes all the paid and allowed statistics for every patient_id and year_month combination.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique identifier for each patient in the dataset.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "Unique year-month of in the dataset computed from eligibility.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer": {"name": "payer", "description": "Name of the payer (i.e. health insurer) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan": {"name": "plan", "description": "Name of the plan (i.e. sub contract) providing coverage.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider": {"name": "payer_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the payer.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "description": "Name of the practice for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "description": "Name of the organization for the payer attributed provider.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "description": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider": {"name": "custom_attributed_provider", "description": "Unique identifier for the provider assigned to this patient-year_month by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "description": "Name of the practice for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "description": "Name of the organization for the attributed provider assigned by the user.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "description": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_paid": {"name": "inpatient_paid", "description": "Total inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_paid": {"name": "outpatient_paid", "description": "Total outpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid": {"name": "office_visit_paid", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_paid": {"name": "ancillary_paid", "description": "Total ancillary paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_paid": {"name": "pharmacy_paid", "description": "Total pharmacy paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_paid": {"name": "other_paid", "description": "Total other paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_paid": {"name": "acute_inpatient_paid", "description": "Total acute inpatient paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_paid": {"name": "ambulance_paid", "description": "Total ambulance paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_paid": {"name": "ambulatory_surgery_paid", "description": "Total ambulatory surgery paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_paid": {"name": "dialysis_paid", "description": "Total dialysis paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_paid": {"name": "durable_medical_equipment_paid", "description": "Total durable medical equipment paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_paid": {"name": "emergency_department_paid", "description": "Total emergency department paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_paid": {"name": "home_health_paid", "description": "Total home health paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_paid": {"name": "hospice_paid", "description": "Total hospice paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_paid": {"name": "inpatient_psychiatric_paid", "description": "Total inpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_paid": {"name": "inpatient_rehabilitation_paid", "description": "Total inpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_paid": {"name": "lab_paid", "description": "Total lab paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_paid_2": {"name": "office_visit_paid_2", "description": "Total office visit paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_paid": {"name": "outpatient_hospital_or_clinic_paid", "description": "Total outpatient hospital or clinic paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_paid": {"name": "outpatient_psychiatric_paid", "description": "Total outpatient psychiatric paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_paid": {"name": "outpatient_rehabilitation_paid", "description": "Total outpatient rehabilitation paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_paid": {"name": "skilled_nursing_paid", "description": "Total skilled nursing paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_paid": {"name": "urgent_care_paid", "description": "Total urgent care paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_allowed": {"name": "inpatient_allowed", "description": "Total inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_allowed": {"name": "outpatient_allowed", "description": "Total outpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed": {"name": "office_visit_allowed", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ancillary_allowed": {"name": "ancillary_allowed", "description": "Total ancillary allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pharmacy_allowed": {"name": "pharmacy_allowed", "description": "Total pharmacy allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "other_allowed": {"name": "other_allowed", "description": "Total other allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "acute_inpatient_allowed": {"name": "acute_inpatient_allowed", "description": "Total acute inpatient allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulance_allowed": {"name": "ambulance_allowed", "description": "Total ambulance allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ambulatory_surgery_allowed": {"name": "ambulatory_surgery_allowed", "description": "Total ambulatory surgery allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dialysis_allowed": {"name": "dialysis_allowed", "description": "Total dialysis allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "durable_medical_equipment_allowed": {"name": "durable_medical_equipment_allowed", "description": "Total durable medical equipment allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emergency_department_allowed": {"name": "emergency_department_allowed", "description": "Total emergency department allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "home_health_allowed": {"name": "home_health_allowed", "description": "Total home health allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hospice_allowed": {"name": "hospice_allowed", "description": "Total hospice allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_psychiatric_allowed": {"name": "inpatient_psychiatric_allowed", "description": "Total inpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inpatient_rehabilitation_allowed": {"name": "inpatient_rehabilitation_allowed", "description": "Total inpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_allowed": {"name": "lab_allowed", "description": "Total lab allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "office_visit_allowed_2": {"name": "office_visit_allowed_2", "description": "Total office visit allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_hospital_or_clinic_allowed": {"name": "outpatient_hospital_or_clinic_allowed", "description": "Total outpatient hospital or clinic allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_psychiatric_allowed": {"name": "outpatient_psychiatric_allowed", "description": "Total outpatient psychiatric allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "outpatient_rehabilitation_allowed": {"name": "outpatient_rehabilitation_allowed", "description": "Total outpatient rehabilitation allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "skilled_nursing_allowed": {"name": "skilled_nursing_allowed", "description": "Total skilled nursing allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "urgent_care_allowed": {"name": "urgent_care_allowed", "description": "Total urgent care allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_paid": {"name": "total_paid", "description": "Total paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_paid": {"name": "medical_paid", "description": "Total medical paid amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_allowed": {"name": "total_allowed", "description": "Total allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_allowed": {"name": "medical_allowed", "description": "Total medical allowed amount per member per month (PMPM).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "pmpm_prep", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8426542, "relation_name": "dev_thuxuan.financial_pmpm.pmpm_prep", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n )\r\n}}\r\n\r\nwith combine as (\r\n select\r\n a.patient_id\r\n , a.year_month\r\n , a.payer\r\n , a.{{ quote_column('plan') }}\r\n , a.data_source\r\n , a.payer_attributed_provider\r\n , a.payer_attributed_provider_practice\r\n , a.payer_attributed_provider_organization\r\n , a.payer_attributed_provider_lob\r\n , a.custom_attributed_provider\r\n , a.custom_attributed_provider_practice\r\n , a.custom_attributed_provider_organization\r\n , a.custom_attributed_provider_lob\r\n\r\n -- service cat 1 paid\r\n , coalesce(b.inpatient_paid, 0) as inpatient_paid\r\n , coalesce(b.outpatient_paid, 0) as outpatient_paid\r\n , coalesce(b.office_based_paid, 0) as office_based_paid\r\n , coalesce(b.ancillary_paid, 0) as ancillary_paid\r\n , coalesce(b.other_paid, 0) as other_paid\r\n , coalesce(b.pharmacy_paid, 0) as pharmacy_paid\r\n\r\n -- service cat 2 paid\r\n , coalesce(c.acute_inpatient_paid, 0) as acute_inpatient_paid\r\n , coalesce(c.ambulance_paid, 0) as ambulance_paid\r\n , coalesce(c.ambulatory_surgery_center_paid, 0) as ambulatory_surgery_center_paid\r\n , coalesce(c.dialysis_paid, 0) as dialysis_paid\r\n , coalesce(c.durable_medical_equipment_paid, 0) as durable_medical_equipment_paid\r\n , coalesce(c.emergency_department_paid, 0) as emergency_department_paid\r\n , coalesce(c.home_health_paid, 0) as home_health_paid\r\n , coalesce(c.inpatient_hospice_paid, 0) as inpatient_hospice_paid\r\n , coalesce(c.inpatient_psychiatric_paid, 0) as inpatient_psychiatric_paid\r\n , coalesce(c.inpatient_rehabilitation_paid, 0) as inpatient_rehabilitation_paid\r\n , coalesce(c.lab_paid, 0) as lab_paid\r\n , coalesce(c.observation_paid, 0) as observation_paid\r\n , coalesce(c.office_based_other_paid, 0) as office_based_other_paid\r\n , coalesce(c.office_based_ptotst_paid, 0) as office_based_pt_ot_st_paid\r\n , coalesce(c.office_based_radiology_paid, 0) as office_based_radiology_paid\r\n , coalesce(c.office_based_surgery_paid, 0) as office_based_surgery_paid\r\n , coalesce(c.office_based_visit_paid, 0) as office_based_visit_paid\r\n , coalesce(c.other_paid, 0) as other_paid_2\r\n , coalesce(c.outpatient_hospice_paid, 0) as outpatient_hospice_paid\r\n , coalesce(c.outpatient_hospital_or_clinic_paid, 0) as outpatient_hospital_or_clinic_paid\r\n , coalesce(c.outpatient_ptotst_paid, 0) as outpatient_pt_ot_st_paid\r\n , coalesce(c.outpatient_psychiatric_paid, 0) as outpatient_psychiatric_paid\r\n , coalesce(c.outpatient_radiology_paid, 0) as outpatient_radiology_paid\r\n , coalesce(c.outpatient_rehabilitation_paid, 0) as outpatient_rehabilitation_paid\r\n , coalesce(c.outpatient_surgery_paid, 0) as outpatient_surgery_paid\r\n , coalesce(c.pharmacy_paid, 0) as pharmacy_paid_2\r\n , coalesce(c.skilled_nursing_paid, 0) as skilled_nursing_paid\r\n , coalesce(c.telehealth_visit_paid, 0) as telehealth_visit_paid\r\n , coalesce(c.urgent_care_paid, 0) as urgent_care_paid\r\n\r\n -- service cat 1 allowed\r\n , coalesce(d.inpatient_allowed, 0) as inpatient_allowed\r\n , coalesce(d.outpatient_allowed, 0) as outpatient_allowed\r\n , coalesce(d.office_based_allowed, 0) as office_based_allowed\r\n , coalesce(d.ancillary_allowed, 0) as ancillary_allowed\r\n , coalesce(d.other_allowed, 0) as other_allowed\r\n , coalesce(d.pharmacy_allowed, 0) as pharmacy_allowed\r\n\r\n -- service cat 2 allowed\r\n , coalesce(e.acute_inpatient_allowed, 0) as acute_inpatient_allowed\r\n , coalesce(e.ambulance_allowed, 0) as ambulance_allowed\r\n , coalesce(e.ambulatory_surgery_center_allowed, 0) as ambulatory_surgery_center_allowed\r\n , coalesce(e.dialysis_allowed, 0) as dialysis_allowed\r\n , coalesce(e.durable_medical_equipment_allowed, 0) as durable_medical_equipment_allowed\r\n , coalesce(e.emergency_department_allowed, 0) as emergency_department_allowed\r\n , coalesce(e.home_health_allowed, 0) as home_health_allowed\r\n , coalesce(e.inpatient_hospice_allowed, 0) as inpatient_hospice_allowed\r\n , coalesce(e.inpatient_psychiatric_allowed, 0) as inpatient_psychiatric_allowed\r\n , coalesce(e.inpatient_rehabilitation_allowed, 0) as inpatient_rehabilitation_allowed\r\n , coalesce(e.lab_allowed, 0) as lab_allowed\r\n , coalesce(e.observation_allowed, 0) as observation_allowed\r\n , coalesce(e.office_based_other_allowed, 0) as office_based_other_allowed\r\n , coalesce(e.office_based_ptotst_allowed, 0) as office_based_pt_ot_st_allowed\r\n , coalesce(e.office_based_radiology_allowed, 0) as office_based_radiology_allowed\r\n , coalesce(e.office_based_surgery_allowed, 0) as office_based_surgery_allowed\r\n , coalesce(e.office_based_visit_allowed, 0) as office_based_visit_allowed\r\n , coalesce(e.other_allowed, 0) as other_allowed_2\r\n , coalesce(e.outpatient_hospice_allowed, 0) as outpatient_hospice_allowed\r\n , coalesce(e.outpatient_hospital_or_clinic_allowed, 0) as outpatient_hospital_or_clinic_allowed\r\n , coalesce(e.outpatient_ptotst_allowed, 0) as outpatient_pt_ot_st_allowed\r\n , coalesce(e.outpatient_psychiatric_allowed, 0) as outpatient_psychiatric_allowed\r\n , coalesce(e.outpatient_radiology_allowed, 0) as outpatient_radiology_allowed\r\n , coalesce(e.outpatient_rehabilitation_allowed, 0) as outpatient_rehabilitation_allowed\r\n , coalesce(e.outpatient_surgery_allowed, 0) as outpatient_surgery_allowed\r\n , coalesce(e.pharmacy_allowed, 0) as pharmacy_allowed_2\r\n , coalesce(e.skilled_nursing_allowed, 0) as skilled_nursing_allowed\r\n , coalesce(e.telehealth_visit_allowed, 0) as telehealth_visit_allowed\r\n , coalesce(e.urgent_care_allowed, 0) as urgent_care_allowed\r\n\r\n from {{ ref('core__member_months') }} as a\r\n left join {{ ref('financial_pmpm__service_category_1_paid_pivot') }} as b\r\n on a.patient_id = b.patient_id\r\n and a.year_month = b.year_month\r\n and a.payer = b.payer\r\n and a.{{ quote_column('plan') }} = b.{{ quote_column('plan') }}\r\n left join {{ ref('financial_pmpm__service_category_2_paid_pivot') }} as c\r\n on a.patient_id = c.patient_id\r\n and a.year_month = c.year_month\r\n and a.payer = c.payer\r\n and a.{{ quote_column('plan') }} = c.{{ quote_column('plan') }}\r\n left join {{ ref('financial_pmpm__service_category_1_allowed_pivot') }} as d\r\n on a.patient_id = d.patient_id\r\n and a.year_month = d.year_month\r\n and a.payer = d.payer\r\n and a.{{ quote_column('plan') }} = d.{{ quote_column('plan') }}\r\n left join {{ ref('financial_pmpm__service_category_2_allowed_pivot') }} as e\r\n on a.patient_id = e.patient_id\r\n and a.year_month = e.year_month\r\n and a.payer = e.payer\r\n and a.{{ quote_column('plan') }} = e.{{ quote_column('plan') }}\r\n)\r\n\r\nselect\r\n *\r\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid + pharmacy_paid as total_paid\r\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid as medical_paid\r\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed + pharmacy_allowed as total_allowed\r\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed as medical_allowed\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom combine", "language": "sql", "refs": [{"name": "core__member_months", "package": null, "version": null}, {"name": "financial_pmpm__service_category_1_paid_pivot", "package": null, "version": null}, {"name": "financial_pmpm__service_category_2_paid_pivot", "package": null, "version": null}, {"name": "financial_pmpm__service_category_1_allowed_pivot", "package": null, "version": null}, {"name": "financial_pmpm__service_category_2_allowed_pivot", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\final\\financial_pmpm__pmpm_prep.sql", "compiled": true, "compiled_code": "\n\nwith combine as (\n select\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.payer_attributed_provider\n , a.payer_attributed_provider_practice\n , a.payer_attributed_provider_organization\n , a.payer_attributed_provider_lob\n , a.custom_attributed_provider\n , a.custom_attributed_provider_practice\n , a.custom_attributed_provider_organization\n , a.custom_attributed_provider_lob\n\n -- service cat 1 paid\n , coalesce(b.inpatient_paid, 0) as inpatient_paid\n , coalesce(b.outpatient_paid, 0) as outpatient_paid\n , coalesce(b.office_based_paid, 0) as office_based_paid\n , coalesce(b.ancillary_paid, 0) as ancillary_paid\n , coalesce(b.other_paid, 0) as other_paid\n , coalesce(b.pharmacy_paid, 0) as pharmacy_paid\n\n -- service cat 2 paid\n , coalesce(c.acute_inpatient_paid, 0) as acute_inpatient_paid\n , coalesce(c.ambulance_paid, 0) as ambulance_paid\n , coalesce(c.ambulatory_surgery_center_paid, 0) as ambulatory_surgery_center_paid\n , coalesce(c.dialysis_paid, 0) as dialysis_paid\n , coalesce(c.durable_medical_equipment_paid, 0) as durable_medical_equipment_paid\n , coalesce(c.emergency_department_paid, 0) as emergency_department_paid\n , coalesce(c.home_health_paid, 0) as home_health_paid\n , coalesce(c.inpatient_hospice_paid, 0) as inpatient_hospice_paid\n , coalesce(c.inpatient_psychiatric_paid, 0) as inpatient_psychiatric_paid\n , coalesce(c.inpatient_rehabilitation_paid, 0) as inpatient_rehabilitation_paid\n , coalesce(c.lab_paid, 0) as lab_paid\n , coalesce(c.observation_paid, 0) as observation_paid\n , coalesce(c.office_based_other_paid, 0) as office_based_other_paid\n , coalesce(c.office_based_ptotst_paid, 0) as office_based_pt_ot_st_paid\n , coalesce(c.office_based_radiology_paid, 0) as office_based_radiology_paid\n , coalesce(c.office_based_surgery_paid, 0) as office_based_surgery_paid\n , coalesce(c.office_based_visit_paid, 0) as office_based_visit_paid\n , coalesce(c.other_paid, 0) as other_paid_2\n , coalesce(c.outpatient_hospice_paid, 0) as outpatient_hospice_paid\n , coalesce(c.outpatient_hospital_or_clinic_paid, 0) as outpatient_hospital_or_clinic_paid\n , coalesce(c.outpatient_ptotst_paid, 0) as outpatient_pt_ot_st_paid\n , coalesce(c.outpatient_psychiatric_paid, 0) as outpatient_psychiatric_paid\n , coalesce(c.outpatient_radiology_paid, 0) as outpatient_radiology_paid\n , coalesce(c.outpatient_rehabilitation_paid, 0) as outpatient_rehabilitation_paid\n , coalesce(c.outpatient_surgery_paid, 0) as outpatient_surgery_paid\n , coalesce(c.pharmacy_paid, 0) as pharmacy_paid_2\n , coalesce(c.skilled_nursing_paid, 0) as skilled_nursing_paid\n , coalesce(c.telehealth_visit_paid, 0) as telehealth_visit_paid\n , coalesce(c.urgent_care_paid, 0) as urgent_care_paid\n\n -- service cat 1 allowed\n , coalesce(d.inpatient_allowed, 0) as inpatient_allowed\n , coalesce(d.outpatient_allowed, 0) as outpatient_allowed\n , coalesce(d.office_based_allowed, 0) as office_based_allowed\n , coalesce(d.ancillary_allowed, 0) as ancillary_allowed\n , coalesce(d.other_allowed, 0) as other_allowed\n , coalesce(d.pharmacy_allowed, 0) as pharmacy_allowed\n\n -- service cat 2 allowed\n , coalesce(e.acute_inpatient_allowed, 0) as acute_inpatient_allowed\n , coalesce(e.ambulance_allowed, 0) as ambulance_allowed\n , coalesce(e.ambulatory_surgery_center_allowed, 0) as ambulatory_surgery_center_allowed\n , coalesce(e.dialysis_allowed, 0) as dialysis_allowed\n , coalesce(e.durable_medical_equipment_allowed, 0) as durable_medical_equipment_allowed\n , coalesce(e.emergency_department_allowed, 0) as emergency_department_allowed\n , coalesce(e.home_health_allowed, 0) as home_health_allowed\n , coalesce(e.inpatient_hospice_allowed, 0) as inpatient_hospice_allowed\n , coalesce(e.inpatient_psychiatric_allowed, 0) as inpatient_psychiatric_allowed\n , coalesce(e.inpatient_rehabilitation_allowed, 0) as inpatient_rehabilitation_allowed\n , coalesce(e.lab_allowed, 0) as lab_allowed\n , coalesce(e.observation_allowed, 0) as observation_allowed\n , coalesce(e.office_based_other_allowed, 0) as office_based_other_allowed\n , coalesce(e.office_based_ptotst_allowed, 0) as office_based_pt_ot_st_allowed\n , coalesce(e.office_based_radiology_allowed, 0) as office_based_radiology_allowed\n , coalesce(e.office_based_surgery_allowed, 0) as office_based_surgery_allowed\n , coalesce(e.office_based_visit_allowed, 0) as office_based_visit_allowed\n , coalesce(e.other_allowed, 0) as other_allowed_2\n , coalesce(e.outpatient_hospice_allowed, 0) as outpatient_hospice_allowed\n , coalesce(e.outpatient_hospital_or_clinic_allowed, 0) as outpatient_hospital_or_clinic_allowed\n , coalesce(e.outpatient_ptotst_allowed, 0) as outpatient_pt_ot_st_allowed\n , coalesce(e.outpatient_psychiatric_allowed, 0) as outpatient_psychiatric_allowed\n , coalesce(e.outpatient_radiology_allowed, 0) as outpatient_radiology_allowed\n , coalesce(e.outpatient_rehabilitation_allowed, 0) as outpatient_rehabilitation_allowed\n , coalesce(e.outpatient_surgery_allowed, 0) as outpatient_surgery_allowed\n , coalesce(e.pharmacy_allowed, 0) as pharmacy_allowed_2\n , coalesce(e.skilled_nursing_allowed, 0) as skilled_nursing_allowed\n , coalesce(e.telehealth_visit_allowed, 0) as telehealth_visit_allowed\n , coalesce(e.urgent_care_allowed, 0) as urgent_care_allowed\n\n from dev_thuxuan.core.member_months as a\n left join dev_thuxuan.financial_pmpm._int_service_category_1_paid_pivot as b\n on a.patient_id = b.patient_id\n and a.year_month = b.year_month\n and a.payer = b.payer\n and a.plan = b.plan\n left join dev_thuxuan.financial_pmpm._int_service_category_2_paid_pivot as c\n on a.patient_id = c.patient_id\n and a.year_month = c.year_month\n and a.payer = c.payer\n and a.plan = c.plan\n left join dev_thuxuan.financial_pmpm._int_service_category_1_allowed_pivot as d\n on a.patient_id = d.patient_id\n and a.year_month = d.year_month\n and a.payer = d.payer\n and a.plan = d.plan\n left join dev_thuxuan.financial_pmpm._int_service_category_2_allowed_pivot as e\n on a.patient_id = e.patient_id\n and a.year_month = e.year_month\n and a.payer = e.payer\n and a.plan = e.plan\n)\n\nselect\n *\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid + pharmacy_paid as total_paid\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid as medical_paid\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed + pharmacy_allowed as total_allowed\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed as medical_allowed\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom combine", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__patient_spend_with_service_categories", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\intermediate\\financial_pmpm__patient_spend_with_service_categories.sql", "original_file_path": "models\\financial_pmpm\\intermediate\\financial_pmpm__patient_spend_with_service_categories.sql", "unique_id": "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__patient_spend_with_service_categories"], "alias": "_int_patient_spend_with_service_categories", "checksum": {"name": "sha256", "checksum": "12cb20b423731ddc9a49995e4c559b500e2bcbf174c7f738e0c9eec70d623630"}, "config": {"enabled": true, "alias": "_int_patient_spend_with_service_categories", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Adds service categories to claims and sums paid and allowed amounts to the year-month level.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_patient_spend_with_service_categories", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8516493, "relation_name": "dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith claims_with_service_categories as (\r\n select\r\n patient_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , service_category_2\r\n , coalesce(claim_start_date,claim_end_date) as claim_date\r\n , paid_amount\r\n , allowed_amount\r\n , data_source\r\n from {{ ref('financial_pmpm__stg_medical_claim') }}\r\n)\r\n\r\n, medical_claims_year_month as (\r\n select\r\n patient_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , service_category_2\r\n , {{ dbt.concat([date_part('year', 'claim_date'),\r\n dbt.right(\r\n dbt.concat([\"'0'\", date_part('month', 'claim_date')])\r\n , 2)]) }} as year_month\r\n , paid_amount\r\n , allowed_amount\r\n , data_source\r\n from claims_with_service_categories\r\n)\r\n\r\n, rx_claims as (\r\n select\r\n patient_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , 'pharmacy' as service_category_1\r\n , cast(null as {{ dbt.type_string() }}) as service_category_2\r\n , coalesce(dispensing_date, paid_date) as claim_date\r\n , paid_amount\r\n , allowed_amount\r\n , data_source\r\n from {{ ref('financial_pmpm__stg_pharmacy_claim') }}\r\n)\r\n\r\n, rx_claims_year_month as (\r\n select\r\n patient_id\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , service_category_2\r\n , {{ dbt.concat([date_part('year', 'claim_date'),\r\n dbt.right(\r\n dbt.concat([\"'0'\", date_part('month', 'claim_date')])\r\n , 2)]) }} as year_month\r\n , paid_amount\r\n , allowed_amount\r\n , data_source\r\n from rx_claims\r\n)\r\n\r\n, combine_medical_and_rx as (\r\nselect *\r\nfrom medical_claims_year_month\r\n\r\nunion all\r\n\r\nselect *\r\nfrom rx_claims_year_month\r\n)\r\n\r\nselect\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , service_category_2\r\n , sum(paid_amount) as total_paid\r\n , sum(allowed_amount) as total_allowed\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from combine_medical_and_rx\r\ngroup by\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , service_category_2\r\n , data_source", "language": "sql", "refs": [{"name": "financial_pmpm__stg_medical_claim", "package": null, "version": null}, {"name": "financial_pmpm__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.right", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.financial_pmpm__stg_medical_claim", "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\intermediate\\financial_pmpm__patient_spend_with_service_categories.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__financial_pmpm__stg_medical_claim as (\n\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), __dbt__cte__financial_pmpm__stg_pharmacy_claim as (\n\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n), claims_with_service_categories as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , coalesce(claim_start_date,claim_end_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_medical_claim\n)\n\n, medical_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from claims_with_service_categories\n)\n\n, rx_claims as (\n select\n patient_id\n , payer\n , plan\n , 'pharmacy' as service_category_1\n , cast(null as TEXT) as service_category_2\n , coalesce(dispensing_date, paid_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_pharmacy_claim\n)\n\n, rx_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from rx_claims\n)\n\n, combine_medical_and_rx as (\nselect *\nfrom medical_claims_year_month\n\nunion all\n\nselect *\nfrom rx_claims_year_month\n)\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , sum(paid_amount) as total_paid\n , sum(allowed_amount) as total_allowed\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from combine_medical_and_rx\ngroup by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.financial_pmpm__stg_medical_claim", "sql": " __dbt__cte__financial_pmpm__stg_medical_claim as (\n\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n)"}, {"id": "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim", "sql": " __dbt__cte__financial_pmpm__stg_pharmacy_claim as (\n\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_1_allowed_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\intermediate\\financial_pmpm__service_category_1_allowed_pivot.sql", "original_file_path": "models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_1_allowed_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_1_allowed_pivot"], "alias": "_int_service_category_1_allowed_pivot", "checksum": {"name": "sha256", "checksum": "ff2f6b0a0f98d7187807c2b789403e24ffae8d1bf7d913d6ba5b21b912741335"}, "config": {"enabled": true, "alias": "_int_service_category_1_allowed_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out allowed amounts into columns by service category level 1.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_1_allowed_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8546495, "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_1_allowed_pivot", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_cat_1 as (\r\n select\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , data_source\r\n , sum(total_allowed) as total_allowed\r\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\r\n group by\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , data_source\r\n)\r\n\r\nselect\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source\r\n, {{ dbt_utils.pivot(\r\n column='service_category_1'\r\n , values=('inpatient','outpatient','office-based','ancillary','other','pharmacy')\r\n , agg='sum'\r\n , then_value='total_allowed'\r\n , else_value= 0\r\n , quote_identifiers = False\r\n , suffix='_allowed'\r\n ) }}\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_cat_1\r\ngroup by\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_1_allowed_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_allowed) as total_allowed\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_allowed\n else 0\n end\n )\n \n \n as ancillary_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_1_paid_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\intermediate\\financial_pmpm__service_category_1_paid_pivot.sql", "original_file_path": "models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_1_paid_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_1_paid_pivot"], "alias": "_int_service_category_1_paid_pivot", "checksum": {"name": "sha256", "checksum": "fb5ee546e24d2705a94cc1e33a54cde437dc92b323f7ab73976bbd76c0e72c8f"}, "config": {"enabled": true, "alias": "_int_service_category_1_paid_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out paid amounts into columns by service category level 1.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_1_paid_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8586493, "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_1_paid_pivot", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_cat_1 as (\r\n select\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , data_source\r\n , sum(total_paid) as total_paid\r\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\r\n group by\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_1\r\n , data_source\r\n)\r\n\r\nselect\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source\r\n, {{ dbt_utils.pivot(\r\n column='service_category_1'\r\n , values=('inpatient','outpatient','office-based','ancillary','other','pharmacy')\r\n , agg='sum'\r\n , then_value='total_paid'\r\n , else_value= 0\r\n , quote_identifiers = False\r\n , suffix='_paid'\r\n ) }}\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_cat_1\r\ngroup by\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_1_paid_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_paid) as total_paid\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_paid\n else 0\n end\n )\n \n \n as ancillary_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_2_allowed_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\intermediate\\financial_pmpm__service_category_2_allowed_pivot.sql", "original_file_path": "models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_2_allowed_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_2_allowed_pivot"], "alias": "_int_service_category_2_allowed_pivot", "checksum": {"name": "sha256", "checksum": "a0bb53e09ae4fe0e5320eaaf0020cda60a14ea61ed99b43fd3dfdbd3de92c4aa"}, "config": {"enabled": true, "alias": "_int_service_category_2_allowed_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out allowed amounts into columns by service category level 2.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_2_allowed_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8566494, "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_2_allowed_pivot", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_cat_2 as (\r\n select\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_2\r\n , data_source\r\n , sum(total_allowed) as total_allowed\r\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\r\n group by\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_2\r\n , data_source\r\n)\r\n\r\nselect\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source\r\n, {{ dbt_utils.pivot(\r\n column='service_category_2'\r\n , values=(\r\n 'acute inpatient', \r\n 'ambulance', \r\n 'ambulatory surgery center', \r\n 'dialysis', \r\n 'durable medical equipment', \r\n 'emergency department', \r\n 'home health', \r\n 'inpatient hospice', \r\n 'inpatient psychiatric', \r\n 'inpatient rehabilitation', \r\n 'lab', \r\n 'observation', \r\n 'office-based other', \r\n 'office-based pt/ot/st', \r\n 'office-based radiology', \r\n 'office-based surgery', \r\n 'office-based visit', \r\n 'other', \r\n 'outpatient hospice', \r\n 'outpatient hospital or clinic', \r\n 'outpatient pt/ot/st', \r\n 'outpatient psychiatric', \r\n 'outpatient radiology', \r\n 'outpatient rehabilitation', \r\n 'outpatient surgery', \r\n 'pharmacy', \r\n 'skilled nursing', \r\n 'telehealth visit', \r\n 'urgent care'\r\n )\r\n , agg='sum'\r\n , then_value='total_allowed'\r\n , else_value= 0\r\n , quote_identifiers = False\r\n , suffix='_allowed'\r\n) }}\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_cat_2\r\ngroup by\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_2_allowed_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_allowed) as total_allowed\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as acute_inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulance_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_allowed\n else 0\n end\n )\n \n \n as dialysis_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_allowed\n else 0\n end\n )\n \n \n as durable_medical_equipment_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_allowed\n else 0\n end\n )\n \n \n as emergency_department_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_allowed\n else 0\n end\n )\n \n \n as home_health_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_allowed\n else 0\n end\n )\n \n \n as lab_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_allowed\n else 0\n end\n )\n \n \n as observation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_allowed\n else 0\n end\n )\n \n \n as skilled_nursing_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_allowed\n else 0\n end\n )\n \n \n as telehealth_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_allowed\n else 0\n end\n )\n \n \n as urgent_care_allowed\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": {"database": "dev_thuxuan", "schema": "financial_pmpm", "name": "financial_pmpm__service_category_2_paid_pivot", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\intermediate\\financial_pmpm__service_category_2_paid_pivot.sql", "original_file_path": "models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_2_paid_pivot.sql", "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "fqn": ["the_tuva_project", "financial_pmpm", "intermediate", "financial_pmpm__service_category_2_paid_pivot"], "alias": "_int_service_category_2_paid_pivot", "checksum": {"name": "sha256", "checksum": "d151abe077c877464149216afbf6a53a015a5562ab81cb23b7245724bc7b4cea"}, "config": {"enabled": true, "alias": "_int_service_category_2_paid_pivot", "schema": "financial_pmpm", "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "Pivots out paid amounts into columns by service category level 2.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"schema": "financial_pmpm", "alias": "_int_service_category_2_paid_pivot", "tags": ["financial_pmpm"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.861652, "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_2_paid_pivot", "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nwith service_cat_2 as (\r\n select\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_2\r\n , data_source\r\n , sum(total_paid) as total_paid\r\n from {{ ref('financial_pmpm__patient_spend_with_service_categories') }}\r\n group by\r\n patient_id\r\n , year_month\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , service_category_2\r\n , data_source\r\n)\r\n\r\nselect\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source\r\n, {{ dbt_utils.pivot(\r\n column='service_category_2'\r\n , values=(\r\n 'acute inpatient', \r\n 'ambulance', \r\n 'ambulatory surgery center', \r\n 'dialysis', \r\n 'durable medical equipment', \r\n 'emergency department', \r\n 'home health', \r\n 'inpatient hospice', \r\n 'inpatient psychiatric', \r\n 'inpatient rehabilitation', \r\n 'lab', \r\n 'observation', \r\n 'office-based other', \r\n 'office-based pt/ot/st', \r\n 'office-based radiology', \r\n 'office-based surgery', \r\n 'office-based visit', \r\n 'other', \r\n 'outpatient hospice', \r\n 'outpatient hospital or clinic', \r\n 'outpatient pt/ot/st', \r\n 'outpatient psychiatric', \r\n 'outpatient radiology', \r\n 'outpatient rehabilitation', \r\n 'outpatient surgery', \r\n 'pharmacy', \r\n 'skilled nursing', \r\n 'telehealth visit', \r\n 'urgent care'\r\n )\r\n , agg='sum'\r\n , then_value='total_paid'\r\n , else_value= 0\r\n , quote_identifiers = False\r\n , suffix='_paid'\r\n ) }}\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom service_cat_2\r\ngroup by\r\n patient_id\r\n, year_month\r\n, payer\r\n, {{ quote_column('plan') }}\r\n, data_source", "language": "sql", "refs": [{"name": "financial_pmpm__patient_spend_with_service_categories", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column", "macro.dbt_utils.pivot"], "nodes": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\intermediate\\financial_pmpm__service_category_2_paid_pivot.sql", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_paid) as total_paid\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as acute_inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_paid\n else 0\n end\n )\n \n \n as ambulance_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_paid\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_paid\n else 0\n end\n )\n \n \n as dialysis_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_paid\n else 0\n end\n )\n \n \n as durable_medical_equipment_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_paid\n else 0\n end\n )\n \n \n as emergency_department_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_paid\n else 0\n end\n )\n \n \n as home_health_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_paid\n else 0\n end\n )\n \n \n as lab_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_paid\n else 0\n end\n )\n \n \n as observation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_paid\n else 0\n end\n )\n \n \n as skilled_nursing_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_paid\n else 0\n end\n )\n \n \n as telehealth_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_paid\n else 0\n end\n )\n \n \n as urgent_care_paid\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_eligibility": {"database": "dev_thuxuan", "schema": "test", "name": "financial_pmpm__stg_eligibility", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\staging\\financial_pmpm__stg_eligibility.sql", "original_file_path": "models\\financial_pmpm\\staging\\financial_pmpm__stg_eligibility.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_eligibility", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_eligibility"], "alias": "financial_pmpm__stg_eligibility", "checksum": {"name": "sha256", "checksum": "87a345ffb8bffd54d7b475a89a27ffd912f45d8e33eed97d5d2862315189776e"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": ["financial_pmpm"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8626518, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n patient_id\r\n , enrollment_start_date\r\n , enrollment_end_date\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__eligibility') }}", "language": "sql", "refs": [{"name": "core__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\staging\\financial_pmpm__stg_eligibility.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_medical_claim": {"database": "dev_thuxuan", "schema": "test", "name": "financial_pmpm__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\staging\\financial_pmpm__stg_medical_claim.sql", "original_file_path": "models\\financial_pmpm\\staging\\financial_pmpm__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_medical_claim", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_medical_claim"], "alias": "financial_pmpm__stg_medical_claim", "checksum": {"name": "sha256", "checksum": "bbeabb91865dd5fd7064776d6047737040cb4e0bf084d49a5cd46af7b3c29952"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": "financial_pmpm", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8636515, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\nSELECT\r\n patient_id\r\n , claim_id\r\n , claim_line_number\r\n , claim_start_date\r\n , claim_end_date\r\n , service_category_1\r\n , service_category_2\r\n , paid_amount\r\n , allowed_amount\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medical_claim') }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\staging\\financial_pmpm__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim": {"database": "dev_thuxuan", "schema": "test", "name": "financial_pmpm__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\staging\\financial_pmpm__stg_pharmacy_claim.sql", "original_file_path": "models\\financial_pmpm\\staging\\financial_pmpm__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_pharmacy_claim"], "alias": "financial_pmpm__stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "32f8cfb52f8b088d813cfd3c96ab841ad9553da38c23793cca1134e7f5538f93"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": "financial_pmpm", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8646517, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('financial_pmpm_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n\r\nSELECT\r\n patient_id\r\n , dispensing_date\r\n , paid_date\r\n , paid_amount\r\n , allowed_amount\r\n , payer\r\n , {{ quote_column('plan') }}\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__pharmacy_claim') }}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\staging\\financial_pmpm__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.financial_pmpm__stg_provider_attribution": {"database": "dev_thuxuan", "schema": "test", "name": "financial_pmpm__stg_provider_attribution", "resource_type": "model", "package_name": "the_tuva_project", "path": "financial_pmpm\\staging\\financial_pmpm__stg_provider_attribution.sql", "original_file_path": "models\\financial_pmpm\\staging\\financial_pmpm__stg_provider_attribution.sql", "unique_id": "model.the_tuva_project.financial_pmpm__stg_provider_attribution", "fqn": ["the_tuva_project", "financial_pmpm", "staging", "financial_pmpm__stg_provider_attribution"], "alias": "financial_pmpm__stg_provider_attribution", "checksum": {"name": "sha256", "checksum": "051ca861338352c92e40bc1df33ac469f611d08837fccab83955bba0ae011e90"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["financial_pmpm"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["financial_pmpm"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\financial_pmpm\\financial_pmpm_models.yml", "build_path": null, "unrendered_config": {"tags": "financial_pmpm", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.865652, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('claims_enabled',var('tuva_marts_enabled',False)) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('provider_attribution_enabled',False) == true -%}\r\n\r\n\r\nselect\r\n cast(patient_id as {{ dbt.type_string() }} ) as patient_id\r\n , cast(year_month as {{ dbt.type_string() }} ) as year_month\r\n , cast(payer as {{ dbt.type_string() }} ) as payer\r\n , {{ quote_column('plan') }}\r\n , cast(data_source as {{ dbt.type_string() }} ) as data_source\r\n \r\n , cast(payer_attributed_provider as {{ dbt.type_string() }} )\r\n as payer_attributed_provider\r\n , cast(payer_attributed_provider_practice as {{ dbt.type_string() }} )\r\n as payer_attributed_provider_practice\r\n , cast(payer_attributed_provider_organization as {{ dbt.type_string() }} )\r\n as payer_attributed_provider_organization\r\n , cast(payer_attributed_provider_lob as {{ dbt.type_string() }} )\r\n as payer_attributed_provider_lob\r\n\r\n , cast(custom_attributed_provider as {{ dbt.type_string() }} )\r\n as custom_attributed_provider\r\n , cast(custom_attributed_provider_practice as {{ dbt.type_string() }} )\r\n as custom_attributed_provider_practice\r\n , cast(custom_attributed_provider_organization as {{ dbt.type_string() }} )\r\n as custom_attributed_provider_organization\r\n , cast(custom_attributed_provider_lob as {{ dbt.type_string() }} )\r\n as custom_attributed_provider_lob\r\n\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n \r\nfrom {{ ref('provider_attribution') }}\r\n\r\n\r\n\r\n{%- else %}\r\n\r\n\r\nselect\r\n cast(null as {{ dbt.type_string() }} ) patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as year_month\r\n , cast(null as {{ dbt.type_string() }} ) as payer\r\n , cast(null as {{ dbt.type_string() }} ) as {{ quote_column('plan') }}\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n \r\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider\r\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider_practice\r\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider_organization\r\n , cast(null as {{ dbt.type_string() }} ) as payer_attributed_provider_lob\r\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider\r\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider_practice\r\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider_organization\r\n , cast(null as {{ dbt.type_string() }} ) as custom_attributed_provider_lob\r\n , cast(null as {{ dbt.type_string() }} ) as tuva_last_run\r\n\r\nlimit 0\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "provider_attribution", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.the_tuva_project.quote_column"], "nodes": ["model.input_layer.provider_attribution"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\staging\\financial_pmpm__stg_provider_attribution.sql", "compiled": true, "compiled_code": "\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__list": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__list", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\final\\hcc_suspecting__list.sql", "original_file_path": "models\\hcc_suspecting\\final\\hcc_suspecting__list.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__list", "fqn": ["the_tuva_project", "hcc_suspecting", "final", "hcc_suspecting__list"], "alias": "list", "checksum": {"name": "sha256", "checksum": "0275aac870879f5a45cb5690575db44cd27566fa74edaf3b4c0f611737258b68"}, "config": {"enabled": true, "alias": "list", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This final model displays the list of suspecting conditions per patient, data_source, hcc, and diagnosis code with the reason and contributing factors.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting condition, observation, result, etc. was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "list", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8746514, "relation_name": "dev_thuxuan.hcc_suspecting.list", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith hcc_history_suspects as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\r\n {% if target.type == 'fabric' %}\r\n where (current_year_billed = 0\r\n or current_year_billed is null)\r\n {% else %}\r\n where (current_year_billed = false\r\n or current_year_billed is null)\r\n {% endif %}\r\n\r\n)\r\n\r\n, comorbidity_suspects as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n from {{ ref('hcc_suspecting__int_comorbidity_suspects') }}\r\n {% if target.type == 'fabric' %}\r\n where (current_year_billed = 0\r\n or current_year_billed is null)\r\n {% else %}\r\n where (current_year_billed = false\r\n or current_year_billed is null)\r\n {% endif %}\r\n\r\n)\r\n\r\n, observation_suspects as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n from {{ ref('hcc_suspecting__int_observation_suspects') }}\r\n {% if target.type == 'fabric' %}\r\n where (current_year_billed = 0\r\n or current_year_billed is null)\r\n {% else %}\r\n where (current_year_billed = false\r\n or current_year_billed is null)\r\n {% endif %}\r\n\r\n)\r\n\r\n, lab_suspects as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n from {{ ref('hcc_suspecting__int_lab_suspects') }}\r\n {% if target.type == 'fabric' %}\r\n where (current_year_billed = 0\r\n or current_year_billed is null)\r\n {% else %}\r\n where (current_year_billed = false\r\n or current_year_billed is null)\r\n {% endif %}\r\n\r\n)\r\n\r\n, medication_suspects as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n from {{ ref('hcc_suspecting__int_medication_suspects') }}\r\n {% if target.type == 'fabric' %}\r\n where (current_year_billed = 0\r\n or current_year_billed is null)\r\n {% else %}\r\n where (current_year_billed = false\r\n or current_year_billed is null)\r\n {% endif %}\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from hcc_history_suspects\r\n union all\r\n select * from comorbidity_suspects\r\n union all\r\n select * from observation_suspects\r\n union all\r\n select * from lab_suspects\r\n union all\r\n select * from medication_suspects\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(suspect_date as date) as suspect_date\r\n from unioned\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}, {"name": "hcc_suspecting__int_comorbidity_suspects", "package": null, "version": null}, {"name": "hcc_suspecting__int_observation_suspects", "package": null, "version": null}, {"name": "hcc_suspecting__int_lab_suspects", "package": null, "version": null}, {"name": "hcc_suspecting__int_medication_suspects", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\final\\hcc_suspecting__list.sql", "compiled": true, "compiled_code": "\n\nwith hcc_history_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, comorbidity_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_comorbidity_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, observation_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_observation_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, lab_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_lab_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, medication_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_medication_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, unioned as (\n\n select * from hcc_history_suspects\n union all\n select * from comorbidity_suspects\n union all\n select * from observation_suspects\n union all\n select * from lab_suspects\n union all\n select * from medication_suspects\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from unioned\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__list_rollup": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__list_rollup", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\final\\hcc_suspecting__list_rollup.sql", "original_file_path": "models\\hcc_suspecting\\final\\hcc_suspecting__list_rollup.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__list_rollup", "fqn": ["the_tuva_project", "hcc_suspecting", "final", "hcc_suspecting__list_rollup"], "alias": "list_rollup", "checksum": {"name": "sha256", "checksum": "af9e01b29e7dbef236a892e44c24386aa71a33395f9429c03213361449d9e5bd"}, "config": {"enabled": true, "alias": "list_rollup", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This final model displays the list of suspecting conditions per patient and hcc with the latest contributing factor rolled up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "latest_suspect_date": {"name": "latest_suspect_date", "description": "Latest date when the suspecting condition, observation, result, etc. was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "list_rollup", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8777647, "relation_name": "dev_thuxuan.hcc_suspecting.list_rollup", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith list as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , row_number() over (\r\n partition by\r\n patient_id\r\n , hcc_code\r\n order by suspect_date desc\r\n ) as row_num\r\n from {{ ref('hcc_suspecting__list') }}\r\n\r\n)\r\n\r\n, list_dedupe as (\r\n\r\n select\r\n patient_id\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , suspect_date as latest_suspect_date\r\n from list\r\n where row_num = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(latest_suspect_date as date) as latest_suspect_date\r\n from list_dedupe\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , hcc_code\r\n , hcc_description\r\n , reason\r\n , contributing_factor\r\n , latest_suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__list"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\final\\hcc_suspecting__list_rollup.sql", "compiled": true, "compiled_code": "\n\nwith list as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , row_number() over (\n partition by\n patient_id\n , hcc_code\n order by suspect_date desc\n ) as row_num\n from dev_thuxuan.hcc_suspecting.list\n\n)\n\n, list_dedupe as (\n\n select\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date as latest_suspect_date\n from list\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(latest_suspect_date as date) as latest_suspect_date\n from list_dedupe\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , latest_suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__summary": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\final\\hcc_suspecting__summary.sql", "original_file_path": "models\\hcc_suspecting\\final\\hcc_suspecting__summary.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__summary", "fqn": ["the_tuva_project", "hcc_suspecting", "final", "hcc_suspecting__summary"], "alias": "summary", "checksum": {"name": "sha256", "checksum": "8cf06addec18f7a1742311d153e25e4f60b204345c33c4e846a57382d0554280"}, "config": {"enabled": true, "alias": "summary", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This final model displays a rollup of suspecting conditions per patient.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_sex": {"name": "patient_sex", "description": "The gender of the patient.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__gender.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_birth_date": {"name": "patient_birth_date", "description": "The birth date of the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_age": {"name": "patient_age", "description": "The patient's current age.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspecting_gaps": {"name": "suspecting_gaps", "description": "Count of suspecting conditions.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "summary", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8797648, "relation_name": "dev_thuxuan.hcc_suspecting.summary", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith patients as (\r\n\r\n select\r\n patient_id\r\n , sex\r\n , birth_date\r\n {% if target.type == 'fabric' %}\r\n , floor({{ datediff('birth_date', 'GETDATE()', 'hour') }} / 8766.0) as age\r\n {% else %}\r\n , floor({{ datediff('birth_date', 'current_date', 'hour') }} / 8766.0) as age\r\n {% endif %}\r\n from {{ ref('hcc_suspecting__stg_core__patient') }}\r\n where death_date is null\r\n\r\n)\r\n\r\n, suspecting_list as (\r\n\r\n select\r\n patient_id\r\n , count(*) as gaps\r\n from {{ ref('hcc_suspecting__list') }}\r\n group by patient_id\r\n\r\n)\r\n\r\n, joined as (\r\n\r\n select\r\n patients.patient_id\r\n , patients.sex\r\n , patients.birth_date\r\n , patients.age\r\n , suspecting_list.gaps\r\n from patients\r\n inner join suspecting_list\r\n on patients.patient_id = suspecting_list.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(sex as {{ dbt.type_string() }}) as patient_sex\r\n , cast(birth_date as date) as patient_birth_date\r\n , cast(age as integer) as patient_age\r\n , cast(gaps as integer) as suspecting_gaps\r\n from joined\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , patient_sex\r\n , patient_birth_date\r\n , patient_age\r\n , suspecting_gaps\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__patient", "package": null, "version": null}, {"name": "hcc_suspecting__list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__patient", "model.the_tuva_project.hcc_suspecting__list"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\final\\hcc_suspecting__summary.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom dev_thuxuan.core.patient\n), patients as (\n\n select\n patient_id\n , sex\n , birth_date\n \n , floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8766.0) as age\n \n from __dbt__cte___stg_patient\n where death_date is null\n\n)\n\n, suspecting_list as (\n\n select\n patient_id\n , count(*) as gaps\n from dev_thuxuan.hcc_suspecting.list\n group by patient_id\n\n)\n\n, joined as (\n\n select\n patients.patient_id\n , patients.sex\n , patients.birth_date\n , patients.age\n , suspecting_list.gaps\n from patients\n inner join suspecting_list\n on patients.patient_id = suspecting_list.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(sex as TEXT) as patient_sex\n , cast(birth_date as date) as patient_birth_date\n , cast(age as integer) as patient_age\n , cast(gaps as integer) as suspecting_gaps\n from joined\n\n)\n\nselect\n patient_id\n , patient_sex\n , patient_birth_date\n , patient_age\n , suspecting_gaps\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_all_conditions": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_all_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_all_conditions.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_all_conditions.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_conditions", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_all_conditions"], "alias": "_int_all_conditions", "checksum": {"name": "sha256", "checksum": "31f7087d7800109df25b4f2bd2bfe15bef163cdf1ed470c43c7fd6be9bf04ff5"}, "config": {"enabled": true, "alias": "_int_all_conditions", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "All historical conditions mapped to HCCs.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code": {"name": "icd_10_cm_code", "description": "The ICD-10-CM condition code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_all_conditions", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8827646, "relation_name": "dev_thuxuan.hcc_suspecting._int_all_conditions", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n from {{ ref('hcc_suspecting__int_prep_conditions') }}\r\n\r\n)\r\n\r\n, seed_hcc_mapping as (\r\n\r\n select\r\n diagnosis_code\r\n , cms_hcc_v28 as hcc_code\r\n from {{ ref('hcc_suspecting__icd_10_cm_mappings') }}\r\n where cms_hcc_v28 is not null\r\n\r\n)\r\n\r\n, seed_hcc_descriptions as (\r\n\r\n select distinct\r\n hcc_code\r\n , hcc_description\r\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\r\n\r\n)\r\n\r\n, joined as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , conditions.condition_type\r\n , conditions.code\r\n , conditions.data_source\r\n , seed_hcc_mapping.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n from conditions\r\n left join seed_hcc_mapping\r\n on conditions.code = seed_hcc_mapping.diagnosis_code\r\n left join seed_hcc_descriptions\r\n on seed_hcc_mapping.hcc_code = seed_hcc_descriptions.hcc_code\r\n where conditions.code_type = 'icd-10-cm'\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(recorded_date as date) as recorded_date\r\n , cast(condition_type as {{ dbt.type_string() }}) as condition_type\r\n , cast(code as {{ dbt.type_string() }}) as icd_10_cm_code\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n from joined\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , icd_10_cm_code\r\n , hcc_code\r\n , hcc_description\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_conditions", "package": null, "version": null}, {"name": "hcc_suspecting__icd_10_cm_mappings", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_all_conditions.sql", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from dev_thuxuan.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n diagnosis_code\n , cms_hcc_v28 as hcc_code\n from dev_thuxuan.hcc_suspecting._value_set_icd_10_cm_mappings\n where cms_hcc_v28 is not null\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, joined as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code\n , conditions.data_source\n , seed_hcc_mapping.hcc_code\n , seed_hcc_descriptions.hcc_description\n from conditions\n left join seed_hcc_mapping\n on conditions.code = seed_hcc_mapping.diagnosis_code\n left join seed_hcc_descriptions\n on seed_hcc_mapping.hcc_code = seed_hcc_descriptions.hcc_code\n where conditions.code_type = 'icd-10-cm'\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(data_source as TEXT) as data_source\n from joined\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_all_medications": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_all_medications", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_all_medications.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_all_medications.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_medications", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_all_medications"], "alias": "_int_all_medications", "checksum": {"name": "sha256", "checksum": "f1698a3af45d12bf1514f7f9c76cba5e93eb85f88349473f05795ec3205509be"}, "config": {"enabled": true, "alias": "_int_all_medications", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Union of medications and pharmacy claims.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed or paid date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug_code": {"name": "drug_code", "description": "NDC or rxnorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "The type of drug code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_all_medications", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8847647, "relation_name": "dev_thuxuan.hcc_suspecting._int_all_medications", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith medications as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , source_code\r\n , source_code_type\r\n , ndc_code\r\n , rxnorm_code\r\n , data_source\r\n from {{ ref('hcc_suspecting__stg_core__medication') }}\r\n\r\n)\r\n\r\n, pharmacy_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(dispensing_date, paid_date) as dispensing_date\r\n , ndc_code as drug_code\r\n , 'ndc' as code_system\r\n , data_source\r\n from {{ ref('hcc_suspecting__stg_core__pharmacy_claim') }}\r\n\r\n)\r\n\r\n, ndc_medications as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code as drug_code\r\n , 'ndc' as code_system\r\n , data_source\r\n from medications\r\n where ndc_code is not null\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , source_code as drug_code\r\n , 'ndc' as code_system\r\n , data_source\r\n from medications\r\n where lower(source_code_type) = 'ndc'\r\n\r\n)\r\n\r\n, rxnorm_medications as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , rxnorm_code as drug_code\r\n , 'rxnorm' as code_system\r\n , data_source\r\n from medications\r\n where rxnorm_code is not null\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , source_code as drug_code\r\n , 'rxnorm' as code_system\r\n , data_source\r\n from medications\r\n where lower(source_code_type) = 'rxnorm'\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from pharmacy_claims\r\n union all\r\n select * from ndc_medications\r\n union all\r\n select * from rxnorm_medications\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(dispensing_date as date) as dispensing_date\r\n , cast(drug_code as {{ dbt.type_string() }}) as drug_code\r\n , cast(code_system as {{ dbt.type_string() }}) as code_system\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n from unioned\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , drug_code\r\n , code_system\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__medication", "package": null, "version": null}, {"name": "hcc_suspecting__stg_core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__medication", "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_all_medications.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom dev_thuxuan.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , coalesce(dispensing_date, paid_date) as dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, ndc_medications as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where ndc_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'ndc'\n\n)\n\n, rxnorm_medications as (\n\n select\n patient_id\n , dispensing_date\n , rxnorm_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where rxnorm_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'rxnorm'\n\n)\n\n, unioned as (\n\n select * from pharmacy_claims\n union all\n select * from ndc_medications\n union all\n select * from rxnorm_medications\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n , cast(code_system as TEXT) as code_system\n , cast(data_source as TEXT) as data_source\n from unioned\n\n)\n\nselect\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom dev_thuxuan.core.medication\n\n\n)"}, {"id": "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_comorbidity_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_comorbidity_suspects.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_comorbidity_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_comorbidity_suspects"], "alias": "_int_comorbidity_suspects", "checksum": {"name": "sha256", "checksum": "ff5803757da12ce8ee3cb19545e9dd0a1ba2f3aff07b5ea8ded13910b35a71b5"}, "config": {"enabled": true, "alias": "_int_comorbidity_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting comorbidities.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_1_concept_name": {"name": "condition_1_concept_name", "description": "Clinical concept name for the first comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_1_code": {"name": "condition_1_code", "description": "Condition code for the first comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_1_recorded_date": {"name": "condition_1_recorded_date", "description": "Recorded date for the first comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_2_concept_name": {"name": "condition_2_concept_name", "description": "Clinical concept name for the second comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_2_code": {"name": "condition_2_code", "description": "Condition code for the second comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_2_recorded_date": {"name": "condition_2_recorded_date", "description": "Recorded date for the second comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting condition was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_comorbidity_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8887649, "relation_name": "dev_thuxuan.hcc_suspecting._int_comorbidity_suspects", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n from {{ ref('hcc_suspecting__int_prep_conditions') }}\r\n\r\n)\r\n\r\n, seed_clinical_concepts as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('hcc_suspecting__clinical_concepts') }}\r\n\r\n)\r\n\r\n, seed_hcc_descriptions as (\r\n\r\n select distinct\r\n hcc_code\r\n , hcc_description\r\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\r\n\r\n)\r\n\r\n, billed_hccs as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , current_year_billed\r\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\r\n\r\n)\r\n\r\n/* BEGIN HCC 37 logic */\r\n, ckd_stage_1_or_2 as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , conditions.condition_type\r\n , conditions.code_type\r\n , conditions.code\r\n , conditions.data_source\r\n , seed_clinical_concepts.concept_name\r\n , row_number() over (\r\n partition by\r\n conditions.patient_id\r\n , conditions.data_source\r\n order by\r\n conditions.recorded_date desc\r\n , conditions.code desc\r\n ) as row_num\r\n from conditions\r\n inner join seed_clinical_concepts\r\n on conditions.code_type = seed_clinical_concepts.code_system\r\n and conditions.code = seed_clinical_concepts.code\r\n where lower(seed_clinical_concepts.concept_name) in (\r\n 'chronic kidney disease, stage 1'\r\n , 'chronic kidney disease, stage 2'\r\n )\r\n\r\n)\r\n\r\n, ckd_stage_1_or_2_dedupe as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n , concept_name\r\n from ckd_stage_1_or_2\r\n where row_num = 1\r\n\r\n)\r\n\r\n, diabetes as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , conditions.condition_type\r\n , conditions.code_type\r\n , conditions.code\r\n , conditions.data_source\r\n , seed_clinical_concepts.concept_name\r\n , row_number() over (\r\n partition by\r\n conditions.patient_id\r\n , conditions.data_source\r\n order by\r\n conditions.recorded_date desc\r\n , conditions.code desc\r\n ) as row_num\r\n from conditions\r\n inner join seed_clinical_concepts\r\n on conditions.code_type = seed_clinical_concepts.code_system\r\n and conditions.code = seed_clinical_concepts.code\r\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\r\n)\r\n\r\n, diabetes_dedupe as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n , concept_name\r\n from diabetes\r\n where row_num = 1\r\n\r\n)\r\n\r\n, hcc_37_suspect as (\r\n\r\n select\r\n diabetes_dedupe.patient_id\r\n , diabetes_dedupe.data_source\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n , diabetes_dedupe.concept_name as condition_1_concept_name\r\n , diabetes_dedupe.code as condition_1_code\r\n , diabetes_dedupe.recorded_date as condition_1_recorded_date\r\n , ckd_stage_1_or_2_dedupe.concept_name as condition_2_concept_name\r\n , ckd_stage_1_or_2_dedupe.code as condition_2_code\r\n , ckd_stage_1_or_2_dedupe.recorded_date as condition_2_recorded_date\r\n from diabetes_dedupe\r\n inner join ckd_stage_1_or_2_dedupe\r\n on diabetes_dedupe.patient_id = ckd_stage_1_or_2_dedupe.patient_id\r\n and diabetes_dedupe.data_source = ckd_stage_1_or_2_dedupe.data_source\r\n /* ensure conditions overlap in the same year */\r\n and {{ date_part('year', 'diabetes_dedupe.recorded_date') }} = {{ date_part('year', 'ckd_stage_1_or_2_dedupe.recorded_date') }}\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '37'\r\n\r\n)\r\n/* END HCC 37 logic */\r\n\r\n, unioned as (\r\n\r\n select * from hcc_37_suspect\r\n\r\n)\r\n\r\n, add_billed_flag as (\r\n\r\n select\r\n unioned.patient_id\r\n , unioned.data_source\r\n , unioned.hcc_code\r\n , unioned.hcc_description\r\n , unioned.condition_1_concept_name\r\n , unioned.condition_1_code\r\n , unioned.condition_1_recorded_date\r\n , unioned.condition_2_concept_name\r\n , unioned.condition_2_code\r\n , unioned.condition_2_recorded_date\r\n , billed_hccs.current_year_billed\r\n from unioned\r\n left join billed_hccs\r\n on unioned.patient_id = billed_hccs.patient_id\r\n and unioned.data_source = billed_hccs.data_source\r\n and unioned.hcc_code = billed_hccs.hcc_code\r\n\r\n)\r\n\r\n, add_standard_fields as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , condition_1_concept_name\r\n , condition_1_code\r\n , condition_1_recorded_date\r\n , condition_2_concept_name\r\n , condition_2_code\r\n , condition_2_recorded_date\r\n , current_year_billed\r\n , cast('Comorbidity suspect' as {{ dbt.type_string() }}) as reason\r\n , {{ dbt.concat([\r\n \"condition_1_concept_name\",\r\n \"' ('\",\r\n \"condition_1_code\",\r\n \"') on '\",\r\n \"condition_1_recorded_date\",\r\n \"') and '\",\r\n \"condition_2_concept_name\",\r\n \"' ('\",\r\n \"condition_2_code\",\r\n \"') on '\",\r\n \"condition_2_recorded_date\"\r\n ]) }} as contributing_factor\r\n , condition_1_recorded_date as suspect_date\r\n from add_billed_flag\r\n\r\n)\r\n\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n , cast(condition_1_concept_name as {{ dbt.type_string() }}) as condition_1_concept_name\r\n , cast(condition_1_code as {{ dbt.type_string() }}) as condition_1_code\r\n , cast(condition_1_recorded_date as date) as condition_1_recorded_date\r\n , cast(condition_2_concept_name as {{ dbt.type_string() }}) as condition_2_concept_name\r\n , cast(condition_2_code as {{ dbt.type_string() }}) as condition_2_code\r\n , cast(condition_2_recorded_date as date) as condition_2_recorded_date\r\n {% if target.type == 'fabric' %}\r\n , cast(current_year_billed as bit) as current_year_billed\r\n {% else %}\r\n , cast(current_year_billed as boolean) as current_year_billed\r\n {% endif %}\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(suspect_date as date) as suspect_date\r\n from add_standard_fields\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , condition_1_concept_name\r\n , condition_1_code\r\n , condition_1_recorded_date\r\n , condition_2_concept_name\r\n , condition_2_code\r\n , condition_2_recorded_date\r\n , current_year_billed\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_conditions", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_comorbidity_suspects.sql", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from dev_thuxuan.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 37 logic */\n, ckd_stage_1_or_2 as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) in (\n 'chronic kidney disease, stage 1'\n , 'chronic kidney disease, stage 2'\n )\n\n)\n\n, ckd_stage_1_or_2_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from ckd_stage_1_or_2\n where row_num = 1\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n)\n\n, diabetes_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from diabetes\n where row_num = 1\n\n)\n\n, hcc_37_suspect as (\n\n select\n diabetes_dedupe.patient_id\n , diabetes_dedupe.data_source\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , diabetes_dedupe.concept_name as condition_1_concept_name\n , diabetes_dedupe.code as condition_1_code\n , diabetes_dedupe.recorded_date as condition_1_recorded_date\n , ckd_stage_1_or_2_dedupe.concept_name as condition_2_concept_name\n , ckd_stage_1_or_2_dedupe.code as condition_2_code\n , ckd_stage_1_or_2_dedupe.recorded_date as condition_2_recorded_date\n from diabetes_dedupe\n inner join ckd_stage_1_or_2_dedupe\n on diabetes_dedupe.patient_id = ckd_stage_1_or_2_dedupe.patient_id\n and diabetes_dedupe.data_source = ckd_stage_1_or_2_dedupe.data_source\n /* ensure conditions overlap in the same year */\n and date_part('year', diabetes_dedupe.recorded_date) = date_part('year', ckd_stage_1_or_2_dedupe.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '37'\n\n)\n/* END HCC 37 logic */\n\n, unioned as (\n\n select * from hcc_37_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.condition_1_concept_name\n , unioned.condition_1_code\n , unioned.condition_1_recorded_date\n , unioned.condition_2_concept_name\n , unioned.condition_2_code\n , unioned.condition_2_recorded_date\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , cast('Comorbidity suspect' as TEXT) as reason\n , condition_1_concept_name || ' (' || condition_1_code || ') on ' || condition_1_recorded_date || ') and ' || condition_2_concept_name || ' (' || condition_2_code || ') on ' || condition_2_recorded_date as contributing_factor\n , condition_1_recorded_date as suspect_date\n from add_billed_flag\n\n)\n\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(condition_1_concept_name as TEXT) as condition_1_concept_name\n , cast(condition_1_code as TEXT) as condition_1_code\n , cast(condition_1_recorded_date as date) as condition_1_recorded_date\n , cast(condition_2_concept_name as TEXT) as condition_2_concept_name\n , cast(condition_2_code as TEXT) as condition_2_code\n , cast(condition_2_recorded_date as date) as condition_2_recorded_date\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_lab_suspects": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_lab_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_lab_suspects.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_lab_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_lab_suspects"], "alias": "_int_lab_suspects", "checksum": {"name": "sha256", "checksum": "f0fdcfcb2b0d87f7647c3d8ccece0a1830fdf20c2a6e321240fcf75ac66d2164"}, "config": {"enabled": true, "alias": "_int_lab_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting conditions based on labs.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "Cleaned numeric result of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "lab_code": {"name": "lab_code", "description": "The normalized code or source code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting lab result was recorded.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_lab_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8927717, "relation_name": "dev_thuxuan.hcc_suspecting._int_lab_suspects", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith egfr_labs as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , result_date\r\n , result\r\n from {{ ref('hcc_suspecting__int_prep_egfr_labs') }}\r\n\r\n)\r\n\r\n, seed_hcc_descriptions as (\r\n\r\n select distinct\r\n hcc_code\r\n , hcc_description\r\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\r\n\r\n)\r\n\r\n, billed_hccs as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , current_year_billed\r\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\r\n\r\n)\r\n\r\n/* BEGIN CKD logic */\r\n\r\n/*\r\n Find a patient\u2019s two most recent eGFR lab results that are spaced by at\r\n least 90 days.\r\n*/\r\n, max_lab_date as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , max(result_date) as max_result_date\r\n from egfr_labs\r\n group by\r\n patient_id\r\n , data_source\r\n\r\n)\r\n\r\n, lab_lookback as (\r\n\r\n select\r\n egfr_labs.patient_id\r\n , egfr_labs.data_source\r\n , max_lab_date.max_result_date\r\n , max(egfr_labs.result_date) as lookback_result_date\r\n from egfr_labs\r\n left join max_lab_date\r\n on egfr_labs.patient_id = max_lab_date.patient_id\r\n and egfr_labs.data_source = max_lab_date.data_source\r\n where egfr_labs.result_date <= {{ dateadd('day', -90, 'max_result_date') }}\r\n group by\r\n egfr_labs.patient_id\r\n , egfr_labs.data_source\r\n , max_lab_date.max_result_date\r\n\r\n)\r\n\r\n/*\r\n Take the highest eGFR result that occurred between the date range.\r\n*/\r\n, eligible_labs as (\r\n\r\n select\r\n egfr_labs.patient_id\r\n , egfr_labs.data_source\r\n , egfr_labs.code_type\r\n , egfr_labs.code\r\n , egfr_labs.result_date\r\n , egfr_labs.result\r\n , row_number() over (\r\n partition by\r\n egfr_labs.patient_id\r\n , egfr_labs.data_source\r\n order by egfr_labs.result desc\r\n ) as row_num\r\n from egfr_labs\r\n inner join lab_lookback\r\n on egfr_labs.patient_id = lab_lookback.patient_id\r\n and egfr_labs.data_source = lab_lookback.data_source\r\n where egfr_labs.result_date >= lab_lookback.lookback_result_date\r\n\r\n)\r\n\r\n/*\r\n Assign a patient's kidney disease stage based on the highest eGFR based on\r\n the following range:\r\n\r\n CKD 3a: eGFR in the range (45-59)\r\n CKD 3b: eGFR in the range (30-44)\r\n CKD 4: eGFR in the range (15-29)\r\n CKD 5: eGFR in the range (0-14)\r\n*/\r\n, ckd_suspects as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code as lab_code\r\n , result_date\r\n , result\r\n , case\r\n when result between 0 and 14 then '326'\r\n when result between 15 and 29 then '327'\r\n when result between 30 and 44 then '328'\r\n when result between 45 and 59 then '329'\r\n end as hcc_code\r\n , {{ dbt.concat([\r\n \"'eGFR ('\",\r\n \"code\",\r\n \"') result '\",\r\n \"result\",\r\n \"' on '\",\r\n \"result_date\"\r\n ]) }} as contributing_factor\r\n from eligible_labs\r\n where row_num = 1\r\n\r\n)\r\n/* END CKD logic */\r\n\r\n, unioned as (\r\n\r\n select * from ckd_suspects\r\n\r\n)\r\n\r\n, add_billed_flag as (\r\n\r\n select\r\n unioned.patient_id\r\n , unioned.data_source\r\n , unioned.result_date\r\n , unioned.result\r\n , unioned.lab_code\r\n , unioned.hcc_code\r\n , unioned.contributing_factor\r\n , seed_hcc_descriptions.hcc_description\r\n , billed_hccs.current_year_billed\r\n from unioned\r\n inner join seed_hcc_descriptions\r\n on unioned.hcc_code = seed_hcc_descriptions.hcc_code\r\n left join billed_hccs\r\n on unioned.patient_id = billed_hccs.patient_id\r\n and unioned.data_source = billed_hccs.data_source\r\n and unioned.hcc_code = billed_hccs.hcc_code\r\n\r\n)\r\n\r\n, add_standard_fields as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , result_date\r\n , result\r\n , lab_code\r\n , hcc_code\r\n , hcc_description\r\n , contributing_factor\r\n , current_year_billed\r\n , cast('Lab result suspect' as {{ dbt.type_string() }}) as reason\r\n , result_date as suspect_date\r\n from add_billed_flag\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(result_date as date) as result_date\r\n , cast(result as {{ dbt.type_numeric() }}) as result\r\n , cast(lab_code as {{ dbt.type_string() }}) as lab_code\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n {% if target.type == 'fabric' %}\r\n , cast(current_year_billed as bit) as current_year_billed\r\n {% else %}\r\n , cast(current_year_billed as boolean) as current_year_billed\r\n {% endif %}\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(suspect_date as date) as suspect_date\r\n from add_standard_fields\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , result_date\r\n , result\r\n , lab_code\r\n , hcc_code\r\n , hcc_description\r\n , current_year_billed\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_egfr_labs", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.concat", "macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_lab_suspects.sql", "compiled": true, "compiled_code": "\n\nwith egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from dev_thuxuan.hcc_suspecting._int_prep_egfr_labs\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN CKD logic */\n\n/*\n Find a patient\u2019s two most recent eGFR lab results that are spaced by at\n least 90 days.\n*/\n, max_lab_date as (\n\n select\n patient_id\n , data_source\n , max(result_date) as max_result_date\n from egfr_labs\n group by\n patient_id\n , data_source\n\n)\n\n, lab_lookback as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n , max(egfr_labs.result_date) as lookback_result_date\n from egfr_labs\n left join max_lab_date\n on egfr_labs.patient_id = max_lab_date.patient_id\n and egfr_labs.data_source = max_lab_date.data_source\n where egfr_labs.result_date <= \n\n dateadd(\n day,\n -90,\n max_result_date\n )\n\n\n group by\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n\n)\n\n/*\n Take the highest eGFR result that occurred between the date range.\n*/\n, eligible_labs as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , egfr_labs.code_type\n , egfr_labs.code\n , egfr_labs.result_date\n , egfr_labs.result\n , row_number() over (\n partition by\n egfr_labs.patient_id\n , egfr_labs.data_source\n order by egfr_labs.result desc\n ) as row_num\n from egfr_labs\n inner join lab_lookback\n on egfr_labs.patient_id = lab_lookback.patient_id\n and egfr_labs.data_source = lab_lookback.data_source\n where egfr_labs.result_date >= lab_lookback.lookback_result_date\n\n)\n\n/*\n Assign a patient's kidney disease stage based on the highest eGFR based on\n the following range:\n\n CKD 3a: eGFR in the range (45-59)\n CKD 3b: eGFR in the range (30-44)\n CKD 4: eGFR in the range (15-29)\n CKD 5: eGFR in the range (0-14)\n*/\n, ckd_suspects as (\n\n select\n patient_id\n , data_source\n , code_type\n , code as lab_code\n , result_date\n , result\n , case\n when result between 0 and 14 then '326'\n when result between 15 and 29 then '327'\n when result between 30 and 44 then '328'\n when result between 45 and 59 then '329'\n end as hcc_code\n , 'eGFR (' || code || ') result ' || result || ' on ' || result_date as contributing_factor\n from eligible_labs\n where row_num = 1\n\n)\n/* END CKD logic */\n\n, unioned as (\n\n select * from ckd_suspects\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.result_date\n , unioned.result\n , unioned.lab_code\n , unioned.hcc_code\n , unioned.contributing_factor\n , seed_hcc_descriptions.hcc_description\n , billed_hccs.current_year_billed\n from unioned\n inner join seed_hcc_descriptions\n on unioned.hcc_code = seed_hcc_descriptions.hcc_code\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Lab result suspect' as TEXT) as reason\n , result_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n , cast(lab_code as TEXT) as lab_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_medication_suspects": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_medication_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_medication_suspects.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_medication_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_medication_suspects"], "alias": "_int_medication_suspects", "checksum": {"name": "sha256", "checksum": "d854abebaf7c385d828d4f191dcb971cfcabe40589ea40e7b37302fb4d406cd3"}, "config": {"enabled": true, "alias": "_int_medication_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting conditions based on medications.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the medication was dispensed or paid date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug_code": {"name": "drug_code", "description": "NDC or rxnorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting medication was dispensed or paid.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_medication_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8947723, "relation_name": "dev_thuxuan.hcc_suspecting._int_medication_suspects", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith all_medications as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , drug_code\r\n , code_system\r\n , data_source\r\n from {{ ref('hcc_suspecting__int_all_medications') }}\r\n\r\n)\r\n\r\n, seed_clinical_concepts as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('hcc_suspecting__clinical_concepts') }}\r\n\r\n)\r\n\r\n, seed_hcc_descriptions as (\r\n\r\n select distinct\r\n hcc_code\r\n , hcc_description\r\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\r\n\r\n)\r\n\r\n, billed_hccs as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , current_year_billed\r\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\r\n\r\n)\r\n\r\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\r\n\r\n antidepressant medication taken within the past five years\r\n*/\r\n, hcc_155_suspect as (\r\n\r\n select\r\n all_medications.patient_id\r\n , all_medications.dispensing_date\r\n , all_medications.drug_code\r\n , all_medications.code_system\r\n , all_medications.data_source\r\n , seed_clinical_concepts.concept_name\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n from all_medications\r\n inner join seed_clinical_concepts\r\n on all_medications.code_system = seed_clinical_concepts.code_system\r\n and all_medications.drug_code = seed_clinical_concepts.code\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '155'\r\n where lower(seed_clinical_concepts.concept_name) = 'antidepressant medication'\r\n and all_medications.dispensing_date >= {{ dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -5\r\n , from_date_or_timestamp = dbt.current_timestamp()\r\n ) }}\r\n\r\n)\r\n/* END HCC 155 logic */\r\n\r\n, unioned as (\r\n\r\n select * from hcc_155_suspect\r\n\r\n)\r\n\r\n, add_billed_flag as (\r\n\r\n select\r\n unioned.patient_id\r\n , unioned.data_source\r\n , unioned.hcc_code\r\n , unioned.hcc_description\r\n , unioned.concept_name\r\n , unioned.dispensing_date\r\n , unioned.drug_code\r\n , billed_hccs.current_year_billed\r\n from unioned\r\n left join billed_hccs\r\n on unioned.patient_id = billed_hccs.patient_id\r\n and unioned.data_source = billed_hccs.data_source\r\n and unioned.hcc_code = billed_hccs.hcc_code\r\n)\r\n\r\n, add_standard_fields as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , dispensing_date\r\n , drug_code\r\n , current_year_billed\r\n , cast('Medication suspect' as {{ dbt.type_string() }}) as reason\r\n , {{ dbt.concat([\r\n \"concept_name\",\r\n \"drug_code\",\r\n \"') dispensed on '\",\r\n \"dispensing_date\" ]) }} as contributing_factor\r\n , dispensing_date as suspect_date\r\n from add_billed_flag\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n , cast(dispensing_date as date) as dispensing_date\r\n , cast(drug_code as {{ dbt.type_string() }}) as drug_code\r\n {% if target.type == 'fabric' %}\r\n , cast(current_year_billed as bit) as current_year_billed\r\n {% else %}\r\n , cast(current_year_billed as boolean) as current_year_billed\r\n {% endif %}\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(suspect_date as date) as suspect_date\r\n from add_standard_fields\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , dispensing_date\r\n , drug_code\r\n , current_year_billed\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_all_medications", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.dateadd", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_all_medications", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_medication_suspects.sql", "compiled": true, "compiled_code": "\n\nwith all_medications as (\n\n select\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n from dev_thuxuan.hcc_suspecting._int_all_medications\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n antidepressant medication taken within the past five years\n*/\n, hcc_155_suspect as (\n\n select\n all_medications.patient_id\n , all_medications.dispensing_date\n , all_medications.drug_code\n , all_medications.code_system\n , all_medications.data_source\n , seed_clinical_concepts.concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from all_medications\n inner join seed_clinical_concepts\n on all_medications.code_system = seed_clinical_concepts.code_system\n and all_medications.drug_code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where lower(seed_clinical_concepts.concept_name) = 'antidepressant medication'\n and all_medications.dispensing_date >= \n\n dateadd(\n year,\n -5,\n convert_timezone('UTC', current_timestamp())\n )\n\n\n\n)\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.concept_name\n , unioned.dispensing_date\n , unioned.drug_code\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , cast('Medication suspect' as TEXT) as reason\n , concept_name || drug_code || ') dispensed on ' || dispensing_date as contributing_factor\n , dispensing_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_observation_suspects": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_observation_suspects", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_observation_suspects.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_observation_suspects.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_observation_suspects"], "alias": "_int_observation_suspects", "checksum": {"name": "sha256", "checksum": "380d9977224a2de68365fe053934feb699ab69c59885736b776ed046bd435c2a"}, "config": {"enabled": true, "alias": "_int_observation_suspects", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Suspecting observation conditions.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "Date the observation was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_result": {"name": "observation_result", "description": "The result of the observation.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_code": {"name": "condition_code", "description": "The code for the comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_date": {"name": "condition_date", "description": "Recorded date for the condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_concept_name": {"name": "condition_concept_name", "description": "Clinical concept name for the comorbid condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting observation was recorded.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_observation_suspects", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.8977726, "relation_name": "dev_thuxuan.hcc_suspecting._int_observation_suspects", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n from {{ ref('hcc_suspecting__int_prep_conditions') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , result\r\n , code_type\r\n , code\r\n , data_source\r\n from {{ ref('hcc_suspecting__stg_core__observation') }}\r\n\r\n)\r\n\r\n, numeric_observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n {% if target.type == 'fabric' %}\r\n , TRY_CAST(result AS {{ dbt.type_numeric() }}) AS result\r\n {% else %}\r\n , CAST(result AS {{ dbt.type_numeric() }}) AS result\r\n {% endif %}\r\n , code_type\r\n , code\r\n , data_source\r\n from observations\r\n {% if target.type == 'fabric' %}\r\n WHERE result LIKE '%.%' OR result LIKE '%[0-9]%'\r\n AND result NOT LIKE '%[^0-9.]%'\r\n {% else %}\r\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\r\n {% endif %}\r\n\r\n)\r\n\r\n, seed_clinical_concepts as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('hcc_suspecting__clinical_concepts') }}\r\n\r\n)\r\n\r\n, seed_hcc_descriptions as (\r\n\r\n select distinct\r\n hcc_code\r\n , hcc_description\r\n from {{ ref('hcc_suspecting__hcc_descriptions') }}\r\n\r\n)\r\n\r\n, billed_hccs as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , current_year_billed\r\n from {{ ref('hcc_suspecting__int_patient_hcc_history') }}\r\n\r\n)\r\n\r\n, depression_assessment as (\r\n\r\n select\r\n numeric_observations.patient_id\r\n , numeric_observations.observation_date\r\n , numeric_observations.result\r\n , numeric_observations.code_type\r\n , numeric_observations.code\r\n , numeric_observations.data_source\r\n , seed_clinical_concepts.concept_name\r\n from numeric_observations\r\n inner join seed_clinical_concepts\r\n on numeric_observations.code_type = seed_clinical_concepts.code_system\r\n and numeric_observations.code = seed_clinical_concepts.code\r\n where lower(seed_clinical_concepts.concept_name) = 'depression assessment (phq-9)'\r\n\r\n)\r\n\r\n, diabetes as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , conditions.condition_type\r\n , conditions.code_type\r\n , conditions.code\r\n , conditions.data_source\r\n , seed_clinical_concepts.concept_name\r\n from conditions\r\n inner join seed_clinical_concepts\r\n on conditions.code_type = seed_clinical_concepts.code_system\r\n and conditions.code = seed_clinical_concepts.code\r\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\r\n\r\n)\r\n\r\n, hypertension as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , conditions.condition_type\r\n , conditions.code_type\r\n , conditions.code\r\n , conditions.data_source\r\n , seed_clinical_concepts.concept_name\r\n from conditions\r\n inner join seed_clinical_concepts\r\n on conditions.code_type = seed_clinical_concepts.code_system\r\n and conditions.code = seed_clinical_concepts.code\r\n where lower(seed_clinical_concepts.concept_name) = 'essential hypertension'\r\n\r\n)\r\n\r\n, obstructive_sleep_apnea as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , conditions.condition_type\r\n , conditions.code_type\r\n , conditions.code\r\n , conditions.data_source\r\n , seed_clinical_concepts.concept_name\r\n from conditions\r\n inner join seed_clinical_concepts\r\n on conditions.code_type = seed_clinical_concepts.code_system\r\n and conditions.code = seed_clinical_concepts.code\r\n where lower(seed_clinical_concepts.concept_name) = 'obstructive sleep apnea'\r\n\r\n)\r\n\r\n/* BEGIN HCC 48 logic (Morbid Obesity) */\r\n, bmi_over_30_with_osa as (\r\n\r\n select\r\n numeric_observations.patient_id\r\n , numeric_observations.data_source\r\n , numeric_observations.observation_date\r\n , numeric_observations.result as observation_result\r\n , obstructive_sleep_apnea.code as condition_code\r\n , obstructive_sleep_apnea.recorded_date as condition_date\r\n , obstructive_sleep_apnea.concept_name as condition_concept_name\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n from numeric_observations\r\n inner join seed_clinical_concepts\r\n on numeric_observations.code_type = seed_clinical_concepts.code_system\r\n and numeric_observations.code = seed_clinical_concepts.code\r\n inner join obstructive_sleep_apnea\r\n on numeric_observations.patient_id = obstructive_sleep_apnea.patient_id\r\n /* ensure bmi and condition overlaps in the same year */\r\n and {{ date_part('year', 'numeric_observations.observation_date') }} = {{ date_part('year', 'obstructive_sleep_apnea.recorded_date') }}\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '48'\r\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\r\n and result >= 30\r\n\r\n)\r\n\r\n, bmi_over_35_with_diabetes as (\r\n\r\n select\r\n numeric_observations.patient_id\r\n , numeric_observations.data_source\r\n , numeric_observations.observation_date\r\n , numeric_observations.result as observation_result\r\n , diabetes.code as condition_code\r\n , diabetes.recorded_date as condition_date\r\n , diabetes.concept_name as condition_concept_name\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n from numeric_observations\r\n inner join seed_clinical_concepts\r\n on numeric_observations.code_type = seed_clinical_concepts.code_system\r\n and numeric_observations.code = seed_clinical_concepts.code\r\n inner join diabetes\r\n on numeric_observations.patient_id = diabetes.patient_id\r\n /* ensure bmi and condition overlaps in the same year */\r\n and {{ date_part('year', 'numeric_observations.observation_date') }} = {{ date_part('year', 'diabetes.recorded_date') }}\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '48'\r\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\r\n and result >= 35\r\n\r\n)\r\n\r\n, bmi_over_35_with_hypertension as (\r\n\r\n select\r\n numeric_observations.patient_id\r\n , numeric_observations.data_source\r\n , numeric_observations.observation_date\r\n , numeric_observations.result as observation_result\r\n , hypertension.code as condition_code\r\n , hypertension.recorded_date as condition_date\r\n , hypertension.concept_name as condition_concept_name\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n from numeric_observations\r\n inner join seed_clinical_concepts\r\n on numeric_observations.code_type = seed_clinical_concepts.code_system\r\n and numeric_observations.code = seed_clinical_concepts.code\r\n inner join hypertension\r\n on numeric_observations.patient_id = hypertension.patient_id\r\n /* ensure bmi and condition overlaps in the same year */\r\n and {{ date_part('year', 'numeric_observations.observation_date') }} = {{ date_part('year', 'hypertension.recorded_date') }}\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '48'\r\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\r\n and result >= 35\r\n\r\n)\r\n\r\n, bmi_over_40 as (\r\n\r\n select\r\n numeric_observations.patient_id\r\n , numeric_observations.data_source\r\n , numeric_observations.observation_date\r\n , numeric_observations.result as observation_result\r\n , cast(null as {{ dbt.type_string() }}) as condition_code\r\n , cast(null as date) as condition_date\r\n , cast(null as {{ dbt.type_string() }}) as condition_concept_name\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n from numeric_observations\r\n inner join seed_clinical_concepts\r\n on numeric_observations.code_type = seed_clinical_concepts.code_system\r\n and numeric_observations.code = seed_clinical_concepts.code\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '48'\r\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\r\n and result >= 40\r\n\r\n)\r\n\r\n, hcc_48_unioned as (\r\n\r\n select * from bmi_over_30_with_osa\r\n union all\r\n select * from bmi_over_35_with_diabetes\r\n union all\r\n select * from bmi_over_35_with_hypertension\r\n union all\r\n select * from bmi_over_40\r\n\r\n)\r\n\r\n, hcc_48_suspect as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , observation_date\r\n , observation_result\r\n , condition_code\r\n , condition_date\r\n , condition_concept_name\r\n , hcc_code\r\n , hcc_description\r\n , {{ dbt.concat([\r\n \"'BMI result '\",\r\n \"observation_result\",\r\n \"case\"\r\n \" when condition_code is null then '' \"\r\n \" else \" ~\r\n dbt.concat([\"' with '\",\r\n \"condition_concept_name\",\r\n \"'('\",\r\n \"condition_code\",\r\n \"' on '\",\r\n \"condition_date\",\r\n \"')'\"]) ~\r\n \" end\"\r\n ]) }} as contributing_factor\r\n from hcc_48_unioned\r\n\r\n)\r\n/* END HCC 48 logic */\r\n\r\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\r\n\r\n to determine a positive PHQ-9 assessment, we look at the past 3 screenings\r\n for a patient and take the highest result\r\n*/\r\n, eligible_depression_assessments as (\r\n\r\n select\r\n depression_assessment.patient_id\r\n , depression_assessment.observation_date\r\n , depression_assessment.result\r\n , depression_assessment.code_type\r\n , depression_assessment.code\r\n , depression_assessment.data_source\r\n , depression_assessment.concept_name\r\n , row_number() over (\r\n partition by\r\n depression_assessment.patient_id\r\n , depression_assessment.data_source\r\n order by\r\n case when depression_assessment.observation_date is null then 1 else 0 end,\r\n depression_assessment.observation_date desc\r\n ) assessment_order\r\n from depression_assessment\r\n\r\n)\r\n\r\n, depression_assessments_ordered as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , code_type\r\n , code\r\n , data_source\r\n , concept_name\r\n , result\r\n , row_number() over (\r\n partition by\r\n patient_id\r\n , data_source\r\n --order by result desc nulls last\r\n order by\r\n case when result is null then 1 else 0 end,\r\n result desc\r\n ) as result_order --order the last three assessments by result value\r\n from eligible_depression_assessments\r\n where assessment_order <= 3\r\n\r\n)\r\n\r\n, hcc_155_suspect as (\r\n\r\n select\r\n depression_assessments_ordered.patient_id\r\n , depression_assessments_ordered.data_source\r\n , depression_assessments_ordered.observation_date\r\n , depression_assessments_ordered.result as observation_result\r\n , cast(null as {{ dbt.type_string() }}) as condition_code\r\n , cast(null as date) as condition_date\r\n , depression_assessments_ordered.concept_name as condition_concept_name\r\n , seed_hcc_descriptions.hcc_code\r\n , seed_hcc_descriptions.hcc_description\r\n , {{ dbt.concat([\r\n \"'PHQ-9 result '\",\r\n \"depression_assessments_ordered.result\",\r\n \"' on '\",\r\n \"depression_assessments_ordered.observation_date\"]) }} as contributing_factor\r\n from depression_assessments_ordered\r\n inner join seed_hcc_descriptions\r\n on hcc_code = '155'\r\n where result_order = 1\r\n and result >= 15\r\n\r\n)\r\n\r\n/* END HCC 155 logic */\r\n\r\n, unioned as (\r\n\r\n select * from hcc_48_suspect\r\n union all\r\n select * from hcc_155_suspect\r\n\r\n)\r\n\r\n, add_billed_flag as (\r\n\r\n select\r\n unioned.patient_id\r\n , unioned.data_source\r\n , unioned.observation_date\r\n , unioned.observation_result\r\n , unioned.condition_code\r\n , unioned.condition_date\r\n , unioned.condition_concept_name\r\n , unioned.hcc_code\r\n , unioned.hcc_description\r\n , unioned.contributing_factor\r\n , billed_hccs.current_year_billed\r\n from unioned\r\n left join billed_hccs\r\n on unioned.patient_id = billed_hccs.patient_id\r\n and unioned.data_source = billed_hccs.data_source\r\n and unioned.hcc_code = billed_hccs.hcc_code\r\n\r\n)\r\n\r\n, add_standard_fields as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , observation_date\r\n , observation_result\r\n , condition_code\r\n , condition_date\r\n , condition_concept_name\r\n , hcc_code\r\n , hcc_description\r\n , contributing_factor\r\n , current_year_billed\r\n , cast('Observation suspect' as {{ dbt.type_string() }}) as reason\r\n , observation_date as suspect_date\r\n from add_billed_flag\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(observation_date as date) as observation_date\r\n , cast(observation_result as {{ dbt.type_string() }}) as observation_result\r\n , cast(condition_code as {{ dbt.type_string() }}) as condition_code\r\n , cast(condition_date as date) as condition_date\r\n , cast(condition_concept_name as {{ dbt.type_string() }}) as condition_concept_name\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n {% if target.type == 'fabric' %}\r\n , cast(current_year_billed as bit) as current_year_billed\r\n {% else %}\r\n , cast(current_year_billed as boolean) as current_year_billed\r\n {% endif %}\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(suspect_date as date) as suspect_date\r\n from add_standard_fields\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , observation_date\r\n , observation_result\r\n , condition_code\r\n , condition_date\r\n , condition_concept_name\r\n , hcc_code\r\n , hcc_description\r\n , current_year_billed\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_prep_conditions", "package": null, "version": null}, {"name": "hcc_suspecting__stg_core__observation", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}, {"name": "hcc_suspecting__hcc_descriptions", "package": null, "version": null}, {"name": "hcc_suspecting__int_patient_hcc_history", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.the_tuva_project.apply_regex", "macro.the_tuva_project.date_part", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "model.the_tuva_project.hcc_suspecting__stg_core__observation", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_observation_suspects.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom dev_thuxuan.core.observation\n\n\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from dev_thuxuan.hcc_suspecting._int_prep_conditions\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , result\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_observation\n\n)\n\n, numeric_observations as (\n\n select\n patient_id\n , observation_date\n \n , CAST(result AS numeric(28,6)) AS result\n \n , code_type\n , code\n , data_source\n from observations\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n, depression_assessment as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.observation_date\n , numeric_observations.result\n , numeric_observations.code_type\n , numeric_observations.code\n , numeric_observations.data_source\n , seed_clinical_concepts.concept_name\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'depression assessment (phq-9)'\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n\n)\n\n, hypertension as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'essential hypertension'\n\n)\n\n, obstructive_sleep_apnea as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'obstructive sleep apnea'\n\n)\n\n/* BEGIN HCC 48 logic (Morbid Obesity) */\n, bmi_over_30_with_osa as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , obstructive_sleep_apnea.code as condition_code\n , obstructive_sleep_apnea.recorded_date as condition_date\n , obstructive_sleep_apnea.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join obstructive_sleep_apnea\n on numeric_observations.patient_id = obstructive_sleep_apnea.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', obstructive_sleep_apnea.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 30\n\n)\n\n, bmi_over_35_with_diabetes as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , diabetes.code as condition_code\n , diabetes.recorded_date as condition_date\n , diabetes.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join diabetes\n on numeric_observations.patient_id = diabetes.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', diabetes.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_35_with_hypertension as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , hypertension.code as condition_code\n , hypertension.recorded_date as condition_date\n , hypertension.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join hypertension\n on numeric_observations.patient_id = hypertension.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', hypertension.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_40 as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , cast(null as TEXT) as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 40\n\n)\n\n, hcc_48_unioned as (\n\n select * from bmi_over_30_with_osa\n union all\n select * from bmi_over_35_with_diabetes\n union all\n select * from bmi_over_35_with_hypertension\n union all\n select * from bmi_over_40\n\n)\n\n, hcc_48_suspect as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , 'BMI result ' || observation_result || case when condition_code is null then '' else ' with ' || condition_concept_name || '(' || condition_code || ' on ' || condition_date || ')' end as contributing_factor\n from hcc_48_unioned\n\n)\n/* END HCC 48 logic */\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n to determine a positive PHQ-9 assessment, we look at the past 3 screenings\n for a patient and take the highest result\n*/\n, eligible_depression_assessments as (\n\n select\n depression_assessment.patient_id\n , depression_assessment.observation_date\n , depression_assessment.result\n , depression_assessment.code_type\n , depression_assessment.code\n , depression_assessment.data_source\n , depression_assessment.concept_name\n , row_number() over (\n partition by\n depression_assessment.patient_id\n , depression_assessment.data_source\n order by\n case when depression_assessment.observation_date is null then 1 else 0 end,\n depression_assessment.observation_date desc\n ) assessment_order\n from depression_assessment\n\n)\n\n, depression_assessments_ordered as (\n\n select\n patient_id\n , observation_date\n , code_type\n , code\n , data_source\n , concept_name\n , result\n , row_number() over (\n partition by\n patient_id\n , data_source\n --order by result desc nulls last\n order by\n case when result is null then 1 else 0 end,\n result desc\n ) as result_order --order the last three assessments by result value\n from eligible_depression_assessments\n where assessment_order <= 3\n\n)\n\n, hcc_155_suspect as (\n\n select\n depression_assessments_ordered.patient_id\n , depression_assessments_ordered.data_source\n , depression_assessments_ordered.observation_date\n , depression_assessments_ordered.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , depression_assessments_ordered.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , 'PHQ-9 result ' || depression_assessments_ordered.result || ' on ' || depression_assessments_ordered.observation_date as contributing_factor\n from depression_assessments_ordered\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where result_order = 1\n and result >= 15\n\n)\n\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_48_suspect\n union all\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.observation_date\n , unioned.observation_result\n , unioned.condition_code\n , unioned.condition_date\n , unioned.condition_concept_name\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.contributing_factor\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Observation suspect' as TEXT) as reason\n , observation_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(observation_date as date) as observation_date\n , cast(observation_result as TEXT) as observation_result\n , cast(condition_code as TEXT) as condition_code\n , cast(condition_date as date) as condition_date\n , cast(condition_concept_name as TEXT) as condition_concept_name\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom dev_thuxuan.core.observation\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_patient_hcc_history", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_patient_hcc_history.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_patient_hcc_history.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_patient_hcc_history"], "alias": "_int_patient_hcc_history", "checksum": {"name": "sha256", "checksum": "f7770cbd15d8e650a62ddfd124b79505bc2114e5517b3aefe6e47c6f1f218526"}, "config": {"enabled": true, "alias": "_int_patient_hcc_history", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "This intermediate model displays the full history of a patient's recorded HCCs with a flag for recorded during the current year.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the ICD-10-CM condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code": {"name": "icd_10_cm_code", "description": "The ICD-10-CM condition code.", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__icd_10_cm_mappings.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "HCC code from the latest CMS HCC model available in the mart.\n", "meta": {"terminology": "https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "HCC description from the latest CMS HCC model available in the mart.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_recorded": {"name": "first_recorded", "description": "Date the HCC was first recorded in the patient's record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_recorded": {"name": "last_recorded", "description": "Date the HCC was last recorded in the patient's record.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_billed": {"name": "last_billed", "description": "Date the HCC was last billed in the patient's record (where condition_type <> 'problem').\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_year_billed": {"name": "current_year_billed", "description": "Flag indicating that the ICD-10-CM code mapped to the HCC has been billed during the payment year.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "reason": {"name": "reason", "description": "Standardized reason for the suspecting condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "contributing_factor": {"name": "contributing_factor", "description": "Description of the contributing factor(s) for the suspecting condition.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "suspect_date": {"name": "suspect_date", "description": "Date when the suspecting condition was recorded or billed.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_patient_hcc_history", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9017792, "relation_name": "dev_thuxuan.hcc_suspecting._int_patient_hcc_history", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith all_conditions as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , recorded_date\r\n , condition_type\r\n , icd_10_cm_code\r\n , hcc_code\r\n , hcc_description\r\n from {{ ref('hcc_suspecting__int_all_conditions') }}\r\n where hcc_code is not null\r\n\r\n)\r\n\r\n, hcc_grouped as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , min(recorded_date) as first_recorded\r\n , max(recorded_date) as last_recorded\r\n from all_conditions\r\n where hcc_code is not null\r\n group by\r\n patient_id\r\n , hcc_code\r\n , hcc_description\r\n , data_source\r\n\r\n)\r\n\r\n, hcc_billed as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , hcc_code\r\n , hcc_description\r\n , max(recorded_date) as last_billed\r\n from all_conditions\r\n where hcc_code is not null\r\n and lower(condition_type) <> 'problem'\r\n group by\r\n patient_id\r\n , hcc_code\r\n , hcc_description\r\n , data_source\r\n\r\n)\r\n\r\n, add_flag as (\r\n\r\n select\r\n hcc_grouped.patient_id\r\n , hcc_grouped.data_source\r\n , hcc_grouped.hcc_code\r\n , hcc_grouped.hcc_description\r\n , hcc_grouped.first_recorded\r\n , hcc_grouped.last_recorded\r\n , hcc_billed.last_billed\r\n , case\r\n when {{ date_part('year', 'hcc_billed.last_billed') }} = {{ date_part('year', dbt.current_timestamp()) }}\r\n then 1\r\n else 0\r\n end as current_year_billed\r\n\r\n from hcc_grouped\r\n left join hcc_billed\r\n on hcc_grouped.patient_id = hcc_billed.patient_id\r\n and hcc_grouped.hcc_code = hcc_billed.hcc_code\r\n and hcc_grouped.data_source = hcc_billed.data_source\r\n\r\n)\r\n\r\n, all_conditions_with_flag as (\r\n\r\n select distinct\r\n all_conditions.patient_id\r\n , all_conditions.data_source\r\n , all_conditions.recorded_date\r\n , all_conditions.condition_type\r\n , all_conditions.icd_10_cm_code\r\n , all_conditions.hcc_code\r\n , all_conditions.hcc_description\r\n , add_flag.first_recorded\r\n , add_flag.last_recorded\r\n , add_flag.last_billed\r\n , add_flag.current_year_billed\r\n , cast('Prior coding history' as {{ dbt.type_string() }}) as reason\r\n , {{ dbt.concat([\r\n \"icd_10_cm_code\",\r\n \"case\"\r\n \" when last_billed is not null then \" ~\r\n dbt.concat([\"' last billed on '\", \"last_billed\"]) ~\r\n \" when last_billed is null and last_recorded is not null then \" ~\r\n dbt.concat([\"' last recorded on '\", \"last_recorded\"]) ~\r\n \" else ' (missing recorded and billing dates) '\"\r\n \" end\"\r\n ]) }} as contributing_factor\r\n , coalesce(last_billed, last_recorded) as condition_date\r\n from all_conditions\r\n left join add_flag\r\n on all_conditions.patient_id = add_flag.patient_id\r\n and all_conditions.hcc_code = add_flag.hcc_code\r\n and all_conditions.data_source = add_flag.data_source\r\n\r\n)\r\n\r\n, add_standard_fields as (\r\n\r\n select distinct\r\n patient_id\r\n , data_source\r\n , recorded_date\r\n , condition_type\r\n , icd_10_cm_code\r\n , hcc_code\r\n , hcc_description\r\n , first_recorded\r\n , last_recorded\r\n , last_billed\r\n , current_year_billed\r\n , 'Prior coding history' as reason\r\n , {{ dbt.concat([\r\n \"icd_10_cm_code\",\r\n \"case\"\r\n \" when last_billed is not null then \" ~\r\n dbt.concat([\"' last billed on '\", \"last_billed\"]) ~\r\n \" when last_billed is null and last_recorded is not null then \" ~\r\n dbt.concat([\"' last recorded on '\", \"last_recorded\"]) ~\r\n \" else ' (missing recorded and billing dates) '\"\r\n \" end\"\r\n ]) }} as contributing_factor\r\n , coalesce(last_billed, last_recorded) as suspect_date\r\n from all_conditions_with_flag\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(recorded_date as date) as recorded_date\r\n , cast(condition_type as {{ dbt.type_string() }}) as condition_type\r\n , cast(icd_10_cm_code as {{ dbt.type_string() }}) as icd_10_cm_code\r\n , cast(hcc_code as {{ dbt.type_string() }}) as hcc_code\r\n , cast(hcc_description as {{ dbt.type_string() }}) as hcc_description\r\n , cast(first_recorded as date) as first_recorded\r\n , cast(last_recorded as date) as last_recorded\r\n , cast(last_billed as date) as last_billed\r\n {% if target.type == 'fabric' %}\r\n , cast(current_year_billed as bit) as current_year_billed\r\n {% else %}\r\n , cast(current_year_billed as boolean) as current_year_billed\r\n {% endif %}\r\n , cast(reason as {{ dbt.type_string() }}) as reason\r\n , cast(contributing_factor as {{ dbt.type_string() }}) as contributing_factor\r\n , cast(suspect_date as date) as suspect_date\r\n from add_standard_fields\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , recorded_date\r\n , condition_type\r\n , icd_10_cm_code\r\n , hcc_code\r\n , hcc_description\r\n , first_recorded\r\n , last_recorded\r\n , last_billed\r\n , current_year_billed\r\n , reason\r\n , contributing_factor\r\n , suspect_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__int_all_conditions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.date_part", "macro.dbt.current_timestamp", "macro.dbt.type_string", "macro.dbt.concat"], "nodes": ["model.the_tuva_project.hcc_suspecting__int_all_conditions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_patient_hcc_history.sql", "compiled": true, "compiled_code": "\n\nwith all_conditions as (\n\n select\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._int_all_conditions\n where hcc_code is not null\n\n)\n\n, hcc_grouped as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , min(recorded_date) as first_recorded\n , max(recorded_date) as last_recorded\n from all_conditions\n where hcc_code is not null\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, hcc_billed as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , max(recorded_date) as last_billed\n from all_conditions\n where hcc_code is not null\n and lower(condition_type) <> 'problem'\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, add_flag as (\n\n select\n hcc_grouped.patient_id\n , hcc_grouped.data_source\n , hcc_grouped.hcc_code\n , hcc_grouped.hcc_description\n , hcc_grouped.first_recorded\n , hcc_grouped.last_recorded\n , hcc_billed.last_billed\n , case\n when date_part('year', hcc_billed.last_billed) = date_part('year', convert_timezone('UTC', current_timestamp()))\n then 1\n else 0\n end as current_year_billed\n\n from hcc_grouped\n left join hcc_billed\n on hcc_grouped.patient_id = hcc_billed.patient_id\n and hcc_grouped.hcc_code = hcc_billed.hcc_code\n and hcc_grouped.data_source = hcc_billed.data_source\n\n)\n\n, all_conditions_with_flag as (\n\n select distinct\n all_conditions.patient_id\n , all_conditions.data_source\n , all_conditions.recorded_date\n , all_conditions.condition_type\n , all_conditions.icd_10_cm_code\n , all_conditions.hcc_code\n , all_conditions.hcc_description\n , add_flag.first_recorded\n , add_flag.last_recorded\n , add_flag.last_billed\n , add_flag.current_year_billed\n , cast('Prior coding history' as TEXT) as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as condition_date\n from all_conditions\n left join add_flag\n on all_conditions.patient_id = add_flag.patient_id\n and all_conditions.hcc_code = add_flag.hcc_code\n and all_conditions.data_source = add_flag.data_source\n\n)\n\n, add_standard_fields as (\n\n select distinct\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , 'Prior coding history' as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as suspect_date\n from all_conditions_with_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(icd_10_cm_code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(first_recorded as date) as first_recorded\n , cast(last_recorded as date) as last_recorded\n , cast(last_billed as date) as last_billed\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_prep_conditions": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_prep_conditions", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_prep_conditions.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_prep_conditions.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_prep_conditions"], "alias": "_int_prep_conditions", "checksum": {"name": "sha256", "checksum": "1e62f38c7c47c6b0de539861d3cd81d18120cc672f9b441bee2b0bf819a4c47e"}, "config": {"enabled": true, "alias": "_int_prep_conditions", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Preparing conditions; mapping snomed-ct conditions to icd-10-cm.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date in which the condition was recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "The type of condition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "The type of condition code reported in the source system e.g. ICD-10-CM.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "The condition code in the source system e.g. the ICD-10 code.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_prep_conditions", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9037724, "relation_name": "dev_thuxuan.hcc_suspecting._int_prep_conditions", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n from {{ ref('hcc_suspecting__stg_core__condition') }}\r\n\r\n)\r\n\r\n/*\r\n Default mapping guidance: Most map groups terminate with an unconditional\r\n rule \u2013 a rule whose predicate is \u201cTRUE\u201d or, equivalently, \u201cOTHERWISE TRUE\u201d.\r\n This rule is considered a \u201cdefault\u201d because it should be applied if\r\n nothing further is known about the patient\u2019s condition.\r\n*/\r\n, seed_snomed_icd_10_map as (\r\n\r\n select\r\n referenced_component_id as snomed_code\r\n , map_target as icd_10_code\r\n from {{ ref('terminology__snomed_icd_10_map') }}\r\n where lower(map_rule) in ('true', 'otherwise true')\r\n and map_group = '1'\r\n\r\n)\r\n\r\n, snomed_conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , 'icd-10-cm' as code_type\r\n , icd_10_code as code\r\n , data_source\r\n from conditions\r\n inner join seed_snomed_icd_10_map\r\n on conditions.code = seed_snomed_icd_10_map.snomed_code\r\n where conditions.code_type = 'snomed-ct'\r\n\r\n)\r\n\r\n, other_conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n from conditions\r\n where conditions.code_type <> 'snomed-ct'\r\n\r\n)\r\n\r\n, union_conditions as (\r\n\r\n select * from snomed_conditions\r\n union all\r\n select * from other_conditions\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(recorded_date as date) as recorded_date\r\n , cast(condition_type as {{ dbt.type_string() }}) as condition_type\r\n , cast(code_type as {{ dbt.type_string() }}) as code_type\r\n , cast(code as {{ dbt.type_string() }}) as code\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n from union_conditions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , recorded_date\r\n , condition_type\r\n , code_type\r\n , code\r\n , data_source\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__condition", "package": null, "version": null}, {"name": "terminology__snomed_icd_10_map", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__condition", "seed.the_tuva_project.terminology__snomed_icd_10_map"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_prep_conditions.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom dev_thuxuan.core.condition\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_condition\n\n)\n\n/*\n Default mapping guidance: Most map groups terminate with an unconditional\n rule \u2013 a rule whose predicate is \u201cTRUE\u201d or, equivalently, \u201cOTHERWISE TRUE\u201d.\n This rule is considered a \u201cdefault\u201d because it should be applied if\n nothing further is known about the patient\u2019s condition.\n*/\n, seed_snomed_icd_10_map as (\n\n select\n referenced_component_id as snomed_code\n , map_target as icd_10_code\n from dev_thuxuan.terminology.snomed_icd_10_map\n where lower(map_rule) in ('true', 'otherwise true')\n and map_group = '1'\n\n)\n\n, snomed_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , 'icd-10-cm' as code_type\n , icd_10_code as code\n , data_source\n from conditions\n inner join seed_snomed_icd_10_map\n on conditions.code = seed_snomed_icd_10_map.snomed_code\n where conditions.code_type = 'snomed-ct'\n\n)\n\n, other_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from conditions\n where conditions.code_type <> 'snomed-ct'\n\n)\n\n, union_conditions as (\n\n select * from snomed_conditions\n union all\n select * from other_conditions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(data_source as TEXT) as data_source\n from union_conditions\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__int_prep_egfr_labs", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\intermediate\\hcc_suspecting__int_prep_egfr_labs.sql", "original_file_path": "models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_prep_egfr_labs.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "fqn": ["the_tuva_project", "hcc_suspecting", "intermediate", "hcc_suspecting__int_prep_egfr_labs"], "alias": "_int_prep_egfr_labs", "checksum": {"name": "sha256", "checksum": "d026f9fd9a2e583db2e43da7fc3f298bdfca276b040577263e57cf4ba735d837"}, "config": {"enabled": true, "alias": "_int_prep_egfr_labs", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Preparing eGFR labs with clean numeric results.", "columns": {"patient_id": {"name": "patient_id", "description": "Unique ID for the patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "User-configured field that indicates the data source (e.g. typically named after the payer and state \"BCBS Tennessee\").\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "The normalized code type or source code type.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "The normalized code or source code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "Date of the test result.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "Cleaned numeric result of the lab test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date the model was run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_int_prep_egfr_labs", "tags": "hcc_suspecting", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9062808, "relation_name": "dev_thuxuan.hcc_suspecting._int_prep_egfr_labs", "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith lab_result as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , status\r\n , result\r\n , result_date\r\n from {{ ref('hcc_suspecting__stg_core__lab_result') }}\r\n\r\n)\r\n\r\n, seed_egfr_codes as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('hcc_suspecting__clinical_concepts') }}\r\n where lower(concept_name) = 'estimated glomerular filtration rate'\r\n\r\n)\r\n\r\n, egfr_labs as (\r\n\r\n select distinct\r\n lab_result.patient_id\r\n , lab_result.data_source\r\n , lab_result.code_type\r\n , lab_result.code\r\n , lab_result.result_date\r\n , lab_result.result\r\n from lab_result\r\n inner join seed_egfr_codes\r\n on lab_result.code = seed_egfr_codes.code\r\n and lab_result.code_type = seed_egfr_codes.code_system\r\n where lab_result.result is not null\r\n and lower(lab_result.status) not in ('cancelled', 'entered-in-error')\r\n\r\n)\r\n\r\n, numeric_egfr_labs as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , result_date\r\n , cast(result as {{ dbt.type_numeric() }}) as result\r\n from egfr_labs\r\n {% if target.type == 'fabric' %}\r\n WHERE result LIKE '%.%' OR result LIKE '%[0-9]%'\r\n AND result NOT LIKE '%[^0-9.]%'\r\n {% else %}\r\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\r\n {% endif %}\r\n\r\n)\r\n\r\n, clean_non_numeric_egfr_labs as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , result_date\r\n , result\r\n , cast(case\r\n when lower(result) like '%unsatisfactory specimen%' then null\r\n when result like '%>%' then null\r\n when result like '%<%' then null\r\n when result like '%@%' then trim(replace(result,'@',''))\r\n when result like '%mL/min/1.73m2%' then trim(replace(result,'mL/min/1.73m2',''))\r\n else null\r\n end as {{ dbt.type_numeric() }}) as clean_result\r\n from egfr_labs\r\n {% if target.type == 'fabric' %}\r\n WHERE NOT (result LIKE '%.%' OR result LIKE '%[0-9]%'\r\n AND result NOT LIKE '%[^0-9.]%')\r\n {% else %}\r\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }} = False\r\n {% endif %}\r\n\r\n)\r\n\r\n, unioned_labs as (\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , result_date\r\n , result\r\n from numeric_egfr_labs\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , result_date\r\n , clean_result as result\r\n from clean_non_numeric_egfr_labs\r\n where clean_result is not null\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(data_source as {{ dbt.type_string() }}) as data_source\r\n , cast(code_type as {{ dbt.type_string() }}) as code_type\r\n , cast(code as {{ dbt.type_string() }}) as code\r\n , cast(result_date as date) as result_date\r\n , cast(result as {{ dbt.type_numeric() }}) as result\r\n from unioned_labs\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , data_source\r\n , code_type\r\n , code\r\n , result_date\r\n , result\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "hcc_suspecting__stg_core__lab_result", "package": null, "version": null}, {"name": "hcc_suspecting__clinical_concepts", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.the_tuva_project.apply_regex", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "seed.the_tuva_project.hcc_suspecting__clinical_concepts"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\intermediate\\hcc_suspecting__int_prep_egfr_labs.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom dev_thuxuan.core.lab_result\n\n\n), lab_result as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , status\n , result\n , result_date\n from __dbt__cte___stg_lab_result\n\n)\n\n, seed_egfr_codes as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n where lower(concept_name) = 'estimated glomerular filtration rate'\n\n)\n\n, egfr_labs as (\n\n select distinct\n lab_result.patient_id\n , lab_result.data_source\n , lab_result.code_type\n , lab_result.code\n , lab_result.result_date\n , lab_result.result\n from lab_result\n inner join seed_egfr_codes\n on lab_result.code = seed_egfr_codes.code\n and lab_result.code_type = seed_egfr_codes.code_system\n where lab_result.result is not null\n and lower(lab_result.status) not in ('cancelled', 'entered-in-error')\n\n)\n\n, numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , cast(result as numeric(28,6)) as result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, clean_non_numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , cast(case\n when lower(result) like '%unsatisfactory specimen%' then null\n when result like '%>%' then null\n when result like '%<%' then null\n when result like '%@%' then trim(replace(result,'@',''))\n when result like '%mL/min/1.73m2%' then trim(replace(result,'mL/min/1.73m2',''))\n else null\n end as numeric(28,6)) as clean_result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$') = False\n \n\n)\n\n, unioned_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from numeric_egfr_labs\n\n union all\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , clean_result as result\n from clean_non_numeric_egfr_labs\n where clean_result is not null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n from unioned_labs\n\n)\n\nselect\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom dev_thuxuan.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__condition": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\staging\\hcc_suspecting__stg_core__condition.sql", "original_file_path": "models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__condition.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__condition", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__condition"], "alias": "_stg_condition", "checksum": {"name": "sha256", "checksum": "745c9b9ac8c84d1567536d8b9004b6158df4abeeb8f8d9e6ae2e8f7c02c7879e"}, "config": {"enabled": true, "alias": "_stg_condition", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging conditions from core.", "columns": {"claim_id": {"name": "claim_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_type": {"name": "condition_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_condition", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9102864, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n claim_id\r\n , patient_id\r\n , recorded_date\r\n , condition_type\r\n , lower(normalized_code_type) as code_type\r\n , normalized_code as code\r\n , data_source\r\nfrom {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__condition.sql", "compiled": true, "compiled_code": "\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom dev_thuxuan.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__lab_result": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\staging\\hcc_suspecting__stg_core__lab_result.sql", "original_file_path": "models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__lab_result.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__lab_result"], "alias": "_stg_lab_result", "checksum": {"name": "sha256", "checksum": "ac844b856565dfa2a6326034da949d60917252f0fb5ff7cf0f22082564338400"}, "config": {"enabled": true, "alias": "_stg_lab_result", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging conditions from core.", "columns": {"lab_result_id": {"name": "lab_result_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_lab_result", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.913287, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n lab_result_id\r\n , patient_id\r\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\r\n , coalesce(normalized_code,source_code) as code\r\n , status\r\n , result\r\n , result_date\r\n , data_source\r\nfrom {{ ref('core__lab_result') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n lab_result_id\r\n , patient_id\r\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\r\n , coalesce(normalized_code,source_code) as code\r\n , status\r\n , result\r\n , result_date\r\n , data_source\r\nfrom {{ ref('core__lab_result') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as lab_result_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as code_type\r\n , cast(null as {{ dbt.type_string() }} ) as code\r\n , cast(null as {{ dbt.type_string() }} ) as status\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n{% else %}\r\n select\r\n cast(null as {{ dbt.type_string() }} ) as lab_result_id\r\n , cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as code_type\r\n , cast(null as {{ dbt.type_string() }} ) as code\r\n , cast(null as {{ dbt.type_string() }} ) as status\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__lab_result.sql", "compiled": true, "compiled_code": "\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom dev_thuxuan.core.lab_result\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__medication": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\staging\\hcc_suspecting__stg_core__medication.sql", "original_file_path": "models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__medication.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__medication", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__medication"], "alias": "_stg_medication", "checksum": {"name": "sha256", "checksum": "d389f3fd240b91e66b75b6ec408a4d10b02ead0e2fab2cfa68ac24717ef96cb6"}, "config": {"enabled": true, "alias": "_stg_medication", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging medications from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_medication", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9152865, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , source_code\r\n , source_code_type\r\n , ndc_code\r\n , rxnorm_code\r\n , data_source\r\nfrom {{ ref('core__medication') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , source_code\r\n , source_code_type\r\n , ndc_code\r\n , rxnorm_code\r\n , data_source\r\nfrom {{ ref('core__medication') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n{% else %}\r\nselect\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n limit 0\r\n{% endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__medication.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom dev_thuxuan.core.medication\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__observation": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\staging\\hcc_suspecting__stg_core__observation.sql", "original_file_path": "models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__observation.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__observation", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__observation"], "alias": "_stg_observation", "checksum": {"name": "sha256", "checksum": "227bc66bb2320ec602beafe2a04e37907ba979fa9579f62c5123767def2d8122"}, "config": {"enabled": true, "alias": "_stg_observation", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging observations from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result": {"name": "result", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_type": {"name": "code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_observation", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9182866, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , observation_date\r\n , result\r\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\r\n , coalesce(normalized_code,source_code) as code\r\n , data_source\r\nfrom {{ ref('core__observation') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , observation_date\r\n , result\r\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\r\n , coalesce(normalized_code,source_code) as code\r\n , data_source\r\nfrom {{ ref('core__observation') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , cast(null as {{ dbt.type_string() }} ) as code_type\r\n , cast(null as {{ dbt.type_string() }} ) as code\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n{% else %}\r\n select\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , cast(null as {{ dbt.type_string() }} ) as code_type\r\n , cast(null as {{ dbt.type_string() }} ) as code\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__observation.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom dev_thuxuan.core.observation\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__patient": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\staging\\hcc_suspecting__stg_core__patient.sql", "original_file_path": "models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__patient.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__patient", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__patient"], "alias": "_stg_patient", "checksum": {"name": "sha256", "checksum": "751bf83a7239d99b66b7156431ae7a9593c9c6fa536a6231f5f8c1d3e825d692"}, "config": {"enabled": true, "alias": "_stg_patient", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging patients from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_patient", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9202867, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , sex\r\n , birth_date\r\n , death_date\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__patient.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__stg_core__pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "hcc_suspecting\\staging\\hcc_suspecting__stg_core__pharmacy_claim.sql", "original_file_path": "models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__pharmacy_claim.sql", "unique_id": "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim", "fqn": ["the_tuva_project", "hcc_suspecting", "staging", "hcc_suspecting__stg_core__pharmacy_claim"], "alias": "_stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "52ece2e97bdbf139a5787d7195fcbaa725dad51d99b1fee8749223a94ae20b3b"}, "config": {"enabled": true, "alias": "_stg_pharmacy_claim", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["hcc_suspecting"], "description": "Staging pharmacy claims from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\hcc_suspecting\\hcc_suspecting_models.yml", "build_path": null, "unrendered_config": {"schema": "hcc_suspecting", "alias": "_stg_pharmacy_claim", "tags": "hcc_suspecting", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9222865, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('hcc_suspecting_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , paid_date\r\n , data_source\r\nfrom {{ ref('core__pharmacy_claim') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , paid_date\r\n , data_source\r\nfrom {{ ref('core__pharmacy_claim') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n{% else %}\r\n select\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date\r\n , cast(null as {{ dbt.type_string() }} ) as data_source\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\hcc_suspecting\\staging\\hcc_suspecting__stg_core__pharmacy_claim.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom dev_thuxuan.core.pharmacy_claim\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__brand_generic_opportunity": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__brand_generic_opportunity", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\final\\pharmacy__brand_generic_opportunity.sql", "original_file_path": "models\\pharmacy\\final\\pharmacy__brand_generic_opportunity.sql", "unique_id": "model.the_tuva_project.pharmacy__brand_generic_opportunity", "fqn": ["the_tuva_project", "pharmacy", "final", "pharmacy__brand_generic_opportunity"], "alias": "brand_generic_opportunity", "checksum": {"name": "sha256", "checksum": "bb74faa560e3f0e1887166be57a6332ca96ec6b643499cbccd893af2dbcc720a"}, "config": {"enabled": true, "alias": "brand_generic_opportunity", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Table that identifies opportunities for generic substitution in pharmacy claims.\n", "columns": {"data_source": {"name": "data_source", "description": "Source of the data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Line number of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National Drug Code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description of the drug as per NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_rxcui": {"name": "brand_rxcui", "description": "RxNorm Concept Unique Identifier for the brand.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_vs_generic": {"name": "brand_vs_generic", "description": "Indicates whether the drug is a brand or generic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available": {"name": "generic_available", "description": "Indicates if a generic version is available.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid for the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "total_units": {"name": "total_units", "description": "Total units of the drug dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_cost_per_unit": {"name": "brand_cost_per_unit", "description": "Cost per unit for the branded drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_average_cost_per_unit": {"name": "generic_average_cost_per_unit", "description": "Average cost per unit of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_less_generic_cost_per_unit": {"name": "brand_less_generic_cost_per_unit", "description": "Difference between the cost per unit of the brand and the average cost per unit of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available_total_opportunity": {"name": "generic_available_total_opportunity", "description": "Total potential savings from substituting with generics, where applicable, based on units multiplied by cost difference per unit.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "brand_generic_opportunity", "tags": ["pharmacy"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9503708, "relation_name": "dev_thuxuan.pharmacy.brand_generic_opportunity", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n/* claimid/line/source grain. calculates opportunity at line level*/\r\n\r\nwith cpu as (\r\nselect claim_id\r\n,claim_line_number\r\n,data_source\r\n,case when quantity > 0 then paid_amount/quantity else null end as brand_cost_per_unit\r\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }}\r\n)\r\n\r\n\r\nselect \r\n pc.data_source\r\n , pc.claim_id\r\n , pc.claim_line_number\r\n , cc.ndc_code\r\n , cc.ndc_description\r\n , cc.rxcui as brand_rxcui\r\n , cc.brand_vs_generic \r\n , cc.generic_available\r\n , pc.paid_amount\r\n , pc.quantity as total_units\r\n , cpu.brand_cost_per_unit\r\n , gc.generic_average_cost_per_unit \r\n , cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit as brand_less_generic_cost_per_unit\r\n , case \r\n when cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit > 0 \r\n then (cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit) * pc.quantity \r\n else 0 \r\n end as generic_available_total_opportunity\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }} as pc\r\ninner join cpu on pc.claim_id = cpu.claim_id\r\n and\r\n pc.claim_line_number = cpu.claim_line_number\r\n and\r\n pc.data_source = cpu.data_source\r\ninner join {{ ref('pharmacy__int_claims_current_cost') }} cc\r\n on cc.ndc_code = pc.ndc_code\r\n and\r\n cc.data_source = pc.data_source\r\ninner join {{ ref('pharmacy__int_generic_cost') }} as gc \r\n on cc.rxcui = gc.brand_rxcui\r\n and gc.data_source = cc.data_source\r\nwhere prescribed_atleast_one_generic_history = 1", "language": "sql", "refs": [{"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}, {"name": "pharmacy__int_generic_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__stg_pharmacy_claim", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__int_generic_cost"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\final\\pharmacy__brand_generic_opportunity.sql", "compiled": true, "compiled_code": "\n\n/* claimid/line/source grain. calculates opportunity at line level*/\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n), cpu as (\nselect claim_id\n,claim_line_number\n,data_source\n,case when quantity > 0 then paid_amount/quantity else null end as brand_cost_per_unit\nfrom __dbt__cte__stg_pharmacy_claim\n)\n\n\nselect \n pc.data_source\n , pc.claim_id\n , pc.claim_line_number\n , cc.ndc_code\n , cc.ndc_description\n , cc.rxcui as brand_rxcui\n , cc.brand_vs_generic \n , cc.generic_available\n , pc.paid_amount\n , pc.quantity as total_units\n , cpu.brand_cost_per_unit\n , gc.generic_average_cost_per_unit \n , cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit as brand_less_generic_cost_per_unit\n , case \n when cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit > 0 \n then (cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit) * pc.quantity \n else 0 \n end as generic_available_total_opportunity\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as pc\ninner join cpu on pc.claim_id = cpu.claim_id\n and\n pc.claim_line_number = cpu.claim_line_number\n and\n pc.data_source = cpu.data_source\ninner join dev_thuxuan.pharmacy._int_claims_current_cost cc\n on cc.ndc_code = pc.ndc_code\n and\n cc.data_source = pc.data_source\ninner join dev_thuxuan.pharmacy._int_generic_cost as gc \n on cc.rxcui = gc.brand_rxcui\n and gc.data_source = cc.data_source\nwhere prescribed_atleast_one_generic_history = 1", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__generic_available_list": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__generic_available_list", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\final\\pharmacy__generic_available_list.sql", "original_file_path": "models\\pharmacy\\final\\pharmacy__generic_available_list.sql", "unique_id": "model.the_tuva_project.pharmacy__generic_available_list", "fqn": ["the_tuva_project", "pharmacy", "final", "pharmacy__generic_available_list"], "alias": "generic_available_list", "checksum": {"name": "sha256", "checksum": "6cb064af7f7c0de4ae71c5501633ab07450870ecbfbb40a2b0a8898b15046fe9"}, "config": {"enabled": true, "alias": "generic_available_list", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Provides a list of pharmacy claims where a generic alternative is available, detailing both brand and potential generic drug costs and descriptions.\n", "columns": {"generic_available_sk": {"name": "generic_available_sk", "description": "Surrogate key for generic availability.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "data_source": {"name": "data_source", "description": "Source of the data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_ndc_code": {"name": "brand_ndc_code", "description": "National Drug Code for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_ndc_description": {"name": "brand_ndc_description", "description": "Description of the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_rxcui": {"name": "brand_rxcui", "description": "RxNorm Concept Unique Identifier for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_paid_amount": {"name": "brand_paid_amount", "description": "Total amount paid for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_units": {"name": "brand_units", "description": "Units of the brand drug dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_paid_per_unit": {"name": "brand_paid_per_unit", "description": "Paid amount per unit for the brand drug, calculated as total paid divided by units, if units are not zero.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_ndc": {"name": "generic_ndc", "description": "National Drug Code for the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_ndc_description": {"name": "generic_ndc_description", "description": "FDA description of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_prescribed_history": {"name": "generic_prescribed_history", "description": "Indicates if a generic version has previously been prescribed, 1 for yes and 0 for no.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_cost_per_unit": {"name": "generic_cost_per_unit", "description": "Cost per unit for the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_cost_at_units": {"name": "generic_cost_at_units", "description": "Cost for the generic drug at the dispensed units of the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "generic_available_list", "tags": ["pharmacy"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9564614, "relation_name": "dev_thuxuan.pharmacy.generic_available_list", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith generic_sk as (\r\n select \r\n generic_available_sk\r\n , claim_id\r\n , claim_line_number\r\n , data_source\r\n from {{ ref('pharmacy__pharmacy_claim_expanded') }} as e\r\n where generic_available_sk is not null\r\n)\r\n\r\nselect \r\n sk.generic_available_sk\r\n , p.data_source\r\n , p.ndc_code as brand_ndc_code\r\n , p.ndc_description as brand_ndc_description\r\n , p.rxcui as brand_rxcui\r\n , p.paid_amount as brand_paid_amount\r\n , p.quantity as brand_units\r\n , case \r\n when p.quantity = 0 \r\n then 0 \r\n else p.paid_amount / p.quantity \r\n end as brand_paid_per_unit\r\n , ga.ndc as generic_ndc\r\n , n.fda_description as generic_ndc_description\r\n , case \r\n when gc.ndc_code is not null \r\n then 1 \r\n else 0 \r\n end as generic_prescribed_history\r\n , gc.cost_per_unit as generic_cost_per_unit\r\n , gc.cost_per_unit * p.quantity as generic_cost_at_units\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }} as p\r\ninner join generic_sk as sk \r\n on p.claim_id = sk.claim_id\r\n and p.claim_line_number = sk.claim_line_number\r\n and p.data_source = sk.data_source\r\ninner join {{ ref('pharmacy__int_brand_with_generic_available') }} as b \r\n on p.rxcui = b.brand_with_generic_available\r\ninner join {{ ref('pharmacy__rxnorm_generic_available') }} as ga \r\n on p.rxcui = ga.product_rxcui\r\n and ga.ndc_product_tty in ('SCD','GPCK')\r\nleft join {{ ref('terminology__ndc') }} as n \r\n on ga.ndc = n.ndc\r\nleft join {{ ref('pharmacy__int_claims_current_cost') }} as gc \r\n on ga.ndc = gc.ndc_code\r\n and gc.brand_vs_generic = 'generic'\r\n and gc.data_source = p.data_source\r\nwhere \r\n ga.product_startmarketingdate is not null\r\n {% if target.type == 'fabric' %}\r\n and cast(ga.product_startmarketingdate as date) <= GETDATE()\r\n {% else %}\r\n and cast(ga.product_startmarketingdate as date) <= current_date\r\n{% endif %}", "language": "sql", "refs": [{"name": "pharmacy__pharmacy_claim_expanded", "package": null, "version": null}, {"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "pharmacy__int_brand_with_generic_available", "package": null, "version": null}, {"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "seed.the_tuva_project.terminology__ndc", "model.the_tuva_project.pharmacy__int_claims_current_cost"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\final\\pharmacy__generic_available_list.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n), generic_sk as (\n select \n generic_available_sk\n , claim_id\n , claim_line_number\n , data_source\n from dev_thuxuan.pharmacy.pharmacy_claim_expanded as e\n where generic_available_sk is not null\n)\n\nselect \n sk.generic_available_sk\n , p.data_source\n , p.ndc_code as brand_ndc_code\n , p.ndc_description as brand_ndc_description\n , p.rxcui as brand_rxcui\n , p.paid_amount as brand_paid_amount\n , p.quantity as brand_units\n , case \n when p.quantity = 0 \n then 0 \n else p.paid_amount / p.quantity \n end as brand_paid_per_unit\n , ga.ndc as generic_ndc\n , n.fda_description as generic_ndc_description\n , case \n when gc.ndc_code is not null \n then 1 \n else 0 \n end as generic_prescribed_history\n , gc.cost_per_unit as generic_cost_per_unit\n , gc.cost_per_unit * p.quantity as generic_cost_at_units\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\ninner join generic_sk as sk \n on p.claim_id = sk.claim_id\n and p.claim_line_number = sk.claim_line_number\n and p.data_source = sk.data_source\ninner join dev_thuxuan.pharmacy._int_brand_with_generic_available as b \n on p.rxcui = b.brand_with_generic_available\ninner join dev_thuxuan.pharmacy.rxnorm_generic_available as ga \n on p.rxcui = ga.product_rxcui\n and ga.ndc_product_tty in ('SCD','GPCK')\nleft join dev_thuxuan.terminology.ndc as n \n on ga.ndc = n.ndc\nleft join dev_thuxuan.pharmacy._int_claims_current_cost as gc \n on ga.ndc = gc.ndc_code\n and gc.brand_vs_generic = 'generic'\n and gc.data_source = p.data_source\nwhere \n ga.product_startmarketingdate is not null\n \n and cast(ga.product_startmarketingdate as date) <= current_date\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__pharmacy_claim_expanded", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\final\\pharmacy__pharmacy_claim_expanded.sql", "original_file_path": "models\\pharmacy\\final\\pharmacy__pharmacy_claim_expanded.sql", "unique_id": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "fqn": ["the_tuva_project", "pharmacy", "final", "pharmacy__pharmacy_claim_expanded"], "alias": "pharmacy_claim_expanded", "checksum": {"name": "sha256", "checksum": "cf7704113ebe67e97e4ab6fb31b321f913666e9d1ff9437ea23d6f7a3e4a3bc3"}, "config": {"enabled": true, "alias": "pharmacy_claim_expanded", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Expanded view of pharmacy claims with additional details.\n", "columns": {"data_source": {"name": "data_source", "description": "Source of the data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_id": {"name": "claim_id", "description": "Unique identifier for each pharmacy claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_line_number": {"name": "claim_line_number", "description": "Line number of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "Unique identifier for each patient.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "member_id": {"name": "member_id", "description": "Unique identifier for each member.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_provider_id": {"name": "prescribing_provider_id", "description": "ID of the prescribing provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_provider_id": {"name": "dispensing_provider_id", "description": "ID of the dispensing provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date when the drug was dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National Drug Code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_description": {"name": "ndc_description", "description": "Description of the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "quantity": {"name": "quantity", "description": "Quantity of the drug dispensed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days the drug supply will last.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "refills": {"name": "refills", "description": "Number of refills for the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "Date when the drug was paid for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "Amount paid for the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "allowed_amount": {"name": "allowed_amount", "description": "Total allowed amount covered by insurance.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxcui": {"name": "rxcui", "description": "RxNorm Concept Unique Identifier.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "product_name": {"name": "product_name", "description": "Name of the product.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "product_tty": {"name": "product_tty", "description": "Term type of the product.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_vs_generic": {"name": "brand_vs_generic", "description": "Indicates whether the drug is a brand or generic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_name": {"name": "brand_name", "description": "Name of the brand.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_rxcui": {"name": "generic_rxcui", "description": "RxNorm Concept Unique Identifier for the generic version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_rxcui_description": {"name": "generic_rxcui_description", "description": "Description of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_tty": {"name": "generic_tty", "description": "Term type of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ingredient_name": {"name": "ingredient_name", "description": "Active ingredient in the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dose_form_name": {"name": "dose_form_name", "description": "Form of the drug dose.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available": {"name": "generic_available", "description": "Indicates if a generic version is available.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_cost_per_unit": {"name": "brand_cost_per_unit", "description": "Cost per unit for the brand drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_average_cost_per_unit": {"name": "generic_average_cost_per_unit", "description": "Average cost per unit of the generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "brand_less_generic_cost_per_unit": {"name": "brand_less_generic_cost_per_unit", "description": "Difference in cost per unit between the brand and generic drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available_total_opportunity": {"name": "generic_available_total_opportunity", "description": "Total potential savings from substituting with generics, where applicable, calculated per unit.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "generic_available_sk": {"name": "generic_available_sk", "description": "Surrogate key for generic availability data.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "pharmacy_claim_expanded", "tags": ["pharmacy"], "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9614599, "relation_name": "dev_thuxuan.pharmacy.pharmacy_claim_expanded", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nwith all_drugs as (\r\n select \r\n p.data_source\r\n , p.claim_id\r\n , p.claim_line_number\r\n , p.patient_id\r\n , p.member_id\r\n , p.prescribing_provider_id\r\n , p.dispensing_provider_id\r\n , p.dispensing_date\r\n , p.ndc_code\r\n , p.ndc_description\r\n , p.quantity\r\n , p.days_supply\r\n , p.refills\r\n , p.paid_date\r\n , p.paid_amount\r\n , p.allowed_amount\r\n , p.rxcui\r\n , r.product_name\r\n , r.product_tty\r\n , r.brand_vs_generic\r\n , r.brand_name\r\n , r.clinical_product_rxcui as generic_rxcui\r\n , r.clinical_product_name as generic_rxcui_description\r\n , r.clinical_product_tty as generic_tty\r\n , r.ingredient_name\r\n , r.dose_form_name\r\n , case \r\n when ga.brand_with_generic_available is not null \r\n then 'brand_with_generic_available' \r\n else r.brand_vs_generic \r\n end as generic_available\r\n , opp.brand_cost_per_unit\r\n , opp.generic_average_cost_per_unit\r\n , opp.brand_less_generic_cost_per_unit\r\n , opp.generic_available_total_opportunity\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ ref('pharmacy__stg_pharmacy_claim') }} as p\r\n left join {{ ref('terminology__rxnorm_brand_generic') }} as r \r\n on p.rxcui = r.product_rxcui\r\n left join {{ ref('pharmacy__int_brand_with_generic_available') }} as ga \r\n on p.rxcui = ga.brand_with_generic_available\r\n left join {{ ref('pharmacy__brand_generic_opportunity') }} as opp \r\n on p.claim_id = opp.claim_id\r\n and p.claim_line_number = opp.claim_line_number\r\n and p.data_source = opp.data_source\r\n)\r\n\r\n, generic_available as (\r\n select \r\n *\r\n , row_number() over (order by ndc_code, data_source) as generic_available_sk\r\n from all_drugs\r\n where generic_available = 'brand_with_generic_available'\r\n)\r\n\r\nselect \r\n a.data_source\r\n , a.claim_id\r\n , a.claim_line_number\r\n , a.patient_id\r\n , a.member_id\r\n , a.prescribing_provider_id\r\n , a.dispensing_provider_id\r\n , a.dispensing_date\r\n , a.ndc_code\r\n , a.ndc_description\r\n , a.quantity\r\n , a.days_supply\r\n , a.refills\r\n , a.paid_date\r\n , a.paid_amount\r\n , a.allowed_amount\r\n , a.rxcui\r\n , a.product_name\r\n , a.product_tty\r\n , a.brand_vs_generic\r\n , a.brand_name\r\n , a.generic_rxcui\r\n , a.generic_rxcui_description\r\n , a.generic_tty\r\n , a.ingredient_name\r\n , a.dose_form_name\r\n , a.generic_available\r\n , a.brand_cost_per_unit\r\n , a.generic_average_cost_per_unit\r\n , a.brand_less_generic_cost_per_unit\r\n , a.generic_available_total_opportunity\r\n , g.generic_available_sk\r\nfrom all_drugs as a\r\nleft join generic_available as g \r\n on a.claim_id = g.claim_id\r\n and a.claim_line_number = g.claim_line_number\r\n and a.data_source = g.data_source", "language": "sql", "refs": [{"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__rxnorm_brand_generic", "package": null, "version": null}, {"name": "pharmacy__int_brand_with_generic_available", "package": null, "version": null}, {"name": "pharmacy__brand_generic_opportunity", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__brand_generic_opportunity"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\final\\pharmacy__pharmacy_claim_expanded.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n), all_drugs as (\n select \n p.data_source\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.ndc_code\n , p.ndc_description\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\n , p.paid_amount\n , p.allowed_amount\n , p.rxcui\n , r.product_name\n , r.product_tty\n , r.brand_vs_generic\n , r.brand_name\n , r.clinical_product_rxcui as generic_rxcui\n , r.clinical_product_name as generic_rxcui_description\n , r.clinical_product_tty as generic_tty\n , r.ingredient_name\n , r.dose_form_name\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else r.brand_vs_generic \n end as generic_available\n , opp.brand_cost_per_unit\n , opp.generic_average_cost_per_unit\n , opp.brand_less_generic_cost_per_unit\n , opp.generic_available_total_opportunity\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from __dbt__cte__stg_pharmacy_claim as p\n left join dev_thuxuan.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\n left join dev_thuxuan.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\n left join dev_thuxuan.pharmacy.brand_generic_opportunity as opp \n on p.claim_id = opp.claim_id\n and p.claim_line_number = opp.claim_line_number\n and p.data_source = opp.data_source\n)\n\n, generic_available as (\n select \n *\n , row_number() over (order by ndc_code, data_source) as generic_available_sk\n from all_drugs\n where generic_available = 'brand_with_generic_available'\n)\n\nselect \n a.data_source\n , a.claim_id\n , a.claim_line_number\n , a.patient_id\n , a.member_id\n , a.prescribing_provider_id\n , a.dispensing_provider_id\n , a.dispensing_date\n , a.ndc_code\n , a.ndc_description\n , a.quantity\n , a.days_supply\n , a.refills\n , a.paid_date\n , a.paid_amount\n , a.allowed_amount\n , a.rxcui\n , a.product_name\n , a.product_tty\n , a.brand_vs_generic\n , a.brand_name\n , a.generic_rxcui\n , a.generic_rxcui_description\n , a.generic_tty\n , a.ingredient_name\n , a.dose_form_name\n , a.generic_available\n , a.brand_cost_per_unit\n , a.generic_average_cost_per_unit\n , a.brand_less_generic_cost_per_unit\n , a.generic_available_total_opportunity\n , g.generic_available_sk\nfrom all_drugs as a\nleft join generic_available as g \n on a.claim_id = g.claim_id\n and a.claim_line_number = g.claim_line_number\n and a.data_source = g.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_brand_with_generic_available": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__int_brand_with_generic_available", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\intermediate\\pharmacy__int_brand_with_generic_available.sql", "original_file_path": "models\\pharmacy\\intermediate\\pharmacy__int_brand_with_generic_available.sql", "unique_id": "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_brand_with_generic_available"], "alias": "_int_brand_with_generic_available", "checksum": {"name": "sha256", "checksum": "33858903f8a0fca48246cc4a0f7393cd08a4a6f5993b1f27cf4864e815193b3b"}, "config": {"enabled": true, "alias": "_int_brand_with_generic_available", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view identifying brand drugs that have generic equivalents available.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_brand_with_generic_available", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9634607, "relation_name": "dev_thuxuan.pharmacy._int_brand_with_generic_available", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect distinct \r\n product_rxcui as brand_with_generic_available\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy__rxnorm_generic_available') }}\r\nwhere \r\n ndc_product_tty in ('SCD', 'GPCK')\r\n {% if target.type == 'fabric' %}\r\n and cast(product_startmarketingdate as date) <= GETDATE()\r\n {% else %}\r\n and cast(product_startmarketingdate as date) <= current_date\r\n{% endif %}", "language": "sql", "refs": [{"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\intermediate\\pharmacy__int_brand_with_generic_available.sql", "compiled": true, "compiled_code": "\n\nselect distinct \n product_rxcui as brand_with_generic_available\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.pharmacy.rxnorm_generic_available\nwhere \n ndc_product_tty in ('SCD', 'GPCK')\n \n and cast(product_startmarketingdate as date) <= current_date\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_claims_current_cost": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__int_claims_current_cost", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\intermediate\\pharmacy__int_claims_current_cost.sql", "original_file_path": "models\\pharmacy\\intermediate\\pharmacy__int_claims_current_cost.sql", "unique_id": "model.the_tuva_project.pharmacy__int_claims_current_cost", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_claims_current_cost"], "alias": "_int_claims_current_cost", "checksum": {"name": "sha256", "checksum": "c0622532f2b087ef80091d85b0696d7f54e074d16888b3b80ebe41eaf0263ec7"}, "config": {"enabled": true, "alias": "_int_claims_current_cost", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view calculating the current cost of claims.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_claims_current_cost", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.965461, "relation_name": "dev_thuxuan.pharmacy._int_claims_current_cost", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n/* All claims, current cost*/\r\n\r\nselect \r\n p.ndc_code\r\n , p.ndc_description\r\n , p.data_source\r\n , p.rxcui\r\n , r.brand_vs_generic\r\n , case \r\n when ga.brand_with_generic_available is not null \r\n then 'brand_with_generic_available' \r\n else null \r\n end as generic_available\r\n , sum(paid_amount) as paid_amount\r\n , count(distinct claim_id) as claim_count\r\n , sum(paid_amount) / count(distinct claim_id) as cost_per_claim\r\n , sum(quantity) as total_units\r\n , case \r\n when sum(quantity) > 0 \r\n and sum(paid_amount) > 0 \r\n then sum(paid_amount) / sum(quantity) \r\n else null \r\n end as cost_per_unit\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy__stg_pharmacy_claim') }} as p\r\nleft join {{ ref('terminology__rxnorm_brand_generic') }} as r \r\n on p.rxcui = r.product_rxcui\r\nleft join {{ ref('pharmacy__int_brand_with_generic_available') }} as ga \r\n on p.rxcui = ga.brand_with_generic_available\r\nwhere p.ndc_code is not null\r\ngroup by \r\n case \r\n when ga.brand_with_generic_available is not null \r\n then 'brand_with_generic_available' \r\n else null \r\n end\r\n , r.brand_vs_generic\r\n , p.ndc_code\r\n , p.rxcui\r\n , p.ndc_description\r\n , p.data_source", "language": "sql", "refs": [{"name": "pharmacy__stg_pharmacy_claim", "package": null, "version": null}, {"name": "terminology__rxnorm_brand_generic", "package": null, "version": null}, {"name": "pharmacy__int_brand_with_generic_available", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "model.the_tuva_project.pharmacy__int_brand_with_generic_available"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\intermediate\\pharmacy__int_claims_current_cost.sql", "compiled": true, "compiled_code": "\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n) /* All claims, current cost*/\n\nselect \n p.ndc_code\n , p.ndc_description\n , p.data_source\n , p.rxcui\n , r.brand_vs_generic\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end as generic_available\n , sum(paid_amount) as paid_amount\n , count(distinct claim_id) as claim_count\n , sum(paid_amount) / count(distinct claim_id) as cost_per_claim\n , sum(quantity) as total_units\n , case \n when sum(quantity) > 0 \n and sum(paid_amount) > 0 \n then sum(paid_amount) / sum(quantity) \n else null \n end as cost_per_unit\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\nleft join dev_thuxuan.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\nleft join dev_thuxuan.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\nwhere p.ndc_code is not null\ngroup by \n case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end\n , r.brand_vs_generic\n , p.ndc_code\n , p.rxcui\n , p.ndc_description\n , p.data_source", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "sql": " __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_generic_cost": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__int_generic_cost", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\intermediate\\pharmacy__int_generic_cost.sql", "original_file_path": "models\\pharmacy\\intermediate\\pharmacy__int_generic_cost.sql", "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_generic_cost"], "alias": "_int_generic_cost", "checksum": {"name": "sha256", "checksum": "e3770cb98ab638c3da281c6ddbe17417e5c52fbeb158884aed6a2b1cae3a079b"}, "config": {"enabled": true, "alias": "_int_generic_cost", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view calculating the cost of generic drugs.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_generic_cost", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.967461, "relation_name": "dev_thuxuan.pharmacy._int_generic_cost", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n/* for each brand rxcui, what is the average cost/unit of generics available*/\r\n\r\nselect\r\n g.product_rxcui as brand_rxcui\r\n , cl.data_source\r\n , max(case when claim_count > 0 then 1 else 0 end) as prescribed_atleast_one_generic_history\r\n , sum(case when total_units > 0 and paid_amount > 0 then paid_amount else null end)/sum(case when total_units > 0 and paid_amount > 0 then total_units else null end) as generic_average_cost_per_unit\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy__rxnorm_generic_available') }} as g\r\nleft join {{ ref('pharmacy__int_claims_current_cost') }} as cl \r\n on cl.ndc_code = g.ndc\r\nwhere cl.brand_vs_generic = 'generic'\r\ngroup by\r\n g.product_rxcui\r\n , cl.data_source", "language": "sql", "refs": [{"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available", "model.the_tuva_project.pharmacy__int_claims_current_cost"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\intermediate\\pharmacy__int_generic_cost.sql", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , max(case when claim_count > 0 then 1 else 0 end) as prescribed_atleast_one_generic_history\n , sum(case when total_units > 0 and paid_amount > 0 then paid_amount else null end)/sum(case when total_units > 0 and paid_amount > 0 then total_units else null end) as generic_average_cost_per_unit\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.pharmacy.rxnorm_generic_available as g\nleft join dev_thuxuan.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'\ngroup by\n g.product_rxcui\n , cl.data_source", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__int_generic_cost_by_ndc", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\intermediate\\pharmacy__int_generic_cost_by_ndc.sql", "original_file_path": "models\\pharmacy\\intermediate\\pharmacy__int_generic_cost_by_ndc.sql", "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc", "fqn": ["the_tuva_project", "pharmacy", "intermediate", "pharmacy__int_generic_cost_by_ndc"], "alias": "_int_generic_cost_by_ndc", "checksum": {"name": "sha256", "checksum": "4cd0ab4b95e39486fee8c408fa8a95192e5fc1a80f7217773f4fe4e697b35604"}, "config": {"enabled": true, "alias": "_int_generic_cost_by_ndc", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Intermediate view calculating the cost of generic drugs at the ndc level for informational purposes.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "_int_generic_cost_by_ndc", "tags": ["pharmacy"], "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.969461, "relation_name": "dev_thuxuan.pharmacy._int_generic_cost_by_ndc", "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\n/* for each brand rxcui, what is the average cost/unit of all generics available*/\r\n\r\nselect\r\n g.product_rxcui as brand_rxcui\r\n , cl.data_source\r\n , cl.ndc_code as generic_ndc_code\r\n , cl.paid_amount\r\n , cl.claim_count\r\n , cl.total_units\r\n , cl.cost_per_unit\r\n , case when claim_count > 0 then 1 else 0 end as prescribed_atleast_one_generic_history\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('pharmacy__rxnorm_generic_available') }} as g\r\nleft join {{ ref('pharmacy__int_claims_current_cost') }} as cl \r\n on cl.ndc_code = g.ndc\r\nwhere cl.brand_vs_generic = 'generic'", "language": "sql", "refs": [{"name": "pharmacy__rxnorm_generic_available", "package": null, "version": null}, {"name": "pharmacy__int_claims_current_cost", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available", "model.the_tuva_project.pharmacy__int_claims_current_cost"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\intermediate\\pharmacy__int_generic_cost_by_ndc.sql", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of all generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , cl.ndc_code as generic_ndc_code\n , cl.paid_amount\n , cl.claim_count\n , cl.total_units\n , cl.cost_per_unit\n , case when claim_count > 0 then 1 else 0 end as prescribed_atleast_one_generic_history\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.pharmacy.rxnorm_generic_available as g\nleft join dev_thuxuan.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.pharmacy__stg_pharmacy_claim": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "pharmacy\\staging\\pharmacy__stg_pharmacy_claim.sql", "original_file_path": "models\\pharmacy\\staging\\pharmacy__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "fqn": ["the_tuva_project", "pharmacy", "staging", "pharmacy__stg_pharmacy_claim"], "alias": "stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "ff2ebe8ecd47bbff49b1830376eb1176f24fbc14a93ec577bd68adf4564b9d60"}, "config": {"enabled": true, "alias": "stg_pharmacy_claim", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["pharmacy"], "description": "Staging table for pharmacy claims, serving as the basis for further calculations.", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\pharmacy\\pharmacy_models.yml", "build_path": null, "unrendered_config": {"schema": "pharmacy", "alias": "stg_pharmacy_claim", "tags": ["pharmacy"], "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9725957, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('brand_generic_enabled', var('claims_enabled', var('tuva_marts_enabled', False))) | as_bool\r\n) }}\r\n\r\nselect \r\n p.ndc_code\r\n , n.fda_description as ndc_description\r\n , p.data_source\r\n , n.rxcui\r\n , p.paid_amount\r\n , p.allowed_amount\r\n , p.claim_id\r\n , p.claim_line_number\r\n , p.patient_id\r\n , p.member_id\r\n , p.prescribing_provider_id\r\n , p.dispensing_provider_id\r\n , p.dispensing_date\r\n , p.quantity\r\n , p.days_supply\r\n , p.refills\r\n , p.paid_date\r\nfrom {{ ref('core__pharmacy_claim') }} as p\r\nleft join {{ ref('terminology__ndc') }} as n \r\n on p.ndc_code = n.ndc", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}, {"name": "terminology__ndc", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.terminology__ndc"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\staging\\pharmacy__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__summary_counts": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__summary_counts", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\final\\quality_measures__summary_counts.sql", "original_file_path": "models\\quality_measures\\final\\quality_measures__summary_counts.sql", "unique_id": "model.the_tuva_project.quality_measures__summary_counts", "fqn": ["the_tuva_project", "quality_measures", "final", "quality_measures__summary_counts"], "alias": "summary_counts", "checksum": {"name": "sha256", "checksum": "744c720898dd2acc91d01ccb4ec34c9f8f0a8b43d1b18d3ac1eed11fc010f4e8"}, "config": {"enabled": true, "alias": "summary_counts", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Reporting measure counts with performance rates.", "columns": {"measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_sum": {"name": "denominator_sum", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_sum": {"name": "numerator_sum", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved with exclusion logic applied.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_sum": {"name": "exclusion_sum", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_rate": {"name": "performance_rate", "description": "Calculated performance rate. The numerator sum divided by the denominator sum after exclusion logic applied and multiplied by 100.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "summary_counts", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9869058, "relation_name": "dev_thuxuan.quality_measures.summary_counts", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith summary_long as (\r\n\r\n select\r\n measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , performance_flag\r\n from {{ ref('quality_measures__summary_long') }}\r\n where measure_id is not null\r\n\r\n)\r\n\r\n, calculate_performance_rate as (\r\n\r\n select\r\n measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , sum(denominator_flag) as denominator_sum\r\n , sum(numerator_flag) as numerator_sum\r\n , sum(exclusion_flag) as exclusion_sum\r\n , (\r\n cast(sum(performance_flag) as {{ dbt.type_numeric() }}) /\r\n (cast(count(performance_flag) as {{ dbt.type_numeric() }}) )\r\n )*100 as performance_rate\r\n from summary_long\r\n group by\r\n measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(denominator_sum as integer) as denominator_sum\r\n , cast(numerator_sum as integer) as numerator_sum\r\n , cast(exclusion_sum as integer) as exclusion_sum\r\n , round(cast(performance_rate as {{ dbt.type_numeric() }}),3) as performance_rate\r\n from calculate_performance_rate\r\n\r\n)\r\n\r\nselect\r\n measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , denominator_sum\r\n , numerator_sum\r\n , exclusion_sum\r\n , performance_rate\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__summary_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\final\\quality_measures__summary_counts.sql", "compiled": true, "compiled_code": "\n\nwith summary_long as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n from dev_thuxuan.quality_measures.summary_long\n where measure_id is not null\n\n)\n\n, calculate_performance_rate as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , sum(denominator_flag) as denominator_sum\n , sum(numerator_flag) as numerator_sum\n , sum(exclusion_flag) as exclusion_sum\n , (\n cast(sum(performance_flag) as numeric(28,6)) /\n (cast(count(performance_flag) as numeric(28,6)) )\n )*100 as performance_rate\n from summary_long\n group by\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(denominator_sum as integer) as denominator_sum\n , cast(numerator_sum as integer) as numerator_sum\n , cast(exclusion_sum as integer) as exclusion_sum\n , round(cast(performance_rate as numeric(28,6)),3) as performance_rate\n from calculate_performance_rate\n\n)\n\nselect\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_sum\n , numerator_sum\n , exclusion_sum\n , performance_rate\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__summary_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__summary_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\final\\quality_measures__summary_long.sql", "original_file_path": "models\\quality_measures\\final\\quality_measures__summary_long.sql", "unique_id": "model.the_tuva_project.quality_measures__summary_long", "fqn": ["the_tuva_project", "quality_measures", "final", "quality_measures__summary_long"], "alias": "summary_long", "checksum": {"name": "sha256", "checksum": "6f4e7773541420b39a44b2034caa4539842e221eb8da4cf27dbf00d8b8502e66"}, "config": {"enabled": true, "alias": "summary_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Long view of the results for the reporting version of all measures. Each row represents the results a measure per patient. A null for the denominator indicates that the patient was not eligible for that measure.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_flag": {"name": "performance_flag", "description": "Performance flag calculated by using exclusion, numerator, and denominator flags. When excluded from a measure the flag is null.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/quality_measures/quality_measures__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "summary_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9909143, "relation_name": "dev_thuxuan.quality_measures.summary_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/* measures should already be at the full eligibility population grain */\r\nwith union_measures as (\r\n\r\n {{ dbt_utils.union_relations(\r\n\r\n relations=[\r\n ref('quality_measures__int_nqf2372_long')\r\n , ref('quality_measures__int_nqf0034_long')\r\n , ref('quality_measures__int_nqf0059_long')\r\n , ref('quality_measures__int_cqm236_long')\r\n , ref('quality_measures__int_nqf0053_long')\r\n , ref('quality_measures__int_cbe0055_long')\r\n , ref('quality_measures__int_nqf0097_long')\r\n , ref('quality_measures__int_cqm438_long')\r\n , ref('quality_measures__int_nqf0041_long')\r\n , ref('quality_measures__int_cbe0101_long')\r\n , ref('quality_measures__int_cqm48_long')\r\n , ref('quality_measures__int_cqm130_long')\r\n , ref('quality_measures__int_nqf0420_long')\r\n , ref('quality_measures__int_adh_diabetes_long')\r\n , ref('quality_measures__int_adhras_long')\r\n ]\r\n\r\n ) }}\r\n\r\n)\r\n\r\n, patient as (\r\n\r\n select distinct patient_id\r\n from {{ ref('quality_measures__stg_core__patient') }}\r\n\r\n)\r\n\r\n/* selecting the full patient population as the grain of this table */\r\n, joined as (\r\n\r\n select distinct\r\n patient.patient_id\r\n , union_measures.denominator_flag\r\n , union_measures.numerator_flag\r\n , union_measures.exclusion_flag\r\n , case\r\n when union_measures.exclusion_flag = 1 then null\r\n when union_measures.numerator_flag = 1 then 1\r\n when union_measures.denominator_flag = 1 then 0\r\n else null\r\n end as performance_flag\r\n , union_measures.evidence_date\r\n , union_measures.evidence_value\r\n , union_measures.exclusion_date\r\n , union_measures.exclusion_reason\r\n , union_measures.performance_period_begin\r\n , union_measures.performance_period_end\r\n , union_measures.measure_id\r\n , union_measures.measure_name\r\n , union_measures.measure_version\r\n from patient\r\n left join union_measures\r\n on patient.patient_id = union_measures.patient_id\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(performance_flag as integer) as performance_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from joined\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , performance_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_long", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_long", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_long", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_long", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_long", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_long", "package": null, "version": null}, {"name": "quality_measures__int_adhras_long", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.union_relations", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_long", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0059_long", "model.the_tuva_project.quality_measures__int_cqm236_long", "model.the_tuva_project.quality_measures__int_nqf0053_long", "model.the_tuva_project.quality_measures__int_cbe0055_long", "model.the_tuva_project.quality_measures__int_nqf0097_long", "model.the_tuva_project.quality_measures__int_cqm438_long", "model.the_tuva_project.quality_measures__int_nqf0041_long", "model.the_tuva_project.quality_measures__int_cbe0101_long", "model.the_tuva_project.quality_measures__int_cqm48_long", "model.the_tuva_project.quality_measures__int_cqm130_long", "model.the_tuva_project.quality_measures__int_nqf0420_long", "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "model.the_tuva_project.quality_measures__int_adhras_long", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\final\\quality_measures__summary_long.sql", "compiled": true, "compiled_code": "\n\n/* measures should already be at the full eligibility population grain */\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), union_measures as (\n\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf2372_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf2372_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0034_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0034_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0059_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0059_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm236_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm236_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0053_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0053_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cbe0055_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cbe0055_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0097_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0097_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm438_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm438_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0041_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0041_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cbe0101_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cbe0101_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm48_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm48_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm130_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm130_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0420_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0420_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_adh_diabetes_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_adh_diabetes_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_adhras_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_adhras_long\n\n \n )\n\n \n\n)\n\n, patient as (\n\n select distinct patient_id\n from __dbt__cte___stg_patient\n\n)\n\n/* selecting the full patient population as the grain of this table */\n, joined as (\n\n select distinct\n patient.patient_id\n , union_measures.denominator_flag\n , union_measures.numerator_flag\n , union_measures.exclusion_flag\n , case\n when union_measures.exclusion_flag = 1 then null\n when union_measures.numerator_flag = 1 then 1\n when union_measures.denominator_flag = 1 then 0\n else null\n end as performance_flag\n , union_measures.evidence_date\n , union_measures.evidence_value\n , union_measures.exclusion_date\n , union_measures.exclusion_reason\n , union_measures.performance_period_begin\n , union_measures.performance_period_end\n , union_measures.measure_id\n , union_measures.measure_name\n , union_measures.measure_version\n from patient\n left join union_measures\n on patient.patient_id = union_measures.patient_id\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(performance_flag as integer) as performance_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from joined\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__summary_wide": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__summary_wide", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\final\\quality_measures__summary_wide.sql", "original_file_path": "models\\quality_measures\\final\\quality_measures__summary_wide.sql", "unique_id": "model.the_tuva_project.quality_measures__summary_wide", "fqn": ["the_tuva_project", "quality_measures", "final", "quality_measures__summary_wide"], "alias": "summary_wide", "checksum": {"name": "sha256", "checksum": "de00302c994c3c14e2e28dca7ae2ef75c6252172f888180ed28581c7422ad084"}, "config": {"enabled": true, "alias": "summary_wide", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Wide view of the results for the reporting version of all measures. This model pivots measures on the patient level (i.e. one row per patient with flags for each measure. The false flags can be treated as care gaps as exclusions have been included in the pivot logic.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_2372": {"name": "nqf_2372", "description": "Performance flag for NQF2372, Breast Cancer Screening. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0034": {"name": "nqf_0034", "description": "Performance flag for NQF0034, Colorectal Cancer Screening. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0059": {"name": "nqf_0059", "description": "Performance flag for NQF0059, Diabetes: Hemoglobin A1c (HbA1c) Poor Control (> 9%). A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_236": {"name": "cqm_236", "description": "Performance flag for CQM236, Controlling High Blood Pressure. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0053": {"name": "nqf_0053", "description": "Performance flag for NQF0053, Osteoporosis Management in Women Who Had a Fracture. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cbe_0055": {"name": "cbe_0055", "description": "Performance flag for CBE0055, Diabetes: Eye Exam. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0097": {"name": "nqf_0097", "description": "Performance flag for NQF0097, Medication Reconciliation Post-Discharge. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_438": {"name": "cqm_438", "description": "Performance flag for CQM438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0041": {"name": "nqf_0041", "description": "Performance flag for NQF0041, Influenza Immunization. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cbe_0101": {"name": "cbe_0101", "description": "Performance flag for CBE0101, Falls: Plan of Care. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_48": {"name": "cqm_48", "description": "Performance flag for CQM48, Urinary Incontinence: Assessment of Presence or Absence of Urinary Incontinence in Women Aged 65 Years and Older. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cqm_130": {"name": "cqm_130", "description": "Performance flag for CQM130, Documentation of Current Medications in the Medical Record. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "nqf_0420": {"name": "nqf_0420", "description": "Performance flag for NQF0420, Pain Assessment and Follow-Up. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adh_diabetes": {"name": "adh_diabetes", "description": "Performance flag for ADH-Diabetes, Medication Adherence for Diabetes Medications. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adh_ras": {"name": "adh_ras", "description": "Performance flag for ADH-RAS, Medication Adherence for Hypertension. A null indicates that the measure was not applicable for the patient.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "summary_wide", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9969223, "relation_name": "dev_thuxuan.quality_measures.summary_wide", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\n Each measure is pivoted into a boolean column by evaluating the\r\n denominator, numerator, and exclusion flags.\r\n*/\r\nwith measures_long as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , performance_flag\r\n , measure_id\r\n from {{ ref('quality_measures__summary_long') }}\r\n\r\n)\r\n\r\n, nqf_2372 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF2372'\r\n\r\n)\r\n\r\n, nqf_0034 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF0034'\r\n\r\n)\r\n\r\n, nqf_0059 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF0059'\r\n\r\n)\r\n\r\n, cqm_236 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'CQM236'\r\n\r\n)\r\n\r\n, nqf_0053 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF0053'\r\n\r\n)\r\n\r\n, cbe_0055 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'CBE0055'\r\n\r\n)\r\n\r\n, nqf_0097 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF0097'\r\n\r\n)\r\n\r\n, cqm_438 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'CQM438'\r\n\r\n)\r\n\r\n, nqf_0041 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF0041'\r\n\r\n)\r\n\r\n, cbe_0101 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'CBE0101'\r\n\r\n)\r\n\r\n, cqm_48 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'CQM48'\r\n\r\n)\r\n\r\n, cqm_130 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'CQM130'\r\n\r\n)\r\n\r\n, nqf_0420 as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'NQF0420'\r\n\r\n)\r\n\r\n, adh_diabetes as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'ADH-Diabetes'\r\n\r\n)\r\n\r\n, adh_ras as (\r\n\r\n select\r\n patient_id\r\n , performance_flag\r\n from measures_long\r\n where measure_id = 'ADH-RAS'\r\n \r\n)\r\n\r\n, joined as (\r\n\r\n select\r\n measures_long.patient_id\r\n , max(nqf_2372.performance_flag) as nqf_2372\r\n , max(nqf_0034.performance_flag) as nqf_0034\r\n , max(nqf_0059.performance_flag) as nqf_0059\r\n , max(cqm_236.performance_flag) as cqm_236\r\n , max(nqf_0053.performance_flag) as nqf_0053\r\n , max(cbe_0055.performance_flag) as cbe_0055\r\n , max(nqf_0097.performance_flag) as nqf_0097\r\n , max(cqm_438.performance_flag) as cqm_438\r\n , max(nqf_0041.performance_flag) as nqf_0041\r\n , max(cbe_0101.performance_flag) as cbe_0101\r\n , max(cqm_48.performance_flag) as cqm_48\r\n , max(cqm_130.performance_flag) as cqm_130\r\n , max(nqf_0420.performance_flag) as nqf_0420\r\n , max(adh_diabetes.performance_flag) as adh_diabetes\r\n , max(adh_ras.performance_flag) as adh_ras\r\n from measures_long\r\n left join nqf_2372\r\n on measures_long.patient_id = nqf_2372.patient_id\r\n left join nqf_0034\r\n on measures_long.patient_id = nqf_0034.patient_id\r\n left join nqf_0059\r\n on measures_long.patient_id = nqf_0059.patient_id\r\n left join cqm_236\r\n on measures_long.patient_id = cqm_236.patient_id\r\n left join nqf_0053\r\n on measures_long.patient_id = nqf_0053.patient_id\r\n left join cbe_0055\r\n on measures_long.patient_id = cbe_0055.patient_id\r\n left join nqf_0097\r\n on measures_long.patient_id = nqf_0097.patient_id\r\n left join cqm_438\r\n on measures_long.patient_id = cqm_438.patient_id\r\n left join nqf_0041\r\n on measures_long.patient_id = nqf_0041.patient_id\r\n left join cbe_0101\r\n on measures_long.patient_id = cbe_0101.patient_id\r\n left join cqm_48\r\n on measures_long.patient_id = cqm_48.patient_id\r\n left join cqm_130\r\n on measures_long.patient_id = cqm_130.patient_id\r\n left join nqf_0420\r\n on measures_long.patient_id = nqf_0420.patient_id\r\n left join adh_diabetes\r\n on measures_long.patient_id = adh_diabetes.patient_id\r\n left join adh_ras\r\n on measures_long.patient_id = adh_ras.patient_id\r\n group by measures_long.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(nqf_2372 as integer) as nqf_2372\r\n , cast(nqf_0034 as integer) as nqf_0034\r\n , cast(nqf_0059 as integer) as nqf_0059\r\n , cast(cqm_236 as integer) as cqm_236\r\n , cast(nqf_0053 as integer) as nqf_0053\r\n , cast(cbe_0055 as integer) as cbe_0055\r\n , cast(nqf_0097 as integer) as nqf_0097\r\n , cast(cqm_438 as integer) as cqm_438 \r\n , cast(nqf_0041 as integer) as nqf_0041\r\n , cast(cbe_0101 as integer) as cbe_0101\r\n , cast(cqm_48 as integer) as cqm_48\r\n , cast(cqm_130 as integer) as cqm_130\r\n , cast(nqf_0420 as integer) as nqf_0420\r\n , cast(adh_diabetes as integer) as adh_diabetes\r\n , cast(adh_ras as integer) as adh_ras\r\n from joined\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , nqf_2372\r\n , nqf_0034\r\n , nqf_0059\r\n , cqm_236\r\n , nqf_0053\r\n , cbe_0055\r\n , nqf_0097\r\n , cqm_438\r\n , nqf_0041\r\n , cbe_0101\r\n , cqm_48\r\n , cqm_130\r\n , nqf_0420\r\n , adh_diabetes\r\n , adh_ras\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__summary_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\final\\quality_measures__summary_wide.sql", "compiled": true, "compiled_code": "\n\n/*\n Each measure is pivoted into a boolean column by evaluating the\n denominator, numerator, and exclusion flags.\n*/\nwith measures_long as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , measure_id\n from dev_thuxuan.quality_measures.summary_long\n\n)\n\n, nqf_2372 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF2372'\n\n)\n\n, nqf_0034 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0034'\n\n)\n\n, nqf_0059 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0059'\n\n)\n\n, cqm_236 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM236'\n\n)\n\n, nqf_0053 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0053'\n\n)\n\n, cbe_0055 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0055'\n\n)\n\n, nqf_0097 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0097'\n\n)\n\n, cqm_438 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM438'\n\n)\n\n, nqf_0041 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0041'\n\n)\n\n, cbe_0101 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0101'\n\n)\n\n, cqm_48 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM48'\n\n)\n\n, cqm_130 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM130'\n\n)\n\n, nqf_0420 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0420'\n\n)\n\n, adh_diabetes as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-Diabetes'\n\n)\n\n, adh_ras as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-RAS'\n \n)\n\n, joined as (\n\n select\n measures_long.patient_id\n , max(nqf_2372.performance_flag) as nqf_2372\n , max(nqf_0034.performance_flag) as nqf_0034\n , max(nqf_0059.performance_flag) as nqf_0059\n , max(cqm_236.performance_flag) as cqm_236\n , max(nqf_0053.performance_flag) as nqf_0053\n , max(cbe_0055.performance_flag) as cbe_0055\n , max(nqf_0097.performance_flag) as nqf_0097\n , max(cqm_438.performance_flag) as cqm_438\n , max(nqf_0041.performance_flag) as nqf_0041\n , max(cbe_0101.performance_flag) as cbe_0101\n , max(cqm_48.performance_flag) as cqm_48\n , max(cqm_130.performance_flag) as cqm_130\n , max(nqf_0420.performance_flag) as nqf_0420\n , max(adh_diabetes.performance_flag) as adh_diabetes\n , max(adh_ras.performance_flag) as adh_ras\n from measures_long\n left join nqf_2372\n on measures_long.patient_id = nqf_2372.patient_id\n left join nqf_0034\n on measures_long.patient_id = nqf_0034.patient_id\n left join nqf_0059\n on measures_long.patient_id = nqf_0059.patient_id\n left join cqm_236\n on measures_long.patient_id = cqm_236.patient_id\n left join nqf_0053\n on measures_long.patient_id = nqf_0053.patient_id\n left join cbe_0055\n on measures_long.patient_id = cbe_0055.patient_id\n left join nqf_0097\n on measures_long.patient_id = nqf_0097.patient_id\n left join cqm_438\n on measures_long.patient_id = cqm_438.patient_id\n left join nqf_0041\n on measures_long.patient_id = nqf_0041.patient_id\n left join cbe_0101\n on measures_long.patient_id = cbe_0101.patient_id\n left join cqm_48\n on measures_long.patient_id = cqm_48.patient_id\n left join cqm_130\n on measures_long.patient_id = cqm_130.patient_id\n left join nqf_0420\n on measures_long.patient_id = nqf_0420.patient_id\n left join adh_diabetes\n on measures_long.patient_id = adh_diabetes.patient_id\n left join adh_ras\n on measures_long.patient_id = adh_ras.patient_id\n group by measures_long.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(nqf_2372 as integer) as nqf_2372\n , cast(nqf_0034 as integer) as nqf_0034\n , cast(nqf_0059 as integer) as nqf_0059\n , cast(cqm_236 as integer) as cqm_236\n , cast(nqf_0053 as integer) as nqf_0053\n , cast(cbe_0055 as integer) as cbe_0055\n , cast(nqf_0097 as integer) as nqf_0097\n , cast(cqm_438 as integer) as cqm_438 \n , cast(nqf_0041 as integer) as nqf_0041\n , cast(cbe_0101 as integer) as cbe_0101\n , cast(cqm_48 as integer) as cqm_48\n , cast(cqm_130 as integer) as cqm_130\n , cast(nqf_0420 as integer) as nqf_0420\n , cast(adh_diabetes as integer) as adh_diabetes\n , cast(adh_ras as integer) as adh_ras\n from joined\n\n)\n\nselect\n patient_id\n , nqf_2372\n , nqf_0034\n , nqf_0059\n , cqm_236\n , nqf_0053\n , cbe_0055\n , nqf_0097\n , cqm_438\n , nqf_0041\n , cbe_0101\n , cqm_48\n , cqm_130\n , nqf_0420\n , adh_diabetes\n , adh_ras\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adhras_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_denominator"], "alias": "_int_adhras_denominator", "checksum": {"name": "sha256", "checksum": "399a7d73468029b261626b903910b2a6d004b22a356121b3375fac7a059a7be5"}, "config": {"enabled": true, "alias": "_int_adhras_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of ADH-RAS, Medication Adherence for Hypertension\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_dispensing_date": {"name": "first_dispensing_date", "description": "Date the first prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days supply.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2114124, "relation_name": "dev_thuxuan.quality_measures._int_adhras_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith performance_period as (\r\n\r\n select\r\n measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_end\r\n , performance_period_begin\r\n from {{ ref('quality_measures__int_adhras__performance_period') }}\r\n\r\n)\r\n\r\n, visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) = 'pqa rasa medications'\r\n\r\n)\r\n\r\n, pharmacy_claim as (\r\n\r\n select \r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }}\r\n\r\n)\r\n\r\n, patient_with_claim as (\r\n\r\n select\r\n pharmacy_claim.patient_id\r\n , dispensing_date\r\n , days_supply\r\n , ndc_code\r\n from pharmacy_claim \r\n inner join visit_codes\r\n on pharmacy_claim.ndc_code = visit_codes.code\r\n \r\n)\r\n\r\n, patient_within_performance_period as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , days_supply\r\n , ndc_code\r\n , performance_period_begin\r\n , performance_period_end\r\n from patient_with_claim as claim_patient\r\n inner join performance_period as pp\r\n on claim_patient.dispensing_date between pp.performance_period_begin and pp.performance_period_end\r\n\r\n)\r\n\r\n/* \r\n These patients need to pass two checks\r\n - First medication fill date should be at least 91 days before the end of measurement period\r\n - Should have at least two distinct Date of Service (FillDate) for rx\r\n*/\r\n\r\n, patient_with_rank as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , days_supply\r\n , ndc_code\r\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\r\n from patient_within_performance_period\r\n\r\n)\r\n\r\n, patient_with_first_dispensing_date as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date as first_dispensing_date\r\n from patient_with_rank\r\n where dense_rank = 1\r\n\r\n)\r\n\r\n/*\r\ntreatment period days is abbreviated as tpd\r\n*/\r\n\r\n, patient_with_tpd as (\r\n\r\n select\r\n patients1.patient_id\r\n , patients1.dispensing_date\r\n , patients2.first_dispensing_date\r\n , patients1.days_supply\r\n , {{ datediff('first_dispensing_date', 'performance_period_end', 'day') }} as tpd\r\n from patient_within_performance_period as patients1\r\n inner join patient_with_first_dispensing_date as patients2\r\n on patients1.patient_id = patients2.patient_id\r\n\r\n)\r\n\r\n, first_check_patient as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , first_dispensing_date\r\n , days_supply\r\n from patient_with_tpd\r\n where tpd > 89\r\n \r\n)\r\n\r\n, second_check_patient as (\r\n\r\n select\r\n patient_id\r\n , ndc_code\r\n from patient_with_rank\r\n where dense_rank = 2\r\n\r\n)\r\n\r\n, both_check_patient as (\r\n\r\n select\r\n valid_patients1.patient_id\r\n , valid_patients1.dispensing_date\r\n , valid_patients1.first_dispensing_date\r\n , valid_patients1.days_supply\r\n , valid_patients2.ndc_code\r\n from first_check_patient as valid_patients1\r\n inner join second_check_patient as valid_patients2\r\n on valid_patients1.patient_id = valid_patients2.patient_id\r\n \r\n)\r\n\r\n, patient_with_age as (\r\n\r\n select\r\n valid_patients1.patient_id\r\n , floor({{ datediff('birth_date', 'pp.performance_period_begin', 'hour') }} / 8760.0) as age\r\n , dispensing_date\r\n , first_dispensing_date\r\n , days_supply\r\n , ndc_code\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n from {{ ref('quality_measures__stg_core__patient') }} as patient\r\n inner join both_check_patient as valid_patients1\r\n on patient.patient_id = valid_patients1.patient_id\r\n cross join performance_period as pp\r\n where patient.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , first_dispensing_date\r\n , days_supply\r\n , ndc_code\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , 1 as denominator_flag\r\n from patient_with_age \r\n where age > 17\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(dispensing_date as date) as dispensing_date\r\n , cast(first_dispensing_date as date) as first_dispensing_date\r\n , cast(days_supply as integer) as days_supply\r\n , cast(ndc_code as {{ dbt.type_string() }}) as ndc_code\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , dispensing_date\r\n , first_dispensing_date\r\n , days_supply\r\n , ndc_code\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) = 'pqa rasa medications'\n\n)\n\n, pharmacy_claim as (\n\n select \n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, patient_with_claim as (\n\n select\n pharmacy_claim.patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n from pharmacy_claim \n inner join visit_codes\n on pharmacy_claim.ndc_code = visit_codes.code\n \n)\n\n, patient_within_performance_period as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n from patient_with_claim as claim_patient\n inner join performance_period as pp\n on claim_patient.dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, patient_with_rank as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n from patient_within_performance_period\n\n)\n\n, patient_with_first_dispensing_date as (\n\n select\n patient_id\n , dispensing_date as first_dispensing_date\n from patient_with_rank\n where dense_rank = 1\n\n)\n\n/*\ntreatment period days is abbreviated as tpd\n*/\n\n, patient_with_tpd as (\n\n select\n patients1.patient_id\n , patients1.dispensing_date\n , patients2.first_dispensing_date\n , patients1.days_supply\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as tpd\n from patient_within_performance_period as patients1\n inner join patient_with_first_dispensing_date as patients2\n on patients1.patient_id = patients2.patient_id\n\n)\n\n, first_check_patient as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n from patient_with_tpd\n where tpd > 89\n \n)\n\n, second_check_patient as (\n\n select\n patient_id\n , ndc_code\n from patient_with_rank\n where dense_rank = 2\n\n)\n\n, both_check_patient as (\n\n select\n valid_patients1.patient_id\n , valid_patients1.dispensing_date\n , valid_patients1.first_dispensing_date\n , valid_patients1.days_supply\n , valid_patients2.ndc_code\n from first_check_patient as valid_patients1\n inner join second_check_patient as valid_patients2\n on valid_patients1.patient_id = valid_patients2.patient_id\n \n)\n\n, patient_with_age as (\n\n select\n valid_patients1.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from __dbt__cte___stg_patient as patient\n inner join both_check_patient as valid_patients1\n on patient.patient_id = valid_patients1.patient_id\n cross join performance_period as pp\n where patient.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from patient_with_age \n where age > 17\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(first_dispensing_date as date) as first_dispensing_date\n , cast(days_supply as integer) as days_supply\n , cast(ndc_code as TEXT) as ndc_code\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adhras_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_exclusions"], "alias": "_int_adhras_exclusions", "checksum": {"name": "sha256", "checksum": "656baad98bc6ef359b54d175fde129865b6a24f14d233e116651a5d91abe5509"}, "config": {"enabled": true, "alias": "_int_adhras_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of ADH-RAS, Medication Adherence for Hypertension\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2144232, "relation_name": "dev_thuxuan.quality_measures._int_adhras_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_adhras__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_adhras__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_adhras_denominator')}}\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where concept_name in (\r\n 'PQA ESRD'\r\n , 'PQA Sacubitril Valsartan Medications'\r\n )\r\n\r\n)\r\n\r\n, valid_esrd as (\r\n\r\n select\r\n condition.patient_id\r\n , condition.recorded_date as exclusion_date\r\n , codes.concept_name as exclusion_reason\r\n from {{ ref('quality_measures__stg_core__condition') }} as condition\r\n inner join codes \r\n on coalesce(condition.normalized_code, condition.source_code) = codes.code \r\n and coalesce(condition.normalized_code_type, condition.source_code_type) = codes.code_system\r\n where condition.recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, sacubitril_pharmacy_claim as (\r\n\r\n select\r\n pharmacy_claim.patient_id\r\n , pharmacy_claim.dispensing_date as exclusion_date\r\n , codes.concept_name as exclusion_reason\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claim\r\n inner join codes\r\n on pharmacy_claim.ndc_code = codes.code \r\n where pharmacy_claim.dispensing_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from valid_hospice_palliative\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from valid_esrd\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason \r\n from sacubitril_pharmacy_claim\r\n\r\n)\r\n\r\n, measure_exclusions as (\r\n\r\n select \r\n exclusions.patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from exclusions\r\n inner join denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from measure_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run \r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adhras_denominator", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), denominator as (\n\n select\n patient_id\n from dev_thuxuan.quality_measures._int_adhras_denominator\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name in (\n 'PQA ESRD'\n , 'PQA Sacubitril Valsartan Medications'\n )\n\n)\n\n, valid_esrd as (\n\n select\n condition.patient_id\n , condition.recorded_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_condition as condition\n inner join codes \n on coalesce(condition.normalized_code, condition.source_code) = codes.code \n and coalesce(condition.normalized_code_type, condition.source_code_type) = codes.code_system\n where condition.recorded_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, sacubitril_pharmacy_claim as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claim\n inner join codes\n on pharmacy_claim.ndc_code = codes.code \n where pharmacy_claim.dispensing_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_esrd\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason \n from sacubitril_pharmacy_claim\n\n)\n\n, measure_exclusions as (\n\n select \n exclusions.patient_id\n , exclusion_date\n , exclusion_reason\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from measure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run \nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adhras_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_long"], "alias": "_int_adhras_long", "checksum": {"name": "sha256", "checksum": "da0c3f2d9b18097919d70d5b0f18ff7357afb0861fbfc58a59f900cdb5571ded"}, "config": {"enabled": true, "alias": "_int_adhras_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of ADH-RAS, Medication Adherence for Hypertension before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2174146, "relation_name": "dev_thuxuan.quality_measures._int_adhras_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_adhras_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_adhras_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_adhras_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adhras_numerator", "package": null, "version": null}, {"name": "quality_measures__int_adhras_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_numerator", "model.the_tuva_project.quality_measures__int_adhras_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_adhras_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_adhras_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_adhras_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adhras_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras_numerator"], "alias": "_int_adhras_numerator", "checksum": {"name": "sha256", "checksum": "5de38c0fa6032d7975dc02b7dbffaa588c30972230a0eff802b7134ebccf0450"}, "config": {"enabled": true, "alias": "_int_adhras_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of ADH-RAS, Medication Adherence for Hypertension\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adherence": {"name": "adherence", "description": "The extent to which a person's behaviour corresponds with taking a medicine optimally.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2194102, "relation_name": "dev_thuxuan.quality_measures._int_adhras_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , first_dispensing_date\r\n , days_supply\r\n , ndc_code\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_adhras_denominator') }}\r\n\r\n)\r\n\r\n, performance_end as (\r\n\r\n select\r\n performance_period_end\r\n from {{ ref('quality_measures__int_adhras__performance_period') }}\r\n\r\n)\r\n\r\n/*\r\nThe below 3 cte identifies periods of continuous medication use for each patient by:\r\n1. Assigning a row number and tracking the previous medication per patient.\r\n2. Flagging when a medication change occurs.\r\n3. Grouping consecutive periods of the same medication by assigning a group ID.\r\n*/\r\n\r\n, ranked_patient as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\r\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\r\n from denominator\r\n\r\n)\r\n\r\n, grouped_meds as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , dense_rank\r\n , case\r\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\r\n else 0\r\n end as med_change_flag --to increment group when medication changes\r\n from ranked_patient\r\n\r\n)\r\n\r\n, final_groups as (\r\n\r\n select\r\n patient_id\r\n , ndc_code\r\n , dispensing_date\r\n , days_supply\r\n , sum(med_change_flag) over (\r\n partition by patient_id \r\n order by dense_rank \r\n rows between unbounded preceding and current row\r\n ) as group_id\r\n from grouped_meds\r\n\r\n)\r\n\r\n/*\r\nThis cte theoretical_end_dates to final_fills calculates adjusted medication fill dates, \r\ngroups fills by continuous periods of use and ensures accurate start and end dates based \r\non previous fills and the performance period.\r\n*/\r\n\r\n, theoretical_end_dates as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = -1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"days_supply\"\r\n , from_date_or_timestamp = \"dispensing_date\"\r\n )\r\n ) }} as theoretical_end_date\r\n from final_groups\r\n\r\n)\r\n\r\n/* \r\nAdjust start dates based on the previous fill's end date + 1,\r\nor use the current rx_fill_date \r\n*/\r\n\r\n, previous_fill_end_dates as (\r\n \r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , theoretical_end_date\r\n , lag(theoretical_end_date)\r\n over (partition by \r\n patient_id\r\n , group_id \r\n order by\r\n dispensing_date\r\n ) as previous_fill_end_date\r\n from theoretical_end_dates\r\n\r\n)\r\n\r\n, adjusted_fill_dates as (\r\n \r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , theoretical_end_date\r\n , coalesce(\r\n greatest(\r\n dispensing_date\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp = \"previous_fill_end_date\"\r\n ) }}\r\n )\r\n , dispensing_date\r\n ) as adjusted_fill_date\r\n from previous_fill_end_dates\r\n\r\n)\r\n\r\n\r\n, actual_end_dates as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , adjusted_fill_date\r\n , least(\r\n {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = -1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"days_supply\"\r\n , from_date_or_timestamp = \"adjusted_fill_date\"\r\n )\r\n ) }}\r\n , performance_period_end\r\n ) as actual_end_date\r\n from adjusted_fill_dates\r\n inner join performance_end\r\n on adjusted_fill_dates.adjusted_fill_date <= performance_end.performance_period_end\r\n\r\n)\r\n\r\n, grouped_fill_ranges as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , adjusted_fill_date\r\n , actual_end_date\r\n , min(adjusted_fill_date) over(partition by patient_id, group_id) as group_first\r\n , max(adjusted_fill_date) over(partition by patient_id, group_id) as group_last\r\n from actual_end_dates\r\n\r\n)\r\n\r\n, final_fills as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , adjusted_fill_date\r\n , actual_end_date\r\n , group_first\r\n , group_last\r\n , max(\r\n case\r\n when adjusted_fill_date = group_last\r\n then days_supply\r\n else 0\r\n end) over (partition by patient_id, group_id) as group_last_days_supply\r\n from grouped_fill_ranges\r\n\r\n)\r\n\r\n/*\r\n1. Calculates the total covered days per every medication group per patient\r\n2. Then, calculates the overlap between groups of medication per patient.\r\n3. Then, calculates the actual total covered days for each patient.\r\n*/\r\n\r\n, covered_days_per_groups as (\r\n \r\n select\r\n patient_id\r\n , group_id\r\n , group_first\r\n , group_last\r\n , group_last_days_supply\r\n , sum( 1 + {{ dbt.datediff (\r\n datepart = 'day'\r\n , first_date = 'adjusted_fill_date'\r\n , second_date = 'actual_end_date'\r\n )\r\n }} ) as covered_days_per_group\r\n from final_fills\r\n group by \r\n patient_id\r\n , group_id\r\n , group_first\r\n , group_last\r\n , group_last_days_supply\r\n\r\n)\r\n\r\n, with_lag as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , group_first\r\n , group_last\r\n , covered_days_per_group\r\n , lag(group_last) over(partition by patient_id order by group_first) as lag_date\r\n , lag(group_last_days_supply) over(partition by patient_id order by group_first) as lag_days_supply\r\n from covered_days_per_groups\r\n\r\n)\r\n\r\n, overlap_days as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , group_first\r\n , group_last\r\n , covered_days_per_group\r\n , lag_date\r\n , case\r\n when group_first < \r\n {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"lag_days_supply\"\r\n , from_date_or_timestamp = \"lag_date\" \r\n ) }}\r\n then\r\n {{ dbt.datediff (\r\n datepart = 'day'\r\n , first_date = \"group_first\"\r\n , second_date = \r\n dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"lag_days_supply\"\r\n , from_date_or_timestamp = \"lag_date\" \r\n )\r\n ) }}\r\n else 0\r\n end as overlap\r\n from with_lag\r\n\r\n)\r\n\r\n\r\n, final_covered_days as (\r\n\r\n select \r\n patient_id\r\n , sum(covered_days_per_group) - sum(overlap) as actual_covered_days\r\n from overlap_days\r\n group by patient_id\r\n\r\n)\r\n\r\n, patient_with_treatment_period_days as (\r\n select\r\n patient_id\r\n , {{ datediff('first_dispensing_date', 'performance_period_end', 'day') }} as treatment_period_days\r\n from denominator\r\n\r\n)\r\n\r\n, patient_with_pdc as (\r\n\r\n select\r\n final_covered_days.patient_id\r\n , round(cast(actual_covered_days * 100 / treatment_period_days as {{ dbt.type_numeric() }}), 4) as adherence\r\n from final_covered_days\r\n inner join patient_with_treatment_period_days \r\n on final_covered_days.patient_id = patient_with_treatment_period_days.patient_id\r\n\r\n)\r\n\r\n/*\r\nSelects only the patient whose pdc is greater than 80%.\r\n*/\r\n\r\n, valid_patients as (\r\n\r\n select \r\n patient_with_pdc.patient_id\r\n , adherence\r\n , denominator.dispensing_date as evidence_date\r\n , denominator.days_supply as evidence_value\r\n , 1 as numerator_flag\r\n from patient_with_pdc \r\n inner join denominator\r\n on patient_with_pdc.patient_id = denominator.patient_id \r\n where patient_with_pdc.adherence >= 80.00 \r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(adherence as {{ dbt.type_numeric() }}) as adherence\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from valid_patients\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n , adherence\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adhras_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adhras__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.datediff", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras_numerator.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_adhras_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n/*\nThe below 3 cte identifies periods of continuous medication use for each patient by:\n1. Assigning a row number and tracking the previous medication per patient.\n2. Flagging when a medication change occurs.\n3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dense_rank \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\nThis cte theoretical_end_dates to final_fills calculates adjusted medication fill dates, \ngroups fills by continuous periods of use and ensures accurate start and end dates based \non previous fills and the performance period.\n*/\n\n, theoretical_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n/* \nAdjust start dates based on the previous fill's end date + 1,\nor use the current rx_fill_date \n*/\n\n, previous_fill_end_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_fill_end_date\n from theoretical_end_dates\n\n)\n\n, adjusted_fill_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_fill_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_fill_date\n from previous_fill_end_dates\n\n)\n\n\n, actual_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_fill_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as actual_end_date\n from adjusted_fill_dates\n inner join performance_end\n on adjusted_fill_dates.adjusted_fill_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , min(adjusted_fill_date) over(partition by patient_id, group_id) as group_first\n , max(adjusted_fill_date) over(partition by patient_id, group_id) as group_last\n from actual_end_dates\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , group_first\n , group_last\n , max(\n case\n when adjusted_fill_date = group_last\n then days_supply\n else 0\n end) over (partition by patient_id, group_id) as group_last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n1. Calculates the total covered days per every medication group per patient\n2. Then, calculates the overlap between groups of medication per patient.\n3. Then, calculates the actual total covered days for each patient.\n*/\n\n, covered_days_per_groups as (\n \n select\n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_fill_date,\n actual_end_date\n ) ) as covered_days_per_group\n from final_fills\n group by \n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n\n)\n\n, with_lag as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag(group_last) over(partition by patient_id order by group_first) as lag_date\n , lag(group_last_days_supply) over(partition by patient_id order by group_first) as lag_days_supply\n from covered_days_per_groups\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag_date\n , case\n when group_first < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n group_first,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from with_lag\n\n)\n\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days_per_group) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, patient_with_treatment_period_days as (\n select\n patient_id\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as treatment_period_days\n from denominator\n\n)\n\n, patient_with_pdc as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days * 100 / treatment_period_days as numeric(28,6)), 4) as adherence\n from final_covered_days\n inner join patient_with_treatment_period_days \n on final_covered_days.patient_id = patient_with_treatment_period_days.patient_id\n\n)\n\n/*\nSelects only the patient whose pdc is greater than 80%.\n*/\n\n, valid_patients as (\n\n select \n patient_with_pdc.patient_id\n , adherence\n , denominator.dispensing_date as evidence_date\n , denominator.days_supply as evidence_value\n , 1 as numerator_flag\n from patient_with_pdc \n inner join denominator\n on patient_with_pdc.patient_id = denominator.patient_id \n where patient_with_pdc.adherence >= 80.00 \n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from valid_patients\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adhras__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adhras__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adhras__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh-ras_medication_adherence_for_hypertension", "quality_measures__int_adhras__performance_period"], "alias": "_int_adhras__performance_period", "checksum": {"name": "sha256", "checksum": "fd981736702b8c0c1a83f9b07cff58a3561604027f93f73eda96bac12671a59b"}, "config": {"enabled": true, "alias": "_int_adhras__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Medication Adherence for Hypertension\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adhras__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2050176, "relation_name": "dev_thuxuan.quality_measures._int_adhras__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n\r\n(\r\n select id\r\n from {{ ref('quality_measures__measures') }}\r\n where id = 'ADH-RAS'\r\n)\r\n\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n\r\n(\r\n select name\r\n from {{ ref('quality_measures__measures') }}\r\n where id = 'ADH-RAS'\r\n)\r\n\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n\r\n(\r\n select version\r\n from {{ ref('quality_measures__measures') }}\r\n where id = 'ADH-RAS'\r\n)\r\n\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n\r\n)\r\n\r\n/*\r\n set performance period begin to following day of 1 year prior\r\n*/\r\n\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh-ras_medication_adherence_for_hypertension\\quality_measures__int_adhras__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((\n select id\n from dev_thuxuan.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_id\n , cast((\n select name\n from dev_thuxuan.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_name\n , cast((\n select version\n from dev_thuxuan.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_denominator"], "alias": "_int_adh_diabetes_denominator", "checksum": {"name": "sha256", "checksum": "e0a694c5aa58e82b3f770a1a42f47a359cdd8008818f7e7141637087f1b45a7d"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during latest encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "Date the prescription was filled.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "National drug code on the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "Number of days the filled medication lasts for.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_in_treatment_period": {"name": "days_in_treatment_period", "description": "Number of days from first dispensing_date to performance_period_end in the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1960173, "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith diabetics_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'pqa diabetes medications'\r\n )\r\n\r\n)\r\n\r\n, rx_diabetes as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claims\r\n inner join diabetics_codes\r\n on pharmacy_claims.ndc_code = diabetics_codes.code\r\n and lower(diabetics_codes.code_system) = 'ndc'\r\n\r\n)\r\n\r\n, rx_diabetes_in_measurement_period as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , performance_period_end -- to use in latter cte for days in treatment period calculation\r\n from rx_diabetes\r\n inner join {{ ref('quality_measures__int_adh_diabetes__performance_period') }} pp\r\n on dispensing_date between pp.performance_period_begin and pp.performance_period_end\r\n\r\n)\r\n\r\n/* \r\n These patients need to pass two checks\r\n - First medication fill date should be at least 91 days before the end of measurement period\r\n - Should have at least two distinct Date of Service (FillDate) for rx\r\n*/\r\n\r\n, rx_fill_order as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , performance_period_end\r\n , dense_rank() over (\r\n partition by \r\n patient_id\r\n , performance_period_end\r\n order by dispensing_date\r\n ) as dr\r\n from rx_diabetes_in_measurement_period\r\n\r\n)\r\n\r\n, rx_first_fill as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , performance_period_end\r\n from rx_fill_order\r\n where dr = 1\r\n \r\n)\r\n\r\n, timely_fill_check as (\r\n\r\n select\r\n patient_id\r\n , ( 1 + {{ dbt.datediff (\r\n datepart = 'day'\r\n , first_date = 'dispensing_date'\r\n , second_date = 'performance_period_end'\r\n )\r\n }} )\r\n as days_in_treatment_period\r\n /* \r\n Performance Period end minus dispensing date results in \r\n second_date non-inclusive difference, so to include both of these days\r\n 1 day is added\r\n */\r\n from rx_first_fill\r\n\r\n)\r\n\r\n, first_check_passed_patients as (\r\n\r\n select\r\n patient_id\r\n , days_in_treatment_period\r\n from timely_fill_check\r\n where days_in_treatment_period > 90\r\n\r\n)\r\n\r\n, second_check_passed_patients as (\r\n\r\n select\r\n patient_id\r\n from rx_fill_order\r\n where dr = 2\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n first_check_passed_patients.patient_id\r\n , first_check_passed_patients.days_in_treatment_period\r\n from first_check_passed_patients\r\n inner join second_check_passed_patients\r\n on first_check_passed_patients.patient_id = second_check_passed_patients.patient_id \r\n\r\n)\r\n\r\n, qualifying_patients_with_age as (\r\n \r\n select\r\n patients.patient_id\r\n , floor({{ datediff('birth_date', 'pp.performance_period_begin', 'hour') }} / 8760.0) as age\r\n , days_in_treatment_period\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__stg_core__patient') }} patients\r\n inner join qualifying_patients\r\n on patients.patient_id = qualifying_patients.patient_id\r\n cross join {{ ref('quality_measures__int_adh_diabetes__performance_period') }} pp\r\n where patients.death_date is null\r\n\r\n)\r\n/*\r\n Extracting related fields like dispensing_date, ndc_code and days_supply of qualified patients\r\n to avoid redundant computations in numerator model\r\n*/\r\n\r\n, qualifying_patients_all_claim_info as (\r\n\r\n select\r\n qualifying_patients_with_age.patient_id\r\n , qualifying_patients_with_age.age\r\n , rx_diabetes_in_measurement_period.dispensing_date\r\n , rx_diabetes_in_measurement_period.ndc_code\r\n , rx_diabetes_in_measurement_period.days_supply\r\n , qualifying_patients_with_age.days_in_treatment_period\r\n , qualifying_patients_with_age.performance_period_begin\r\n , qualifying_patients_with_age.performance_period_end\r\n , qualifying_patients_with_age.measure_id\r\n , qualifying_patients_with_age.measure_name\r\n , qualifying_patients_with_age.measure_version\r\n from qualifying_patients_with_age\r\n inner join rx_diabetes_in_measurement_period\r\n on qualifying_patients_with_age.patient_id = rx_diabetes_in_measurement_period.patient_id\r\n\r\n)\r\n\r\n, denominator as (\r\n\r\n select\r\n patient_id\r\n , age\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , days_in_treatment_period\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , 1 as denominator_flag\r\n from qualifying_patients_all_claim_info\r\n where age >= 18\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(dispensing_date as date) as dispensing_date\r\n , cast(ndc_code as {{ dbt.type_string() }}) as ndc_code\r\n , cast(days_supply as integer) as days_supply\r\n , cast(days_in_treatment_period as integer) as days_in_treatment_period\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from denominator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , age\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , days_in_treatment_period\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), diabetics_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa diabetes medications'\n )\n\n)\n\n, rx_diabetes as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join diabetics_codes\n on pharmacy_claims.ndc_code = diabetics_codes.code\n and lower(diabetics_codes.code_system) = 'ndc'\n\n)\n\n, rx_diabetes_in_measurement_period as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , performance_period_end -- to use in latter cte for days in treatment period calculation\n from rx_diabetes\n inner join dev_thuxuan.quality_measures._int_adh_diabetes__performance_period pp\n on dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, rx_fill_order as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n , dense_rank() over (\n partition by \n patient_id\n , performance_period_end\n order by dispensing_date\n ) as dr\n from rx_diabetes_in_measurement_period\n\n)\n\n, rx_first_fill as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n from rx_fill_order\n where dr = 1\n \n)\n\n, timely_fill_check as (\n\n select\n patient_id\n , ( 1 + datediff(\n day,\n dispensing_date,\n performance_period_end\n ) )\n as days_in_treatment_period\n /* \n Performance Period end minus dispensing date results in \n second_date non-inclusive difference, so to include both of these days\n 1 day is added\n */\n from rx_first_fill\n\n)\n\n, first_check_passed_patients as (\n\n select\n patient_id\n , days_in_treatment_period\n from timely_fill_check\n where days_in_treatment_period > 90\n\n)\n\n, second_check_passed_patients as (\n\n select\n patient_id\n from rx_fill_order\n where dr = 2\n\n)\n\n, qualifying_patients as (\n\n select\n first_check_passed_patients.patient_id\n , first_check_passed_patients.days_in_treatment_period\n from first_check_passed_patients\n inner join second_check_passed_patients\n on first_check_passed_patients.patient_id = second_check_passed_patients.patient_id \n\n)\n\n, qualifying_patients_with_age as (\n \n select\n patients.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from __dbt__cte___stg_patient patients\n inner join qualifying_patients\n on patients.patient_id = qualifying_patients.patient_id\n cross join dev_thuxuan.quality_measures._int_adh_diabetes__performance_period pp\n where patients.death_date is null\n\n)\n/*\n Extracting related fields like dispensing_date, ndc_code and days_supply of qualified patients\n to avoid redundant computations in numerator model\n*/\n\n, qualifying_patients_all_claim_info as (\n\n select\n qualifying_patients_with_age.patient_id\n , qualifying_patients_with_age.age\n , rx_diabetes_in_measurement_period.dispensing_date\n , rx_diabetes_in_measurement_period.ndc_code\n , rx_diabetes_in_measurement_period.days_supply\n , qualifying_patients_with_age.days_in_treatment_period\n , qualifying_patients_with_age.performance_period_begin\n , qualifying_patients_with_age.performance_period_end\n , qualifying_patients_with_age.measure_id\n , qualifying_patients_with_age.measure_name\n , qualifying_patients_with_age.measure_version\n from qualifying_patients_with_age\n inner join rx_diabetes_in_measurement_period\n on qualifying_patients_with_age.patient_id = rx_diabetes_in_measurement_period.patient_id\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from qualifying_patients_all_claim_info\n where age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(dispensing_date as date) as dispensing_date\n , cast(ndc_code as TEXT) as ndc_code\n , cast(days_supply as integer) as days_supply\n , cast(days_in_treatment_period as integer) as days_in_treatment_period\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from denominator\n\n)\n\nselect\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_exclusions"], "alias": "_int_adh_diabetes_exclusions", "checksum": {"name": "sha256", "checksum": "3eba3fd2ca2612c36fa330fe2ab07212bf61cbdb4d8064a05471ca72f57a4c8f"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1980176, "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_adh_diabetes__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_adh_diabetes__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith denominator as (\r\n \r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_adh_diabetes_denominator') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'pqa esrd'\r\n , 'pqa insulin medications'\r\n )\r\n\r\n)\r\n\r\n, hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_hospice as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from hospice_palliative\r\n where lower(exclusion_reason) in (\r\n 'hospice encounter'\r\n , 'hospice care ambulatory'\r\n , 'hospice diagnosis'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , claim_id\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n where recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date as exclusion_date\r\n , exclusion_codes.concept_name as exclusion_reason\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, pharmacy_exclusions as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claims\r\n inner join exclusion_codes\r\n on pharmacy_claims.ndc_code = exclusion_codes.code\r\n and exclusion_codes.code_system = 'ndc'\r\n\r\n)\r\n\r\n, exclusion_patients as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from valid_hospice\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from condition_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from pharmacy_exclusions\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select\r\n exclusion_patients.patient_id\r\n , exclusion_patients.exclusion_date\r\n , exclusion_patients.exclusion_reason\r\n from exclusion_patients\r\n inner join denominator\r\n on exclusion_patients.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from combined_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa esrd'\n , 'pqa insulin medications'\n )\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as exclusion_date\n , exclusion_codes.concept_name as exclusion_reason\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_exclusions as (\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and exclusion_codes.code_system = 'ndc'\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from pharmacy_exclusions\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_long"], "alias": "_int_adh_diabetes_long", "checksum": {"name": "sha256", "checksum": "5ac4b98e0589227241ccadbc924f6e7c8448bf3397810a2929dd74fdbd2bada4"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2010171, "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_adh_diabetes_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_adh_diabetes_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_adh_diabetes_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adh_diabetes_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_numerator", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_adh_diabetes_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_adh_diabetes_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes_numerator"], "alias": "_int_adh_diabetes_numerator", "checksum": {"name": "sha256", "checksum": "0a876fd575aa49cd81441a37161696e45f2335d591d637031ccaac51a426c549"}, "config": {"enabled": true, "alias": "_int_adh_diabetes_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of ADH-Diabetes, Medication Adherence for Diabetes Medications.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "adherence": {"name": "adherence", "description": "The degree to which the person behaviour corresponds with taking a medicine optimally in percentage.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2030175, "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , days_in_treatment_period\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_adh_diabetes_denominator') }}\r\n\r\n)\r\n\r\n, performance_end as (\r\n\r\n select\r\n performance_period_end\r\n from {{ ref('quality_measures__int_adh_diabetes__performance_period') }}\r\n\r\n)\r\n\r\n/*\r\n The below 3 cte identifies periods of continuous medication use for each patient by:\r\n 1. Assigning a row number and tracking the previous medication per patient.\r\n 2. Flagging when a medication change occurs.\r\n 3. Grouping consecutive periods of the same medication by assigning a group ID.\r\n*/\r\n\r\n, ranked_patient as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , dense_rank() over (partition by patient_id order by dispensing_date) as dr\r\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\r\n from denominator\r\n\r\n)\r\n\r\n, grouped_meds as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , dr\r\n , case\r\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\r\n else 0\r\n end as med_change_flag --to increment group when medication changes\r\n from ranked_patient\r\n\r\n)\r\n\r\n, final_groups as (\r\n\r\n select\r\n patient_id\r\n , ndc_code\r\n , dispensing_date\r\n , days_supply\r\n , sum(med_change_flag) over (\r\n partition by patient_id \r\n order by dr \r\n rows between unbounded preceding and current row\r\n ) as group_id\r\n from grouped_meds\r\n\r\n)\r\n\r\n/*\r\n The ctes below calculates adjusted medication fill dates,\r\n groups fills by continuous periods of use and ensures accurate start and end dates based \r\n on previous fills and the performance period.\r\n*/\r\n\r\n, fills as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = -1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"days_supply\"\r\n , from_date_or_timestamp = \"dispensing_date\"\r\n )\r\n ) }} as theoretical_end_date\r\n from final_groups\r\n\r\n)\r\n\r\n, previous_fill_end_date as (\r\n \r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , theoretical_end_date\r\n , lag(theoretical_end_date)\r\n over (partition by \r\n patient_id\r\n , group_id \r\n order by\r\n dispensing_date\r\n ) as previous_end_date\r\n from fills\r\n\r\n)\r\n\r\n, adjusted_fills as (\r\n \r\n /* Adjust start dates based on the previous fill's end date + 1,\r\n or use the current rx_fill_date */\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , theoretical_end_date\r\n , coalesce(\r\n greatest(\r\n dispensing_date\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp = \"previous_end_date\"\r\n ) }}\r\n )\r\n , dispensing_date\r\n ) as adjusted_start_date\r\n from previous_fill_end_date\r\n\r\n)\r\n\r\n, final_fills as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , adjusted_start_date\r\n , least(\r\n {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = -1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"days_supply\"\r\n , from_date_or_timestamp = \"adjusted_start_date\"\r\n )\r\n ) }}\r\n , performance_period_end\r\n ) as final_end_date\r\n from adjusted_fills\r\n inner join performance_end\r\n on adjusted_fills.adjusted_start_date <= performance_end.performance_period_end\r\n\r\n)\r\n\r\n, grouped_fill_ranges as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , adjusted_start_date\r\n , final_end_date\r\n , min(adjusted_start_date) over(partition by patient_id, group_id) as first_disp_date\r\n , max(adjusted_start_date) over(partition by patient_id, group_id) as last_disp_date\r\n from final_fills\r\n\r\n)\r\n\r\n, last_med_end_groupwise as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , dispensing_date\r\n , days_supply\r\n , adjusted_start_date\r\n , final_end_date\r\n , first_disp_date\r\n , last_disp_date\r\n , max(\r\n case\r\n when adjusted_start_date = last_disp_date\r\n then days_supply\r\n else null\r\n end) over (partition by patient_id, group_id) as last_days_supply\r\n from grouped_fill_ranges\r\n\r\n)\r\n\r\n/*\r\n 1. Calculates the total covered days per medication group per patient\r\n 2. Then calculates the overlap between groups of medication per patient\r\n 3. Finally calculates the actual total covered days for each patient\r\n*/\r\n\r\n, covered_days_per_group as (\r\n \r\n select\r\n patient_id\r\n , group_id\r\n , first_disp_date\r\n , last_disp_date\r\n , last_days_supply\r\n , sum( 1 + {{ dbt.datediff (\r\n datepart = 'day'\r\n , first_date = 'adjusted_start_date'\r\n , second_date = 'final_end_date'\r\n )\r\n }} ) as covered_days\r\n from last_med_end_groupwise\r\n group by \r\n patient_id\r\n , group_id\r\n , first_disp_date\r\n , last_disp_date\r\n , last_days_supply\r\n\r\n)\r\n\r\n, final_with_lag as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , first_disp_date\r\n , last_disp_date\r\n , covered_days\r\n , lag(last_disp_date) over(partition by patient_id order by first_disp_date) as lag_date\r\n , lag(last_days_supply) over(partition by patient_id order by first_disp_date) as lag_days_supply\r\n from covered_days_per_group\r\n\r\n)\r\n\r\n, overlap_days as (\r\n\r\n select\r\n patient_id\r\n , group_id\r\n , first_disp_date\r\n , last_disp_date\r\n , covered_days\r\n , lag_date\r\n , case\r\n when first_disp_date < \r\n {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"lag_days_supply\"\r\n , from_date_or_timestamp = \"lag_date\" \r\n ) }}\r\n then\r\n {{ dbt.datediff (\r\n datepart = 'day'\r\n , first_date = \"first_disp_date\"\r\n , second_date = \r\n dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = \"lag_days_supply\"\r\n , from_date_or_timestamp = \"lag_date\" \r\n )\r\n ) }}\r\n else 0\r\n end as overlap\r\n from final_with_lag\r\n\r\n)\r\n\r\n, final_covered_days as (\r\n\r\n select \r\n patient_id\r\n , sum(covered_days) - sum(overlap) as actual_covered_days\r\n from overlap_days\r\n group by patient_id\r\n\r\n)\r\n\r\n, relevant_patients_from_deno as (\r\n\r\n select\r\n final_covered_days.patient_id\r\n , round(cast(actual_covered_days / days_in_treatment_period as {{ dbt.type_numeric() }}), 4) as adherence\r\n , dispensing_date as evidence_date\r\n , days_supply as evidence_value\r\n from final_covered_days\r\n inner join denominator\r\n on final_covered_days.patient_id = denominator.patient_id\r\n \r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , adherence * 100 as adherence --percent conversion\r\n , evidence_date\r\n , evidence_value\r\n , 1 as numerator_flag\r\n from relevant_patients_from_deno\r\n where adherence >= 0.8\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(adherence as {{ dbt.type_numeric() }}) as adherence\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from numerator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n , adherence\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_adh_diabetes_denominator", "package": null, "version": null}, {"name": "quality_measures__int_adh_diabetes__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.datediff", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes_numerator.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n/*\n The below 3 cte identifies periods of continuous medication use for each patient by:\n 1. Assigning a row number and tracking the previous medication per patient.\n 2. Flagging when a medication change occurs.\n 3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dr\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dr\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dr \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\n The ctes below calculates adjusted medication fill dates,\n groups fills by continuous periods of use and ensures accurate start and end dates based \n on previous fills and the performance period.\n*/\n\n, fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n, previous_fill_end_date as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_end_date\n from fills\n\n)\n\n, adjusted_fills as (\n \n /* Adjust start dates based on the previous fill's end date + 1,\n or use the current rx_fill_date */\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_start_date\n from previous_fill_end_date\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_start_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as final_end_date\n from adjusted_fills\n inner join performance_end\n on adjusted_fills.adjusted_start_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , min(adjusted_start_date) over(partition by patient_id, group_id) as first_disp_date\n , max(adjusted_start_date) over(partition by patient_id, group_id) as last_disp_date\n from final_fills\n\n)\n\n, last_med_end_groupwise as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , first_disp_date\n , last_disp_date\n , max(\n case\n when adjusted_start_date = last_disp_date\n then days_supply\n else null\n end) over (partition by patient_id, group_id) as last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n 1. Calculates the total covered days per medication group per patient\n 2. Then calculates the overlap between groups of medication per patient\n 3. Finally calculates the actual total covered days for each patient\n*/\n\n, covered_days_per_group as (\n \n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_start_date,\n final_end_date\n ) ) as covered_days\n from last_med_end_groupwise\n group by \n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n\n)\n\n, final_with_lag as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag(last_disp_date) over(partition by patient_id order by first_disp_date) as lag_date\n , lag(last_days_supply) over(partition by patient_id order by first_disp_date) as lag_days_supply\n from covered_days_per_group\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag_date\n , case\n when first_disp_date < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n first_disp_date,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from final_with_lag\n\n)\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, relevant_patients_from_deno as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days / days_in_treatment_period as numeric(28,6)), 4) as adherence\n , dispensing_date as evidence_date\n , days_supply as evidence_value\n from final_covered_days\n inner join denominator\n on final_covered_days.patient_id = denominator.patient_id\n \n)\n\n, numerator as (\n\n select\n patient_id\n , adherence * 100 as adherence --percent conversion\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from relevant_patients_from_deno\n where adherence >= 0.8\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_adh_diabetes__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "adh_diabetes", "quality_measures__int_adh_diabetes__performance_period"], "alias": "_int_adh_diabetes__performance_period", "checksum": {"name": "sha256", "checksum": "e45697adc02c4046adb2cc97313ce9ba884818f3f6d6bafd91e56f75e26b272b"}, "config": {"enabled": true, "alias": "_int_adh_diabetes__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Medication Adherence for Diabetes Medications.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_adh_diabetes__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1930172, "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'ADH-Diabetes')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'ADH-Diabetes')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'ADH-Diabetes')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\adh_diabetes\\quality_measures__int_adh_diabetes__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_denominator"], "alias": "_int_cbe0055_denominator", "checksum": {"name": "sha256", "checksum": "aae855e419f5cafabd2578935de01ce97f1506fe00bad7d372a8e8f9a5043b14"}, "config": {"enabled": true, "alias": "_int_cbe0055_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Diabetes: Eye Exam\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0864408, "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'office visit'\r\n , 'home healthcare services'\r\n , 'preventive care services established office visit, 18 and up' \r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'annual wellness visit'\r\n , 'telephone visits'\r\n , 'outpatient'\r\n , 'observation'\r\n , 'diabetes visit'\r\n , 'ophthalmological services'\r\n , 'diabetic retinopathy'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ref('quality_measures__stg_core__encounter')}} encounter\r\n inner join {{ref('quality_measures__int_cbe0055__performance_period')}} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ref('quality_measures__stg_core__procedure')}} procs\r\n inner join {{ref('quality_measures__int_cbe0055__performance_period')}} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\r\n inner join {{ref('quality_measures__int_cbe0055__performance_period')}} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code= visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id,min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, diabetics_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'diabetes'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition')}}\r\n\r\n)\r\n\r\n, diabetic_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.encounter_id\r\n , conditions.recorded_date\r\n , conditions.source_code\r\n , conditions.source_code_type\r\n from conditions\r\n inner join diabetics_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\r\n , max_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\r\n , qualifying_types\r\n from {{ref('quality_measures__stg_core__patient')}} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n diabetic_conditions.patient_id\r\n , patients_with_age.max_age as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from diabetic_conditions\r\n left join patients_with_age\r\n on diabetic_conditions.patient_id = patients_with_age.patient_id\r\n cross join {{ref('quality_measures__int_cbe0055__performance_period')}} pp\r\n where max_age >= 18 and min_age <= 75\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up' \n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'outpatient'\n , 'observation'\n , 'diabetes visit'\n , 'ophthalmological services'\n , 'diabetic retinopathy'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_cbe0055__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_exclusions"], "alias": "_int_cbe0055_exclusions", "checksum": {"name": "sha256", "checksum": "11abd5d748ded05dae6277431ba69cc631ea0af6de880e6735dfff3caf3bba91"}, "config": {"enabled": true, "alias": "_int_cbe0055_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CBE 0055, Diabetes: Eye Exam.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.091441, "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_cbe0055__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_cbe0055__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith frailty as (\r\n\r\n select\r\n *\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_institutional_snp as (\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_dementia_exclusions as (\r\n\r\n select\r\n source.patient_id\r\n , source.exclusion_date\r\n , source.exclusion_reason\r\n , source.exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where (\r\n source.dispensing_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n or source.paid_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n )\r\n\r\n)\r\n\r\n-- advanced illness start\r\n, advanced_illness_exclusion as (\r\n\r\n select\r\n source.*\r\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where source.exclusion_date\r\n between\r\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\r\n and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, acute_inpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'acute_inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'nonacute_outpatient'\r\n\r\n)\r\n\r\n, acute_inpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from acute_inpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, nonacute_outpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from nonacute_outpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, valid_advanced_illness_exclusions as (\r\n\r\n select\r\n acute_inpatient_advanced_illness.patient_id\r\n , acute_inpatient_advanced_illness.exclusion_date\r\n , acute_inpatient_advanced_illness.exclusion_reason\r\n , acute_inpatient_advanced_illness.exclusion_type\r\n from acute_inpatient_advanced_illness\r\n left join acute_inpatient_counts\r\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\r\n where acute_inpatient_counts.encounter_count >= 1\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient_advanced_illness.patient_id\r\n , nonacute_outpatient_advanced_illness.exclusion_date\r\n , nonacute_outpatient_advanced_illness.exclusion_reason\r\n , nonacute_outpatient_advanced_illness.exclusion_type\r\n from nonacute_outpatient_advanced_illness\r\n left join nonacute_outpatient_counts\r\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\r\n where nonacute_outpatient_counts.encounter_count >= 2\r\n\r\n\r\n)\r\n-- advanced illness end\r\n\r\n, exclusions as (\r\n\r\n select * from valid_advanced_illness_exclusions\r\n union all\r\n select * from valid_dementia_exclusions\r\n union all\r\n select * from valid_hospice_palliative\r\n union all\r\n select * from valid_institutional_snp\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select \r\n exclusions.*\r\n , denominator.age\r\n from exclusions\r\n inner join {{ref('quality_measures__int_cbe0055_denominator')}} as denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type != 'hospice_palliative'\r\n and age >= 66\r\n\r\n union all\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type = 'hospice_palliative'\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_cbe0055_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join dev_thuxuan.quality_measures._int_cbe0055_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_long"], "alias": "_int_cbe0055_long", "checksum": {"name": "sha256", "checksum": "1ae26f331d905e1b3199e150b5311c5818ace569b05d4bc17ce1a0e9ecc64bbc"}, "config": {"enabled": true, "alias": "_int_cbe0055_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CBE 0055, Diabetes: Eye Exam before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0944488, "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_cbe0055_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_cbe0055_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_cbe0055_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0055_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cbe0055_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cbe0055_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cbe0055_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0055_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055_numerator"], "alias": "_int_cbe0055_numerator", "checksum": {"name": "sha256", "checksum": "08a3778b13681b6d02277a36205b36bf8cf03f657114713508fce06f0853ab9d"}, "config": {"enabled": true, "alias": "_int_cbe0055_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CBE 0055, Diabetes: Eye Exam\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0894406, "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_cbe0055_denominator') }}\r\n\r\n)\r\n\r\n, retina_test_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ref('quality_measures__value_sets')}}\r\n where lower(concept_name) in (\r\n 'diabetic retinal eye exam met'\r\n , 'retinal or dilated eye exam'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select \r\n procedures.patient_id\r\n , procedures.procedure_date as evidence_date\r\n from procedures\r\n inner join {{ ref('quality_measures__int_cbe0055__performance_period') }} pp\r\n on procedure_date between\r\n performance_period_begin and performance_period_end\r\n inner join retina_test_code\r\n on procedures.code = retina_test_code.code\r\n and procedures.code_type = retina_test_code.code_system\r\n\r\n)\r\n\r\n, qualifying_patients_with_denominator as (\r\n\r\n select \r\n qualifying_patients.patient_id\r\n , qualifying_patients.evidence_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , cast('1' as integer) as numerator_flag\r\n from qualifying_patients\r\n inner join denominator\r\n on qualifying_patients.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from qualifying_patients_with_denominator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0055_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cbe0055__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__int_cbe0055__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cbe0055_denominator\n\n)\n\n, retina_test_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetic retinal eye exam met'\n , 'retinal or dilated eye exam'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_patients as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period pp\n on procedure_date between\n performance_period_begin and performance_period_end\n inner join retina_test_code\n on procedures.code = retina_test_code.code\n and procedures.code_type = retina_test_code.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast('1' as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0055__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0055_diabetes_eye_exam", "quality_measures__int_cbe0055__performance_period"], "alias": "_int_cbe0055__performance_period", "checksum": {"name": "sha256", "checksum": "451e6bbd1496ff25cdefb64c1e8bec8c36db0fc0d2a595b51a223244213482e5"}, "config": {"enabled": true, "alias": "_int_cbe0055__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Diabetes: Eye Exam\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0055__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0844402, "relation_name": "dev_thuxuan.quality_measures._int_cbe0055__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0055')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0055')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0055')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0055_diabetes_eye_exam\\quality_measures__int_cbe0055__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_denominator"], "alias": "_int_cbe0101_denominator", "checksum": {"name": "sha256", "checksum": "957878497b81b265f6a35d4999eac5a086020ece2d53ef3670b362f033fe3829"}, "config": {"enabled": true, "alias": "_int_cbe0101_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Falls: Plan of Care.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_date": {"name": "encounter_date", "description": "Patient's date of encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.145956, "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'annual wellness visit'\r\n , 'audiology visit'\r\n , 'home healthcare services'\r\n , 'nursing facility visit'\r\n , 'occupational therapy evaluation'\r\n , 'office visit'\r\n , 'physical therapy evaluation'\r\n , 'online assessments'\r\n , 'telephone visits' \r\n , 'care services in long term residential facility'\r\n , 'discharge services nursing facility'\r\n , 'encounter inpatient'\r\n , 'ophthalmological services'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services individual counseling'\r\n , 'preventive care services initial office visit, 18 and up'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n \r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from procedures\r\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on procedures.code = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from medical_claim\r\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} as pp \r\n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code = visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id, min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n , coalesce(min(proc_enc),''))\r\n , coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as age\r\n , max_date\r\n , qualifying_types\r\n from {{ ref('quality_measures__stg_core__patient') }} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, falls_screening_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where code = '1100F'\r\n /* \r\n Patient screened for future fall risk; documentation of two or more falls in the past year \r\n or any fall with injury in the past year\r\n */\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date as evidence_date\r\n from procedures\r\n inner join falls_screening_code\r\n on procedures.code = falls_screening_code.code\r\n and procedures.code_type = falls_screening_code.code_system\r\n \r\n)\r\n\r\n, qualifying_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(claim_end_date, claim_start_date) as evidence_date\r\n from medical_claim\r\n inner join falls_screening_code\r\n on medical_claim.hcpcs_code = falls_screening_code.code\r\n and lower(falls_screening_code.code_system) = 'hcpcs'\r\n\r\n)\r\n\r\n, qualifying_cares as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_procedures\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_claims\r\n\r\n)\r\n\r\n, qualifying_cares_past_year as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n from qualifying_cares\r\n inner join {{ ref('quality_measures__int_cbe0101__performance_period') }} pp\r\n on evidence_date between pp.performance_period_begin and pp.performance_period_end \r\n /* \r\n code 1100F is reported if there are two or more falls in the last year itself,\r\n so if it's reported in performance year, it indicates the falls in the last year\r\n */\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n qualifying_cares_past_year.patient_id\r\n , patients_with_age.age\r\n , max_date as encounter_date\r\n , qualifying_cares_past_year.performance_period_begin\r\n , qualifying_cares_past_year.performance_period_end\r\n , qualifying_cares_past_year.measure_id\r\n , qualifying_cares_past_year.measure_name\r\n , qualifying_cares_past_year.measure_version\r\n , 1 as denominator_flag\r\n from qualifying_cares_past_year\r\n left join patients_with_age\r\n on qualifying_cares_past_year.patient_id = patients_with_age.patient_id\r\n where age >= 65\r\n\r\n)\r\n\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(encounter_date as date) as encounter_date\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'audiology visit'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'occupational therapy evaluation'\n , 'office visit'\n , 'physical therapy evaluation'\n , 'online assessments'\n , 'telephone visits' \n , 'care services in long term residential facility'\n , 'discharge services nursing facility'\n , 'encounter inpatient'\n , 'ophthalmological services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, falls_screening_code as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where code = '1100F'\n /* \n Patient screened for future fall risk; documentation of two or more falls in the past year \n or any fall with injury in the past year\n */\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join falls_screening_code\n on procedures.code = falls_screening_code.code\n and procedures.code_type = falls_screening_code.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from medical_claim\n inner join falls_screening_code\n on medical_claim.hcpcs_code = falls_screening_code.code\n and lower(falls_screening_code.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, qualifying_cares_past_year as (\n\n select\n patient_id\n , evidence_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from qualifying_cares\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period pp\n on evidence_date between pp.performance_period_begin and pp.performance_period_end \n /* \n code 1100F is reported if there are two or more falls in the last year itself,\n so if it's reported in performance year, it indicates the falls in the last year\n */\n\n)\n\n, qualifying_patients as (\n\n select\n qualifying_cares_past_year.patient_id\n , patients_with_age.age\n , max_date as encounter_date\n , qualifying_cares_past_year.performance_period_begin\n , qualifying_cares_past_year.performance_period_end\n , qualifying_cares_past_year.measure_id\n , qualifying_cares_past_year.measure_name\n , qualifying_cares_past_year.measure_version\n , 1 as denominator_flag\n from qualifying_cares_past_year\n left join patients_with_age\n on qualifying_cares_past_year.patient_id = patients_with_age.patient_id\n where age >= 65\n\n)\n\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_exclusions"], "alias": "_int_cbe0101_exclusions", "checksum": {"name": "sha256", "checksum": "576cf5de92c8360e4a0c57bdfe05e1589c5d9ea9571e7794b71fda2c7c8dc8bc"}, "config": {"enabled": true, "alias": "_int_cbe0101_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CBE 0101, Falls: Plan of Care.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.147956, "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_cbe0101__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_cbe0101__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith denominator as (\r\n \r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_cbe0101_denominator') }}\r\n\r\n)\r\n\r\n, exclusion_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where code = '0518F'\r\n -- further 1P modifier are only excluded\r\n)\r\n\r\n, hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_hospice as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from hospice_palliative\r\n where lower(exclusion_reason) in (\r\n 'hospice encounter'\r\n , 'hospice care ambulatory'\r\n , 'hospice diagnosis'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n , modifier_1\r\n , modifier_2\r\n , modifier_3\r\n , modifier_4\r\n , modifier_5\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, exclusion_procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date as exclusion_date\r\n , 'Limited Mobility' as exclusion_reason\r\n from procedures\r\n inner join exclusion_code\r\n on procedures.code = exclusion_code.code\r\n and procedures.code_type = exclusion_code.code_system\r\n where '1P' in (modifier_1, modifier_2, modifier_3, modifier_4, modifier_5)\r\n \r\n)\r\n\r\n, exclusion_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\r\n , 'Limited mobility' as exclusion_reason\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join exclusion_code\r\n on medical_claim.hcpcs_code = exclusion_code.code\r\n and lower(exclusion_code.code_system) = 'hcpcs'\r\n where '1P' in (hcpcs_modifier_1, hcpcs_modifier_2, hcpcs_modifier_3, hcpcs_modifier_4, hcpcs_modifier_5)\r\n\r\n)\r\n\r\n, exclusion_patients as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from valid_hospice\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from exclusion_procedures\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from exclusion_claims\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select\r\n exclusion_patients.patient_id\r\n , exclusion_patients.exclusion_date\r\n , exclusion_patients.exclusion_reason\r\n from exclusion_patients\r\n inner join denominator\r\n on exclusion_patients.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from combined_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_cbe0101_denominator\n\n)\n\n, exclusion_code as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where code = '0518F'\n -- further 1P modifier are only excluded\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0101__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0101__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_procedures as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , 'Limited Mobility' as exclusion_reason\n from procedures\n inner join exclusion_code\n on procedures.code = exclusion_code.code\n and procedures.code_type = exclusion_code.code_system\n where '1P' in (modifier_1, modifier_2, modifier_3, modifier_4, modifier_5)\n \n)\n\n, exclusion_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , 'Limited mobility' as exclusion_reason\n from __dbt__cte___stg_medical_claim medical_claim\n inner join exclusion_code\n on medical_claim.hcpcs_code = exclusion_code.code\n and lower(exclusion_code.code_system) = 'hcpcs'\n where '1P' in (hcpcs_modifier_1, hcpcs_modifier_2, hcpcs_modifier_3, hcpcs_modifier_4, hcpcs_modifier_5)\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_procedures\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_claims\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_long"], "alias": "_int_cbe0101_long", "checksum": {"name": "sha256", "checksum": "ade68a609913733be4f6d6d3b0f30f75337dfa94e350d2897dd6957eafb1cac4"}, "config": {"enabled": true, "alias": "_int_cbe0101_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CBE 0101, Falls: Plan of Care before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1509557, "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_cbe0101_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_cbe0101_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_cbe0101_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0101_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cbe0101_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cbe0101_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cbe0101_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cbe0101_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0101_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101_numerator"], "alias": "_int_cbe0101_numerator", "checksum": {"name": "sha256", "checksum": "8dea05618e3f956359e40c7274fac7d25ece8599f191943164385333ddf4e65b"}, "config": {"enabled": true, "alias": "_int_cbe0101_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CBE 0101, Falls: Plan of Care.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1529565, "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select \r\n patient_id\r\n , encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_cbe0101_denominator') }}\r\n\r\n)\r\n\r\n, fallcare_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where code = '0518F' -- Falls plan of care documented\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date as evidence_date\r\n from procedures\r\n inner join fallcare_codes\r\n on procedures.code = fallcare_codes.code\r\n and procedures.code_type = fallcare_codes.code_system\r\n \r\n)\r\n\r\n, qualifying_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(claim_end_date, claim_start_date) as evidence_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join fallcare_codes\r\n on medical_claim.hcpcs_code = fallcare_codes.code\r\n and lower(fallcare_codes.code_system) = 'hcpcs'\r\n\r\n)\r\n\r\n, qualifying_cares as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_procedures\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_claims\r\n\r\n)\r\n\r\n, combined_qualifying_patients as (\r\n\r\n select\r\n qualifying_cares.patient_id\r\n , qualifying_cares.evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , 1 as numerator_flag\r\n from qualifying_cares\r\n inner join denominator\r\n on qualifying_cares.patient_id = denominator.patient_id\r\n where evidence_date between\r\n {{ dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"denominator.encounter_date\"\r\n )\r\n }}\r\n and \r\n denominator.encounter_date -- within last 12 months of falls screening visit\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from combined_qualifying_patients\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cbe0101_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cbe0101_denominator\n\n)\n\n, fallcare_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where code = '0518F' -- Falls plan of care documented\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join fallcare_codes\n on procedures.code = fallcare_codes.code\n and procedures.code_type = fallcare_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join fallcare_codes\n on medical_claim.hcpcs_code = fallcare_codes.code\n and lower(fallcare_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of falls screening visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cbe0101__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cbe0101_falls_plan_of_care", "quality_measures__int_cbe0101__performance_period"], "alias": "_int_cbe0101__performance_period", "checksum": {"name": "sha256", "checksum": "35ee6ccf32f4ef56c9e9e5c9b04b55e5b9c91034d0301848d95dcb11f4879524"}, "config": {"enabled": true, "alias": "_int_cbe0101__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Falls: Plan of Care.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cbe0101__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1420438, "relation_name": "dev_thuxuan.quality_measures._int_cbe0101__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0101')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0101')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CBE0101')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided \r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to following day of 1 year prior\r\n*/\r\n\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cbe0101_falls_plan_of_care\\quality_measures__int_cbe0101__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm130_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_denominator"], "alias": "_int_cqm130_denominator", "checksum": {"name": "sha256", "checksum": "84ea388d142467326bf5faf2733844b31f4ca02a732a1773c7ab477993ba23c4"}, "config": {"enabled": true, "alias": "_int_cqm130_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Documentation of Current Medications in the Medical Record.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during latest encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_encounter_date": {"name": "procedure_encounter_date", "description": "Patient's date of encounter in the performance period for procedures.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claims_encounter_date": {"name": "claims_encounter_date", "description": "Patient's date of encounter in the performance period for medical claims.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.171021, "relation_name": "dev_thuxuan.quality_measures._int_cqm130_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'encounter to document medications'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as procedure_encounter_date -- alias only to enable union later\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as claims_encounter_date -- alias only to enable union later\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_cqm130__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as procedure_encounter_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claims_encounter_date\r\n from {{ ref('quality_measures__stg_core__procedure') }} procs\r\n inner join {{ ref('quality_measures__int_cqm130__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select \r\n patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as procedure_encounter_date\r\n , coalesce(claim_end_date,claim_start_date) as claims_encounter_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join {{ ref('quality_measures__int_cqm130__performance_period') }} as pp \r\n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code = visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, multiple_encounters_by_patient as (\r\n\r\n select\r\n patient_id\r\n , procedure_encounter_date\r\n , claims_encounter_date\r\n , case when procedure_encounter_date >= claims_encounter_date\r\n then procedure_encounter_date\r\n else claims_encounter_date\r\n end as max_encounter_date\r\n , {{ dbt.concat([\r\n \"coalesce(min(visit_enc), '')\"\r\n , \"coalesce(min(proc_enc), '')\"\r\n , \"coalesce(min(claim_enc), '')\"\r\n ]) }} as qualifying_types\r\n from all_encounters\r\n group by patient_id, procedure_encounter_date, claims_encounter_date\r\n\r\n)\r\n\r\n, max_encounter_dates_by_patient as (\r\n\r\n\tselect\r\n\t\t patient_id\r\n\t\t, max(max_encounter_date) as max_encounter_date\r\n\tfrom multiple_encounters_by_patient\r\n\tgroup by patient_id\r\n\r\n)\r\n\r\n, latest_patient_encounters as (\r\n\t\r\n\tselect\r\n\t\t max_encounter_dates_by_patient.patient_id\r\n\t\t, max_encounter_dates_by_patient.max_encounter_date\r\n\t\t, procedure_encounter_date\r\n\t\t, claims_encounter_date\r\n\tfrom max_encounter_dates_by_patient\r\n\tinner join multiple_encounters_by_patient\r\n\t\ton max_encounter_dates_by_patient.patient_id = multiple_encounters_by_patient.patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , procedure_encounter_date\r\n , claims_encounter_date\r\n , floor({{ datediff('birth_date', 'e.max_encounter_date', 'hour') }} / 8760.0) as max_age\r\n from {{ ref('quality_measures__stg_core__patient') }} p\r\n inner join latest_patient_encounters e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n patients_with_age.patient_id\r\n , patients_with_age.max_age as age\r\n , patients_with_age.procedure_encounter_date\r\n , patients_with_age.claims_encounter_date\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_age\r\n cross join {{ ref('quality_measures__int_cqm130__performance_period') }} pp\r\n where max_age >= 18\r\n \r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(procedure_encounter_date as date) as procedure_encounter_date\r\n , cast(claims_encounter_date as date) as claims_encounter_date\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , procedure_encounter_date\r\n , claims_encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.try_to_cast_date", "macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'encounter to document medications'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as procedure_encounter_date -- alias only to enable union later\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as claims_encounter_date -- alias only to enable union later\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm130__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as procedure_encounter_date\n , try_cast( null as date ) as claims_encounter_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_cqm130__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , try_cast( null as date ) as procedure_encounter_date\n , coalesce(claim_end_date,claim_start_date) as claims_encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm130__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, multiple_encounters_by_patient as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , case when procedure_encounter_date >= claims_encounter_date\n then procedure_encounter_date\n else claims_encounter_date\n end as max_encounter_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id, procedure_encounter_date, claims_encounter_date\n\n)\n\n, max_encounter_dates_by_patient as (\n\n\tselect\n\t\t patient_id\n\t\t, max(max_encounter_date) as max_encounter_date\n\tfrom multiple_encounters_by_patient\n\tgroup by patient_id\n\n)\n\n, latest_patient_encounters as (\n\t\n\tselect\n\t\t max_encounter_dates_by_patient.patient_id\n\t\t, max_encounter_dates_by_patient.max_encounter_date\n\t\t, procedure_encounter_date\n\t\t, claims_encounter_date\n\tfrom max_encounter_dates_by_patient\n\tinner join multiple_encounters_by_patient\n\t\ton max_encounter_dates_by_patient.patient_id = multiple_encounters_by_patient.patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_encounter_date\n ) / 8760.0) as max_age\n from __dbt__cte___stg_patient p\n inner join latest_patient_encounters e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , patients_with_age.procedure_encounter_date\n , patients_with_age.claims_encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_cqm130__performance_period pp\n where max_age >= 18\n \n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(procedure_encounter_date as date) as procedure_encounter_date\n , cast(claims_encounter_date as date) as claims_encounter_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm130_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_exclusions"], "alias": "_int_cqm130_exclusions", "checksum": {"name": "sha256", "checksum": "db4824082465eeaa2c384abedad01c966232eb88cc77de6634be774f713bce84"}, "config": {"enabled": true, "alias": "_int_cqm130_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 130, Documentation of Current Medications in the Medical Record.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1730208, "relation_name": "dev_thuxuan.quality_measures._int_cqm130_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_cqm130__performance_period') }}\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_cqm130__performance_period') }}\r\n)\r\n{%- endset -%}\r\n\r\nwith exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'medical reason'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , claim_id\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n where recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name as concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name as concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name as concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n and exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, patients_with_exclusions as (\r\n \r\n select \r\n patient_id\r\n , recorded_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from condition_exclusions\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , concept_name as exclusion_reason\r\n from med_claim_exclusions\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select \r\n patients_with_exclusions.patient_id\r\n , patients_with_exclusions.exclusion_date\r\n , patients_with_exclusions.exclusion_reason \r\n from patients_with_exclusions\r\n inner join {{ ref('quality_measures__int_cqm130_denominator') }} as denominator\r\n on patients_with_exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm130__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm130__performance_period", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__int_cqm130_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medical reason'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as (\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join dev_thuxuan.quality_measures._int_cqm130_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm130_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_long"], "alias": "_int_cqm130_long", "checksum": {"name": "sha256", "checksum": "ff7872af3c809343de8e627300c79acb4e3008bfb506eb34903140c83e7f630a"}, "config": {"enabled": true, "alias": "_int_cqm130_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 130, Documentation of Current Medications in the Medical Record before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1760175, "relation_name": "dev_thuxuan.quality_measures._int_cqm130_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_cqm130_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_cqm130_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_cqm130_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm130_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm130_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm130_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cqm130_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm130_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm130_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130_numerator"], "alias": "_int_cqm130_numerator", "checksum": {"name": "sha256", "checksum": "2bee56fa7d0acba849b46c585cdf8d9365fe4f9cd0c5f244bfe7eb104babe236"}, "config": {"enabled": true, "alias": "_int_cqm130_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 130, Documentation of Current Medications in the Medical Record.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1790173, "relation_name": "dev_thuxuan.quality_measures._int_cqm130_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , procedure_encounter_date\r\n , claims_encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_cqm130_denominator') }}\r\n\r\n)\r\n\r\n, medication_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'eligible clinician attests to documenting current medications'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, documenting_meds_procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n from procedures\r\n inner join medication_code\r\n on procedures.code = medication_code.code\r\n and procedures.code_type = medication_code.code_system\r\n\r\n)\r\n\r\n, documenting_meds_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(claim_end_date,claim_start_date) as encounter_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join medication_code\r\n on medical_claim.hcpcs_code = medication_code.code\r\n and medication_code.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, qualifying_procedure as (\r\n\r\n select \r\n documenting_meds_procedures.patient_id\r\n , documenting_meds_procedures.procedure_date as encounter_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n from documenting_meds_procedures\r\n inner join denominator\r\n on documenting_meds_procedures.patient_id = denominator.patient_id\r\n and documenting_meds_procedures.procedure_date = denominator.procedure_encounter_date\r\n\r\n)\r\n\r\n, qualifying_claims as (\r\n \r\n select \r\n documenting_meds_claims.patient_id\r\n , documenting_meds_claims.encounter_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n from documenting_meds_claims\r\n inner join denominator\r\n on documenting_meds_claims.patient_id = denominator.patient_id\r\n and documenting_meds_claims.encounter_date = denominator.claims_encounter_date\r\n\r\n)\r\n\r\n, qualifying_cares as (\r\n\r\n select\r\n patient_id\r\n , encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , cast(1 as integer) as numerator_flag\r\n from qualifying_procedure\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , cast(1 as integer) as numerator_flag\r\n from qualifying_claims\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(encounter_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from qualifying_cares\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm130_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cqm130_denominator\n\n)\n\n, medication_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'eligible clinician attests to documenting current medications'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, documenting_meds_procedures as (\n\n select\n patient_id\n , procedure_date\n from procedures\n inner join medication_code\n on procedures.code = medication_code.code\n and procedures.code_type = medication_code.code_system\n\n)\n\n, documenting_meds_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date,claim_start_date) as encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join medication_code\n on medical_claim.hcpcs_code = medication_code.code\n and medication_code.code_system = 'hcpcs'\n\n)\n\n, qualifying_procedure as (\n\n select \n documenting_meds_procedures.patient_id\n , documenting_meds_procedures.procedure_date as encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_procedures\n inner join denominator\n on documenting_meds_procedures.patient_id = denominator.patient_id\n and documenting_meds_procedures.procedure_date = denominator.procedure_encounter_date\n\n)\n\n, qualifying_claims as (\n \n select \n documenting_meds_claims.patient_id\n , documenting_meds_claims.encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_claims\n inner join denominator\n on documenting_meds_claims.patient_id = denominator.patient_id\n and documenting_meds_claims.encounter_date = denominator.claims_encounter_date\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_procedure\n\n union all\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(encounter_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_cares\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm130__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm130__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm130_documentation_of_current_medications_in_the_medical_record", "quality_measures__int_cqm130__performance_period"], "alias": "_int_cqm130__performance_period", "checksum": {"name": "sha256", "checksum": "b401ad1c29e144a85835af03adafd7e4dc183513544ff40cca1f2b08d54b328c"}, "config": {"enabled": true, "alias": "_int_cqm130__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Documentation of Current Medications in the Medical Record.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm130__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.168021, "relation_name": "dev_thuxuan.quality_measures._int_cqm130__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM130')\r\n\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM130')\r\n\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM130')\r\n\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to following day of 1 year prior\r\n*/\r\n\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm130_documentation_of_current_medications_in_the_medical_record\\quality_measures__int_cqm130__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm236_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_denominator"], "alias": "_int_cqm236_denominator", "checksum": {"name": "sha256", "checksum": "f000301e07487b123b0ae5e7d70b02a24882485f92d207a3081bb5d1618751bf"}, "config": {"enabled": true, "alias": "_int_cqm236_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of CQM 236, Controlling Blood Pressure\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0554376, "relation_name": "dev_thuxuan.quality_measures._int_cqm236_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'office visit'\r\n , 'home healthcare services'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'annual wellness visit'\r\n , 'telephone visits'\r\n , 'emergency department evaluation and management visit'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ref('quality_measures__stg_core__encounter')}} encounter\r\n inner join {{ref('quality_measures__int_cqm236__performance_period')}} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'outpatient'\r\n , 'nonacute inpatient'\r\n , 'encounter inpatient'\r\n , 'acute_inpatient'\r\n , 'emergency_department'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ref('quality_measures__stg_core__procedure')}} procs\r\n inner join {{ref('quality_measures__int_cqm236__performance_period')}} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\r\n inner join {{ref('quality_measures__int_cqm236__performance_period')}} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code= visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n union all\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n union all\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select\r\n patient_id\r\n , min(min_date) min_date\r\n , max(max_date) max_date\r\n , concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, hypertension_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'essential hypertension'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition')}}\r\n\r\n)\r\n\r\n, hypertension_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.encounter_id\r\n , conditions.recorded_date\r\n , conditions.source_code\r\n , conditions.source_code_type\r\n from conditions\r\n inner join hypertension_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = hypertension_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = hypertension_codes.code\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n \r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\r\n , max_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\r\n , qualifying_types\r\n from {{ref('quality_measures__stg_core__patient')}} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n-- Patients 18-85 years of age who had a visit and diagnosis of essential hypertension starting before and continuing into, or starting during the first six months of the measurement period.\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n hypertension_conditions.patient_id\r\n , hypertension_conditions.recorded_date\r\n , patients_with_age.max_age as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from hypertension_conditions\r\n left join patients_with_age\r\n on hypertension_conditions.patient_id = patients_with_age.patient_id\r\n cross join {{ref('quality_measures__int_cqm236__performance_period')}} pp\r\n where max_age >= 18 and min_age <= 85\r\n and hypertension_conditions.recorded_date between\r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -12\r\n , from_date_or_timestamp = \"performance_period_begin\"\r\n )\r\n }}\r\n and \r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = +6\r\n , from_date_or_timestamp = \"performance_period_begin\"\r\n )}}\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff", "macro.dbt.dateadd"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'emergency department evaluation and management visit'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm236__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'outpatient'\n , 'nonacute inpatient'\n , 'encounter inpatient'\n , 'acute_inpatient'\n , 'emergency_department'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_cqm236__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm236__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, hypertension_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'essential hypertension'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, hypertension_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join hypertension_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = hypertension_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = hypertension_codes.code\n\n)\n\n, patients_with_age as (\n \n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n-- Patients 18-85 years of age who had a visit and diagnosis of essential hypertension starting before and continuing into, or starting during the first six months of the measurement period.\n, qualifying_patients as (\n\n select\n distinct\n hypertension_conditions.patient_id\n , hypertension_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from hypertension_conditions\n left join patients_with_age\n on hypertension_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_cqm236__performance_period pp\n where max_age >= 18 and min_age <= 85\n and hypertension_conditions.recorded_date between\n \n\n dateadd(\n month,\n -12,\n performance_period_begin\n )\n\n\n and \n \n\n dateadd(\n month,\n 6,\n performance_period_begin\n )\n\n\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm236_exclude_procedures_observations", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_exclude_procedures_observations.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_exclude_procedures_observations.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_exclude_procedures_observations"], "alias": "_int_cqm236_exclude_procedures_observations", "checksum": {"name": "sha256", "checksum": "e2f9355f5b56591960d235729d37fd1ce51f3c34eb61f4bb4bebc37d9318a3d3"}, "config": {"enabled": true, "alias": "_int_cqm236_exclude_procedures_observations", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with certain observations and procedures for the reporting version of CQM 236, Controlling Blood Pressure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_exclude_procedures_observations", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0574377, "relation_name": "dev_thuxuan.quality_measures._int_cqm236_exclude_procedures_observations", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n from {{ ref('quality_measures__int_cqm236_denominator') }}\r\n\r\n)\r\n\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets')}}\r\n where lower(concept_name) in (\r\n 'dialysis services'\r\n , 'end stage renal disease'\r\n , 'esrd monthly outpatient services'\r\n , 'kidney transplant'\r\n , 'kidney transplant recipient'\r\n , 'pregnancy'\r\n )\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, exclusions_unioned as (\r\n\r\n select\r\n patient_id\r\n , recorded_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from condition_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n)\r\n\r\n, excluded_patients as (\r\n\r\n select\r\n exclusions_unioned.patient_id\r\n , exclusions_unioned.exclusion_date\r\n , exclusions_unioned.exclusion_reason\r\n , case\r\n when exclusion_reason = 'pregnancy' then 1\r\n else 0\r\n end as is_pregnant\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.age\r\n from exclusions_unioned\r\n inner join denominator\r\n on exclusions_unioned.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, exclusions_filtered as (\r\n\r\n select\r\n patient_id\r\n , age\r\n , exclusion_date\r\n , exclusion_reason\r\n from excluded_patients\r\n where is_pregnant = 1\r\n and exclusion_date between performance_period_begin and performance_period_end\r\n \r\n union all\r\n\r\n select\r\n patient_id\r\n , age\r\n , exclusion_date\r\n , exclusion_reason\r\n from excluded_patients\r\n where is_pregnant = 0\r\n and exclusion_date between performance_period_begin and performance_period_end\r\n or (exclusion_date between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=\"performance_period_begin\") }}\r\n and performance_period_end)\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , age\r\n , 'measure specific exclusion for observation procedure' as exclusion_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom\r\n exclusions_filtered", "language": "sql", "refs": [{"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_exclude_procedures_observations.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dialysis services'\n , 'end stage renal disease'\n , 'esrd monthly outpatient services'\n , 'kidney transplant'\n , 'kidney transplant recipient'\n , 'pregnancy'\n )\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, exclusions_unioned as (\n\n select\n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, excluded_patients as (\n\n select\n exclusions_unioned.patient_id\n , exclusions_unioned.exclusion_date\n , exclusions_unioned.exclusion_reason\n , case\n when exclusion_reason = 'pregnancy' then 1\n else 0\n end as is_pregnant\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.age\n from exclusions_unioned\n inner join denominator\n on exclusions_unioned.patient_id = denominator.patient_id\n\n)\n\n, exclusions_filtered as (\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 1\n and exclusion_date between performance_period_begin and performance_period_end\n \n union all\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 0\n and exclusion_date between performance_period_begin and performance_period_end\n or (exclusion_date between \n\n dateadd(\n year,\n -1,\n performance_period_begin\n )\n\n\n and performance_period_end)\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , age\n , 'measure specific exclusion for observation procedure' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n exclusions_filtered", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm236_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_exclusions"], "alias": "_int_cqm236_exclusions", "checksum": {"name": "sha256", "checksum": "055adeb8a79bcb8346f45475eaabcbfd2e8e69bdf6a32fd0de3b2fa22c3f0ad1"}, "config": {"enabled": true, "alias": "_int_cqm236_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 236, Controlling Blood Pressure.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0594373, "relation_name": "dev_thuxuan.quality_measures._int_cqm236_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_cqm236__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_cqm236__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith frailty as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, denominator as (\r\n\r\n select\r\n patient_id\r\n , age\r\n from {{ref('quality_measures__int_cqm236_denominator')}}\r\n\r\n)\r\n-- advanced illness start\r\n, advanced_illness_exclusion as (\r\n\r\n select\r\n source.*\r\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where source.exclusion_date\r\n between\r\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\r\n and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, acute_inpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'acute_inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'nonacute_outpatient'\r\n\r\n)\r\n\r\n, acute_inpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from acute_inpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, nonacute_outpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from nonacute_outpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, valid_advanced_illness_exclusions as (\r\n\r\n select\r\n acute_inpatient_advanced_illness.patient_id\r\n , acute_inpatient_advanced_illness.exclusion_date\r\n , acute_inpatient_advanced_illness.exclusion_reason\r\n , acute_inpatient_advanced_illness.exclusion_type\r\n from acute_inpatient_advanced_illness\r\n left join acute_inpatient_counts\r\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\r\n where acute_inpatient_counts.encounter_count >= 1\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient_advanced_illness.patient_id\r\n , nonacute_outpatient_advanced_illness.exclusion_date\r\n , nonacute_outpatient_advanced_illness.exclusion_reason\r\n , nonacute_outpatient_advanced_illness.exclusion_type\r\n from nonacute_outpatient_advanced_illness\r\n left join nonacute_outpatient_counts\r\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\r\n where nonacute_outpatient_counts.encounter_count >= 2\r\n\r\n\r\n)\r\n-- advanced illness end\r\n\r\n, valid_dementia_exclusions as (\r\n\r\n select\r\n source.patient_id\r\n , source.exclusion_date\r\n , source.exclusion_reason\r\n , source.exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where (\r\n source.dispensing_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n or source.paid_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n )\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_institutional_snp as (\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, measure_specific_procedure_observation_exclusion as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n , age\r\n from {{ref('quality_measures__int_cqm236_exclude_procedures_observations')}}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select *\r\n from valid_advanced_illness_exclusions\r\n \r\n union all\r\n\r\n select *\r\n from valid_dementia_exclusions\r\n\r\n union all\r\n\r\n select *\r\n from valid_hospice_palliative\r\n\r\n union all\r\n\r\n select *\r\n from valid_institutional_snp\r\n\r\n union all\r\n\r\n select *\r\n from valid_dementia_exclusions\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select \r\n exclusions.*\r\n , denominator.age\r\n from exclusions\r\n inner join denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, frailty_exclusion_older_than_80 as (\r\n\r\n select\r\n frailty.patient_id\r\n , frailty.exclusion_date\r\n , frailty.exclusion_reason\r\n , 'measure specific exclusion for patients older than 80' as exclusion_type\r\n , denominator.age\r\n from frailty\r\n inner join denominator\r\n on frailty.patient_id = denominator.patient_id\r\n where denominator.age >= 81\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select * from combined_exclusions\r\n where exclusion_type != 'hospice_palliative'\r\n and age >= 66\r\n\r\n union all\r\n\r\n select * from combined_exclusions\r\n where exclusion_type = 'hospice_palliative'\r\n\r\n union all\r\n\r\n select * from frailty_exclusion_older_than_80\r\n\r\n union all\r\n\r\n select * from measure_specific_procedure_observation_exclusion\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm236__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_exclude_procedures_observations", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, measure_specific_procedure_observation_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n , age\n from dev_thuxuan.quality_measures._int_cqm236_exclude_procedures_observations\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, frailty_exclusion_older_than_80 as (\n\n select\n frailty.patient_id\n , frailty.exclusion_date\n , frailty.exclusion_reason\n , 'measure specific exclusion for patients older than 80' as exclusion_type\n , denominator.age\n from frailty\n inner join denominator\n on frailty.patient_id = denominator.patient_id\n where denominator.age >= 81\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select * from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n union all\n\n select * from frailty_exclusion_older_than_80\n\n union all\n\n select * from measure_specific_procedure_observation_exclusion\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm236_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_long"], "alias": "_int_cqm236_long", "checksum": {"name": "sha256", "checksum": "e437b9d4c86ae1bea2f7d0057350805350cd90a38501667264db92788b88cb79"}, "config": {"enabled": true, "alias": "_int_cqm236_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 236,Controlling Blood Pressure before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0654368, "relation_name": "dev_thuxuan.quality_measures._int_cqm236_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_cqm236_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n from {{ ref('quality_measures__int_cqm236_numerator') }}\r\n where numerator_flag = 1\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_cqm236_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.observation_date\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.observation_date is null then 1 else 0 end,\r\n numerator.observation_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , observation_date\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(observation_date as date) as evidence_date\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm236_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n from dev_thuxuan.quality_measures._int_cqm236_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm236_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.observation_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.observation_date is null then 1 else 0 end,\n numerator.observation_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , observation_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(observation_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm236_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236_numerator"], "alias": "_int_cqm236_numerator", "checksum": {"name": "sha256", "checksum": "65c1601529f5dbd7fd58cda542935c5ddb995d880690b3020e1360e059c27e31"}, "config": {"enabled": true, "alias": "_int_cqm236_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 236, Controlling Blood Pressure.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.062437, "relation_name": "dev_thuxuan.quality_measures._int_cqm236_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith controlled_bp_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'most recent systolic blood pressure < 140 mmhg' --G8752 hcpcs\r\n , 'most recent diastolic blood pressure < 90 mmhg' --G8754 hcpcs\r\n )\r\n \r\n)\r\n\r\n, denominator as (\r\n\r\n select\r\n patient_id\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n from {{ ref('quality_measures__int_cqm236_denominator') }}\r\n\r\n)\r\n\r\n, encounters as (\r\n\r\n select\r\n patient_id\r\n , encounter_type\r\n , encounter_start_date\r\n , encounter_end_date\r\n from {{ ref('quality_measures__stg_core__encounter') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , normalized_code\r\n , normalized_description\r\n , result\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n where lower(normalized_description) in \r\n (\r\n 'systolic blood pressure'\r\n , 'diastolic blood pressure'\r\n )\r\n and normalized_code not in (\r\n '99473' -- Self-measured blood pressure using a device validated for clinical accuracy; patient education/training and device calibration\r\n , '99474' -- Separate self-measurements of two readings one minute apart, twice daily over a 30-day period (minimum of 12 readings), collection of data reported by the patient and/or caregiver to the physician or other qualified health care professional, with report of average systolic and diastolic pressures and subsequent communication of a treatment plan to the patient\r\n )\r\n and {{ dbt.safe_cast(\"result\", api.Column.translate_type(\"numeric\")) }} is not null\r\n\r\n)\r\n\r\n, labs as (\r\n\r\n select \r\n patient_id\r\n , result_date\r\n , collection_date\r\n , result\r\n , normalized_code\r\n from {{ref('quality_measures__stg_core__lab_result')}}\r\n where normalized_code in \r\n ('8480-6' --systolic\r\n ,'8462-4') --diastolic\r\n and\r\n normalized_code_type = 'loinc'\r\n and {{ dbt.safe_cast(\"result\", api.Column.translate_type(\"numeric\")) }} is not null\r\n\r\n)\r\n\r\n, all_procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, all_medical_claims as (\r\n \r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, controlled_bp_procedures as (\r\n\r\n select\r\n all_procedures.patient_id\r\n , all_procedures.procedure_date as evidence_date\r\n , controlled_bp_codes.code\r\n from all_procedures\r\n inner join controlled_bp_codes\r\n on all_procedures.code_type = controlled_bp_codes.code_system\r\n and all_procedures.code = controlled_bp_codes.code\r\n\r\n)\r\n\r\n, controlled_bp_medical_claims as (\r\n\r\n select\r\n all_medical_claims.patient_id\r\n , coalesce(all_medical_claims.claim_end_date, all_medical_claims.claim_start_date) as evidence_date\r\n , controlled_bp_codes.code\r\n from all_medical_claims\r\n inner join controlled_bp_codes\r\n on all_medical_claims.hcpcs_code = controlled_bp_codes.code\r\n and controlled_bp_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, controlled_bp_patients_proc_claims as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , code\r\n from controlled_bp_procedures\r\n\r\n union all\r\n \r\n select\r\n patient_id\r\n , evidence_date\r\n , code\r\n from controlled_bp_medical_claims\r\n\r\n)\r\n\r\n, controlled_bp_within_range_proc_claims as (\r\n\r\n select\r\n controlled_bp_patients_proc_claims.patient_id\r\n , controlled_bp_patients_proc_claims.evidence_date\r\n , controlled_bp_patients_proc_claims.code\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n from controlled_bp_patients_proc_claims\r\n inner join denominator\r\n on controlled_bp_patients_proc_claims.patient_id = denominator.patient_id\r\n and controlled_bp_patients_proc_claims.evidence_date between\r\n denominator.performance_period_begin and denominator.performance_period_end\r\n\r\n)\r\n\r\n, procedure_claims_w_encounters as (\r\n\r\n select\r\n controlled_bp_within_range_proc_claims.patient_id\r\n , controlled_bp_within_range_proc_claims.evidence_date\r\n , controlled_bp_within_range_proc_claims.code\r\n , case\r\n when lower(encounters.encounter_type) in (\r\n 'emergency department'\r\n , 'acute inpatient'\r\n )\r\n then 0\r\n else 1\r\n end as is_valid_procedure_claims\r\n , controlled_bp_within_range_proc_claims.measure_id\r\n , controlled_bp_within_range_proc_claims.measure_name\r\n , controlled_bp_within_range_proc_claims.measure_version\r\n , controlled_bp_within_range_proc_claims.performance_period_begin\r\n , controlled_bp_within_range_proc_claims.performance_period_end\r\n from controlled_bp_within_range_proc_claims\r\n left join encounters\r\n on controlled_bp_within_range_proc_claims.patient_id = encounters.patient_id\r\n and controlled_bp_within_range_proc_claims.evidence_date between \r\n encounters.encounter_start_date and encounters.encounter_end_date \r\n \r\n)\r\n\r\n, valid_procedures_and_claims as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , code\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n from procedure_claims_w_encounters\r\n where is_valid_procedure_claims = 1\r\n\r\n)\r\n\r\n, systolic_bp_from_procedure_claims as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n from valid_procedures_and_claims\r\n where code = 'G8752' --systolic\r\n\r\n)\r\n\r\n, diastolic_bp_from_procedure_claims as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from valid_procedures_and_claims\r\n where code = 'G8754' --diastolic\r\n\r\n)\r\n\r\n, qualifying_controlled_bp_proc_claims as (\r\n\r\n select\r\n systolic_bp_from_procedure_claims.patient_id\r\n , systolic_bp_from_procedure_claims.evidence_date\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n from systolic_bp_from_procedure_claims\r\n inner join diastolic_bp_from_procedure_claims\r\n on systolic_bp_from_procedure_claims.patient_id = diastolic_bp_from_procedure_claims.patient_id\r\n and systolic_bp_from_procedure_claims.evidence_date = diastolic_bp_from_procedure_claims.evidence_date\r\n\r\n)\r\n\r\n, observations_within_range as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , observations.normalized_code\r\n , observations.normalized_description\r\n , observations.result\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n from observations\r\n inner join denominator\r\n on observations.patient_id = denominator.patient_id\r\n and observations.observation_date between \r\n denominator.performance_period_begin and denominator.performance_period_end\r\n\r\n)\r\n\r\n, labs_within_range as (\r\n\r\n select\r\n labs.patient_id\r\n , labs.normalized_code\r\n , coalesce(labs.result_date, labs.collection_date) as observation_date\r\n , labs.result\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n from labs\r\n inner join denominator\r\n on labs.patient_id = denominator.patient_id\r\n and coalesce(labs.result_date,labs.collection_date) between \r\n denominator.performance_period_begin and denominator.performance_period_end\r\n\r\n)\r\n\r\n, observations_with_encounters as (\r\n\r\n select\r\n observations_within_range.patient_id\r\n , observations_within_range.observation_date\r\n , observations_within_range.normalized_description\r\n , observations_within_range.result\r\n , observations_within_range.normalized_code\r\n , case\r\n when lower(encounters.encounter_type) in (\r\n 'emergency department'\r\n , 'acute inpatient'\r\n )\r\n then 0\r\n else 1\r\n end as is_valid_encounter_observation\r\n , observations_within_range.measure_id\r\n , observations_within_range.measure_name\r\n , observations_within_range.measure_version\r\n , observations_within_range.performance_period_begin\r\n , observations_within_range.performance_period_end\r\n from observations_within_range\r\n left join encounters\r\n on observations_within_range.patient_id = encounters.patient_id\r\n and observations_within_range.observation_date between \r\n encounters.encounter_start_date and encounters.encounter_end_date\r\n\r\n)\r\n\r\n, labs_with_encounters as (\r\n\r\n select\r\n labs_within_range.patient_id\r\n , labs_within_range.normalized_code\r\n , labs_within_range.observation_date\r\n , labs_within_range.result\r\n , case\r\n when lower(encounters.encounter_type) in (\r\n 'emergency department'\r\n , 'acute inpatient'\r\n )\r\n then 0\r\n else 1\r\n end as is_valid_encounter_labs\r\n , labs_within_range.measure_id\r\n , labs_within_range.measure_name\r\n , labs_within_range.measure_version\r\n , labs_within_range.performance_period_begin\r\n , labs_within_range.performance_period_end\r\n from labs_within_range\r\n left join encounters\r\n on labs_within_range.patient_id = encounters.patient_id\r\n and labs_within_range.observation_date between\r\n encounters.encounter_start_date and encounters.encounter_end_date\r\n \r\n)\r\n\r\n, obs_and_labs as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n {% if target.type == 'fabric' %}\r\n , try_cast(result as {{ dbt.type_float() }}) as bp_reading\r\n {% else %}\r\n , cast(result as {{ dbt.type_float() }}) as bp_reading\r\n {% endif %}\r\n , normalized_description\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , normalized_code\r\n from observations_with_encounters\r\n where is_valid_encounter_observation = 1\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n {% if target.type == 'fabric' %}\r\n , try_cast(result as {{ dbt.type_float() }}) as bp_reading\r\n {% else %}\r\n , cast(result as {{ dbt.type_float() }}) as bp_reading\r\n {% endif %}\r\n , cast(null as {{ dbt.type_string() }}) as normalized_description\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , normalized_code\r\n from labs_with_encounters labs\r\n where is_valid_encounter_labs = 1\r\n\r\n)\r\n\r\n, systolic_bp as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , bp_reading\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\r\n from obs_and_labs\r\n where lower(normalized_description) = 'systolic blood pressure'\r\n or\r\n normalized_code = '8480-6'\r\n\r\n)\r\n\r\n, diastolic_bp as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , bp_reading\r\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\r\n from obs_and_labs\r\n where lower(normalized_description) = 'diastolic blood pressure'\r\n or\r\n normalized_code = '8462-4'\r\n\r\n)\r\n\r\n, least_recent_systolic_bp as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , bp_reading as systolic_bp\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n from systolic_bp\r\n where rn = 1\r\n\r\n)\r\n\r\n, least_recent_diastolic_bp as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , bp_reading as diastolic_bp\r\n from diastolic_bp\r\n where rn = 1\r\n\r\n)\r\n\r\n, patients_with_bp_readings as (\r\n\r\n select\r\n least_recent_systolic_bp.patient_id\r\n , least_recent_systolic_bp.systolic_bp\r\n , least_recent_diastolic_bp.diastolic_bp\r\n , least_recent_systolic_bp.observation_date\r\n , least_recent_systolic_bp.measure_id\r\n , least_recent_systolic_bp.measure_name\r\n , least_recent_systolic_bp.measure_version\r\n , least_recent_systolic_bp.performance_period_begin\r\n , least_recent_systolic_bp.performance_period_end\r\n from least_recent_systolic_bp\r\n inner join least_recent_diastolic_bp\r\n on least_recent_systolic_bp.patient_id = least_recent_diastolic_bp.patient_id\r\n and least_recent_systolic_bp.observation_date = least_recent_diastolic_bp.observation_date\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , case\r\n when systolic_bp < 140.0 and diastolic_bp < 90.0\r\n then 1\r\n else 0\r\n end as numerator_flag\r\n from patients_with_bp_readings\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , evidence_date as observation_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , 1 as numerator_flag\r\n from qualifying_controlled_bp_proc_claims\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(observation_date as date) as observation_date\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from numerator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , observation_date\r\n , numerator_flag\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_cqm236_denominator", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_float", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), controlled_bp_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'most recent systolic blood pressure < 140 mmhg' --G8752 hcpcs\n , 'most recent diastolic blood pressure < 90 mmhg' --G8754 hcpcs\n )\n \n)\n\n, denominator as (\n\n select\n patient_id\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n , encounter_end_date\n from __dbt__cte___stg_encounter\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , normalized_code\n , normalized_description\n , result\n from __dbt__cte___stg_observation\n where lower(normalized_description) in \n (\n 'systolic blood pressure'\n , 'diastolic blood pressure'\n )\n and normalized_code not in (\n '99473' -- Self-measured blood pressure using a device validated for clinical accuracy; patient education/training and device calibration\n , '99474' -- Separate self-measurements of two readings one minute apart, twice daily over a 30-day period (minimum of 12 readings), collection of data reported by the patient and/or caregiver to the physician or other qualified health care professional, with report of average systolic and diastolic pressures and subsequent communication of a treatment plan to the patient\n )\n and \n \n try_cast(result as numeric)\n is not null\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , result\n , normalized_code\n from __dbt__cte___stg_lab_result\n where normalized_code in \n ('8480-6' --systolic\n ,'8462-4') --diastolic\n and\n normalized_code_type = 'loinc'\n and \n \n try_cast(result as numeric)\n is not null\n\n)\n\n, all_procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, all_medical_claims as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, controlled_bp_procedures as (\n\n select\n all_procedures.patient_id\n , all_procedures.procedure_date as evidence_date\n , controlled_bp_codes.code\n from all_procedures\n inner join controlled_bp_codes\n on all_procedures.code_type = controlled_bp_codes.code_system\n and all_procedures.code = controlled_bp_codes.code\n\n)\n\n, controlled_bp_medical_claims as (\n\n select\n all_medical_claims.patient_id\n , coalesce(all_medical_claims.claim_end_date, all_medical_claims.claim_start_date) as evidence_date\n , controlled_bp_codes.code\n from all_medical_claims\n inner join controlled_bp_codes\n on all_medical_claims.hcpcs_code = controlled_bp_codes.code\n and controlled_bp_codes.code_system = 'hcpcs'\n\n)\n\n, controlled_bp_patients_proc_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_procedures\n\n union all\n \n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_medical_claims\n\n)\n\n, controlled_bp_within_range_proc_claims as (\n\n select\n controlled_bp_patients_proc_claims.patient_id\n , controlled_bp_patients_proc_claims.evidence_date\n , controlled_bp_patients_proc_claims.code\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from controlled_bp_patients_proc_claims\n inner join denominator\n on controlled_bp_patients_proc_claims.patient_id = denominator.patient_id\n and controlled_bp_patients_proc_claims.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, procedure_claims_w_encounters as (\n\n select\n controlled_bp_within_range_proc_claims.patient_id\n , controlled_bp_within_range_proc_claims.evidence_date\n , controlled_bp_within_range_proc_claims.code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_procedure_claims\n , controlled_bp_within_range_proc_claims.measure_id\n , controlled_bp_within_range_proc_claims.measure_name\n , controlled_bp_within_range_proc_claims.measure_version\n , controlled_bp_within_range_proc_claims.performance_period_begin\n , controlled_bp_within_range_proc_claims.performance_period_end\n from controlled_bp_within_range_proc_claims\n left join encounters\n on controlled_bp_within_range_proc_claims.patient_id = encounters.patient_id\n and controlled_bp_within_range_proc_claims.evidence_date between \n encounters.encounter_start_date and encounters.encounter_end_date \n \n)\n\n, valid_procedures_and_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from procedure_claims_w_encounters\n where is_valid_procedure_claims = 1\n\n)\n\n, systolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from valid_procedures_and_claims\n where code = 'G8752' --systolic\n\n)\n\n, diastolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n from valid_procedures_and_claims\n where code = 'G8754' --diastolic\n\n)\n\n, qualifying_controlled_bp_proc_claims as (\n\n select\n systolic_bp_from_procedure_claims.patient_id\n , systolic_bp_from_procedure_claims.evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp_from_procedure_claims\n inner join diastolic_bp_from_procedure_claims\n on systolic_bp_from_procedure_claims.patient_id = diastolic_bp_from_procedure_claims.patient_id\n and systolic_bp_from_procedure_claims.evidence_date = diastolic_bp_from_procedure_claims.evidence_date\n\n)\n\n, observations_within_range as (\n\n select\n observations.patient_id\n , observations.observation_date\n , observations.normalized_code\n , observations.normalized_description\n , observations.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from observations\n inner join denominator\n on observations.patient_id = denominator.patient_id\n and observations.observation_date between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, labs_within_range as (\n\n select\n labs.patient_id\n , labs.normalized_code\n , coalesce(labs.result_date, labs.collection_date) as observation_date\n , labs.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from labs\n inner join denominator\n on labs.patient_id = denominator.patient_id\n and coalesce(labs.result_date,labs.collection_date) between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, observations_with_encounters as (\n\n select\n observations_within_range.patient_id\n , observations_within_range.observation_date\n , observations_within_range.normalized_description\n , observations_within_range.result\n , observations_within_range.normalized_code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_observation\n , observations_within_range.measure_id\n , observations_within_range.measure_name\n , observations_within_range.measure_version\n , observations_within_range.performance_period_begin\n , observations_within_range.performance_period_end\n from observations_within_range\n left join encounters\n on observations_within_range.patient_id = encounters.patient_id\n and observations_within_range.observation_date between \n encounters.encounter_start_date and encounters.encounter_end_date\n\n)\n\n, labs_with_encounters as (\n\n select\n labs_within_range.patient_id\n , labs_within_range.normalized_code\n , labs_within_range.observation_date\n , labs_within_range.result\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_labs\n , labs_within_range.measure_id\n , labs_within_range.measure_name\n , labs_within_range.measure_version\n , labs_within_range.performance_period_begin\n , labs_within_range.performance_period_end\n from labs_within_range\n left join encounters\n on labs_within_range.patient_id = encounters.patient_id\n and labs_within_range.observation_date between\n encounters.encounter_start_date and encounters.encounter_end_date\n \n)\n\n, obs_and_labs as (\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from observations_with_encounters\n where is_valid_encounter_observation = 1\n\n union all\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , cast(null as TEXT) as normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from labs_with_encounters labs\n where is_valid_encounter_labs = 1\n\n)\n\n, systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'systolic blood pressure'\n or\n normalized_code = '8480-6'\n\n)\n\n, diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'diastolic blood pressure'\n or\n normalized_code = '8462-4'\n\n)\n\n, least_recent_systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as systolic_bp\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp\n where rn = 1\n\n)\n\n, least_recent_diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as diastolic_bp\n from diastolic_bp\n where rn = 1\n\n)\n\n, patients_with_bp_readings as (\n\n select\n least_recent_systolic_bp.patient_id\n , least_recent_systolic_bp.systolic_bp\n , least_recent_diastolic_bp.diastolic_bp\n , least_recent_systolic_bp.observation_date\n , least_recent_systolic_bp.measure_id\n , least_recent_systolic_bp.measure_name\n , least_recent_systolic_bp.measure_version\n , least_recent_systolic_bp.performance_period_begin\n , least_recent_systolic_bp.performance_period_end\n from least_recent_systolic_bp\n inner join least_recent_diastolic_bp\n on least_recent_systolic_bp.patient_id = least_recent_diastolic_bp.patient_id\n and least_recent_systolic_bp.observation_date = least_recent_diastolic_bp.observation_date\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , case\n when systolic_bp < 140.0 and diastolic_bp < 90.0\n then 1\n else 0\n end as numerator_flag\n from patients_with_bp_readings\n\n union all\n\n select\n patient_id\n , evidence_date as observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as numerator_flag\n from qualifying_controlled_bp_proc_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(observation_date as date) as observation_date\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , observation_date\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm236__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm236__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm236_controlling_blood_pressure", "quality_measures__int_cqm236__performance_period"], "alias": "_int_cqm236__performance_period", "checksum": {"name": "sha256", "checksum": "68c2780987fdd7d1e3c8024e4ba00995aa5212c4f38c7472b1376ded088f664e"}, "config": {"enabled": true, "alias": "_int_cqm236__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Controlling Blood Pressure.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm236__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0534372, "relation_name": "dev_thuxuan.quality_measures._int_cqm236__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM236')\r\n\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM236')\r\n\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM236')\r\n\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm236_controlling_blood_pressure\\quality_measures__int_cqm236__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator"], "alias": "_int_cqm438_denominator", "checksum": {"name": "sha256", "checksum": "441689cc08475c43760572ebcfd31a62fd384a683d220bb54b115edbe5a54c6f"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for submission of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age as of performance_period_begin date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1199787, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith patients_with_ascvd as (\r\n\r\n select \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , 1 as criteria\r\n from {{ ref('quality_measures__int_cqm438_denominator_criteria1') }}\r\n\r\n)\r\n\r\n, patients_with_cholesterol as (\r\n\r\n select \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , 2 as criteria\r\n from {{ ref('quality_measures__int_cqm438_denominator_criteria2') }}\r\n\r\n)\r\n\r\n, patients_with_diabetes as (\r\n\r\n select \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , 3 as criteria\r\n from {{ ref('quality_measures__int_cqm438_denominator_criteria3') }}\r\n\r\n)\r\n\r\n, visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }} \r\n where lower(concept_name) in (\r\n 'annual wellness visit'\r\n , 'office visit'\r\n , 'outpatient consultation'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services individual counseling'\r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'outpatient encounters for preventive care'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ ref('quality_measures__stg_core__procedure') }} procedures\r\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code= visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id,min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , floor({{ datediff('birth_date', 'performance_period_begin', 'hour') }} / 8760.0) as age\r\n from {{ ref('quality_measures__stg_core__patient') }} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n and p.death_date is null\r\n cross join {{ ref('quality_measures__int_cqm438__performance_period') }}\r\n\r\n)\r\n\r\n, qualifying_patients_from_criteria1 as (\r\n\r\n select\r\n distinct\r\n patients_with_ascvd.patient_id\r\n , patients_with_age.age as age\r\n , patients_with_ascvd.performance_period_begin\r\n , patients_with_ascvd.performance_period_end\r\n , patients_with_ascvd.measure_id\r\n , patients_with_ascvd.measure_name\r\n , patients_with_ascvd.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_ascvd\r\n left join patients_with_age\r\n on patients_with_ascvd.patient_id = patients_with_age.patient_id\r\n where age is not null\r\n\r\n)\r\n\r\n, qualifying_patients_from_criteria2 as (\r\n\r\n select\r\n distinct\r\n patients_with_cholesterol.patient_id\r\n , patients_with_age.age as age\r\n , patients_with_cholesterol.performance_period_begin\r\n , patients_with_cholesterol.performance_period_end\r\n , patients_with_cholesterol.measure_id\r\n , patients_with_cholesterol.measure_name\r\n , patients_with_cholesterol.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_cholesterol\r\n left join patients_with_age\r\n on patients_with_cholesterol.patient_id = patients_with_age.patient_id\r\n where age between 20 and 75\r\n\r\n)\r\n\r\n, qualifying_patients_from_criteria3 as (\r\n\r\n select\r\n distinct\r\n patients_with_diabetes.patient_id\r\n , patients_with_age.age as age\r\n , patients_with_diabetes.performance_period_begin\r\n , patients_with_diabetes.performance_period_end\r\n , patients_with_diabetes.measure_id\r\n , patients_with_diabetes.measure_name\r\n , patients_with_diabetes.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_diabetes\r\n left join patients_with_age\r\n on patients_with_diabetes.patient_id = patients_with_age.patient_id\r\n where age between 40 and 75\r\n\r\n)\r\n\r\n, final_denominator as (\r\n \r\n select\r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from qualifying_patients_from_criteria1\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from qualifying_patients_from_criteria2\r\n \r\n union all\r\n\r\n select\r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from qualifying_patients_from_criteria3\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from final_denominator\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438_denominator_criteria1", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_denominator_criteria2", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_denominator_criteria3", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), patients_with_ascvd as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as criteria\n from dev_thuxuan.quality_measures._int_cqm438_denominator_criteria1\n\n)\n\n, patients_with_cholesterol as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 2 as criteria\n from dev_thuxuan.quality_measures._int_cqm438_denominator_criteria2\n\n)\n\n, patients_with_diabetes as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 3 as criteria\n from dev_thuxuan.quality_measures._int_cqm438_denominator_criteria3\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes \n where lower(concept_name) in (\n 'annual wellness visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'outpatient encounters for preventive care'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n performance_period_begin\n ) / 8760.0) as age\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n and p.death_date is null\n cross join dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n, qualifying_patients_from_criteria1 as (\n\n select\n distinct\n patients_with_ascvd.patient_id\n , patients_with_age.age as age\n , patients_with_ascvd.performance_period_begin\n , patients_with_ascvd.performance_period_end\n , patients_with_ascvd.measure_id\n , patients_with_ascvd.measure_name\n , patients_with_ascvd.measure_version\n , 1 as denominator_flag\n from patients_with_ascvd\n left join patients_with_age\n on patients_with_ascvd.patient_id = patients_with_age.patient_id\n where age is not null\n\n)\n\n, qualifying_patients_from_criteria2 as (\n\n select\n distinct\n patients_with_cholesterol.patient_id\n , patients_with_age.age as age\n , patients_with_cholesterol.performance_period_begin\n , patients_with_cholesterol.performance_period_end\n , patients_with_cholesterol.measure_id\n , patients_with_cholesterol.measure_name\n , patients_with_cholesterol.measure_version\n , 1 as denominator_flag\n from patients_with_cholesterol\n left join patients_with_age\n on patients_with_cholesterol.patient_id = patients_with_age.patient_id\n where age between 20 and 75\n\n)\n\n, qualifying_patients_from_criteria3 as (\n\n select\n distinct\n patients_with_diabetes.patient_id\n , patients_with_age.age as age\n , patients_with_diabetes.performance_period_begin\n , patients_with_diabetes.performance_period_end\n , patients_with_diabetes.measure_id\n , patients_with_diabetes.measure_name\n , patients_with_diabetes.measure_version\n , 1 as denominator_flag\n from patients_with_diabetes\n left join patients_with_age\n on patients_with_diabetes.patient_id = patients_with_age.patient_id\n where age between 40 and 75\n\n)\n\n, final_denominator as (\n \n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria1\n\n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria2\n \n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria3\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from final_denominator\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator_criteria1", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria1.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria1.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator_criteria1"], "alias": "_int_cqm438_denominator_criteria1", "checksum": {"name": "sha256", "checksum": "dc0c799bca1e1f177967756058399395e23c862b07652e59d1da6e4134d8f0a9"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator_criteria1", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Subset of denominator logic for submission of criteria 1 of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator_criteria1", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1109562, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator_criteria1", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith ascvd_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'atherosclerosis and peripheral arterial disease'\r\n , 'myocardial infarction'\r\n , 'pci'\r\n , 'stable and unstable angina'\r\n , 'cabg or pci procedure'\r\n , 'cabg surgeries'\r\n , 'cerebrovascular disease stroke or tia'\r\n , 'ischemic heart disease or related diagnoses'\r\n , 'carotid intervention'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition')}}\r\n\r\n)\r\n\r\n, ascvd_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date as evidence_date\r\n from conditions\r\n inner join ascvd_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = ascvd_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = ascvd_codes.code\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, ascvd_procedures as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date as evidence_date\r\n from procedures\r\n inner join ascvd_codes\r\n on procedures.code = ascvd_codes.code\r\n and procedures.code_type = ascvd_codes.code_system\r\n\r\n)\r\n\r\n, historical_ascvd as (\r\n\r\n select\r\n ascvd_conditions.patient_id\r\n , ascvd_conditions.evidence_date\r\n from ascvd_conditions\r\n\r\n union all\r\n\r\n select\r\n ascvd_procedures.patient_id\r\n , ascvd_procedures.evidence_date\r\n from ascvd_procedures\r\n\r\n)\r\n\r\n, patients_with_ascvd as (\r\n\r\n select\r\n distinct\r\n historical_ascvd.patient_id\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n from historical_ascvd\r\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} pp\r\n on evidence_date <= pp.performance_period_end\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from patients_with_ascvd\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__int_cqm438__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria1.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), ascvd_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'atherosclerosis and peripheral arterial disease'\n , 'myocardial infarction'\n , 'pci'\n , 'stable and unstable angina'\n , 'cabg or pci procedure'\n , 'cabg surgeries'\n , 'cerebrovascular disease stroke or tia'\n , 'ischemic heart disease or related diagnoses'\n , 'carotid intervention'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, ascvd_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join ascvd_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = ascvd_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = ascvd_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, ascvd_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join ascvd_codes\n on procedures.code = ascvd_codes.code\n and procedures.code_type = ascvd_codes.code_system\n\n)\n\n, historical_ascvd as (\n\n select\n ascvd_conditions.patient_id\n , ascvd_conditions.evidence_date\n from ascvd_conditions\n\n union all\n\n select\n ascvd_procedures.patient_id\n , ascvd_procedures.evidence_date\n from ascvd_procedures\n\n)\n\n, patients_with_ascvd as (\n\n select\n distinct\n historical_ascvd.patient_id\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from historical_ascvd\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_ascvd\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator_criteria2", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria2.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria2.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator_criteria2"], "alias": "_int_cqm438_denominator_criteria2", "checksum": {"name": "sha256", "checksum": "5486a0eb7fbdde021787364b3f401661a617a9a567c2a1837f64e4a3ce81d9e1"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator_criteria2", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Subset of denominator logic for submission of criteria 2 of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator_criteria2", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1149788, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator_criteria2", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith cholesterol_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'ldl cholesterol'\r\n , 'familial hypercholesterolemia'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, cholesterol_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date as evidence_date\r\n from conditions\r\n inner join cholesterol_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = cholesterol_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = cholesterol_codes.code\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, cholesterol_procedures as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date as evidence_date\r\n from procedures\r\n inner join cholesterol_codes\r\n on procedures.code = cholesterol_codes.code\r\n and procedures.code_type = cholesterol_codes.code_system\r\n\r\n)\r\n\r\n, labs as (\r\n\r\n select\r\n patient_id\r\n , result\r\n , result_date\r\n , collection_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n from {{ ref('quality_measures__stg_core__lab_result') }}\r\n\r\n)\r\n\r\n, cholesterol_tests_with_result as (\r\n\r\n select\r\n labs.patient_id\r\n , labs.result as evidence_value\r\n , coalesce(collection_date, result_date) as evidence_date\r\n , cholesterol_codes.concept_name\r\n , row_number() over(partition by labs.patient_id order by\r\n labs.result desc\r\n , result_date desc) as rn\r\n from labs\r\n inner join cholesterol_codes\r\n on coalesce(labs.normalized_code, labs.source_code) = cholesterol_codes.code\r\n and coalesce(labs.normalized_code_type, labs.source_code_type) = cholesterol_codes.code_system\r\n {% if target.type == 'fabric' %}\r\n WHERE result LIKE '%.%' OR result LIKE '%[0-9]%'\r\n AND result NOT LIKE '%[^0-9.]%'\r\n {% else %}\r\n where {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\r\n {% endif %}\r\n\r\n)\r\n\r\n, cholesterol_labs as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from cholesterol_tests_with_result\r\n where rn= 1\r\n and cast(evidence_value as {{ dbt.type_numeric() }}) >= 190\r\n\r\n)\r\n\r\n, all_patients_with_cholesterol as (\r\n\r\n select\r\n cholesterol_conditions.patient_id\r\n , cholesterol_conditions.evidence_date\r\n from cholesterol_conditions\r\n\r\n union all\r\n\r\n select\r\n cholesterol_procedures.patient_id\r\n , cholesterol_procedures.evidence_date\r\n from cholesterol_procedures\r\n\r\n union all\r\n\r\n select\r\n cholesterol_labs.patient_id\r\n , cholesterol_labs.evidence_date\r\n from cholesterol_labs\r\n\r\n)\r\n\r\n, patients_with_cholesterol as (\r\n\r\n select\r\n distinct\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from all_patients_with_cholesterol\r\n inner join {{ref('quality_measures__int_cqm438__performance_period')}} pp\r\n on evidence_date <= pp.performance_period_end\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from patients_with_cholesterol\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.apply_regex", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__int_cqm438__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria2.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), cholesterol_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'ldl cholesterol'\n , 'familial hypercholesterolemia'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, cholesterol_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join cholesterol_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = cholesterol_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = cholesterol_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, cholesterol_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cholesterol_codes\n on procedures.code = cholesterol_codes.code\n and procedures.code_type = cholesterol_codes.code_system\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, cholesterol_tests_with_result as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date, result_date) as evidence_date\n , cholesterol_codes.concept_name\n , row_number() over(partition by labs.patient_id order by\n labs.result desc\n , result_date desc) as rn\n from labs\n inner join cholesterol_codes\n on coalesce(labs.normalized_code, labs.source_code) = cholesterol_codes.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = cholesterol_codes.code_system\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, cholesterol_labs as (\n\n select\n patient_id\n , evidence_date\n from cholesterol_tests_with_result\n where rn= 1\n and cast(evidence_value as numeric(28,6)) >= 190\n\n)\n\n, all_patients_with_cholesterol as (\n\n select\n cholesterol_conditions.patient_id\n , cholesterol_conditions.evidence_date\n from cholesterol_conditions\n\n union all\n\n select\n cholesterol_procedures.patient_id\n , cholesterol_procedures.evidence_date\n from cholesterol_procedures\n\n union all\n\n select\n cholesterol_labs.patient_id\n , cholesterol_labs.evidence_date\n from cholesterol_labs\n\n)\n\n, patients_with_cholesterol as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from all_patients_with_cholesterol\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_cholesterol\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_denominator_criteria3", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria3.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria3.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_denominator_criteria3"], "alias": "_int_cqm438_denominator_criteria3", "checksum": {"name": "sha256", "checksum": "8d38d59cea527095ec9aae9694db9470297c90f967c4009878a0ed594ed96a20"}, "config": {"enabled": true, "alias": "_int_cqm438_denominator_criteria3", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Subset of denominator logic for submission of criteria 3 of the reporting version of Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_denominator_criteria3", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1179786, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator_criteria3", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith diabetes_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'diabetes'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, diabetes_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date as evidence_date\r\n from conditions\r\n inner join diabetes_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetes_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetes_codes.code\r\n\r\n)\r\n\r\n, patients_with_diabetes as (\r\n\r\n select\r\n distinct\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version \r\n from diabetes_conditions\r\n inner join {{ ref('quality_measures__int_cqm438__performance_period') }} pp\r\n on evidence_date <= pp.performance_period_end\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from patients_with_diabetes\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__int_cqm438__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_denominator_criteria3.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), diabetes_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetes_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join diabetes_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetes_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetes_codes.code\n\n)\n\n, patients_with_diabetes as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version \n from diabetes_conditions\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_diabetes\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_exclusions"], "alias": "_int_cqm438_exclusions", "checksum": {"name": "sha256", "checksum": "bbdebac7c930033f778d2ddaae6f3f320c345751e2a7fa345c178f875dd6634d"}, "config": {"enabled": true, "alias": "_int_cqm438_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1219785, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_cqm438__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_cqm438__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith exclusion_codes as (\r\n\r\n select\r\n code\r\n , case code_system\r\n when 'SNOMEDCT' then 'snomed-ct'\r\n when 'ICD9CM' then 'icd-9-cm'\r\n when 'ICD10CM' then 'icd-10-cm'\r\n when 'CPT' then 'hcpcs'\r\n when 'ICD10PCS' then 'icd-10-pcs'\r\n else lower(code_system) end as code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'rhabdomyolysis'\r\n , 'breastfeeding'\r\n , 'liver disease'\r\n , 'hepatitis a'\r\n , 'hepatitis b'\r\n , 'documentation of medical reason for no statin therapy'\r\n , 'statin allergen'\r\n , 'end stage renal disease'\r\n , 'statin associated muscle symptoms'\r\n , 'medical reason'\r\n )\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n where recorded_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n , place_of_service_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n where observation_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, medications as (\r\n \r\n select\r\n patient_id\r\n , coalesce(prescribing_date, dispensing_date) as exclusion_date\r\n , source_code\r\n , source_code_type\r\n from {{ ref('quality_measures__stg_core__medication') }}\r\n\r\n)\r\n\r\n, pharmacy_claims as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }} \r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name as concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name as concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, observation_exclusions as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , exclusion_codes.concept_name as concept_name\r\n from observations\r\n inner join exclusion_codes\r\n on observations.code = exclusion_codes.code\r\n and observations.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name as concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, medication_exclusions as (\r\n\r\n select\r\n medications.patient_id\r\n , medications.exclusion_date\r\n , exclusion_codes.concept_name as concept_name\r\n from medications\r\n inner join exclusion_codes\r\n on medications.source_code = exclusion_codes.code\r\n and medications.source_code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, pharmacy_claims_exclusions as (\r\n\r\n select\r\n pharmacy_claims.patient_id\r\n , pharmacy_claims.dispensing_date\r\n , exclusion_codes.concept_name as concept_name\r\n from pharmacy_claims\r\n inner join exclusion_codes\r\n on pharmacy_claims.ndc_code = exclusion_codes.code\r\n and lower(exclusion_codes.code_system) = 'ndc'\r\n\r\n)\r\n\r\n, patients_with_exclusions as(\r\n \r\n select \r\n patient_id\r\n , recorded_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from condition_exclusions\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\r\n , concept_name as exclusion_reason\r\n from med_claim_exclusions\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , observation_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from observation_exclusions\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , concept_name as exclusion_reason\r\n from medication_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , dispensing_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from pharmacy_claims_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from valid_hospice_palliative\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select \r\n patients_with_exclusions.patient_id\r\n , patients_with_exclusions.exclusion_date\r\n , patients_with_exclusions.exclusion_reason \r\n from patients_with_exclusions\r\n inner join {{ ref('quality_measures__int_cqm438_denominator') }} as denominator\r\n on patients_with_exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm438__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__int_cqm438_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'rhabdomyolysis'\n , 'breastfeeding'\n , 'liver disease'\n , 'hepatitis a'\n , 'hepatitis b'\n , 'documentation of medical reason for no statin therapy'\n , 'statin allergen'\n , 'end stage renal disease'\n , 'statin associated muscle symptoms'\n , 'medical reason'\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n where observation_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medications as (\n \n select\n patient_id\n , coalesce(prescribing_date, dispensing_date) as exclusion_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim \n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.exclusion_date\n , exclusion_codes.concept_name as concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claims_exclusions as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , exclusion_codes.concept_name as concept_name\n from pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and lower(exclusion_codes.code_system) = 'ndc'\n\n)\n\n, patients_with_exclusions as(\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select \n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from medication_exclusions\n\n union all\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from pharmacy_claims_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join dev_thuxuan.quality_measures._int_cqm438_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_long"], "alias": "_int_cqm438_long", "checksum": {"name": "sha256", "checksum": "0c801adb59194d007f38ed6c20ff6d1a1df87222f54d84bb9f45fdced291ee0a"}, "config": {"enabled": true, "alias": "_int_cqm438_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1249795, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_cqm438_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_cqm438_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_cqm438_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm438_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm438_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cqm438_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm438_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438_numerator"], "alias": "_int_cqm438_numerator", "checksum": {"name": "sha256", "checksum": "c333ac72076f3d9dc87cfb5df539d9704240c39bed2c3d36136379301e9bf0b4"}, "config": {"enabled": true, "alias": "_int_cqm438_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 438, Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1279562, "relation_name": "dev_thuxuan.quality_measures._int_cqm438_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_cqm438_denominator') }}\r\n\r\n)\r\n\r\n, statin_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'high intensity statin therapy'\r\n , 'low intensity statin therapy'\r\n , 'moderate intensity statin therapy'\r\n , 'statin therapy'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, procedure_statin_related as (\r\n\r\n select \r\n procedures.patient_id\r\n , procedures.procedure_date as evidence_date\r\n from procedures\r\n inner join statin_codes\r\n on procedures.code = statin_codes.code\r\n and procedures.code_type = statin_codes.code_system\r\n\r\n)\r\n\r\n, pharmacy_claims_statin_related as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date as evidence_date\r\n , ndc_code\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }} as pharmacy_claims\r\n inner join statin_codes\r\n on pharmacy_claims.ndc_code = statin_codes.code\r\n and lower(statin_codes.code_system) = 'ndc'\r\n\r\n)\r\n\r\n, medication_statin_related as (\r\n\r\n select\r\n patient_id\r\n , coalesce(dispensing_date, prescribing_date) as evidence_date\r\n , source_code\r\n , source_code_type\r\n from {{ ref('quality_measures__stg_core__medication') }} as medications\r\n inner join statin_codes\r\n on medications.source_code = statin_codes.code\r\n and medications.source_code_type = statin_codes.code_system\r\n \r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n procedure_statin_related.patient_id\r\n , procedure_statin_related.evidence_date\r\n from procedure_statin_related\r\n\r\n union all\r\n\r\n select\r\n pharmacy_claims_statin_related.patient_id\r\n , pharmacy_claims_statin_related.evidence_date\r\n from pharmacy_claims_statin_related\r\n\r\n union all\r\n\r\n select\r\n medication_statin_related.patient_id\r\n , medication_statin_related.evidence_date\r\n from medication_statin_related\r\n\r\n)\r\n\r\n, qualifying_patients_with_denominator as (\r\n\r\n select \r\n qualifying_patients.patient_id\r\n , qualifying_patients.evidence_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , cast(1 as integer) as numerator_flag\r\n from qualifying_patients\r\n inner join denominator\r\n on qualifying_patients.patient_id = denominator.patient_id\r\n and evidence_date between \r\n denominator.performance_period_begin and \r\n denominator.performance_period_end\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from qualifying_patients_with_denominator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm438_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cqm438_denominator\n\n)\n\n, statin_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'high intensity statin therapy'\n , 'low intensity statin therapy'\n , 'moderate intensity statin therapy'\n , 'statin therapy'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, procedure_statin_related as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join statin_codes\n on procedures.code = statin_codes.code\n and procedures.code_type = statin_codes.code_system\n\n)\n\n, pharmacy_claims_statin_related as (\n\n select\n patient_id\n , dispensing_date as evidence_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join statin_codes\n on pharmacy_claims.ndc_code = statin_codes.code\n and lower(statin_codes.code_system) = 'ndc'\n\n)\n\n, medication_statin_related as (\n\n select\n patient_id\n , coalesce(dispensing_date, prescribing_date) as evidence_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication as medications\n inner join statin_codes\n on medications.source_code = statin_codes.code\n and medications.source_code_type = statin_codes.code_system\n \n)\n\n, qualifying_patients as (\n\n select\n procedure_statin_related.patient_id\n , procedure_statin_related.evidence_date\n from procedure_statin_related\n\n union all\n\n select\n pharmacy_claims_statin_related.patient_id\n , pharmacy_claims_statin_related.evidence_date\n from pharmacy_claims_statin_related\n\n union all\n\n select\n medication_statin_related.patient_id\n , medication_statin_related.evidence_date\n from medication_statin_related\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n and evidence_date between \n denominator.performance_period_begin and \n denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm438__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm438__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm438_statin_therapy_for_patients_with_cardiovascular_disease", "quality_measures__int_cqm438__performance_period"], "alias": "_int_cqm438__performance_period", "checksum": {"name": "sha256", "checksum": "c284e35e5536249eae2ea480bb528e7862b9a0038d24e2fc4d069854482ec440"}, "config": {"enabled": true, "alias": "_int_cqm438__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Statin Therapy for the Prevention and Treatment of Cardiovascular Disease\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm438__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1089563, "relation_name": "dev_thuxuan.quality_measures._int_cqm438__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM438')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM438')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM438')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm438_statin_therapy_for_patients_with_cardiovascular_disease\\quality_measures__int_cqm438__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm48_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_denominator"], "alias": "_int_cqm48_denominator", "checksum": {"name": "sha256", "checksum": "d8b2232f1182062159ec4d6263ca9db998b4f6aacd9fd66dd8cfda99c2de374a"}, "config": {"enabled": true, "alias": "_int_cqm48_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Urinary Incontinence.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_date": {"name": "encounter_date", "description": "Patient's date of encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1579561, "relation_name": "dev_thuxuan.quality_measures._int_cqm48_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'occupational therapy evaluation'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'physical therapy evaluation'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n \r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_cqm48__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from procedures\r\n inner join {{ ref('quality_measures__int_cqm48__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on procedures.code = visit_codes.code\r\n and procedures.code_type = visit_codes.code_system\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from medical_claim\r\n inner join {{ ref('quality_measures__int_cqm48__performance_period') }} as pp \r\n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code = visit_codes.code\r\n and visit_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id, min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n , coalesce(min(proc_enc),''))\r\n , coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as age\r\n , max_date\r\n , qualifying_types\r\n from {{ ref('quality_measures__stg_core__patient') }} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.sex = 'female'\r\n and p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n patients_with_age.patient_id\r\n , patients_with_age.age\r\n , patients_with_age.max_date as encounter_date\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_age\r\n cross join {{ ref('quality_measures__int_cqm48__performance_period') }} pp\r\n where age >= 65\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(encounter_date as date) as encounter_date\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'occupational therapy evaluation'\n , 'office visit'\n , 'outpatient'\n , 'physical therapy evaluation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm48__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_cqm48__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm48__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.sex = 'female'\n and p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age\n , patients_with_age.max_date as encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_cqm48__performance_period pp\n where age >= 65\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm48_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_exclusions"], "alias": "_int_cqm48_exclusions", "checksum": {"name": "sha256", "checksum": "2c0da0d3f9584aaafd2818c3c76e738570b716e538fee942625c9dfb2c24c671"}, "config": {"enabled": true, "alias": "_int_cqm48_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of CQM 48, Urinary Incontinence.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1610222, "relation_name": "dev_thuxuan.quality_measures._int_cqm48_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_cqm48__performance_period') }}\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_cqm48__performance_period') }}\r\n)\r\n{%- endset -%}\r\n\r\nwith valid_hospice_exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n and lower(exclusion_reason) in (\r\n 'hospice encounter'\r\n )\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select\r\n valid_hospice_exclusions.patient_id\r\n , valid_hospice_exclusions.exclusion_date\r\n , valid_hospice_exclusions.exclusion_reason\r\n from valid_hospice_exclusions\r\n inner join {{ ref('quality_measures__int_cqm48_denominator') }} as denominator\r\n on valid_hospice_exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from combined_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_cqm48__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_cqm48_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_exclusions.sql", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm48__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm48__performance_period\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select\n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n from valid_hospice_exclusions\n inner join dev_thuxuan.quality_measures._int_cqm48_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm48_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_long"], "alias": "_int_cqm48_long", "checksum": {"name": "sha256", "checksum": "8955470a16180ac83d0e70404e323349c7a6d841c5adc146f7f7f4032e7042a5"}, "config": {"enabled": true, "alias": "_int_cqm48_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of CQM 48, Urinary Incontinence before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1630204, "relation_name": "dev_thuxuan.quality_measures._int_cqm48_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_cqm48_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_cqm48_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_cqm48_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm48_denominator", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_numerator", "package": null, "version": null}, {"name": "quality_measures__int_cqm48_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_cqm48_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm48_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cqm48_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm48_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm48_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48_numerator"], "alias": "_int_cqm48_numerator", "checksum": {"name": "sha256", "checksum": "46159630eff15fe44dc2c49911bad8ea6074775eb7ca405385b11b8388eaa26f"}, "config": {"enabled": true, "alias": "_int_cqm48_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of CQM 48, Urinary Incontinence.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1660204, "relation_name": "dev_thuxuan.quality_measures._int_cqm48_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select \r\n patient_id\r\n , encounter_date\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_cqm48_denominator') }}\r\n\r\n)\r\n\r\n, involuntary_urination_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'presence or absence of urinary incontinence assessed'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date as evidence_date\r\n from procedures\r\n inner join involuntary_urination_codes\r\n on procedures.code = involuntary_urination_codes.code\r\n and procedures.code_type = involuntary_urination_codes.code_system\r\n \r\n)\r\n\r\n, qualifying_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(claim_end_date, claim_start_date) as evidence_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join involuntary_urination_codes\r\n on medical_claim.hcpcs_code = involuntary_urination_codes.code\r\n and lower(involuntary_urination_codes.code_system) = 'hcpcs'\r\n\r\n)\r\n\r\n, qualifying_cares as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_procedures\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_claims\r\n\r\n)\r\n\r\n, combined_qualifying_patients as (\r\n\r\n select\r\n qualifying_cares.patient_id\r\n , qualifying_cares.evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , 1 as numerator_flag\r\n from qualifying_cares\r\n inner join denominator\r\n on qualifying_cares.patient_id = denominator.patient_id\r\n where evidence_date between\r\n {{ dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"denominator.encounter_date\"\r\n )\r\n }}\r\n and \r\n denominator.encounter_date -- within last 12 months of visit\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from combined_qualifying_patients\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_cqm48_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cqm48_denominator\n\n)\n\n, involuntary_urination_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'presence or absence of urinary incontinence assessed'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join involuntary_urination_codes\n on procedures.code = involuntary_urination_codes.code\n and procedures.code_type = involuntary_urination_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join involuntary_urination_codes\n on medical_claim.hcpcs_code = involuntary_urination_codes.code\n and lower(involuntary_urination_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_cqm48__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_cqm48__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "cqm48_urinary_incontinence", "quality_measures__int_cqm48__performance_period"], "alias": "_int_cqm48__performance_period", "checksum": {"name": "sha256", "checksum": "0532858bc47687211a2e420f40bd5f954cad8c5d66e80606cd40d54bc1bda517"}, "config": {"enabled": true, "alias": "_int_cqm48__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Urinary Incontinence.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_cqm48__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1549563, "relation_name": "dev_thuxuan.quality_measures._int_cqm48__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM48')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM48')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'CQM48')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided \r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to following day of 1 year prior\r\n*/\r\n\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\cqm48_urinary_incontinence\\quality_measures__int_cqm48__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_denominator"], "alias": "_int_nqf0034_denominator", "checksum": {"name": "sha256", "checksum": "e1abb6ee1de44407d187f9528a2134392162d5434c2eef06673e538887a5735a"}, "config": {"enabled": true, "alias": "_int_nqf0034_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0034, Colorectal Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "min_age": {"name": "min_age", "description": "Patient's minumum age during encounter as of the performance_period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "max_age": {"name": "max_age", "description": "Patient's maximum age during encounter as of the performance_period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "qualifying_types": {"name": "qualifying_types", "description": "Indicative letter of patient's type of encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0254407, "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\nDENOMINATOR:\r\nPatients 45-75 years of age with a visit during the measurement period\r\nDENOMINATOR NOTE: To assess the age for exclusions, the patient\u2019s age on the date of the encounter\r\nshould be used\r\n*Signifies that this CPT Category I code is a non-covered service under the Medicare Part B Physician Fee\r\nSchedule (PFS). These non-covered services should be counted in the denominator population for MIPS\r\nCQMs.\r\nDenominator Criteria (Eligible Cases):\r\nPatients 45 to 75 years of age on date of encounter\r\nAND\r\nPatient encounter during the performance period (CPT or HCPCS): 99202, 99203, 99204, 99205,\r\n99212, 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350, 99386*, 99387*,\r\n99396*, 99397*, G0438, G0439\r\n*/\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'office visit'\r\n , 'home healthcare services'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'annual wellness visit'\r\n , 'telephone visits'\r\n , 'online assessments'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_nqf0034__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where encounter_type in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ ref('quality_measures__stg_core__procedure') }} procs\r\n inner join {{ ref('quality_measures__int_nqf0034__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n\r\n select patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\r\n inner join {{ref('quality_measures__int_nqf0034__performance_period')}} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code= visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n union all\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n union all\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id, min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8766.0) as min_age\r\n , max_date\r\n ,floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8766.0) as max_age\r\n , qualifying_types\r\n from {{ref('quality_measures__stg_core__patient')}} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null -- ensures deceased patients are not included\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , min_age\r\n , max_age\r\n , qualifying_types\r\nfrom patients_with_age\r\nwhere max_age >= 45 and min_age <= 75", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_denominator.sql", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR:\nPatients 45-75 years of age with a visit during the measurement period\nDENOMINATOR NOTE: To assess the age for exclusions, the patient\u2019s age on the date of the encounter\nshould be used\n*Signifies that this CPT Category I code is a non-covered service under the Medicare Part B Physician Fee\nSchedule (PFS). These non-covered services should be counted in the denominator population for MIPS\nCQMs.\nDenominator Criteria (Eligible Cases):\nPatients 45 to 75 years of age on date of encounter\nAND\nPatient encounter during the performance period (CPT or HCPCS): 99202, 99203, 99204, 99205,\n99212, 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350, 99386*, 99387*,\n99396*, 99397*, G0438, G0439\n*/\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'online assessments'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where encounter_type in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8766.0) as min_age\n , max_date\n ,floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8766.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null -- ensures deceased patients are not included\n\n)\n\nselect \n patient_id\n , min_age\n , max_age\n , qualifying_types\nfrom patients_with_age\nwhere max_age >= 45 and min_age <= 75", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_exclude_colectomy_cancer", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_exclude_colectomy_cancer.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_exclude_colectomy_cancer.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_exclude_colectomy_cancer"], "alias": "_int_nqf0034_exclude_colectomy_cancer", "checksum": {"name": "sha256", "checksum": "98a2f6839377f97859e279fb3cfa6a78868fdab5ee3553fbd2eed78b762474e5"}, "config": {"enabled": true, "alias": "_int_nqf0034_exclude_colectomy_cancer", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty and advanced illness for the reporting version of NQF 0034, Colorectal Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_type": {"name": "exclusion_type", "description": "Measure specific exclusion for historical record of colectomy cancer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "desciption": "The date and timestamp of the dbt run."}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_exclude_colectomy_cancer", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0284364, "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_exclude_colectomy_cancer", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\nDENOMINATOR EXCLUSIONS:\r\nPatients with a diagnosis or past history of total colectomy or colorectal cancer: G9711\r\n*/\r\n\r\n\r\nwith exclusion_codes as (\r\n\r\n select\r\n code\r\n , case code_system\r\n when 'SNOMEDCT' then 'snomed-ct'\r\n when 'ICD9CM' then 'icd-9-cm'\r\n when 'ICD10CM' then 'icd-10-cm'\r\n when 'CPT' then 'hcpcs'\r\n when 'ICD10PCS' then 'icd-10-pcs'\r\n else lower(code_system) \r\n end as code_system\r\n , concept_name\r\n From {{ref('quality_measures__value_sets')}}\r\n where lower(concept_name) in (\r\n 'malignant neoplasm of colon'\r\n , 'total colectomy'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n , place_of_service_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name as concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name as concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, observation_exclusions as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , exclusion_codes.concept_name as concept_name\r\n from observations\r\n inner join exclusion_codes\r\n on observations.code = exclusion_codes.code\r\n and observations.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name as concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, patients_with_exclusions as(\r\n select patient_id\r\n , recorded_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from condition_exclusions\r\n\r\n union all\r\n\r\n select patient_id\r\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\r\n , concept_name as exclusion_reason\r\n from med_claim_exclusions\r\n\r\n union all\r\n\r\n select patient_id\r\n , observation_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from observation_exclusions\r\n\r\n union all\r\n\r\n select patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'measure specific exclusion for historical record of colectomy cancer' as exclusion_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom patients_with_exclusions", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_exclude_colectomy_cancer.sql", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatients with a diagnosis or past history of total colectomy or colorectal cancer: G9711\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n From dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'malignant neoplasm of colon'\n , 'total colectomy'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for historical record of colectomy cancer' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom patients_with_exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_exclusions"], "alias": "_int_nqf0034_exclusions", "checksum": {"name": "sha256", "checksum": "ef96b731ff607c92679f3b339841efe4f1beb12caa13e16ed9063889163b6631"}, "config": {"enabled": true, "alias": "_int_nqf0034_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0034, Colorectal Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0314374, "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0034__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf0034__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith frailty as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, denominator as (\r\n\r\n select\r\n patient_id\r\n , max_age as age\r\n from {{ref('quality_measures__int_nqf0034_denominator')}}\r\n\r\n)\r\n-- advanced illness start\r\n, advanced_illness_exclusion as (\r\n\r\n select\r\n source.*\r\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where source.exclusion_date\r\n between\r\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\r\n and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, acute_inpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'acute_inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'nonacute_outpatient'\r\n\r\n)\r\n\r\n, acute_inpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from acute_inpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, nonacute_outpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from nonacute_outpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, valid_advanced_illness_exclusions as (\r\n\r\n select\r\n acute_inpatient_advanced_illness.patient_id\r\n , acute_inpatient_advanced_illness.exclusion_date\r\n , acute_inpatient_advanced_illness.exclusion_reason\r\n , acute_inpatient_advanced_illness.exclusion_type\r\n from acute_inpatient_advanced_illness\r\n left join acute_inpatient_counts\r\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\r\n where acute_inpatient_counts.encounter_count >= 1\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient_advanced_illness.patient_id\r\n , nonacute_outpatient_advanced_illness.exclusion_date\r\n , nonacute_outpatient_advanced_illness.exclusion_reason\r\n , nonacute_outpatient_advanced_illness.exclusion_type\r\n from nonacute_outpatient_advanced_illness\r\n left join nonacute_outpatient_counts\r\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\r\n where nonacute_outpatient_counts.encounter_count >= 2\r\n\r\n\r\n)\r\n-- advanced illness end\r\n\r\n, valid_dementia_exclusions as (\r\n\r\n select\r\n source.patient_id\r\n , source.exclusion_date\r\n , source.exclusion_reason\r\n , source.exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where (\r\n source.dispensing_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n or source.paid_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n )\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n and lower(exclusion_reason) in \r\n (\r\n 'palliative care encounter'\r\n , 'palliative care intervention'\r\n , 'hospice care ambulatory'\r\n , 'hospice encounter'\r\n )\r\n\r\n)\r\n\r\n, valid_institutional_snp as (\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, measure_specific_colectomy_colorectal_cancer_exclusion as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_nqf0034_exclude_colectomy_cancer')}}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select *\r\n from valid_advanced_illness_exclusions\r\n \r\n union all\r\n\r\n select *\r\n from valid_dementia_exclusions\r\n\r\n union all\r\n\r\n select *\r\n from valid_hospice_palliative\r\n\r\n union all\r\n\r\n select *\r\n from valid_institutional_snp\r\n\r\n union all\r\n\r\n select *\r\n from valid_dementia_exclusions\r\n\r\n union all\r\n\r\n select *\r\n from measure_specific_colectomy_colorectal_cancer_exclusion\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select \r\n exclusions.*\r\n , denominator.age\r\n from exclusions\r\n inner join denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select * from combined_exclusions\r\n where exclusion_type not in (\r\n 'measure specific exclusion for historical record of colectomy cancer'\r\n , 'hospice_palliative'\r\n ) \r\n and age >= 66\r\n\r\n union all\r\n\r\n select * from combined_exclusions --age irrelvant exclusions\r\n where exclusion_type in (\r\n 'measure specific exclusion for historical record of colectomy cancer'\r\n , 'hospice_palliative'\r\n ) \r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_denominator", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_exclude_colectomy_cancer", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , max_age as age\n from dev_thuxuan.quality_measures._int_nqf0034_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n and lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, measure_specific_colectomy_colorectal_cancer_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_nqf0034_exclude_colectomy_cancer\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from measure_specific_colectomy_colorectal_cancer_exclusion\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type not in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n and age >= 66\n\n union all\n\n select * from combined_exclusions --age irrelvant exclusions\n where exclusion_type in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_long"], "alias": "_int_nqf0034_long", "checksum": {"name": "sha256", "checksum": "905eaa9da79e2ebee48cf94c60a99e483739cd75ba4bb0be2812b1d0718dbe41"}, "config": {"enabled": true, "alias": "_int_nqf0034_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0034, Colorectal Cancer Screening before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.033437, "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n\r\n{%- set measure_id -%}\r\n(\r\n select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0034'\r\n )\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(\r\n\r\n select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0034'\r\n\r\n )\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(\r\n select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0034'\r\n\r\n )\r\n{%- endset -%}\r\n\r\n\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_nqf0034_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from {{ ref('quality_measures__int_nqf0034_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf0034_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , {{ measure_id }} as measure_id\r\n , {{ measure_name }} as measure_name\r\n , {{ measure_version }} as measure_version\r\n from denominator\r\n inner join {{ref('quality_measures__int_nqf0034__performance_period')}} pp\r\n on 1 = 1\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, add_rownum as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , row_number() over(\r\n partition by\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n order by\r\n case when evidence_date is null then 1 else 0 end,\r\n evidence_date desc\r\n , case when exclusion_date is null then 1 else 0 end,\r\n exclusion_date desc\r\n ) as row_num\r\n from measure_flags\r\n\r\n)\r\n\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from add_rownum\r\n where row_num = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034_exclusions", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_long.sql", "compiled": true, "compiled_code": "with denominator as (\n\n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0034_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n from dev_thuxuan.quality_measures._int_nqf0034_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0034_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , pp.performance_period_begin\n , pp.performance_period_end\n , (\n select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n ) as measure_id\n , (\n\n select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_name\n , (\n select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_version\n from denominator\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0034_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034_numerator"], "alias": "_int_nqf0034_numerator", "checksum": {"name": "sha256", "checksum": "1c2745ee9b2d483babb41288cc91c51dad6ac21ba7ea045c86b1e28116c15f7b"}, "config": {"enabled": true, "alias": "_int_nqf0034_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0034, Colorectal Cancer Screening\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence": {"name": "evidence", "description": "Reason (usually the value set concept name) that includes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.036437, "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n\r\n/*\r\nPatients with one or more screenings for colorectal cancer. Appropriate screenings are defined by any one of the\r\nfollowing criteria:\r\n- Fecal occult blood test (FOBT) during the measurement period\r\n- Flexible sigmoidoscopy during the measurement period or the four years prior to the measurement period\r\n- Colonoscopy during the measurement period or the nine years prior to the measurement period\r\n- Computed tomography (CT) colonography during the measurement period or the four years prior to the\r\nmeasurement period.\r\n- Fecal immunochemical DNA test (FIT-DNA) during the measurement period or the two years prior to the\r\nmeasurement period.\r\n\r\n*/\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_nqf0034_denominator') }}\r\n\r\n)\r\n\r\n, screening_codes as (\r\n\r\n select\r\n code\r\n , case code_system\r\n when 'SNOMEDCT' then 'snomed-ct'\r\n when 'ICD9CM' then 'icd-9-cm'\r\n when 'ICD10CM' then 'icd-10-cm'\r\n when 'CPT' then 'hcpcs'\r\n when 'ICD10PCS' then 'icd-10-pcs'\r\n else lower(code_system) \r\n end as code_system\r\n , concept_name\r\n from {{ref('quality_measures__value_sets')}}\r\n where lower(concept_name) in (\r\n 'fecal occult blood test (fobt)' -- mp\r\n , 'flexible sigmoidoscopy' --mp+4\r\n , 'colonoscopy' -- mp+9\r\n , 'ct colonography' -- mp+4\r\n , 'sdna fit test' -- mp+2\r\n )\r\n\r\n)\r\n\r\n, screening_periods as (\r\n\r\n select \r\n code\r\n , code_system\r\n , concept_name\r\n , case concept_name\r\n when 'Fecal Occult Blood Test (FOBT)' then pp.performance_period_begin --mp\r\n when 'Flexible Sigmoidoscopy' then pp.performance_period_begin_4yp --mp+4\r\n when 'Colonoscopy' then pp.performance_period_begin_9yp -- mp+9\r\n when 'CT Colonography' then pp.performance_period_begin_4yp -- mp+4\r\n when 'sDNA FIT Test' then pp.performance_period_begin_2yp -- mp+2\r\n else pp.performance_period_begin \r\n end as effective_performance_period_begin\r\n , performance_period_end\r\n from screening_codes\r\n inner join {{ref('quality_measures__int_nqf0034__performance_period')}} pp\r\n on 1 = 1\r\n \r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce(\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, labs as (\r\n\r\n select \r\n patient_id\r\n , result_date\r\n , collection_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n from {{ ref('quality_measures__stg_core__lab_result')}}\r\n\r\n)\r\n\r\n, qualifying_claims as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , coalesce( medical_claim.claim_start_date, medical_claim.claim_end_date) as claim_date\r\n , screening_codes.concept_name\r\n from medical_claim\r\n inner join screening_periods\r\n on medical_claim.claim_start_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\r\n or medical_claim.claim_end_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\r\n inner join screening_codes\r\n on medical_claim.hcpcs_code = screening_codes.code\r\n where screening_codes.code_system in ('hcpcs', 'cpt' )\r\n\r\n)\r\n\r\n, qualifying_observations as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , screening_codes.concept_name\r\n from observations\r\n inner join screening_periods\r\n on observations.observation_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\r\n inner join screening_codes\r\n on observations.code = screening_codes.code\r\n and observations.code_type = screening_codes.code_system\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , screening_codes.concept_name\r\n from procedures\r\n inner join screening_periods\r\n on procedures.procedure_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\r\n inner join screening_codes\r\n on procedures.code = screening_codes.code\r\n and procedures.code_type = screening_codes.code_system\r\n\r\n)\r\n\r\n, normalized_code_labs as (\r\n select\r\n patient_id\r\n , coalesce(collection_date, result_date) as lab_date\r\n , screening_codes.concept_name\r\n from labs\r\n inner join screening_periods\r\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\r\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\r\n inner join screening_codes\r\n on labs.normalized_code = screening_codes.code\r\n and labs.normalized_code_type = screening_codes.code_system\r\n)\r\n\r\n, source_code_labs as (\r\n\r\n select\r\n patient_id\r\n , coalesce(collection_date, result_date) as lab_date\r\n , screening_codes.concept_name\r\n from labs\r\n inner join screening_periods\r\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\r\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\r\n inner join screening_codes\r\n on labs.source_code = screening_codes.code\r\n and labs.source_code_type = screening_codes.code_system\r\n\r\n)\r\n\r\n, qualifying_labs_union as (\r\n\r\n select \r\n patient_id\r\n , lab_date\r\n , concept_name\r\n from normalized_code_labs\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , lab_date\r\n , concept_name\r\n from source_code_labs\r\n\r\n)\r\n\r\n, qualifying_labs as (\r\n\r\n select distinct\r\n patient_id\r\n , lab_date\r\n , concept_name\r\n from qualifying_labs_union\r\n\r\n)\r\n\r\n, qualifying_events as (\r\n\r\n select\r\n patient_id\r\n , claim_date as evidence_date\r\n , concept_name as evidence\r\n from qualifying_claims\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , observation_date as evidence_date\r\n , concept_name as evidence\r\n from qualifying_observations\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , procedure_date as evidence_date\r\n , concept_name as evidence\r\n from qualifying_procedures\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , lab_date as evidence_date\r\n , concept_name as evidence\r\n from qualifying_labs\r\n\r\n)\r\n\r\nselect\r\n cast( qualifying_events.patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast( evidence_date as date) as evidence_date\r\n , cast( evidence as {{ dbt.type_string() }}) as evidence\r\nfrom qualifying_events\r\ninner join denominator\r\n on qualifying_events.patient_id = denominator.patient_id", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0034_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__int_nqf0034__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0034_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034_numerator.sql", "compiled": true, "compiled_code": "\n\n\n/*\nPatients with one or more screenings for colorectal cancer. Appropriate screenings are defined by any one of the\nfollowing criteria:\n- Fecal occult blood test (FOBT) during the measurement period\n- Flexible sigmoidoscopy during the measurement period or the four years prior to the measurement period\n- Colonoscopy during the measurement period or the nine years prior to the measurement period\n- Computed tomography (CT) colonography during the measurement period or the four years prior to the\nmeasurement period.\n- Fecal immunochemical DNA test (FIT-DNA) during the measurement period or the two years prior to the\nmeasurement period.\n\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0034_denominator\n\n)\n\n, screening_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'fecal occult blood test (fobt)' -- mp\n , 'flexible sigmoidoscopy' --mp+4\n , 'colonoscopy' -- mp+9\n , 'ct colonography' -- mp+4\n , 'sdna fit test' -- mp+2\n )\n\n)\n\n, screening_periods as (\n\n select \n code\n , code_system\n , concept_name\n , case concept_name\n when 'Fecal Occult Blood Test (FOBT)' then pp.performance_period_begin --mp\n when 'Flexible Sigmoidoscopy' then pp.performance_period_begin_4yp --mp+4\n when 'Colonoscopy' then pp.performance_period_begin_9yp -- mp+9\n when 'CT Colonography' then pp.performance_period_begin_4yp -- mp+4\n when 'sDNA FIT Test' then pp.performance_period_begin_2yp -- mp+2\n else pp.performance_period_begin \n end as effective_performance_period_begin\n , performance_period_end\n from screening_codes\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n \n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , coalesce( medical_claim.claim_start_date, medical_claim.claim_end_date) as claim_date\n , screening_codes.concept_name\n from medical_claim\n inner join screening_periods\n on medical_claim.claim_start_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n or medical_claim.claim_end_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on medical_claim.hcpcs_code = screening_codes.code\n where screening_codes.code_system in ('hcpcs', 'cpt' )\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n , screening_codes.concept_name\n from observations\n inner join screening_periods\n on observations.observation_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on observations.code = screening_codes.code\n and observations.code_type = screening_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , screening_codes.concept_name\n from procedures\n inner join screening_periods\n on procedures.procedure_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on procedures.code = screening_codes.code\n and procedures.code_type = screening_codes.code_system\n\n)\n\n, normalized_code_labs as (\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.normalized_code = screening_codes.code\n and labs.normalized_code_type = screening_codes.code_system\n)\n\n, source_code_labs as (\n\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.source_code = screening_codes.code\n and labs.source_code_type = screening_codes.code_system\n\n)\n\n, qualifying_labs_union as (\n\n select \n patient_id\n , lab_date\n , concept_name\n from normalized_code_labs\n\n union all\n\n select \n patient_id\n , lab_date\n , concept_name\n from source_code_labs\n\n)\n\n, qualifying_labs as (\n\n select distinct\n patient_id\n , lab_date\n , concept_name\n from qualifying_labs_union\n\n)\n\n, qualifying_events as (\n\n select\n patient_id\n , claim_date as evidence_date\n , concept_name as evidence\n from qualifying_claims\n\n union all\n\n select\n patient_id\n , observation_date as evidence_date\n , concept_name as evidence\n from qualifying_observations\n\n union all\n\n select\n patient_id\n , procedure_date as evidence_date\n , concept_name as evidence\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , lab_date as evidence_date\n , concept_name as evidence\n from qualifying_labs\n\n)\n\nselect\n cast( qualifying_events.patient_id as TEXT) as patient_id\n , cast( evidence_date as date) as evidence_date\n , cast( evidence as TEXT) as evidence\nfrom qualifying_events\ninner join denominator\n on qualifying_events.patient_id = denominator.patient_id", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0034__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0034_colorectal_cancer_screening", "quality_measures__int_nqf0034__performance_period"], "alias": "_int_nqf0034__performance_period", "checksum": {"name": "sha256", "checksum": "a49a0c6632579c310d621764621dc383b6acb81c7557c9ff38f701d58e5e8139"}, "config": {"enabled": true, "alias": "_int_nqf0034__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for NQF 0034 Colorectal Cancer screening.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0034__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0384374, "relation_name": "dev_thuxuan.quality_measures._int_nqf0034__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\n/*\r\n set performance lookback periods for each type of test\r\n\r\n during the measurement period:\r\n - Fecal occult blood test (FOBT) during the measurement period\r\n\r\n during the measurement period or the two years prior:\r\n - Fecal immunochemical DNA test (FIT-DNA)\r\n\r\n during the measurement period or the four years prior:\r\n - Flexible sigmoidoscopy\r\n - Computed tomography (CT) colonography\r\n\r\n during the measurement period or the nine years prior:\r\n - Colonoscopy\r\n\r\n*/\r\n, period_lookback as (\r\n\r\n select\r\n performance_period_end\r\n , performance_period_begin\r\n , {{ dbt.dateadd(\r\n datepart = \"year\"\r\n , interval = -2\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n ) }} as performance_period_begin_1yp\r\n , {{ dbt.dateadd(\r\n datepart = \"year\"\r\n , interval = -3\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n ) }} as performance_period_begin_2yp\r\n , {{ dbt.dateadd(\r\n datepart = \"year\"\r\n , interval = -5\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n ) }} as performance_period_begin_4yp\r\n , {{ dbt.dateadd(\r\n datepart = \"year\"\r\n , interval = -10\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n ) }} as performance_period_begin_9yp\r\n from period_begin\r\n\r\n)\r\n\r\nselect\r\n cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(performance_period_begin_1yp as date) as performance_period_begin_1yp\r\n , cast(performance_period_begin_2yp as date) as performance_period_begin_2yp\r\n , cast(performance_period_begin_4yp as date) as performance_period_begin_4yp\r\n , cast(performance_period_begin_9yp as date) as performance_period_begin_9yp\r\nfrom period_lookback", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd"], "nodes": []}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0034_colorectal_cancer_screening\\quality_measures__int_nqf0034__performance_period.sql", "compiled": true, "compiled_code": "\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback periods for each type of test\n\n during the measurement period:\n - Fecal occult blood test (FOBT) during the measurement period\n\n during the measurement period or the two years prior:\n - Fecal immunochemical DNA test (FIT-DNA)\n\n during the measurement period or the four years prior:\n - Flexible sigmoidoscopy\n - Computed tomography (CT) colonography\n\n during the measurement period or the nine years prior:\n - Colonoscopy\n\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n year,\n -2,\n performance_period_end\n )\n\n as performance_period_begin_1yp\n , \n\n dateadd(\n year,\n -3,\n performance_period_end\n )\n\n as performance_period_begin_2yp\n , \n\n dateadd(\n year,\n -5,\n performance_period_end\n )\n\n as performance_period_begin_4yp\n , \n\n dateadd(\n year,\n -10,\n performance_period_end\n )\n\n as performance_period_begin_9yp\n from period_begin\n\n)\n\nselect\n cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin_1yp as date) as performance_period_begin_1yp\n , cast(performance_period_begin_2yp as date) as performance_period_begin_2yp\n , cast(performance_period_begin_4yp as date) as performance_period_begin_4yp\n , cast(performance_period_begin_9yp as date) as performance_period_begin_9yp\nfrom period_lookback", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_denominator"], "alias": "_int_nqf0041_denominator", "checksum": {"name": "sha256", "checksum": "35b9d651c51126e7fd7054814b6f3afbf880c45a815fe75e41618008d51a15c7"}, "config": {"enabled": true, "alias": "_int_nqf0041_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Influenza Immunization\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1320443, "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'annual wellness visit'\r\n , 'discharge services nursing facility'\r\n , 'hemodialysis'\r\n , 'home healthcare services'\r\n , 'nursing facility visit'\r\n , 'office visit'\r\n , 'outpatient consultation'\r\n , 'peritoneal dialysis'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services group counseling'\r\n , 'preventive care services individual counseling'\r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'preventive care services, initial office visit, 0 to 17'\r\n , 'preventive care, established office visit, 0 to 17'\r\n , 'online assessments'\r\n , 'patient provider interaction'\r\n , 'telephone visits'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ ref('quality_measures__stg_core__procedure') }} procedures\r\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code = visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id, min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n , coalesce(min(proc_enc),''))\r\n , coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , min_date\r\n , ({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as age_in_decimal_point\r\n , max_date\r\n , qualifying_types\r\n from {{ ref('quality_measures__stg_core__patient') }} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n patients_with_age.patient_id\r\n , patients_with_age.age_in_decimal_point as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_age\r\n cross join {{ ref('quality_measures__int_nqf0041__performance_period') }} pp\r\n where age_in_decimal_point >= 0.5 --filters patients aged 6 months or older\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , round(cast(age as {{ dbt.type_numeric() }}), 1) as age -- ensures age is seen in one decimal point\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff", "macro.dbt.type_numeric"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'discharge services nursing facility'\n , 'hemodialysis'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'peritoneal dialysis'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services group counseling'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'preventive care services, initial office visit, 0 to 17'\n , 'preventive care, established office visit, 0 to 17'\n , 'online assessments'\n , 'patient provider interaction'\n , 'telephone visits'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , (datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age_in_decimal_point\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age_in_decimal_point as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_nqf0041__performance_period pp\n where age_in_decimal_point >= 0.5 --filters patients aged 6 months or older\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(age as numeric(28,6)), 1) as age -- ensures age is seen in one decimal point\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_exclusions"], "alias": "_int_nqf0041_exclusions", "checksum": {"name": "sha256", "checksum": "5e766d956bab5709408687d8ccb06eda6538aa3a6ba7be4db74afc8fc97e95e7"}, "config": {"enabled": true, "alias": "_int_nqf0041_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0041, Influenza Immunization.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.135061, "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0041__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf0041__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith denominator as (\r\n \r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_nqf0041_denominator') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select \r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'influenza immunization not ordered or administered reason documented'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name as concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name as concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n and exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ ref('quality_measures__int_shared_exclusions_hospice_palliative') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from hospice_palliative\r\n where exclusion_reason in (\r\n 'hospice care ambulatory'\r\n , 'hospice encounter'\r\n )\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select\r\n patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , concept_name as exclusion_reason\r\n from med_claim_exclusions\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from valid_hospice_palliative\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select\r\n valid_exclusions.patient_id\r\n , valid_exclusions.exclusion_date\r\n , valid_exclusions.exclusion_reason\r\n from valid_exclusions\r\n inner join denominator\r\n on valid_exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from combined_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0041_denominator\n\n)\n\n, exclusion_codes as (\n\n select \n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza immunization not ordered or administered reason documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from hospice_palliative\n where exclusion_reason in (\n 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select\n valid_exclusions.patient_id\n , valid_exclusions.exclusion_date\n , valid_exclusions.exclusion_reason\n from valid_exclusions\n inner join denominator\n on valid_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_long"], "alias": "_int_nqf0041_long", "checksum": {"name": "sha256", "checksum": "0f99a57de7554381870944dde0e882426473665fa5c4da4b265207c8d2bafe00"}, "config": {"enabled": true, "alias": "_int_nqf0041_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0041, Influenza Immunization before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1370523, "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_nqf0041_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_nqf0041_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf0041_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0041_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0041_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0041_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0041_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0041_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041_numerator"], "alias": "_int_nqf0041_numerator", "checksum": {"name": "sha256", "checksum": "0f8c7224ec6f8ae4d52c2f35bf68e72517dde23dced5cc0a47a4f0aa16af04d1"}, "config": {"enabled": true, "alias": "_int_nqf0041_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0041, Influenza Immunization\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1400647, "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_nqf0041_denominator') }}\r\n\r\n)\r\n\r\n, influenza_vaccination_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'influenza vaccination'\r\n , 'influenza vaccine'\r\n , 'influenza virus laiv immunization'\r\n , 'influenza virus laiv procedure'\r\n )\r\n\r\n)\r\n\r\n, procedure_vaccination as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n from {{ ref('quality_measures__stg_core__procedure') }} as procedures\r\n inner join influenza_vaccination_code\r\n on coalesce(procedures.normalized_code, procedures.source_code) = influenza_vaccination_code.code\r\n and coalesce(procedures.normalized_code_type, procedures.source_code_type) = influenza_vaccination_code.code_system\r\n\r\n)\r\n\r\n, claims_vaccination as (\r\n \r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join influenza_vaccination_code\r\n on medical_claim.hcpcs_code = influenza_vaccination_code.code\r\n\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n procedure_vaccination.patient_id\r\n , procedure_vaccination.procedure_date as evidence_date\r\n from procedure_vaccination\r\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} pp\r\n on procedure_date between \r\n pp.lookback_period_august and\r\n pp.performance_period_end\r\n\r\n)\r\n\r\n, qualifying_claims as (\r\n\r\n select \r\n claims_vaccination.patient_id\r\n , claims_vaccination.max_date as evidence_date\r\n from claims_vaccination\r\n inner join {{ ref('quality_measures__int_nqf0041__performance_period') }} pp\r\n on max_date between\r\n pp.lookback_period_august and\r\n pp.performance_period_end\r\n\r\n)\r\n\r\n, qualified_patients as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_procedures\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from qualifying_claims\r\n\r\n)\r\n\r\n, combined_qualifying_patients as (\r\n\r\n select\r\n qualified_patients.patient_id\r\n , qualified_patients.evidence_date\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , 1 as numerator_flag\r\n from qualified_patients\r\n inner join denominator\r\n on qualified_patients.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from combined_qualifying_patients\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0041_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0041__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__int_nqf0041__performance_period"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0041_denominator\n\n)\n\n, influenza_vaccination_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza vaccination'\n , 'influenza vaccine'\n , 'influenza virus laiv immunization'\n , 'influenza virus laiv procedure'\n )\n\n)\n\n, procedure_vaccination as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procedures\n inner join influenza_vaccination_code\n on coalesce(procedures.normalized_code, procedures.source_code) = influenza_vaccination_code.code\n and coalesce(procedures.normalized_code_type, procedures.source_code_type) = influenza_vaccination_code.code_system\n\n)\n\n, claims_vaccination as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join influenza_vaccination_code\n on medical_claim.hcpcs_code = influenza_vaccination_code.code\n\n)\n\n, qualifying_procedures as (\n\n select\n procedure_vaccination.patient_id\n , procedure_vaccination.procedure_date as evidence_date\n from procedure_vaccination\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period pp\n on procedure_date between \n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualifying_claims as (\n\n select \n claims_vaccination.patient_id\n , claims_vaccination.max_date as evidence_date\n from claims_vaccination\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period pp\n on max_date between\n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualified_patients as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualified_patients.patient_id\n , qualified_patients.evidence_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , 1 as numerator_flag\n from qualified_patients\n inner join denominator\n on qualified_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0041__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0041_influenza_immunization", "quality_measures__int_nqf0041__performance_period"], "alias": "_int_nqf0041__performance_period", "checksum": {"name": "sha256", "checksum": "15a5f0ec0b2f5cc1c9bd2c790cb1ae679f3e4245c255038eaff7632c05494e8f"}, "config": {"enabled": true, "alias": "_int_nqf0041__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Influenza Immunization\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0041__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.130041, "relation_name": "dev_thuxuan.quality_measures._int_nqf0041__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0041')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0041')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0041')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n - set quality_measures_period_end to december end for last quarter measurement period\r\n - set quality_measures_period_end to march end for first quarter measurement period \r\n*/\r\n\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to following day of 3 months prior\r\n for visits in influenza season\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -3\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\n/*\r\n lookback_period for august of either current or previous year\r\n for immunization qualifying date\r\n*/\r\n, lookback_period as (\r\n\r\n select\r\n *\r\n , case\r\n when {{ date_part('month', 'performance_period_end') | as_number }} between 1 and 8\r\n then {{ dbt.concat([\r\n \"(cast(\" ~\r\n date_part('year', 'performance_period_end') ~\r\n \" as integer) - 1)\",\r\n \"'-08-01'\"\r\n ]) }}\r\n else {{ dbt.concat([\r\n date_part('year', 'performance_period_end'),\r\n \"'-08-01'\"\r\n ]) }}\r\n end as lookback_period_august\r\n from period_begin\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(lookback_period_august as date) as lookback_period_august\r\nfrom lookback_period", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0041_influenza_immunization\\quality_measures__int_nqf0041__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n - set quality_measures_period_end to december end for last quarter measurement period\n - set quality_measures_period_end to march end for first quarter measurement period \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 3 months prior\n for visits in influenza season\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n month,\n -3,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n lookback_period for august of either current or previous year\n for immunization qualifying date\n*/\n, lookback_period as (\n\n select\n *\n , case\n when date_part('month', performance_period_end) between 1 and 8\n then (cast(date_part('year', performance_period_end) as integer) - 1) || '-08-01'\n else date_part('year', performance_period_end) || '-08-01'\n end as lookback_period_august\n from period_begin\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_august as date) as lookback_period_august\nfrom lookback_period", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_denominator"], "alias": "_int_nqf0053_denominator", "checksum": {"name": "sha256", "checksum": "6448a02e64b45aa0200534c254438a458e3eeff980e3d68b18bed7bec1dbad0f"}, "config": {"enabled": true, "alias": "_int_nqf0053_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "Date of incident/fracture recorded.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0694375, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }} as value_sets\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n , encounter_type\r\n from {{ref('quality_measures__stg_core__encounter')}} as encounter\r\n inner join {{ ref('quality_measures__int_nqf0053__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ref('quality_measures__stg_core__procedure')}} procs\r\n inner join {{ref('quality_measures__int_nqf0053__performance_period')}} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n , place_of_service_code\r\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\r\n inner join {{ref('quality_measures__int_nqf0053__performance_period')}} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code= visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select\r\n patient_id\r\n , min_date\r\n , max_date\r\n , 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n union all\r\n select\r\n patient_id\r\n , min_date\r\n , max_date\r\n , cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n union all\r\n select\r\n patient_id\r\n , min_date\r\n , max_date\r\n , cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select\r\n patient_id\r\n , min(min_date) min_date\r\n , max(max_date) max_date\r\n , concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, bone_fracture_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) = 'fracture diagnoses'\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition')}}\r\n\r\n)\r\n\r\n, bone_fracture_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.encounter_id\r\n , conditions.recorded_date\r\n , conditions.source_code\r\n , conditions.source_code_type\r\n from conditions\r\n inner join bone_fracture_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = bone_fracture_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = bone_fracture_codes.code\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n patient.patient_id\r\n , patient.sex\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\r\n , max_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\r\n , qualifying_types\r\n from {{ref('quality_measures__stg_core__patient')}} patient\r\n inner join encounters_by_patient e\r\n on patient.patient_id = e.patient_id\r\n where patient.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients_w_fractures as (\r\n\r\n select\r\n distinct\r\n bone_fracture_conditions.patient_id\r\n , bone_fracture_conditions.recorded_date\r\n , patients_with_age.max_age as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from bone_fracture_conditions\r\n left join patients_with_age\r\n on bone_fracture_conditions.patient_id = patients_with_age.patient_id\r\n cross join {{ref('quality_measures__int_nqf0053__performance_period')}} pp\r\n where max_age >= 50 and min_age <= 85\r\n and bone_fracture_conditions.recorded_date between\r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -6\r\n , from_date_or_timestamp = \"performance_period_begin\"\r\n )\r\n }}\r\n and\r\n pp.lookback_period_june\r\n and lower(patients_with_age.sex) = 'female'\r\n\r\n)\r\n\r\n, fracture_procedures as (\r\n\r\n select\r\n procedures.*\r\n from procedures\r\n inner join visit_codes\r\n on procedures.code = visit_codes.code\r\n and procedures.code_type = visit_codes.code_system\r\n inner join {{ ref('quality_measures__int_nqf0053__performance_period') }} as pp\r\n on procedures.procedure_date \r\n between pp.performance_period_begin and pp.performance_period_end\r\n where lower(visit_codes.concept_name) = 'fracture procedures'\r\n\r\n)\r\n\r\n, qualifying_patients_w_encounter as (\r\n\r\n select\r\n qualifying_patients_w_fractures.*\r\n from qualifying_patients_w_fractures\r\n inner join visits_encounters\r\n on qualifying_patients_w_fractures.patient_id = visits_encounters.patient_id\r\n where \r\n lower(visits_encounters.encounter_type) in (\r\n 'acute inpatient'\r\n , 'annual wellness visit'\r\n , 'emergency department visit'\r\n , 'emergency department'\r\n , 'home healthcare services'\r\n , 'office visit'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'emergency department evaluation and management visit'\r\n , 'outpatient'\r\n )\r\n)\r\n\r\n, qualifying_patients_w_procedure as (\r\n\r\n select\r\n qualifying_patients_w_fractures.*\r\n from qualifying_patients_w_fractures\r\n inner join fracture_procedures\r\n on qualifying_patients_w_fractures.patient_id = fracture_procedures.patient_id\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n qualifying_patients_w_encounter.*\r\n from qualifying_patients_w_encounter\r\n left join qualifying_patients_w_procedure\r\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\r\n left join claims_encounters\r\n on qualifying_patients_w_encounter.patient_id = claims_encounters.patient_id\r\n where (cast(claims_encounters.place_of_service_code as {{ dbt.type_string() }}) not in ('21')\r\n or claims_encounters.patient_id is null)\r\n\r\n union all\r\n\r\n select\r\n distinct\r\n qualifying_patients_w_procedure.*\r\n from qualifying_patients_w_procedure\r\n left join qualifying_patients_w_encounter\r\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\r\n where qualifying_patients_w_encounter.patient_id is null\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(recorded_date as date) as recorded_date\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , recorded_date \r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff", "macro.dbt.dateadd"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes as value_sets\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n , encounter_type\n from __dbt__cte___stg_encounter as encounter\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , place_of_service_code\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, bone_fracture_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) = 'fracture diagnoses'\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, bone_fracture_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join bone_fracture_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = bone_fracture_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = bone_fracture_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient patient\n inner join encounters_by_patient e\n on patient.patient_id = e.patient_id\n where patient.death_date is null\n\n)\n\n, qualifying_patients_w_fractures as (\n\n select\n distinct\n bone_fracture_conditions.patient_id\n , bone_fracture_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from bone_fracture_conditions\n left join patients_with_age\n on bone_fracture_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_nqf0053__performance_period pp\n where max_age >= 50 and min_age <= 85\n and bone_fracture_conditions.recorded_date between\n \n\n dateadd(\n month,\n -6,\n performance_period_begin\n )\n\n\n and\n pp.lookback_period_june\n and lower(patients_with_age.sex) = 'female'\n\n)\n\n, fracture_procedures as (\n\n select\n procedures.*\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp\n on procedures.procedure_date \n between pp.performance_period_begin and pp.performance_period_end\n where lower(visit_codes.concept_name) = 'fracture procedures'\n\n)\n\n, qualifying_patients_w_encounter as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join visits_encounters\n on qualifying_patients_w_fractures.patient_id = visits_encounters.patient_id\n where \n lower(visits_encounters.encounter_type) in (\n 'acute inpatient'\n , 'annual wellness visit'\n , 'emergency department visit'\n , 'emergency department'\n , 'home healthcare services'\n , 'office visit'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'emergency department evaluation and management visit'\n , 'outpatient'\n )\n)\n\n, qualifying_patients_w_procedure as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join fracture_procedures\n on qualifying_patients_w_fractures.patient_id = fracture_procedures.patient_id\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n qualifying_patients_w_encounter.*\n from qualifying_patients_w_encounter\n left join qualifying_patients_w_procedure\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n left join claims_encounters\n on qualifying_patients_w_encounter.patient_id = claims_encounters.patient_id\n where (cast(claims_encounters.place_of_service_code as TEXT) not in ('21')\n or claims_encounters.patient_id is null)\n\n union all\n\n select\n distinct\n qualifying_patients_w_procedure.*\n from qualifying_patients_w_procedure\n left join qualifying_patients_w_encounter\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n where qualifying_patients_w_encounter.patient_id is null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , recorded_date \n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_exclude_procedures_medications", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclude_procedures_medications.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclude_procedures_medications.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_exclude_procedures_medications"], "alias": "_int_nqf0053_exclude_procedures_medications", "checksum": {"name": "sha256", "checksum": "5243fee8808e0ec90e7357d3eeb91f7ff27e9dc497aac037c4869d867cc7e0ab"}, "config": {"enabled": true, "alias": "_int_nqf0053_exclude_procedures_medications", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with certain procedures and medicatons for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_type": {"name": "exclusion_type", "description": "measure specific exclusion for procedure medication.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": [], "desciption": "The date and timestamp of the dbt run."}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_exclude_procedures_medications", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0794375, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_exclude_procedures_medications", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0053_denominator')}}\r\n\r\n)\r\n\r\n, value_sets as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets')}}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, pharmacy_claims as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }}\r\n\r\n)\r\n\r\n, medications as (\r\n\r\n select\r\n patient_id\r\n , encounter_id\r\n , prescribing_date\r\n , dispensing_date\r\n , source_code\r\n , source_code_type\r\n from {{ ref('quality_measures__stg_core__medication') }}\r\n\r\n)\r\n\r\n, bone_density_test_codes as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from value_sets\r\n where lower(concept_name) in (\r\n 'bone mineral density test'\r\n , 'bone mineral density tests cpt'\r\n , 'bone mineral density tests hcpcs'\r\n , 'bone mineral density tests icd10pcs'\r\n , 'dexa dual energy xray absorptiometry, bone density'\r\n )\r\n\r\n)\r\n\r\n, osteoporosis_medication_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from value_sets\r\n where lower(concept_name) in \r\n ( \r\n 'osteoporosis medications for urology care'\r\n , 'osteoporosis medication'\r\n , 'bisphosphonates'\r\n )\r\n\r\n)\r\n\r\n, bone_density_test_procedures as (\r\n\r\n select\r\n procedures.*\r\n , bone_density_test_codes.concept_name\r\n from procedures\r\n inner join bone_density_test_codes\r\n on procedures.code = bone_density_test_codes.code\r\n and procedures.code_type = bone_density_test_codes.code_system\r\n\r\n)\r\n\r\n, osteoporosis_pharmacy_claims as (\r\n\r\n select\r\n pharmacy_claims.patient_id\r\n , pharmacy_claims.dispensing_date\r\n , pharmacy_claims.ndc_code\r\n , osteoporosis_medication_codes.concept_name\r\n from pharmacy_claims\r\n inner join osteoporosis_medication_codes\r\n on pharmacy_claims.ndc_code = osteoporosis_medication_codes.code\r\n and lower(osteoporosis_medication_codes.code_system) = 'ndc'\r\n \r\n)\r\n\r\n, osteoporosis_medications as (\r\n\r\n select\r\n medications.patient_id\r\n , medications.encounter_id\r\n , medications.prescribing_date\r\n , medications.dispensing_date\r\n , medications.source_code\r\n , medications.source_code_type\r\n , osteoporosis_medication_codes.concept_name\r\n from medications\r\n inner join osteoporosis_medication_codes\r\n on medications.source_code = osteoporosis_medication_codes.code\r\n and medications.source_code_type = osteoporosis_medication_codes.code_system\r\n\r\n)\r\n\r\n, valid_osteoporosis_medications_procedures as (\r\n\r\n select\r\n denominator.patient_id\r\n , osteoporosis_pharmacy_claims.concept_name as exclusion_reason\r\n , osteoporosis_pharmacy_claims.dispensing_date as exclusion_date\r\n from denominator\r\n inner join osteoporosis_pharmacy_claims\r\n on denominator.patient_id = osteoporosis_pharmacy_claims.patient_id\r\n where osteoporosis_pharmacy_claims.dispensing_date\r\n between\r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -12\r\n , from_date_or_timestamp = \"denominator.performance_period_begin\"\r\n )}}\r\n and denominator.performance_period_begin\r\n \r\n union all\r\n\r\n select\r\n denominator.patient_id\r\n , osteoporosis_medications.concept_name as exclusion_reason\r\n , coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date) as exclusion_date\r\n from denominator\r\n inner join osteoporosis_medications\r\n on denominator.patient_id = osteoporosis_medications.patient_id\r\n and coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date)\r\n between\r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -12\r\n , from_date_or_timestamp = \"denominator.performance_period_begin\"\r\n )}}\r\n and denominator.performance_period_begin\r\n\r\n)\r\n\r\n, valid_tests_performed as (\r\n\r\n select\r\n denominator.patient_id\r\n , bone_density_test_procedures.concept_name as exclusion_reason\r\n , procedure_date as exclusion_date\r\n from denominator\r\n inner join bone_density_test_procedures\r\n on denominator.patient_id = bone_density_test_procedures.patient_id\r\n where bone_density_test_procedures.procedure_date\r\n between \r\n {{ dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -2\r\n , from_date_or_timestamp = \"denominator.performance_period_begin\"\r\n )}}\r\n and denominator.performance_period_begin\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select * from valid_tests_performed\r\n\r\n union all\r\n\r\n select * from valid_osteoporosis_medications_procedures\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'measure specific exclusion for procedure medication' as exclusion_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom\r\n valid_exclusions", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclude_procedures_medications.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medications as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, bone_density_test_codes as (\n\n select\n concept_name\n , code\n , code_system\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests hcpcs'\n , 'bone mineral density tests icd10pcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n )\n\n)\n\n, osteoporosis_medication_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, bone_density_test_procedures as (\n\n select\n procedures.*\n , bone_density_test_codes.concept_name\n from procedures\n inner join bone_density_test_codes\n on procedures.code = bone_density_test_codes.code\n and procedures.code_type = bone_density_test_codes.code_system\n\n)\n\n, osteoporosis_pharmacy_claims as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , pharmacy_claims.ndc_code\n , osteoporosis_medication_codes.concept_name\n from pharmacy_claims\n inner join osteoporosis_medication_codes\n on pharmacy_claims.ndc_code = osteoporosis_medication_codes.code\n and lower(osteoporosis_medication_codes.code_system) = 'ndc'\n \n)\n\n, osteoporosis_medications as (\n\n select\n medications.patient_id\n , medications.encounter_id\n , medications.prescribing_date\n , medications.dispensing_date\n , medications.source_code\n , medications.source_code_type\n , osteoporosis_medication_codes.concept_name\n from medications\n inner join osteoporosis_medication_codes\n on medications.source_code = osteoporosis_medication_codes.code\n and medications.source_code_type = osteoporosis_medication_codes.code_system\n\n)\n\n, valid_osteoporosis_medications_procedures as (\n\n select\n denominator.patient_id\n , osteoporosis_pharmacy_claims.concept_name as exclusion_reason\n , osteoporosis_pharmacy_claims.dispensing_date as exclusion_date\n from denominator\n inner join osteoporosis_pharmacy_claims\n on denominator.patient_id = osteoporosis_pharmacy_claims.patient_id\n where osteoporosis_pharmacy_claims.dispensing_date\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n \n union all\n\n select\n denominator.patient_id\n , osteoporosis_medications.concept_name as exclusion_reason\n , coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date) as exclusion_date\n from denominator\n inner join osteoporosis_medications\n on denominator.patient_id = osteoporosis_medications.patient_id\n and coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date)\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_tests_performed as (\n\n select\n denominator.patient_id\n , bone_density_test_procedures.concept_name as exclusion_reason\n , procedure_date as exclusion_date\n from denominator\n inner join bone_density_test_procedures\n on denominator.patient_id = bone_density_test_procedures.patient_id\n where bone_density_test_procedures.procedure_date\n between \n \n\n dateadd(\n year,\n -2,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_exclusions as (\n\n select * from valid_tests_performed\n\n union all\n\n select * from valid_osteoporosis_medications_procedures\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for procedure medication' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n valid_exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_exclusions"], "alias": "_int_nqf0053_exclusions", "checksum": {"name": "sha256", "checksum": "e42d543080f1de04281d925162592dcca920b35a3ce002cfad1edacaaa33e579"}, "config": {"enabled": true, "alias": "_int_nqf0053_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0764375, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith\r\n\r\ncombined_exclusions as (\r\n\r\n select\r\n exclusions.*\r\n , denominator.age\r\n from {{ ref('quality_measures__int_nqf0053_exclusions_stage_1') }} as exclusions\r\n inner join {{ref('quality_measures__int_nqf0053_denominator')}} as denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type = 'institutional_snp'\r\n and age >= 66\r\n\r\n union all\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type in\r\n (\r\n 'advanced_illness'\r\n , 'dementia'\r\n )\r\n and age between 66 and 80\r\n\r\n union all\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type = 'measure specific exclusion for defined window'\r\n and age >= 81\r\n\r\n union all\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type in\r\n (\r\n 'measure specific exclusion for procedure medication'\r\n , 'hospice_palliative'\r\n )\r\n\r\n)\r\n\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_exclusions_stage_1", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0053_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclusions.sql", "compiled": true, "compiled_code": "\n\nwith\n\ncombined_exclusions as (\n\n select\n exclusions.*\n , denominator.age\n from dev_thuxuan.quality_measures._int_nqf0053_exclusions_stage_1 as exclusions\n inner join dev_thuxuan.quality_measures._int_nqf0053_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'institutional_snp'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'advanced_illness'\n , 'dementia'\n )\n and age between 66 and 80\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'measure specific exclusion for defined window'\n and age >= 81\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'measure specific exclusion for procedure medication'\n , 'hospice_palliative'\n )\n\n)\n\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_exclusions_stage_1", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclusions_stage_1.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclusions_stage_1.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_exclusions_stage_1"], "alias": "_int_nqf0053_exclusions_stage_1", "checksum": {"name": "sha256", "checksum": "4baa57d94abe81120e716b27a07edc2bdd681f47ac8670db00ba8433045b4ca5"}, "config": {"enabled": true, "alias": "_int_nqf0053_exclusions_stage_1", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture. First stage of final exclusion logic.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_type": {"name": "exclusion_type", "description": "Type of exclusion from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_exclusions_stage_1", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0744374, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_exclusions_stage_1", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select\r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0053__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select\r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf0053__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set lookback_period_december -%}\r\n(\r\n select\r\n lookback_period_december\r\n from {{ ref('quality_measures__int_nqf0053__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n\r\nwith frailty as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, frailty_within_defined_window as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between\r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -6\r\n , from_date_or_timestamp = performance_period_begin\r\n )\r\n }}\r\n and {{ lookback_period_december }}\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, exclusion_procedure_and_medication as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_nqf0053_exclude_procedures_medications')}}\r\n\r\n)\r\n\r\n, valid_institutional_snp as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\r\n where exclusion_date between\r\n {{dbt.dateadd(\r\n datepart = \"month\"\r\n , interval = -6\r\n , from_date_or_timestamp = performance_period_begin\r\n )\r\n }}\r\n\r\n and {{ lookback_period_december }}\r\n\r\n)\r\n\r\n, valid_dementia_exclusions as (\r\n\r\n select\r\n source.patient_id\r\n , source.exclusion_date\r\n , source.exclusion_reason\r\n , source.exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where (\r\n source.dispensing_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n or source.paid_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n )\r\n\r\n)\r\n\r\n-- advanced illness start\r\n, advanced_illness_exclusion as (\r\n\r\n select\r\n source.*\r\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where source.exclusion_date\r\n between\r\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\r\n and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, acute_inpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'acute_inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'nonacute_outpatient'\r\n\r\n)\r\n\r\n, acute_inpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from acute_inpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, nonacute_outpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from nonacute_outpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, valid_advanced_illness_exclusions as (\r\n\r\n select\r\n acute_inpatient_advanced_illness.patient_id\r\n , acute_inpatient_advanced_illness.exclusion_date\r\n , acute_inpatient_advanced_illness.exclusion_reason\r\n , acute_inpatient_advanced_illness.exclusion_type\r\n from acute_inpatient_advanced_illness\r\n left join acute_inpatient_counts\r\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\r\n where acute_inpatient_counts.encounter_count >= 1\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient_advanced_illness.patient_id\r\n , nonacute_outpatient_advanced_illness.exclusion_date\r\n , nonacute_outpatient_advanced_illness.exclusion_reason\r\n , nonacute_outpatient_advanced_illness.exclusion_type\r\n from nonacute_outpatient_advanced_illness\r\n left join nonacute_outpatient_counts\r\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\r\n where nonacute_outpatient_counts.encounter_count >= 2\r\n\r\n\r\n)\r\n-- advanced illness end\r\n\r\n, frailty_patients_within_defined_window as (\r\n\r\n select\r\n frailty_within_defined_window.patient_id\r\n , frailty_within_defined_window.exclusion_date\r\n , frailty_within_defined_window.exclusion_reason\r\n , 'measure specific exclusion for defined window' as exclusion_type\r\n from frailty_within_defined_window\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select * from valid_advanced_illness_exclusions\r\n\r\n union all\r\n\r\n select * from valid_dementia_exclusions\r\n\r\n union all\r\n\r\n select * from valid_institutional_snp\r\n\r\n union all\r\n\r\n select * from valid_hospice_palliative\r\n\r\n union all\r\n\r\n select * from exclusion_procedure_and_medication\r\n\r\n union all\r\n\r\n select * from frailty_patients_within_defined_window\r\n\r\n)\r\n\r\nselect\r\n *\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom exclusions", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_exclude_procedures_medications", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_exclusions_stage_1.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, frailty_within_defined_window as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n lookback_period_december\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, exclusion_procedure_and_medication as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_nqf0053_exclude_procedures_medications\n\n)\n\n, valid_institutional_snp as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n\n and (\n select\n lookback_period_december\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, frailty_patients_within_defined_window as (\n\n select\n frailty_within_defined_window.patient_id\n , frailty_within_defined_window.exclusion_date\n , frailty_within_defined_window.exclusion_reason\n , 'measure specific exclusion for defined window' as exclusion_type\n from frailty_within_defined_window\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n union all\n\n select * from exclusion_procedure_and_medication\n\n union all\n\n select * from frailty_patients_within_defined_window\n\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_long"], "alias": "_int_nqf0053_long", "checksum": {"name": "sha256", "checksum": "5bb485a48e75426dd7ec76f60a36e9ca2cfbd6b430bb835b041abf682cacf616"}, "config": {"enabled": true, "alias": "_int_nqf0053_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.08244, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_nqf0053_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_nqf0053_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf0053_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0053_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0053_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0053_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0053_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053_numerator"], "alias": "_int_nqf0053_numerator", "checksum": {"name": "sha256", "checksum": "9ea6ba4f1b21a9e3d4ed8a3d79a8e23a139d7344833280bad17767288d378b56"}, "config": {"enabled": true, "alias": "_int_nqf0053_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0053, Osteoporosis Management in women who had a fracture\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0724373, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , recorded_date\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ref('quality_measures__int_nqf0053_denominator')}}\r\n\r\n)\r\n\r\n, value_sets as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n \r\n)\r\n\r\n, osteo_procedure_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from value_sets\r\n where lower(concept_name) in (\r\n 'bone mineral density test'\r\n , 'bone mineral density tests cpt'\r\n , 'bone mineral density tests icd10pcs'\r\n , 'bone mineral density tests hcpcs'\r\n , 'dexa dual energy xray absorptiometry, bone density'\r\n , 'central dual energy x-ray absorptiometry (dxa)'\r\n , 'spinal densitometry x-ray' \r\n , 'ultrasonography for densitometry' \r\n , 'ct bone density axial'\r\n , 'peripheral dual-energy x-ray absorptiometry (dxa)'\r\n , 'osteoporosis medication'\r\n )\r\n\r\n)\r\n\r\n, procedures_osteo_related as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n from {{ref('quality_measures__stg_core__procedure')}} as procs\r\n inner join osteo_procedure_codes\r\n on coalesce(procs.normalized_code, procs.source_code) = osteo_procedure_codes.code\r\n and coalesce(procs.normalized_code_type, procs.source_code_type) = osteo_procedure_codes.code_system\r\n\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n procedures_osteo_related.patient_id\r\n , procedures_osteo_related.procedure_date\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , denominator.recorded_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n from procedures_osteo_related\r\n inner join denominator\r\n on procedures_osteo_related.patient_id = denominator.patient_id\r\n and \r\n procedures_osteo_related.procedure_date between\r\n denominator.recorded_date \r\n and\r\n {{dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = +6\r\n , from_date_or_timestamp = \"denominator.recorded_date\"\r\n )\r\n }} \r\n\r\n)\r\n\r\n, denominator_patients_disqualified_from_procedure as (\r\n \r\n select \r\n denominator.patient_id\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , denominator.recorded_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end \r\n from denominator\r\n left join qualifying_procedures \r\n on denominator.patient_id = qualifying_procedures.patient_id\r\n where qualifying_procedures.patient_id is null\r\n\r\n)\r\n\r\n-- pharmacy_claim begin\r\n\r\n, osteo_rx_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from value_sets\r\n where lower(concept_name) \r\n in \r\n ( \r\n 'osteoporosis medications for urology care'\r\n , 'osteoporosis medication'\r\n , 'bisphosphonates'\r\n )\r\n\r\n)\r\n\r\n, pharmacy_claims_osteo_related as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code \r\n from {{ref('quality_measures__stg_pharmacy_claim')}} as pharmacy_claims\r\n inner join osteo_rx_codes\r\n on pharmacy_claims.ndc_code = osteo_rx_codes.code\r\n and lower(osteo_rx_codes.code_system) = 'ndc'\r\n\r\n)\r\n\r\n, qualifying_pharmacy_claims as (\r\n\r\n select \r\n pharmacy_claims_osteo_related.patient_id\r\n , pharmacy_claims_osteo_related.dispensing_date\r\n , pharmacy_claims_osteo_related.ndc_code\r\n , denominator_patients_disqualified_from_procedure.measure_id\r\n , denominator_patients_disqualified_from_procedure.measure_name\r\n , denominator_patients_disqualified_from_procedure.measure_version\r\n , denominator_patients_disqualified_from_procedure.recorded_date\r\n , denominator_patients_disqualified_from_procedure.performance_period_begin\r\n , denominator_patients_disqualified_from_procedure.performance_period_end\r\n from pharmacy_claims_osteo_related\r\n inner join denominator_patients_disqualified_from_procedure\r\n on pharmacy_claims_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\r\n and pharmacy_claims_osteo_related.dispensing_date \r\n between \r\n denominator_patients_disqualified_from_procedure.recorded_date \r\n and \r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = +6\r\n , from_date_or_timestamp = \"denominator_patients_disqualified_from_procedure.recorded_date\"\r\n )\r\n }}\r\n)\r\n\r\n-- medication begin\r\n\r\n, medication_osteo_related as (\r\n\r\n select\r\n patient_id\r\n , encounter_id\r\n , prescribing_date\r\n , dispensing_date\r\n , source_code\r\n , source_code_type\r\n , ndc_code\r\n , rxnorm_code\r\n from {{ref('quality_measures__stg_core__medication')}} as medications\r\n inner join osteo_rx_codes\r\n on medications.source_code = osteo_rx_codes.code\r\n and medications.source_code_type = osteo_rx_codes.code_system\r\n\r\n)\r\n\r\n, qualifying_medications as (\r\n\r\n select\r\n medication_osteo_related.patient_id\r\n , medication_osteo_related.encounter_id\r\n , denominator_patients_disqualified_from_procedure.measure_id\r\n , denominator_patients_disqualified_from_procedure.measure_name\r\n , denominator_patients_disqualified_from_procedure.measure_version\r\n , denominator_patients_disqualified_from_procedure.recorded_date\r\n , denominator_patients_disqualified_from_procedure.performance_period_begin\r\n , denominator_patients_disqualified_from_procedure.performance_period_end\r\n from medication_osteo_related\r\n inner join denominator_patients_disqualified_from_procedure\r\n on medication_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\r\n and coalesce(medication_osteo_related.prescribing_date, medication_osteo_related.dispensing_date) between \r\n denominator_patients_disqualified_from_procedure.recorded_date \r\n and \r\n {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = +6\r\n , from_date_or_timestamp = \"denominator_patients_disqualified_from_procedure.recorded_date\"\r\n )\r\n }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n qualifying_procedures.patient_id\r\n , qualifying_procedures.performance_period_begin\r\n , qualifying_procedures.performance_period_end\r\n , qualifying_procedures.measure_id\r\n , qualifying_procedures.measure_name\r\n , qualifying_procedures.measure_version\r\n , recorded_date as evidence_date\r\n , 1 as numerator_flag\r\n from qualifying_procedures\r\n\r\n union all\r\n\r\n select \r\n qualifying_pharmacy_claims.patient_id\r\n , qualifying_pharmacy_claims.performance_period_begin\r\n , qualifying_pharmacy_claims.performance_period_end\r\n , qualifying_pharmacy_claims.measure_id\r\n , qualifying_pharmacy_claims.measure_name\r\n , qualifying_pharmacy_claims.measure_version\r\n , recorded_date as evidence_date\r\n , 1 as numerator_flag\r\n from qualifying_pharmacy_claims\r\n\r\n union all\r\n\r\n select \r\n qualifying_medications.patient_id\r\n , qualifying_medications.performance_period_begin\r\n , qualifying_medications.performance_period_end\r\n , qualifying_medications.measure_id\r\n , qualifying_medications.measure_name\r\n , qualifying_medications.measure_version\r\n , recorded_date as evidence_date\r\n , 1 as numerator_flag\r\n from qualifying_medications\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from numerator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0053_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , recorded_date\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n \n)\n\n, osteo_procedure_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests icd10pcs'\n , 'bone mineral density tests hcpcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n , 'central dual energy x-ray absorptiometry (dxa)'\n , 'spinal densitometry x-ray' \n , 'ultrasonography for densitometry' \n , 'ct bone density axial'\n , 'peripheral dual-energy x-ray absorptiometry (dxa)'\n , 'osteoporosis medication'\n )\n\n)\n\n, procedures_osteo_related as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procs\n inner join osteo_procedure_codes\n on coalesce(procs.normalized_code, procs.source_code) = osteo_procedure_codes.code\n and coalesce(procs.normalized_code_type, procs.source_code_type) = osteo_procedure_codes.code_system\n\n)\n\n, qualifying_procedures as (\n\n select\n procedures_osteo_related.patient_id\n , procedures_osteo_related.procedure_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from procedures_osteo_related\n inner join denominator\n on procedures_osteo_related.patient_id = denominator.patient_id\n and \n procedures_osteo_related.procedure_date between\n denominator.recorded_date \n and\n \n\n dateadd(\n month,\n 6,\n denominator.recorded_date\n )\n\n \n\n)\n\n, denominator_patients_disqualified_from_procedure as (\n \n select \n denominator.patient_id\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end \n from denominator\n left join qualifying_procedures \n on denominator.patient_id = qualifying_procedures.patient_id\n where qualifying_procedures.patient_id is null\n\n)\n\n-- pharmacy_claim begin\n\n, osteo_rx_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) \n in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, pharmacy_claims_osteo_related as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code \n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join osteo_rx_codes\n on pharmacy_claims.ndc_code = osteo_rx_codes.code\n and lower(osteo_rx_codes.code_system) = 'ndc'\n\n)\n\n, qualifying_pharmacy_claims as (\n\n select \n pharmacy_claims_osteo_related.patient_id\n , pharmacy_claims_osteo_related.dispensing_date\n , pharmacy_claims_osteo_related.ndc_code\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from pharmacy_claims_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on pharmacy_claims_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and pharmacy_claims_osteo_related.dispensing_date \n between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n)\n\n-- medication begin\n\n, medication_osteo_related as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication as medications\n inner join osteo_rx_codes\n on medications.source_code = osteo_rx_codes.code\n and medications.source_code_type = osteo_rx_codes.code_system\n\n)\n\n, qualifying_medications as (\n\n select\n medication_osteo_related.patient_id\n , medication_osteo_related.encounter_id\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from medication_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on medication_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and coalesce(medication_osteo_related.prescribing_date, medication_osteo_related.dispensing_date) between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n\n)\n\n, numerator as (\n\n select\n qualifying_procedures.patient_id\n , qualifying_procedures.performance_period_begin\n , qualifying_procedures.performance_period_end\n , qualifying_procedures.measure_id\n , qualifying_procedures.measure_name\n , qualifying_procedures.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_procedures\n\n union all\n\n select \n qualifying_pharmacy_claims.patient_id\n , qualifying_pharmacy_claims.performance_period_begin\n , qualifying_pharmacy_claims.performance_period_end\n , qualifying_pharmacy_claims.measure_id\n , qualifying_pharmacy_claims.measure_name\n , qualifying_pharmacy_claims.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_pharmacy_claims\n\n union all\n\n select \n qualifying_medications.patient_id\n , qualifying_medications.performance_period_begin\n , qualifying_medications.performance_period_end\n , qualifying_medications.measure_id\n , qualifying_medications.measure_name\n , qualifying_medications.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_medications\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0053__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0053_osteoporosis_management_in_women_who_had_a_fracture", "quality_measures__int_nqf0053__performance_period"], "alias": "_int_nqf0053__performance_period", "checksum": {"name": "sha256", "checksum": "ac54ce769e4046bee490051fafe922f3f68f8db08a3da120dccc2e6240df5ca6"}, "config": {"enabled": true, "alias": "_int_nqf0053__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Osteoporosis Management in women who had a fracture\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0053__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0674376, "relation_name": "dev_thuxuan.quality_measures._int_nqf0053__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0053')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0053')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0053')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\n-- lookback_period for last june 30 and december 31\r\n, lookback_period as (\r\n\r\nSELECT\r\n *\r\n , case\r\n when performance_period_end >= cast(({{ dbt.concat([date_part('year', 'performance_period_end'), \"'-06-30'\"]) }}) as date)\r\n then {{ dbt.concat([date_part('year', 'performance_period_end'), \"'-06-30'\"]) }}\r\n else {{ dbt.concat([date_part('year', 'performance_period_begin'), \"'-06-30'\"]) }}\r\n end as lookback_period_june\r\n , case\r\n when performance_period_end >= cast(({{ dbt.concat([date_part('year', 'performance_period_end'), \"'-12-31'\"]) }}) as date)\r\n then {{ dbt.concat([date_part('year', 'performance_period_end'), \"'-12-31'\"]) }}\r\n else {{ dbt.concat([date_part('year', 'performance_period_begin'), \"'-12-31'\"]) }}\r\n end as lookback_period_december\r\nFROM period_begin\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(lookback_period_june as date) as lookback_period_june\r\n , cast(lookback_period_december as date) as lookback_period_december\r\nfrom lookback_period", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.the_tuva_project.date_part", "macro.dbt.concat", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0053_osteoporosis_management_in_women_who_had_a_fracture\\quality_measures__int_nqf0053__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n-- lookback_period for last june 30 and december 31\n, lookback_period as (\n\nSELECT\n *\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-06-30') as date)\n then date_part('year', performance_period_end) || '-06-30'\n else date_part('year', performance_period_begin) || '-06-30'\n end as lookback_period_june\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-12-31') as date)\n then date_part('year', performance_period_end) || '-12-31'\n else date_part('year', performance_period_begin) || '-12-31'\n end as lookback_period_december\nFROM period_begin\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_june as date) as lookback_period_june\n , cast(lookback_period_december as date) as lookback_period_december\nfrom lookback_period", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_denominator"], "alias": "_int_nqf0059_denominator", "checksum": {"name": "sha256", "checksum": "07b4209efe205f067778e07dcbbb22f9420199c227f495cfcab471bee0dedead"}, "config": {"enabled": true, "alias": "_int_nqf0059_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0059, Diabetes Hemoglobin a1c.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0424376, "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'office visit'\r\n , 'home healthcare services'\r\n , 'preventive care services established office visit, 18 and up'\r\n , 'preventive care services initial office visit, 18 and up'\r\n , 'annual wellness visit'\r\n , 'telephone visits'\r\n , 'nutrition services'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ref('quality_measures__stg_core__encounter')}} encounter\r\n inner join {{ref('quality_measures__int_nqf0059__performance_period')}} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ref('quality_measures__stg_core__procedure')}} procs\r\n inner join {{ref('quality_measures__int_nqf0059__performance_period')}} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\r\n inner join {{ref('quality_measures__int_nqf0059__performance_period')}} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code= visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n select *, 'v' as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n union all\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n union all\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc,cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n)\r\n\r\n, encounters_by_patient as (\r\n select patient_id,min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n)\r\n\r\n, diabetics_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'diabetes'\r\n , 'hba1c laboratory test'\r\n )\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , source_code\r\n , source_code_type\r\n , normalized_code\r\n , normalized_code_type\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, diabetic_conditions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n from conditions\r\n inner join diabetics_codes\r\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\r\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\r\n , max_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\r\n , qualifying_types\r\n from {{ref('quality_measures__stg_core__patient')}} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n diabetic_conditions.patient_id\r\n , patients_with_age.max_age as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from diabetic_conditions\r\n left join patients_with_age\r\n on diabetic_conditions.patient_id = patients_with_age.patient_id\r\n cross join {{ref('quality_measures__int_nqf0059__performance_period')}} pp\r\n where max_age >= 18 and min_age <= 75\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'nutrition services'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0059__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_nqf0059__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0059__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n)\n\n, encounters_by_patient as (\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n , 'hba1c laboratory test'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_nqf0059__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_exclusions"], "alias": "_int_nqf0059_exclusions", "checksum": {"name": "sha256", "checksum": "ea896de807aed1b1ef46709b24cf36e6affcbcfcda625f4649e713919ce46b59"}, "config": {"enabled": true, "alias": "_int_nqf0059_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0059, Diabetes Hemoglobin a1c.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0454369, "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0059__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf0059__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith frailty as (\r\n\r\n select\r\n *\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n-- advanced illness start\r\n, advanced_illness_exclusion as (\r\n\r\n select\r\n source.*\r\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where source.exclusion_date\r\n between\r\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\r\n and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, acute_inpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'acute_inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'nonacute_outpatient'\r\n\r\n)\r\n\r\n, acute_inpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from acute_inpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, nonacute_outpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from nonacute_outpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, valid_advanced_illness_exclusions as (\r\n\r\n select\r\n acute_inpatient_advanced_illness.patient_id\r\n , acute_inpatient_advanced_illness.exclusion_date\r\n , acute_inpatient_advanced_illness.exclusion_reason\r\n , acute_inpatient_advanced_illness.exclusion_type\r\n from acute_inpatient_advanced_illness\r\n left join acute_inpatient_counts\r\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\r\n where acute_inpatient_counts.encounter_count >= 1\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient_advanced_illness.patient_id\r\n , nonacute_outpatient_advanced_illness.exclusion_date\r\n , nonacute_outpatient_advanced_illness.exclusion_reason\r\n , nonacute_outpatient_advanced_illness.exclusion_type\r\n from nonacute_outpatient_advanced_illness\r\n left join nonacute_outpatient_counts\r\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\r\n where nonacute_outpatient_counts.encounter_count >= 2\r\n\r\n\r\n)\r\n-- advanced illness end\r\n\r\n, valid_dementia_exclusions as (\r\n\r\n select\r\n source.patient_id\r\n , source.exclusion_date\r\n , source.exclusion_reason\r\n , source.exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where (\r\n source.dispensing_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n or source.paid_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n )\r\n\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_institutional_snp as (\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select * from valid_advanced_illness_exclusions\r\n union all\r\n select * from valid_dementia_exclusions\r\n union all\r\n select * from valid_hospice_palliative\r\n union all\r\n select * from valid_institutional_snp\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select \r\n exclusions.*\r\n , denominator.age\r\n from exclusions\r\n inner join {{ref('quality_measures__int_nqf0059_denominator')}} as denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type != 'hospice_palliative'\r\n and age >= 66\r\n\r\n union all\r\n\r\n select\r\n *\r\n from combined_exclusions\r\n where exclusion_type = 'hospice_palliative'\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_nqf0059_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join dev_thuxuan.quality_measures._int_nqf0059_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_long"], "alias": "_int_nqf0059_long", "checksum": {"name": "sha256", "checksum": "6f66679db6b9ea87109f1613817c34d56ba13599f5a14bdd87f90ac962472fbc"}, "config": {"enabled": true, "alias": "_int_nqf0059_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0059,Diabetes Hemoglobin a1c before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0474377, "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_nqf0059_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_nqf0059_numerator') }}\r\n where numerator_flag = 1\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf0059_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0059_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0059_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0059_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0059_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0059_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0059_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059_numerator"], "alias": "_int_nqf0059_numerator", "checksum": {"name": "sha256", "checksum": "2b539bde6e48b49ab22d26cf27cce84e0a6eb49dffece4113521568cb7bfd4df"}, "config": {"enabled": true, "alias": "_int_nqf0059_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0059, Diabetes Hemoglobin a1c.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0504375, "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_nqf0059_denominator') }}\r\n\r\n)\r\n\r\n, hba1c_test_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n From {{ref('quality_measures__value_sets')}}\r\n where lower(concept_name) in (\r\n 'hba1c laboratory test'\r\n )\r\n\r\n)\r\n\r\n, labs as (\r\n\r\n select\r\n patient_id\r\n , result\r\n , result_date\r\n , collection_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n from {{ ref('quality_measures__stg_core__lab_result')}}\r\n\r\n)\r\n\r\n, qualifying_labs as (\r\n\r\n select\r\n labs.patient_id\r\n , labs.result as evidence_value\r\n , coalesce(collection_date,result_date) as evidence_date\r\n , hba1c_test_code.concept_name\r\n , row_number() over(partition by labs.patient_id order by coalesce(collection_date,result_date) desc) as rn\r\n from labs\r\n inner join hba1c_test_code\r\n on coalesce(labs.normalized_code, labs.source_code) = hba1c_test_code.code\r\n and coalesce(labs.normalized_code_type, labs.source_code_type) = hba1c_test_code.code_system\r\n left join denominator\r\n on labs.patient_id = denominator.patient_id\r\n where coalesce(collection_date,result_date) <= denominator.performance_period_end\r\n {% if target.type == 'fabric' %}\r\n and result LIKE '%.%' OR result LIKE '%[0-9]%'\r\n AND result NOT LIKE '%[^0-9.]%'\r\n {% else %}\r\n and {{ apply_regex('result', '^[+-]?([0-9]*[.])?[0-9]+$') }}\r\n {% endif %}\r\n\r\n)\r\n\r\n, recent_readings as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from qualifying_labs\r\n where rn = 1\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n denominator.*\r\n , recent_readings.evidence_date\r\n , recent_readings.evidence_value\r\n from denominator\r\n left join recent_readings\r\n on denominator.patient_id = recent_readings.patient_id\r\n\r\n)\r\n\r\n, test_not_performed as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , 1 as numerator_flag\r\n from qualifying_patients\r\n where\r\n (evidence_date not between performance_period_begin and performance_period_end)\r\n or evidence_date is null\r\n\r\n)\r\n\r\n, valid_patients as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , case\r\n when cast(evidence_value as {{ dbt.type_numeric() }}) > 9.0 then 1\r\n else 0\r\n end as numerator_flag\r\n from qualifying_patients\r\n where evidence_date between performance_period_begin and performance_period_end\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select * from valid_patients\r\n\r\n union all\r\n\r\n select * from test_not_performed\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from numerator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0059_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.apply_regex", "macro.dbt.type_numeric", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0059_denominator\n\n)\n\n, hba1c_test_code as (\n\n select\n code\n , code_system\n , concept_name\n From dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hba1c laboratory test'\n )\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_labs as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date,result_date) as evidence_date\n , hba1c_test_code.concept_name\n , row_number() over(partition by labs.patient_id order by coalesce(collection_date,result_date) desc) as rn\n from labs\n inner join hba1c_test_code\n on coalesce(labs.normalized_code, labs.source_code) = hba1c_test_code.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = hba1c_test_code.code_system\n left join denominator\n on labs.patient_id = denominator.patient_id\n where coalesce(collection_date,result_date) <= denominator.performance_period_end\n \n and regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, recent_readings as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from qualifying_labs\n where rn = 1\n\n)\n\n, qualifying_patients as (\n\n select\n denominator.*\n , recent_readings.evidence_date\n , recent_readings.evidence_value\n from denominator\n left join recent_readings\n on denominator.patient_id = recent_readings.patient_id\n\n)\n\n, test_not_performed as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from qualifying_patients\n where\n (evidence_date not between performance_period_begin and performance_period_end)\n or evidence_date is null\n\n)\n\n, valid_patients as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , case\n when cast(evidence_value as numeric(28,6)) > 9.0 then 1\n else 0\n end as numerator_flag\n from qualifying_patients\n where evidence_date between performance_period_begin and performance_period_end\n\n)\n\n, numerator as (\n\n select * from valid_patients\n\n union all\n\n select * from test_not_performed\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "sql": " __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0059__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0059_diabetes_hemoglobin_a1c", "quality_measures__int_nqf0059__performance_period"], "alias": "_int_nqf0059__performance_period", "checksum": {"name": "sha256", "checksum": "f13d1c4bf53ca57e3a1841574bb22dcef8a630be9a41d57290d3f6981797c0a0"}, "config": {"enabled": true, "alias": "_int_nqf0059__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Diabetes Hemoglobin a1c.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0059__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0404375, "relation_name": "dev_thuxuan.quality_measures._int_nqf0059__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r | as_bool\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0059')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0059')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0059')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0059_diabetes_hemoglobin_a1c\\quality_measures__int_nqf0059__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_denominator"], "alias": "_int_nqf0420_denominator", "checksum": {"name": "sha256", "checksum": "8c5405107ff36888f702f97c88925011a90956f9a6330222704c096d6b17d924"}, "config": {"enabled": true, "alias": "_int_nqf0420_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 0420, Pain Assessment and Follow-Up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during latest encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1830175, "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'home healthcare services'\r\n , 'office visit'\r\n , 'encounter to document medications'\r\n , 'psychological and/or neuropsychological test administration'\r\n )\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select \r\n patient_id\r\n , coalesce(encounter.encounter_start_date, encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date, encounter.encounter_start_date) as max_date\r\n from {{ ref('quality_measures__stg_core__encounter') }} encounter\r\n inner join {{ ref('quality_measures__int_nqf0420__performance_period') }} as pp\r\n on coalesce(encounter.encounter_end_date, encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date, encounter.encounter_end_date) <= pp.performance_period_end\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n where coalesce(modifier_1, '') not in ('GQ', 'GT', '95')\r\n and coalesce(modifier_2, '') not in ('GQ', 'GT', '95')\r\n and coalesce(modifier_3, '') not in ('GQ', 'GT', '95')\r\n and coalesce(modifier_4, '') not in ('GQ', 'GT', '95')\r\n and coalesce(modifier_5, '') not in ('GQ', 'GT', '95')\r\n\r\n)\r\n\r\n, claims as (\r\n\r\n select \r\n patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n where coalesce(hcpcs_modifier_1, '') not in ('GQ', 'GT', '95')\r\n and coalesce(hcpcs_modifier_2, '') not in ('GQ', 'GT', '95')\r\n and coalesce(hcpcs_modifier_3, '') not in ('GQ', 'GT', '95')\r\n and coalesce(hcpcs_modifier_4, '') not in ('GQ', 'GT', '95')\r\n and coalesce(hcpcs_modifier_5, '') not in ('GQ', 'GT', '95')\r\n and coalesce(place_of_service_code, '') not in ('02')\r\n \r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n procedures.patient_id\r\n , procedures.procedure_date as min_date\r\n , procedures.procedure_date as max_date\r\n from procedures\r\n inner join {{ ref('quality_measures__int_nqf0420__performance_period') }} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join visit_codes\r\n on procedures.code = visit_codes.code\r\n and procedures.code_type = visit_codes.code_system\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select \r\n claims.patient_id\r\n , claims.min_date\r\n , claims.max_date\r\n from claims\r\n inner join {{ ref('quality_measures__int_nqf0420__performance_period') }} as pp \r\n on claims.max_date >= pp.performance_period_begin\r\n and claims.min_date <= pp.performance_period_end\r\n inner join visit_codes\r\n on claims.hcpcs_code = visit_codes.code\r\n and visit_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select *, 'v' as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, 'p' as proc_enc, cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select *, cast(null as {{ dbt.type_string() }}) as visit_enc, cast(null as {{ dbt.type_string() }}) as proc_enc, 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select \r\n patient_id\r\n , max(max_date) max_date\r\n , {{ dbt.concat([\r\n \"coalesce(min(visit_enc), '')\"\r\n , \"coalesce(min(proc_enc), '')\"\r\n , \"coalesce(min(claim_enc), '')\"\r\n ]) }} as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\r\n , qualifying_types\r\n from {{ ref('quality_measures__stg_core__patient') }} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n patient_id\r\n , max_age as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , 1 as denominator_flag\r\n from patients_with_age\r\n cross join {{ ref('quality_measures__int_nqf0420__performance_period') }} pp\r\n where max_age >= 18\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.concat", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'home healthcare services'\n , 'office visit'\n , 'encounter to document medications'\n , 'psychological and/or neuropsychological test administration'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date, encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date, encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0420__performance_period as pp\n on coalesce(encounter.encounter_end_date, encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date, encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where coalesce(modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_5, '') not in ('GQ', 'GT', '95')\n\n)\n\n, claims as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(hcpcs_modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_5, '') not in ('GQ', 'GT', '95')\n and coalesce(place_of_service_code, '') not in ('02')\n \n)\n\n, procedure_encounters as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as min_date\n , procedures.procedure_date as max_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_nqf0420__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n claims.patient_id\n , claims.min_date\n , claims.max_date\n from claims\n inner join dev_thuxuan.quality_measures._int_nqf0420__performance_period as pp \n on claims.max_date >= pp.performance_period_begin\n and claims.min_date <= pp.performance_period_end\n inner join visit_codes\n on claims.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select \n patient_id\n , max(max_date) max_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patient_id\n , max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_nqf0420__performance_period pp\n where max_age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_exclusions"], "alias": "_int_nqf0420_exclusions", "checksum": {"name": "sha256", "checksum": "672cb086e422f0fe5ae6894b09e9fc3341719bda08f2bafe4cf8554b4513f6e9"}, "config": {"enabled": true, "alias": "_int_nqf0420_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0420, Pain Assessment and Follow-Up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1860173, "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0420__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf0420__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith denominator as (\r\n \r\n select\r\n patient_id\r\n from {{ ref('quality_measures__int_nqf0420_denominator') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'patient is not eligible for a pain assessment'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n where procedure_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n where coalesce(claim_end_date, claim_start_date) between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name as concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name as concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n and exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, patients_with_exclusions as(\r\n \r\n select\r\n patient_id\r\n , exclusion_date\r\n , concept_name as exclusion_reason\r\n from med_claim_exclusions\r\n\r\n union all\r\n\r\n select \r\n patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select \r\n patients_with_exclusions.patient_id\r\n , patients_with_exclusions.exclusion_date\r\n , patients_with_exclusions.exclusion_reason \r\n from patients_with_exclusions\r\n inner join denominator\r\n on patients_with_exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(1 as integer) as exclusion_flag\r\n from valid_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run') }}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_exclusions.sql", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0420_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'patient is not eligible for a pain assessment'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as(\n \n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_long"], "alias": "_int_nqf0420_long", "checksum": {"name": "sha256", "checksum": "1bee0d1078340a5a4d83f8b05d19b3dfdf30529da94c9a1813a5cb272f274c96"}, "config": {"enabled": true, "alias": "_int_nqf0420_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0420, Pain Assessment and Follow-Up before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1880174, "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_nqf0420_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_nqf0420_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf0420_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0420_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0420_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0420_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0420_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0420_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0420_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420_numerator"], "alias": "_int_nqf0420_numerator", "checksum": {"name": "sha256", "checksum": "f7bb1eadf205104734c08966a64a2de227eb24513919c79ec0b742817bf709c5"}, "config": {"enabled": true, "alias": "_int_nqf0420_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0420, Pain Assessment and Follow-Up.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.191017, "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select \r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_nqf0420_denominator') }}\r\n\r\n)\r\n\r\n, pain_assessment_code as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'pain assessment documented'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, pain_assessment_procedures as (\r\n\r\n select \r\n procedures.patient_id\r\n , procedures.procedure_date as evidence_date\r\n from procedures\r\n inner join pain_assessment_code\r\n on procedures.code = pain_assessment_code.code\r\n and procedures.code_type = pain_assessment_code.code_system\r\n\r\n)\r\n\r\n, pain_assessment_claims as (\r\n\r\n select\r\n patient_id\r\n , coalesce(claim_end_date, claim_start_date) as evidence_date\r\n from {{ ref('quality_measures__stg_medical_claim') }} medical_claim\r\n inner join pain_assessment_code\r\n on medical_claim.hcpcs_code = pain_assessment_code.code\r\n and lower(pain_assessment_code.code_system) = 'hcpcs'\r\n\r\n)\r\n\r\n, time_unbounded_qualifying_patients as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from pain_assessment_procedures\r\n \r\n union all\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n from pain_assessment_claims\r\n\r\n)\r\n\r\n, qualifying_patients_with_denominator as (\r\n\r\n select \r\n time_unbounded_qualifying_patients.patient_id\r\n , time_unbounded_qualifying_patients.evidence_date\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , 1 as numerator_flag\r\n from time_unbounded_qualifying_patients\r\n inner join denominator\r\n on time_unbounded_qualifying_patients.patient_id = denominator.patient_id\r\n and time_unbounded_qualifying_patients.evidence_date between\r\n denominator.performance_period_begin and denominator.performance_period_end\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from qualifying_patients_with_denominator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0420_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0420_denominator\n\n)\n\n, pain_assessment_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pain assessment documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pain_assessment_procedures as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join pain_assessment_code\n on procedures.code = pain_assessment_code.code\n and procedures.code_type = pain_assessment_code.code_system\n\n)\n\n, pain_assessment_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join pain_assessment_code\n on medical_claim.hcpcs_code = pain_assessment_code.code\n and lower(pain_assessment_code.code_system) = 'hcpcs'\n\n)\n\n, time_unbounded_qualifying_patients as (\n\n select\n patient_id\n , evidence_date\n from pain_assessment_procedures\n \n union all\n\n select\n patient_id\n , evidence_date\n from pain_assessment_claims\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n time_unbounded_qualifying_patients.patient_id\n , time_unbounded_qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from time_unbounded_qualifying_patients\n inner join denominator\n on time_unbounded_qualifying_patients.patient_id = denominator.patient_id\n and time_unbounded_qualifying_patients.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0420__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf0420_pain_assessment_and_follow_up", "quality_measures__int_nqf0420__performance_period"], "alias": "_int_nqf0420__performance_period", "checksum": {"name": "sha256", "checksum": "43cb09b3af3f5d8accf6d85d08e6af01162f4347753a8fa987f93a4dbdce85b1"}, "config": {"enabled": true, "alias": "_int_nqf0420__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Pain Assessment and Follow-Up.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0420__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1810176, "relation_name": "dev_thuxuan.quality_measures._int_nqf0420__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0420')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0420')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0420')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to following day of 1 year prior\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf0420_pain_assessment_and_follow_up\\quality_measures__int_nqf0420__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_denominator"], "alias": "_int_nqf2372_denominator", "checksum": {"name": "sha256", "checksum": "7c24a51179f4d010ee1881f27881bea8fe33f68c6a41376f4d3ba1e77971cb54"}, "config": {"enabled": true, "alias": "_int_nqf2372_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age as of the performance_period_begin date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_lookback": {"name": "performance_period_lookback", "description": "Lookback period of NQF2372.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0134373, "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith performance_period as (\r\n\r\n select\r\n measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_end\r\n , performance_period_begin\r\n , performance_period_lookback\r\n from {{ ref('quality_measures__int_nqf2372__performance_period') }}\r\n\r\n)\r\n\r\n, patient as (\r\n\r\n select\r\n patient_id\r\n , sex\r\n , birth_date\r\n , death_date\r\n from {{ ref('quality_measures__stg_core__patient') }}\r\n\r\n)\r\n\r\n, encounters as (\r\n\r\n select\r\n patient_id\r\n , encounter_type\r\n , encounter_start_date\r\n from {{ ref('quality_measures__stg_core__encounter') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, visit_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where concept_name in (\r\n 'Office Visit'\r\n , 'Home Healthcare Services'\r\n , 'Preventive Care Services Established Office Visit, 18 and Up'\r\n , 'Preventive Care Services Initial Office Visit, 18 and Up'\r\n , 'Annual Wellness Visit'\r\n , 'Telephone Visits'\r\n , 'Online Assessments'\r\n )\r\n\r\n)\r\n\r\n, patient_with_age as (\r\n\r\n select\r\n patient.patient_id\r\n , patient.sex\r\n , patient.birth_date\r\n , patient.death_date\r\n , performance_period.measure_id\r\n , performance_period.measure_name\r\n , performance_period.measure_version\r\n , performance_period.performance_period_begin\r\n , performance_period.performance_period_end\r\n , performance_period.performance_period_lookback\r\n , floor({{ datediff('patient.birth_date', 'performance_period.performance_period_begin', 'hour') }} / 8760.0) as age -- 365*24 hours in a year\r\n from patient\r\n cross join performance_period\r\n\r\n)\r\n\r\n/*\r\n Filter patient to living women 51 - 74 years of age\r\n at the beginning of the measurement period\r\n*/\r\n, patient_filtered as (\r\n\r\n select\r\n patient_id\r\n , age\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , performance_period_begin\r\n , performance_period_end\r\n , performance_period_lookback\r\n , 1 as denominator_flag\r\n from patient_with_age\r\n where lower(sex) = 'female'\r\n and age between 51 and 74\r\n and death_date is null\r\n\r\n)\r\n\r\n/*\r\n Filter to qualifying visit types by claim procedures\r\n*/\r\n, visit_claims as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n , medical_claim.hcpcs_code\r\n from medical_claim\r\n inner join visit_codes\r\n on medical_claim.hcpcs_code = visit_codes.code\r\n where visit_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n/*\r\n Filter encounters to qualifying visit type\r\n*/\r\n, visit_encounters as (\r\n\r\n select\r\n patient_id\r\n , encounter_start_date\r\n from encounters\r\n where lower(encounter_type) in (\r\n 'home health'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'outpatient rehabilitation'\r\n , 'telehealth'\r\n )\r\n\r\n)\r\n\r\n/*\r\n Filter to qualifying visit types by procedure\r\n*/\r\n, visit_procedures as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n from procedures\r\n inner join visit_codes\r\n on procedures.code = visit_codes.code\r\n and procedures.code_type = visit_codes.code_system\r\n\r\n)\r\n\r\n/*\r\n Filter to final eligible population/denominator before exclusions\r\n with a qualifying visit during the measurement period\r\n*/\r\n, eligible_population as (\r\n\r\n select\r\n patient_filtered.patient_id\r\n , patient_filtered.age\r\n , patient_filtered.measure_id\r\n , patient_filtered.measure_name\r\n , patient_filtered.measure_version\r\n , patient_filtered.performance_period_begin\r\n , patient_filtered.performance_period_end\r\n , performance_period_lookback\r\n , patient_filtered.denominator_flag\r\n from patient_filtered\r\n left join visit_claims\r\n on patient_filtered.patient_id = visit_claims.patient_id\r\n left join visit_procedures\r\n on patient_filtered.patient_id = visit_procedures.patient_id\r\n left join visit_encounters\r\n on patient_filtered.patient_id = visit_encounters.patient_id\r\n where (\r\n visit_claims.claim_start_date\r\n between patient_filtered.performance_period_begin\r\n and patient_filtered.performance_period_end\r\n or visit_claims.claim_end_date\r\n between patient_filtered.performance_period_begin\r\n and patient_filtered.performance_period_end\r\n or visit_procedures.procedure_date\r\n between patient_filtered.performance_period_begin\r\n and patient_filtered.performance_period_end\r\n or visit_encounters.encounter_start_date\r\n between patient_filtered.performance_period_begin\r\n and patient_filtered.performance_period_end\r\n )\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(performance_period_lookback as date) as performance_period_lookback\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from eligible_population\r\n\r\n)\r\n\r\n select distinct\r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , performance_period_lookback\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n , performance_period_lookback\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n, patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n from __dbt__cte___stg_encounter\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name in (\n 'Office Visit'\n , 'Home Healthcare Services'\n , 'Preventive Care Services Established Office Visit, 18 and Up'\n , 'Preventive Care Services Initial Office Visit, 18 and Up'\n , 'Annual Wellness Visit'\n , 'Telephone Visits'\n , 'Online Assessments'\n )\n\n)\n\n, patient_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , patient.birth_date\n , patient.death_date\n , performance_period.measure_id\n , performance_period.measure_name\n , performance_period.measure_version\n , performance_period.performance_period_begin\n , performance_period.performance_period_end\n , performance_period.performance_period_lookback\n , floor(datediff(\n hour,\n patient.birth_date,\n performance_period.performance_period_begin\n ) / 8760.0) as age -- 365*24 hours in a year\n from patient\n cross join performance_period\n\n)\n\n/*\n Filter patient to living women 51 - 74 years of age\n at the beginning of the measurement period\n*/\n, patient_filtered as (\n\n select\n patient_id\n , age\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , 1 as denominator_flag\n from patient_with_age\n where lower(sex) = 'female'\n and age between 51 and 74\n and death_date is null\n\n)\n\n/*\n Filter to qualifying visit types by claim procedures\n*/\n, visit_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n from medical_claim\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n where visit_codes.code_system = 'hcpcs'\n\n)\n\n/*\n Filter encounters to qualifying visit type\n*/\n, visit_encounters as (\n\n select\n patient_id\n , encounter_start_date\n from encounters\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n/*\n Filter to qualifying visit types by procedure\n*/\n, visit_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n/*\n Filter to final eligible population/denominator before exclusions\n with a qualifying visit during the measurement period\n*/\n, eligible_population as (\n\n select\n patient_filtered.patient_id\n , patient_filtered.age\n , patient_filtered.measure_id\n , patient_filtered.measure_name\n , patient_filtered.measure_version\n , patient_filtered.performance_period_begin\n , patient_filtered.performance_period_end\n , performance_period_lookback\n , patient_filtered.denominator_flag\n from patient_filtered\n left join visit_claims\n on patient_filtered.patient_id = visit_claims.patient_id\n left join visit_procedures\n on patient_filtered.patient_id = visit_procedures.patient_id\n left join visit_encounters\n on patient_filtered.patient_id = visit_encounters.patient_id\n where (\n visit_claims.claim_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_claims.claim_end_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_procedures.procedure_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_encounters.encounter_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n )\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_lookback as date) as performance_period_lookback\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from eligible_population\n\n)\n\n select distinct\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_exclude_mastectomy", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_exclude_mastectomy.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_exclude_mastectomy.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_exclude_mastectomy"], "alias": "_int_nqf2372_exclude_mastectomy", "checksum": {"name": "sha256", "checksum": "cbeec7a759b67ead397c2973b62195cf910802220a0cf4dd967e1591d4853459"}, "config": {"enabled": true, "alias": "_int_nqf2372_exclude_mastectomy", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with a mastectomy for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_exclude_mastectomy", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0154374, "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_exclude_mastectomy", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\n Women who had a bilateral mastectomy or who have a history of a bilateral\r\n mastectomy or for whom there is evidence of a right and a left\r\n unilateral mastectomy\r\n*/\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n from {{ ref('quality_measures__int_nqf2372_denominator') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where concept_name in (\r\n 'Bilateral Mastectomy'\r\n , 'History of bilateral mastectomy'\r\n , 'Status Post Left Mastectomy'\r\n , 'Status Post Right Mastectomy'\r\n , 'Unilateral Mastectomy Left'\r\n , 'Unilateral Mastectomy Right'\r\n , 'Unilateral Mastectomy, Unspecified Laterality'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, observation_exclusions as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , exclusion_codes.concept_name\r\n from observations\r\n inner join exclusion_codes\r\n on observations.code = exclusion_codes.code\r\n and observations.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, all_mastectomy as (\r\n\r\n select\r\n denominator.patient_id\r\n , condition_exclusions.recorded_date as exclusion_date\r\n , condition_exclusions.concept_name as exclusion_reason\r\n from denominator\r\n inner join condition_exclusions\r\n on denominator.patient_id = condition_exclusions.patient_id\r\n\r\n union all\r\n\r\n select\r\n denominator.patient_id\r\n , observation_exclusions.observation_date as exclusion_date\r\n , observation_exclusions.concept_name as exclusion_reason\r\n from denominator\r\n inner join observation_exclusions\r\n on denominator.patient_id = observation_exclusions.patient_id\r\n\r\n union all\r\n\r\n select\r\n denominator.patient_id\r\n , procedure_exclusions.procedure_date as exclusion_date\r\n , procedure_exclusions.concept_name as exclusion_reason\r\n from denominator\r\n inner join procedure_exclusions\r\n on denominator.patient_id = procedure_exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Women who had a bilateral mastectomy or who have a history of a bilateral\r\n mastectomy\r\n*/\r\n, bilateral_mastectomy as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from all_mastectomy\r\n where exclusion_reason in (\r\n 'Bilateral Mastectomy'\r\n , 'History of bilateral mastectomy'\r\n )\r\n\r\n)\r\n\r\n, right_mastectomy as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from all_mastectomy\r\n where exclusion_reason in (\r\n 'Status Post Right Mastectomy'\r\n , 'Unilateral Mastectomy Right'\r\n )\r\n\r\n)\r\n\r\n, left_mastectomy as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from all_mastectomy\r\n where exclusion_reason in (\r\n 'Status Post Left Mastectomy'\r\n , 'Unilateral Mastectomy Left'\r\n )\r\n\r\n)\r\n\r\n, unspecified_mastectomy as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from all_mastectomy\r\n where exclusion_reason in (\r\n 'Unilateral Mastectomy, Unspecified Laterality'\r\n )\r\n\r\n)\r\n\r\n/*\r\n Women for whom there is evidence of a right AND a left unilateral mastectomy\r\n or unspecific mastectomies on different dates\r\n*/\r\n, unilateral_mastectomy as (\r\n\r\n select\r\n right_mastectomy.patient_id\r\n , right_mastectomy.exclusion_date\r\n , right_mastectomy.exclusion_reason\r\n from right_mastectomy\r\n inner join left_mastectomy\r\n on right_mastectomy.patient_id = left_mastectomy.patient_id\r\n\r\n union all\r\n\r\n select\r\n unspecified_mastectomy.patient_id\r\n , unspecified_mastectomy.exclusion_date\r\n , unspecified_mastectomy.exclusion_reason\r\n from unspecified_mastectomy\r\n inner join unspecified_mastectomy as self_join\r\n on unspecified_mastectomy.patient_id = self_join.patient_id\r\n and unspecified_mastectomy.exclusion_date <> self_join.exclusion_date\r\n\r\n)\r\n\r\n, unioned as (\r\n\r\n select * from bilateral_mastectomy\r\n union all\r\n select * from unilateral_mastectomy\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom unioned", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_exclude_mastectomy.sql", "compiled": true, "compiled_code": "\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy or for whom there is evidence of a right and a left\n unilateral mastectomy\n*/\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n , 'Status Post Left Mastectomy'\n , 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Left'\n , 'Unilateral Mastectomy Right'\n , 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, all_mastectomy as (\n\n select\n denominator.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from denominator\n inner join condition_exclusions\n on denominator.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from denominator\n inner join observation_exclusions\n on denominator.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from denominator\n inner join procedure_exclusions\n on denominator.patient_id = procedure_exclusions.patient_id\n\n)\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy\n*/\n, bilateral_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n )\n\n)\n\n, right_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Right'\n )\n\n)\n\n, left_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Left Mastectomy'\n , 'Unilateral Mastectomy Left'\n )\n\n)\n\n, unspecified_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n/*\n Women for whom there is evidence of a right AND a left unilateral mastectomy\n or unspecific mastectomies on different dates\n*/\n, unilateral_mastectomy as (\n\n select\n right_mastectomy.patient_id\n , right_mastectomy.exclusion_date\n , right_mastectomy.exclusion_reason\n from right_mastectomy\n inner join left_mastectomy\n on right_mastectomy.patient_id = left_mastectomy.patient_id\n\n union all\n\n select\n unspecified_mastectomy.patient_id\n , unspecified_mastectomy.exclusion_date\n , unspecified_mastectomy.exclusion_reason\n from unspecified_mastectomy\n inner join unspecified_mastectomy as self_join\n on unspecified_mastectomy.patient_id = self_join.patient_id\n and unspecified_mastectomy.exclusion_date <> self_join.exclusion_date\n\n)\n\n, unioned as (\n\n select * from bilateral_mastectomy\n union all\n select * from unilateral_mastectomy\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_exclusions"], "alias": "_int_nqf2372_exclusions", "checksum": {"name": "sha256", "checksum": "0599c399c1615fecc7c447c26c22bcda6f8241d74c87256e7640c34ee10e0a03"}, "config": {"enabled": true, "alias": "_int_nqf2372_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0184402, "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf2372__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf2372__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith frailty as (\r\n\r\n select\r\n *\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_mastectomy_patients as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf2372_exclude_mastectomy') }}\r\n)\r\n\r\n, valid_hospice_palliative as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where lower(exclusion_reason) in \r\n (\r\n 'palliative care encounter'\r\n , 'palliative care intervention'\r\n , 'hospice care ambulatory'\r\n , 'hospice encounter'\r\n )\r\n and\r\n exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_institutional_snp as (\r\n\r\n select \r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_institutional_snp')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, valid_dementia_exclusions as (\r\n\r\n select\r\n source.patient_id\r\n , source.exclusion_date\r\n , source.exclusion_reason\r\n , source.exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_dementia')}} source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where (\r\n source.dispensing_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n or source.paid_date\r\n between {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp= performance_period_begin ) }}\r\n and {{ performance_period_end }}\r\n )\r\n\r\n)\r\n\r\n-- advanced illness start\r\n, advanced_illness_exclusion as (\r\n\r\n select\r\n source.*\r\n from {{ ref('quality_measures__int_shared_exclusions_advanced_illness') }} as source\r\n inner join frailty\r\n on source.patient_id = frailty.patient_id\r\n where source.exclusion_date\r\n between\r\n {{ dbt.dateadd(datepart=\"year\", interval=-1, from_date_or_timestamp=performance_period_begin) }}\r\n and {{ performance_period_end }}\r\n\r\n)\r\n\r\n, acute_inpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'acute_inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient_advanced_illness as (\r\n\r\n select\r\n *\r\n from advanced_illness_exclusion\r\n where patient_type = 'nonacute_outpatient'\r\n\r\n)\r\n\r\n, acute_inpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from acute_inpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, nonacute_outpatient_counts as (\r\n\r\n select\r\n patient_id\r\n , exclusion_type\r\n , count(distinct exclusion_date) as encounter_count\r\n from nonacute_outpatient_advanced_illness\r\n group by patient_id, exclusion_type\r\n\r\n)\r\n\r\n, valid_advanced_illness_exclusions as (\r\n\r\n select\r\n acute_inpatient_advanced_illness.patient_id\r\n , acute_inpatient_advanced_illness.exclusion_date\r\n , acute_inpatient_advanced_illness.exclusion_reason\r\n , acute_inpatient_advanced_illness.exclusion_type\r\n from acute_inpatient_advanced_illness\r\n left join acute_inpatient_counts\r\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\r\n where acute_inpatient_counts.encounter_count >= 1\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient_advanced_illness.patient_id\r\n , nonacute_outpatient_advanced_illness.exclusion_date\r\n , nonacute_outpatient_advanced_illness.exclusion_reason\r\n , nonacute_outpatient_advanced_illness.exclusion_type\r\n from nonacute_outpatient_advanced_illness\r\n left join nonacute_outpatient_counts\r\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\r\n where nonacute_outpatient_counts.encounter_count >= 2\r\n\r\n)\r\n-- advanced illness end\r\n\r\n, valid_mastectomy_patients_with_exclusion_type as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'mastectomy_performed' as exclusion_type\r\n from valid_mastectomy_patients\r\n)\r\n\r\n, exclusions as (\r\n\r\n select * from valid_advanced_illness_exclusions\r\n\r\n union all\r\n\r\n select * from valid_dementia_exclusions\r\n\r\n union all\r\n\r\n select * from valid_institutional_snp\r\n\r\n union all\r\n\r\n select * from valid_hospice_palliative\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select \r\n exclusions.*\r\n , denominator.age\r\n from exclusions\r\n inner join {{ ref('quality_measures__int_nqf2372_denominator') }} denominator\r\n on exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, valid_exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from combined_exclusions\r\n where exclusion_type != 'hospice_palliative' \r\n and age >= 66\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from combined_exclusions\r\n where exclusion_type = 'hospice_palliative'\r\n\r\n)\r\n\r\n, valid_exclusions_with_mastectomy as (\r\n\r\n select *\r\n from valid_exclusions\r\n\r\n union all\r\n\r\n select *\r\n from valid_mastectomy_patients_with_exclusion_type\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from valid_exclusions_with_mastectomy\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_exclude_mastectomy", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_institutional_snp", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_dementia", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_advanced_illness", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_nqf2372_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_exclusions.sql", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_mastectomy_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf2372_exclude_mastectomy\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n and\n exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n)\n-- advanced illness end\n\n, valid_mastectomy_patients_with_exclusion_type as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'mastectomy_performed' as exclusion_type\n from valid_mastectomy_patients\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join dev_thuxuan.quality_measures._int_nqf2372_denominator denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type != 'hospice_palliative' \n and age >= 66\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, valid_exclusions_with_mastectomy as (\n\n select *\n from valid_exclusions\n\n union all\n\n select *\n from valid_mastectomy_patients_with_exclusion_type\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions_with_mastectomy\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_long"], "alias": "_int_nqf2372_long", "checksum": {"name": "sha256", "checksum": "371b4f064dc7ee6f479ec03094283c0327b89ca377b5eb0d0e0c94983d265e52"}, "config": {"enabled": true, "alias": "_int_nqf2372_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 2372, Breast Cancer Screening before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0204403, "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_nqf2372_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , numerator_flag\r\n from {{ ref('quality_measures__int_nqf2372_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n from {{ ref('quality_measures__int_nqf2372_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then denominator.denominator_flag\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null\r\n then numerator.numerator_flag\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null\r\n then exclusions.exclusion_flag\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, add_rownum as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , row_number() over(\r\n partition by\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n order by\r\n case when evidence_date is null then 1 else 0 end,\r\n evidence_date desc\r\n , case when exclusion_date is null then 1 else 0 end,\r\n exclusion_date desc\r\n ) as row_num\r\n from measure_flags\r\n\r\n)\r\n\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from add_rownum\r\n where row_num = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf2372_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_long.sql", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf2372_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , numerator_flag\n from dev_thuxuan.quality_measures._int_nqf2372_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n from dev_thuxuan.quality_measures._int_nqf2372_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then denominator.denominator_flag\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null\n then numerator.numerator_flag\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null\n then exclusions.exclusion_flag\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf2372_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372_numerator"], "alias": "_int_nqf2372_numerator", "checksum": {"name": "sha256", "checksum": "a0903f344296f48c8dbbad2d57dab19ecc6d8fe96cabac29cc707acd8ffbd257"}, "config": {"enabled": true, "alias": "_int_nqf2372_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 2372, Breast Cancer Screening.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0234401, "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\n Eligible population from the denominator model before exclusions\r\n*/\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , performance_period_lookback\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from {{ ref('quality_measures__int_nqf2372_denominator') }}\r\n\r\n)\r\n\r\n, mammography_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where concept_name = 'Mammography'\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce(\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, qualifying_claims as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n from medical_claim\r\n inner join mammography_codes\r\n on medical_claim.hcpcs_code = mammography_codes.code\r\n where mammography_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, qualifying_observations as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n from observations\r\n inner join mammography_codes\r\n on observations.code = mammography_codes.code\r\n and observations.code_type = mammography_codes.code_system\r\n)\r\n\r\n, qualifying_procedures as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n from procedures\r\n inner join mammography_codes\r\n on procedures.code = mammography_codes.code\r\n and procedures.code_type = mammography_codes.code_system\r\n\r\n)\r\n\r\n/*\r\n Check if patients in the eligible population have had a screening,\r\n diagnostic, film, digital or digital breast tomosynthesis (3D)\r\n mammography results documented and reviewed.\r\n*/\r\n\r\n, patients_with_mammograms as (\r\n\r\n select\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.performance_period_lookback\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , case\r\n when qualifying_claims.claim_start_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then qualifying_claims.claim_start_date\r\n when qualifying_claims.claim_end_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then qualifying_claims.claim_end_date\r\n when qualifying_observations.observation_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then qualifying_observations.observation_date\r\n when qualifying_procedures.procedure_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then qualifying_procedures.procedure_date\r\n else null\r\n end as evidence_date\r\n , case\r\n when qualifying_claims.claim_start_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then 1\r\n when qualifying_claims.claim_end_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then 1\r\n when qualifying_observations.observation_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then 1\r\n when qualifying_procedures.procedure_date\r\n between denominator.performance_period_lookback\r\n and denominator.performance_period_end\r\n then 1\r\n else 0\r\n end as numerator_flag\r\n from denominator\r\n left join qualifying_claims\r\n on denominator.patient_id = qualifying_claims.patient_id\r\n left join qualifying_observations\r\n on denominator.patient_id = qualifying_observations.patient_id\r\n left join qualifying_procedures\r\n on denominator.patient_id = qualifying_procedures.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from patients_with_mammograms\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf2372_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372_numerator.sql", "compiled": true, "compiled_code": "\n\n/*\n Eligible population from the denominator model before exclusions\n*/\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf2372_denominator\n\n)\n\n, mammography_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name = 'Mammography'\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n from medical_claim\n inner join mammography_codes\n on medical_claim.hcpcs_code = mammography_codes.code\n where mammography_codes.code_system = 'hcpcs'\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n from observations\n inner join mammography_codes\n on observations.code = mammography_codes.code\n and observations.code_type = mammography_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join mammography_codes\n on procedures.code = mammography_codes.code\n and procedures.code_type = mammography_codes.code_system\n\n)\n\n/*\n Check if patients in the eligible population have had a screening,\n diagnostic, film, digital or digital breast tomosynthesis (3D)\n mammography results documented and reviewed.\n*/\n\n, patients_with_mammograms as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.performance_period_lookback\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_start_date\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_end_date\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_observations.observation_date\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_procedures.procedure_date\n else null\n end as evidence_date\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n else 0\n end as numerator_flag\n from denominator\n left join qualifying_claims\n on denominator.patient_id = qualifying_claims.patient_id\n left join qualifying_observations\n on denominator.patient_id = qualifying_observations.patient_id\n left join qualifying_procedures\n on denominator.patient_id = qualifying_procedures.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(numerator_flag as integer) as numerator_flag\n from patients_with_mammograms\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf2372__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf2372_breast_cancer_screening", "quality_measures__int_nqf2372__performance_period"], "alias": "_int_nqf2372__performance_period", "checksum": {"name": "sha256", "checksum": "4bb3e6347eee038dcf4dcf1814b1b9b45f40ca74e2b6f194d9a7d2955ae50b29"}, "config": {"enabled": true, "alias": "_int_nqf2372__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Breast Cancer screening.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf2372__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0104406, "relation_name": "dev_thuxuan.quality_measures._int_nqf2372__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF2372')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF2372')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF2372')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\n/*\r\n set performance lookback period to 27 months prior to the end of the\r\n performance period\r\n*/\r\n, period_lookback as (\r\n\r\n select\r\n performance_period_end\r\n , performance_period_begin\r\n , {{ dbt.dateadd (\r\n datepart = \"month\"\r\n , interval = -27\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n ) }} as performance_period_lookback\r\n from period_begin\r\n\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_lookback as date) as performance_period_lookback\r\nfrom period_lookback", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf2372_breast_cancer_screening\\quality_measures__int_nqf2372__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback period to 27 months prior to the end of the\n performance period\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n month,\n -27,\n performance_period_end\n )\n\n as performance_period_lookback\n from period_begin\n\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_version\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_lookback as date) as performance_period_lookback\nfrom period_lookback", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_denominator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_denominator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_denominator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_denominator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_denominator"], "alias": "_int_nqf0097_denominator", "checksum": {"name": "sha256", "checksum": "7112419eb82f1d629dcfb971b3d64b87c880acff0e223c403dcc3c5cf6f10a1f"}, "config": {"enabled": true, "alias": "_int_nqf0097_denominator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Denominator logic for the reporting version of Medication Reconciliation Post-Discharge\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age": {"name": "age", "description": "Patient's age during encounter in the performance period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "Inpatient discharged date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_denominator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0964465, "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_denominator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith visit_codes as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n\r\n)\r\n\r\n, valid_concepts as (\r\n\r\n select\r\n concept_name\r\n from {{ ref('quality_measures__concepts') }}\r\n where concept_name in (\r\n 'annual wellness visit'\r\n , 'care services in long term residential facility'\r\n , 'encounter to document medications'\r\n , 'home healthcare services'\r\n , 'office visit'\r\n , 'outpatient'\r\n , 'psychoanalysis'\r\n )\r\n\r\n)\r\n\r\n, valid_visit_codes as (\r\n\r\n select\r\n visit_codes.concept_name\r\n , visit_codes.code\r\n , visit_codes.code_system\r\n from visit_codes\r\n inner join valid_concepts\r\n on visit_codes.concept_name = valid_concepts.concept_name\r\n\r\n)\r\n\r\n, visits_encounters as (\r\n\r\n select patient_id\r\n , length_of_stay\r\n , encounter.encounter_end_date\r\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\r\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\r\n from {{ref('quality_measures__stg_core__encounter')}} encounter\r\n inner join {{ref('quality_measures__int_nqf0097__performance_period')}} as pp\r\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\r\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\r\n -- all encounter types considered; inpatient encounters are filtered by length of stay being more than 0 days\r\n\r\n)\r\n\r\n, procedure_encounters as (\r\n\r\n select \r\n patient_id\r\n , procedure_date as min_date\r\n , procedure_date as max_date\r\n from {{ref('quality_measures__stg_core__procedure')}} procs\r\n\r\n inner join {{ref('quality_measures__int_nqf0097__performance_period')}} as pp\r\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\r\n inner join valid_visit_codes\r\n on coalesce(procs.normalized_code,procs.source_code) = valid_visit_codes.code\r\n\r\n)\r\n\r\n, claims_encounters as (\r\n \r\n select patient_id\r\n , coalesce(claim_start_date,claim_end_date) as min_date\r\n , coalesce(claim_end_date,claim_start_date) as max_date\r\n from {{ref('quality_measures__stg_medical_claim')}} medical_claim\r\n inner join {{ref('quality_measures__int_nqf0097__performance_period')}} as pp on\r\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\r\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\r\n inner join valid_visit_codes\r\n on medical_claim.hcpcs_code= valid_visit_codes.code\r\n\r\n)\r\n\r\n, all_encounters as (\r\n\r\n select\r\n patient_id\r\n , min_date\r\n , max_date\r\n , 'v' as visit_enc\r\n , cast(null as {{ dbt.type_string() }}) as proc_enc\r\n , cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from visits_encounters\r\n\r\n union all\r\n\r\n select\r\n patient_id\r\n , min_date\r\n , max_date\r\n , cast(null as {{ dbt.type_string() }}) as visit_enc\r\n , 'p' as proc_enc\r\n , cast(null as {{ dbt.type_string() }}) as claim_enc\r\n from procedure_encounters\r\n\r\n union all\r\n \r\n select\r\n patient_id\r\n , min_date\r\n , max_date\r\n , cast(null as {{ dbt.type_string() }}) as visit_enc\r\n , cast(null as {{ dbt.type_string() }}) as proc_enc\r\n , 'c' as claim_enc\r\n from claims_encounters\r\n\r\n)\r\n\r\n, encounters_by_patient as (\r\n\r\n select patient_id,min(min_date) min_date, max(max_date) max_date,\r\n concat(concat(\r\n coalesce(min(visit_enc),'')\r\n ,coalesce(min(proc_enc),''))\r\n ,coalesce(min(claim_enc),'')\r\n ) as qualifying_types\r\n from all_encounters\r\n group by patient_id\r\n\r\n)\r\n\r\n, patients_with_age as (\r\n\r\n select\r\n p.patient_id\r\n , min_date\r\n , floor({{ datediff('birth_date', 'e.min_date', 'hour') }} / 8760.0) as min_age\r\n , max_date\r\n , floor({{ datediff('birth_date', 'e.max_date', 'hour') }} / 8760.0) as max_age\r\n , qualifying_types\r\n from {{ref('quality_measures__stg_core__patient')}} p\r\n inner join encounters_by_patient e\r\n on p.patient_id = e.patient_id\r\n where p.death_date is null\r\n\r\n)\r\n\r\n, qualifying_patients as (\r\n\r\n select\r\n distinct\r\n patients_with_age.patient_id\r\n , patients_with_age.max_age as age\r\n , pp.performance_period_begin\r\n , pp.performance_period_end\r\n , pp.measure_id\r\n , pp.measure_name\r\n , pp.measure_version\r\n , visits_encounters.encounter_end_date as discharge_date\r\n , 1 as denominator_flag\r\n from patients_with_age\r\n cross join {{ref('quality_measures__int_nqf0097__performance_period')}} pp\r\n inner join visits_encounters\r\n on patients_with_age.patient_id = visits_encounters.patient_id\r\n where max_age >= 18\r\n and visits_encounters.length_of_stay > 0 --ensures inpatient\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(age as integer) as age\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(discharge_date as date) as discharge_date\r\n , cast(denominator_flag as integer) as denominator_flag\r\n from qualifying_patients\r\n\r\n)\r\n\r\nselect \r\n patient_id\r\n , age\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , discharge_date\r\n , denominator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__concepts", "package": null, "version": null}, {"name": "quality_measures__stg_core__encounter", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.datediff"], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "seed.the_tuva_project.quality_measures__concepts", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_denominator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n\n)\n\n, valid_concepts as (\n\n select\n concept_name\n from dev_thuxuan.quality_measures._value_set_concepts\n where concept_name in (\n 'annual wellness visit'\n , 'care services in long term residential facility'\n , 'encounter to document medications'\n , 'home healthcare services'\n , 'office visit'\n , 'outpatient'\n , 'psychoanalysis'\n )\n\n)\n\n, valid_visit_codes as (\n\n select\n visit_codes.concept_name\n , visit_codes.code\n , visit_codes.code_system\n from visit_codes\n inner join valid_concepts\n on visit_codes.concept_name = valid_concepts.concept_name\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , length_of_stay\n , encounter.encounter_end_date\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0097__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n -- all encounter types considered; inpatient encounters are filtered by length of stay being more than 0 days\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n\n inner join dev_thuxuan.quality_measures._int_nqf0097__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join valid_visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = valid_visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0097__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join valid_visit_codes\n on medical_claim.hcpcs_code= valid_visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc\n , cast(null as TEXT) as proc_enc\n , cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , 'p' as proc_enc\n , cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , cast(null as TEXT) as proc_enc\n , 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , visits_encounters.encounter_end_date as discharge_date\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_nqf0097__performance_period pp\n inner join visits_encounters\n on patients_with_age.patient_id = visits_encounters.patient_id\n where max_age >= 18\n and visits_encounters.length_of_stay > 0 --ensures inpatient\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(discharge_date as date) as discharge_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_exclusions", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_exclusions.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_exclusions.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_exclusions"], "alias": "_int_nqf0097_exclusions", "checksum": {"name": "sha256", "checksum": "23db2e3ed31c789d18d082f8f662f8c5a029ed0b04f7d030448757f598e841a6"}, "config": {"enabled": true, "alias": "_int_nqf0097_exclusions", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Combined exclusion logic for the reporting version of NQF 0097, Medication Reconciliation Post-Discharge.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_exclusions", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.099446, "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_exclusions", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{%- set performance_period_begin -%}\r\n(\r\n select \r\n performance_period_begin\r\n from {{ ref('quality_measures__int_nqf0097__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\n{%- set performance_period_end -%}\r\n(\r\n select \r\n performance_period_end\r\n from {{ ref('quality_measures__int_nqf0097__performance_period') }}\r\n\r\n)\r\n{%- endset -%}\r\n\r\nwith valid_hospice_exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_type\r\n from {{ref('quality_measures__int_shared_exclusions_hospice_palliative')}}\r\n where exclusion_date between {{ performance_period_begin }} and {{ performance_period_end }}\r\n and lower(exclusion_reason) in (\r\n 'hospice encounter'\r\n )\r\n\r\n)\r\n\r\n, combined_exclusions as (\r\n\r\n select \r\n valid_hospice_exclusions.patient_id\r\n , valid_hospice_exclusions.exclusion_date\r\n , valid_hospice_exclusions.exclusion_reason\r\n , valid_hospice_exclusions.exclusion_type\r\n from valid_hospice_exclusions\r\n inner join {{ref('quality_measures__int_nqf0097_denominator')}} as denominator\r\n on valid_hospice_exclusions.patient_id = denominator.patient_id\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , 1 as exclusion_flag\r\n from combined_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , exclusion_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097__performance_period", "package": null, "version": null}, {"name": "quality_measures__int_shared_exclusions_hospice_palliative", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_denominator", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_nqf0097_denominator"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_exclusions.sql", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0097__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0097__performance_period\n\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select \n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n , valid_hospice_exclusions.exclusion_type\n from valid_hospice_exclusions\n inner join dev_thuxuan.quality_measures._int_nqf0097_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_long": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_long", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_long.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_long.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_long", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_long"], "alias": "_int_nqf0097_long", "checksum": {"name": "sha256", "checksum": "9cd822de69be0de7ec2f9d456a01bd607ca595a729d0313a5db3d7ca3bd4186b"}, "config": {"enabled": true, "alias": "_int_nqf0097_long", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Final preparation of the reporting version of NQF 0097, Medication Reconciliation Post-Discharge before combining with other measures.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "denominator_flag": {"name": "denominator_flag", "description": "The denominator is associated with a given patient population that may be counted as eligible to meet a measure\u2019s inclusion requirements.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_flag": {"name": "exclusion_flag", "description": "Specifications of those characteristics that would cause groups of individuals to be removed from the numerator and/or denominator of a measure although they experience the denominator index event.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_date": {"name": "exclusion_date", "description": "Date of event or service that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_reason": {"name": "exclusion_reason", "description": "Reason (usually the value set concept name) that excludes patient from the measure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_long", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.1014462, "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_long", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/* selecting the full patient population as the grain of this table */\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , denominator_flag\r\n from {{ ref('quality_measures__int_nqf0097_denominator') }}\r\n\r\n)\r\n\r\n, numerator as (\r\n\r\n select\r\n patient_id\r\n , evidence_date\r\n , evidence_value\r\n from {{ ref('quality_measures__int_nqf0097_numerator') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_nqf0097_exclusions') }}\r\n\r\n)\r\n\r\n, measure_flags as (\r\n\r\n select\r\n denominator.patient_id\r\n , case\r\n when denominator.patient_id is not null\r\n then 1\r\n else null\r\n end as denominator_flag\r\n , case\r\n when numerator.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as numerator_flag\r\n , case\r\n when exclusions.patient_id is not null and denominator.patient_id is not null\r\n then 1\r\n when denominator.patient_id is not null\r\n then 0\r\n else null\r\n end as exclusion_flag\r\n , numerator.evidence_date\r\n , numerator.evidence_value\r\n , exclusions.exclusion_date\r\n , exclusions.exclusion_reason\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , (row_number() over(\r\n partition by\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n order by\r\n case when numerator.evidence_date is null then 1 else 0 end,\r\n numerator.evidence_date desc\r\n , case when exclusions.exclusion_date is null then 1 else 0 end,\r\n exclusions.exclusion_date desc\r\n )) as rn\r\n from denominator\r\n left join numerator\r\n on denominator.patient_id = numerator.patient_id\r\n left join exclusions\r\n on denominator.patient_id = exclusions.patient_id\r\n\r\n)\r\n\r\n/*\r\n Deduplicate measure rows by latest evidence date or exclusion date\r\n*/\r\n, deduped as (\r\n\r\n select\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n from measure_flags\r\n where rn = 1\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(denominator_flag as integer) as denominator_flag\r\n , cast(numerator_flag as integer) as numerator_flag\r\n , cast(exclusion_flag as integer) as exclusion_flag\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(evidence_value as {{ dbt.type_string() }}) as evidence_value\r\n , cast(exclusion_date as date) as exclusion_date\r\n , cast(exclusion_reason as {{ dbt.type_string() }}) as exclusion_reason\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n from deduped\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , denominator_flag\r\n , numerator_flag\r\n , exclusion_flag\r\n , evidence_date\r\n , evidence_value\r\n , exclusion_date\r\n , exclusion_reason\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0097_denominator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_numerator", "package": null, "version": null}, {"name": "quality_measures__int_nqf0097_exclusions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_long.sql", "compiled": true, "compiled_code": "\n\n/* selecting the full patient population as the grain of this table */\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0097_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0097_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0097_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097_numerator": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0097_numerator", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_numerator.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_numerator.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097_numerator"], "alias": "_int_nqf0097_numerator", "checksum": {"name": "sha256", "checksum": "cb42dfc6daafa7f74366fadd93bd924f2de0a51fe4809ec9b165017e41dc54da"}, "config": {"enabled": true, "alias": "_int_nqf0097_numerator", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Numerator logic for the reporting version of NQF 0097, Medication Reconciliation Post-Discharge.\n", "columns": {"patient_id": {"name": "patient_id", "description": "Unique patient_id for each person.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_begin": {"name": "performance_period_begin", "description": "Beginning date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "performance_period_end": {"name": "performance_period_end", "description": "Ending date of the performance or measurement period.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Unique measure identification number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_version": {"name": "measure_version", "description": "Version of the measure.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_date": {"name": "evidence_date", "description": "Date of event or service that places patient in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "evidence_value": {"name": "evidence_value", "description": "Observed evidence value for the patients in the numerator.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "numerator_flag": {"name": "numerator_flag", "description": "The numerator reflects the subset of patients in the denominator for whom a particular service has been provided or for whom a particular outcome has been achieved.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The date and timestamp of the dbt run.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097_numerator", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.104446, "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_numerator", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\nwith denominator as (\r\n\r\n select\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , discharge_date\r\n from {{ ref('quality_measures__int_nqf0097_denominator') }}\r\n\r\n)\r\n\r\n, reconciliation_codes as (\r\n\r\n select\r\n concept_name\r\n , code\r\n , code_system\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'medication reconciliation post discharge'\r\n )\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce(\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, reconciliation_procedures as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n from procedures\r\n inner join reconciliation_codes\r\n on procedures.code = reconciliation_codes.code\r\n and procedures.code_type = reconciliation_codes.code_system\r\n\r\n)\r\n\r\n, qualifying_patients_with_denominator as (\r\n\r\n select\r\n denominator.patient_id\r\n , denominator.performance_period_begin\r\n , denominator.performance_period_end\r\n , denominator.measure_id\r\n , denominator.measure_name\r\n , denominator.measure_version\r\n , reconciliation_procedures.procedure_date as evidence_date\r\n , 1 as numerator_flag\r\n from denominator\r\n inner join reconciliation_procedures\r\n on denominator.patient_id = reconciliation_procedures.patient_id\r\n where {{ datediff('denominator.discharge_date', 'reconciliation_procedures.procedure_date', 'day') }} between 0 and 30\r\n\r\n)\r\n\r\n, add_data_types as (\r\n\r\n select distinct\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\n , cast(measure_id as {{ dbt.type_string() }}) as measure_id\r\n , cast(measure_name as {{ dbt.type_string() }}) as measure_name\r\n , cast(measure_version as {{ dbt.type_string() }}) as measure_version\r\n , cast(evidence_date as date) as evidence_date\r\n , cast(null as {{ dbt.type_string() }}) as evidence_value\r\n , cast(numerator_flag as integer) as numerator_flag\r\n from qualifying_patients_with_denominator\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , performance_period_begin\r\n , performance_period_end\r\n , measure_id\r\n , measure_name\r\n , measure_version\r\n , evidence_date\r\n , evidence_value\r\n , numerator_flag\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom add_data_types", "language": "sql", "refs": [{"name": "quality_measures__int_nqf0097_denominator", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff", "macro.dbt.type_string"], "nodes": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097_numerator.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n from dev_thuxuan.quality_measures._int_nqf0097_denominator\n\n)\n\n, reconciliation_codes as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medication reconciliation post discharge'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, reconciliation_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join reconciliation_codes\n on procedures.code = reconciliation_codes.code\n and procedures.code_type = reconciliation_codes.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , reconciliation_procedures.procedure_date as evidence_date\n , 1 as numerator_flag\n from denominator\n inner join reconciliation_procedures\n on denominator.patient_id = reconciliation_procedures.patient_id\n where datediff(\n day,\n denominator.discharge_date,\n reconciliation_procedures.procedure_date\n ) between 0 and 30\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_nqf0097__performance_period", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097__performance_period.sql", "original_file_path": "models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097__performance_period.sql", "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "nqf_0097_medication_reconciliation_post_discharge", "quality_measures__int_nqf0097__performance_period"], "alias": "_int_nqf0097__performance_period", "checksum": {"name": "sha256", "checksum": "1b2a25a56fd4665a7fb894a23d4b898edd5bf677dd8c3589f67a67d111d0e6ae"}, "config": {"enabled": true, "alias": "_int_nqf0097__performance_period", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Performance Period definition for Medication Reconciliation Post-Discharge\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_nqf0097__performance_period", "tags": "quality_measures", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.106446, "relation_name": "dev_thuxuan.quality_measures._int_nqf0097__performance_period", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\n{%- set measure_id -%}\r\n(select id\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0097')\r\n{%- endset -%}\r\n\r\n{%- set measure_name -%}\r\n(select name\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0097')\r\n{%- endset -%}\r\n\r\n{%- set measure_version -%}\r\n(select version\r\nfrom {{ ref('quality_measures__measures') }}\r\nwhere id = 'NQF0097')\r\n{%- endset -%}\r\n\r\n/*\r\n set performance period end to the end of the current calendar year\r\n or use the quality_measures_period_end variable if provided\r\n*/\r\nwith period_end as (\r\n\r\n select\r\n {% if var('quality_measures_period_end',False) == False -%}\r\n {{ last_day(dbt.current_timestamp(), 'year') }}\r\n {% else -%}\r\n cast('{{ var('quality_measures_period_end') }}' as date)\r\n {%- endif %}\r\n as performance_period_end\r\n \r\n)\r\n\r\n/*\r\n set performance period begin to a year and a day prior\r\n for a complete calendar year\r\n*/\r\n, period_begin as (\r\n\r\n select\r\n performance_period_end\r\n , {{ dbt.dateadd (\r\n datepart = \"day\"\r\n , interval = +1\r\n , from_date_or_timestamp =\r\n dbt.dateadd (\r\n datepart = \"year\"\r\n , interval = -1\r\n , from_date_or_timestamp = \"performance_period_end\"\r\n )\r\n ) }} as performance_period_begin\r\n from period_end\r\n\r\n)\r\n\r\nselect\r\n cast({{ measure_id }} as {{ dbt.type_string() }}) as measure_id\r\n , cast({{ measure_name }} as {{ dbt.type_string() }}) as measure_name\r\n , cast({{ measure_version }} as {{ dbt.type_string() }}) as measure_version\r\n , cast(performance_period_begin as date) as performance_period_begin\r\n , cast(performance_period_end as date) as performance_period_end\r\nfrom period_begin", "language": "sql", "refs": [{"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}, {"name": "quality_measures__measures", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.current_timestamp", "macro.dbt.last_day", "macro.dbt.dateadd", "macro.dbt.type_string"], "nodes": ["seed.the_tuva_project.quality_measures__measures"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\nqf_0097_medication_reconciliation_post_discharge\\quality_measures__int_nqf0097__performance_period.sql", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_advanced_illness", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_advanced_illness.sql", "original_file_path": "models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_advanced_illness.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_advanced_illness"], "alias": "_int_shared_exclusions_advanced_illness", "checksum": {"name": "sha256", "checksum": "beeef8a1bf032b9c1b832824901133259757a9b3336e259be61f1b69a3067fc1"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_advanced_illness", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty and advanced illness for entire patient population.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_advanced_illness", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.000923, "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false)))) | as_bool\r\n )\r\n}}\r\n\r\nwith patients_with_frailty as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'advanced illness'\r\n , 'acute inpatient'\r\n , 'encounter inpatient'\r\n , 'outpatient'\r\n , 'observation'\r\n , 'emergency department visit'\r\n , 'nonacute inpatient'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n , place_of_service_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n where lower(exclusion_codes.concept_name) = 'advanced illness'\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, acute_inpatient as (\r\n\r\n select distinct\r\n patients_with_frailty.patient_id\r\n , coalesce(\r\n med_claim_exclusions.claim_start_date\r\n , med_claim_exclusions.claim_end_date\r\n ) as exclusion_date\r\n , {{ dbt.concat([\r\n \"patients_with_frailty.exclusion_reason\",\r\n \"' with '\",\r\n \"med_claim_exclusions.concept_name\",\r\n \"' and '\",\r\n \"condition_exclusions.concept_name\"\r\n ]) }} as exclusion_reason\r\n , med_claim_exclusions.claim_start_date\r\n , med_claim_exclusions.claim_end_date\r\n , cast(null as date) as procedure_date\r\n from patients_with_frailty\r\n inner join med_claim_exclusions\r\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\r\n inner join condition_exclusions\r\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\r\n where lower(med_claim_exclusions.concept_name) = 'acute inpatient'\r\n\r\n union all\r\n\r\n select distinct\r\n patients_with_frailty.patient_id\r\n , procedure_exclusions.procedure_date as exclusion_date\r\n , {{ dbt.concat([\r\n \"patients_with_frailty.exclusion_reason\",\r\n \"' with '\",\r\n \"procedure_exclusions.concept_name\",\r\n \"' and '\",\r\n \"condition_exclusions.concept_name\"\r\n ]) }} as exclusion_reason\r\n , cast(null as date) as claim_start_date\r\n , cast(null as date) as claim_end_date\r\n , procedure_exclusions.procedure_date\r\n from patients_with_frailty\r\n inner join procedure_exclusions\r\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\r\n inner join condition_exclusions\r\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\r\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\r\n where lower(procedure_exclusions.concept_name) = 'acute inpatient'\r\n\r\n)\r\n\r\n, nonacute_outpatient as (\r\n\r\n select distinct\r\n patients_with_frailty.patient_id\r\n , coalesce(\r\n med_claim_exclusions.claim_start_date\r\n , med_claim_exclusions.claim_end_date\r\n ) as exclusion_date\r\n , {{ dbt.concat([\r\n \"patients_with_frailty.exclusion_reason\",\r\n \"' with '\",\r\n \"med_claim_exclusions.concept_name\",\r\n \"' and '\",\r\n \"condition_exclusions.concept_name\"\r\n ]) }} as exclusion_reason\r\n , med_claim_exclusions.claim_start_date\r\n , med_claim_exclusions.claim_end_date\r\n , cast(null as date) as procedure_date\r\n from patients_with_frailty\r\n inner join med_claim_exclusions\r\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\r\n inner join condition_exclusions\r\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\r\n where lower(med_claim_exclusions.concept_name) in (\r\n 'encounter inpatient'\r\n , 'outpatient'\r\n , 'observation'\r\n , 'emergency department visit'\r\n , 'nonacute inpatient'\r\n )\r\n\r\n union all\r\n\r\n select distinct\r\n patients_with_frailty.patient_id\r\n , procedure_exclusions.procedure_date as exclusion_date\r\n , {{ dbt.concat([\r\n \"patients_with_frailty.exclusion_reason\",\r\n \"' with '\",\r\n \"procedure_exclusions.concept_name\",\r\n \"' and '\",\r\n \"condition_exclusions.concept_name\"\r\n ]) }} as exclusion_reason\r\n , cast(null as date) as claim_start_date\r\n , cast(null as date) as claim_end_date\r\n , procedure_exclusions.procedure_date\r\n from patients_with_frailty\r\n inner join procedure_exclusions\r\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\r\n inner join condition_exclusions\r\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\r\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\r\n where lower(procedure_exclusions.concept_name) in (\r\n 'encounter inpatient'\r\n , 'outpatient'\r\n , 'observation'\r\n , 'emergency department visit'\r\n , 'nonacute inpatient'\r\n )\r\n\r\n)\r\n\r\n, exclusions_unioned as (\r\n\r\n select\r\n acute_inpatient.patient_id\r\n , acute_inpatient.exclusion_date\r\n , acute_inpatient.exclusion_reason\r\n , acute_inpatient.claim_start_date\r\n , acute_inpatient.claim_end_date\r\n , acute_inpatient.procedure_date\r\n , 'acute_inpatient' as patient_type\r\n from acute_inpatient\r\n\r\n union all\r\n\r\n select\r\n nonacute_outpatient.patient_id\r\n , nonacute_outpatient.exclusion_date\r\n , nonacute_outpatient.exclusion_reason\r\n , nonacute_outpatient.claim_start_date\r\n , nonacute_outpatient.claim_end_date\r\n , nonacute_outpatient.procedure_date\r\n , 'nonacute_outpatient' as patient_type\r\n from nonacute_outpatient\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'advanced_illness' as exclusion_type\r\n , claim_start_date\r\n , claim_end_date\r\n , procedure_date\r\n , patient_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom exclusions_unioned", "language": "sql", "refs": [{"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_advanced_illness.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'advanced illness'\n , 'acute inpatient'\n , 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n where lower(exclusion_codes.concept_name) = 'advanced illness'\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, acute_inpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) = 'acute inpatient'\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) = 'acute inpatient'\n\n)\n\n, nonacute_outpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, exclusions_unioned as (\n\n select\n acute_inpatient.patient_id\n , acute_inpatient.exclusion_date\n , acute_inpatient.exclusion_reason\n , acute_inpatient.claim_start_date\n , acute_inpatient.claim_end_date\n , acute_inpatient.procedure_date\n , 'acute_inpatient' as patient_type\n from acute_inpatient\n\n union all\n\n select\n nonacute_outpatient.patient_id\n , nonacute_outpatient.exclusion_date\n , nonacute_outpatient.exclusion_reason\n , nonacute_outpatient.claim_start_date\n , nonacute_outpatient.claim_end_date\n , nonacute_outpatient.procedure_date\n , 'nonacute_outpatient' as patient_type\n from nonacute_outpatient\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'advanced_illness' as exclusion_type\n , claim_start_date\n , claim_end_date\n , procedure_date\n , patient_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions_unioned", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_dementia", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_dementia.sql", "original_file_path": "models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_dementia.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_dementia"], "alias": "_int_shared_exclusions_dementia", "checksum": {"name": "sha256", "checksum": "73f4264ac1ada5a86f5db96916554a3e8b9959e11671217d70995e684e21ed84"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_dementia", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty and taking dementia medications for entire patient population.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_dementia", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.003919, "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_dementia", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith patients_with_frailty as (\r\n\r\n select\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n from {{ ref('quality_measures__int_shared_exclusions_frailty') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'dementia medications'\r\n )\r\n\r\n)\r\n\r\n, medications as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , source_code_type\r\n , source_code\r\n , ndc_code\r\n , rxnorm_code\r\n from {{ ref('quality_measures__stg_core__medication') }}\r\n\r\n)\r\n\r\n, pharmacy_claim as (\r\n\r\n select\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , paid_date\r\n from {{ ref('quality_measures__stg_pharmacy_claim') }}\r\n\r\n)\r\n\r\n, medication_exclusions as (\r\n\r\n select\r\n medications.patient_id\r\n , medications.dispensing_date\r\n , exclusion_codes.concept_name\r\n from medications\r\n inner join exclusion_codes\r\n on medications.ndc_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'ndc'\r\n\r\n union all\r\n\r\n select\r\n medications.patient_id\r\n , medications.dispensing_date\r\n , exclusion_codes.concept_name\r\n from medications\r\n inner join exclusion_codes\r\n on medications.rxnorm_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'rxnorm'\r\n\r\n union all\r\n\r\n select\r\n medications.patient_id\r\n , medications.dispensing_date\r\n , exclusion_codes.concept_name\r\n from medications\r\n inner join exclusion_codes\r\n on medications.source_code = exclusion_codes.code\r\n and medications.source_code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, pharmacy_claim_exclusions as (\r\n\r\n select\r\n pharmacy_claim.patient_id\r\n , pharmacy_claim.dispensing_date\r\n , pharmacy_claim.ndc_code\r\n , pharmacy_claim.paid_date\r\n , exclusion_codes.concept_name\r\n from pharmacy_claim\r\n inner join exclusion_codes\r\n on pharmacy_claim.ndc_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'ndc'\r\n\r\n)\r\n\r\n, frailty_with_dementia as (\r\n\r\n select\r\n patients_with_frailty.patient_id\r\n , patients_with_frailty.exclusion_date\r\n , {{ dbt.concat([\r\n \"patients_with_frailty.exclusion_reason\",\r\n \"' with '\",\r\n \"pharmacy_claim_exclusions.concept_name\"\r\n ]) }} as exclusion_reason\r\n , pharmacy_claim_exclusions.dispensing_date\r\n , pharmacy_claim_exclusions.paid_date\r\n from patients_with_frailty\r\n inner join pharmacy_claim_exclusions\r\n on patients_with_frailty.patient_id = pharmacy_claim_exclusions.patient_id\r\n\r\n union all\r\n\r\n select\r\n patients_with_frailty.patient_id\r\n , medication_exclusions.dispensing_date as exclusion_date\r\n , {{ dbt.concat([\r\n \"patients_with_frailty.exclusion_reason\",\r\n \"' with '\",\r\n \"medication_exclusions.concept_name\"\r\n ]) }} as exclusion_reason\r\n , medication_exclusions.dispensing_date\r\n , null as paid_date\r\n from patients_with_frailty\r\n inner join medication_exclusions\r\n on patients_with_frailty.patient_id = medication_exclusions.patient_id\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'dementia' as exclusion_type\r\n , dispensing_date\r\n , paid_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom frailty_with_dementia", "language": "sql", "refs": [{"name": "quality_measures__int_shared_exclusions_frailty", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__medication", "package": null, "version": null}, {"name": "quality_measures__stg_pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.concat"], "nodes": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_dementia.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dementia medications'\n )\n\n)\n\n, medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claim as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.rxnorm_code = exclusion_codes.code\n where exclusion_codes.code_system = 'rxnorm'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claim_exclusions as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date\n , pharmacy_claim.ndc_code\n , pharmacy_claim.paid_date\n , exclusion_codes.concept_name\n from pharmacy_claim\n inner join exclusion_codes\n on pharmacy_claim.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n)\n\n, frailty_with_dementia as (\n\n select\n patients_with_frailty.patient_id\n , patients_with_frailty.exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || pharmacy_claim_exclusions.concept_name as exclusion_reason\n , pharmacy_claim_exclusions.dispensing_date\n , pharmacy_claim_exclusions.paid_date\n from patients_with_frailty\n inner join pharmacy_claim_exclusions\n on patients_with_frailty.patient_id = pharmacy_claim_exclusions.patient_id\n\n union all\n\n select\n patients_with_frailty.patient_id\n , medication_exclusions.dispensing_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || medication_exclusions.concept_name as exclusion_reason\n , medication_exclusions.dispensing_date\n , null as paid_date\n from patients_with_frailty\n inner join medication_exclusions\n on patients_with_frailty.patient_id = medication_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'dementia' as exclusion_type\n , dispensing_date\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom frailty_with_dementia", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "sql": " __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_frailty", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_frailty.sql", "original_file_path": "models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_frailty.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_frailty"], "alias": "_int_shared_exclusions_frailty", "checksum": {"name": "sha256", "checksum": "41e832cc78098a822ad3583681601d409417ce80cbd2dde8b8c9936f640cd788"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_frailty", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients with frailty used by other exclusion models.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_frailty", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9989228, "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_frailty", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False))))\r\n | as_bool\r\n )\r\n}}\r\n\r\nwith patients as (\r\n\r\n select\r\n patient_id\r\n from {{ ref('quality_measures__stg_core__patient') }}\r\n\r\n)\r\n\r\n, exclusion_codes as (\r\n\r\n select\r\n code\r\n , code_system\r\n , concept_name\r\n from {{ ref('quality_measures__value_sets') }}\r\n where lower(concept_name) in (\r\n 'frailty device'\r\n , 'frailty diagnosis'\r\n , 'frailty encounter'\r\n , 'frailty symptom'\r\n )\r\n\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n , place_of_service_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, observation_exclusions as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , exclusion_codes.concept_name\r\n from observations\r\n inner join exclusion_codes\r\n on observations.code = exclusion_codes.code\r\n and observations.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, patients_with_frailty as (\r\n\r\n select\r\n patients.patient_id\r\n , condition_exclusions.recorded_date as exclusion_date\r\n , condition_exclusions.concept_name as exclusion_reason\r\n from patients\r\n inner join condition_exclusions\r\n on patients.patient_id = condition_exclusions.patient_id\r\n\r\n union all\r\n\r\n select\r\n patients.patient_id\r\n , coalesce(\r\n med_claim_exclusions.claim_start_date\r\n , med_claim_exclusions.claim_end_date\r\n ) as exclusion_date\r\n , med_claim_exclusions.concept_name as exclusion_reason\r\n from patients\r\n inner join med_claim_exclusions\r\n on patients.patient_id = med_claim_exclusions.patient_id\r\n\r\n union all\r\n\r\n select\r\n patients.patient_id\r\n , observation_exclusions.observation_date as exclusion_date\r\n , observation_exclusions.concept_name as exclusion_reason\r\n from patients\r\n inner join observation_exclusions\r\n on patients.patient_id = observation_exclusions.patient_id\r\n\r\n union all\r\n\r\n select\r\n patients.patient_id\r\n , procedure_exclusions.procedure_date as exclusion_date\r\n , procedure_exclusions.concept_name as exclusion_reason\r\n from patients\r\n inner join procedure_exclusions\r\n on patients.patient_id = procedure_exclusions.patient_id\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom patients_with_frailty", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient", "seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_frailty.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'frailty device'\n , 'frailty diagnosis'\n , 'frailty encounter'\n , 'frailty symptom'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_frailty as (\n\n select\n patients.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from patients\n inner join condition_exclusions\n on patients.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , med_claim_exclusions.concept_name as exclusion_reason\n from patients\n inner join med_claim_exclusions\n on patients.patient_id = med_claim_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from patients\n inner join observation_exclusions\n on patients.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from patients\n inner join procedure_exclusions\n on patients.patient_id = procedure_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom patients_with_frailty", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_hospice_palliative", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_hospice_palliative.sql", "original_file_path": "models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_hospice_palliative.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_hospice_palliative"], "alias": "_int_shared_exclusions_hospice_palliative", "checksum": {"name": "sha256", "checksum": "f1bfe290ff54fbfdaea6c4272887d140cc960e09b7e336caf7a7ffb53e7d2e14"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_hospice_palliative", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients using hospice or palliative services for the reporting for entire patient population.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_hospice_palliative", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.004923, "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\nDENOMINATOR EXCLUSIONS:\r\nPatient was provided hospice services any time during the measurement period: G9687\r\n*/\r\n\r\n\r\nwith exclusion_codes as (\r\n\r\n select\r\n code\r\n , case code_system\r\n when 'SNOMEDCT' then 'snomed-ct'\r\n when 'ICD9CM' then 'icd-9-cm'\r\n when 'ICD10CM' then 'icd-10-cm'\r\n when 'CPT' then 'hcpcs'\r\n when 'ICD10PCS' then 'icd-10-pcs'\r\n else lower(code_system) end as code_system\r\n , concept_name\r\n From {{ref('quality_measures__value_sets')}}\r\n where lower(concept_name) in (\r\n 'hospice encounter'\r\n , 'hospice care ambulatory'\r\n , 'hospice diagnosis'\r\n , 'palliative care encounter'\r\n , 'palliative care diagnosis'\r\n , 'palliative care intervention'\r\n )\r\n)\r\n\r\n, conditions as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , recorded_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__condition') }} \r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n , place_of_service_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, observations as (\r\n\r\n select\r\n patient_id\r\n , observation_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__observation') }}\r\n\r\n)\r\n\r\n, procedures as (\r\n\r\n select\r\n patient_id\r\n , procedure_date\r\n , coalesce (\r\n normalized_code_type\r\n , case\r\n when lower(source_code_type) = 'cpt' then 'hcpcs'\r\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\r\n else lower(source_code_type)\r\n end\r\n ) as code_type\r\n , coalesce (\r\n normalized_code\r\n , source_code\r\n ) as code\r\n from {{ ref('quality_measures__stg_core__procedure') }}\r\n\r\n)\r\n\r\n, condition_exclusions as (\r\n\r\n select\r\n conditions.patient_id\r\n , conditions.claim_id\r\n , conditions.recorded_date\r\n , exclusion_codes.concept_name as concept_name\r\n from conditions\r\n inner join exclusion_codes\r\n on conditions.code = exclusion_codes.code\r\n and conditions.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, med_claim_exclusions as (\r\n\r\n select\r\n medical_claim.patient_id\r\n , medical_claim.claim_id\r\n , medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n , medical_claim.hcpcs_code\r\n , exclusion_codes.concept_name as concept_name\r\n from medical_claim\r\n inner join exclusion_codes\r\n on medical_claim.hcpcs_code = exclusion_codes.code\r\n where exclusion_codes.code_system = 'hcpcs'\r\n\r\n)\r\n\r\n, observation_exclusions as (\r\n\r\n select\r\n observations.patient_id\r\n , observations.observation_date\r\n , exclusion_codes.concept_name as concept_name\r\n from observations\r\n inner join exclusion_codes\r\n on observations.code = exclusion_codes.code\r\n and observations.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, procedure_exclusions as (\r\n\r\n select\r\n procedures.patient_id\r\n , procedures.procedure_date\r\n , exclusion_codes.concept_name as concept_name\r\n from procedures\r\n inner join exclusion_codes\r\n on procedures.code = exclusion_codes.code\r\n and procedures.code_type = exclusion_codes.code_system\r\n\r\n)\r\n\r\n, patients_with_exclusions as(\r\n \r\n select patient_id\r\n , recorded_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from condition_exclusions\r\n\r\n union all\r\n\r\n select patient_id\r\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\r\n , concept_name as exclusion_reason\r\n from med_claim_exclusions\r\n\r\n union all\r\n\r\n select patient_id\r\n , observation_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from observation_exclusions\r\n\r\n union all\r\n\r\n select patient_id\r\n , procedure_date as exclusion_date\r\n , concept_name as exclusion_reason\r\n from procedure_exclusions\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'hospice_palliative' as exclusion_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom patients_with_exclusions", "language": "sql", "refs": [{"name": "quality_measures__value_sets", "package": null, "version": null}, {"name": "quality_measures__stg_core__condition", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}, {"name": "quality_measures__stg_core__observation", "package": null, "version": null}, {"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["seed.the_tuva_project.quality_measures__value_sets", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_hospice_palliative.sql", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatient was provided hospice services any time during the measurement period: G9687\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n From dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n , 'palliative care encounter'\n , 'palliative care diagnosis'\n , 'palliative care intervention'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition \n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n \n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'hospice_palliative' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom patients_with_exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__int_shared_exclusions_institutional_snp", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_institutional_snp.sql", "original_file_path": "models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_institutional_snp.sql", "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "fqn": ["the_tuva_project", "quality_measures", "intermediate", "shared_exclusions", "quality_measures__int_shared_exclusions_institutional_snp"], "alias": "_int_shared_exclusions_institutional_snp", "checksum": {"name": "sha256", "checksum": "03caa2b62da546757a1b900c660c7f8a0f23287be4b454f03667d0617b28c01f"}, "config": {"enabled": true, "alias": "_int_shared_exclusions_institutional_snp", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Exclusion logic for patients staying in an institution for the reporting for entire patient population. \n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_int_shared_exclusions_institutional_snp", "tags": "quality_measures", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.0084405, "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp", "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',false)))) | as_bool\r\n )\r\n}}\r\n\r\n/*\r\n patients in institutional special needs plans (snp)\r\n or residing in long term care\r\n\r\n while referencing this model, patients greater or equal than 66 years of age should be taken\r\n\r\n filtering out age from this model has been stripped out as different measures calculate age varingly\r\n\r\n future enhancement: group claims into encounters\r\n*/\r\n\r\nwith patients as (\r\n\r\n select\r\n patient_id\r\n from {{ ref('quality_measures__stg_core__patient') }}\r\n\r\n)\r\n\r\n, medical_claim as (\r\n\r\n select\r\n patient_id\r\n , claim_start_date\r\n , claim_end_date\r\n , hcpcs_code\r\n , place_of_service_code\r\n from {{ ref('quality_measures__stg_medical_claim') }}\r\n\r\n)\r\n\r\n, exclusions as (\r\n\r\n select\r\n patients.patient_id\r\n , coalesce(\r\n medical_claim.claim_start_date\r\n , medical_claim.claim_end_date\r\n ) as exclusion_date\r\n , 'institutional or long term care' as exclusion_reason\r\n from patients\r\n inner join medical_claim\r\n on patients.patient_id = medical_claim.patient_id\r\n where place_of_service_code in ('32', '33', '34', '54', '56')\r\n and {{ datediff('medical_claim.claim_start_date', 'medical_claim.claim_end_date', 'day') }} >= 90\r\n\r\n)\r\n\r\nselect\r\n patient_id\r\n , exclusion_date\r\n , exclusion_reason\r\n , 'institutional_snp' as exclusion_type\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom exclusions", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}, {"name": "quality_measures__stg_medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\intermediate\\shared_exclusions\\quality_measures__int_shared_exclusions_institutional_snp.sql", "compiled": true, "compiled_code": "\n\n/*\n patients in institutional special needs plans (snp)\n or residing in long term care\n\n while referencing this model, patients greater or equal than 66 years of age should be taken\n\n filtering out age from this model has been stripped out as different measures calculate age varingly\n\n future enhancement: group claims into encounters\n*/\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, exclusions as (\n\n select\n patients.patient_id\n , coalesce(\n medical_claim.claim_start_date\n , medical_claim.claim_end_date\n ) as exclusion_date\n , 'institutional or long term care' as exclusion_reason\n from patients\n inner join medical_claim\n on patients.patient_id = medical_claim.patient_id\n where place_of_service_code in ('32', '33', '34', '54', '56')\n and datediff(\n day,\n medical_claim.claim_start_date,\n medical_claim.claim_end_date\n ) >= 90\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'institutional_snp' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}, {"id": "model.the_tuva_project.quality_measures__stg_medical_claim", "sql": " __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__condition": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__condition.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__condition.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__condition", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__condition"], "alias": "_stg_condition", "checksum": {"name": "sha256", "checksum": "83b38f12430d4d586bce68f972fd1c2ba390d1ea178782670bfd513f5f8610e9"}, "config": {"enabled": true, "alias": "_stg_condition", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging conditions from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recorded_date": {"name": "recorded_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_condition", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2224135, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , claim_id\r\n , encounter_id\r\n , recorded_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__condition') }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__condition.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__encounter": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__encounter.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__encounter.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__encounter", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__encounter"], "alias": "_stg_encounter", "checksum": {"name": "sha256", "checksum": "9715891ead404e594bb30ff45442e891a8ed972f1c61e28f25f1ebb0c72f243d"}, "config": {"enabled": true, "alias": "_stg_encounter", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging encounters from core. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_type": {"name": "encounter_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_start_date": {"name": "encounter_start_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_end_date": {"name": "encounter_end_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_encounter", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.22441, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , encounter_id\r\n , encounter_type\r\n , length_of_stay\r\n , encounter_start_date\r\n , encounter_end_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__encounter') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , encounter_id\r\n , encounter_type\r\n , length_of_stay\r\n , encounter_start_date\r\n , encounter_end_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__encounter') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_type\r\n , cast(null as {{dbt.type_numeric()}} ) as length_of_stay\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_start_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_end_date\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n{% else %}\r\n select\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_type\r\n , cast(null as {{dbt.type_numeric()}} ) as length_of_stay\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_start_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_end_date\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__lab_result": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__lab_result.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__lab_result.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__lab_result", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__lab_result"], "alias": "_stg_lab_result", "checksum": {"name": "sha256", "checksum": "1456eac4fb8efa7d19d9ec69ea8df59915479c8a0be4d3823003e10974f43d01"}, "config": {"enabled": true, "alias": "_stg_lab_result", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging lab results from the input layer. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "result_date": {"name": "result_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "collection_date": {"name": "collection_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_lab_result", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2403252, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , result\r\n , result_date\r\n , collection_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__lab_result') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , result\r\n , result_date\r\n , collection_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__lab_result') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as collection_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n{% else %}\r\n select\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as result_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as collection_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__lab_result.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__medication": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__medication.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__medication.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__medication", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__medication"], "alias": "_stg_medication", "checksum": {"name": "sha256", "checksum": "5fa916afdfc14b4e2e25ced5e6f021d93db4bb7175c69a98664f230126c23019"}, "config": {"enabled": true, "alias": "_stg_medication", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging medications from core. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id": {"name": "encounter_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prescribing_date": {"name": "prescribing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_code": {"name": "rxnorm_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_medication", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.226427, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , encounter_id\r\n , prescribing_date \r\n , dispensing_date\r\n , source_code_type\r\n , source_code\r\n , ndc_code\r\n , rxnorm_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medication') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , encounter_id\r\n , prescribing_date \r\n , dispensing_date\r\n , source_code_type\r\n , source_code\r\n , ndc_code\r\n , rxnorm_code\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medication') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as prescribing_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n{% else %}\r\nselect\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as prescribing_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_string() }} ) as rxnorm_code\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__medication.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__observation": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__observation.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__observation.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__observation", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__observation"], "alias": "_stg_observation", "checksum": {"name": "sha256", "checksum": "951c9e909bbd64b1aa5a481c3f3643568ed4f541e1fa3397cd79744c7e3b1dfc"}, "config": {"enabled": true, "alias": "_stg_observation", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging medications from core. Creates an empty table if using claims only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "observation_date": {"name": "observation_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_observation", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2284112, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , encounter_id\r\n , observation_date\r\n , result\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n , normalized_description\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__observation') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , encounter_id\r\n , observation_date\r\n , result\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n , normalized_description\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__observation') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n{% else %}\r\nselect\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as encounter_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as observation_date\r\n , cast(null as {{ dbt.type_string() }} ) as result\r\n , cast(null as {{ dbt.type_string() }} ) as source_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as source_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code_type\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_code\r\n , cast(null as {{ dbt.type_string() }} ) as normalized_description\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__observation.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__patient": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__patient", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__patient.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__patient.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__patient", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__patient"], "alias": "_stg_patient", "checksum": {"name": "sha256", "checksum": "34acce40b2eeb227e56056c3e339265f96561013b169cabc3c9e5657936d4d43"}, "config": {"enabled": true, "alias": "_stg_patient", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging eligibility from the input layer.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "sex": {"name": "sex", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "birth_date": {"name": "birth_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "death_date": {"name": "death_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_patient", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2304215, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , sex\r\n , birth_date\r\n , death_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__patient') }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__patient.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_core__procedure": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_core__procedure.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_core__procedure", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_core__procedure"], "alias": "_stg_procedure", "checksum": {"name": "sha256", "checksum": "3676fea7025af203eade630b21e7f6597e89f94c102c0f48a675d0f6f48c8c44"}, "config": {"enabled": true, "alias": "_stg_procedure", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging procedures from core.", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_date": {"name": "procedure_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code_type": {"name": "source_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "source_code": {"name": "source_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code_type": {"name": "normalized_code_type", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalized_code": {"name": "normalized_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_1": {"name": "modifier_1", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_2": {"name": "modifier_2", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_3": {"name": "modifier_3", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_4": {"name": "modifier_4", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "modifier_5": {"name": "modifier_5", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_procedure", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.233418, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\nselect\r\n patient_id\r\n , encounter_id\r\n , procedure_date\r\n , source_code_type\r\n , source_code\r\n , normalized_code_type\r\n , normalized_code\r\n , modifier_1\r\n , modifier_2\r\n , modifier_3\r\n , modifier_4\r\n , modifier_5\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_core__procedure.sql", "compiled": true, "compiled_code": "\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_medical_claim": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_medical_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_medical_claim.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_medical_claim.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_medical_claim", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_medical_claim"], "alias": "_stg_medical_claim", "checksum": {"name": "sha256", "checksum": "bea109905ed6c5bab03b27d21c74711d48674a5a1be171f20a9eecd53ec201ca"}, "config": {"enabled": true, "alias": "_stg_medical_claim", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging medical claims from the input layer. Creates an empty table if using clinical only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_start_date": {"name": "claim_start_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claim_end_date": {"name": "claim_end_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service": {"name": "place_of_service", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_code": {"name": "hcpcs_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_medical_claim", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2354171, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , claim_id\r\n , claim_start_date\r\n , claim_end_date\r\n , place_of_service_code\r\n , hcpcs_code\r\n , hcpcs_modifier_1\r\n , hcpcs_modifier_2\r\n , hcpcs_modifier_3\r\n , hcpcs_modifier_4\r\n , hcpcs_modifier_5\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medical_claim') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , claim_id\r\n , claim_start_date\r\n , claim_end_date\r\n , place_of_service_code\r\n , hcpcs_code\r\n , hcpcs_modifier_1\r\n , hcpcs_modifier_2\r\n , hcpcs_modifier_3\r\n , hcpcs_modifier_4\r\n , hcpcs_modifier_5\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__medical_claim') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as claim_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_start_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_end_date\r\n , cast(null as {{ dbt.type_string() }} ) as place_of_service_code\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_code\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_1\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_2\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_3\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_4\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_5\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n{% else %}\r\nselect\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , cast(null as {{ dbt.type_string() }} ) as claim_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_start_date\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as claim_end_date\r\n , cast(null as {{ dbt.type_string() }} ) as place_of_service_code\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_code\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_1\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_2\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_3\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_4\r\n , cast(null as {{ dbt.type_string() }} ) as hcpcs_modifier_5\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_medical_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.quality_measures__stg_pharmacy_claim": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__stg_pharmacy_claim", "resource_type": "model", "package_name": "the_tuva_project", "path": "quality_measures\\staging\\quality_measures__stg_pharmacy_claim.sql", "original_file_path": "models\\quality_measures\\staging\\quality_measures__stg_pharmacy_claim.sql", "unique_id": "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "fqn": ["the_tuva_project", "quality_measures", "staging", "quality_measures__stg_pharmacy_claim"], "alias": "_stg_pharmacy_claim", "checksum": {"name": "sha256", "checksum": "7ca2b8609fe77ecfb53a38852bbb5222ac2c6a43bf0459958874a89be5c7e4c3"}, "config": {"enabled": true, "alias": "_stg_pharmacy_claim", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["quality_measures"], "description": "Staging pharmacy claims from the input layer. Creates an empty table if using clinical only.\n", "columns": {"patient_id": {"name": "patient_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dispensing_date": {"name": "dispensing_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ndc_code": {"name": "ndc_code", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_supply": {"name": "days_supply", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_date": {"name": "paid_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\quality_measures\\quality_measures_models.yml", "build_path": null, "unrendered_config": {"schema": "quality_measures", "alias": "_stg_pharmacy_claim", "tags": "quality_measures", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2374284, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , paid_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__pharmacy_claim') }}\r\n\r\n{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\nselect\r\n patient_id\r\n , dispensing_date\r\n , ndc_code\r\n , days_supply\r\n , paid_date\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__pharmacy_claim') }}\r\n\r\n{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n\r\n{% if target.type == 'fabric' %}\r\n select top 0\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_int() }} ) as days_supply\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date\r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n{% else %}\r\n select\r\n cast(null as {{ dbt.type_string() }} ) as patient_id\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as dispensing_date\r\n , cast(null as {{ dbt.type_string() }} ) as ndc_code\r\n , cast(null as {{ dbt.type_int() }} ) as days_supply\r\n , {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as paid_date \r\n , cast(null as {{ dbt.type_timestamp() }} ) as tuva_last_run\r\n limit 0\r\n{%- endif %}\r\n\r\n{%- endif %}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\staging\\quality_measures__stg_pharmacy_claim.sql", "compiled": true, "compiled_code": "\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_augmented": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__encounter_augmented", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\final\\readmissions__encounter_augmented.sql", "original_file_path": "models\\readmissions\\final\\readmissions__encounter_augmented.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_augmented", "fqn": ["the_tuva_project", "readmissions", "final", "readmissions__encounter_augmented"], "alias": "encounter_augmented", "checksum": {"name": "sha256", "checksum": "e1793013f5278282a796e57e91a60d7580446d0b21b35e399acf095c0bb4033b"}, "config": {"enabled": true, "alias": "encounter_augmented", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model includes all encounters from the stg_encounter model, and for each encounter_id we add fields relevant for the encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The date of discharge for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "The valid 2-digit discharge status for the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "An ID for the facility where the inpatient visit occurred", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "The MS-DRG associted with the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The number of dollars paid on the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Integer representing the length of stay of the inpatient visit in days", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "index_admission_flag": {"name": "index_admission_flag", "description": "Flag to indicate if the encounter is an index admission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "planned_flag": {"name": "planned_flag", "description": "Flag to indicate if the encounter was planned", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort the encounter belongs to", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__specialty_cohort.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "died_flag": {"name": "died_flag", "description": "Flag to indicate of the patient died in this encounter", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "diagnosis_ccs": {"name": "diagnosis_ccs", "description": "CCS code associated with the primary diagnosis for the encounter", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "disqualified_encounter_flag": {"name": "disqualified_encounter_flag", "description": "A flag that indicates whether this encounter is disqualified from being used in readmission measures for any critical data quality problem.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_admit_date_flag": {"name": "missing_admit_date_flag", "description": "A flag that indicates whether the admit date is missing from this encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_discharge_date_flag": {"name": "missing_discharge_date_flag", "description": "A flag that indicates whether the discharge date is missing from this encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "admit_after_discharge_flag": {"name": "admit_after_discharge_flag", "description": "A flag that indicates whether the admit date for the encounter is after the discharge date for the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_discharge_disposition_code_flag": {"name": "missing_discharge_disposition_code_flag", "description": "A flag that indicates whether the discharge status code is missing for the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "invalid_discharge_disposition_code_flag": {"name": "invalid_discharge_disposition_code_flag", "description": "A flag that indicates whether the discharge status code that is present for this encounter is invalid. This flag is 1 only when the discharge status code is present but invalid.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_primary_diagnosis_flag": {"name": "missing_primary_diagnosis_flag", "description": "A flag that indicates whether there is no primary diagnosis associated with the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "multiple_primary_diagnoses_flag": {"name": "multiple_primary_diagnoses_flag", "description": "A flag that indicates whether there are multiple primary diagnoses associated with the encounter.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "invalid_primary_diagnosis_code_flag": {"name": "invalid_primary_diagnosis_code_flag", "description": "A flag that indicates whether the primary diagnosis present for this encounter is invalid, i.e. a non existing ICD-10-CM code. This flag indicates that a primary diagnosis code is indeed present for the encounter, but it is not a valid ICD-10-CM code.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "no_diagnosis_ccs_flag": {"name": "no_diagnosis_ccs_flag", "description": "A flag that indicates whether there is no CCS diagnosis category associated with the primary ICD-10-CM diagnosis code for the encounter. This flag indicates that there is a valid primary ICD-10-CM diagnosis code associated with the encounter, but there is no CCS diagnosis category associated with that ICD-10-CM code.", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "overlaps_with_another_encounter_flag": {"name": "overlaps_with_another_encounter_flag", "description": "A flag that indicates whether this encounter's dates overlap with those of another encounter in the dataset", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "missing_ms_drg_flag": {"name": "missing_ms_drg_flag", "description": "A flag that indicates whether this encounter contains a claim with a missing ms-drg code", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "invalid_ms_drg_flag": {"name": "invalid_ms_drg_flag", "description": "A flag that indicates whether this encounter contains a claim with an invalid missing ms-drg code", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "encounter_augmented", "tags": "readmissions", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2623265, "relation_name": "dev_thuxuan.readmissions.encounter_augmented", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list all encounters from the stg_encounter model\r\n-- and we augment them with extra fields\r\n-- that are relevant for readmission measures\r\nselect\r\n aa.encounter_id,\r\n aa.patient_id,\r\n aa.admit_date,\r\n aa.discharge_date,\r\n aa.discharge_disposition_code,\r\n aa.facility_id,\r\n aa.ms_drg_code,\r\n aa.paid_amount,\r\n {{ dbt.datediff(\"aa.admit_date\", \"aa.discharge_date\",\"day\") }} as length_of_stay,\r\n case\r\n when bb.encounter_id is not null then 1\r\n\t else 0\r\n end as index_admission_flag,\r\n case\r\n when cc.encounter_id is not null then 1\r\n\t else 0\r\n end as planned_flag,\r\n dd.specialty_cohort,\r\n case\r\n when aa.discharge_disposition_code = '20' then 1\r\n\t else 0\r\n end as died_flag,\r\n ee.diagnosis_ccs,\r\n ee.disqualified_encounter_flag,\r\n ee.missing_admit_date_flag,\r\n ee.missing_discharge_date_flag,\r\n ee.admit_after_discharge_flag,\r\n ee.missing_discharge_disposition_code_flag,\r\n ee.invalid_discharge_disposition_code_flag,\r\n ee.missing_primary_diagnosis_flag,\r\n ee.invalid_primary_diagnosis_code_flag,\r\n ee.no_diagnosis_ccs_flag,\r\n ee.overlaps_with_another_encounter_flag,\r\n ee.missing_ms_drg_flag,\r\n ee.invalid_ms_drg_flag,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom\r\n {{ ref('readmissions__encounter') }} aa\r\n left join {{ ref('readmissions__index_admission') }} bb\r\n on aa.encounter_id = bb.encounter_id\r\n left join {{ ref('readmissions__planned_encounter') }} cc\r\n on aa.encounter_id = cc.encounter_id \r\n left join {{ ref('readmissions__encounter_specialty_cohort') }} dd\r\n on aa.encounter_id = dd.encounter_id\r\n left join {{ ref('readmissions__encounter_data_quality') }} ee\r\n on aa.encounter_id = ee.encounter_id", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__index_admission", "package": null, "version": null}, {"name": "readmissions__planned_encounter", "package": null, "version": null}, {"name": "readmissions__encounter_specialty_cohort", "package": null, "version": null}, {"name": "readmissions__encounter_data_quality", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__index_admission", "model.the_tuva_project.readmissions__planned_encounter", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__encounter_data_quality"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\final\\readmissions__encounter_augmented.sql", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter model\n-- and we augment them with extra fields\n-- that are relevant for readmission measures\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n datediff(\n day,\n aa.admit_date,\n aa.discharge_date\n ) as length_of_stay,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as index_admission_flag,\n case\n when cc.encounter_id is not null then 1\n\t else 0\n end as planned_flag,\n dd.specialty_cohort,\n case\n when aa.discharge_disposition_code = '20' then 1\n\t else 0\n end as died_flag,\n ee.diagnosis_ccs,\n ee.disqualified_encounter_flag,\n ee.missing_admit_date_flag,\n ee.missing_discharge_date_flag,\n ee.admit_after_discharge_flag,\n ee.missing_discharge_disposition_code_flag,\n ee.invalid_discharge_disposition_code_flag,\n ee.missing_primary_diagnosis_flag,\n ee.invalid_primary_diagnosis_code_flag,\n ee.no_diagnosis_ccs_flag,\n ee.overlaps_with_another_encounter_flag,\n ee.missing_ms_drg_flag,\n ee.invalid_ms_drg_flag,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n dev_thuxuan.readmissions._int_encounter aa\n left join dev_thuxuan.readmissions._int_index_admission bb\n on aa.encounter_id = bb.encounter_id\n left join dev_thuxuan.readmissions._int_planned_encounter cc\n on aa.encounter_id = cc.encounter_id \n left join dev_thuxuan.readmissions._int_encounter_specialty_cohort dd\n on aa.encounter_id = dd.encounter_id\n left join dev_thuxuan.readmissions._int_encounter_data_quality ee\n on aa.encounter_id = ee.encounter_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__readmission_summary": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__readmission_summary", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\final\\readmissions__readmission_summary.sql", "original_file_path": "models\\readmissions\\final\\readmissions__readmission_summary.sql", "unique_id": "model.the_tuva_project.readmissions__readmission_summary", "fqn": ["the_tuva_project", "readmissions", "final", "readmissions__readmission_summary"], "alias": "readmission_summary", "checksum": {"name": "sha256", "checksum": "1d3d73370f6f83023227b330fb02f2a03534446a390b8c7ab3cbd36ebb5bd4a5"}, "config": {"enabled": true, "alias": "readmission_summary", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model includes all rows from the encounter_augmented model where disqualified_encounter_flag = 0 (all rows for encounters that are not disqualified for data quality issues). For each of these encounters we add fields to indicate whether it had a readmission and, when a readmission was present, to show relevant fields for the readmission.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The date of discharge for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_code": {"name": "discharge_disposition_code", "description": "The valid 2-digit discharge status for the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility_id": {"name": "facility_id", "description": "An ID for the facility where the inpatient visit occurred", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_code": {"name": "ms_drg_code", "description": "The MS-DRG associted with the inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "paid_amount": {"name": "paid_amount", "description": "The amount paid for the visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "length_of_stay": {"name": "length_of_stay", "description": "Integer representing the length of stay of the inpatient visit in days", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "index_admission_flag": {"name": "index_admission_flag", "description": "Flag to indicate if the encounter is an index admission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "planned_flag": {"name": "planned_flag", "description": "Flag to indicate if the encounter was planned", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort the encounter belongs to", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__specialty_cohort.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "died_flag": {"name": "died_flag", "description": "Flag to indicate of the patient died in this encounter", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "diagnosis_ccs": {"name": "diagnosis_ccs", "description": "CCS code associated with the primary diagnosis for the encounter", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "had_readmission_flag": {"name": "had_readmission_flag", "description": "A flag to indicate whether the encounter had a readmission any number of days after discharge", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "days_to_readmit": {"name": "days_to_readmit", "description": "An integer to indicate the number of days to readmission", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "readmit_30_flag": {"name": "readmit_30_flag", "description": "A flag to indicate whether the encounter had a 30-day readmission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "unplanned_readmit_30_flag": {"name": "unplanned_readmit_30_flag", "description": "A flag to indicate whether the encounter had an unplanned 30-day readmission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_encounter_id": {"name": "readmission_encounter_id", "description": "The unique identifier for the readmission encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_admit_date": {"name": "readmission_admit_date", "description": "The date of admission for the readmission inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_discharge_date": {"name": "readmission_discharge_date", "description": "The date of discharge for the readmission inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_discharge_disposition_code": {"name": "readmission_discharge_disposition_code", "description": "The valid 2-digit discharge status for the readmission inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__discharge_disposition.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_facility": {"name": "readmission_facility", "description": "A name or ID for the facility where the readmission inpatient visit occured", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__provider.csv", "terminology_note": "**Note: this terminology set is too large to be loaded as a seed and is instead loaded from public cloud storage for supported adapters."}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_ms_drg": {"name": "readmission_ms_drg", "description": "The MS-DRG associted with the readmission inpatient visit", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__ms_drg.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_length_of_stay": {"name": "readmission_length_of_stay", "description": "Integer representing the length of stay of the readmission inpatient visit in days", "meta": {}, "data_type": "integer", "constraints": [], "quote": null, "tags": []}, "readmission_index_admission_flag": {"name": "readmission_index_admission_flag", "description": "Flag to indicate if the readmission encounter is an index admission", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_planned_flag": {"name": "readmission_planned_flag", "description": "Flag to indicate if the readmission encounter was planned", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_specialty_cohort": {"name": "readmission_specialty_cohort", "description": "Specialty cohort the readmission encounter belongs to", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__specialty_cohort.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmission_died_flag": {"name": "readmission_died_flag", "description": "Flag to indicate of the patient died in the readmission encounter", "meta": {}, "data_type": "boolean", "constraints": [], "quote": null, "tags": []}, "readmission_diagnosis_ccs": {"name": "readmission_diagnosis_ccs", "description": "CCS code associated with the primary diagnosis for the readmission encounter", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/readmissions/readmissions__acute_diagnosis_ccs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "tuva_last_run": {"name": "tuva_last_run", "description": "The time at with the model was materialized. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "readmission_summary", "tags": "readmissions", "materialized": "table", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2693307, "relation_name": "dev_thuxuan.readmissions.readmission_summary", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here calculate days to readmission for encounters\r\n-- that had a readmission and create readmission flags\r\n\r\n\r\n-- We create the encounter_sequence integer count\r\n-- which keeps track of what number of encounter each\r\n-- encounter is for a given patient\r\nwith encounter_sequence as (\r\nselect\r\n *,\r\n row_number() over(\r\n partition by patient_id order by admit_date, discharge_date\r\n ) as encounter_seq\r\nfrom {{ ref('readmissions__encounter_augmented') }}\r\nwhere disqualified_encounter_flag = 0\r\n),\r\n\r\n\r\nreadmission_calc as (\r\nselect\r\n aa.encounter_id,\r\n aa.patient_id,\r\n aa.admit_date,\r\n aa.discharge_date,\r\n aa.discharge_disposition_code,\r\n aa.facility_id,\r\n aa.ms_drg_code,\r\n aa.paid_amount,\r\n aa.length_of_stay,\r\n aa.index_admission_flag,\r\n aa.planned_flag,\r\n aa.specialty_cohort,\r\n aa.died_flag,\r\n aa.diagnosis_ccs,\r\n case\r\n when bb.encounter_id is not null then 1\r\n\t else 0\r\n end as had_readmission_flag,\r\n {{ dbt.datediff(\"aa.discharge_date\", \"bb.admit_date\",\"day\") }} as days_to_readmit,\r\n case\r\n when ({{ dbt.datediff(\"aa.discharge_date\", \"bb.admit_date\",\"day\") }}) <= 30 then 1\r\n\t else 0\r\n end as readmit_30_flag,\r\n case\r\n when\r\n\t (({{ dbt.datediff(\"aa.discharge_date\", \"bb.admit_date\", \"day\") }}) <= 30) and (bb.planned_flag = 0) then 1\r\n\t else 0\r\n end as unplanned_readmit_30_flag,\r\n bb.encounter_id as readmission_encounter_id,\r\n bb.admit_date as readmission_admit_date,\r\n bb.discharge_date as readmission_discharge_date,\r\n bb.discharge_disposition_code as readmission_discharge_disposition_code,\r\n bb.facility_id as readmission_facility,\r\n bb.ms_drg_code as readmission_ms_drg,\r\n bb.length_of_stay as readmission_length_of_stay,\r\n bb.index_admission_flag as readmission_index_admission_flag,\r\n bb.planned_flag as readmission_planned_flag,\r\n bb.specialty_cohort as readmission_specialty_cohort,\r\n bb.died_flag as readmission_died_flag,\r\n bb.diagnosis_ccs as readmission_diagnosis_ccs,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom\r\n encounter_sequence aa\r\n left join encounter_sequence bb\r\n on aa.patient_id = bb.patient_id\r\n and aa.encounter_seq + 1 = bb.encounter_seq\r\n)\r\n\r\nselect *\r\nfrom readmission_calc", "language": "sql", "refs": [{"name": "readmissions__encounter_augmented", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.readmissions__encounter_augmented"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\final\\readmissions__readmission_summary.sql", "compiled": true, "compiled_code": "\n\n-- Here calculate days to readmission for encounters\n-- that had a readmission and create readmission flags\n\n\n-- We create the encounter_sequence integer count\n-- which keeps track of what number of encounter each\n-- encounter is for a given patient\nwith encounter_sequence as (\nselect\n *,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom dev_thuxuan.readmissions.encounter_augmented\nwhere disqualified_encounter_flag = 0\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.length_of_stay,\n aa.index_admission_flag,\n aa.planned_flag,\n aa.specialty_cohort,\n aa.died_flag,\n aa.diagnosis_ccs,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as had_readmission_flag,\n datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30 then 1\n\t else 0\n end as readmit_30_flag,\n case\n when\n\t ((datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30) and (bb.planned_flag = 0) then 1\n\t else 0\n end as unplanned_readmit_30_flag,\n bb.encounter_id as readmission_encounter_id,\n bb.admit_date as readmission_admit_date,\n bb.discharge_date as readmission_discharge_date,\n bb.discharge_disposition_code as readmission_discharge_disposition_code,\n bb.facility_id as readmission_facility,\n bb.ms_drg_code as readmission_ms_drg,\n bb.length_of_stay as readmission_length_of_stay,\n bb.index_admission_flag as readmission_index_admission_flag,\n bb.planned_flag as readmission_planned_flag,\n bb.specialty_cohort as readmission_specialty_cohort,\n bb.died_flag as readmission_died_flag,\n bb.diagnosis_ccs as readmission_diagnosis_ccs,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n encounter_sequence aa\n left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\nselect *\nfrom readmission_calc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__encounter.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__encounter.sql", "unique_id": "model.the_tuva_project.readmissions__encounter", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter"], "alias": "_int_encounter", "checksum": {"name": "sha256", "checksum": "b41c4d56d4511fed0352d213fe42b8e87094833014713baeb917afddb62a0aca"}, "config": {"enabled": true, "alias": "_int_encounter", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This is a staging table for the input layer. Each row represents a unique acute inpatient encounter.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "The date of discharge for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_status_code": {"name": "discharge_status_code", "description": "The valid 2-digit discharge status for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "facility": {"name": "facility", "description": "A name or ID for the facility where the inpatient visit occured", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg": {"name": "ms_drg", "description": "The MS-DRG associted with the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.3018453, "relation_name": "dev_thuxuan.readmissions._int_encounter", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Staging model for the input layer:\r\n-- stg_encounter input layer model.\r\n-- This contains one row for every unique encounter in the dataset.\r\n\r\nselect\r\n cast(encounter_id as {{ dbt.type_string() }}) as encounter_id,\r\n cast(patient_id as {{ dbt.type_string() }}) as patient_id,\r\n cast(encounter_start_date as date) as admit_date,\r\n cast(encounter_end_date as date) as discharge_date,\r\n cast(discharge_disposition_code as {{ dbt.type_string() }}) as discharge_disposition_code,\r\n cast(facility_id as {{ dbt.type_string() }}) as facility_id,\r\n cast(ms_drg_code as {{ dbt.type_string() }}) as ms_drg_code,\r\n cast(paid_amount as {{ dbt.type_numeric() }}) as paid_amount,\r\n cast(primary_diagnosis_code as {{ dbt.type_string() }}) as primary_diagnosis_code,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('readmissions__stg_core__encounter') }}", "language": "sql", "refs": [{"name": "readmissions__stg_core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.type_numeric"], "nodes": ["model.the_tuva_project.readmissions__stg_core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__encounter.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__encounter as (\n\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n) -- Staging model for the input layer:\n-- stg_encounter input layer model.\n-- This contains one row for every unique encounter in the dataset.\n\nselect\n cast(encounter_id as TEXT) as encounter_id,\n cast(patient_id as TEXT) as patient_id,\n cast(encounter_start_date as date) as admit_date,\n cast(encounter_end_date as date) as discharge_date,\n cast(discharge_disposition_code as TEXT) as discharge_disposition_code,\n cast(facility_id as TEXT) as facility_id,\n cast(ms_drg_code as TEXT) as ms_drg_code,\n cast(paid_amount as numeric(28,6)) as paid_amount,\n cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__readmissions__stg_core__encounter", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.readmissions__stg_core__encounter", "sql": " __dbt__cte__readmissions__stg_core__encounter as (\n\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_data_quality": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__encounter_data_quality", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__encounter_data_quality.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__encounter_data_quality.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_data_quality", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_data_quality"], "alias": "_int_encounter_data_quality", "checksum": {"name": "sha256", "checksum": "85bf70dcffff48c401c303e894eff2d2e1da14d93417696f3e14fd59a3dfe9f0"}, "config": {"enabled": true, "alias": "_int_encounter_data_quality", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model has the same number of rows as the stg_encounter model. Here we have one row for every unique encounter in the stg_encounter model, and for each encounter we have a flag (disqualified_encounter_flag) to indicte if the encounter is disqualified from being useful for readmission measures. We also have other flags to indicate which specific data quality issues this encounter has that may disqualify it from being used in readmission measures.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_ccs": {"name": "diagnosis_ccs", "description": "The CCS diagnosis category associated with the primary diagnosis of this encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "disqualified_encounter_flag": {"name": "disqualified_encounter_flag", "description": "A flag that indicates whether this encounter is disqualified from being used in readmission measures for any critical data quality problem.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_admit_date_flag": {"name": "missing_admit_date_flag", "description": "A flag that indicates whether the admit date is missing from this encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_discharge_date_flag": {"name": "missing_discharge_date_flag", "description": "A flag that indicates whether the discharge date is missing from this encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_after_discharge_flag": {"name": "admit_after_discharge_flag", "description": "A flag that indicates whether the admit date for the encounter is after the discharge date for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_discharge_status_code_flag": {"name": "missing_discharge_status_code_flag", "description": "A flag that indicates whether the discharge status code is missing for the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_discharge_status_code_flag": {"name": "invalid_discharge_status_code_flag", "description": "A flag that indicates whether the discharge status code that is present for this encounter is invalid. This flag is 1 only when the discharge status code is present but invalid.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "missing_primary_diagnosis_flag": {"name": "missing_primary_diagnosis_flag", "description": "A flag that indicates whether there is no primary diagnosis associated with the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "multiple_primary_diagnosis": {"name": "multiple_primary_diagnosis", "description": "A flag that indicates whether there are multiple primary diagnoses associated with the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "invalid_primary_diagnosis_code": {"name": "invalid_primary_diagnosis_code", "description": "A flag that indicates whether the primary diagnosis present for this encounter is invalid, i.e. a non existing ICD-10-CM code. This flag indicates that a primary diagnosis code is indeed present for the encounter, but it is not a valid ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "no_diagnosis_ccs_flag": {"name": "no_diagnosis_ccs_flag", "description": "A flag that indicates whether there is no CCS diagnosis category associated with the primary ICD-10-CM diagnosis code for the encounter. This flag indicates that there is a valid primary ICD-10-CM diagnosis code associated with the encounter, but there is no CCS diagnosis category associated with that ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "overlaps_with_another_encounter_flag": {"name": "overlaps_with_another_encounter_flag", "description": "A flag that indicates whether this encounter's dates overlap with those of another encounter in the dataset", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_data_quality", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2738338, "relation_name": "dev_thuxuan.readmissions._int_encounter_data_quality", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list all encounters from the stg_encounter table\r\n-- with data quality flags that may disqualify them from\r\n-- being used for readmission measures \r\n\r\n\r\n-- Flag several potential data quality issues\r\n-- with all encounters.\r\n-- Every encounter_id from the stg_encounter model\r\n-- will be here. This CTE should have the same\r\n-- number of rows as the stg_encounter model, i.e.,\r\n-- there is a one to one correspondence between the\r\n-- rows in stg_encounter and this CTE.\r\nwith encounter_data_quality_issues as (\r\nselect\r\n aa.encounter_id,\r\n case\r\n when aa.admit_date is null then 1\r\n\telse 0\r\n end as missing_admit_date_flag,\r\n case\r\n when aa.discharge_date is null then 1\r\n\telse 0\r\n end as missing_discharge_date_flag,\r\n case\r\n when aa.admit_date > aa.discharge_date then 1\r\n\telse 0\r\n end as admit_after_discharge_flag,\r\n case\r\n when aa.discharge_disposition_code is null then 1\r\n\telse 0\r\n end as missing_discharge_disposition_code_flag,\r\n case\r\n when\r\n\t (aa.discharge_disposition_code is not null)\r\n\t and\r\n\t (bb.discharge_disposition_code is null) then 1\r\n\telse 0\r\n end as invalid_discharge_disposition_code_flag,\r\n case\r\n when aa.primary_diagnosis_code is null then 1\r\n else 0\r\n end as missing_primary_diagnosis_flag,\r\n case\r\n when aa.valid_primary_diagnosis_code_flag = 0 then 1\r\n\telse 0\r\n end as invalid_primary_diagnosis_code_flag,\r\n case\r\n when aa.ccs_diagnosis_category is null then 1\r\n\telse 0\r\n end as no_diagnosis_ccs_flag,\r\n aa.ccs_diagnosis_category as diagnosis_ccs,\r\n case\r\n when aa.encounter_id in (select distinct encounter_id_A\r\n\t from {{ ref('readmissions__encounter_overlap') }} )\r\n\t or\r\n\t aa.encounter_id in (select distinct encounter_id_B\r\n\t from {{ ref('readmissions__encounter_overlap') }} )\r\n\tthen 1\r\n\telse 0\r\n end as overlaps_with_another_encounter_flag,\r\n case\r\n when aa.ms_drg_code is null then 1\r\n\telse 0\r\n end as missing_ms_drg_flag,\r\n case\r\n when cc.ms_drg_code is null then 1\r\n\telse 0\r\n end as invalid_ms_drg_flag\r\n\r\nfrom {{ ref('readmissions__encounter_with_ccs') }} aa\r\n left join {{ ref('terminology__discharge_disposition') }} bb\r\n on aa.discharge_disposition_code = bb.discharge_disposition_code\r\n left join {{ ref('terminology__ms_drg') }} cc\r\n on aa.ms_drg_code = cc.ms_drg_code\r\n),\r\n\r\n\r\n-- Here we add a disqualified_encounter_flag.\r\n-- This disqualified_encounter_flag = 1\r\n-- when any of the critical data quality flags\r\n-- from the above CTE are equal to 1.\r\nall_data_quality_flags as (\r\nselect\r\n encounter_id,\r\n diagnosis_ccs,\r\n case\r\n when\r\n\t (missing_admit_date_flag = 1)\r\n\t or\r\n\t (missing_discharge_date_flag = 1)\r\n\t or\r\n\t (admit_after_discharge_flag = 1)\r\n\t or\r\n\t (missing_discharge_disposition_code_flag = 1)\r\n\t or\r\n\t (invalid_discharge_disposition_code_flag = 1)\r\n\t or\r\n\t (missing_primary_diagnosis_flag = 1)\r\n\t or\r\n\t (invalid_primary_diagnosis_code_flag = 1)\r\n\t or\r\n\t (no_diagnosis_ccs_flag = 1)\r\n\t or\r\n\t (overlaps_with_another_encounter_flag = 1)\r\n\t or\r\n\t (missing_ms_drg_flag = 1)\r\n\t or\r\n\t (invalid_ms_drg_flag = 1)\r\n\t then 1\r\n\telse 0\r\n end as disqualified_encounter_flag,\r\n missing_admit_date_flag,\r\n missing_discharge_date_flag,\r\n admit_after_discharge_flag,\r\n missing_discharge_disposition_code_flag,\r\n invalid_discharge_disposition_code_flag,\r\n missing_primary_diagnosis_flag,\r\n invalid_primary_diagnosis_code_flag,\r\n no_diagnosis_ccs_flag,\r\n overlaps_with_another_encounter_flag,\r\n missing_ms_drg_flag,\r\n invalid_ms_drg_flag\r\nfrom encounter_data_quality_issues\r\n) \r\n\r\n\r\n\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom all_data_quality_flags", "language": "sql", "refs": [{"name": "readmissions__encounter_overlap", "package": null, "version": null}, {"name": "readmissions__encounter_overlap", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "terminology__discharge_disposition", "package": null, "version": null}, {"name": "terminology__ms_drg", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter_overlap", "model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__encounter_data_quality.sql", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter table\n-- with data quality flags that may disqualify them from\n-- being used for readmission measures \n\n\n-- Flag several potential data quality issues\n-- with all encounters.\n-- Every encounter_id from the stg_encounter model\n-- will be here. This CTE should have the same\n-- number of rows as the stg_encounter model, i.e.,\n-- there is a one to one correspondence between the\n-- rows in stg_encounter and this CTE.\nwith encounter_data_quality_issues as (\nselect\n aa.encounter_id,\n case\n when aa.admit_date is null then 1\n\telse 0\n end as missing_admit_date_flag,\n case\n when aa.discharge_date is null then 1\n\telse 0\n end as missing_discharge_date_flag,\n case\n when aa.admit_date > aa.discharge_date then 1\n\telse 0\n end as admit_after_discharge_flag,\n case\n when aa.discharge_disposition_code is null then 1\n\telse 0\n end as missing_discharge_disposition_code_flag,\n case\n when\n\t (aa.discharge_disposition_code is not null)\n\t and\n\t (bb.discharge_disposition_code is null) then 1\n\telse 0\n end as invalid_discharge_disposition_code_flag,\n case\n when aa.primary_diagnosis_code is null then 1\n else 0\n end as missing_primary_diagnosis_flag,\n case\n when aa.valid_primary_diagnosis_code_flag = 0 then 1\n\telse 0\n end as invalid_primary_diagnosis_code_flag,\n case\n when aa.ccs_diagnosis_category is null then 1\n\telse 0\n end as no_diagnosis_ccs_flag,\n aa.ccs_diagnosis_category as diagnosis_ccs,\n case\n when aa.encounter_id in (select distinct encounter_id_A\n\t from dev_thuxuan.readmissions._int_encounter_overlap )\n\t or\n\t aa.encounter_id in (select distinct encounter_id_B\n\t from dev_thuxuan.readmissions._int_encounter_overlap )\n\tthen 1\n\telse 0\n end as overlaps_with_another_encounter_flag,\n case\n when aa.ms_drg_code is null then 1\n\telse 0\n end as missing_ms_drg_flag,\n case\n when cc.ms_drg_code is null then 1\n\telse 0\n end as invalid_ms_drg_flag\n\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs aa\n left join dev_thuxuan.terminology.discharge_disposition bb\n on aa.discharge_disposition_code = bb.discharge_disposition_code\n left join dev_thuxuan.terminology.ms_drg cc\n on aa.ms_drg_code = cc.ms_drg_code\n),\n\n\n-- Here we add a disqualified_encounter_flag.\n-- This disqualified_encounter_flag = 1\n-- when any of the critical data quality flags\n-- from the above CTE are equal to 1.\nall_data_quality_flags as (\nselect\n encounter_id,\n diagnosis_ccs,\n case\n when\n\t (missing_admit_date_flag = 1)\n\t or\n\t (missing_discharge_date_flag = 1)\n\t or\n\t (admit_after_discharge_flag = 1)\n\t or\n\t (missing_discharge_disposition_code_flag = 1)\n\t or\n\t (invalid_discharge_disposition_code_flag = 1)\n\t or\n\t (missing_primary_diagnosis_flag = 1)\n\t or\n\t (invalid_primary_diagnosis_code_flag = 1)\n\t or\n\t (no_diagnosis_ccs_flag = 1)\n\t or\n\t (overlaps_with_another_encounter_flag = 1)\n\t or\n\t (missing_ms_drg_flag = 1)\n\t or\n\t (invalid_ms_drg_flag = 1)\n\t then 1\n\telse 0\n end as disqualified_encounter_flag,\n missing_admit_date_flag,\n missing_discharge_date_flag,\n admit_after_discharge_flag,\n missing_discharge_disposition_code_flag,\n invalid_discharge_disposition_code_flag,\n missing_primary_diagnosis_flag,\n invalid_primary_diagnosis_code_flag,\n no_diagnosis_ccs_flag,\n overlaps_with_another_encounter_flag,\n missing_ms_drg_flag,\n invalid_ms_drg_flag\nfrom encounter_data_quality_issues\n) \n\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom all_data_quality_flags", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_overlap": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__encounter_overlap", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__encounter_overlap.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__encounter_overlap.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_overlap", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_overlap"], "alias": "_int_encounter_overlap", "checksum": {"name": "sha256", "checksum": "f962709bed5f4396f7956a8658c9f97ea39e81b7ab403a706e0bc323fe61f253"}, "config": {"enabled": true, "alias": "_int_encounter_overlap", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all pairs of encounters that have some date overlap.", "columns": {"patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id_A": {"name": "encounter_id_A", "description": "Unique identifier for one of the overlapping encounters", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "encounter_id_B": {"name": "encounter_id_B", "description": "Unique identifier for the other overlapping encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_overlap", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2758343, "relation_name": "dev_thuxuan.readmissions._int_encounter_overlap", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we give a list of all pairs of encounters\r\n-- that have some date overlap.\r\n\r\n\r\nwith encounters_with_row_num as (\r\nselect\r\n encounter_id,\r\n patient_id,\r\n admit_date,\r\n discharge_date,\r\n row_number() over (\r\n partition by patient_id order by encounter_id\r\n\t) as row_num\r\nfrom {{ ref('readmissions__encounter') }}\r\n),\r\n\r\n\r\ncartesian as (\r\nselect\r\n aa.encounter_id as encounter_id_A,\r\n bb.encounter_id as encounter_id_B,\r\n aa.patient_id,\r\n aa.admit_date as Ai,\r\n aa.discharge_date as Af,\r\n bb.admit_date as Bi,\r\n bb.discharge_date as Bf,\r\n case\r\n when (aa.admit_date between bb.admit_date and bb.discharge_date) or (aa.discharge_date between bb.admit_date and bb.discharge_date) or\r\n (bb.admit_date between aa.admit_date and aa.discharge_date) or (bb.discharge_date between aa.admit_date and aa.discharge_date)\r\n then 1\r\n else 0\r\n end as overlap\r\n from encounters_with_row_num aa\r\n left join encounters_with_row_num bb\r\n on aa.patient_id = bb.patient_id and aa.row_num < bb.row_num\r\n),\r\n\r\n\r\noverlapping_pairs\r\nas\r\n(\r\n select\r\n patient_id,\r\n encounter_id_A,\r\n\tencounter_id_B\r\n from cartesian\r\n where overlap = 1\r\n)\r\n\r\n\r\n\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom overlapping_pairs", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__encounter_overlap.sql", "compiled": true, "compiled_code": "\n\n-- Here we give a list of all pairs of encounters\n-- that have some date overlap.\n\n\nwith encounters_with_row_num as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over (\n partition by patient_id order by encounter_id\n\t) as row_num\nfrom dev_thuxuan.readmissions._int_encounter\n),\n\n\ncartesian as (\nselect\n aa.encounter_id as encounter_id_A,\n bb.encounter_id as encounter_id_B,\n aa.patient_id,\n aa.admit_date as Ai,\n aa.discharge_date as Af,\n bb.admit_date as Bi,\n bb.discharge_date as Bf,\n case\n when (aa.admit_date between bb.admit_date and bb.discharge_date) or (aa.discharge_date between bb.admit_date and bb.discharge_date) or\n (bb.admit_date between aa.admit_date and aa.discharge_date) or (bb.discharge_date between aa.admit_date and aa.discharge_date)\n then 1\n else 0\n end as overlap\n from encounters_with_row_num aa\n left join encounters_with_row_num bb\n on aa.patient_id = bb.patient_id and aa.row_num < bb.row_num\n),\n\n\noverlapping_pairs\nas\n(\n select\n patient_id,\n encounter_id_A,\n\tencounter_id_B\n from cartesian\n where overlap = 1\n)\n\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom overlapping_pairs", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_specialty_cohort": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__encounter_specialty_cohort", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__encounter_specialty_cohort.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__encounter_specialty_cohort.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_specialty_cohort", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_specialty_cohort"], "alias": "_int_encounter_specialty_cohort", "checksum": {"name": "sha256", "checksum": "ae3d6ba69602fe68d9762ac0859dcc14c90c167e793504aaef61d5671f250910"}, "config": {"enabled": true, "alias": "_int_encounter_specialty_cohort", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists the specialty cohort associated with each inpatient encounter. All encounters in the stg_encounter model are present here, and each gets a specialty cohort assigned from the following list of 5 options: Surgery/Gynecology, Medicine, Cardiorespiratory, Cardiovascular, Neurology. Encounters that don't have a specialty cohort get 'Medicine' assigned by default.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "The specialty cohort associated with the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_specialty_cohort", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2778342, "relation_name": "dev_thuxuan.readmissions._int_encounter_specialty_cohort", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list the specialty cohort for each encounter that has\r\n-- an associated specialty cohort.\r\n-- There are 5 possible specialty cohorts:\r\n-- [1] Medicine\r\n-- [2] Surgery/Gynecology\r\n-- [3] Cardiology\r\n-- [4] Cardiovascular\r\n-- [5] Neurology\r\n-- An encounter that has an ICD-10-PCS procedure code or a\r\n-- CCS procedure category that corresponds to the\r\n-- 'Surgery/Gynecology' cohort will always be in that cohort.\r\n-- For encounters that are not in the 'Surgery/Gynecology' cohort,\r\n-- we then check to see if they are in one of the other 4 cohorts.\r\n\r\n--ranking to eventually assign a cohort to encounters in multiple cohorts\r\nwith cohort_ranks as (\r\n select 'Surgery/Gynecology' as cohort, 1 as c_rank\r\n union all\r\n select 'Cardiorespiratory' as cohort, 2 as c_rank\r\n union all\r\n select 'Cardiovascular' as cohort, 3 as c_rank\r\n union all\r\n select 'Neurology' as cohort, 4 as c_rank\r\n union all\r\n select 'Medicine' as cohort, 5 as c_rank\r\n)\r\n\r\n\r\n--get all encounter ids in any procedure or diagnosis based cohorts\r\n, all_encounter_cohorts as (\r\n\r\n --encounter ids in procedure based cohorts\r\n select procs.encounter_id, 1 as c_rank\r\n from {{ ref('readmissions__procedure_ccs') }} procs\r\n left join {{ ref('readmissions__surgery_gynecology_cohort') }} sgc\r\n on procs.procedure_code = sgc.icd_10_pcs\r\n left join {{ ref('readmissions__specialty_cohort') }} sgsc\r\n on procs.ccs_procedure_category = sgsc.ccs and sgsc.specialty_cohort = 'Surgery/Gynecology'\r\n where sgc.icd_10_pcs is not null or sgsc.ccs is not null\r\n\r\n union all\r\n\r\n --encounter ids in diagnosis based cohorts\r\n select diag.encounter_id, cohort_ranks.c_rank\r\n from {{ ref('readmissions__encounter_with_ccs') }} diag\r\n inner join {{ ref('readmissions__specialty_cohort') }} sc\r\n on diag.ccs_diagnosis_category = sc.ccs and sc.procedure_or_diagnosis = 'Diagnosis'\r\n inner join cohort_ranks\r\n on sc.specialty_cohort = cohort_ranks.cohort\r\n)\r\n\r\n\r\n-- getting one cohort per encounter\r\n, main_encounter_cohort as (\r\n select encounter_id, min(c_rank) as main_c_rank\r\n from all_encounter_cohorts\r\n group by encounter_id\r\n\r\n)\r\n\r\n\r\n--getting all encounters, with labeled cohorts, if no cohort cohort is \"medicine\"\r\nselect enc.encounter_id, coalesce(cohort_ranks.cohort, 'Medicine') as specialty_cohort, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('readmissions__encounter') }} enc\r\nleft join main_encounter_cohort mec\r\n on enc.encounter_id = mec.encounter_id\r\nleft join cohort_ranks\r\n on mec.main_c_rank = cohort_ranks.c_rank", "language": "sql", "refs": [{"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__surgery_gynecology_cohort", "package": null, "version": null}, {"name": "readmissions__specialty_cohort", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__specialty_cohort", "package": null, "version": null}, {"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__surgery_gynecology_cohort", "seed.the_tuva_project.readmissions__specialty_cohort", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__encounter_specialty_cohort.sql", "compiled": true, "compiled_code": "\n\n-- Here we list the specialty cohort for each encounter that has\n-- an associated specialty cohort.\n-- There are 5 possible specialty cohorts:\n-- [1] Medicine\n-- [2] Surgery/Gynecology\n-- [3] Cardiology\n-- [4] Cardiovascular\n-- [5] Neurology\n-- An encounter that has an ICD-10-PCS procedure code or a\n-- CCS procedure category that corresponds to the\n-- 'Surgery/Gynecology' cohort will always be in that cohort.\n-- For encounters that are not in the 'Surgery/Gynecology' cohort,\n-- we then check to see if they are in one of the other 4 cohorts.\n\n--ranking to eventually assign a cohort to encounters in multiple cohorts\nwith cohort_ranks as (\n select 'Surgery/Gynecology' as cohort, 1 as c_rank\n union all\n select 'Cardiorespiratory' as cohort, 2 as c_rank\n union all\n select 'Cardiovascular' as cohort, 3 as c_rank\n union all\n select 'Neurology' as cohort, 4 as c_rank\n union all\n select 'Medicine' as cohort, 5 as c_rank\n)\n\n\n--get all encounter ids in any procedure or diagnosis based cohorts\n, all_encounter_cohorts as (\n\n --encounter ids in procedure based cohorts\n select procs.encounter_id, 1 as c_rank\n from dev_thuxuan.readmissions._int_procedure_ccs procs\n left join dev_thuxuan.readmissions._value_set_surgery_gynecology_cohort sgc\n on procs.procedure_code = sgc.icd_10_pcs\n left join dev_thuxuan.readmissions._value_set_specialty_cohort sgsc\n on procs.ccs_procedure_category = sgsc.ccs and sgsc.specialty_cohort = 'Surgery/Gynecology'\n where sgc.icd_10_pcs is not null or sgsc.ccs is not null\n\n union all\n\n --encounter ids in diagnosis based cohorts\n select diag.encounter_id, cohort_ranks.c_rank\n from dev_thuxuan.readmissions._int_encounter_with_ccs diag\n inner join dev_thuxuan.readmissions._value_set_specialty_cohort sc\n on diag.ccs_diagnosis_category = sc.ccs and sc.procedure_or_diagnosis = 'Diagnosis'\n inner join cohort_ranks\n on sc.specialty_cohort = cohort_ranks.cohort\n)\n\n\n-- getting one cohort per encounter\n, main_encounter_cohort as (\n select encounter_id, min(c_rank) as main_c_rank\n from all_encounter_cohorts\n group by encounter_id\n\n)\n\n\n--getting all encounters, with labeled cohorts, if no cohort cohort is \"medicine\"\nselect enc.encounter_id, coalesce(cohort_ranks.cohort, 'Medicine') as specialty_cohort, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter enc\nleft join main_encounter_cohort mec\n on enc.encounter_id = mec.encounter_id\nleft join cohort_ranks\n on mec.main_c_rank = cohort_ranks.c_rank", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__encounter_with_ccs": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__encounter_with_ccs", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__encounter_with_ccs.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__encounter_with_ccs.sql", "unique_id": "model.the_tuva_project.readmissions__encounter_with_ccs", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__encounter_with_ccs"], "alias": "_int_encounter_with_ccs", "checksum": {"name": "sha256", "checksum": "1f13f09332a3fe5b1738a86bd295a488442f4d47dffe1c4829465cb450b654d4"}, "config": {"enabled": true, "alias": "_int_encounter_with_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_encounter_with_ccs", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2808347, "relation_name": "dev_thuxuan.readmissions._int_encounter_with_ccs", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we add a CCS diagnosis category to\r\n-- every encounter that we can add a CCS diagnosis category to.\r\n-- The CCS diagnosis category is found using\r\n-- the encounter's primary diagnosis code.\r\n\r\n\r\nselect\r\n aa.encounter_id,\r\n aa.patient_id,\r\n aa.admit_date,\r\n aa.discharge_date,\r\n aa.discharge_disposition_code,\r\n aa.facility_id,\r\n aa.ms_drg_code,\r\n aa.paid_amount,\r\n aa.primary_diagnosis_code,\r\n\r\n case\r\n when bb.icd_10_cm is not null then 1\r\n else 0\r\n end as valid_primary_diagnosis_code_flag,\r\n\r\n cc.ccs_diagnosis_category,\r\n\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\n\r\nfrom\r\n {{ ref('readmissions__encounter') }} aa\r\n left join {{ ref('terminology__icd_10_cm') }} bb\r\n on aa.primary_diagnosis_code = bb.icd_10_cm\r\n left join {{ ref('readmissions__icd_10_cm_to_ccs') }} cc\r\n on aa.primary_diagnosis_code = cc.icd_10_cm", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "terminology__icd_10_cm", "package": null, "version": null}, {"name": "readmissions__icd_10_cm_to_ccs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__encounter_with_ccs.sql", "compiled": true, "compiled_code": "\n\n-- Here we add a CCS diagnosis category to\n-- every encounter that we can add a CCS diagnosis category to.\n-- The CCS diagnosis category is found using\n-- the encounter's primary diagnosis code.\n\n\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.primary_diagnosis_code,\n\n case\n when bb.icd_10_cm is not null then 1\n else 0\n end as valid_primary_diagnosis_code_flag,\n\n cc.ccs_diagnosis_category,\n\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n\nfrom\n dev_thuxuan.readmissions._int_encounter aa\n left join dev_thuxuan.terminology.icd_10_cm bb\n on aa.primary_diagnosis_code = bb.icd_10_cm\n left join dev_thuxuan.readmissions._value_set_icd_10_cm_to_ccs cc\n on aa.primary_diagnosis_code = cc.icd_10_cm", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__exclusion": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__exclusion", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__exclusion.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__exclusion.sql", "unique_id": "model.the_tuva_project.readmissions__exclusion", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__exclusion"], "alias": "_int_exclusion", "checksum": {"name": "sha256", "checksum": "b31e6649264b98b4fe7df0754f44c05dc3c88992718a139f0df3942b3920e93d"}, "config": {"enabled": true, "alias": "_int_exclusion", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters that are excluded from being index admissions because they belong to one of the exclusion categories.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_exclusion", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2838337, "relation_name": "dev_thuxuan.readmissions._int_exclusion", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list encounter_ids that are excluded\r\n-- from being index admissions because they\r\n-- belong to one of these categories:\r\n-- [1] Medical Treatment of Cancer\r\n-- [2] Rehabilitation\r\n-- [3] Psychiatric\r\n\r\n\r\n-- encounter_ids for encounters that should be\r\n-- excluded because they belong to one of the\r\n-- exclusion categories\r\nwith exclusions as (\r\nselect distinct encounter_id\r\nfrom {{ ref('readmissions__encounter_with_ccs') }}\r\nwhere\r\n(ccs_diagnosis_category is not null)\r\nand\r\n(\r\nccs_diagnosis_category in\r\n (select distinct ccs_diagnosis_category\r\n from {{ ref('readmissions__exclusion_ccs_diagnosis_category') }} )\r\n)\r\n)\r\n\r\n\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom exclusions", "language": "sql", "refs": [{"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__exclusion_ccs_diagnosis_category", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__exclusion.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that are excluded\n-- from being index admissions because they\n-- belong to one of these categories:\n-- [1] Medical Treatment of Cancer\n-- [2] Rehabilitation\n-- [3] Psychiatric\n\n\n-- encounter_ids for encounters that should be\n-- excluded because they belong to one of the\n-- exclusion categories\nwith exclusions as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs\nwhere\n(ccs_diagnosis_category is not null)\nand\n(\nccs_diagnosis_category in\n (select distinct ccs_diagnosis_category\n from dev_thuxuan.readmissions._value_set_exclusion_ccs_diagnosis_category )\n)\n)\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__index_admission": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__index_admission", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__index_admission.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__index_admission.sql", "unique_id": "model.the_tuva_project.readmissions__index_admission", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__index_admission"], "alias": "_int_index_admission", "checksum": {"name": "sha256", "checksum": "dcb38723afc9f460fa4a604542fc958d1594b88e866be06132a22b1d40007e62"}, "config": {"enabled": true, "alias": "_int_index_admission", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all index admissions for the hospital wide readmissions measure. These represent encounter_ids that meet the requirements to be an index admission for the HWR measure.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_index_admission", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2868373, "relation_name": "dev_thuxuan.readmissions._int_index_admission", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list all index admissions for the hospital wide readmissions\r\n-- measure.\r\n-- These represent encounter_ids that meet the requirements to be an\r\n-- index admission for the HWR measure.\r\n-- These are the requirements for a hospitalization to be an index admission\r\n-- for the HWR measure:\r\n--\r\n-- Time Requirement: The discharge data must be at least 30 days\r\n-- earlier than the last dischareg date available\r\n-- in the dataset.\r\n-- \r\n-- Discharge Requirements: The patient must not be discharged to another\r\n-- acute care hospital; the patient must not have\r\n-- left against medical advice; and the patient\r\n-- must be alive at discharge.\r\n--\r\n-- Diagnosis Requirements: Exclude encounters where based on the CCS\r\n-- (exclusions) diagnosis category we know the encounter was\r\n-- for medical treatment of cancer, rehabilitation,\r\n-- or psychiatric reasons.\r\n\r\n\r\n\r\nselect distinct a.encounter_id, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('readmissions__encounter') }} a\r\ninner join {{ ref('readmissions__index_time_requirement') }} b\r\n on a.encounter_id = b.encounter_id\r\ninner join {{ ref('readmissions__index_discharge_requirement') }} c\r\n on a.encounter_id = c.encounter_id\r\nleft join {{ ref('readmissions__exclusion') }} d\r\n on a.encounter_id = d.encounter_id\r\nwhere d.encounter_id is null", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__index_time_requirement", "package": null, "version": null}, {"name": "readmissions__index_discharge_requirement", "package": null, "version": null}, {"name": "readmissions__exclusion", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__index_time_requirement", "model.the_tuva_project.readmissions__index_discharge_requirement", "model.the_tuva_project.readmissions__exclusion"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__index_admission.sql", "compiled": true, "compiled_code": "\n\n-- Here we list all index admissions for the hospital wide readmissions\n-- measure.\n-- These represent encounter_ids that meet the requirements to be an\n-- index admission for the HWR measure.\n-- These are the requirements for a hospitalization to be an index admission\n-- for the HWR measure:\n--\n-- Time Requirement: The discharge data must be at least 30 days\n-- earlier than the last dischareg date available\n-- in the dataset.\n-- \n-- Discharge Requirements: The patient must not be discharged to another\n-- acute care hospital; the patient must not have\n-- left against medical advice; and the patient\n-- must be alive at discharge.\n--\n-- Diagnosis Requirements: Exclude encounters where based on the CCS\n-- (exclusions) diagnosis category we know the encounter was\n-- for medical treatment of cancer, rehabilitation,\n-- or psychiatric reasons.\n\n\n\nselect distinct a.encounter_id, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter a\ninner join dev_thuxuan.readmissions._int_index_time_requirement b\n on a.encounter_id = b.encounter_id\ninner join dev_thuxuan.readmissions._int_index_discharge_requirement c\n on a.encounter_id = c.encounter_id\nleft join dev_thuxuan.readmissions._int_exclusion d\n on a.encounter_id = d.encounter_id\nwhere d.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__index_discharge_requirement": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__index_discharge_requirement", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__index_discharge_requirement.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__index_discharge_requirement.sql", "unique_id": "model.the_tuva_project.readmissions__index_discharge_requirement", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__index_discharge_requirement"], "alias": "_int_index_discharge_requirement", "checksum": {"name": "sha256", "checksum": "2b8b5e8b5553070da0cf0285073fbda99ccb81f78793989007f335d90c90351a"}, "config": {"enabled": true, "alias": "_int_index_discharge_requirement", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters that meet the discharge disposition requirement to be an index admission.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_index_discharge_requirement", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2888372, "relation_name": "dev_thuxuan.readmissions._int_index_discharge_requirement", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list encounter_ids that meet\r\n-- the discharge_disposition_code requirements to be an\r\n-- index admission:\r\n-- *** Must NOT be discharged to another acute care hospital\r\n-- *** Must NOT have left against medical advice\r\n-- *** Patient must be alive at discharge\r\n\r\n\r\n\r\nwith all_invalid_discharges as (\r\nselect encounter_id\r\nfrom {{ ref('readmissions__encounter') }}\r\nwhere discharge_disposition_code in (\r\n '02' -- Patient discharged/transferred to other short term general hospital for inpatient care.\r\n ,'07' -- Patient left against medical advice\r\n ,'20' -- Patient died\r\n )\r\n)\r\n\r\n-- All discharges that meet the discharge_disposition_code\r\n-- requirements to be an index admission\r\nselect a.encounter_id, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('readmissions__encounter') }} a\r\nleft join all_invalid_discharges b\r\n on a.encounter_id = b.encounter_id\r\nwhere b.encounter_id is null", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__index_discharge_requirement.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the discharge_disposition_code requirements to be an\n-- index admission:\n-- *** Must NOT be discharged to another acute care hospital\n-- *** Must NOT have left against medical advice\n-- *** Patient must be alive at discharge\n\n\n\nwith all_invalid_discharges as (\nselect encounter_id\nfrom dev_thuxuan.readmissions._int_encounter\nwhere discharge_disposition_code in (\n '02' -- Patient discharged/transferred to other short term general hospital for inpatient care.\n ,'07' -- Patient left against medical advice\n ,'20' -- Patient died\n )\n)\n\n-- All discharges that meet the discharge_disposition_code\n-- requirements to be an index admission\nselect a.encounter_id, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter a\nleft join all_invalid_discharges b\n on a.encounter_id = b.encounter_id\nwhere b.encounter_id is null", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__index_time_requirement": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__index_time_requirement", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__index_time_requirement.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__index_time_requirement.sql", "unique_id": "model.the_tuva_project.readmissions__index_time_requirement", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__index_time_requirement"], "alias": "_int_index_time_requirement", "checksum": {"name": "sha256", "checksum": "1df226d40f0ecf51fe76c15d6e7c89b466031cc516061cffaa0a2a7a71bb43b3"}, "config": {"enabled": true, "alias": "_int_index_time_requirement", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters that meet the time requirement to be an index admission.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_index_time_requirement", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2908373, "relation_name": "dev_thuxuan.readmissions._int_index_time_requirement", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list encounter_ids that meet\r\n-- the time requirement to be an index admission:\r\n-- The discharge date must be at least 30 days\r\n-- earlier than the last discharge date available\r\n-- in the dataset.\r\n\r\n\r\nwith cte as (\r\n select max(discharge_date) max_discharge\r\n from {{ ref('readmissions__encounter') }}\r\n)\r\n\r\nselect encounter_id\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('readmissions__encounter') }}\r\ncross join cte\r\nwhere discharge_date <= {{ dbt.dateadd (\r\ndatepart = \"day\"\r\n, interval = -30\r\n, from_date_or_timestamp = \"cte.max_discharge\"\r\n)}}", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.dateadd"], "nodes": ["model.the_tuva_project.readmissions__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__index_time_requirement.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the time requirement to be an index admission:\n-- The discharge date must be at least 30 days\n-- earlier than the last discharge date available\n-- in the dataset.\n\n\nwith cte as (\n select max(discharge_date) max_discharge\n from dev_thuxuan.readmissions._int_encounter\n)\n\nselect encounter_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter\ncross join cte\nwhere discharge_date <= \n\n dateadd(\n day,\n -30,\n cte.max_discharge\n )\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__planned_encounter": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__planned_encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__planned_encounter.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__planned_encounter.sql", "unique_id": "model.the_tuva_project.readmissions__planned_encounter", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__planned_encounter"], "alias": "_int_planned_encounter", "checksum": {"name": "sha256", "checksum": "28f71048d300e37bfe2bea0044a61a506b0f9629e95738af4e30846f534074d1"}, "config": {"enabled": true, "alias": "_int_planned_encounter", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model gives a list of all encounter_ids that were planned encounters.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_planned_encounter", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2938457, "relation_name": "dev_thuxuan.readmissions._int_planned_encounter", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we list encounter_ids for all encounters\r\n-- that are planned.\r\n\r\n\r\n-- encounter_ids for encounters that we know\r\n-- are planned because they had a procedure category\r\n-- that is only present for planned encounters \r\nwith always_planned_px as (\r\nselect distinct pccs.encounter_id\r\nfrom {{ ref('readmissions__procedure_ccs') }} pccs\r\ninner join {{ ref('readmissions__always_planned_ccs_procedure_category') }} apc\r\n on pccs.ccs_procedure_category = apc.ccs_procedure_category\r\n),\r\n\r\n\r\n-- encounter_ids for encounters that we know\r\n-- are planned because they had a diagnosis category\r\n-- that is only present for planned encounters\r\nalways_planned_dx as (\r\nselect distinct encounter_id\r\nfrom {{ ref('readmissions__encounter_with_ccs') }} dccs\r\ninner join {{ ref('readmissions__always_planned_ccs_diagnosis_category') }} apd\r\n on dccs.ccs_diagnosis_category = apd.ccs_diagnosis_category\r\n),\r\n\r\n\r\n-- encounter_ids for encounters that are potentially planned\r\n-- based on one of their CCS procedure categories.\r\n-- For these encounters to actually be planned, we must further\r\n-- require that they are NOT acute encounters\r\npotentially_planned_px_ccs as (\r\nselect distinct encounter_id\r\nfrom {{ ref('readmissions__procedure_ccs') }} pccs\r\ninner join {{ ref('readmissions__potentially_planned_ccs_procedure_category') }} pcs\r\n on pccs.ccs_procedure_category = pcs.ccs_procedure_category\r\n),\r\n\r\n\r\n-- encounter_ids for encounters that are potentially planned\r\n-- based on their ICD-10-PCS procedure codes.\r\n-- For these encounters to actually be planned, we must further\r\n-- require that they are NOT acute encounters\r\npotentially_planned_px_icd_10_pcs as (\r\nselect distinct encounter_id\r\nfrom {{ ref('readmissions__procedure_ccs') }} pcs\r\ninner join {{ ref('readmissions__potentially_planned_icd_10_pcs') }} pps\r\n on pcs.procedure_code = pps.icd_10_pcs\r\n),\r\n\r\n\r\n-- encounter_ids for encounters that are acute based\r\n-- on their primary diagnosis code or their CCS diagnosis category\r\nacute_encounters as (\r\nselect distinct encounter_id\r\nfrom {{ ref('readmissions__encounter_with_ccs') }} dccs\r\nleft join {{ ref('readmissions__acute_diagnosis_icd_10_cm') }} adi\r\n on dccs.primary_diagnosis_code = adi.icd_10_cm\r\nleft join {{ ref('readmissions__acute_diagnosis_ccs') }} adc\r\n on dccs.ccs_diagnosis_category = adc.ccs_diagnosis_category\r\nwhere adi.icd_10_cm is not null or adc.ccs_diagnosis_category is not null\r\n),\r\n\r\n\r\n-- encounter_ids for encounters that are:\r\n-- [1] potentially planned, based on one of\r\n-- their CCS procedure categories or\r\n-- their ICD-10-PCS procedure codes\r\n-- [2] not acute, based on their primary diagnosis code\r\n-- or their CCS diagnosis category\r\n-- These encounters are therefore confirmed to be planned\r\npotentially_planned_that_are_actually_planned as (\r\nselect distinct ppp.encounter_id\r\nfrom (\r\n select * from potentially_planned_px_ccs\r\n union all\r\n select * from potentially_planned_px_icd_10_pcs) ppp\r\nleft join acute_encounters\r\n on ppp.encounter_id = acute_encounters.encounter_id\r\nwhere acute_encounters.encounter_id is null\r\n\r\n)\r\n\r\n\r\n-- Aggregate of all encounter_ids for planned encounters\r\n\r\nselect * , '{{ var('tuva_last_run')}}' as tuva_last_run from always_planned_px\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from always_planned_dx\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run from potentially_planned_that_are_actually_planned", "language": "sql", "refs": [{"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__always_planned_ccs_procedure_category", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__always_planned_ccs_diagnosis_category", "package": null, "version": null}, {"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__potentially_planned_ccs_procedure_category", "package": null, "version": null}, {"name": "readmissions__procedure_ccs", "package": null, "version": null}, {"name": "readmissions__potentially_planned_icd_10_pcs", "package": null, "version": null}, {"name": "readmissions__encounter_with_ccs", "package": null, "version": null}, {"name": "readmissions__acute_diagnosis_icd_10_cm", "package": null, "version": null}, {"name": "readmissions__acute_diagnosis_ccs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs", "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "seed.the_tuva_project.readmissions__acute_diagnosis_ccs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__planned_encounter.sql", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids for all encounters\n-- that are planned.\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a procedure category\n-- that is only present for planned encounters \nwith always_planned_px as (\nselect distinct pccs.encounter_id\nfrom dev_thuxuan.readmissions._int_procedure_ccs pccs\ninner join dev_thuxuan.readmissions._value_set_always_planned_ccs_procedure_category apc\n on pccs.ccs_procedure_category = apc.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a diagnosis category\n-- that is only present for planned encounters\nalways_planned_dx as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs dccs\ninner join dev_thuxuan.readmissions._value_set_always_planned_ccs_diagnosis_category apd\n on dccs.ccs_diagnosis_category = apd.ccs_diagnosis_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on one of their CCS procedure categories.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_ccs as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_procedure_ccs pccs\ninner join dev_thuxuan.readmissions._value_set_potentially_planned_ccs_procedure_category pcs\n on pccs.ccs_procedure_category = pcs.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on their ICD-10-PCS procedure codes.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_icd_10_pcs as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_procedure_ccs pcs\ninner join dev_thuxuan.readmissions._value_set_potentially_planned_icd_10_pcs pps\n on pcs.procedure_code = pps.icd_10_pcs\n),\n\n\n-- encounter_ids for encounters that are acute based\n-- on their primary diagnosis code or their CCS diagnosis category\nacute_encounters as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs dccs\nleft join dev_thuxuan.readmissions._value_set_acute_diagnosis_icd_10_cm adi\n on dccs.primary_diagnosis_code = adi.icd_10_cm\nleft join dev_thuxuan.readmissions._value_set_acute_diagnosis_ccs adc\n on dccs.ccs_diagnosis_category = adc.ccs_diagnosis_category\nwhere adi.icd_10_cm is not null or adc.ccs_diagnosis_category is not null\n),\n\n\n-- encounter_ids for encounters that are:\n-- [1] potentially planned, based on one of\n-- their CCS procedure categories or\n-- their ICD-10-PCS procedure codes\n-- [2] not acute, based on their primary diagnosis code\n-- or their CCS diagnosis category\n-- These encounters are therefore confirmed to be planned\npotentially_planned_that_are_actually_planned as (\nselect distinct ppp.encounter_id\nfrom (\n select * from potentially_planned_px_ccs\n union all\n select * from potentially_planned_px_icd_10_pcs) ppp\nleft join acute_encounters\n on ppp.encounter_id = acute_encounters.encounter_id\nwhere acute_encounters.encounter_id is null\n\n)\n\n\n-- Aggregate of all encounter_ids for planned encounters\n\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from always_planned_px\n\nunion distinct\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from always_planned_dx\n\nunion distinct\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from potentially_planned_that_are_actually_planned", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__procedure_ccs": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__procedure_ccs", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__procedure_ccs.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__procedure_ccs.sql", "unique_id": "model.the_tuva_project.readmissions__procedure_ccs", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__procedure_ccs"], "alias": "_int_procedure_ccs", "checksum": {"name": "sha256", "checksum": "559e894edcdd88758b66a520f1ab0234d405d137e47ebb782ce681282fe746fa"}, "config": {"enabled": true, "alias": "_int_procedure_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model includes all procedures from the stg_procedure model and adds a valid_icd_10_pcs_flag to indicate if the ICD-10-PCS code for this procedure is valid. We also add the CCS procedure category associated with the procedure", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_code": {"name": "procedure_code", "description": "An ICD-10-PCS code associated with this encounter_id", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "valid_icd_10_pcs_flag": {"name": "valid_icd_10_pcs_flag", "description": "A flag indicating if the ICD-10-PCS procedure code given is valid", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_procedure_category": {"name": "ccs_procedure_category", "description": "The CCS code associated with the given ICD-10-PCS procedure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_procedure_ccs", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.295846, "relation_name": "dev_thuxuan.readmissions._int_procedure_ccs", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we map every procedure code to its corresponding\r\n-- CCS procedure category.\r\n-- This model may list more than one CCS procedure category\r\n-- per encounter_id because different procedures associated with the\r\n-- encounter (different rows on the stg_procedure model) may have\r\n-- different associated CCS procedure categories.\r\n\r\n\r\n\r\nselect\r\n aa.encounter_id,\r\n aa.normalized_code as procedure_code,\r\n case\r\n when bb.icd_10_pcs is null then 0\r\n\telse 1\r\n end as valid_icd_10_pcs_flag,\r\n cc.ccs_procedure_category,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom\r\n {{ ref('readmissions__stg_core__procedure') }} aa\r\n left join {{ ref('terminology__icd_10_pcs') }} bb\r\n on aa.normalized_code = bb.icd_10_pcs\r\n left join {{ ref('readmissions__icd_10_pcs_to_ccs') }} cc\r\n on aa.normalized_code = cc.icd_10_pcs\r\nwhere aa.normalized_code_type = 'icd-10-pcs'", "language": "sql", "refs": [{"name": "readmissions__stg_core__procedure", "package": null, "version": null}, {"name": "terminology__icd_10_pcs", "package": null, "version": null}, {"name": "readmissions__icd_10_pcs_to_ccs", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.readmissions__stg_core__procedure", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__procedure_ccs.sql", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__procedure as (\n\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n) -- Here we map every procedure code to its corresponding\n-- CCS procedure category.\n-- This model may list more than one CCS procedure category\n-- per encounter_id because different procedures associated with the\n-- encounter (different rows on the stg_procedure model) may have\n-- different associated CCS procedure categories.\n\n\n\nselect\n aa.encounter_id,\n aa.normalized_code as procedure_code,\n case\n when bb.icd_10_pcs is null then 0\n\telse 1\n end as valid_icd_10_pcs_flag,\n cc.ccs_procedure_category,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n __dbt__cte__readmissions__stg_core__procedure aa\n left join dev_thuxuan.terminology.icd_10_pcs bb\n on aa.normalized_code = bb.icd_10_pcs\n left join dev_thuxuan.readmissions._value_set_icd_10_pcs_to_ccs cc\n on aa.normalized_code = cc.icd_10_pcs\nwhere aa.normalized_code_type = 'icd-10-pcs'", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.readmissions__stg_core__procedure", "sql": " __dbt__cte__readmissions__stg_core__procedure as (\n\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__readmission_crude": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__readmission_crude", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\intermediate\\readmissions__readmission_crude.sql", "original_file_path": "models\\readmissions\\intermediate\\readmissions__readmission_crude.sql", "unique_id": "model.the_tuva_project.readmissions__readmission_crude", "fqn": ["the_tuva_project", "readmissions", "intermediate", "readmissions__readmission_crude"], "alias": "_int_readmission_crude", "checksum": {"name": "sha256", "checksum": "61c17697963e9c2b82d47881ffad9a3b3c486479c0eac94ea1495bc1e1fad43c"}, "config": {"enabled": true, "alias": "_int_readmission_crude", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "This model lists all encounters and whether they had a 'crude' readmission, meaning that the encounter had a hospitalization after discharge, without regard to all CMS readmission logic.", "columns": {"encounter_id": {"name": "encounter_id", "description": "The unique identifier for the encounter", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "patient_id": {"name": "patient_id", "description": "The unique identifier for the patient", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_date": {"name": "admit_date", "description": "The date of admission for the inpatient visit", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_date": {"name": "discharge_date", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "had_readmission_flag": {"name": "had_readmission_flag", "description": "A flag to indicate whether the encounter had a readmission any number of days after discharge", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "days_to_readmit": {"name": "days_to_readmit", "description": "An integer to indicate the number of days to readmission", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "readmit_30_flag": {"name": "readmit_30_flag", "description": "A flag to indicate whether the encounter had a 30-day readmission", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"schema": "readmissions", "alias": "_int_readmission_crude", "tags": "readmissions", "materialized": "view", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.2988453, "relation_name": "dev_thuxuan.readmissions._int_readmission_crude", "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\n-- Here we calculate readmissions using all encounters\r\n-- that have valid admit and discharge dates and no overlap.\r\n-- This is meant to give a crude sense of the readmission\r\n-- rate without taking into account all the CMS HWR logic.\r\n\r\n\r\nwith encounter_info as (\r\nselect\r\n enc.encounter_id,\r\n enc.patient_id,\r\n enc.admit_date,\r\n enc.discharge_date\r\nfrom {{ ref('readmissions__encounter') }} enc\r\nleft join {{ ref('readmissions__encounter_overlap') }} over_a\r\n on enc.encounter_id = over_a.encounter_id_A\r\nleft join {{ ref('readmissions__encounter_overlap') }} over_b\r\n on enc.encounter_id = over_b.encounter_id_B\r\nwhere\r\n admit_date is not null\r\n and\r\n discharge_date is not null\r\n and\r\n admit_date <= discharge_date\r\nand over_a.encounter_id_A is null and over_b.encounter_id_B is null\r\n ),\r\n\r\n\r\nencounter_sequence as (\r\nselect\r\n encounter_id,\r\n patient_id,\r\n admit_date,\r\n discharge_date,\r\n row_number() over(\r\n partition by patient_id order by admit_date, discharge_date\r\n ) as encounter_seq\r\nfrom encounter_info\r\n),\r\n\r\n\r\nreadmission_calc as (\r\nselect\r\n aa.encounter_id,\r\n aa.patient_id,\r\n aa.admit_date,\r\n aa.discharge_date,\r\n case\r\n when bb.encounter_id is not null then 1\r\n\telse 0\r\n end as had_readmission_flag,\r\n {{ dbt.datediff(\"bb.admit_date\", \"aa.discharge_date\", \"day\") }} as days_to_readmit,\r\n case\r\n when ({{ dbt.datediff(\"bb.admit_date\", \"aa.discharge_date\", \"day\") }}) <= 30 then 1\r\n\telse 0\r\n end as readmit_30_flag\r\nfrom encounter_sequence aa left join encounter_sequence bb\r\n on aa.patient_id = bb.patient_id\r\n and aa.encounter_seq + 1 = bb.encounter_seq\r\n)\r\n\r\n\r\n\r\nselect *, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom readmission_calc", "language": "sql", "refs": [{"name": "readmissions__encounter", "package": null, "version": null}, {"name": "readmissions__encounter_overlap", "package": null, "version": null}, {"name": "readmissions__encounter_overlap", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.datediff"], "nodes": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_overlap"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\intermediate\\readmissions__readmission_crude.sql", "compiled": true, "compiled_code": "\n\n-- Here we calculate readmissions using all encounters\n-- that have valid admit and discharge dates and no overlap.\n-- This is meant to give a crude sense of the readmission\n-- rate without taking into account all the CMS HWR logic.\n\n\nwith encounter_info as (\nselect\n enc.encounter_id,\n enc.patient_id,\n enc.admit_date,\n enc.discharge_date\nfrom dev_thuxuan.readmissions._int_encounter enc\nleft join dev_thuxuan.readmissions._int_encounter_overlap over_a\n on enc.encounter_id = over_a.encounter_id_A\nleft join dev_thuxuan.readmissions._int_encounter_overlap over_b\n on enc.encounter_id = over_b.encounter_id_B\nwhere\n admit_date is not null\n and\n discharge_date is not null\n and\n admit_date <= discharge_date\nand over_a.encounter_id_A is null and over_b.encounter_id_B is null\n ),\n\n\nencounter_sequence as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom encounter_info\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n case\n when bb.encounter_id is not null then 1\n\telse 0\n end as had_readmission_flag,\n datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n )) <= 30 then 1\n\telse 0\n end as readmit_30_flag\nfrom encounter_sequence aa left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom readmission_calc", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__stg_core__encounter": {"database": "dev_thuxuan", "schema": "test", "name": "readmissions__stg_core__encounter", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\staging\\readmissions__stg_core__encounter.sql", "original_file_path": "models\\readmissions\\staging\\readmissions__stg_core__encounter.sql", "unique_id": "model.the_tuva_project.readmissions__stg_core__encounter", "fqn": ["the_tuva_project", "readmissions", "staging", "readmissions__stg_core__encounter"], "alias": "readmissions__stg_core__encounter", "checksum": {"name": "sha256", "checksum": "cfb81c8e5b29ea383438277139e19e276c0f76f7afa3e1c6a3114029a6bf91db"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"tags": "readmissions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.3039954, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n encounter_id,\r\n patient_id,\r\n encounter_start_date,\r\n encounter_end_date,\r\n discharge_disposition_code,\r\n facility_id,\r\n ms_drg_code,\r\n paid_amount,\r\n primary_diagnosis_code,\r\n '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__encounter') }}\r\nwhere encounter_type = 'acute inpatient'", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\staging\\readmissions__stg_core__encounter.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.the_tuva_project.readmissions__stg_core__procedure": {"database": "dev_thuxuan", "schema": "test", "name": "readmissions__stg_core__procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "readmissions\\staging\\readmissions__stg_core__procedure.sql", "original_file_path": "models\\readmissions\\staging\\readmissions__stg_core__procedure.sql", "unique_id": "model.the_tuva_project.readmissions__stg_core__procedure", "fqn": ["the_tuva_project", "readmissions", "staging", "readmissions__stg_core__procedure"], "alias": "readmissions__stg_core__procedure", "checksum": {"name": "sha256", "checksum": "9d7956301a9813bb6becf26522ccf9532e24dcc9cd6041cd537dd15db6227fc6"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["readmissions"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\readmissions\\readmissions_models.yml", "build_path": null, "unrendered_config": {"tags": "readmissions", "materialized": "ephemeral", "enabled": true, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866318.304995, "relation_name": null, "raw_code": "{{ config(\r\n enabled = var('readmissions_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) | as_bool\r\n )\r\n}}\r\n\r\nselect\r\n encounter_id\r\n, normalized_code\r\n, normalized_code_type\r\n, '{{ var('tuva_last_run')}}' as tuva_last_run\r\nfrom {{ ref('core__procedure') }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\readmissions\\staging\\readmissions__stg_core__procedure.sql", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "seed.the_tuva_project.clinical_concept_library__clinical_concepts": {"database": "dev_thuxuan", "schema": "clinical_concept_library", "name": "clinical_concept_library__clinical_concepts", "resource_type": "seed", "package_name": "the_tuva_project", "path": "clinical_concept_library\\clinical_concept_library__clinical_concepts.csv", "original_file_path": "seeds\\clinical_concept_library\\clinical_concept_library__clinical_concepts.csv", "unique_id": "seed.the_tuva_project.clinical_concept_library__clinical_concepts", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__clinical_concepts"], "alias": "clinical_concepts", "checksum": {"name": "sha256", "checksum": "28904352227711d78b2ffd3f5b674269b3f16f92e5eba2a8f83b8749500ea30d"}, "config": {"enabled": true, "alias": "clinical_concepts", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_clinical_concepts.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_id": "varchar(256)", "concept_name": "varchar(256)", "status": "varchar(256)", "concept_oid": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "concept_type": "varchar(256)", "content_source": "varchar(3000)", "external_source_detail": "varchar(3000)", "concept_scope": "varchar(3000)", "value_set_search_notes": "varchar(3000)", "code": "varchar(256)", "code_description": "varchar(256)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["clinical_concept_library"], "description": "", "columns": {"concept_id": {"name": "concept_id", "description": "Primary key for the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_name": {"name": "concept_name", "description": "Human-readable term for the concept. Should include spaces as needed, and casing per titlecase conventions, e.g. \u201cMyocardial Infarction\u201d.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of this concept and the completeness of the links to value_set_members. Values include \u201cin progress\u201d, \u201cready for review\u201d, \u201creviewed\u201d, \u201cinactive\u201d, others to be added as needed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID for the concept; Added since some clinical concepts used in standardized quality measures have OIDs.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_date": {"name": "last_update_date", "description": "Date of last update of this row (formatted as YYYY-MM-DD) and/or addition, removal, or changes to any of its linked value_set_members rows.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_note": {"name": "last_update_note", "description": "Relevant details regarding the nature and reasons for the most recent update.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_type": {"name": "concept_type", "description": "Clinical type of the concept. Potential values: \u201ccondition\u201d, \u201ctherapy\u201d, \u201cdiagnostic test\u201d, others TBD.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "content_source": {"name": "content_source", "description": "Indicates whether the clinical concept definition and associated value set content was developed by Tuva or from some other public source. Values will be \u201cTuva-developed\u201d or \u201cexternal\u201d.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "external_source_detail": {"name": "external_source_detail", "description": "For concepts for which the definition and associated value set content was not developed by Tuva, this provides details on the source of the concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_scope": {"name": "concept_scope", "description": "Narrative text that defines the semantic scope of the clinical concept, including specific inclusions and exclusions, to ensure consistency in value set construction and clarity in use. May be up to several paragraphs in length.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "value_set_search_notes": {"name": "value_set_search_notes", "description": "Narrative text that describes the approach taken for identifying candidate codes for human review. May include text search terms, code ranges or hierarchical assertions. Will facilitate consistency when periodic value set maintenance is performed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Standardized code that represents the concept, to facilitate searching for clinical concepts by standardized code. Not to be confused with value set member codes, this is meant to be synonymous with the concept or, if a synonymous code isn\u2019t available, the closest subsuming code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "Description for the code in concept_coding_code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_id": {"name": "coding_system_id", "description": "Coding system for code in concept_coding_code. Foreign key to coding_systems.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_version": {"name": "coding_system_version", "description": "Version of the coding system used. For now, editorial conventions and/or business logic will be required to establish a consistent format for coding version for each coding system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\clinical_concept_library\\clinical_concept_library_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_clinical_concepts.csv',compression=true,null_marker=true) }}", "schema": "clinical_concept_library", "alias": "clinical_concepts", "tags": "clinical_concept_library", "column_types": {"concept_id": "varchar(256)", "concept_name": "varchar(256)", "status": "varchar(256)", "concept_oid": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "concept_type": "varchar(256)", "content_source": "varchar(3000)", "external_source_detail": "varchar(3000)", "concept_scope": "varchar(3000)", "value_set_search_notes": "varchar(3000)", "code": "varchar(256)", "code_description": "varchar(256)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0110168, "relation_name": "dev_thuxuan.clinical_concept_library.clinical_concepts", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.clinical_concept_library__coding_systems": {"database": "dev_thuxuan", "schema": "clinical_concept_library", "name": "clinical_concept_library__coding_systems", "resource_type": "seed", "package_name": "the_tuva_project", "path": "clinical_concept_library\\clinical_concept_library__coding_systems.csv", "original_file_path": "seeds\\clinical_concept_library\\clinical_concept_library__coding_systems.csv", "unique_id": "seed.the_tuva_project.clinical_concept_library__coding_systems", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__coding_systems"], "alias": "coding_systems", "checksum": {"name": "sha256", "checksum": "2468b8aad4f2ee3fe8043f55d2cfde2203aefb7fa7d959b9e63d138361bdafae"}, "config": {"enabled": true, "alias": "coding_systems", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_coding_systems.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"coding_system_id": "varchar(256)", "coding_system_name": "varchar(256)", "coding_system_uri": "varchar(256)", "coding_system_oid": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["clinical_concept_library"], "description": "", "columns": {"coding_system_id": {"name": "coding_system_id", "description": "Primary key for the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_name": {"name": "coding_system_name", "description": "Name of the coding system, e.g. \u201cSNOMED CT US Edition\u201d", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_uri": {"name": "coding_system_uri", "description": "URI as used in FHIR to represent coding system. This provides an unambiguous identifier for the coding system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_oid": {"name": "coding_system_oid", "description": "OID for the coding system. This provides another unambiguous identifier for the coding system (along with uri).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\clinical_concept_library\\clinical_concept_library_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_coding_systems.csv',compression=true,null_marker=true) }}", "schema": "clinical_concept_library", "alias": "coding_systems", "tags": "clinical_concept_library", "column_types": {"coding_system_id": "varchar(256)", "coding_system_name": "varchar(256)", "coding_system_uri": "varchar(256)", "coding_system_oid": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0295177, "relation_name": "dev_thuxuan.clinical_concept_library.coding_systems", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.clinical_concept_library__value_set_members": {"database": "dev_thuxuan", "schema": "clinical_concept_library", "name": "clinical_concept_library__value_set_members", "resource_type": "seed", "package_name": "the_tuva_project", "path": "clinical_concept_library\\clinical_concept_library__value_set_members.csv", "original_file_path": "seeds\\clinical_concept_library\\clinical_concept_library__value_set_members.csv", "unique_id": "seed.the_tuva_project.clinical_concept_library__value_set_members", "fqn": ["the_tuva_project", "clinical_concept_library", "clinical_concept_library__value_set_members"], "alias": "value_set_members", "checksum": {"name": "sha256", "checksum": "066f2f31496a1d94f83040789f89b512753bda8edc902a24a183ddadfcc305df"}, "config": {"enabled": true, "alias": "value_set_members", "schema": "clinical_concept_library", "database": null, "tags": ["clinical_concept_library"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_value_set_members.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"value_set_member_id": "varchar(256)", "concept_id": "varchar(256)", "status": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "code": "varchar(256)", "code_description": "varchar(2000)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)", "include_descendants": "varchar(256)", "comment": "varchar(2000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["clinical_concept_library"], "description": "", "columns": {"value_set_member_id": {"name": "value_set_member_id", "description": "Primary key for the table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_id": {"name": "concept_id", "description": "Foreign key to concept table", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "Status of this individual value_set_members record. Options = \u201cactive\u201d and \u201cinactive\u201d, others to be added as needed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_date": {"name": "last_update_date", "description": "Date of last update of this row, formatted as YYYY-MM-DD.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_update_note": {"name": "last_update_note", "description": "Relevant details regarding the nature and reasons for the most recent update.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Standardized code that is a member of the value set for the concept referenced in concept_id", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_description": {"name": "code_description", "description": "Description for the code in the \"code\" column.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_id": {"name": "coding_system_id", "description": "Coding system ID for code in the \"code\" column. Foreign key to coding_systems", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coding_system_version": {"name": "coding_system_version", "description": "Version of the coding system used. For now, editorial conventions and/or business logic will be required to establish a consistent format for coding version for each coding system.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "include_descendants": {"name": "include_descendants", "description": "Indicates whether the value set should include descendants of the specified code. If \u201ctrue\u201d, include the specified code and all of its descendants. If \u201cfalse\u201d, include only the specified code. Applies only to coding systems for which Tuva has implemented this feature.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "comment": {"name": "comment", "description": "In some cases it may be helpful to provide some explanatory context for inclusion of a particular code, e.g., insights into the intended meaning of the code that aren\u2019t implicit in the code description but are implied by other aspects of the coding system e.g., ICD-10-CM coding guidance.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\clinical_concept_library\\clinical_concept_library_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_value_set_members.csv',compression=true,null_marker=true) }}", "schema": "clinical_concept_library", "alias": "value_set_members", "tags": "clinical_concept_library", "column_types": {"value_set_member_id": "varchar(256)", "concept_id": "varchar(256)", "status": "varchar(256)", "last_update_date": "date", "last_update_note": "varchar(256)", "code": "varchar(256)", "code_description": "varchar(2000)", "coding_system_id": "varchar(256)", "coding_system_version": "varchar(256)", "include_descendants": "varchar(256)", "comment": "varchar(2000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0220132, "relation_name": "dev_thuxuan.clinical_concept_library.value_set_members", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__ansi_fips_state": {"database": "dev_thuxuan", "schema": "reference_data", "name": "reference_data__ansi_fips_state", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data\\reference_data__ansi_fips_state.csv", "original_file_path": "seeds\\reference_data\\reference_data__ansi_fips_state.csv", "unique_id": "seed.the_tuva_project.reference_data__ansi_fips_state", "fqn": ["the_tuva_project", "reference_data", "reference_data__ansi_fips_state"], "alias": "ansi_fips_state", "checksum": {"name": "sha256", "checksum": "8b9ed6a3c0deef5889027408e19e785820305639d8185cbc6ff0a660266633d5"}, "config": {"enabled": true, "alias": "ansi_fips_state", "schema": "reference_data", "database": null, "tags": ["terminology", "medicare_cclf_connector", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ansi_fips_state.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ansi_fips_state_code": "varchar(256)", "ansi_fips_state_abbreviation": "varchar(256)", "ansi_fips_state_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "medicare_cclf_connector", "reference_data"], "description": "Seed containing ANSI FIPS state codes and names.", "columns": {"ansi_fips_state_code": {"name": "ansi_fips_state_code", "description": "The unique ANSI FIPS state code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ansi_fips_state_abbreviation": {"name": "ansi_fips_state_abbreviation", "description": "The abbreviation of the ANSI FIPS state.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ansi_fips_state_name": {"name": "ansi_fips_state_name", "description": "The full name of the ANSI FIPS state.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\reference_data\\reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ansi_fips_state.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "ansi_fips_state", "tags": ["terminology", "medicare_cclf_connector", "reference_data"], "column_types": {"ansi_fips_state_code": "varchar(256)", "ansi_fips_state_abbreviation": "varchar(256)", "ansi_fips_state_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0375168, "relation_name": "dev_thuxuan.reference_data.ansi_fips_state", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__calendar": {"database": "dev_thuxuan", "schema": "reference_data", "name": "reference_data__calendar", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data\\reference_data__calendar.csv", "original_file_path": "seeds\\reference_data\\reference_data__calendar.csv", "unique_id": "seed.the_tuva_project.reference_data__calendar", "fqn": ["the_tuva_project", "reference_data", "reference_data__calendar"], "alias": "calendar", "checksum": {"name": "sha256", "checksum": "0b05d002a395c589a2bd33f0c3a551d2a4642fcc9ebcd63e0a61c16e6d62bc2e"}, "config": {"enabled": true, "alias": "calendar", "schema": "reference_data", "database": null, "tags": ["terminology", "pmpm", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','calendar.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"full_date": "date", "year": "integer", "month": "integer", "day": "integer", "month_name": "varchar(256)", "day_of_week_number": "integer", "day_of_week_name": "varchar(256)", "week_of_year": "integer", "day_of_year": "integer", "year_month": "varchar(256)", "first_day_of_month": "date", "last_day_of_month": "date", "year_month_int": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "pmpm", "reference_data"], "description": "Seed containing calendar dates and related attributes.", "columns": {"full_date": {"name": "full_date", "description": "The complete date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year": {"name": "year", "description": "The year part of the date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "month": {"name": "month", "description": "The month part of the date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day": {"name": "day", "description": "The day part of the date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "month_name": {"name": "month_name", "description": "The name of the month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day_of_week_number": {"name": "day_of_week_number", "description": "The number of the day in the week.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day_of_week_name": {"name": "day_of_week_name", "description": "The name of the day in the week.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "week_of_year": {"name": "week_of_year", "description": "The week number in the year.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "day_of_year": {"name": "day_of_year", "description": "The day number in the year.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "year_month": {"name": "year_month", "description": "The year and month in YYYY-MM format.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "first_day_of_month": {"name": "first_day_of_month", "description": "The first day of the month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_day_of_month": {"name": "last_day_of_month", "description": "The last day of the month.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\reference_data\\reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','calendar.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "calendar", "tags": ["terminology", "pmpm", "reference_data"], "column_types": {"full_date": "date", "year": "integer", "month": "integer", "day": "integer", "month_name": "varchar(256)", "day_of_week_number": "integer", "day_of_week_name": "varchar(256)", "week_of_year": "integer", "day_of_year": "integer", "year_month": "varchar(256)", "first_day_of_month": "date", "last_day_of_month": "date", "year_month_int": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.046518, "relation_name": "dev_thuxuan.reference_data.calendar", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__code_type": {"database": "dev_thuxuan", "schema": "reference_data", "name": "reference_data__code_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data\\reference_data__code_type.csv", "original_file_path": "seeds\\reference_data\\reference_data__code_type.csv", "unique_id": "seed.the_tuva_project.reference_data__code_type", "fqn": ["the_tuva_project", "reference_data", "reference_data__code_type"], "alias": "code_type", "checksum": {"name": "sha256", "checksum": "3a94151ece0a448f49b110851a7dd224fdd59207faa27d61aebe5fd5d39c51b4"}, "config": {"enabled": true, "alias": "code_type", "schema": "reference_data", "database": null, "tags": ["terminology", "data_profiling", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','code_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"code_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling", "reference_data"], "description": "Seed containing code types.", "columns": {"code_type": {"name": "code_type", "description": "The type of the code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\reference_data\\reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','code_type.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "code_type", "tags": ["terminology", "data_profiling", "reference_data"], "column_types": {"code_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0515172, "relation_name": "dev_thuxuan.reference_data.code_type", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__fips_county": {"database": "dev_thuxuan", "schema": "reference_data", "name": "reference_data__fips_county", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data\\reference_data__fips_county.csv", "original_file_path": "seeds\\reference_data\\reference_data__fips_county.csv", "unique_id": "seed.the_tuva_project.reference_data__fips_county", "fqn": ["the_tuva_project", "reference_data", "reference_data__fips_county"], "alias": "fips_county", "checksum": {"name": "sha256", "checksum": "206c5df28096e19cfc225b0cc29b1aed721a971d84007ace9f9a839dac378080"}, "config": {"enabled": true, "alias": "fips_county", "schema": "reference_data", "database": null, "tags": ["terminology", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','fips_county.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"fips_code": "varchar(256)", "county": "varchar(256)", "state": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "reference_data"], "description": "Seed containing FIPS county codes and names.", "columns": {"fips_code": {"name": "fips_code", "description": "The FIPS code for the county.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "county": {"name": "county", "description": "The name of the county.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "state": {"name": "state", "description": "The state where the county is located.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\reference_data\\reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','fips_county.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "fips_county", "tags": ["terminology", "reference_data"], "column_types": {"fips_code": "varchar(256)", "county": "varchar(256)", "state": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0575173, "relation_name": "dev_thuxuan.reference_data.fips_county", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.reference_data__ssa_fips_state": {"database": "dev_thuxuan", "schema": "reference_data", "name": "reference_data__ssa_fips_state", "resource_type": "seed", "package_name": "the_tuva_project", "path": "reference_data\\reference_data__ssa_fips_state.csv", "original_file_path": "seeds\\reference_data\\reference_data__ssa_fips_state.csv", "unique_id": "seed.the_tuva_project.reference_data__ssa_fips_state", "fqn": ["the_tuva_project", "reference_data", "reference_data__ssa_fips_state"], "alias": "ssa_fips_state", "checksum": {"name": "sha256", "checksum": "79a3093e6af928b718e6ac895e2b0f94fecd19d083227846626cd88ddea299f7"}, "config": {"enabled": true, "alias": "ssa_fips_state", "schema": "reference_data", "database": null, "tags": ["terminology", "reference_data"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ssa_fips_state.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ssa_fips_state_code": "varchar(256)", "ssa_fips_state_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "reference_data"], "description": "Seed containing SSA FIPS state codes and names.", "columns": {"ssa_fips_state_code": {"name": "ssa_fips_state_code", "description": "The SSA FIPS state code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ssa_fips_state_name": {"name": "ssa_fips_state_name", "description": "The name of the SSA FIPS state.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\reference_data\\reference_data.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ssa_fips_state.csv',compression=true,null_marker=true) }}", "schema": "reference_data", "alias": "ssa_fips_state", "tags": ["terminology", "reference_data"], "column_types": {"ssa_fips_state_code": "varchar(256)", "ssa_fips_state_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.0645144, "relation_name": "dev_thuxuan.reference_data.ssa_fips_state", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__admit_source": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__admit_source", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__admit_source.csv", "original_file_path": "seeds\\terminology\\terminology__admit_source.csv", "unique_id": "seed.the_tuva_project.terminology__admit_source", "fqn": ["the_tuva_project", "terminology", "terminology__admit_source"], "alias": "admit_source", "checksum": {"name": "sha256", "checksum": "7068c87e74a237a6908ab4e7709afe8cfca181ad74d3e91ff9955926dc0e92ff"}, "config": {"enabled": true, "alias": "admit_source", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','admit_source.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"admit_source_code": "varchar(256)", "admit_source_description": "varchar(256)", "newborn_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "NUBC Admit Sources", "columns": {"admit_source_code": {"name": "admit_source_code", "description": "The code representing the source of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_source_description": {"name": "admit_source_description", "description": "A description of the admission source.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "newborn_description": {"name": "newborn_description", "description": "Description related to newborn admission. For use when admit type code = 4 (Newborn)", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','admit_source.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "admit_source", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"admit_source_code": "varchar(256)", "admit_source_description": "varchar(256)", "newborn_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1594727, "relation_name": "dev_thuxuan.terminology.admit_source", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__admit_type": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__admit_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__admit_type.csv", "original_file_path": "seeds\\terminology\\terminology__admit_type.csv", "unique_id": "seed.the_tuva_project.terminology__admit_type", "fqn": ["the_tuva_project", "terminology", "terminology__admit_type"], "alias": "admit_type", "checksum": {"name": "sha256", "checksum": "8fd4b52317db368c0e056c2d0682234f2ba7017161f67dcc055b33738608f14c"}, "config": {"enabled": true, "alias": "admit_type", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','admit_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"admit_type_code": "varchar(256)", "admit_type_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing NUBC admission types and descriptions.", "columns": {"admit_type_code": {"name": "admit_type_code", "description": "The code representing the type of admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "admit_type_description": {"name": "admit_type_description", "description": "A description of the admission type.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','admit_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "admit_type", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"admit_type_code": "varchar(256)", "admit_type_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1654835, "relation_name": "dev_thuxuan.terminology.admit_type", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__apr_drg": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__apr_drg", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__apr_drg.csv", "original_file_path": "seeds\\terminology\\terminology__apr_drg.csv", "unique_id": "seed.the_tuva_project.terminology__apr_drg", "fqn": ["the_tuva_project", "terminology", "terminology__apr_drg"], "alias": "apr_drg", "checksum": {"name": "sha256", "checksum": "09eb60b322cc83936cee0e221fdb694a6ab8e3dd8016c275885e126b58cb55b6"}, "config": {"enabled": true, "alias": "apr_drg", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','apr_drg.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"apr_drg_code": "varchar(256)", "medical_surgical": "varchar(256)", "mdc_code": "varchar(256)", "apr_drg_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing All Patient Refined Diagnosis Related Groups (APR-DRG) codes and descriptions.", "columns": {"apr_drg_code": {"name": "apr_drg_code", "description": "The All Patient Refined Diagnosis Related Group (APR-DRG) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "Indicates whether the DRG is medical or surgical.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc_code": {"name": "mdc_code", "description": "The Major Diagnostic Category (MDC) code associated with the APR-DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "apr_drg_description": {"name": "apr_drg_description", "description": "The description of the All Patient Refined Diagnosis Related Group (APR-DRG).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','apr_drg.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "apr_drg", "tags": ["terminology", "data_profiling"], "column_types": {"apr_drg_code": "varchar(256)", "medical_surgical": "varchar(256)", "mdc_code": "varchar(256)", "apr_drg_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1724887, "relation_name": "dev_thuxuan.terminology.apr_drg", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__bill_type": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__bill_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__bill_type.csv", "original_file_path": "seeds\\terminology\\terminology__bill_type.csv", "unique_id": "seed.the_tuva_project.terminology__bill_type", "fqn": ["the_tuva_project", "terminology", "terminology__bill_type"], "alias": "bill_type", "checksum": {"name": "sha256", "checksum": "398d806848f4a65fafccb3c4ad84b18f90ca269945d0121c4b81fe1b923d1627"}, "config": {"enabled": true, "alias": "bill_type", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','bill_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"bill_type_code": "varchar(256)", "bill_type_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing NUBC billing types and descriptions.", "columns": {"bill_type_code": {"name": "bill_type_code", "description": "The code representing the type of bill.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "bill_type_description": {"name": "bill_type_description", "description": "A description of the billing type.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated": {"name": "deprecated", "description": "Indicates if the billing type is deprecated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated_date": {"name": "deprecated_date", "description": "The date when the billing type code was deprecated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','bill_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "bill_type", "tags": ["terminology", "data_profiling"], "column_types": {"bill_type_code": "varchar(256)", "bill_type_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1794884, "relation_name": "dev_thuxuan.terminology.bill_type", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ccs_services_procedures": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__ccs_services_procedures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__ccs_services_procedures.csv", "original_file_path": "seeds\\terminology\\terminology__ccs_services_procedures.csv", "unique_id": "seed.the_tuva_project.terminology__ccs_services_procedures", "fqn": ["the_tuva_project", "terminology", "terminology__ccs_services_procedures"], "alias": "ccs_services_procedures", "checksum": {"name": "sha256", "checksum": "8f104023cc661ebf3eb34a6900a8c2e0b008cc631bf27e1db53950a883323dfe"}, "config": {"enabled": true, "alias": "ccs_services_procedures", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ccs_services_procedures.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs_code": "varchar(5)", "ccs_category": "varchar(3)", "ccs_category_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ccs_services_procedures.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ccs_services_procedures", "tags": ["terminology"], "column_types": {"hcpcs_code": "varchar(5)", "ccs_category": "varchar(3)", "ccs_category_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.467509, "relation_name": "dev_thuxuan.terminology.ccs_services_procedures", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__claim_type": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__claim_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__claim_type.csv", "original_file_path": "seeds\\terminology\\terminology__claim_type.csv", "unique_id": "seed.the_tuva_project.terminology__claim_type", "fqn": ["the_tuva_project", "terminology", "terminology__claim_type"], "alias": "claim_type", "checksum": {"name": "sha256", "checksum": "5e72668475091f682d6782ae0d708213ddb0a1c5c1f4e3c457132e739ceb7cb5"}, "config": {"enabled": true, "alias": "claim_type", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','claim_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"claim_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing claim types.", "columns": {"claim_type": {"name": "claim_type", "description": "The type of the claim.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','claim_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "claim_type", "tags": ["terminology", "data_profiling"], "column_types": {"claim_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1844888, "relation_name": "dev_thuxuan.terminology.claim_type", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__discharge_disposition": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__discharge_disposition", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__discharge_disposition.csv", "original_file_path": "seeds\\terminology\\terminology__discharge_disposition.csv", "unique_id": "seed.the_tuva_project.terminology__discharge_disposition", "fqn": ["the_tuva_project", "terminology", "terminology__discharge_disposition"], "alias": "discharge_disposition", "checksum": {"name": "sha256", "checksum": "a76af528d7f867c651a809fdc4147595eb3a4e67f813b03f856f76f86a0b585c"}, "config": {"enabled": true, "alias": "discharge_disposition", "schema": "terminology", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','discharge_disposition.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"discharge_disposition_code": "varchar(256)", "discharge_disposition_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Seed containing NUBC discharge disposition codes and descriptions.", "columns": {"discharge_disposition_code": {"name": "discharge_disposition_code", "description": "The code representing the discharge disposition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "discharge_disposition_description": {"name": "discharge_disposition_description", "description": "A description of the discharge disposition.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','discharge_disposition.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "discharge_disposition", "column_types": {"discharge_disposition_code": "varchar(256)", "discharge_disposition_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1896057, "relation_name": "dev_thuxuan.terminology.discharge_disposition", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__encounter_type": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__encounter_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__encounter_type.csv", "original_file_path": "seeds\\terminology\\terminology__encounter_type.csv", "unique_id": "seed.the_tuva_project.terminology__encounter_type", "fqn": ["the_tuva_project", "terminology", "terminology__encounter_type"], "alias": "encounter_type", "checksum": {"name": "sha256", "checksum": "a8d2626a7aa8401d6b2c32eed1226abd92f4e3967986c9ba66006e68cfbd927d"}, "config": {"enabled": true, "alias": "encounter_type", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','encounter_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"encounter_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing"], "description": "Seed containing Tuva maintained encounter types.", "columns": {"encounter_type": {"name": "encounter_type", "description": "The type of the encounter.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','encounter_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "encounter_type", "tags": ["terminology", "claims_preprocessing"], "column_types": {"encounter_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.1965125, "relation_name": "dev_thuxuan.terminology.encounter_type", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ethnicity": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__ethnicity", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__ethnicity.csv", "original_file_path": "seeds\\terminology\\terminology__ethnicity.csv", "unique_id": "seed.the_tuva_project.terminology__ethnicity", "fqn": ["the_tuva_project", "terminology", "terminology__ethnicity"], "alias": "ethnicity", "checksum": {"name": "sha256", "checksum": "bcfd53e2a625f5953eddc7252d70dadd8a688413415a52484c604d7233d52dd6"}, "config": {"enabled": true, "alias": "ethnicity", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ethnicity.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing ethnicity codes and descriptions.", "columns": {"code": {"name": "code", "description": "The code representing the ethnicity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "A description of the ethnicity.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ethnicity.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ethnicity", "tags": "terminology", "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2025125, "relation_name": "dev_thuxuan.terminology.ethnicity", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__gender": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__gender", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__gender.csv", "original_file_path": "seeds\\terminology\\terminology__gender.csv", "unique_id": "seed.the_tuva_project.terminology__gender", "fqn": ["the_tuva_project", "terminology", "terminology__gender"], "alias": "gender", "checksum": {"name": "sha256", "checksum": "de9feaea8b66f7ba74845ee5fc156cdd22e8e4533de13ca76d71ac495da358ff"}, "config": {"enabled": true, "alias": "gender", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','gender.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"gender": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing gender codes and descriptions.", "columns": {"gender": {"name": "gender", "description": "The gender code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','gender.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "gender", "tags": ["terminology", "data_profiling"], "column_types": {"gender": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2070272, "relation_name": "dev_thuxuan.terminology.gender", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__hcpcs_level_2": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__hcpcs_level_2", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__hcpcs_level_2.csv", "original_file_path": "seeds\\terminology\\terminology__hcpcs_level_2.csv", "unique_id": "seed.the_tuva_project.terminology__hcpcs_level_2", "fqn": ["the_tuva_project", "terminology", "terminology__hcpcs_level_2"], "alias": "hcpcs_level_2", "checksum": {"name": "sha256", "checksum": "7c204c5d21b38f16be4dfdea1167634ccb992fac1b91699e94fc4180dd902d09"}, "config": {"enabled": true, "alias": "hcpcs_level_2", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','hcpcs_level_2.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs": "varchar(256)", "seqnum": "varchar(256)", "recid": "varchar(256)", "long_description": "varchar(2000)", "short_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing HCPCS Level II codes and descriptions.", "columns": {"hcpcs": {"name": "hcpcs", "description": "The HCPCS Level II code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "seqnum": {"name": "seqnum", "description": "The sequence number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "recid": {"name": "recid", "description": "The record identifier.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the HCPCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the HCPCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','hcpcs_level_2.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "hcpcs_level_2", "tags": "terminology", "column_types": {"hcpcs": "varchar(256)", "seqnum": "varchar(256)", "recid": "varchar(256)", "long_description": "varchar(2000)", "short_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2160268, "relation_name": "dev_thuxuan.terminology.hcpcs_level_2", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__hcpcs_to_rbcs": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__hcpcs_to_rbcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__hcpcs_to_rbcs.csv", "original_file_path": "seeds\\terminology\\terminology__hcpcs_to_rbcs.csv", "unique_id": "seed.the_tuva_project.terminology__hcpcs_to_rbcs", "fqn": ["the_tuva_project", "terminology", "terminology__hcpcs_to_rbcs"], "alias": "hcpcs_to_rbcs", "checksum": {"name": "sha256", "checksum": "d77822a411a96ed720cb2b94ffda8e51f1522a508ad2bb286ea24d90057aa02c"}, "config": {"enabled": true, "alias": "hcpcs_to_rbcs", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','hcpcs_to_rbcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs_cd": "varchar(256)", "rbcs_id": "varchar(256)", "rbcs_cat": "varchar(256)", "rbcs_cat_desc": "varchar(256)", "rbcs_cat_subcat": "varchar(256)", "rbcs_subcat_desc": "varchar(256)", "rbcs_famnumb": "numeric", "rbcs_family_desc": "varchar(256)", "rbcs_major_ind": "varchar(256)", "hcpcs_cd_add_dt": "date", "hcpcs_cd_end_dt": "date", "rbcs_assignment_eff_dt": "date", "current_flag": "numeric"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "HCPCS to RBCS crosswalk.", "columns": {"hcpcs_cd": {"name": "hcpcs_cd", "description": "HCPCS or CPT code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_id": {"name": "rbcs_id", "description": "RBCS identifier which is comprised of 6 characters. The first \ncharacter identifies the category; the second character identifies\nthe subcategory; the third, fourth, and fifth characters identify\nthe family, and the sixth character identifies whether the service\nis a major procedure.\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_cat": {"name": "rbcs_cat", "description": "First character for the RBCS taxonomy ID, which represents the RBCS ID category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_cat_desc": {"name": "rbcs_cat_desc", "description": "Category description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_cat_subcat": {"name": "rbcs_cat_subcat", "description": "First 2 characters for the RBCS taxonomy ID, which represents the RBCS ID's category and subcategory.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_subcat_desc": {"name": "rbcs_subcat_desc", "description": "Subcategory description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_famnumb": {"name": "rbcs_famnumb", "description": "Third, fourth, and fifth characters, which represents the RBCS family number.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_family_desc": {"name": "rbcs_family_desc", "description": "Family description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_major_ind": {"name": "rbcs_major_ind", "description": "Sixth character for the RBCS taxonomy ID, which identifies whether\nthe HCPCS code is a Major procedure (M), Other (O), or non-procedure\ncode (N).\n", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_cd_add_dt": {"name": "hcpcs_cd_add_dt", "description": "HCPCS Code Effective Date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_cd_end_dt": {"name": "hcpcs_cd_end_dt", "description": "HCPCS Code End Date.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rbcs_assignment_eff_dt": {"name": "rbcs_assignment_eff_dt", "description": "Provides users with the earliest date that the RBCS ID is effective.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "current_flag": {"name": "current_flag", "description": "Flag where 1 = the current version of the RBCS for that particular HCPCS_CD, 0 = old version.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','hcpcs_to_rbcs.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "hcpcs_to_rbcs", "tags": "terminology", "enabled": true, "column_types": {"hcpcs_cd": "varchar(256)", "rbcs_id": "varchar(256)", "rbcs_cat": "varchar(256)", "rbcs_cat_desc": "varchar(256)", "rbcs_cat_subcat": "varchar(256)", "rbcs_subcat_desc": "varchar(256)", "rbcs_famnumb": "numeric", "rbcs_family_desc": "varchar(256)", "rbcs_major_ind": "varchar(256)", "hcpcs_cd_add_dt": "date", "hcpcs_cd_end_dt": "date", "rbcs_assignment_eff_dt": "date", "current_flag": "numeric"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2310297, "relation_name": "dev_thuxuan.terminology.hcpcs_to_rbcs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_10_cm": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__icd_10_cm", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__icd_10_cm.csv", "original_file_path": "seeds\\terminology\\terminology__icd_10_cm.csv", "unique_id": "seed.the_tuva_project.terminology__icd_10_cm", "fqn": ["the_tuva_project", "terminology", "terminology__icd_10_cm"], "alias": "icd_10_cm", "checksum": {"name": "sha256", "checksum": "26bd81ab956f24c68160aadcef4bb75551ffb125b0ecadf437f6eb0e343099fb"}, "config": {"enabled": true, "alias": "icd_10_cm", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_10_cm.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "header_flag": "varchar(256)", "short_description": "varchar(256)", "long_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "description": "Seed containing ICD-10-CM codes and descriptions.", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "The ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "header_flag": {"name": "header_flag", "description": "Flag indicating if the code is a header.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the ICD-10-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_10_cm.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_10_cm", "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "column_types": {"icd_10_cm": "varchar(256)", "header_flag": "varchar(256)", "short_description": "varchar(256)", "long_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2520304, "relation_name": "dev_thuxuan.terminology.icd_10_cm", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_10_pcs": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__icd_10_pcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__icd_10_pcs.csv", "original_file_path": "seeds\\terminology\\terminology__icd_10_pcs.csv", "unique_id": "seed.the_tuva_project.terminology__icd_10_pcs", "fqn": ["the_tuva_project", "terminology", "terminology__icd_10_pcs"], "alias": "icd_10_pcs", "checksum": {"name": "sha256", "checksum": "1d18cafa0d405e60cd1be1e039fbfb2dfa9591a1cef6a441b60c26a61de41ad3"}, "config": {"enabled": true, "alias": "icd_10_pcs", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_10_pcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions"], "description": "Seed containing ICD-10-PCS codes and descriptions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "The ICD-10-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "The description of the ICD-10-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_10_pcs.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_10_pcs", "tags": ["terminology", "claims_preprocessing", "readmissions"], "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2580843, "relation_name": "dev_thuxuan.terminology.icd_10_pcs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_9_cm": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__icd_9_cm", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__icd_9_cm.csv", "original_file_path": "seeds\\terminology\\terminology__icd_9_cm.csv", "unique_id": "seed.the_tuva_project.terminology__icd_9_cm", "fqn": ["the_tuva_project", "terminology", "terminology__icd_9_cm"], "alias": "icd_9_cm", "checksum": {"name": "sha256", "checksum": "ed4c7e9c312522e20df88cb21837ea0953be63016bbd49c48a44f215e55353db"}, "config": {"enabled": true, "alias": "icd_9_cm", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_9_cm.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_9_cm": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "description": "Seed containing ICD-9-CM codes and descriptions.", "columns": {"icd_9_cm": {"name": "icd_9_cm", "description": "The ICD-9-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the ICD-9-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the ICD-9-CM code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_9_cm.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_9_cm", "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "column_types": {"icd_9_cm": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2380302, "relation_name": "dev_thuxuan.terminology.icd_9_cm", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__icd_9_pcs": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__icd_9_pcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__icd_9_pcs.csv", "original_file_path": "seeds\\terminology\\terminology__icd_9_pcs.csv", "unique_id": "seed.the_tuva_project.terminology__icd_9_pcs", "fqn": ["the_tuva_project", "terminology", "terminology__icd_9_pcs"], "alias": "icd_9_pcs", "checksum": {"name": "sha256", "checksum": "97258446a8c069119ada9e71632dd8a3f73135968cfdb38ba09109003915b525"}, "config": {"enabled": true, "alias": "icd_9_pcs", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_9_pcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_9_pcs": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "description": "Seed containing ICD-9-PCS codes and descriptions.", "columns": {"icd_9_pcs": {"name": "icd_9_pcs", "description": "The ICD-9-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_description": {"name": "long_description", "description": "The long description of the ICD-9-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_description": {"name": "short_description", "description": "The short description of the ICD-9-PCS code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','icd_9_pcs.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "icd_9_pcs", "tags": ["terminology", "claims_preprocessing", "readmissions", "data_profiling"], "column_types": {"icd_9_pcs": "varchar(256)", "long_description": "varchar(256)", "short_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2450304, "relation_name": "dev_thuxuan.terminology.icd_9_pcs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__loinc": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__loinc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__loinc.csv", "original_file_path": "seeds\\terminology\\terminology__loinc.csv", "unique_id": "seed.the_tuva_project.terminology__loinc", "fqn": ["the_tuva_project", "terminology", "terminology__loinc"], "alias": "loinc", "checksum": {"name": "sha256", "checksum": "374101e8b4e4fd5038c5bcae0dca2e5fcf2992883068619e2cbadad7ea3a8e7b"}, "config": {"enabled": true, "alias": "loinc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','loinc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"loinc": "varchar(256)", "short_name": "varchar(256)", "long_common_name": "varchar(256)", "component": "varchar(256)", "property": "varchar(256)", "time_aspect": "varchar(256)", "system": "varchar(256)", "scale_type": "varchar(256)", "method_type": "varchar(256)", "class_code": "varchar(256)", "class_description": "varchar(256)", "class_type_code": "varchar(256)", "class_type_description": "varchar(256)", "external_copyright_notice": "varchar(3000)", "status": "varchar(256)", "version_first_released": "varchar(256)", "version_last_changed": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing LOINC codes and descriptions.", "columns": {"loinc": {"name": "loinc", "description": "The LOINC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_name": {"name": "short_name", "description": "If exists, the short human-readable version of the LOINC description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "long_common_name": {"name": "long_common_name", "description": "Clinician-friendly full LOINC description.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "component": {"name": "component", "description": "The substance or entity being measured or observed. Also called the Analyte. The first of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "property": {"name": "property", "description": "The characteristic or attribute of the analyte. The second of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "time_aspect": {"name": "time_aspect", "description": "The interval of time over which an observation was made. The third of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "system": {"name": "system", "description": "The thing upon which the observation was made. Also called specimen for laboratory tests. The fourth of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "scale_type": {"name": "scale_type", "description": "How the observation value is quantified or expressed (e.g. quantitative, ordinal, nominal, etc.). The fifth of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "method_type": {"name": "method_type", "description": "A high-level classification of how the observation was made. Optional; only needed when the technique affects the clinical interpretation of the results. The sixth of six LOINC parts.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_code": {"name": "class_code", "description": "A code representing the general category of the LOINC term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_description": {"name": "class_description", "description": "The general category of the LOINC term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_type_code": {"name": "class_type_code", "description": "A code representing the top-level category for the test.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "class_type_description": {"name": "class_type_description", "description": "The top-level category for the test; Laboratory, Clinical, Claims attachments, or Surveys.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "external_copyright_notice": {"name": "external_copyright_notice", "description": "External copyright holder's copyright notice for this LOINC code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "status": {"name": "status", "description": "The status of the LOINC code concept. Active, Trial (experimental), Discouraged (not recommended), or Deprecated (should not be used).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "version_first_released": {"name": "version_first_released", "description": "The first release version of LOINC that included this code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "version_last_changed": {"name": "version_last_changed", "description": "The last LOINC version in which this record was changed.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','loinc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "loinc", "tags": ["terminology"], "column_types": {"loinc": "varchar(256)", "short_name": "varchar(256)", "long_common_name": "varchar(256)", "component": "varchar(256)", "property": "varchar(256)", "time_aspect": "varchar(256)", "system": "varchar(256)", "scale_type": "varchar(256)", "method_type": "varchar(256)", "class_code": "varchar(256)", "class_description": "varchar(256)", "class_type_code": "varchar(256)", "class_type_description": "varchar(256)", "external_copyright_notice": "varchar(3000)", "status": "varchar(256)", "version_first_released": "varchar(256)", "version_last_changed": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2763941, "relation_name": "dev_thuxuan.terminology.loinc", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__loinc_deprecated_mapping": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__loinc_deprecated_mapping", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__loinc_deprecated_mapping.csv", "original_file_path": "seeds\\terminology\\terminology__loinc_deprecated_mapping.csv", "unique_id": "seed.the_tuva_project.terminology__loinc_deprecated_mapping", "fqn": ["the_tuva_project", "terminology", "terminology__loinc_deprecated_mapping"], "alias": "loinc_deprecated_mapping", "checksum": {"name": "sha256", "checksum": "eecd52c3944bc1abd373c557a286ee386438733c6daf2fbb844e86623f7af119"}, "config": {"enabled": true, "alias": "loinc_deprecated_mapping", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','loinc_deprecated_mapping.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"loinc": "varchar(256)", "map_to": "varchar(256)", "comment": "varchar(256)", "final_map_to": "varchar(256)", "all_comments": "varchar(256)", "depth": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing deprecated LOINC codes and their replacements.", "columns": {"loinc": {"name": "loinc", "description": "The deprecated term to which the replacement term(s) apply.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_to": {"name": "map_to", "description": "A replacement term that is to be used in place of the deprecated or discouraged term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "comment": {"name": "comment", "description": "Narrative text that explains the rationale for using the recommended replacement term.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "final_map_to": {"name": "final_map_to", "description": "If there are multiple steps of deprecated codes, this is the final (active) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "all_comments": {"name": "all_comments", "description": "An aggregation of comments for any mapping steps between the deprecated code and the active code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "depth": {"name": "depth", "description": "How many steps this mapping is to the active code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','loinc_deprecated_mapping.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "loinc_deprecated_mapping", "tags": ["terminology"], "column_types": {"loinc": "varchar(256)", "map_to": "varchar(256)", "comment": "varchar(256)", "final_map_to": "varchar(256)", "all_comments": "varchar(256)", "depth": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.2884061, "relation_name": "dev_thuxuan.terminology.loinc_deprecated_mapping", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__mdc": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__mdc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__mdc.csv", "original_file_path": "seeds\\terminology\\terminology__mdc.csv", "unique_id": "seed.the_tuva_project.terminology__mdc", "fqn": ["the_tuva_project", "terminology", "terminology__mdc"], "alias": "mdc", "checksum": {"name": "sha256", "checksum": "ff8bd52323887788765f3602e13e6083ecebee26d5b9466d118f531d46a445e3"}, "config": {"enabled": true, "alias": "mdc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','mdc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"mdc_code": "varchar(256)", "mdc_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing Major Diagnostic Categories (MDC) codes and descriptions.", "columns": {"mdc_code": {"name": "mdc_code", "description": "The Major Diagnostic Category (MDC) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc_description": {"name": "mdc_description", "description": "The description of the Major Diagnostic Category (MDC).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','mdc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "mdc", "tags": "terminology", "column_types": {"mdc_code": "varchar(256)", "mdc_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.294406, "relation_name": "dev_thuxuan.terminology.mdc", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__medicare_dual_eligibility": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__medicare_dual_eligibility", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__medicare_dual_eligibility.csv", "original_file_path": "seeds\\terminology\\terminology__medicare_dual_eligibility.csv", "unique_id": "seed.the_tuva_project.terminology__medicare_dual_eligibility", "fqn": ["the_tuva_project", "terminology", "terminology__medicare_dual_eligibility"], "alias": "medicare_dual_eligibility", "checksum": {"name": "sha256", "checksum": "520243cb81b0f298c80fe446ea6c3d7b5f78d66d8caa6594e028073045210091"}, "config": {"enabled": true, "alias": "medicare_dual_eligibility", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_dual_eligibility.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"dual_status_code": "varchar(256)", "dual_status_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing Medicare dual eligibility status codes and descriptions.", "columns": {"dual_status_code": {"name": "dual_status_code", "description": "The code representing dual eligibility status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status_description": {"name": "dual_status_description", "description": "A description of the dual eligibility status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_dual_eligibility.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "medicare_dual_eligibility", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"dual_status_code": "varchar(256)", "dual_status_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3029175, "relation_name": "dev_thuxuan.terminology.medicare_dual_eligibility", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__medicare_orec": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__medicare_orec", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__medicare_orec.csv", "original_file_path": "seeds\\terminology\\terminology__medicare_orec.csv", "unique_id": "seed.the_tuva_project.terminology__medicare_orec", "fqn": ["the_tuva_project", "terminology", "terminology__medicare_orec"], "alias": "medicare_orec", "checksum": {"name": "sha256", "checksum": "91af2feb419d4ab1b82f88a165db27a2ded30c3e3b221081dc0bebee6c9c44ed"}, "config": {"enabled": true, "alias": "medicare_orec", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_orec.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"original_reason_entitlement_code": "varchar(256)", "original_reason_entitlement_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing Medicare original reason for entitlement (OREC) codes and descriptions.", "columns": {"original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "description": "The code representing the original reason for Medicare entitlement.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "original_reason_entitlement_description": {"name": "original_reason_entitlement_description", "description": "A description of the original reason for Medicare entitlement.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_orec.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "medicare_orec", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"original_reason_entitlement_code": "varchar(256)", "original_reason_entitlement_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3089259, "relation_name": "dev_thuxuan.terminology.medicare_orec", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__medicare_status": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__medicare_status", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__medicare_status.csv", "original_file_path": "seeds\\terminology\\terminology__medicare_status.csv", "unique_id": "seed.the_tuva_project.terminology__medicare_status", "fqn": ["the_tuva_project", "terminology", "terminology__medicare_status"], "alias": "medicare_status", "checksum": {"name": "sha256", "checksum": "c9d34774cf96cec7e8b301c8a965bdf320c0a03e65ffb96ba745ac3f161a2656"}, "config": {"enabled": true, "alias": "medicare_status", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_status.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"medicare_status_code": "varchar(256)", "medicare_status_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing Medicare status codes and descriptions.", "columns": {"medicare_status_code": {"name": "medicare_status_code", "description": "The code representing the Medicare status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_status_description": {"name": "medicare_status_description", "description": "A description of the Medicare status.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','medicare_status.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "medicare_status", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"medicare_status_code": "varchar(256)", "medicare_status_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3159263, "relation_name": "dev_thuxuan.terminology.medicare_status", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ms_drg": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__ms_drg", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__ms_drg.csv", "original_file_path": "seeds\\terminology\\terminology__ms_drg.csv", "unique_id": "seed.the_tuva_project.terminology__ms_drg", "fqn": ["the_tuva_project", "terminology", "terminology__ms_drg"], "alias": "ms_drg", "checksum": {"name": "sha256", "checksum": "d551fa50b60ab14efddee46089274d432d11570f3216db9aa6868074ace94ca2"}, "config": {"enabled": true, "alias": "ms_drg", "schema": "terminology", "database": null, "tags": ["terminology", "readmissions", "data_profiling", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ms_drg.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ms_drg_code": "varchar(256)", "mdc_code": "varchar(256)", "medical_surgical": "varchar(256)", "ms_drg_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "readmissions", "data_profiling", "claims_preprocessing"], "description": "Seed containing Medicare Severity Diagnosis Related Groups (MS-DRG) codes and descriptions.", "columns": {"ms_drg_code": {"name": "ms_drg_code", "description": "The Medicare Severity Diagnosis Related Group (MS-DRG) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc_code": {"name": "mdc_code", "description": "The Major Diagnostic Category (MDC) code associated with the MS-DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medical_surgical": {"name": "medical_surgical", "description": "Indicates whether the DRG is medical or surgical.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_description": {"name": "ms_drg_description", "description": "The description of the Medicare Severity Diagnosis Related Group (MS-DRG).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated": {"name": "deprecated", "description": "Indicates if the MS-DRG code is deprecated (1) or not (0).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deprecated_date": {"name": "deprecated_date", "description": "The date when the MS-DRG code was deprecated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ms_drg.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ms_drg", "tags": ["terminology", "readmissions", "data_profiling", "claims_preprocessing"], "column_types": {"ms_drg_code": "varchar(256)", "mdc_code": "varchar(256)", "medical_surgical": "varchar(256)", "ms_drg_description": "varchar(256)", "deprecated": "integer", "deprecated_date": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.336923, "relation_name": "dev_thuxuan.terminology.ms_drg", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ms_drg_weights_los": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__ms_drg_weights_los", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__ms_drg_weights_los.csv", "original_file_path": "seeds\\terminology\\terminology__ms_drg_weights_los.csv", "unique_id": "seed.the_tuva_project.terminology__ms_drg_weights_los", "fqn": ["the_tuva_project", "terminology", "terminology__ms_drg_weights_los"], "alias": "ms_drg_weights_los", "checksum": {"name": "sha256", "checksum": "599ee0b04a743ea1ab18f6f6bb6ee78bd767beef01aad6bcf872ef367520bc51"}, "config": {"enabled": true, "alias": "ms_drg_weights_los", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ms_drg_weights_los.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ms_drg": "varchar(256)", "fy_2024_final_post_acute_drg": "varchar(256)", "fy_2024_final_special_pay_drg": "varchar(256)", "mdc": "varchar(256)", "type": "varchar(256)", "ms_drg_title": "varchar(256)", "drg_weight_raw": "numeric(18,4)", "drg_weight": "numeric(18,4)", "geometric_mean_los": "numeric(18,2)", "arithmetic_mean_los": "numeric(18,2)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "description": "Seed containing Medicare Severity Diagnosis Related Groups (MS-DRG) weights and benchmark length of stay values from CMS.", "columns": {"ms_drg": {"name": "ms_drg", "description": "The Medicare Severity Diagnosis Related Group (MS-DRG) code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fy_2024_final_post_acute_drg": {"name": "fy_2024_final_post_acute_drg", "description": "Indicates if this is a FY 2024 final post-acute DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fy_2024_final_special_pay_drg": {"name": "fy_2024_final_special_pay_drg", "description": "Indicates if this is a FY 2024 final special pay DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "mdc": {"name": "mdc", "description": "The Major Diagnostic Category (MDC) code associated with the MS-DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "type": {"name": "type", "description": "The type of the DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ms_drg_title": {"name": "ms_drg_title", "description": "The title of the Medicare Severity Diagnosis Related Group (MS-DRG).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drg_weight_raw": {"name": "drg_weight_raw", "description": "The raw DRG weight.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drg_weight": {"name": "drg_weight", "description": "The adjusted DRG weight.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "geometric_mean_los": {"name": "geometric_mean_los", "description": "The geometric mean length of stay for this DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "arithmetic_mean_los": {"name": "arithmetic_mean_los", "description": "The arithmetic mean length of stay for this DRG.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ms_drg_weights_los.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ms_drg_weights_los", "tags": ["terminology", "data_profiling", "claims_preprocessing"], "column_types": {"ms_drg": "varchar(256)", "fy_2024_final_post_acute_drg": "varchar(256)", "fy_2024_final_special_pay_drg": "varchar(256)", "mdc": "varchar(256)", "type": "varchar(256)", "ms_drg_title": "varchar(256)", "drg_weight_raw": "numeric(18,4)", "drg_weight": "numeric(18,4)", "geometric_mean_los": "numeric(18,2)", "arithmetic_mean_los": "numeric(18,2)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3289225, "relation_name": "dev_thuxuan.terminology.ms_drg_weights_los", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__ndc": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__ndc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__ndc.csv", "original_file_path": "seeds\\terminology\\terminology__ndc.csv", "unique_id": "seed.the_tuva_project.terminology__ndc", "fqn": ["the_tuva_project", "terminology", "terminology__ndc"], "alias": "ndc", "checksum": {"name": "sha256", "checksum": "d53a75e4c3a87004c8cb4b4bf2368eada76e2ce9e60ad2d330420327d8fd30f2"}, "config": {"enabled": true, "alias": "ndc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ndc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ndc": "varchar(256)", "rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "fda_description": "varchar(3000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "This file collects all NDCs collected by the FDA and RxNorm, and compiles them into one list. The file is maintained by [CodeRX](https://coderx.io/) in partnership with Tuva Health.", "columns": {"ndc": {"name": "ndc", "description": "The National Drug Code (NDC).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxcui": {"name": "rxcui", "description": "The RxCUI identifier associated with the NDC.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "The description of the RxNorm concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "fda_description": {"name": "fda_description", "description": "The FDA description of the drug.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','ndc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "ndc", "tags": ["terminology"], "column_types": {"ndc": "varchar(256)", "rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "fda_description": "varchar(3000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3439229, "relation_name": "dev_thuxuan.terminology.ndc", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__nitos": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__nitos", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__nitos.csv", "original_file_path": "seeds\\terminology\\terminology__nitos.csv", "unique_id": "seed.the_tuva_project.terminology__nitos", "fqn": ["the_tuva_project", "terminology", "terminology__nitos"], "alias": "nitos", "checksum": {"name": "sha256", "checksum": "91f2354f390ee9ee2c22d71c7303028fdde8f0ed38d9899f15e61bb285b3f91b"}, "config": {"enabled": true, "alias": "nitos", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','nitos.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcpcs_code": "varchar(5)", "nitos_code": "varchar(5)", "nitos_description": "varchar(1000)", "invasive_non_invasive_flag": "varchar(50)", "modality": "varchar(50)", "body_region": "varchar(50)", "focus_area": "varchar(50)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','nitos.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "nitos", "tags": ["terminology"], "column_types": {"hcpcs_code": "varchar(5)", "nitos_code": "varchar(5)", "nitos_description": "varchar(1000)", "invasive_non_invasive_flag": "varchar(50)", "modality": "varchar(50)", "body_region": "varchar(50)", "focus_area": "varchar(50)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.475509, "relation_name": "dev_thuxuan.terminology.nitos", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__other_provider_taxonomy": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__other_provider_taxonomy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__other_provider_taxonomy.csv", "original_file_path": "seeds\\terminology\\terminology__other_provider_taxonomy.csv", "unique_id": "seed.the_tuva_project.terminology__other_provider_taxonomy", "fqn": ["the_tuva_project", "terminology", "terminology__other_provider_taxonomy"], "alias": "other_provider_taxonomy", "checksum": {"name": "sha256", "checksum": "ea344ae188db60f0f75e52a39114af49b7828fe050d3f761db03d4d07039cccf"}, "config": {"enabled": true, "alias": "other_provider_taxonomy", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.2','other_provider_taxonomy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"npi": "varchar(35)", "taxonomy_code": "varchar(35)", "medicare_specialty_code": "varchar(173)", "description": "varchar(101)", "primary_flag": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing"], "description": "Seed containing other provider taxonomy codes and descriptions.", "columns": {"npi": {"name": "npi", "description": "The National Provider Identifier (NPI).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "taxonomy_code": {"name": "taxonomy_code", "description": "The provider taxonomy code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicare_specialty_code": {"name": "medicare_specialty_code", "description": "The Medicare specialty code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the provider taxonomy.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_flag": {"name": "primary_flag", "description": "Indicates if this is the primary taxonomy (1) or not (0).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.2','other_provider_taxonomy.csv',compression=true,null_marker=true) }}", "schema": "terminology", "tags": ["terminology", "claims_preprocessing"], "alias": "other_provider_taxonomy", "column_types": {"npi": "varchar(35)", "taxonomy_code": "varchar(35)", "medicare_specialty_code": "varchar(173)", "description": "varchar(101)", "primary_flag": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3519225, "relation_name": "dev_thuxuan.terminology.other_provider_taxonomy", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__payer_type": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__payer_type", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__payer_type.csv", "original_file_path": "seeds\\terminology\\terminology__payer_type.csv", "unique_id": "seed.the_tuva_project.terminology__payer_type", "fqn": ["the_tuva_project", "terminology", "terminology__payer_type"], "alias": "payer_type", "checksum": {"name": "sha256", "checksum": "282a78d9af16774f2afddfd20b98c6b5cb9fedb632a5dea1a887f0e15bafade0"}, "config": {"enabled": true, "alias": "payer_type", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','payer_type.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"payer_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing payer types.", "columns": {"payer_type": {"name": "payer_type", "description": "The type of payer.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','payer_type.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "payer_type", "tags": ["terminology", "data_profiling"], "column_types": {"payer_type": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3569229, "relation_name": "dev_thuxuan.terminology.payer_type", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__place_of_service": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__place_of_service", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__place_of_service.csv", "original_file_path": "seeds\\terminology\\terminology__place_of_service.csv", "unique_id": "seed.the_tuva_project.terminology__place_of_service", "fqn": ["the_tuva_project", "terminology", "terminology__place_of_service"], "alias": "place_of_service", "checksum": {"name": "sha256", "checksum": "73979f823fbd58b0591864b102c9fbaea4459a05cc2aa4dcd3231c6a33c7ebb7"}, "config": {"enabled": true, "alias": "place_of_service", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','place_of_service.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"place_of_service_code": "varchar(256)", "place_of_service_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing place of service codes and descriptions.", "columns": {"place_of_service_code": {"name": "place_of_service_code", "description": "The code representing the place of service.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "place_of_service_description": {"name": "place_of_service_description", "description": "A description of the place of service.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','place_of_service.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "place_of_service", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"place_of_service_code": "varchar(256)", "place_of_service_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3639233, "relation_name": "dev_thuxuan.terminology.place_of_service", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__present_on_admission": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__present_on_admission", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__present_on_admission.csv", "original_file_path": "seeds\\terminology\\terminology__present_on_admission.csv", "unique_id": "seed.the_tuva_project.terminology__present_on_admission", "fqn": ["the_tuva_project", "terminology", "terminology__present_on_admission"], "alias": "present_on_admission", "checksum": {"name": "sha256", "checksum": "1f17dd2ef1ccf1f8cb156ac0d4be3cf5e7e96b56bfcb97b5113d0de8aabace48"}, "config": {"enabled": true, "alias": "present_on_admission", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','present_on_admission.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"present_on_admit_code": "varchar(256)", "present_on_admit_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling", "claims_preprocessing"], "description": "Seed containing present on admission (POA) indicator codes and descriptions.", "columns": {"present_on_admit_code": {"name": "present_on_admit_code", "description": "The code representing if the condition was present on admission.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "present_on_admit_description": {"name": "present_on_admit_description", "description": "A description of the present on admission (POA) indicator.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','present_on_admission.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "present_on_admission", "tags": ["terminology", "data_profiling", "claims_preprocessing"], "column_types": {"present_on_admit_code": "varchar(256)", "present_on_admit_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3699434, "relation_name": "dev_thuxuan.terminology.present_on_admission", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__provider": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__provider", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__provider.csv", "original_file_path": "seeds\\terminology\\terminology__provider.csv", "unique_id": "seed.the_tuva_project.terminology__provider", "fqn": ["the_tuva_project", "terminology", "terminology__provider"], "alias": "provider", "checksum": {"name": "sha256", "checksum": "f88950a046cf237eda0f4b60cd8284961c4b9c59742960a8e63f7305fe89ed05"}, "config": {"enabled": true, "alias": "provider", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.2','provider.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"npi": "varchar(35)", "entity_type_code": "varchar(26)", "entity_type_description": "varchar(37)", "primary_taxonomy_code": "varchar(35)", "primary_specialty_description": "varchar(173)", "provider_first_name": "varchar(95)", "provider_last_name": "varchar(95)", "provider_organization_name": "varchar(95)", "parent_organization_name": "varchar(95)", "practice_address_line_1": "varchar(80)", "practice_address_line_2": "varchar(80)", "practice_city": "varchar(65)", "practice_state": "varchar(65)", "practice_zip_code": "varchar(42)", "last_updated": "date", "deactivation_date": "date", "deactivation_flag": "varchar(80)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing"], "description": "Seed containing provider information.", "columns": {"npi": {"name": "npi", "description": "The National Provider Identifier (NPI).", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "entity_type_code": {"name": "entity_type_code", "description": "The entity type code of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "entity_type_description": {"name": "entity_type_description", "description": "The entity type description of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_taxonomy_code": {"name": "primary_taxonomy_code", "description": "The primary taxonomy code of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "primary_specialty_description": {"name": "primary_specialty_description", "description": "The primary specialty description of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_first_name": {"name": "provider_first_name", "description": "The first name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_last_name": {"name": "provider_last_name", "description": "The last name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "provider_organization_name": {"name": "provider_organization_name", "description": "The organization name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_organization_name": {"name": "parent_organization_name", "description": "The parent organization name of the provider.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_address_line_1": {"name": "practice_address_line_1", "description": "The first line of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_address_line_2": {"name": "practice_address_line_2", "description": "The second line of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_city": {"name": "practice_city", "description": "The city of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_state": {"name": "practice_state", "description": "The state of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "practice_zip_code": {"name": "practice_zip_code", "description": "The ZIP code of the practice address.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_updated": {"name": "last_updated", "description": "The date when the provider information was last updated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deactivation_date": {"name": "deactivation_date", "description": "The date when the provider was deactivated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "deactivation_flag": {"name": "deactivation_flag", "description": "Flag indicating if the provider is deactivated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_provider_data/0.12.2','provider.csv',compression=true,null_marker=true) }}", "schema": "terminology", "tags": ["terminology", "claims_preprocessing"], "alias": "provider", "column_types": {"npi": "varchar(35)", "entity_type_code": "varchar(26)", "entity_type_description": "varchar(37)", "primary_taxonomy_code": "varchar(35)", "primary_specialty_description": "varchar(173)", "provider_first_name": "varchar(95)", "provider_last_name": "varchar(95)", "provider_organization_name": "varchar(95)", "parent_organization_name": "varchar(95)", "practice_address_line_1": "varchar(80)", "practice_address_line_2": "varchar(80)", "practice_city": "varchar(65)", "practice_state": "varchar(65)", "practice_zip_code": "varchar(42)", "last_updated": "date", "deactivation_date": "date", "deactivation_flag": "varchar(80)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3899446, "relation_name": "dev_thuxuan.terminology.provider", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__race": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__race", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__race.csv", "original_file_path": "seeds\\terminology\\terminology__race.csv", "unique_id": "seed.the_tuva_project.terminology__race", "fqn": ["the_tuva_project", "terminology", "terminology__race"], "alias": "race", "checksum": {"name": "sha256", "checksum": "bcfd53e2a625f5953eddc7252d70dadd8a688413415a52484c604d7233d52dd6"}, "config": {"enabled": true, "alias": "race", "schema": "terminology", "database": null, "tags": ["terminology", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','race.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "data_profiling"], "description": "Seed containing race codes and descriptions.", "columns": {"code": {"name": "code", "description": "The code representing the race.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "A description of the race.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','race.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "race", "tags": ["terminology", "data_profiling"], "column_types": {"code": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.3949442, "relation_name": "dev_thuxuan.terminology.race", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__revenue_center": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__revenue_center", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__revenue_center.csv", "original_file_path": "seeds\\terminology\\terminology__revenue_center.csv", "unique_id": "seed.the_tuva_project.terminology__revenue_center", "fqn": ["the_tuva_project", "terminology", "terminology__revenue_center"], "alias": "revenue_center", "checksum": {"name": "sha256", "checksum": "58bde54ea73aaaa50a0342bb8a28da19fe865ca82d3997c3297c9ad616ca9eb1"}, "config": {"enabled": true, "alias": "revenue_center", "schema": "terminology", "database": null, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','revenue_center.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"revenue_center_code": "varchar(256)", "revenue_center_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "claims_preprocessing", "data_profiling"], "description": "Seed containing revenue center codes and descriptions.", "columns": {"revenue_center_code": {"name": "revenue_center_code", "description": "The code representing the revenue center.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "revenue_center_description": {"name": "revenue_center_description", "description": "A description of the revenue center.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','revenue_center.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "revenue_center", "tags": ["terminology", "claims_preprocessing", "data_profiling"], "column_types": {"revenue_center_code": "varchar(256)", "revenue_center_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4029672, "relation_name": "dev_thuxuan.terminology.revenue_center", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__rxnorm_brand_generic": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__rxnorm_brand_generic", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__rxnorm_brand_generic.csv", "original_file_path": "seeds\\terminology\\terminology__rxnorm_brand_generic.csv", "unique_id": "seed.the_tuva_project.terminology__rxnorm_brand_generic", "fqn": ["the_tuva_project", "terminology", "terminology__rxnorm_brand_generic"], "alias": "rxnorm_brand_generic", "checksum": {"name": "sha256", "checksum": "5300a2b3b0d164174be2fb0fb4c3eb1cef581ddc8f8f21e47c5803e22304f8e6"}, "config": {"enabled": true, "alias": "rxnorm_brand_generic", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','rxnorm_brand_generic.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "product_tty": "varchar(256)", "brand_vs_generic": "varchar(256)", "brand_name": "varchar(1000)", "clinical_product_rxcui": "varchar(256)", "clinical_product_name": "varchar(3000)", "clinical_product_tty": "varchar(256)", "ingredient_name": "varchar(3000)", "dose_form_name": "varchar(3000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','rxnorm_brand_generic.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "rxnorm_brand_generic", "tags": ["terminology"], "column_types": {"product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "product_tty": "varchar(256)", "brand_vs_generic": "varchar(256)", "brand_name": "varchar(1000)", "clinical_product_rxcui": "varchar(256)", "clinical_product_name": "varchar(3000)", "clinical_product_tty": "varchar(256)", "ingredient_name": "varchar(3000)", "dose_form_name": "varchar(3000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.459509, "relation_name": "dev_thuxuan.terminology.rxnorm_brand_generic", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__rxnorm_to_atc": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__rxnorm_to_atc", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__rxnorm_to_atc.csv", "original_file_path": "seeds\\terminology\\terminology__rxnorm_to_atc.csv", "unique_id": "seed.the_tuva_project.terminology__rxnorm_to_atc", "fqn": ["the_tuva_project", "terminology", "terminology__rxnorm_to_atc"], "alias": "rxnorm_to_atc", "checksum": {"name": "sha256", "checksum": "3817989c76e5142e5e0e6827d61b00cab45c17a94b77f923898d844f9807ad4c"}, "config": {"enabled": true, "alias": "rxnorm_to_atc", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','rxnorm_to_atc.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "atc_1_code": "varchar(256)", "atc_1_name": "varchar(256)", "atc_2_code": "varchar(256)", "atc_2_name": "varchar(256)", "atc_3_code": "varchar(256)", "atc_3_name": "varchar(256)", "atc_4_code": "varchar(256)", "atc_4_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "This file maps ATC classes to RxCUI. The file is maintained by [CodeRX](https://coderx.io/) in partnership with Tuva Health.", "columns": {"rxcui": {"name": "rxcui", "description": "The RxNorm code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rxnorm_description": {"name": "rxnorm_description", "description": "Description of the RxNorm concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_1_code": {"name": "atc_1_code", "description": "The ATC level 1 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_1_name": {"name": "atc_1_name", "description": "The name of the ATC level 1 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_2_code": {"name": "atc_2_code", "description": "The ATC level 2 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_2_name": {"name": "atc_2_name", "description": "The name of the ATC level 2 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_3_code": {"name": "atc_3_code", "description": "The ATC level 3 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_3_name": {"name": "atc_3_name", "description": "The name of the ATC level 3 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_4_code": {"name": "atc_4_code", "description": "The ATC level 4 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "atc_4_name": {"name": "atc_4_name", "description": "The name of the ATC level 4 code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','rxnorm_to_atc.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "rxnorm_to_atc", "tags": ["terminology"], "column_types": {"rxcui": "varchar(256)", "rxnorm_description": "varchar(3000)", "atc_1_code": "varchar(256)", "atc_1_name": "varchar(256)", "atc_2_code": "varchar(256)", "atc_2_name": "varchar(256)", "atc_3_code": "varchar(256)", "atc_3_name": "varchar(256)", "atc_4_code": "varchar(256)", "atc_4_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4145312, "relation_name": "dev_thuxuan.terminology.rxnorm_to_atc", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__snomed_ct": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__snomed_ct", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__snomed_ct.csv", "original_file_path": "seeds\\terminology\\terminology__snomed_ct.csv", "unique_id": "seed.the_tuva_project.terminology__snomed_ct", "fqn": ["the_tuva_project", "terminology", "terminology__snomed_ct"], "alias": "snomed_ct", "checksum": {"name": "sha256", "checksum": "b43378e55ac19ee1113d5b863784f7c8f5c5198d129d37c860bc43d311b5e00f"}, "config": {"enabled": true, "alias": "snomed_ct", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_ct.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"snomed_ct": "varchar(256)", "description": "varchar(256)", "is_active": "varchar(256)", "created": "date", "last_updated": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing SNOMED CT codes and descriptions.", "columns": {"snomed_ct": {"name": "snomed_ct", "description": "The SNOMED CT code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "The description of the SNOMED CT code.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "is_active": {"name": "is_active", "description": "Indicates if the SNOMED CT code is active.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "created": {"name": "created", "description": "The date when the SNOMED CT code was created.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "last_updated": {"name": "last_updated", "description": "The date when the SNOMED CT code was last updated.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_ct.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "snomed_ct", "tags": ["terminology"], "column_types": {"snomed_ct": "varchar(256)", "description": "varchar(256)", "is_active": "varchar(256)", "created": "date", "last_updated": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4405174, "relation_name": "dev_thuxuan.terminology.snomed_ct", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__snomed_ct_transitive_closures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__snomed_ct_transitive_closures.csv", "original_file_path": "seeds\\terminology\\terminology__snomed_ct_transitive_closures.csv", "unique_id": "seed.the_tuva_project.terminology__snomed_ct_transitive_closures", "fqn": ["the_tuva_project", "terminology", "terminology__snomed_ct_transitive_closures"], "alias": "snomed_ct_transitive_closures", "checksum": {"name": "sha256", "checksum": "8b4906f98be3058e45aee7a8c557623623beeeaca290ca922146f1541ff85c7b"}, "config": {"enabled": true, "alias": "snomed_ct_transitive_closures", "schema": "terminology", "database": null, "tags": ["terminology"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_ct_transitive_closures.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"parent_snomed_code": "varchar(256)", "parent_description": "varchar(256)", "child_snomed_code": "varchar(256)", "child_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology"], "description": "Seed containing SNOMED CT transitive closures.", "columns": {"parent_snomed_code": {"name": "parent_snomed_code", "description": "The SNOMED code of the parent concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_description": {"name": "parent_description", "description": "The description of the parent SNOMED concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "child_snomed_code": {"name": "child_snomed_code", "description": "The SNOMED code of the child concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "child_description": {"name": "child_description", "description": "The description of the child SNOMED concept.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_ct_transitive_closures.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "snomed_ct_transitive_closures", "tags": ["terminology"], "column_types": {"parent_snomed_code": "varchar(256)", "parent_description": "varchar(256)", "child_snomed_code": "varchar(256)", "child_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4495091, "relation_name": "dev_thuxuan.terminology.snomed_ct_transitive_closures", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.terminology__snomed_icd_10_map": {"database": "dev_thuxuan", "schema": "terminology", "name": "terminology__snomed_icd_10_map", "resource_type": "seed", "package_name": "the_tuva_project", "path": "terminology\\terminology__snomed_icd_10_map.csv", "original_file_path": "seeds\\terminology\\terminology__snomed_icd_10_map.csv", "unique_id": "seed.the_tuva_project.terminology__snomed_icd_10_map", "fqn": ["the_tuva_project", "terminology", "terminology__snomed_icd_10_map"], "alias": "snomed_icd_10_map", "checksum": {"name": "sha256", "checksum": "a9e5ce05b4fe9149571f87cfe6a77ef63f0f697da4f7e31a537bdc83927ee593"}, "config": {"enabled": true, "alias": "snomed_icd_10_map", "schema": "terminology", "database": null, "tags": ["terminology", "hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_icd_10_map.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"id": "varchar(256)", "effective_time": "varchar(256)", "active": "varchar(256)", "module_id": "varchar(256)", "ref_set_id": "varchar(256)", "referenced_component_id": "varchar(256)", "referenced_component_name": "varchar(256)", "map_group": "varchar(256)", "map_priority": "varchar(256)", "map_rule": "varchar(500)", "map_advice": "varchar(500)", "map_target": "varchar(256)", "map_target_name": "varchar(256)", "correlation_id": "varchar(256)", "map_category_id": "varchar(256)", "map_category_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["terminology", "hcc_suspecting"], "description": "Seed containing mappings between SNOMED CT and ICD-10 codes.", "columns": {"id": {"name": "id", "description": "The unique identifier for the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "effective_time": {"name": "effective_time", "description": "The effective time of the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "active": {"name": "active", "description": "Indicates if the mapping is active.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "module_id": {"name": "module_id", "description": "The module ID associated with the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ref_set_id": {"name": "ref_set_id", "description": "The reference set ID associated with the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "referenced_component_id": {"name": "referenced_component_id", "description": "The referenced component ID.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "referenced_component_name": {"name": "referenced_component_name", "description": "The name of the referenced component.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_group": {"name": "map_group", "description": "The map group.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_priority": {"name": "map_priority", "description": "The map priority.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_rule": {"name": "map_rule", "description": "The map rule.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_advice": {"name": "map_advice", "description": "Advice related to the map.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_target": {"name": "map_target", "description": "The map target.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_target_name": {"name": "map_target_name", "description": "The name of the map target.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "correlation_id": {"name": "correlation_id", "description": "The correlation ID associated with the mapping.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_category_id": {"name": "map_category_id", "description": "The map category ID.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "map_category_name": {"name": "map_category_name", "description": "The name of the map category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\terminology\\terminology_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_terminology/0.12.2','snomed_icd_10_map.csv',compression=true,null_marker=true) }}", "schema": "terminology", "alias": "snomed_icd_10_map", "tags": ["terminology", "hcc_suspecting"], "column_types": {"id": "varchar(256)", "effective_time": "varchar(256)", "active": "varchar(256)", "module_id": "varchar(256)", "ref_set_id": "varchar(256)", "referenced_component_id": "varchar(256)", "referenced_component_name": "varchar(256)", "map_group": "varchar(256)", "map_priority": "varchar(256)", "map_rule": "varchar(500)", "map_advice": "varchar(500)", "map_target": "varchar(256)", "map_target_name": "varchar(256)", "correlation_id": "varchar(256)", "map_category_id": "varchar(256)", "map_category_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4335203, "relation_name": "dev_thuxuan.terminology.snomed_icd_10_map", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.pqi__measures": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "pqi__measures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ahrq_measures\\pqi__measures.csv", "original_file_path": "seeds\\value_sets\\ahrq_measures\\pqi__measures.csv", "unique_id": "seed.the_tuva_project.pqi__measures", "fqn": ["the_tuva_project", "value_sets", "ahrq_measures", "pqi__measures"], "alias": "_value_set_pqi_measures", "checksum": {"name": "sha256", "checksum": "418bfe56cc5df98f458992857d672624a100921e46cdc0f67b04c704aaae42b3"}, "config": {"enabled": true, "alias": "_value_set_pqi_measures", "schema": "ahrq_measures", "database": null, "tags": ["pqi"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"pqi_number": "varchar(256)", "pqi_name": "varchar(256)", "pqi_description": "varchar(1000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["pqi"], "description": "Names and descriptions of each of the PQI measures", "columns": {"pqi_number": {"name": "pqi_number", "description": "Number of the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_name": {"name": "pqi_name", "description": "Name of the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_description": {"name": "pqi_description", "description": "Description of the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ahrq_measures\\pqi__seeds.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_value_set_pqi_measures", "tags": ["pqi"], "enabled": true, "column_types": {"pqi_number": "varchar(256)", "pqi_name": "varchar(256)", "pqi_description": "varchar(1000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4865124, "relation_name": "dev_thuxuan.ahrq_measures._value_set_pqi_measures", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": []}}, "seed.the_tuva_project.pqi__value_sets": {"database": "dev_thuxuan", "schema": "ahrq_measures", "name": "pqi__value_sets", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ahrq_measures\\pqi__value_sets.csv", "original_file_path": "seeds\\value_sets\\ahrq_measures\\pqi__value_sets.csv", "unique_id": "seed.the_tuva_project.pqi__value_sets", "fqn": ["the_tuva_project", "value_sets", "ahrq_measures", "pqi__value_sets"], "alias": "_value_set_pqi", "checksum": {"name": "sha256", "checksum": "69f16d118a28d012e04eff04a533ee3842e86fd9bf36e1fc1e533389d1b6de71"}, "config": {"enabled": true, "alias": "_value_set_pqi", "schema": "ahrq_measures", "database": null, "tags": ["pqi"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {"code": "varchar(256)", "value_set_name": "varchar(256)", "pqi_number": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["pqi"], "description": "Value sets from AHRQ for each of the published PQI measures", "columns": {"code": {"name": "code", "description": "Code associated with the PQI measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "value_set_name": {"name": "value_set_name", "description": "Name of the value set", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "pqi_number": {"name": "pqi_number", "description": "Number of the PQI measure", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/ahrq_measures/pqi__measures.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ahrq_measures\\pqi__seeds.yml", "build_path": null, "unrendered_config": {"schema": "ahrq_measures", "alias": "_value_set_pqi", "tags": ["pqi"], "enabled": true, "column_types": {"code": "varchar(256)", "value_set_name": "varchar(256)", "pqi_number": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.4815118, "relation_name": "dev_thuxuan.ahrq_measures._value_set_pqi", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": []}}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__dxccsr_v2023_1_body_systems", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ccsr\\ccsr__dxccsr_v2023_1_body_systems.csv", "original_file_path": "seeds\\value_sets\\ccsr\\ccsr__dxccsr_v2023_1_body_systems.csv", "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems", "fqn": ["the_tuva_project", "value_sets", "ccsr", "ccsr__dxccsr_v2023_1_body_systems"], "alias": "_value_set_dxccsr_v2023_1_body_systems", "checksum": {"name": "sha256", "checksum": "7697bf1b376e5db2c79b42edf944e29332b40b534eeaf0f379ff17439b4fb440"}, "config": {"enabled": true, "alias": "_value_set_dxccsr_v2023_1_body_systems", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','dxccsr_v2023_1_body_systems.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"body_system": "varchar(256)", "ccsr_parent_category": "varchar(256)", "parent_category_description": "varchar(3000)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ccsr"], "description": "A table containing descriptions of the top level categories used in the CCSR condition mapper.\nThis was manually extracted from the User Guide PDF included with the DXCCSR SAS program.\n", "columns": {"body_system": {"name": "body_system", "description": "The body system associated with the CCSR parent category.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_parent_category": {"name": "ccsr_parent_category", "description": "The parent category in the CCSR condition mapper.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "parent_category_description": {"name": "parent_category_description", "description": "Description of the parent category in the CCSR condition mapper.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ccsr\\ccsr_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','dxccsr_v2023_1_body_systems.csv',compression=true,null_marker=true) }}", "schema": "ccsr", "alias": "_value_set_dxccsr_v2023_1_body_systems", "tags": ["ccsr"], "enabled": true, "column_types": {"body_system": "varchar(256)", "ccsr_parent_category": "varchar(256)", "parent_category_description": "varchar(3000)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.495621, "relation_name": "dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__dxccsr_v2023_1_cleaned_map", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ccsr\\ccsr__dxccsr_v2023_1_cleaned_map.csv", "original_file_path": "seeds\\value_sets\\ccsr\\ccsr__dxccsr_v2023_1_cleaned_map.csv", "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "fqn": ["the_tuva_project", "value_sets", "ccsr", "ccsr__dxccsr_v2023_1_cleaned_map"], "alias": "_value_set_dxccsr_v2023_1_cleaned_map", "checksum": {"name": "sha256", "checksum": "cce1c4661615e89299e601fb26d3e3060b140864507858e5d0e8b61ea9b70c12"}, "config": {"enabled": true, "alias": "_value_set_dxccsr_v2023_1_cleaned_map", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','dxccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm_code": "varchar(256)", "icd_10_cm_code_description": "varchar(256)", "default_ccsr_category_ip": "varchar(256)", "default_ccsr_category_description_ip": "varchar(256)", "default_ccsr_category_op": "varchar(256)", "default_ccsr_category_description_op": "varchar(256)", "ccsr_category_1": "varchar(256)", "ccsr_category_1_description": "varchar(256)", "ccsr_category_2": "varchar(256)", "ccsr_category_2_description": "varchar(256)", "ccsr_category_3": "varchar(256)", "ccsr_category_3_description": "varchar(256)", "ccsr_category_4": "varchar(256)", "ccsr_category_4_description": "varchar(256)", "ccsr_category_5": "varchar(256)", "ccsr_category_5_description": "varchar(256)", "ccsr_category_6": "varchar(256)", "ccsr_category_6_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ccsr"], "description": "A table containing the CSV mapping file included with the DXCCSR SAS program.\nThe original CSV was not natively seedable, and the file was transformed with the coded included in the README.\nFor each ICD-10-CM code, the table contains up to six CCSR category codes and a default CCSR category code.\n", "columns": {"icd_10_cm_code": {"name": "icd_10_cm_code", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code_description": {"name": "icd_10_cm_code_description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_ip": {"name": "default_ccsr_category_ip", "description": "Default CCSR category for inpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_ip": {"name": "default_ccsr_category_description_ip", "description": "Description of the default CCSR category for inpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_op": {"name": "default_ccsr_category_op", "description": "Default CCSR category for outpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "default_ccsr_category_description_op": {"name": "default_ccsr_category_description_op", "description": "Description of the default CCSR category for outpatient settings", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_1": {"name": "ccsr_category_1", "description": "First CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_1_description": {"name": "ccsr_category_1_description", "description": "Description of the first CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_2": {"name": "ccsr_category_2", "description": "Second CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_2_description": {"name": "ccsr_category_2_description", "description": "Description of the second CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_3": {"name": "ccsr_category_3", "description": "Third CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_3_description": {"name": "ccsr_category_3_description", "description": "Description of the third CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_4": {"name": "ccsr_category_4", "description": "Fourth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_4_description": {"name": "ccsr_category_4_description", "description": "Description of the fourth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_5": {"name": "ccsr_category_5", "description": "Fifth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_5_description": {"name": "ccsr_category_5_description", "description": "Description of the fifth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_6": {"name": "ccsr_category_6", "description": "Sixth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccsr_category_6_description": {"name": "ccsr_category_6_description", "description": "Description of the sixth CCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ccsr\\ccsr_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','dxccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "schema": "ccsr", "alias": "_value_set_dxccsr_v2023_1_cleaned_map", "tags": ["ccsr"], "enabled": true, "column_types": {"icd_10_cm_code": "varchar(256)", "icd_10_cm_code_description": "varchar(256)", "default_ccsr_category_ip": "varchar(256)", "default_ccsr_category_description_ip": "varchar(256)", "default_ccsr_category_op": "varchar(256)", "default_ccsr_category_description_op": "varchar(256)", "ccsr_category_1": "varchar(256)", "ccsr_category_1_description": "varchar(256)", "ccsr_category_2": "varchar(256)", "ccsr_category_2_description": "varchar(256)", "ccsr_category_3": "varchar(256)", "ccsr_category_3_description": "varchar(256)", "ccsr_category_4": "varchar(256)", "ccsr_category_4_description": "varchar(256)", "ccsr_category_5": "varchar(256)", "ccsr_category_5_description": "varchar(256)", "ccsr_category_6": "varchar(256)", "ccsr_category_6_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5161338, "relation_name": "dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": {"database": "dev_thuxuan", "schema": "ccsr", "name": "ccsr__prccsr_v2023_1_cleaned_map", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ccsr\\ccsr__prccsr_v2023_1_cleaned_map.csv", "original_file_path": "seeds\\value_sets\\ccsr\\ccsr__prccsr_v2023_1_cleaned_map.csv", "unique_id": "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map", "fqn": ["the_tuva_project", "value_sets", "ccsr", "ccsr__prccsr_v2023_1_cleaned_map"], "alias": "_value_set_prccsr_v2023_1_cleaned_map", "checksum": {"name": "sha256", "checksum": "fd84423264c0174b1fc1e2ba23f1ac7957ef4fa7aaefcb2c45932f587b59fedf"}, "config": {"enabled": true, "alias": "_value_set_prccsr_v2023_1_cleaned_map", "schema": "ccsr", "database": null, "tags": ["ccsr"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','prccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "icd_10_pcs_description": "varchar(256)", "prccsr": "varchar(256)", "prccsr_description": "varchar(256)", "clinical_domain": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ccsr"], "description": "A table containing the CSV mapping file included with the PRCCSR SAS program.\nThe original CSV was not natively seedable, and the file was transformed with the coded included in the README.\n", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_pcs_description": {"name": "icd_10_pcs_description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prccsr": {"name": "prccsr", "description": "PRCCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "prccsr_description": {"name": "prccsr_description", "description": "Description of the PRCCSR category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "clinical_domain": {"name": "clinical_domain", "description": "Clinical domain associated with the PRCCSR category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ccsr\\ccsr_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','prccsr_v2023_1_cleaned_map.csv',compression=true,null_marker=true) }}", "schema": "ccsr", "alias": "_value_set_prccsr_v2023_1_cleaned_map", "tags": ["ccsr"], "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "icd_10_pcs_description": "varchar(256)", "prccsr": "varchar(256)", "prccsr_description": "varchar(256)", "clinical_domain": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5251303, "relation_name": "dev_thuxuan.ccsr._value_set_prccsr_v2023_1_cleaned_map", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__cms_chronic_conditions_hierarchy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\chronic_conditions\\chronic_conditions__cms_chronic_conditions_hierarchy.csv", "original_file_path": "seeds\\value_sets\\chronic_conditions\\chronic_conditions__cms_chronic_conditions_hierarchy.csv", "unique_id": "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "fqn": ["the_tuva_project", "value_sets", "chronic_conditions", "chronic_conditions__cms_chronic_conditions_hierarchy"], "alias": "_value_set_cms_chronic_conditions_hierarchy", "checksum": {"name": "sha256", "checksum": "3328c63a1bcb8d0813bb98a61739cb69306aa2726082b042baa377c4fb761302"}, "config": {"enabled": true, "alias": "_value_set_cms_chronic_conditions_hierarchy", "schema": "chronic_conditions", "database": null, "tags": ["cms_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"condition_id": "varchar(256)", "condition": "varchar(256)", "condition_column_name": "varchar(256)", "chronic_condition_type": "varchar(256)", "condition_category": "varchar(256)", "additional_logic": "varchar(256)", "claims_qualification": "varchar(1024)", "inclusion_type": "varchar(256)", "code_system": "varchar(256)", "code": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_chronic_conditions", "chronic_conditions"], "description": "CMS generated grouping of ICD 10 codes into chronic conditions groups", "columns": {"condition_id": {"name": "condition_id", "description": "Identifier for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "Name of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_column_name": {"name": "condition_column_name", "description": "Column name for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "chronic_condition_type": {"name": "chronic_condition_type", "description": "Type of chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_category": {"name": "condition_category", "description": "Category of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "additional_logic": {"name": "additional_logic", "description": "Additional logic for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "claims_qualification": {"name": "claims_qualification", "description": "Claims qualification criteria for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "inclusion_type": {"name": "inclusion_type", "description": "Type of inclusion for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "Code system used for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Code for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\chronic_conditions\\cms_chronic_conditions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "schema": "chronic_conditions", "alias": "_value_set_cms_chronic_conditions_hierarchy", "tags": ["cms_chronic_conditions", "chronic_conditions"], "enabled": true, "column_types": {"condition_id": "varchar(256)", "condition": "varchar(256)", "condition_column_name": "varchar(256)", "chronic_condition_type": "varchar(256)", "condition_category": "varchar(256)", "additional_logic": "varchar(256)", "claims_qualification": "varchar(1024)", "inclusion_type": "varchar(256)", "code_system": "varchar(256)", "code": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5381303, "relation_name": "dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": {"database": "dev_thuxuan", "schema": "chronic_conditions", "name": "chronic_conditions__tuva_chronic_conditions_hierarchy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\chronic_conditions\\chronic_conditions__tuva_chronic_conditions_hierarchy.csv", "original_file_path": "seeds\\value_sets\\chronic_conditions\\chronic_conditions__tuva_chronic_conditions_hierarchy.csv", "unique_id": "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy", "fqn": ["the_tuva_project", "value_sets", "chronic_conditions", "chronic_conditions__tuva_chronic_conditions_hierarchy"], "alias": "_value_set_tuva_chronic_conditions_hierarchy", "checksum": {"name": "sha256", "checksum": "b379c992888d52f3b13270d7e804e5c5d0d1314d1039123674e6122884c37ce3"}, "config": {"enabled": true, "alias": "_value_set_tuva_chronic_conditions_hierarchy", "schema": "chronic_conditions", "database": null, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"condition_family": "varchar(256)", "condition": "varchar(256)", "icd_10_cm_code": "varchar(256)", "icd_10_cm_description": "varchar(256)", "condition_column_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["tuva_chronic_conditions", "chronic_conditions"], "description": "A list of the diagnoses codes and their long and short names along with grouping logic classifying each code into a condition group and a condition family group.", "columns": {"condition_family": {"name": "condition_family", "description": "Family group of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition": {"name": "condition", "description": "Name of the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_code": {"name": "icd_10_cm_code", "description": "ICD-10-CM code for the chronic condition", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "icd_10_cm_description": {"name": "icd_10_cm_description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "condition_column_name": {"name": "condition_column_name", "description": "Column name for the chronic condition", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\chronic_conditions\\tuva_chronic_conditions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','tuva_chronic_conditions_hierarchy.csv',compression=true,null_marker=true) }}", "schema": "chronic_conditions", "alias": "_value_set_tuva_chronic_conditions_hierarchy", "tags": ["tuva_chronic_conditions", "chronic_conditions"], "enabled": true, "column_types": {"condition_family": "varchar(256)", "condition": "varchar(256)", "icd_10_cm_code": "varchar(256)", "icd_10_cm_description": "varchar(256)", "condition_column_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.550223, "relation_name": "dev_thuxuan.chronic_conditions._value_set_tuva_chronic_conditions_hierarchy", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__adjustment_rates": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__adjustment_rates", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__adjustment_rates.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__adjustment_rates.csv", "unique_id": "seed.the_tuva_project.cms_hcc__adjustment_rates", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__adjustment_rates"], "alias": "_value_set_adjustment_rates", "checksum": {"name": "sha256", "checksum": "51bc7577f57c9638cdc72ca40f108301756eb831a01345b7763c38bfbb869b4a"}, "config": {"enabled": true, "alias": "_value_set_adjustment_rates", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_adjustment_rates.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "payment_year": "integer", "normalization_factor": "float", "ma_coding_pattern_adjustment": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Adjustment rates by payment year. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_year": {"name": "payment_year", "description": "The year for which the adjustment rates are applicable", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "normalization_factor": {"name": "normalization_factor", "description": "The normalization factor applied", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ma_coding_pattern_adjustment": {"name": "ma_coding_pattern_adjustment", "description": "The Medicare Advantage coding pattern adjustment factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_adjustment_rates.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_adjustment_rates", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "payment_year": "integer", "normalization_factor": "float", "ma_coding_pattern_adjustment": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5581303, "relation_name": "dev_thuxuan.cms_hcc._value_set_adjustment_rates", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__cpt_hcpcs": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__cpt_hcpcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__cpt_hcpcs.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__cpt_hcpcs.csv", "unique_id": "seed.the_tuva_project.cms_hcc__cpt_hcpcs", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__cpt_hcpcs"], "alias": "_value_set_cpt_hcpcs", "checksum": {"name": "sha256", "checksum": "511389c6e0558d00efb8c3cae2123a46f97e616d26bdf7b8a331670f857b1ac8"}, "config": {"enabled": true, "alias": "_value_set_cpt_hcpcs", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_cpt_hcpcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"payment_year": "integer", "hcpcs_cpt_code": "varchar(256)", "included_flag": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "CPT/HCPCS encounter filtering included list by payment year. Combined and cleaned version of code files on cms.gov.\n", "columns": {"payment_year": {"name": "payment_year", "description": "The year for which the CPT/HCPCS codes are applicable", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcpcs_cpt_code": {"name": "hcpcs_cpt_code", "description": "The CPT or HCPCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "included_flag": {"name": "included_flag", "description": "Flag indicating whether the code is included in the filtering", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_cpt_hcpcs.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_cpt_hcpcs", "tags": "cms_hcc", "enabled": true, "column_types": {"payment_year": "integer", "hcpcs_cpt_code": "varchar(256)", "included_flag": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.565131, "relation_name": "dev_thuxuan.cms_hcc._value_set_cpt_hcpcs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__demographic_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__demographic_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__demographic_factors.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__demographic_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__demographic_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__demographic_factors"], "alias": "_value_set_demographic_factors", "checksum": {"name": "sha256", "checksum": "b3bbcb21143941da7dc41c5ca2f68d4cbe180920e344ea1dded30722b7193c84"}, "config": {"enabled": true, "alias": "_value_set_demographic_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_demographic_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "plan_segment": "varchar(256)", "gender": "varchar(256)", "age_group": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Demographic factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of demographic factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "plan_segment": {"name": "plan_segment", "description": "Plan segment of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Gender of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "age_group": {"name": "age_group", "description": "Age group of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the demographic factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_demographic_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_demographic_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "plan_segment": "varchar(256)", "gender": "varchar(256)", "age_group": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5781336, "relation_name": "dev_thuxuan.cms_hcc._value_set_demographic_factors", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__disabled_interaction_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__disabled_interaction_factors.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__disabled_interaction_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disabled_interaction_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disabled_interaction_factors"], "alias": "_value_set_disabled_interaction_factors", "checksum": {"name": "sha256", "checksum": "b2e6ac06c8ef6087ff21d9aa2b868cdddca29fda8fc8346563c81a56f0e97f2a"}, "config": {"enabled": true, "alias": "_value_set_disabled_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disabled_interaction_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease and disabled interaction factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_name": {"name": "short_name", "description": "Short name of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disabled_interaction_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disabled_interaction_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5891345, "relation_name": "dev_thuxuan.cms_hcc._value_set_disabled_interaction_factors", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disease_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__disease_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__disease_factors.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__disease_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disease_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disease_factors"], "alias": "_value_set_disease_factors", "checksum": {"name": "sha256", "checksum": "64c15ace094f384cb6a38b0a0c67a0216f8eb2ef0e00cd8fc7537e9fd1a85f7f"}, "config": {"enabled": true, "alias": "_value_set_disease_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of disease factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disease factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the disease factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disease_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.5991342, "relation_name": "dev_thuxuan.cms_hcc._value_set_disease_factors", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disease_hierarchy": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__disease_hierarchy", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__disease_hierarchy.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__disease_hierarchy.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disease_hierarchy", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disease_hierarchy"], "alias": "_value_set_disease_hierarchy", "checksum": {"name": "sha256", "checksum": "48982402067756cdefe3729778775b1868734dacdc88f44407971aa120586468"}, "config": {"enabled": true, "alias": "_value_set_disease_hierarchy", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_hierarchy.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "hccs_to_exclude": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease hierarchies by model version. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the disease hierarchy", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hccs_to_exclude": {"name": "hccs_to_exclude", "description": "HCC codes to exclude from the hierarchy", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_hierarchy.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disease_hierarchy", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "hcc_code": "varchar(256)", "description": "varchar(256)", "hccs_to_exclude": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6089296, "relation_name": "dev_thuxuan.cms_hcc._value_set_disease_hierarchy", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__disease_interaction_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__disease_interaction_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__disease_interaction_factors.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__disease_interaction_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__disease_interaction_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__disease_interaction_factors"], "alias": "_value_set_disease_interaction_factors", "checksum": {"name": "sha256", "checksum": "a2f6c69a63ed5c43e250b356ea308285effbb38643d732404f8e4277fe649a00"}, "config": {"enabled": true, "alias": "_value_set_disease_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_interaction_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code_1": "varchar(256)", "hcc_code_2": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Disease interaction factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "short_name": {"name": "short_name", "description": "Short name of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_1": {"name": "hcc_code_1", "description": "First Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_code_2": {"name": "hcc_code_2", "description": "Second Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_disease_interaction_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_disease_interaction_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "short_name": "varchar(256)", "description": "varchar(256)", "hcc_code_1": "varchar(256)", "hcc_code_2": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6218038, "relation_name": "dev_thuxuan.cms_hcc._value_set_disease_interaction_factors", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__enrollment_interaction_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__enrollment_interaction_factors.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__enrollment_interaction_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__enrollment_interaction_factors"], "alias": "_value_set_enrollment_interaction_factors", "checksum": {"name": "sha256", "checksum": "8ff088e57fc620bde58a0e1707097011e249e3b2c65f1b1754da0cb6a0c3fa09"}, "config": {"enabled": true, "alias": "_value_set_enrollment_interaction_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_enrollment_interaction_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "gender": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "institutional_status": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Enrollment interaction factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of enrollment interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "gender": {"name": "gender", "description": "Gender of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the enrollment interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the enrollment interaction factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_enrollment_interaction_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_enrollment_interaction_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "gender": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "institutional_status": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6328037, "relation_name": "dev_thuxuan.cms_hcc._value_set_enrollment_interaction_factors", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__icd_10_cm_mappings", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__icd_10_cm_mappings.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__icd_10_cm_mappings.csv", "unique_id": "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__icd_10_cm_mappings"], "alias": "_value_set_icd_10_cm_mappings", "checksum": {"name": "sha256", "checksum": "03dda989fc2f10b3741665515d73d2352b52061d605ddf7fef318b53b1a24a57"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_mappings", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"payment_year": "integer", "diagnosis_code": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v24_flag": "varchar(256)", "cms_hcc_v28": "varchar(256)", "cms_hcc_v28_flag": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "ICD-10 to HCC mapping by payment year and model version. Combined and cleaned version of code files on cms.gov.\n", "columns": {"payment_year": {"name": "payment_year", "description": "The year for which the ICD-10 to HCC mapping is applicable", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "diagnosis_code": {"name": "diagnosis_code", "description": "ICD-10 diagnosis code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v24": {"name": "cms_hcc_v24", "description": "CMS-HCC version 24 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v24_flag": {"name": "cms_hcc_v24_flag", "description": "Flag indicating inclusion in CMS-HCC version 24", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v28": {"name": "cms_hcc_v28", "description": "CMS-HCC version 28 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v28_flag": {"name": "cms_hcc_v28_flag", "description": "Flag indicating inclusion in CMS-HCC version 28", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_icd_10_cm_mappings", "tags": "cms_hcc", "enabled": true, "column_types": {"payment_year": "integer", "diagnosis_code": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v24_flag": "varchar(256)", "cms_hcc_v28": "varchar(256)", "cms_hcc_v28_flag": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6421225, "relation_name": "dev_thuxuan.cms_hcc._value_set_icd_10_cm_mappings", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": {"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__payment_hcc_count_factors", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\cms_hcc\\cms_hcc__payment_hcc_count_factors.csv", "original_file_path": "seeds\\value_sets\\cms_hcc\\cms_hcc__payment_hcc_count_factors.csv", "unique_id": "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors", "fqn": ["the_tuva_project", "value_sets", "cms_hcc", "cms_hcc__payment_hcc_count_factors"], "alias": "_value_set_payment_hcc_count_factors", "checksum": {"name": "sha256", "checksum": "bf87f7657286107fa26c903a7ed24a2e8d39ca5fbd8869ee778adecb91bb2431"}, "config": {"enabled": true, "alias": "_value_set_payment_hcc_count_factors", "schema": "cms_hcc", "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_payment_hcc_count_factors.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "payment_hcc_count": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["cms_hcc"], "description": "Payment HCC count factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"model_version": {"name": "model_version", "description": "Version of the CMS-HCC model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "factor_type": {"name": "factor_type", "description": "Type of HCC count factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Enrollment status of the individual", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_status.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "medicaid_status": {"name": "medicaid_status", "description": "Medicaid status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "dual_status": {"name": "dual_status", "description": "Dual eligibility status of the individual", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_dual_eligibility.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "orec": {"name": "orec", "description": "Original reason for entitlement code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__medicare_orec.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "institutional_status": {"name": "institutional_status", "description": "Institutional status of the individual", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "payment_hcc_count": {"name": "payment_hcc_count", "description": "Count of HCCs for payment adjustment", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the HCC count factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "coefficient": {"name": "coefficient", "description": "Coefficient for the HCC count factor", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\cms_hcc\\cms_hcc_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','cms_hcc_payment_hcc_count_factors.csv',compression=true,null_marker=true) }}", "schema": "cms_hcc", "alias": "_value_set_payment_hcc_count_factors", "tags": "cms_hcc", "enabled": true, "column_types": {"model_version": "varchar(256)", "factor_type": "varchar(256)", "enrollment_status": "varchar(256)", "medicaid_status": "varchar(256)", "dual_status": "varchar(256)", "orec": "varchar(256)", "institutional_status": "varchar(256)", "payment_hcc_count": "varchar(256)", "description": "varchar(256)", "coefficient": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6530085, "relation_name": "dev_thuxuan.cms_hcc._value_set_payment_hcc_count_factors", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_field_info": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__crosswalk_field_info", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\data_quality\\data_quality__crosswalk_field_info.csv", "original_file_path": "seeds\\value_sets\\data_quality\\data_quality__crosswalk_field_info.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_info", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_field_info"], "alias": "_value_set_crosswalk_field_info", "checksum": {"name": "sha256", "checksum": "49018f7f640ba18033abb593294b72b1ed3a7bf4f648481dbc62316427cf842c"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_field_info", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_field_info.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "red": "integer", "green": "integer", "unique_values_expected_flag": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Target thresholds at the field level determining red, yellow, and green values in the Data Quality dashboard.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\data_quality\\data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_field_info.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_field_info", "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "red": "integer", "green": "integer", "unique_values_expected_flag": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6590085, "relation_name": "dev_thuxuan.data_quality._value_set_crosswalk_field_info", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__crosswalk_field_to_mart", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\data_quality\\data_quality__crosswalk_field_to_mart.csv", "original_file_path": "seeds\\value_sets\\data_quality\\data_quality__crosswalk_field_to_mart.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_to_mart", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_field_to_mart"], "alias": "_value_set_crosswalk_field_to_mart", "checksum": {"name": "sha256", "checksum": "80e5215c48dc51ea0e4ce834d4006f7649e62cd60b0fcb278d83cfbdc4abacda"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_field_to_mart", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_field_to_mart.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "mart_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Crosswalk table that defines which fields impact the ability for marts to run.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\data_quality\\data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_field_to_mart.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_field_to_mart", "column_types": {"input_layer_table_name": "varchar(256)", "claim_type": "varchar(256)", "field_name": "varchar(256)", "mart_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6670082, "relation_name": "dev_thuxuan.data_quality._value_set_crosswalk_field_to_mart", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__crosswalk_mart_to_outcome_measure", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\data_quality\\data_quality__crosswalk_mart_to_outcome_measure.csv", "original_file_path": "seeds\\value_sets\\data_quality\\data_quality__crosswalk_mart_to_outcome_measure.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_mart_to_outcome_measure"], "alias": "_value_set_crosswalk_mart_to_outcome_measure", "checksum": {"name": "sha256", "checksum": "dc42970571b546b1577e4abe46411e2a3b49b8c30d099b0f2c89adb1c133e45d"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_mart_to_outcome_measure", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_mart_to_outcome_measure.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"mart_name": "varchar(256)", "measure_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Crosswalk table that defines which marts impact which outcome measures.\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\data_quality\\data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_mart_to_outcome_measure.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_mart_to_outcome_measure", "column_types": {"mart_name": "varchar(256)", "measure_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.672008, "relation_name": "dev_thuxuan.data_quality._value_set_crosswalk_mart_to_outcome_measure", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__crosswalk_measure_reasonable_ranges", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\data_quality\\data_quality__crosswalk_measure_reasonable_ranges.csv", "original_file_path": "seeds\\value_sets\\data_quality\\data_quality__crosswalk_measure_reasonable_ranges.csv", "unique_id": "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__crosswalk_measure_reasonable_ranges"], "alias": "_value_set_crosswalk_measure_reasonable_ranges", "checksum": {"name": "sha256", "checksum": "02fafa4757f16c3134b2d5f622eff335102ca1397547eba27d67b6042fba299d"}, "config": {"enabled": true, "alias": "_value_set_crosswalk_measure_reasonable_ranges", "schema": "data_quality", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_measure_reasonable_ranges.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"measure_name": "varchar(256)", "payer_type": "varchar(256)", "lower_bound": "float", "upper_bound": "float"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Crosswalk table that sets reasonable ranges for outcome measures\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\data_quality\\data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_crosswalk_measure_reasonable_ranges.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_crosswalk_measure_reasonable_ranges", "column_types": {"measure_name": "varchar(256)", "payer_type": "varchar(256)", "lower_bound": "float", "upper_bound": "float"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.679009, "relation_name": "dev_thuxuan.data_quality._value_set_crosswalk_measure_reasonable_ranges", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.data_quality__reference_mart_analytics": {"database": "dev_thuxuan", "schema": "data_quality", "name": "data_quality__reference_mart_analytics", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\data_quality\\data_quality__reference_mart_analytics.csv", "original_file_path": "seeds\\value_sets\\data_quality\\data_quality__reference_mart_analytics.csv", "unique_id": "seed.the_tuva_project.data_quality__reference_mart_analytics", "fqn": ["the_tuva_project", "value_sets", "data_quality", "data_quality__reference_mart_analytics"], "alias": "_value_set_reference_mart_analytics", "checksum": {"name": "sha256", "checksum": "a75ae350862f59242b8a5097b4806caa5c1f780e60da7ec7d12701be0393174e"}, "config": {"enabled": true, "alias": "_value_set_reference_mart_analytics", "schema": "data_quality", "database": null, "tags": ["data_quality_audit"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_reference_mart_analytics.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"analytics_concept": "varchar(256)", "analytics_measure": "varchar(256)", "analytics_value": "varchar(256)", "value_rank": "integer", "payer_type": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["data_quality_audit"], "description": "reference values for analytics checks from various benchmark sources\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\data_quality\\data_quality__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','data_quality_reference_mart_analytics.csv',compression=true,null_marker=true) }}", "schema": "data_quality", "alias": "_value_set_reference_mart_analytics", "column_types": {"analytics_concept": "varchar(256)", "analytics_measure": "varchar(256)", "analytics_value": "varchar(256)", "value_rank": "integer", "payer_type": "varchar(256)"}, "tags": ["data_quality_audit"], "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6871753, "relation_name": "dev_thuxuan.data_quality._value_set_reference_mart_analytics", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__categories": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__categories", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ed_classification\\ed_classification__categories.csv", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification__categories.csv", "unique_id": "seed.the_tuva_project.ed_classification__categories", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__categories"], "alias": "_value_set_categories", "checksum": {"name": "sha256", "checksum": "cf0576acd61cdf96595d8efb636ca9fa6812aa88ea934ab70f7cffe1241f4c2f"}, "config": {"enabled": true, "alias": "_value_set_categories", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','ed_classification_categories.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"classification": "varchar(256)", "classification_name": "varchar(256)", "classification_order": "varchar(256)", "classification_column": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A mapping of ED Classifications to human-readable names", "columns": {"classification": {"name": "classification", "description": "ED classification code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "classification_name": {"name": "classification_name", "description": "Human-readable name for the ED classification", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "classification_order": {"name": "classification_order", "description": "Order of the ED classification", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "classification_column": {"name": "classification_column", "description": "Column name for the ED classification", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','ed_classification_categories.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_categories", "tags": "ed_classification", "enabled": true, "column_types": {"classification": "varchar(256)", "classification_name": "varchar(256)", "classification_order": "varchar(256)", "classification_column": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.6971643, "relation_name": "dev_thuxuan.ed_classification._value_set_categories", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__icd_10_cm_to_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ed_classification\\ed_classification__icd_10_cm_to_ccs.csv", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification__icd_10_cm_to_ccs.csv", "unique_id": "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__icd_10_cm_to_ccs"], "alias": "_value_set_icd_10_cm_to_ccs", "checksum": {"name": "sha256", "checksum": "0f2119b159a22eeb902b925b2eb98357b33bbc09bae3b7fceb04de71cf041476"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_to_ccs", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A mapping of ICD-10-CM codes to CCS categories", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/value_sets/ed_classification/ed_classification__categories.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_description": {"name": "ccs_description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_icd_10_cm_to_ccs", "tags": "ed_classification", "enabled": true, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.7046728, "relation_name": "dev_thuxuan.ed_classification._value_set_icd_10_cm_to_ccs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__johnston_icd10": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__johnston_icd10", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ed_classification\\ed_classification__johnston_icd10.csv", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification__johnston_icd10.csv", "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd10", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__johnston_icd10"], "alias": "_value_set_johnston_icd10", "checksum": {"name": "sha256", "checksum": "86d77b4087f009aa80ba4a6ea7e1977c1230d6067ef4538b3a5cc0249e65657b"}, "config": {"enabled": true, "alias": "_value_set_johnston_icd10", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','johnston_icd10.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd10": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "noner": "varchar(256)", "epct": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A probabilistic mapping of ICD-10 codes to ED classification categories", "columns": {"icd10": {"name": "icd10", "description": "ICD-10 code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnnpa": {"name": "edcnnpa", "description": "ED CNNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnpa": {"name": "edcnpa", "description": "ED CNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "epct": {"name": "epct", "description": "EPCT category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "noner": {"name": "noner", "description": "Non-ER category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "injury": {"name": "injury", "description": "Injury category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "psych": {"name": "psych", "description": "Psych category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alcohol": {"name": "alcohol", "description": "Alcohol category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug": {"name": "drug", "description": "Drug category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','johnston_icd10.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_johnston_icd10", "tags": "ed_classification", "enabled": true, "column_types": {"icd10": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "noner": "varchar(256)", "epct": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.7307396, "relation_name": "dev_thuxuan.ed_classification._value_set_johnston_icd10", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.ed_classification__johnston_icd9": {"database": "dev_thuxuan", "schema": "ed_classification", "name": "ed_classification__johnston_icd9", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\ed_classification\\ed_classification__johnston_icd9.csv", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification__johnston_icd9.csv", "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd9", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "ed_classification__johnston_icd9"], "alias": "_value_set_johnston_icd9", "checksum": {"name": "sha256", "checksum": "77255f5ce0469f045a941b092e3ec84002afb0d3dabfc3d24acb0cfe29d90829"}, "config": {"enabled": true, "alias": "_value_set_johnston_icd9", "schema": "ed_classification", "database": null, "tags": ["ed_classification"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','johnston_icd9.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd9": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "epct": "varchar(256)", "noner": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["ed_classification"], "description": "A probabilistic mapping of ICD-9 codes to ED classification categories", "columns": {"icd9": {"name": "icd9", "description": "ICD-9 code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_9_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnnpa": {"name": "edcnnpa", "description": "ED CNNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "edcnpa": {"name": "edcnpa", "description": "ED CNPA category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "epct": {"name": "epct", "description": "EPCT category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "noner": {"name": "noner", "description": "Non-ER category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "injury": {"name": "injury", "description": "Injury category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "psych": {"name": "psych", "description": "Psych category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "alcohol": {"name": "alcohol", "description": "Alcohol category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "drug": {"name": "drug", "description": "Drug category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','johnston_icd9.csv',compression=true,null_marker=true) }}", "schema": "ed_classification", "alias": "_value_set_johnston_icd9", "tags": "ed_classification", "enabled": true, "column_types": {"icd9": "varchar(256)", "edcnnpa": "varchar(256)", "edcnpa": "varchar(256)", "epct": "varchar(256)", "noner": "varchar(256)", "injury": "varchar(256)", "psych": "varchar(256)", "alcohol": "varchar(256)", "drug": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.7197428, "relation_name": "dev_thuxuan.ed_classification._value_set_johnston_icd9", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.hcc_suspecting__clinical_concepts": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__clinical_concepts", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\hcc_suspecting\\hcc_suspecting__clinical_concepts.csv", "original_file_path": "seeds\\value_sets\\hcc_suspecting\\hcc_suspecting__clinical_concepts.csv", "unique_id": "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "fqn": ["the_tuva_project", "value_sets", "hcc_suspecting", "hcc_suspecting__clinical_concepts"], "alias": "_value_set_clinical_concepts", "checksum": {"name": "sha256", "checksum": "e130e1696ce203c3c7faec7efadfc972c4e7502553190544a2077b4c2817ac75"}, "config": {"enabled": true, "alias": "_value_set_clinical_concepts", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_clinical_concepts.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["hcc_suspecting"], "description": "Value sets for clinical concepts.", "columns": {"concept_name": {"name": "concept_name", "description": "Name of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Code representing the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "Code system used for the code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\hcc_suspecting\\hcc_suspecting_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_clinical_concepts.csv',compression=true,null_marker=true) }}", "schema": "hcc_suspecting", "alias": "_value_set_clinical_concepts", "tags": "hcc_suspecting", "enabled": true, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8340073, "relation_name": "dev_thuxuan.hcc_suspecting._value_set_clinical_concepts", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__hcc_descriptions", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\hcc_suspecting\\hcc_suspecting__hcc_descriptions.csv", "original_file_path": "seeds\\value_sets\\hcc_suspecting\\hcc_suspecting__hcc_descriptions.csv", "unique_id": "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "fqn": ["the_tuva_project", "value_sets", "hcc_suspecting", "hcc_suspecting__hcc_descriptions"], "alias": "_value_set_hcc_descriptions", "checksum": {"name": "sha256", "checksum": "7e7ac940d8a7da977e3e33e93d6690af3d6b36c8791fb14a10f06beb8f3f779f"}, "config": {"enabled": true, "alias": "_value_set_hcc_descriptions", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_descriptions.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"hcc_code": "varchar(256)", "hcc_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["hcc_suspecting"], "description": "Disease factors by model version and risk segment. Extracted from rate announcement documents on cms.gov.\n", "columns": {"hcc_code": {"name": "hcc_code", "description": "Hierarchical Condition Category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "hcc_description": {"name": "hcc_description", "description": "Description of the HCC code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\hcc_suspecting\\hcc_suspecting_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_descriptions.csv',compression=true,null_marker=true) }}", "schema": "hcc_suspecting", "alias": "_value_set_hcc_descriptions", "tags": "hcc_suspecting", "enabled": true, "column_types": {"hcc_code": "varchar(256)", "hcc_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8410077, "relation_name": "dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": {"database": "dev_thuxuan", "schema": "hcc_suspecting", "name": "hcc_suspecting__icd_10_cm_mappings", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\hcc_suspecting\\hcc_suspecting__icd_10_cm_mappings.csv", "original_file_path": "seeds\\value_sets\\hcc_suspecting\\hcc_suspecting__icd_10_cm_mappings.csv", "unique_id": "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings", "fqn": ["the_tuva_project", "value_sets", "hcc_suspecting", "hcc_suspecting__icd_10_cm_mappings"], "alias": "_value_set_icd_10_cm_mappings", "checksum": {"name": "sha256", "checksum": "2d5d504da80762d6e23c1d61b5ba3ad0d50ab964d5dd914af92570aa536104a9"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_mappings", "schema": "hcc_suspecting", "database": null, "tags": ["hcc_suspecting"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"diagnosis_code": "varchar(256)", "cms_hcc_esrd_v21": "varchar(256)", "cms_hcc_esrd_v24": "varchar(256)", "cms_hcc_v22": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v28": "varchar(256)", "rx_hcc_v05": "varchar(256)", "rx_hcc_v08": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["hcc_suspecting"], "description": "ICD-10 to HCC mapping by payment year and model version. Combined and cleaned version of code files on cms.gov.\n", "columns": {"diagnosis_code": {"name": "diagnosis_code", "description": "ICD-10 diagnosis code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_esrd_v21": {"name": "cms_hcc_esrd_v21", "description": "CMS-HCC ESRD version 21 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_esrd_v24": {"name": "cms_hcc_esrd_v24", "description": "CMS-HCC ESRD version 24 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v22": {"name": "cms_hcc_v22", "description": "CMS-HCC version 22 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v24": {"name": "cms_hcc_v24", "description": "CMS-HCC version 24 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "cms_hcc_v28": {"name": "cms_hcc_v28", "description": "CMS-HCC version 28 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rx_hcc_v05": {"name": "rx_hcc_v05", "description": "Rx-HCC version 05 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "rx_hcc_v08": {"name": "rx_hcc_v08", "description": "Rx-HCC version 08 code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\hcc_suspecting\\hcc_suspecting_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','hcc_suspecting_icd_10_cm_mappings.csv',compression=true,null_marker=true) }}", "schema": "hcc_suspecting", "alias": "_value_set_icd_10_cm_mappings", "tags": "hcc_suspecting", "enabled": true, "column_types": {"diagnosis_code": "varchar(256)", "cms_hcc_esrd_v21": "varchar(256)", "cms_hcc_esrd_v24": "varchar(256)", "cms_hcc_v22": "varchar(256)", "cms_hcc_v24": "varchar(256)", "cms_hcc_v28": "varchar(256)", "rx_hcc_v05": "varchar(256)", "rx_hcc_v08": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8520072, "relation_name": "dev_thuxuan.hcc_suspecting._value_set_icd_10_cm_mappings", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.pharmacy__rxnorm_generic_available": {"database": "dev_thuxuan", "schema": "pharmacy", "name": "pharmacy__rxnorm_generic_available", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\pharmacy\\pharmacy__rxnorm_generic_available.csv", "original_file_path": "seeds\\value_sets\\pharmacy\\pharmacy__rxnorm_generic_available.csv", "unique_id": "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "fqn": ["the_tuva_project", "value_sets", "pharmacy", "pharmacy__rxnorm_generic_available"], "alias": "rxnorm_generic_available", "checksum": {"name": "sha256", "checksum": "ba766e1c3ca581e309af4aa0ae15b9f2a6bff5fb116280c6d408e949ebde2f04"}, "config": {"enabled": true, "alias": "rxnorm_generic_available", "schema": "pharmacy", "database": null, "tags": ["pharmacy"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','rxnorm_generic_available.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"product_tty": "varchar(256)", "product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "ndc_product_tty": "varchar(256)", "ndc_product_rxcui": "varchar(256)", "ndc_product_name": "varchar(3000)", "ndc": "varchar(256)", "product_startmarketingdate": "date", "package_startmarketingdate": "date"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["pharmacy"], "description": "brand rxcuis from rxnorm with some additional columns added in", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\pharmacy\\pharmacy__seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','rxnorm_generic_available.csv',compression=true,null_marker=true) }}", "schema": "pharmacy", "alias": "rxnorm_generic_available", "tags": ["pharmacy"], "enabled": true, "column_types": {"product_tty": "varchar(256)", "product_rxcui": "varchar(256)", "product_name": "varchar(3000)", "ndc_product_tty": "varchar(256)", "ndc_product_rxcui": "varchar(256)", "ndc_product_name": "varchar(3000)", "ndc": "varchar(256)", "product_startmarketingdate": "date", "package_startmarketingdate": "date"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8620136, "relation_name": "dev_thuxuan.pharmacy.rxnorm_generic_available", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.quality_measures__concepts": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__concepts", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\quality_measures\\quality_measures__concepts.csv", "original_file_path": "seeds\\value_sets\\quality_measures\\quality_measures__concepts.csv", "unique_id": "seed.the_tuva_project.quality_measures__concepts", "fqn": ["the_tuva_project", "value_sets", "quality_measures", "quality_measures__concepts"], "alias": "_value_set_concepts", "checksum": {"name": "sha256", "checksum": "327c96bdd4582e91ea0c6f7f2b9641eba1e3973dab46402760c175af6e3987a8"}, "config": {"enabled": true, "alias": "_value_set_concepts", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_concepts.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "measure_id": "varchar(256)", "measure_name": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["quality_measures"], "description": "Measures to concepts crosswalk. List of concepts used in each reporting measure.", "columns": {"concept_name": {"name": "concept_name", "description": "Name of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_id": {"name": "measure_id", "description": "Identifier for the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "measure_name": {"name": "measure_name", "description": "Name of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\quality_measures\\quality_measures_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_concepts.csv',compression=true,null_marker=true) }}", "schema": "quality_measures", "alias": "_value_set_concepts", "tags": "quality_measures", "enabled": true, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "measure_id": "varchar(256)", "measure_name": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.87124, "relation_name": "dev_thuxuan.quality_measures._value_set_concepts", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.quality_measures__measures": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__measures", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\quality_measures\\quality_measures__measures.csv", "original_file_path": "seeds\\value_sets\\quality_measures\\quality_measures__measures.csv", "unique_id": "seed.the_tuva_project.quality_measures__measures", "fqn": ["the_tuva_project", "value_sets", "quality_measures", "quality_measures__measures"], "alias": "_value_set_measures", "checksum": {"name": "sha256", "checksum": "ffba1ed18ece6d32fe634f279e2833b355b51c66691ef06db717ee4ebb257992"}, "config": {"enabled": true, "alias": "_value_set_measures", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_measures.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"id": "varchar(256)", "name": "varchar(256)", "description": "varchar(3000)", "version": "varchar(256)", "steward": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["quality_measures"], "description": "Overview of reporting measures.", "columns": {"id": {"name": "id", "description": "Identifier for the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "name": {"name": "name", "description": "Name of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "version": {"name": "version", "description": "Version of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "steward": {"name": "steward", "description": "Steward of the reporting measure", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\quality_measures\\quality_measures_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_measures.csv',compression=true,null_marker=true) }}", "schema": "quality_measures", "alias": "_value_set_measures", "tags": "quality_measures", "enabled": true, "column_types": {"id": "varchar(256)", "name": "varchar(256)", "description": "varchar(3000)", "version": "varchar(256)", "steward": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8812523, "relation_name": "dev_thuxuan.quality_measures._value_set_measures", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.quality_measures__value_sets": {"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__value_sets", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\quality_measures\\quality_measures__value_sets.csv", "original_file_path": "seeds\\value_sets\\quality_measures\\quality_measures__value_sets.csv", "unique_id": "seed.the_tuva_project.quality_measures__value_sets", "fqn": ["the_tuva_project", "value_sets", "quality_measures", "quality_measures__value_sets"], "alias": "_value_set_codes", "checksum": {"name": "sha256", "checksum": "e130e1696ce203c3c7faec7efadfc972c4e7502553190544a2077b4c2817ac75"}, "config": {"enabled": true, "alias": "_value_set_codes", "schema": "quality_measures", "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_value_set_codes.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["quality_measures"], "description": "Concepts to value sets crosswalk. List of codes in each concept.", "columns": {"concept_name": {"name": "concept_name", "description": "Name of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "concept_oid": {"name": "concept_oid", "description": "OID of the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code": {"name": "code", "description": "Code representing the clinical concept", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "code_system": {"name": "code_system", "description": "System used for the code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\quality_measures\\quality_measures_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','quality_measures_value_set_codes.csv',compression=true,null_marker=true) }}", "schema": "quality_measures", "alias": "_value_set_codes", "tags": "quality_measures", "enabled": true, "column_types": {"concept_name": "varchar(256)", "concept_oid": "varchar(256)", "code": "varchar(256)", "code_system": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8912544, "relation_name": "dev_thuxuan.quality_measures._value_set_codes", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__acute_diagnosis_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__acute_diagnosis_ccs.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__acute_diagnosis_ccs.csv", "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_ccs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__acute_diagnosis_ccs"], "alias": "_value_set_acute_diagnosis_ccs", "checksum": {"name": "sha256", "checksum": "e947ff0e7faffc92d8c129ee41271241fb9e43c5f3249f18403fe20faa9be669"}, "config": {"enabled": true, "alias": "_value_set_acute_diagnosis_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','acute_diagnosis_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Acute diagnosis CCS categories for readmissions.", "columns": {"ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','acute_diagnosis_ccs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_acute_diagnosis_ccs", "tags": "readmissions", "enabled": true, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.8992548, "relation_name": "dev_thuxuan.readmissions._value_set_acute_diagnosis_ccs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__acute_diagnosis_icd_10_cm", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__acute_diagnosis_icd_10_cm.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__acute_diagnosis_icd_10_cm.csv", "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__acute_diagnosis_icd_10_cm"], "alias": "_value_set_acute_diagnosis_icd_10_cm", "checksum": {"name": "sha256", "checksum": "08903dd5b951cfdd2dc1e2d92406571ab08c2fa401c2f951a6190b38af1dbf61"}, "config": {"enabled": true, "alias": "_value_set_acute_diagnosis_icd_10_cm", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','acute_diagnosis_icd_10_cm.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Acute diagnosis ICD-10-CM codes for readmissions.", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','acute_diagnosis_icd_10_cm.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_acute_diagnosis_icd_10_cm", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9057646, "relation_name": "dev_thuxuan.readmissions._value_set_acute_diagnosis_icd_10_cm", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__always_planned_ccs_diagnosis_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__always_planned_ccs_diagnosis_category.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__always_planned_ccs_diagnosis_category.csv", "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__always_planned_ccs_diagnosis_category"], "alias": "_value_set_always_planned_ccs_diagnosis_category", "checksum": {"name": "sha256", "checksum": "1bfbe31c1b65d38e97936d54fa477faf6b189e69e7659499bce52ab8e85fa82e"}, "config": {"enabled": true, "alias": "_value_set_always_planned_ccs_diagnosis_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','always_planned_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Always planned CCS diagnosis categories for readmissions.", "columns": {"ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','always_planned_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_always_planned_ccs_diagnosis_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9127643, "relation_name": "dev_thuxuan.readmissions._value_set_always_planned_ccs_diagnosis_category", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__always_planned_ccs_procedure_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__always_planned_ccs_procedure_category.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__always_planned_ccs_procedure_category.csv", "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__always_planned_ccs_procedure_category"], "alias": "_value_set_always_planned_ccs_procedure_category", "checksum": {"name": "sha256", "checksum": "cfb84522da7baa39ff06dd37fbab4677b01ef87969039775a9708f70353a99b3"}, "config": {"enabled": true, "alias": "_value_set_always_planned_ccs_procedure_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','always_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Always planned CCS procedure categories for readmissions.", "columns": {"ccs_procedure_category": {"name": "ccs_procedure_category", "description": "CCS procedure category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS procedure category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','always_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_always_planned_ccs_procedure_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9228642, "relation_name": "dev_thuxuan.readmissions._value_set_always_planned_ccs_procedure_category", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__exclusion_ccs_diagnosis_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__exclusion_ccs_diagnosis_category.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__exclusion_ccs_diagnosis_category.csv", "unique_id": "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__exclusion_ccs_diagnosis_category"], "alias": "_value_set_exclusion_ccs_diagnosis_category", "checksum": {"name": "sha256", "checksum": "ed6c92b04b1d9b79a34ed80022e4192f2394510f57fd0b4121a8e31a30198d70"}, "config": {"enabled": true, "alias": "_value_set_exclusion_ccs_diagnosis_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','exclusion_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)", "exclusion_category": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Exclusion CCS diagnosis categories for readmissions.", "columns": {"ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "exclusion_category": {"name": "exclusion_category", "description": "Exclusion category for the CCS diagnosis", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','exclusion_ccs_diagnosis_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_exclusion_ccs_diagnosis_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_diagnosis_category": "varchar(256)", "description": "varchar(256)", "exclusion_category": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9288094, "relation_name": "dev_thuxuan.readmissions._value_set_exclusion_ccs_diagnosis_category", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__icd_10_cm_to_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__icd_10_cm_to_ccs.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__icd_10_cm_to_ccs.csv", "unique_id": "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__icd_10_cm_to_ccs"], "alias": "_value_set_icd_10_cm_to_ccs", "checksum": {"name": "sha256", "checksum": "0f2119b159a22eeb902b925b2eb98357b33bbc09bae3b7fceb04de71cf041476"}, "config": {"enabled": true, "alias": "_value_set_icd_10_cm_to_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Mapping of ICD-10-CM codes to CCS diagnosis categories for readmissions.", "columns": {"icd_10_cm": {"name": "icd_10_cm", "description": "ICD-10-CM code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_cm.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-CM code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_diagnosis_category": {"name": "ccs_diagnosis_category", "description": "CCS diagnosis category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_description": {"name": "ccs_description", "description": "Description of the CCS diagnosis category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_cm_to_ccs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_icd_10_cm_to_ccs", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_cm": "varchar(256)", "description": "varchar(256)", "ccs_diagnosis_category": "varchar(256)", "ccs_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.935873, "relation_name": "dev_thuxuan.readmissions._value_set_icd_10_cm_to_ccs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__icd_10_pcs_to_ccs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__icd_10_pcs_to_ccs.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__icd_10_pcs_to_ccs.csv", "unique_id": "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__icd_10_pcs_to_ccs"], "alias": "_value_set_icd_10_pcs_to_ccs", "checksum": {"name": "sha256", "checksum": "b152259e1a13057a37cf15ae765f61c7c9559340b5469fa93909ad910929fd0e"}, "config": {"enabled": true, "alias": "_value_set_icd_10_pcs_to_ccs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_pcs_to_ccs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_procedure_category": "varchar(256)", "ccs_description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Mapping of ICD-10-PCS codes to CCS procedure categories for readmissions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_procedure_category": {"name": "ccs_procedure_category", "description": "CCS procedure category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_description": {"name": "ccs_description", "description": "Description of the CCS procedure category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','icd_10_pcs_to_ccs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_icd_10_pcs_to_ccs", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_procedure_category": "varchar(256)", "ccs_description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9438784, "relation_name": "dev_thuxuan.readmissions._value_set_icd_10_pcs_to_ccs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__potentially_planned_ccs_procedure_category", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__potentially_planned_ccs_procedure_category.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__potentially_planned_ccs_procedure_category.csv", "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__potentially_planned_ccs_procedure_category"], "alias": "_value_set_potentially_planned_ccs_procedure_category", "checksum": {"name": "sha256", "checksum": "d46cf571e714e7ddb997c7be419b496c51d9e7ce0342d72be61d06fc0bf55669"}, "config": {"enabled": true, "alias": "_value_set_potentially_planned_ccs_procedure_category", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','potentially_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Potentially planned CCS procedure categories for readmissions.", "columns": {"ccs_procedure_category": {"name": "ccs_procedure_category", "description": "CCS procedure category code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS procedure category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','potentially_planned_ccs_procedure_category.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_potentially_planned_ccs_procedure_category", "tags": "readmissions", "enabled": true, "column_types": {"ccs_procedure_category": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9508536, "relation_name": "dev_thuxuan.readmissions._value_set_potentially_planned_ccs_procedure_category", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__potentially_planned_icd_10_pcs", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__potentially_planned_icd_10_pcs.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__potentially_planned_icd_10_pcs.csv", "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__potentially_planned_icd_10_pcs"], "alias": "_value_set_potentially_planned_icd_10_pcs", "checksum": {"name": "sha256", "checksum": "1d18cafa0d405e60cd1be1e039fbfb2dfa9591a1cef6a441b60c26a61de41ad3"}, "config": {"enabled": true, "alias": "_value_set_potentially_planned_icd_10_pcs", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','potentially_planned_icd_10_pcs.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Potentially planned ICD-10-PCS codes for readmissions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','potentially_planned_icd_10_pcs.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_potentially_planned_icd_10_pcs", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9568503, "relation_name": "dev_thuxuan.readmissions._value_set_potentially_planned_icd_10_pcs", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__specialty_cohort": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__specialty_cohort", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__specialty_cohort.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__specialty_cohort.csv", "unique_id": "seed.the_tuva_project.readmissions__specialty_cohort", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__specialty_cohort"], "alias": "_value_set_specialty_cohort", "checksum": {"name": "sha256", "checksum": "c1d715929a890fd44e1d5ad4aa89785523f221ce8f5ae8765c11a0e524426a45"}, "config": {"enabled": true, "alias": "_value_set_specialty_cohort", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','specialty_cohort.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"ccs": "varchar(256)", "description": "varchar(256)", "specialty_cohort": "varchar(256)", "procedure_or_diagnosis": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Specialty cohorts for readmissions.", "columns": {"ccs": {"name": "ccs", "description": "CCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the CCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "procedure_or_diagnosis": {"name": "procedure_or_diagnosis", "description": "Indicates whether it is a procedure or diagnosis", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','specialty_cohort.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_specialty_cohort", "tags": "readmissions", "enabled": true, "column_types": {"ccs": "varchar(256)", "description": "varchar(256)", "specialty_cohort": "varchar(256)", "procedure_or_diagnosis": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9649374, "relation_name": "dev_thuxuan.readmissions._value_set_specialty_cohort", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": {"database": "dev_thuxuan", "schema": "readmissions", "name": "readmissions__surgery_gynecology_cohort", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\readmissions\\readmissions__surgery_gynecology_cohort.csv", "original_file_path": "seeds\\value_sets\\readmissions\\readmissions__surgery_gynecology_cohort.csv", "unique_id": "seed.the_tuva_project.readmissions__surgery_gynecology_cohort", "fqn": ["the_tuva_project", "value_sets", "readmissions", "readmissions__surgery_gynecology_cohort"], "alias": "_value_set_surgery_gynecology_cohort", "checksum": {"name": "sha256", "checksum": "ba95843249cbc3167b4887251bf4efbecb2418fe086791e2c428d5748b0e4167"}, "config": {"enabled": true, "alias": "_value_set_surgery_gynecology_cohort", "schema": "readmissions", "database": null, "tags": ["readmissions"], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','surgery_gynecology_cohort.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_code_and_description": "varchar(256)", "specialty_cohort": "varchar(256)"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": ["readmissions"], "description": "Surgery and gynecology cohort for readmissions.", "columns": {"icd_10_pcs": {"name": "icd_10_pcs", "description": "ICD-10-PCS code", "meta": {"terminology": "https://github.com/tuva-health/the_tuva_project/blob/main/seeds/terminology/terminology__icd_10_pcs.csv"}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "description": {"name": "description", "description": "Description of the ICD-10-PCS code", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "ccs_code_and_description": {"name": "ccs_code_and_description", "description": "CCS code and description", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "specialty_cohort": {"name": "specialty_cohort", "description": "Specialty cohort category", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\readmissions\\readmissions_seeds.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','surgery_gynecology_cohort.csv',compression=true,null_marker=true) }}", "schema": "readmissions", "alias": "_value_set_surgery_gynecology_cohort", "tags": "readmissions", "enabled": true, "column_types": {"icd_10_pcs": "varchar(256)", "description": "varchar(256)", "ccs_code_and_description": "varchar(256)", "specialty_cohort": "varchar(256)"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.9720366, "relation_name": "dev_thuxuan.readmissions._value_set_surgery_gynecology_cohort", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "seed.the_tuva_project.service_category__service_categories": {"database": "dev_thuxuan", "schema": "claims_preprocessing", "name": "service_category__service_categories", "resource_type": "seed", "package_name": "the_tuva_project", "path": "value_sets\\service_categories\\service_category__service_categories.csv", "original_file_path": "seeds\\value_sets\\service_categories\\service_category__service_categories.csv", "unique_id": "seed.the_tuva_project.service_category__service_categories", "fqn": ["the_tuva_project", "value_sets", "service_categories", "service_category__service_categories"], "alias": "service_category__service_categories", "checksum": {"name": "sha256", "checksum": "5a2d78ef839e5da2ad7a3b17c589b6ca58c5a87ec11340daa84ac5a29c89d9d7"}, "config": {"enabled": true, "alias": null, "schema": "claims_preprocessing", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "seed", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','service_category__service_categories.csv',compression=true,null_marker=true) }}", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {"service_category_1": "varchar(50)", "service_category_2": "varchar(50)", "service_category_3": "varchar(50)", "priority": "integer"}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#cf751b"}, "contract": {"enforced": false, "alias_types": true}, "delimiter": ",", "quote_columns": null}, "tags": [], "description": "Heirarchy and ranking of Tuva service category logic\n", "columns": {"service_category_1": {"name": "service_category_1", "description": "service category 1 in the Tuva model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_2": {"name": "service_category_2", "description": "service category 2 in the Tuva model", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "service_category_3": {"name": "service_category_3", "description": "service category 3 in the Tuva model, only populated for a group of the service category 2 values.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "priority": {"name": "priority", "description": "priority ranking of the service categories that will be used if a claim qualifies under multiple logic.", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#cf751b"}, "patch_path": "the_tuva_project://seeds\\value_sets\\service_categories\\service_category__service_categories.yml", "build_path": null, "unrendered_config": {"post-hook": "{{ load_seed('tuva-public-resources/versioned_value_sets/0.12.2','service_category__service_categories.csv',compression=true,null_marker=true) }}", "schema": "claims_preprocessing", "column_types": {"service_category_1": "varchar(50)", "service_category_2": "varchar(50)", "service_category_3": "varchar(50)", "priority": "integer"}, "docs": {"node_color": "#cf751b"}}, "created_at": 1729866315.979035, "relation_name": "dev_thuxuan.claims_preprocessing.service_category__service_categories", "raw_code": "", "root_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\dbt_packages\\the_tuva_project", "depends_on": {"macros": ["macro.the_tuva_project.load_seed"]}}, "operation.the_tuva_project.the_tuva_project-on-run-end-0": {"database": "dev_thuxuan", "schema": "test", "name": "the_tuva_project-on-run-end-0", "resource_type": "operation", "package_name": "the_tuva_project", "path": "hooks\\the_tuva_project-on-run-end-0.sql", "original_file_path": ".\\dbt_project.yml", "unique_id": "operation.the_tuva_project.the_tuva_project-on-run-end-0", "fqn": ["the_tuva_project", "hooks", "the_tuva_project-on-run-end-0"], "alias": "the_tuva_project-on-run-end-0", "checksum": {"name": "sha256", "checksum": "37fb25ce0cf6688b363698c57603ab8dae95154c5fddb2424976b4c746c1c525"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "bind": false}, "tags": ["on-run-end"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": null, "build_path": null, "unrendered_config": {"bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866314.6526158, "relation_name": null, "raw_code": "{{ log_warning_for_seeds() }}", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.the_tuva_project.log_warning_for_seeds"], "nodes": []}, "compiled_path": "target\\compiled\\the_tuva_project\\.\\dbt_project.yml\\hooks\\the_tuva_project-on-run-end-0.sql", "compiled": true, "compiled_code": "\n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "index": 0}, "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_ed_classification__johnston_icd9_icd9", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_ed_classification__johnston_icd9_icd9.sql", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "unique_ed_classification__johnston_icd9_icd9"], "alias": "unique_ed_classification__johnston_icd9_icd9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866315.821007, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd9", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd9"]}, "compiled_path": "target\\compiled\\the_tuva_project\\seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml\\unique_ed_classification__johnston_icd9_icd9.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd9 as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd9\nwhere icd9 is not null\ngroup by icd9\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd9", "file_key_name": "seeds.ed_classification__johnston_icd9", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd9", "test_metadata": {"name": "unique", "kwargs": {"column_name": "icd9", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd9')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_ed_classification__johnston_icd9_icd9", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_ed_classification__johnston_icd9_icd9.sql", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "not_null_ed_classification__johnston_icd9_icd9"], "alias": "not_null_ed_classification__johnston_icd9_icd9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866315.8230076, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd9", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd9"]}, "compiled_path": "target\\compiled\\the_tuva_project\\seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml\\not_null_ed_classification__johnston_icd9_icd9.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd9\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd9\nwhere icd9 is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd9", "file_key_name": "seeds.ed_classification__johnston_icd9", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd9", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "icd9", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd9')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_ed_classification__johnston_icd10_icd10", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_ed_classification__johnston_icd10_icd10.sql", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "unique_ed_classification__johnston_icd10_icd10"], "alias": "unique_ed_classification__johnston_icd10_icd10", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866315.8240068, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd10", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd10"]}, "compiled_path": "target\\compiled\\the_tuva_project\\seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml\\unique_ed_classification__johnston_icd10_icd10.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd10 as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd10\nwhere icd10 is not null\ngroup by icd10\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd10", "file_key_name": "seeds.ed_classification__johnston_icd10", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd10", "test_metadata": {"name": "unique", "kwargs": {"column_name": "icd10", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd10')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_ed_classification__johnston_icd10_icd10", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_ed_classification__johnston_icd10_icd10.sql", "original_file_path": "seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml", "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7", "fqn": ["the_tuva_project", "value_sets", "ed_classification", "not_null_ed_classification__johnston_icd10_icd10"], "alias": "not_null_ed_classification__johnston_icd10_icd10", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866315.8250072, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "ed_classification__johnston_icd10", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["seed.the_tuva_project.ed_classification__johnston_icd10"]}, "compiled_path": "target\\compiled\\the_tuva_project\\seeds\\value_sets\\ed_classification\\ed_classification_seeds.yml\\not_null_ed_classification__johnston_icd10_icd10.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd10\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd10\nwhere icd10 is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "icd10", "file_key_name": "seeds.ed_classification__johnston_icd10", "attached_node": "seed.the_tuva_project.ed_classification__johnston_icd10", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "icd10", "model": "{{ get_where_subquery(ref('ed_classification__johnston_icd10')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_chronic_conditions__cms_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586", "fqn": ["the_tuva_project", "chronic_conditions", "unique_chronic_conditions__cms_chronic_conditions_wide_patient_id"], "alias": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2"}, "created_at": 1729866316.1456728, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\unique_chronic_conditions__cms_dd279730922ed20d9a6785adad24b5e2.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id"], "alias": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c"}, "created_at": 1729866316.1466794, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_acd55fa202206ca2dac1594f14fc377c.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_long_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_long_patient_id"], "alias": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53"}, "created_at": 1729866316.1476724, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_49a2bb666f68dc10cb37814113581b53.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_long_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_long_claim_id"], "alias": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4"}, "created_at": 1729866316.1486726, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_6cb109fc60fe56040c1e9a18e4e77fd4.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_long_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_long_condition"], "alias": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf"}, "created_at": 1729866316.1496725, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_9ae72d56fe6849d0aacc73d604c5b0cf.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d", "fqn": ["the_tuva_project", "chronic_conditions", "dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition"], "alias": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3"}, "created_at": 1729866316.1516724, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\dbt_utils_unique_combination_o_989a382b308177b1acfdb170d27c2aa3.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, claim_id, start_date, condition\n from dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\n group by patient_id, claim_id, start_date, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__cms_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "claim_id", "start_date", "condition"], "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_long')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_all_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_all_patient_id"], "alias": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c"}, "created_at": 1729866316.1676724, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_409ab6a82d1b97c996f87af7f330605c.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_all", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_all')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_all_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_all_claim_id"], "alias": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9"}, "created_at": 1729866316.1686723, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_b541fb9d33a4f06d5fea55b9a24aa3a9.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_all", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_all')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_all_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_all_condition"], "alias": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c"}, "created_at": 1729866316.1703477, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_all", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_c4a0f280255574fa8bab0a3d8629b09c.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_all", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_all')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id"], "alias": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d"}, "created_at": 1729866316.1714485, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_6da0dbac3eab9746301bed2ab3f2d52d.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id"], "alias": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827"}, "created_at": 1729866316.1734781, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_075c29078cdfc99a6fe124f31746e827.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition"], "alias": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785"}, "created_at": 1729866316.174453, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_52f5eb486d06b1bc6c4a979fe5d64785.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_", "resource_type": "test", "package_name": "the_tuva_project", "path": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6", "fqn": ["the_tuva_project", "chronic_conditions", "accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_"], "alias": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f"}, "created_at": 1729866316.1754694, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_hiv_aids", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\accepted_values_chronic_condit_dac30732a31f8623801cc82d686e9e8f.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_hiv_aids", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "test_metadata": {"name": "accepted_values", "kwargs": {"values": ["Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)"], "column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_hiv_aids')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id"], "alias": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741"}, "created_at": 1729866316.1814692, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_9bc0b8199dada8f26dfa51bc604f3741.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id"], "alias": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e"}, "created_at": 1729866316.1824696, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_e8858b22e3298bb06dc366c69d72845e.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\nwhere claim_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "claim_id", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "claim_id", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__cms_chronic_conditions_oud_condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__cms_chronic_conditions_oud_condition"], "alias": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4"}, "created_at": 1729866316.1834693, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\not_null_chronic_conditions__c_e1503323470a6f1632ee17ce36ebfdf4.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\nwhere condition is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_", "resource_type": "test", "package_name": "the_tuva_project", "path": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e.sql", "original_file_path": "models\\chronic_conditions\\cms_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5", "fqn": ["the_tuva_project", "chronic_conditions", "accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_"], "alias": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e"}, "created_at": 1729866316.185457, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__cms_chronic_conditions_oud", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\cms_chronic_conditions_models.yml\\accepted_values_chronic_condit_e9f47fcdb123676b8c14e66963fb2f9e.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Opioid Use Disorder (OUD)'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition", "file_key_name": "models.chronic_conditions__cms_chronic_conditions_oud", "attached_node": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test_metadata": {"name": "accepted_values", "kwargs": {"values": ["Opioid Use Disorder (OUD)"], "column_name": "condition", "model": "{{ get_where_subquery(ref('chronic_conditions__cms_chronic_conditions_oud')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c.sql", "original_file_path": "models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2", "fqn": ["the_tuva_project", "chronic_conditions", "dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition"], "alias": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c"}, "created_at": 1729866316.206979, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\tuva_chronic_conditions_models.yml\\dbt_utils_unique_combination_o_6892ce9349455e87eb91af29eb11bb7c.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, condition\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n group by patient_id, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__tuva_chronic_conditions_long", "attached_node": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "condition"], "model": "{{ get_where_subquery(ref('chronic_conditions__tuva_chronic_conditions_long')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550.sql", "original_file_path": "models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158", "fqn": ["the_tuva_project", "chronic_conditions", "unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id"], "alias": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550"}, "created_at": 1729866316.209979, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\tuva_chronic_conditions_models.yml\\unique_chronic_conditions__tuv_f6c9876f5d8c62c8b1b037d28f2c9550.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__tuva_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__tuva_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4.sql", "original_file_path": "models\\chronic_conditions\\tuva_chronic_conditions_models.yml", "unique_id": "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561", "fqn": ["the_tuva_project", "chronic_conditions", "not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id"], "alias": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4"}, "created_at": 1729866316.2109792, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4\") }}", "language": "sql", "refs": [{"name": "chronic_conditions__tuva_chronic_conditions_wide", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\chronic_conditions\\tuva_chronic_conditions_models.yml\\not_null_chronic_conditions__t_85a7e6e4e3c122035b615b501d74cac4.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.chronic_conditions__tuva_chronic_conditions_wide", "attached_node": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('chronic_conditions__tuva_chronic_conditions_wide')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df.sql", "original_file_path": "models\\claims_preprocessing\\claims_preprocessing_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d", "fqn": ["the_tuva_project", "claims_preprocessing", "dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number"], "alias": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df"}, "created_at": 1729866316.3047018, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df\") }}", "language": "sql", "refs": [{"name": "normalized_input__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.normalized_input__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\claims_preprocessing\\claims_preprocessing_models.yml\\dbt_utils_unique_combination_o_d06a302654eec5ea947349d98b39a3df.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n claim_id, claim_line_number\n from dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\n group by claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.normalized_input__medical_claim", "attached_node": "model.the_tuva_project.normalized_input__medical_claim", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["claim_id", "claim_line_number"], "model": "{{ get_where_subquery(ref('normalized_input__medical_claim')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_cms_hcc__patient_risk_scores_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_cms_hcc__patient_risk_scores_patient_id.sql", "original_file_path": "models\\cms_hcc\\cms_hcc_models.yml", "unique_id": "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126", "fqn": ["the_tuva_project", "cms_hcc", "unique_cms_hcc__patient_risk_scores_patient_id"], "alias": "unique_cms_hcc__patient_risk_scores_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866316.8066413, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__patient_risk_scores"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\cms_hcc_models.yml\\unique_cms_hcc__patient_risk_scores_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.cms_hcc.patient_risk_scores\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.cms_hcc__patient_risk_scores", "attached_node": "model.the_tuva_project.cms_hcc__patient_risk_scores", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('cms_hcc__patient_risk_scores')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d.sql", "original_file_path": "models\\cms_hcc\\cms_hcc_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba", "fqn": ["the_tuva_project", "cms_hcc", "dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version"], "alias": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d"}, "created_at": 1729866316.8076413, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d\") }}", "language": "sql", "refs": [{"name": "cms_hcc__int_demographic_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_demographic_factors"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\cms_hcc_models.yml\\dbt_utils_unique_combination_o_e734e3737c475bb785f0079a5739630d.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, model_version\n from dev_thuxuan.cms_hcc._int_demographic_factors\n group by patient_id, model_version\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.cms_hcc__int_demographic_factors", "attached_node": "model.the_tuva_project.cms_hcc__int_demographic_factors", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "model_version"], "model": "{{ get_where_subquery(ref('cms_hcc__int_demographic_factors')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_cms_hcc__int_eligible_conditions_condition_code", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_cms_hcc__int_eligible_conditions_condition_code.sql", "original_file_path": "models\\cms_hcc\\cms_hcc_models.yml", "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc", "fqn": ["the_tuva_project", "cms_hcc", "not_null_cms_hcc__int_eligible_conditions_condition_code"], "alias": "not_null_cms_hcc__int_eligible_conditions_condition_code", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866316.8106418, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__int_eligible_conditions", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\cms_hcc_models.yml\\not_null_cms_hcc__int_eligible_conditions_condition_code.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition_code\nfrom dev_thuxuan.cms_hcc._int_eligible_conditions\nwhere condition_code is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition_code", "file_key_name": "models.cms_hcc__int_eligible_conditions", "attached_node": "model.the_tuva_project.cms_hcc__int_eligible_conditions", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "condition_code", "model": "{{ get_where_subquery(ref('cms_hcc__int_eligible_conditions')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_cms_hcc__int_members_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_cms_hcc__int_members_patient_id.sql", "original_file_path": "models\\cms_hcc\\cms_hcc_models.yml", "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b", "fqn": ["the_tuva_project", "cms_hcc", "not_null_cms_hcc__int_members_patient_id"], "alias": "not_null_cms_hcc__int_members_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866316.811641, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__int_members", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_members"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\cms_hcc_models.yml\\not_null_cms_hcc__int_members_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.cms_hcc._int_members\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.cms_hcc__int_members", "attached_node": "model.the_tuva_project.cms_hcc__int_members", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('cms_hcc__int_members')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_cms_hcc__int_members_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_cms_hcc__int_members_patient_id.sql", "original_file_path": "models\\cms_hcc\\cms_hcc_models.yml", "unique_id": "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb", "fqn": ["the_tuva_project", "cms_hcc", "unique_cms_hcc__int_members_patient_id"], "alias": "unique_cms_hcc__int_members_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866316.8126414, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "cms_hcc__int_members", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.cms_hcc__int_members"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\cms_hcc\\cms_hcc_models.yml\\unique_cms_hcc__int_members_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.cms_hcc._int_members\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.cms_hcc__int_members", "attached_node": "model.the_tuva_project.cms_hcc__int_members", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('cms_hcc__int_members')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__condition_condition_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__condition_condition_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0", "fqn": ["the_tuva_project", "core", "unique_core__condition_condition_id"], "alias": "unique_core__condition_condition_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.976517, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__condition_condition_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n condition_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.condition\nwhere condition_id is not null\ngroup by condition_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "condition_id", "file_key_name": "models.core__condition", "attached_node": "model.the_tuva_project.core__condition", "test_metadata": {"name": "unique", "kwargs": {"column_name": "condition_id", "model": "{{ get_where_subquery(ref('core__condition')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__eligibility_eligibility_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__eligibility_eligibility_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a", "fqn": ["the_tuva_project", "core", "unique_core__eligibility_eligibility_id"], "alias": "unique_core__eligibility_eligibility_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9775162, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__eligibility", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__eligibility"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__eligibility_eligibility_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n eligibility_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.eligibility\nwhere eligibility_id is not null\ngroup by eligibility_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "eligibility_id", "file_key_name": "models.core__eligibility", "attached_node": "model.the_tuva_project.core__eligibility", "test_metadata": {"name": "unique", "kwargs": {"column_name": "eligibility_id", "model": "{{ get_where_subquery(ref('core__eligibility')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__encounter_encounter_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__encounter_encounter_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792", "fqn": ["the_tuva_project", "core", "unique_core__encounter_encounter_id"], "alias": "unique_core__encounter_encounter_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1729866316.9785159, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__encounter_encounter_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n encounter_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.encounter\nwhere encounter_id is not null\ngroup by encounter_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "encounter_id", "file_key_name": "models.core__encounter", "attached_node": "model.the_tuva_project.core__encounter", "test_metadata": {"name": "unique", "kwargs": {"column_name": "encounter_id", "model": "{{ get_where_subquery(ref('core__encounter')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__lab_result_lab_result_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__lab_result_lab_result_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af", "fqn": ["the_tuva_project", "core", "unique_core__lab_result_lab_result_id"], "alias": "unique_core__lab_result_lab_result_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9795165, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__lab_result"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__lab_result_lab_result_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n lab_result_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.lab_result\nwhere lab_result_id is not null\ngroup by lab_result_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "lab_result_id", "file_key_name": "models.core__lab_result", "attached_node": "model.the_tuva_project.core__lab_result", "test_metadata": {"name": "unique", "kwargs": {"column_name": "lab_result_id", "model": "{{ get_where_subquery(ref('core__lab_result')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__location_location_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__location_location_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a", "fqn": ["the_tuva_project", "core", "unique_core__location_location_id"], "alias": "unique_core__location_location_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9815164, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__location", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__location"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__location_location_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n location_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.location\nwhere location_id is not null\ngroup by location_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "location_id", "file_key_name": "models.core__location", "attached_node": "model.the_tuva_project.core__location", "test_metadata": {"name": "unique", "kwargs": {"column_name": "location_id", "model": "{{ get_where_subquery(ref('core__location')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__medical_claim_medical_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__medical_claim_medical_claim_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708", "fqn": ["the_tuva_project", "core", "unique_core__medical_claim_medical_claim_id"], "alias": "unique_core__medical_claim_medical_claim_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "ERROR"}, "created_at": 1729866316.9825165, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"error\") }}", "language": "sql", "refs": [{"name": "core__medical_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__medical_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__medical_claim_medical_claim_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n medical_claim_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.medical_claim\nwhere medical_claim_id is not null\ngroup by medical_claim_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "medical_claim_id", "file_key_name": "models.core__medical_claim", "attached_node": "model.the_tuva_project.core__medical_claim", "test_metadata": {"name": "unique", "kwargs": {"column_name": "medical_claim_id", "model": "{{ get_where_subquery(ref('core__medical_claim')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__medication_medication_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__medication_medication_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1", "fqn": ["the_tuva_project", "core", "unique_core__medication_medication_id"], "alias": "unique_core__medication_medication_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9835174, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__medication_medication_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n medication_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.medication\nwhere medication_id is not null\ngroup by medication_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "medication_id", "file_key_name": "models.core__medication", "attached_node": "model.the_tuva_project.core__medication", "test_metadata": {"name": "unique", "kwargs": {"column_name": "medication_id", "model": "{{ get_where_subquery(ref('core__medication')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__observation_observation_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__observation_observation_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59", "fqn": ["the_tuva_project", "core", "unique_core__observation_observation_id"], "alias": "unique_core__observation_observation_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9855223, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__observation_observation_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n observation_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.observation\nwhere observation_id is not null\ngroup by observation_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "observation_id", "file_key_name": "models.core__observation", "attached_node": "model.the_tuva_project.core__observation", "test_metadata": {"name": "unique", "kwargs": {"column_name": "observation_id", "model": "{{ get_where_subquery(ref('core__observation')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__patient_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__patient_patient_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e", "fqn": ["the_tuva_project", "core", "unique_core__patient_patient_id"], "alias": "unique_core__patient_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "ERROR"}, "created_at": 1729866316.986517, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"error\") }}", "language": "sql", "refs": [{"name": "core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__patient_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.patient\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.core__patient", "attached_node": "model.the_tuva_project.core__patient", "test_metadata": {"name": "unique", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__pharmacy_claim_pharmacy_claim_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__pharmacy_claim_pharmacy_claim_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c", "fqn": ["the_tuva_project", "core", "unique_core__pharmacy_claim_pharmacy_claim_id"], "alias": "unique_core__pharmacy_claim_pharmacy_claim_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "ERROR"}, "created_at": 1729866316.9875197, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"error\") }}", "language": "sql", "refs": [{"name": "core__pharmacy_claim", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__pharmacy_claim"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__pharmacy_claim_pharmacy_claim_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n pharmacy_claim_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.pharmacy_claim\nwhere pharmacy_claim_id is not null\ngroup by pharmacy_claim_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "pharmacy_claim_id", "file_key_name": "models.core__pharmacy_claim", "attached_node": "model.the_tuva_project.core__pharmacy_claim", "test_metadata": {"name": "unique", "kwargs": {"column_name": "pharmacy_claim_id", "model": "{{ get_where_subquery(ref('core__pharmacy_claim')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__practitioner_practitioner_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__practitioner_practitioner_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6", "fqn": ["the_tuva_project", "core", "unique_core__practitioner_practitioner_id"], "alias": "unique_core__practitioner_practitioner_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9885166, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__practitioner", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__practitioner"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__practitioner_practitioner_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n practitioner_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.practitioner\nwhere practitioner_id is not null\ngroup by practitioner_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "practitioner_id", "file_key_name": "models.core__practitioner", "attached_node": "model.the_tuva_project.core__practitioner", "test_metadata": {"name": "unique", "kwargs": {"column_name": "practitioner_id", "model": "{{ get_where_subquery(ref('core__practitioner')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_core__procedure_procedure_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_core__procedure_procedure_id.sql", "original_file_path": "models\\core\\core_models.yml", "unique_id": "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5", "fqn": ["the_tuva_project", "core", "unique_core__procedure_procedure_id"], "alias": "unique_core__procedure_procedure_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866316.9895163, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\core\\core_models.yml\\unique_core__procedure_procedure_id.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n procedure_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.procedure\nwhere procedure_id is not null\ngroup by procedure_id\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "procedure_id", "file_key_name": "models.core__procedure", "attached_node": "model.the_tuva_project.core__procedure", "test_metadata": {"name": "unique", "kwargs": {"column_name": "procedure_id", "model": "{{ get_where_subquery(ref('core__procedure')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_data_quality__data_quality_test_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0.sql", "original_file_path": "models\\data_quality\\data_quality_models.yml", "unique_id": "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98", "fqn": ["the_tuva_project", "data_quality", "unique_data_quality__data_quality_test_summary_data_quality_check"], "alias": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0"}, "created_at": 1729866317.105557, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0\") }}", "language": "sql", "refs": [{"name": "data_quality__data_quality_test_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__data_quality_test_summary"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\data_quality_models.yml\\unique_data_quality__data_qual_30883fe6a968be145ea02c17aaace9b0.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.data_quality.data_quality_test_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__data_quality_test_summary", "attached_node": "model.the_tuva_project.data_quality__data_quality_test_summary", "test_metadata": {"name": "unique", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__data_quality_test_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_data_quality__data_quality_test_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670.sql", "original_file_path": "models\\data_quality\\data_quality_models.yml", "unique_id": "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084", "fqn": ["the_tuva_project", "data_quality", "not_null_data_quality__data_quality_test_summary_data_quality_check"], "alias": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670"}, "created_at": 1729866317.1065626, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670\") }}", "language": "sql", "refs": [{"name": "data_quality__data_quality_test_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__data_quality_test_summary"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\data_quality_models.yml\\not_null_data_quality__data_qu_37c9affe595690ac51e8d23cc5428670.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom dev_thuxuan.data_quality.data_quality_test_summary\nwhere data_quality_check is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__data_quality_test_summary", "attached_node": "model.the_tuva_project.data_quality__data_quality_test_summary", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__data_quality_test_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "unique_data_quality__analytics_checks_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a.sql", "original_file_path": "models\\data_quality\\data_quality_models.yml", "unique_id": "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0", "fqn": ["the_tuva_project", "data_quality", "unique_data_quality__analytics_checks_summary_data_quality_check"], "alias": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a"}, "created_at": 1729866317.1085625, "relation_name": null, "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}{{ config(alias=\"unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a\") }}", "language": "sql", "refs": [{"name": "data_quality__analytics_checks_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_unique", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__analytics_checks_summary"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\data_quality_models.yml\\unique_data_quality__analytics_a17d07208f2fdc558e6a6eb2d933c63a.sql", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.data_quality.analytics_checks_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__analytics_checks_summary", "attached_node": "model.the_tuva_project.data_quality__analytics_checks_summary", "test_metadata": {"name": "unique", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__analytics_checks_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_data_quality__analytics_checks_summary_data_quality_check", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a.sql", "original_file_path": "models\\data_quality\\data_quality_models.yml", "unique_id": "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a", "fqn": ["the_tuva_project", "data_quality", "not_null_data_quality__analytics_checks_summary_data_quality_check"], "alias": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a"}, "created_at": 1729866317.1095624, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(alias=\"not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a\") }}", "language": "sql", "refs": [{"name": "data_quality__analytics_checks_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.data_quality__analytics_checks_summary"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\data_quality\\data_quality_models.yml\\not_null_data_quality__analyti_1c15944946e44a5b0d1b4995074bde0a.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom dev_thuxuan.data_quality.analytics_checks_summary\nwhere data_quality_check is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "data_quality_check", "file_key_name": "models.data_quality__analytics_checks_summary", "attached_node": "model.the_tuva_project.data_quality__analytics_checks_summary", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "data_quality_check", "model": "{{ get_where_subquery(ref('data_quality__analytics_checks_summary')) }}"}, "namespace": null}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd.sql", "original_file_path": "models\\financial_pmpm\\financial_pmpm_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23", "fqn": ["the_tuva_project", "financial_pmpm", "dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_"], "alias": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd"}, "created_at": 1729866317.8666515, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd\") }}", "language": "sql", "refs": [{"name": "financial_pmpm__pmpm_prep", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery", "macro.the_tuva_project.quote_column"], "nodes": ["model.the_tuva_project.financial_pmpm__pmpm_prep"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\financial_pmpm\\financial_pmpm_models.yml\\dbt_utils_unique_combination_o_1fd9ac4bec455dc82047e90790301ccd.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, year_month, plan\n from dev_thuxuan.financial_pmpm.pmpm_prep\n group by patient_id, year_month, plan\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.financial_pmpm__pmpm_prep", "attached_node": "model.the_tuva_project.financial_pmpm__pmpm_prep", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["patient_id", "year_month", "{{ quote_column('plan') }}"], "model": "{{ get_where_subquery(ref('financial_pmpm__pmpm_prep')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33.sql", "original_file_path": "models\\pharmacy\\pharmacy_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7", "fqn": ["the_tuva_project", "pharmacy", "dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number"], "alias": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33"}, "created_at": 1729866317.9736047, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33\") }}", "language": "sql", "refs": [{"name": "pharmacy__brand_generic_opportunity", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.pharmacy__brand_generic_opportunity"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\pharmacy_models.yml\\dbt_utils_unique_combination_o_4a499048d1584ce7a05c125602321e33.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from dev_thuxuan.pharmacy.brand_generic_opportunity\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.pharmacy__brand_generic_opportunity", "attached_node": "model.the_tuva_project.pharmacy__brand_generic_opportunity", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["data_source", "claim_id", "claim_line_number"], "model": "{{ get_where_subquery(ref('pharmacy__brand_generic_opportunity')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd.sql", "original_file_path": "models\\pharmacy\\pharmacy_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42", "fqn": ["the_tuva_project", "pharmacy", "dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc"], "alias": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd"}, "created_at": 1729866317.9766047, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd\") }}", "language": "sql", "refs": [{"name": "pharmacy__generic_available_list", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.pharmacy__generic_available_list"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\pharmacy_models.yml\\dbt_utils_unique_combination_o_7038f36c1d4d0d59e2997dbb19b52fdd.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n generic_available_sk, generic_ndc\n from dev_thuxuan.pharmacy.generic_available_list\n group by generic_available_sk, generic_ndc\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.pharmacy__generic_available_list", "attached_node": "model.the_tuva_project.pharmacy__generic_available_list", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["generic_available_sk", "generic_ndc"], "model": "{{ get_where_subquery(ref('pharmacy__generic_available_list')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number", "resource_type": "test", "package_name": "the_tuva_project", "path": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91.sql", "original_file_path": "models\\pharmacy\\pharmacy_models.yml", "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59", "fqn": ["the_tuva_project", "pharmacy", "dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number"], "alias": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"alias": "dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91"}, "created_at": 1729866317.9796047, "relation_name": null, "raw_code": "{{ dbt_utils.test_unique_combination_of_columns(**_dbt_generic_test_kwargs) }}{{ config(alias=\"dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91\") }}", "language": "sql", "refs": [{"name": "pharmacy__pharmacy_claim_expanded", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\pharmacy\\pharmacy_models.yml\\dbt_utils_unique_combination_o_256dbfff545d7e46e717a6aa4a982f91.sql", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from dev_thuxuan.pharmacy.pharmacy_claim_expanded\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": null, "file_key_name": "models.pharmacy__pharmacy_claim_expanded", "attached_node": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["data_source", "claim_id", "claim_line_number"], "model": "{{ get_where_subquery(ref('pharmacy__pharmacy_claim_expanded')) }}"}, "namespace": "dbt_utils"}}, "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__condition_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__condition_patient_id.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__condition_patient_id"], "alias": "not_null_quality_measures__stg_core__condition_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2413242, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__condition"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__condition_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n) select patient_id\nfrom __dbt__cte___stg_condition\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__condition", "sql": " __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__condition", "attached_node": "model.the_tuva_project.quality_measures__stg_core__condition", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__condition')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__encounter_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__encounter_patient_id.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__encounter_patient_id"], "alias": "not_null_quality_measures__stg_core__encounter_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2433245, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__encounter", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__encounter"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__encounter_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n) select patient_id\nfrom __dbt__cte___stg_encounter\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__encounter", "sql": " __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__encounter", "attached_node": "model.the_tuva_project.quality_measures__stg_core__encounter", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__encounter')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__medication_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__medication_patient_id.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__medication_patient_id"], "alias": "not_null_quality_measures__stg_core__medication_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2443244, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__medication"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__medication_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n) select patient_id\nfrom __dbt__cte___stg_medication\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__medication", "sql": " __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__medication", "attached_node": "model.the_tuva_project.quality_measures__stg_core__medication", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__medication')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__observation_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__observation_patient_id.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__observation_patient_id"], "alias": "not_null_quality_measures__stg_core__observation_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2453244, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__observation"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__observation_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n) select patient_id\nfrom __dbt__cte___stg_observation\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__observation", "sql": " __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__observation", "attached_node": "model.the_tuva_project.quality_measures__stg_core__observation", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__observation')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__patient_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__patient_patient_id.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__patient_patient_id"], "alias": "not_null_quality_measures__stg_core__patient_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2463243, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__patient_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n) select patient_id\nfrom __dbt__cte___stg_patient\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__patient_sex", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__patient_sex.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__patient_sex"], "alias": "not_null_quality_measures__stg_core__patient_sex", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2473245, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__patient_sex.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n) select sex\nfrom __dbt__cte___stg_patient\nwhere sex is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "sex", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "sex", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown", "resource_type": "test", "package_name": "the_tuva_project", "path": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b", "fqn": ["the_tuva_project", "quality_measures", "accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown"], "alias": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "warn", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "warn", "alias": "accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae"}, "created_at": 1729866318.2483244, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\",alias=\"accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\accepted_values_quality_measur_afa1e7d743ee8876cacdbc7a17f0b0ae.sql", "compiled": true, "compiled_code": "\n \n \n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), all_values as (\n\n select\n sex as value_field,\n count(*) as n_records\n\n from __dbt__cte___stg_patient\n group by sex\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'female','male','unknown'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "sex", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "accepted_values", "kwargs": {"values": ["female", "male", "unknown"], "column_name": "sex", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__patient_birth_date", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__patient_birth_date.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__patient_birth_date"], "alias": "not_null_quality_measures__stg_core__patient_birth_date", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2523277, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__patient", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__patient"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__patient_birth_date.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n) select birth_date\nfrom __dbt__cte___stg_patient\nwhere birth_date is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__patient", "sql": " __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "birth_date", "file_key_name": "models.quality_measures__stg_core__patient", "attached_node": "model.the_tuva_project.quality_measures__stg_core__patient", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "birth_date", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__patient')) }}"}, "namespace": null}}, "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9": {"database": "dev_thuxuan", "schema": "dbt_test__audit", "name": "not_null_quality_measures__stg_core__procedure_patient_id", "resource_type": "test", "package_name": "the_tuva_project", "path": "not_null_quality_measures__stg_core__procedure_patient_id.sql", "original_file_path": "models\\quality_measures\\quality_measures_models.yml", "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9", "fqn": ["the_tuva_project", "quality_measures", "not_null_quality_measures__stg_core__procedure_patient_id"], "alias": "not_null_quality_measures__stg_core__procedure_patient_id", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "WARN", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {"severity": "WARN"}, "created_at": 1729866318.2533245, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}{{ config(severity=\"warn\") }}", "language": "sql", "refs": [{"name": "quality_measures__stg_core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.the_tuva_project.quality_measures__stg_core__procedure"]}, "compiled_path": "target\\compiled\\the_tuva_project\\models\\quality_measures\\quality_measures_models.yml\\not_null_quality_measures__stg_core__procedure_patient_id.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n) select patient_id\nfrom __dbt__cte___stg_procedure\nwhere patient_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [{"id": "model.the_tuva_project.quality_measures__stg_core__procedure", "sql": " __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n)"}], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "patient_id", "file_key_name": "models.quality_measures__stg_core__procedure", "attached_node": "model.the_tuva_project.quality_measures__stg_core__procedure", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "patient_id", "model": "{{ get_where_subquery(ref('quality_measures__stg_core__procedure')) }}"}, "namespace": null}}}, "sources": {}, "macros": {"macro.input_layer.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\generate_schema_name.sql", "original_file_path": "../macros\\generate_schema_name.sql", "unique_id": "macro.input_layer.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\r\n {%- set default_schema = target.schema -%}\r\n {%- if custom_schema_name is not none -%}\r\n {{ custom_schema_name | trim }}\r\n {%- else -%}\r\n {{ default_schema }}\r\n {%- endif -%}\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1229575, "supported_languages": null}, "macro.input_layer.try_to_cast_date": {"name": "try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\try_to_cast_date.sql", "original_file_path": "../macros\\try_to_cast_date.sql", "unique_id": "macro.input_layer.try_to_cast_date", "macro_sql": "\r\n\r\n{%- macro try_to_cast_date(column_name, date_format='YYYY-MM-DD') -%}\r\n\r\n {{ return(adapter.dispatch('try_to_cast_date')(column_name, date_format)) }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.input_layer.snowflake__try_to_cast_date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1269867, "supported_languages": null}, "macro.input_layer.bigquery__try_to_cast_date": {"name": "bigquery__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\try_to_cast_date.sql", "original_file_path": "../macros\\try_to_cast_date.sql", "unique_id": "macro.input_layer.bigquery__try_to_cast_date", "macro_sql": "{%- macro bigquery__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n safe_cast( date( {{ column_name }} ) as date )\r\n {%- else -%}\r\n safe_cast( {{ column_name }} as date )\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1269867, "supported_languages": null}, "macro.input_layer.default__try_to_cast_date": {"name": "default__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\try_to_cast_date.sql", "original_file_path": "../macros\\try_to_cast_date.sql", "unique_id": "macro.input_layer.default__try_to_cast_date", "macro_sql": "{%- macro default__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1269867, "supported_languages": null}, "macro.input_layer.postgres__try_to_cast_date": {"name": "postgres__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\try_to_cast_date.sql", "original_file_path": "../macros\\try_to_cast_date.sql", "unique_id": "macro.input_layer.postgres__try_to_cast_date", "macro_sql": "{%- macro postgres__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {{ dbt.safe_cast(column_name, api.Column.translate_type(\"date\")).strip() }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1279485, "supported_languages": null}, "macro.input_layer.redshift__try_to_cast_date": {"name": "redshift__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\try_to_cast_date.sql", "original_file_path": "../macros\\try_to_cast_date.sql", "unique_id": "macro.input_layer.redshift__try_to_cast_date", "macro_sql": "{%- macro redshift__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYYMMDD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}\\\\d{2}\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYYMMDD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'MM/DD/YYYY' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{2}/\\\\d{2}/\\\\d{4}'\r\n then to_date( {{ column_name }}, 'MM/DD/YYYY')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD HH:MI:SS')\r\n else date(NULL)\r\n end\r\n {%- else -%}\r\n date(NULL)\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1279485, "supported_languages": null}, "macro.input_layer.snowflake__try_to_cast_date": {"name": "snowflake__try_to_cast_date", "resource_type": "macro", "package_name": "input_layer", "path": "../macros\\try_to_cast_date.sql", "original_file_path": "../macros\\try_to_cast_date.sql", "unique_id": "macro.input_layer.snowflake__try_to_cast_date", "macro_sql": "{%- macro snowflake__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1279485, "supported_languages": null}, "macro.dbt_snowflake.get_column_comment_sql": {"name": "get_column_comment_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.get_column_comment_sql", "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1379576, "supported_languages": null}, "macro.dbt_snowflake.get_persist_docs_column_list": {"name": "get_persist_docs_column_list", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1379576, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_columns_in_relation": {"name": "snowflake__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.138957, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_schemas": {"name": "snowflake__list_schemas", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__list_schemas", "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.139961, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_paginated_relations_array": {"name": "snowflake__get_paginated_relations_array", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_paginated_relations_array", "macro_sql": "{% macro snowflake__get_paginated_relations_array(max_iter, max_results_per_iter, max_total_results, schema_relation, watermark) %}\n\n {% set paginated_relations = [] %}\n\n {% for _ in range(0, max_iter) %}\n\n {%- set paginated_sql -%}\n show terse objects in {{ schema_relation.database }}.{{ schema_relation.schema }} limit {{ max_results_per_iter }} from '{{ watermark.table_name }}'\n {%- endset -%}\n\n {%- set paginated_result = run_query(paginated_sql) %}\n {%- set paginated_n = (paginated_result | length) -%}\n\n {#\n terminating condition: if there are 0 records in the result we reached\n the end exactly on the previous iteration\n #}\n {%- if paginated_n == 0 -%}\n {%- break -%}\n {%- endif -%}\n\n {#\n terminating condition: At some point the user needs to be reasonable with how\n many objects are contained in their schemas. Since there was already\n one iteration before attempting pagination, loop.index == max_iter means\n the limit has been surpassed.\n #}\n\n {%- if loop.index == max_iter -%}\n {%- set msg -%}\n dbt will list a maximum of {{ max_total_results }} objects in schema {{ schema_relation.database }}.{{ schema_relation.schema }}.\n Your schema exceeds this limit. Please contact support@getdbt.com for troubleshooting tips,\n or review and reduce the number of objects contained.\n {%- endset -%}\n\n {% do exceptions.raise_compiler_error(msg) %}\n {%- endif -%}\n\n {%- do paginated_relations.append(paginated_result) -%}\n {% set watermark.table_name = paginated_result.columns[1].values()[-1] %}\n\n {#\n terminating condition: paginated_n < max_results_per_iter means we reached the end\n #}\n {%- if paginated_n < max_results_per_iter -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n\n {{ return(paginated_relations) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1409569, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_relations_without_caching": {"name": "snowflake__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation, max_iter=10, max_results_per_iter=10000) %}\n\n {%- set max_total_results = max_results_per_iter * max_iter -%}\n\n {%- set sql -%}\n show terse objects in {{ schema_relation.database }}.{{ schema_relation.schema }} limit {{ max_results_per_iter }}\n {%- endset -%}\n\n {%- set result = run_query(sql) -%}\n\n {%- set n = (result | length) -%}\n {%- set watermark = namespace(table_name=result.columns[1].values()[-1]) -%}\n {%- set paginated = namespace(result=[]) -%}\n\n {% if n >= max_results_per_iter %}\n\n {% set paginated.result = snowflake__get_paginated_relations_array(\n max_iter,\n max_results_per_iter,\n max_total_results,\n schema_relation,\n watermark\n )\n %}\n\n {% endif %}\n\n {%- set all_results_array = [result] + paginated.result -%}\n {%- set result = result.merge(all_results_array) -%}\n {%- do return(result) -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_snowflake.snowflake__get_paginated_relations_array"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1419587, "supported_languages": null}, "macro.dbt_snowflake.snowflake__check_schema_exists": {"name": "snowflake__check_schema_exists", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1429596, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_type": {"name": "snowflake__alter_column_type", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1429596, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_comment": {"name": "snowflake__alter_relation_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n {%- if relation.is_dynamic_table -%}\n {%- set relation_type = 'dynamic table' -%}\n {%- else -%}\n {%- set relation_type = relation.type -%}\n {%- endif -%}\n comment on {{ relation_type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1429596, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_comment": {"name": "snowflake__alter_column_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n alter {{ relation_type }} {{ relation }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1439612, "supported_languages": null}, "macro.dbt_snowflake.get_current_query_tag": {"name": "get_current_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.get_current_query_tag", "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1439612, "supported_languages": null}, "macro.dbt_snowflake.set_query_tag": {"name": "set_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__set_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.144969, "supported_languages": null}, "macro.dbt_snowflake.snowflake__set_query_tag": {"name": "snowflake__set_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_current_query_tag", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.144969, "supported_languages": null}, "macro.dbt_snowflake.unset_query_tag": {"name": "unset_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.unset_query_tag", "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.144969, "supported_languages": null}, "macro.dbt_snowflake.snowflake__unset_query_tag": {"name": "snowflake__unset_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1459699, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": {"name": "snowflake__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"dynamic table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1469636, "supported_languages": null}, "macro.dbt_snowflake.snowflake_dml_explicit_transaction": {"name": "snowflake_dml_explicit_transaction", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1469636, "supported_languages": null}, "macro.dbt_snowflake.snowflake__truncate_relation": {"name": "snowflake__truncate_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\adapters.sql", "original_file_path": "macros\\adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1479626, "supported_languages": null}, "macro.dbt_snowflake.snowflake__copy_grants": {"name": "snowflake__copy_grants", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\apply_grants.sql", "original_file_path": "macros\\apply_grants.sql", "unique_id": "macro.dbt_snowflake.snowflake__copy_grants", "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1479626, "supported_languages": null}, "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": {"name": "snowflake__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\apply_grants.sql", "original_file_path": "macros\\apply_grants.sql", "unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1479626, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog": {"name": "snowflake__get_catalog", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog", "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1520412, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_relations": {"name": "snowflake__get_catalog_relations", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations", "macro_sql": "{% macro snowflake__get_catalog_relations(information_schema, relations) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.152967, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_tables_sql": {"name": "snowflake__get_catalog_tables_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro_sql": "{% macro snowflake__get_catalog_tables_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n case\n when is_dynamic = 'YES' and table_type = 'BASE TABLE' THEN 'DYNAMIC TABLE'\n else table_type\n end as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n from {{ information_schema }}.tables\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.152967, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_columns_sql": {"name": "snowflake__get_catalog_columns_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro_sql": "{% macro snowflake__get_catalog_columns_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n from {{ information_schema }}.columns\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.152967, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_results_sql": {"name": "snowflake__get_catalog_results_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro_sql": "{% macro snowflake__get_catalog_results_sql() -%}\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n order by \"column_index\"\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.152967, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql": {"name": "snowflake__get_catalog_schemas_where_clause_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", "macro_sql": "{% macro snowflake__get_catalog_schemas_where_clause_sql(schemas) -%}\n where ({%- for schema in schemas -%}\n upper(\"table_schema\") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.153949, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql": {"name": "snowflake__get_catalog_relations_where_clause_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\catalog.sql", "original_file_path": "macros\\catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", "macro_sql": "{% macro snowflake__get_catalog_relations_where_clause_sql(relations) -%}\n where (\n {%- for relation in relations -%}\n {% if relation.schema and relation.identifier %}\n (\n upper(\"table_schema\") = upper('{{ relation.schema }}')\n and upper(\"table_name\") = upper('{{ relation.identifier }}')\n )\n {% elif relation.schema %}\n (\n upper(\"table_schema\") = upper('{{ relation.schema }}')\n )\n {% else %}\n {% do exceptions.raise_compiler_error(\n '`get_catalog_relations` requires a list of relations, each with a schema'\n ) %}\n {% endif %}\n\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1549654, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_relation_last_modified": {"name": "snowflake__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\metadata.sql", "original_file_path": "macros\\metadata.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_relation_last_modified", "macro_sql": "{% macro snowflake__get_relation_last_modified(information_schema, relations) -%}\n\n {%- call statement('last_modified', fetch_result=True) -%}\n select table_schema as schema,\n table_name as identifier,\n last_altered as last_modified,\n {{ current_timestamp() }} as snapshotted_at\n from {{ information_schema }}.tables\n where (\n {%- for relation in relations -%}\n (upper(table_schema) = upper('{{ relation.schema }}') and\n upper(table_name) = upper('{{ relation.identifier }}')){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n {%- endcall -%}\n\n {{ return(load_result('last_modified')) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1549654, "supported_languages": null}, "macro.dbt_snowflake.snowflake__can_clone_table": {"name": "snowflake__can_clone_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\clone.sql", "original_file_path": "macros\\materializations\\clone.sql", "unique_id": "macro.dbt_snowflake.snowflake__can_clone_table", "macro_sql": "{% macro snowflake__can_clone_table() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1559622, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_or_replace_clone": {"name": "snowflake__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\clone.sql", "original_file_path": "macros\\materializations\\clone.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_clone", "macro_sql": "{% macro snowflake__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace\n {{ \"transient\" if config.get(\"transient\", true) }}\n table {{ this_relation }}\n clone {{ defer_relation }}\n {{ \"copy grants\" if config.get(\"copy_grants\", false) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1559622, "supported_languages": null}, "macro.dbt_snowflake.materialization_dynamic_table_snowflake": {"name": "materialization_dynamic_table_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\dynamic_table.sql", "original_file_path": "macros\\materializations\\dynamic_table.sql", "unique_id": "macro.dbt_snowflake.materialization_dynamic_table_snowflake", "macro_sql": "{% materialization dynamic_table, adapter='snowflake' %}\n\n {% set query_tag = set_query_tag() %}\n\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.DynamicTable) %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% set build_sql = dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% if build_sql == '' %}\n {{ dynamic_table_execute_no_op(target_relation) }}\n {% else %}\n {{ dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) }}\n {% endif %}\n\n {{ run_hooks(post_hooks) }}\n\n {% do unset_query_tag(query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.load_cached_relation", "macro.dbt.run_hooks", "macro.dbt_snowflake.dynamic_table_get_build_sql", "macro.dbt_snowflake.dynamic_table_execute_no_op", "macro.dbt_snowflake.dynamic_table_execute_build_sql", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1589642, "supported_languages": ["sql"]}, "macro.dbt_snowflake.dynamic_table_get_build_sql": {"name": "dynamic_table_get_build_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\dynamic_table.sql", "original_file_path": "macros\\materializations\\dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_get_build_sql", "macro_sql": "{% macro dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_dynamic_table %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = snowflake__get_dynamic_table_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"No configuration changes were identified on: `\" ~ target_relation ~ \"`. Continuing.\") }}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = snowflake__get_alter_dynamic_table_as_sql(existing_relation, configuration_changes, target_relation, sql) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'continue', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario: `\" ~ on_configuration_change ~ \"`\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_sql", "macro.dbt.get_replace_sql", "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1609588, "supported_languages": null}, "macro.dbt_snowflake.dynamic_table_execute_no_op": {"name": "dynamic_table_execute_no_op", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\dynamic_table.sql", "original_file_path": "macros\\materializations\\dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_execute_no_op", "macro_sql": "{% macro dynamic_table_execute_no_op(relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1609588, "supported_languages": null}, "macro.dbt_snowflake.dynamic_table_execute_build_sql": {"name": "dynamic_table_execute_build_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\dynamic_table.sql", "original_file_path": "macros\\materializations\\dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_execute_build_sql", "macro_sql": "{% macro dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.161971, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes": {"name": "snowflake__get_dynamic_table_configuration_changes", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\dynamic_table.sql", "original_file_path": "macros\\materializations\\dynamic_table.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", "macro_sql": "{% macro snowflake__get_dynamic_table_configuration_changes(existing_relation, new_config) -%}\n {% set _existing_dynamic_table = snowflake__describe_dynamic_table(existing_relation) %}\n {% set _configuration_changes = existing_relation.dynamic_table_config_changeset(_existing_dynamic_table, new_config.model) %}\n {% do return(_configuration_changes) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__describe_dynamic_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.161971, "supported_languages": null}, "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": {"name": "dbt_snowflake_get_tmp_relation_type", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\incremental.sql", "original_file_path": "macros\\materializations\\incremental.sql", "unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n{%- set tmp_relation_type = config.get('tmp_relation_type') -%}\n /* {#\n High-level principles:\n If we are running multiple statements (DELETE + INSERT),\n and we want to guarantee identical inputs to both statements,\n then we must first save the model query results as a temporary table\n (which presumably comes with a performance cost).\n If we are running a single statement (MERGE or INSERT alone),\n we _may_ save the model query definition as a view instead,\n for (presumably) faster overall incremental processing.\n\n Low-level specifics:\n If an invalid option is specified, then we will raise an\n excpetion with corresponding message.\n\n Languages other than SQL (like Python) will use a temporary table.\n With the default strategy of merge, the user may choose between a temporary\n table and view (defaulting to view).\n\n The append strategy can use a view because it will run a single INSERT statement.\n\n When unique_key is none, the delete+insert strategy can use a view beacuse a\n single INSERT statement is run with no DELETES as part of the statement.\n Otherwise, play it safe by using a temporary table.\n #} */\n\n {% if language == \"python\" and tmp_relation_type is not none %}\n {% do exceptions.raise_compiler_error(\n \"Python models currently only support 'table' for tmp_relation_type but \"\n ~ tmp_relation_type ~ \" was specified.\"\n ) %}\n {% endif %}\n\n {% if strategy == \"delete+insert\" and tmp_relation_type is not none and tmp_relation_type != \"table\" and unique_key is not none %}\n {% do exceptions.raise_compiler_error(\n \"In order to maintain consistent results when `unique_key` is not none,\n the `delete+insert` strategy only supports `table` for `tmp_relation_type` but \"\n ~ tmp_relation_type ~ \" was specified.\"\n )\n %}\n {% endif %}\n\n {% if language != \"sql\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"table\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"view\" %}\n {{ return(\"view\") }}\n {% elif strategy in (\"default\", \"merge\", \"append\") %}\n {{ return(\"view\") }}\n {% elif strategy == \"delete+insert\" and unique_key is none %}\n {{ return(\"view\") }}\n {% else %}\n {{ return(\"table\") }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.164971, "supported_languages": null}, "macro.dbt_snowflake.materialization_incremental_snowflake": {"name": "materialization_incremental_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\incremental.sql", "original_file_path": "macros\\materializations\\incremental.sql", "unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ snowflake__create_view_as_with_temp_flag(tmp_relation, compiled_code, True) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.should_full_refresh", "macro.dbt.load_relation", "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro.dbt.make_temp_relation", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", "macro.dbt.process_schema_changes", "macro.dbt.drop_relation_if_exists", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1689718, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.snowflake__get_incremental_default_sql": {"name": "snowflake__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\incremental.sql", "original_file_path": "macros\\materializations\\incremental.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1689718, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_merge_sql": {"name": "snowflake__get_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\merge.sql", "original_file_path": "macros\\materializations\\merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.default__get_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1709552, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": {"name": "snowflake__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\merge.sql", "original_file_path": "macros\\materializations\\merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1709552, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_merge_sql": {"name": "snowflake__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\merge.sql", "original_file_path": "macros\\materializations\\merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1709552, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_incremental_append_sql": {"name": "snowflake__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\merge.sql", "original_file_path": "macros\\materializations\\merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_append_sql", "macro_sql": "{% macro snowflake__get_incremental_append_sql(get_incremental_append_sql) %}\n {% set dml = default__get_incremental_append_sql(get_incremental_append_sql) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1719775, "supported_languages": null}, "macro.dbt_snowflake.snowflake__load_csv_rows": {"name": "snowflake__load_csv_rows", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\seed.sql", "original_file_path": "macros\\materializations\\seed.sql", "unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1740613, "supported_languages": null}, "macro.dbt_snowflake.materialization_seed_snowflake": {"name": "materialization_seed_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\seed.sql", "original_file_path": "macros\\materializations\\seed.sql", "unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_seed_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1740613, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_snapshot_snowflake": {"name": "materialization_snapshot_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\snapshot.sql", "original_file_path": "macros\\materializations\\snapshot.sql", "unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_snapshot_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1740613, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_table_snowflake": {"name": "materialization_table_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\table.sql", "original_file_path": "macros\\materializations\\table.sql", "unique_id": "macro.dbt_snowflake.materialization_table_snowflake", "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.177068, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.py_write_table": {"name": "py_write_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\table.sql", "original_file_path": "macros\\materializations\\table.sql", "unique_id": "macro.dbt_snowflake.py_write_table", "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False, table_type=none) %}\n{#- The following logic is only for backwards-compatiblity with deprecated `temporary` parameter -#}\n{% if table_type is not none %}\n {#- Just use the table_type as-is -#}\n{% elif temporary -%}\n {#- Case 1 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {%- set table_type = \"temporary\" -%}\n{% else %}\n {#- Case 2 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {#- Snowflake treats \"\" as meaning \"permanent\" -#}\n {%- set table_type = \"\" -%}\n{%- endif %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n session.use_database(target_relation.database)\n session.use_schema(target_relation.schema)\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n {% set target_relation_name = resolve_model_name(target_relation) %}\n df.write.mode(\"overwrite\").save_as_table('{{ target_relation_name }}', table_type='{{table_type}}')\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.177068, "supported_languages": null}, "macro.dbt_snowflake.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\table.sql", "original_file_path": "macros\\materializations\\table.sql", "unique_id": "macro.dbt_snowflake.py_script_comment", "macro_sql": "{% macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1780667, "supported_languages": null}, "macro.dbt_snowflake.materialization_test_snowflake": {"name": "materialization_test_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\test.sql", "original_file_path": "macros\\materializations\\test.sql", "unique_id": "macro.dbt_snowflake.materialization_test_snowflake", "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_test_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1780667, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_view_snowflake": {"name": "materialization_view_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\materializations\\view.sql", "original_file_path": "macros\\materializations\\view.sql", "unique_id": "macro.dbt_snowflake.materialization_view_snowflake", "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = snowflake__create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {% do return(to_return) %}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt_snowflake.snowflake__create_or_replace_view", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1790638, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__get_create_sql": {"name": "snowflake__get_create_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\create.sql", "original_file_path": "macros\\relations\\create.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_create_sql", "macro_sql": "{% macro snowflake__get_create_sql(relation, sql) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_create_dynamic_table_as_sql(relation, sql) }}\n\n {% else %}\n {{ default__get_create_sql(relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", "macro.dbt.default__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1790638, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_sql": {"name": "snowflake__get_drop_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\drop.sql", "original_file_path": "macros\\relations\\drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_sql", "macro_sql": "{% macro snowflake__get_drop_sql(relation) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_drop_dynamic_table_sql(relation) }}\n\n {% else %}\n {{ default__get_drop_sql(relation) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", "macro.dbt.default__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1790638, "supported_languages": null}, "macro.dbt_snowflake.snowflake__rename_relation": {"name": "snowflake__rename_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\rename.sql", "original_file_path": "macros\\relations\\rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__rename_relation", "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.18006, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_sql": {"name": "snowflake__get_replace_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\replace.sql", "original_file_path": "macros\\relations\\replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_sql", "macro_sql": "{% macro snowflake__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {% if existing_relation.is_dynamic_table and target_relation.is_dynamic_table %}\n {{ snowflake__get_replace_dynamic_table_sql(target_relation, sql) }}\n\n {% else %}\n {{ default__get_replace_sql(existing_relation, target_relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", "macro.dbt.default__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.18006, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql": {"name": "snowflake__get_alter_dynamic_table_as_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\dynamic_table\\alter.sql", "original_file_path": "macros\\relations\\dynamic_table\\alter.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql", "macro_sql": "{% macro snowflake__get_alter_dynamic_table_as_sql(\n existing_relation,\n configuration_changes,\n target_relation,\n sql\n) -%}\n {{- log('Applying ALTER to: ' ~ existing_relation) -}}\n\n {% if configuration_changes.requires_full_refresh %}\n {{- get_replace_sql(existing_relation, target_relation, sql) -}}\n\n {% else %}\n\n {%- set target_lag = configuration_changes.target_lag -%}\n {%- if target_lag -%}{{- log('Applying UPDATE TARGET_LAG to: ' ~ existing_relation) -}}{%- endif -%}\n {%- set snowflake_warehouse = configuration_changes.snowflake_warehouse -%}\n {%- if snowflake_warehouse -%}{{- log('Applying UPDATE WAREHOUSE to: ' ~ existing_relation) -}}{%- endif -%}\n\n alter dynamic table {{ existing_relation }} set\n {% if target_lag %}target_lag = '{{ target_lag.context }}'{% endif %}\n {% if snowflake_warehouse %}warehouse = {{ snowflake_warehouse.context }}{% endif %}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1810832, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql": {"name": "snowflake__get_create_dynamic_table_as_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\dynamic_table\\create.sql", "original_file_path": "macros\\relations\\dynamic_table\\create.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", "macro_sql": "{% macro snowflake__get_create_dynamic_table_as_sql(relation, sql) -%}\n\n create dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1820736, "supported_languages": null}, "macro.dbt_snowflake.snowflake__describe_dynamic_table": {"name": "snowflake__describe_dynamic_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\dynamic_table\\describe.sql", "original_file_path": "macros\\relations\\dynamic_table\\describe.sql", "unique_id": "macro.dbt_snowflake.snowflake__describe_dynamic_table", "macro_sql": "{% macro snowflake__describe_dynamic_table(relation) %}\n {%- set _dynamic_table_sql -%}\n show dynamic tables\n like '{{ relation.identifier }}'\n in schema {{ relation.database }}.{{ relation.schema }}\n ;\n select\n \"name\",\n \"schema_name\",\n \"database_name\",\n \"text\",\n \"target_lag\",\n \"warehouse\"\n from table(result_scan(last_query_id()))\n {%- endset %}\n {% set _dynamic_table = run_query(_dynamic_table_sql) %}\n\n {% do return({'dynamic_table': _dynamic_table}) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1830518, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql": {"name": "snowflake__get_drop_dynamic_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\dynamic_table\\drop.sql", "original_file_path": "macros\\relations\\dynamic_table\\drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", "macro_sql": "{% macro snowflake__get_drop_dynamic_table_sql(relation) %}\n drop dynamic table if exists {{ relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1830518, "supported_languages": null}, "macro.dbt_snowflake.snowflake__refresh_dynamic_table": {"name": "snowflake__refresh_dynamic_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\dynamic_table\\refresh.sql", "original_file_path": "macros\\relations\\dynamic_table\\refresh.sql", "unique_id": "macro.dbt_snowflake.snowflake__refresh_dynamic_table", "macro_sql": "{% macro snowflake__refresh_dynamic_table(relation) -%}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n\n alter dynamic table {{ relation }} refresh\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1840763, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql": {"name": "snowflake__get_replace_dynamic_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\dynamic_table\\replace.sql", "original_file_path": "macros\\relations\\dynamic_table\\replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", "macro_sql": "{% macro snowflake__get_replace_dynamic_table_sql(relation, sql) %}\n\n create or replace dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n ;\n {{ snowflake__refresh_dynamic_table(relation) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__refresh_dynamic_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1840763, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_table_as": {"name": "snowflake__create_table_as", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_table_as", "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- set transient = config.get('transient', default=true) -%}\n\n {% if temporary -%}\n {%- set table_type = \"temporary\" -%}\n {%- elif transient -%}\n {%- set table_type = \"transient\" -%}\n {%- else -%}\n {%- set table_type = \"\" -%}\n {%- endif %}\n\n {%- if language == 'sql' -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {{ table_type }} table {{ relation }}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {% set compiled_code = get_select_subquery(compiled_code) %}\n {% endif %}\n {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from (\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, table_type=table_type) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery", "macro.dbt_snowflake.py_write_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1886606, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_table_sql": {"name": "snowflake__get_drop_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\table\\drop.sql", "original_file_path": "macros\\relations\\table\\drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_table_sql", "macro_sql": "{% macro snowflake__get_drop_table_sql(relation) %}\n drop table if exists {{ relation }} cascade\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1886606, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_rename_table_sql": {"name": "snowflake__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\table\\rename.sql", "original_file_path": "macros\\relations\\table\\rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_rename_table_sql", "macro_sql": "{%- macro snowflake__get_rename_table_sql(relation, new_name) -%}\n alter table {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1886606, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_table_sql": {"name": "snowflake__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\table\\replace.sql", "original_file_path": "macros\\relations\\table\\replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_table_sql", "macro_sql": "{% macro snowflake__get_replace_table_sql(relation, sql) %}\n {{ snowflake__create_table_as(False, relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.189761, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag": {"name": "snowflake__create_view_as_with_temp_flag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", "macro_sql": "{% macro snowflake__create_view_as_with_temp_flag(relation, sql, is_temporary=False) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} {% if is_temporary -%}\n temporary\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt_snowflake.get_persist_docs_column_list", "macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1907668, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as": {"name": "snowflake__create_view_as", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_view_as", "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {{ snowflake__create_view_as_with_temp_flag(relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.191759, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_or_replace_view": {"name": "snowflake__create_or_replace_view", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_view", "macro_sql": "{% macro snowflake__create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and not old_relation.is_view -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1927578, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_view_sql": {"name": "snowflake__get_drop_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\view\\drop.sql", "original_file_path": "macros\\relations\\view\\drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_view_sql", "macro_sql": "{% macro snowflake__get_drop_view_sql(relation) %}\n drop view if exists {{ relation }} cascade\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1927578, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_rename_view_sql": {"name": "snowflake__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\view\\rename.sql", "original_file_path": "macros\\relations\\view\\rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_rename_view_sql", "macro_sql": "{%- macro snowflake__get_rename_view_sql(relation, new_name) -%}\n alter view {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1927578, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_view_sql": {"name": "snowflake__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\relations\\view\\replace.sql", "original_file_path": "macros\\relations\\view\\replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_view_sql", "macro_sql": "{% macro snowflake__get_replace_view_sql(relation, sql) %}\n {{ snowflake__create_view_as(relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1927578, "supported_languages": null}, "macro.dbt_snowflake.snowflake__array_construct": {"name": "snowflake__array_construct", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\array_construct.sql", "original_file_path": "macros\\utils\\array_construct.sql", "unique_id": "macro.dbt_snowflake.snowflake__array_construct", "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1937728, "supported_languages": null}, "macro.dbt_snowflake.snowflake__bool_or": {"name": "snowflake__bool_or", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\bool_or.sql", "original_file_path": "macros\\utils\\bool_or.sql", "unique_id": "macro.dbt_snowflake.snowflake__bool_or", "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1937728, "supported_languages": null}, "macro.dbt_snowflake.snowflake__cast": {"name": "snowflake__cast", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\cast.sql", "original_file_path": "macros\\utils\\cast.sql", "unique_id": "macro.dbt_snowflake.snowflake__cast", "macro_sql": "{% macro snowflake__cast(field, type) %}\n {% if (type|upper == \"GEOGRAPHY\") -%}\n to_geography({{field}})\n {% elif (type|upper == \"GEOMETRY\") -%}\n to_geometry({{field}})\n {% else -%}\n cast({{field}} as {{type}})\n {% endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1937728, "supported_languages": null}, "macro.dbt_snowflake.snowflake__escape_single_quotes": {"name": "snowflake__escape_single_quotes", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\escape_single_quotes.sql", "original_file_path": "macros\\utils\\escape_single_quotes.sql", "unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.194758, "supported_languages": null}, "macro.dbt_snowflake.snowflake__right": {"name": "snowflake__right", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\right.sql", "original_file_path": "macros\\utils\\right.sql", "unique_id": "macro.dbt_snowflake.snowflake__right", "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.194758, "supported_languages": null}, "macro.dbt_snowflake.snowflake__safe_cast": {"name": "snowflake__safe_cast", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\safe_cast.sql", "original_file_path": "macros\\utils\\safe_cast.sql", "unique_id": "macro.dbt_snowflake.snowflake__safe_cast", "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n {% if type|upper == \"GEOMETRY\" -%}\n try_to_geometry({{field}})\n {% elif type|upper == \"GEOGRAPHY\" -%}\n try_to_geography({{field}})\n {% elif type|upper != \"VARIANT\" -%}\n {#-- Snowflake try_cast does not support casting to variant, and expects the field as a string --#}\n {% set field_as_string = dbt.string_literal(field) if field is number else field %}\n try_cast({{field_as_string}} as {{type}})\n {% else -%}\n {{ adapter.dispatch('cast', 'dbt')(field, type) }}\n {% endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.string_literal", "macro.dbt.cast", "macro.dbt_snowflake.snowflake__cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.195759, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp": {"name": "snowflake__current_timestamp", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\timestamps.sql", "original_file_path": "macros\\utils\\timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.195759, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_string_as_time": {"name": "snowflake__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\timestamps.sql", "original_file_path": "macros\\utils\\timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.195759, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_get_time": {"name": "snowflake__snapshot_get_time", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\timestamps.sql", "original_file_path": "macros\\utils\\timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.195759, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": {"name": "snowflake__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\timestamps.sql", "original_file_path": "macros\\utils\\timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1967719, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": {"name": "snowflake__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros\\utils\\timestamps.sql", "original_file_path": "macros\\utils\\timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1967719, "supported_languages": null}, "macro.dbt.copy_grants": {"name": "copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1987505, "supported_languages": null}, "macro.dbt.default__copy_grants": {"name": "default__copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1987505, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"name": "support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1987505, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"name": "default__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1987505, "supported_languages": null}, "macro.dbt.should_revoke": {"name": "should_revoke", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1997514, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"name": "get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1997514, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"name": "default__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation.render() }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1997514, "supported_languages": null}, "macro.dbt.get_grant_sql": {"name": "get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.1997514, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"name": "default__get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation.render() }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2007606, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"name": "get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2007606, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"name": "default__get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation.render() }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2007606, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"name": "get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2007606, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"name": "default__get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2017574, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"name": "call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2017574, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"name": "default__call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2027612, "supported_languages": null}, "macro.dbt.apply_grants": {"name": "apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2027612, "supported_languages": null}, "macro.dbt.default__apply_grants": {"name": "default__apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\apply_grants.sql", "original_file_path": "macros\\adapters\\apply_grants.sql", "unique_id": "macro.dbt.default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation.render() ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2037597, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"name": "get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.205758, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"name": "default__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2067654, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"name": "sql_convert_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2067654, "supported_languages": null}, "macro.dbt.get_empty_subquery_sql": {"name": "get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.get_empty_subquery_sql", "macro_sql": "{% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}\n {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2067654, "supported_languages": null}, "macro.dbt.default__get_empty_subquery_sql": {"name": "default__get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.default__get_empty_subquery_sql", "macro_sql": "{% macro default__get_empty_subquery_sql(select_sql, select_sql_header=none) %}\n {%- if select_sql_header is not none -%}\n {{ select_sql_header }}\n {%- endif -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2067654, "supported_languages": null}, "macro.dbt.get_empty_schema_sql": {"name": "get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.get_empty_schema_sql", "macro_sql": "{% macro get_empty_schema_sql(columns) -%}\n {{ return(adapter.dispatch('get_empty_schema_sql', 'dbt')(columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_schema_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.207771, "supported_languages": null}, "macro.dbt.default__get_empty_schema_sql": {"name": "default__get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.default__get_empty_schema_sql", "macro_sql": "{% macro default__get_empty_schema_sql(columns) %}\n {%- set col_err = [] -%}\n {%- set col_naked_numeric = [] -%}\n select\n {% for i in columns %}\n {%- set col = columns[i] -%}\n {%- if col['data_type'] is not defined -%}\n {%- do col_err.append(col['name']) -%}\n {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n {%- do col_naked_numeric.append(col['name']) -%}\n {%- endif -%}\n {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n {{ cast('null', col['data_type']) }} as {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n {%- if (col_err | length) > 0 -%}\n {{ exceptions.column_type_missing(column_names=col_err) }}\n {%- elif (col_naked_numeric | length) > 0 -%}\n {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2087646, "supported_languages": null}, "macro.dbt.get_column_schema_from_query": {"name": "get_column_schema_from_query", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.get_column_schema_from_query", "macro_sql": "{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n {% set columns = [] %}\n {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n {{ return(column_schema) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2097669, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"name": "get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2097669, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"name": "default__get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n {{ get_empty_subquery_sql(select_sql) }}\n {% endcall %}\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2097669, "supported_languages": null}, "macro.dbt.alter_column_type": {"name": "alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2097669, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"name": "default__alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation.render() }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation.render() }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation.render() }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation.render() }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2107685, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"name": "alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2107685, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"name": "default__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\columns.sql", "original_file_path": "macros\\adapters\\columns.sql", "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation.render() }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2117648, "supported_languages": null}, "macro.dbt.collect_freshness": {"name": "collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\freshness.sql", "original_file_path": "macros\\adapters\\freshness.sql", "unique_id": "macro.dbt.collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.212765, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"name": "default__collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\freshness.sql", "original_file_path": "macros\\adapters\\freshness.sql", "unique_id": "macro.dbt.default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.212765, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"name": "get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2147486, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"name": "default__get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2147486, "supported_languages": null}, "macro.dbt.create_indexes": {"name": "create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2147486, "supported_languages": null}, "macro.dbt.default__create_indexes": {"name": "default__create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2147486, "supported_languages": null}, "macro.dbt.get_drop_index_sql": {"name": "get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.get_drop_index_sql", "macro_sql": "{% macro get_drop_index_sql(relation, index_name) -%}\n {{ adapter.dispatch('get_drop_index_sql', 'dbt')(relation, index_name) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_drop_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.215768, "supported_languages": null}, "macro.dbt.default__get_drop_index_sql": {"name": "default__get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.default__get_drop_index_sql", "macro_sql": "{% macro default__get_drop_index_sql(relation, index_name) -%}\n {{ exceptions.raise_compiler_error(\"`get_drop_index_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.215768, "supported_languages": null}, "macro.dbt.get_show_indexes_sql": {"name": "get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.get_show_indexes_sql", "macro_sql": "{% macro get_show_indexes_sql(relation) -%}\n {{ adapter.dispatch('get_show_indexes_sql', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_indexes_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.215768, "supported_languages": null}, "macro.dbt.default__get_show_indexes_sql": {"name": "default__get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\indexes.sql", "original_file_path": "macros\\adapters\\indexes.sql", "unique_id": "macro.dbt.default__get_show_indexes_sql", "macro_sql": "{% macro default__get_show_indexes_sql(relation) -%}\n {{ exceptions.raise_compiler_error(\"`get_show_indexes_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.215768, "supported_languages": null}, "macro.dbt.get_catalog_relations": {"name": "get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.get_catalog_relations", "macro_sql": "{% macro get_catalog_relations(information_schema, relations) -%}\n {{ return(adapter.dispatch('get_catalog_relations', 'dbt')(information_schema, relations)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2187576, "supported_languages": null}, "macro.dbt.default__get_catalog_relations": {"name": "default__get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__get_catalog_relations", "macro_sql": "{% macro default__get_catalog_relations(information_schema, relations) -%}\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog_relations not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2197576, "supported_languages": null}, "macro.dbt.get_catalog": {"name": "get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2197576, "supported_languages": null}, "macro.dbt.default__get_catalog": {"name": "default__get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2197576, "supported_languages": null}, "macro.dbt.information_schema_name": {"name": "information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2207618, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"name": "default__information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2207618, "supported_languages": null}, "macro.dbt.list_schemas": {"name": "list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2207618, "supported_languages": null}, "macro.dbt.default__list_schemas": {"name": "default__list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2207618, "supported_languages": null}, "macro.dbt.check_schema_exists": {"name": "check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.221764, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"name": "default__check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.221764, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"name": "list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.221764, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"name": "default__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.221764, "supported_languages": null}, "macro.dbt.get_catalog_for_single_relation": {"name": "get_catalog_for_single_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.get_catalog_for_single_relation", "macro_sql": "{% macro get_catalog_for_single_relation(relation) %}\n {{ return(adapter.dispatch('get_catalog_for_single_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_catalog_for_single_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.221764, "supported_languages": null}, "macro.dbt.default__get_catalog_for_single_relation": {"name": "default__get_catalog_for_single_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__get_catalog_for_single_relation", "macro_sql": "{% macro default__get_catalog_for_single_relation(relation) %}\n {{ exceptions.raise_not_implemented(\n 'get_catalog_for_single_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.222765, "supported_languages": null}, "macro.dbt.get_relations": {"name": "get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.get_relations", "macro_sql": "{% macro get_relations() %}\n {{ return(adapter.dispatch('get_relations', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.222765, "supported_languages": null}, "macro.dbt.default__get_relations": {"name": "default__get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__get_relations", "macro_sql": "{% macro default__get_relations() %}\n {{ exceptions.raise_not_implemented(\n 'get_relations macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.222765, "supported_languages": null}, "macro.dbt.get_relation_last_modified": {"name": "get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.get_relation_last_modified", "macro_sql": "{% macro get_relation_last_modified(information_schema, relations) %}\n {{ return(adapter.dispatch('get_relation_last_modified', 'dbt')(information_schema, relations)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_relation_last_modified"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.222765, "supported_languages": null}, "macro.dbt.default__get_relation_last_modified": {"name": "default__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\metadata.sql", "original_file_path": "macros\\adapters\\metadata.sql", "unique_id": "macro.dbt.default__get_relation_last_modified", "macro_sql": "{% macro default__get_relation_last_modified(information_schema, relations) %}\n {{ exceptions.raise_not_implemented(\n 'get_relation_last_modified macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.222765, "supported_languages": null}, "macro.dbt.alter_column_comment": {"name": "alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\persist_docs.sql", "original_file_path": "macros\\adapters\\persist_docs.sql", "unique_id": "macro.dbt.alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.223779, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"name": "default__alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\persist_docs.sql", "original_file_path": "macros\\adapters\\persist_docs.sql", "unique_id": "macro.dbt.default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.223779, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"name": "alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\persist_docs.sql", "original_file_path": "macros\\adapters\\persist_docs.sql", "unique_id": "macro.dbt.alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2247918, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"name": "default__alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\persist_docs.sql", "original_file_path": "macros\\adapters\\persist_docs.sql", "unique_id": "macro.dbt.default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2247918, "supported_languages": null}, "macro.dbt.persist_docs": {"name": "persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\persist_docs.sql", "original_file_path": "macros\\adapters\\persist_docs.sql", "unique_id": "macro.dbt.persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2247918, "supported_languages": null}, "macro.dbt.default__persist_docs": {"name": "default__persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\persist_docs.sql", "original_file_path": "macros\\adapters\\persist_docs.sql", "unique_id": "macro.dbt.default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2257645, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"name": "make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.227764, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"name": "default__make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.227764, "supported_languages": null}, "macro.dbt.make_temp_relation": {"name": "make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.227764, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"name": "default__make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.228768, "supported_languages": null}, "macro.dbt.make_backup_relation": {"name": "make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.228768, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"name": "default__make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.228768, "supported_languages": null}, "macro.dbt.truncate_relation": {"name": "truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2297728, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"name": "default__truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation.render() }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2297728, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"name": "get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2297728, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"name": "default__get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2307494, "supported_languages": null}, "macro.dbt.load_cached_relation": {"name": "load_cached_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2307494, "supported_languages": null}, "macro.dbt.load_relation": {"name": "load_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\relation.sql", "original_file_path": "macros\\adapters\\relation.sql", "unique_id": "macro.dbt.load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2317643, "supported_languages": null}, "macro.dbt.create_schema": {"name": "create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\schema.sql", "original_file_path": "macros\\adapters\\schema.sql", "unique_id": "macro.dbt.create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2317643, "supported_languages": null}, "macro.dbt.default__create_schema": {"name": "default__create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\schema.sql", "original_file_path": "macros\\adapters\\schema.sql", "unique_id": "macro.dbt.default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2317643, "supported_languages": null}, "macro.dbt.drop_schema": {"name": "drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\schema.sql", "original_file_path": "macros\\adapters\\schema.sql", "unique_id": "macro.dbt.drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2317643, "supported_languages": null}, "macro.dbt.default__drop_schema": {"name": "default__drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\schema.sql", "original_file_path": "macros\\adapters\\schema.sql", "unique_id": "macro.dbt.default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2327635, "supported_languages": null}, "macro.dbt.get_show_sql": {"name": "get_show_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\show.sql", "original_file_path": "macros\\adapters\\show.sql", "unique_id": "macro.dbt.get_show_sql", "macro_sql": "{% macro get_show_sql(compiled_code, sql_header, limit) -%}\n {%- if sql_header is not none -%}\n {{ sql_header }}\n {%- endif %}\n {{ get_limit_subquery_sql(compiled_code, limit) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2327635, "supported_languages": null}, "macro.dbt.get_limit_subquery_sql": {"name": "get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\show.sql", "original_file_path": "macros\\adapters\\show.sql", "unique_id": "macro.dbt.get_limit_subquery_sql", "macro_sql": "\n{%- macro get_limit_subquery_sql(sql, limit) -%}\n {{ adapter.dispatch('get_limit_sql', 'dbt')(sql, limit) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_limit_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2327635, "supported_languages": null}, "macro.dbt.default__get_limit_sql": {"name": "default__get_limit_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\show.sql", "original_file_path": "macros\\adapters\\show.sql", "unique_id": "macro.dbt.default__get_limit_sql", "macro_sql": "{% macro default__get_limit_sql(sql, limit) %}\n {{ compiled_code }}\n {% if limit is not none %}\n limit {{ limit }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.233759, "supported_languages": null}, "macro.dbt.current_timestamp": {"name": "current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.233759, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"name": "default__current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.233759, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"name": "snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2347574, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"name": "default__snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2347574, "supported_languages": null}, "macro.dbt.get_snapshot_get_time_data_type": {"name": "get_snapshot_get_time_data_type", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.get_snapshot_get_time_data_type", "macro_sql": "{% macro get_snapshot_get_time_data_type() %}\n {% set snapshot_time = adapter.dispatch('snapshot_get_time', 'dbt')() %}\n {% set time_data_type_sql = 'select ' ~ snapshot_time ~ ' as dbt_snapshot_time' %}\n {% set snapshot_time_column_schema = get_column_schema_from_query(time_data_type_sql) %}\n {% set time_data_type = snapshot_time_column_schema[0].dtype %}\n {{ return(time_data_type or none) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt_snowflake.snowflake__snapshot_get_time", "macro.dbt.get_column_schema_from_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2347574, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"name": "current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2347574, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"name": "default__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2347574, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"name": "current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2357628, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"name": "default__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\timestamps.sql", "original_file_path": "macros\\adapters\\timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2357628, "supported_languages": null}, "macro.dbt.validate_sql": {"name": "validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\validate_sql.sql", "original_file_path": "macros\\adapters\\validate_sql.sql", "unique_id": "macro.dbt.validate_sql", "macro_sql": "{% macro validate_sql(sql) -%}\n {{ return(adapter.dispatch('validate_sql', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__validate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2357628, "supported_languages": null}, "macro.dbt.default__validate_sql": {"name": "default__validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\adapters\\validate_sql.sql", "original_file_path": "macros\\adapters\\validate_sql.sql", "unique_id": "macro.dbt.default__validate_sql", "macro_sql": "{% macro default__validate_sql(sql) -%}\n {% call statement('validate_sql') -%}\n explain {{ sql }}\n {% endcall %}\n {{ return(load_result('validate_sql')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2357628, "supported_languages": null}, "macro.dbt.convert_datetime": {"name": "convert_datetime", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\datetime.sql", "original_file_path": "macros\\etc\\datetime.sql", "unique_id": "macro.dbt.convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.237771, "supported_languages": null}, "macro.dbt.dates_in_range": {"name": "dates_in_range", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\datetime.sql", "original_file_path": "macros\\etc\\datetime.sql", "unique_id": "macro.dbt.dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partition start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2397664, "supported_languages": null}, "macro.dbt.partition_range": {"name": "partition_range", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\datetime.sql", "original_file_path": "macros\\etc\\datetime.sql", "unique_id": "macro.dbt.partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2397664, "supported_languages": null}, "macro.dbt.py_current_timestring": {"name": "py_current_timestring", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\datetime.sql", "original_file_path": "macros\\etc\\datetime.sql", "unique_id": "macro.dbt.py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2407665, "supported_languages": null}, "macro.dbt.statement": {"name": "statement", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\statement.sql", "original_file_path": "macros\\etc\\statement.sql", "unique_id": "macro.dbt.statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2417686, "supported_languages": null}, "macro.dbt.noop_statement": {"name": "noop_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\statement.sql", "original_file_path": "macros\\etc\\statement.sql", "unique_id": "macro.dbt.noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2427654, "supported_languages": null}, "macro.dbt.run_query": {"name": "run_query", "resource_type": "macro", "package_name": "dbt", "path": "macros\\etc\\statement.sql", "original_file_path": "macros\\etc\\statement.sql", "unique_id": "macro.dbt.run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2427654, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"name": "default__test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "macros\\generic_test_sql\\accepted_values.sql", "original_file_path": "macros\\generic_test_sql\\accepted_values.sql", "unique_id": "macro.dbt.default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.243766, "supported_languages": null}, "macro.dbt.default__test_not_null": {"name": "default__test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "macros\\generic_test_sql\\not_null.sql", "original_file_path": "macros\\generic_test_sql\\not_null.sql", "unique_id": "macro.dbt.default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.243766, "supported_languages": null}, "macro.dbt.default__test_relationships": {"name": "default__test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "macros\\generic_test_sql\\relationships.sql", "original_file_path": "macros\\generic_test_sql\\relationships.sql", "unique_id": "macro.dbt.default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2447653, "supported_languages": null}, "macro.dbt.default__test_unique": {"name": "default__test_unique", "resource_type": "macro", "package_name": "dbt", "path": "macros\\generic_test_sql\\unique.sql", "original_file_path": "macros\\generic_test_sql\\unique.sql", "unique_id": "macro.dbt.default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2447653, "supported_languages": null}, "macro.dbt.generate_alias_name": {"name": "generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_alias.sql", "original_file_path": "macros\\get_custom_name\\get_custom_alias.sql", "unique_id": "macro.dbt.generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2457764, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"name": "default__generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_alias.sql", "original_file_path": "macros\\get_custom_name\\get_custom_alias.sql", "unique_id": "macro.dbt.default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name -%}\n\n {{ custom_alias_name | trim }}\n\n {%- elif node.version -%}\n\n {{ return(node.name ~ \"_v\" ~ (node.version | replace(\".\", \"_\"))) }}\n\n {%- else -%}\n\n {{ node.name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2457764, "supported_languages": null}, "macro.dbt.generate_database_name": {"name": "generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_database.sql", "original_file_path": "macros\\get_custom_name\\get_custom_database.sql", "unique_id": "macro.dbt.generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.246748, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"name": "default__generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_database.sql", "original_file_path": "macros\\get_custom_name\\get_custom_database.sql", "unique_id": "macro.dbt.default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.246748, "supported_languages": null}, "macro.dbt.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_schema.sql", "original_file_path": "macros\\get_custom_name\\get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2477686, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_schema.sql", "original_file_path": "macros\\get_custom_name\\get_custom_schema.sql", "unique_id": "macro.dbt.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2477686, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"name": "generate_schema_name_for_env", "resource_type": "macro", "package_name": "dbt", "path": "macros\\get_custom_name\\get_custom_schema.sql", "original_file_path": "macros\\get_custom_name\\get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2477686, "supported_languages": null}, "macro.dbt.set_sql_header": {"name": "set_sql_header", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\configs.sql", "original_file_path": "macros\\materializations\\configs.sql", "unique_id": "macro.dbt.set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.248773, "supported_languages": null}, "macro.dbt.should_full_refresh": {"name": "should_full_refresh", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\configs.sql", "original_file_path": "macros\\materializations\\configs.sql", "unique_id": "macro.dbt.should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.248773, "supported_languages": null}, "macro.dbt.should_store_failures": {"name": "should_store_failures", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\configs.sql", "original_file_path": "macros\\materializations\\configs.sql", "unique_id": "macro.dbt.should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.248773, "supported_languages": null}, "macro.dbt.run_hooks": {"name": "run_hooks", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\hooks.sql", "original_file_path": "macros\\materializations\\hooks.sql", "unique_id": "macro.dbt.run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2507517, "supported_languages": null}, "macro.dbt.make_hook_config": {"name": "make_hook_config", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\hooks.sql", "original_file_path": "macros\\materializations\\hooks.sql", "unique_id": "macro.dbt.make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2507517, "supported_languages": null}, "macro.dbt.before_begin": {"name": "before_begin", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\hooks.sql", "original_file_path": "macros\\materializations\\hooks.sql", "unique_id": "macro.dbt.before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2507517, "supported_languages": null}, "macro.dbt.in_transaction": {"name": "in_transaction", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\hooks.sql", "original_file_path": "macros\\materializations\\hooks.sql", "unique_id": "macro.dbt.in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2507517, "supported_languages": null}, "macro.dbt.after_commit": {"name": "after_commit", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\hooks.sql", "original_file_path": "macros\\materializations\\hooks.sql", "unique_id": "macro.dbt.after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2507517, "supported_languages": null}, "macro.dbt.materialization_materialized_view_default": {"name": "materialization_materialized_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\materialized_view.sql", "original_file_path": "macros\\materializations\\models\\materialized_view.sql", "unique_id": "macro.dbt.materialization_materialized_view_default", "macro_sql": "{% materialization materialized_view, default %}\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.MaterializedView) %}\n {% set intermediate_relation = make_intermediate_relation(target_relation) %}\n {% set backup_relation_type = target_relation.MaterializedView if existing_relation is none else existing_relation.type %}\n {% set backup_relation = make_backup_relation(target_relation, backup_relation_type) %}\n\n {{ materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) }}\n\n {% set build_sql = materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% if build_sql == '' %}\n {{ materialized_view_execute_no_op(target_relation) }}\n {% else %}\n {{ materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) }}\n {% endif %}\n\n {{ materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.materialized_view_setup", "macro.dbt.materialized_view_get_build_sql", "macro.dbt.materialized_view_execute_no_op", "macro.dbt.materialized_view_execute_build_sql", "macro.dbt.materialized_view_teardown"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2557645, "supported_languages": ["sql"]}, "macro.dbt.materialized_view_setup": {"name": "materialized_view_setup", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\materialized_view.sql", "original_file_path": "macros\\materializations\\models\\materialized_view.sql", "unique_id": "macro.dbt.materialized_view_setup", "macro_sql": "{% macro materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) %}\n\n -- backup_relation and intermediate_relation should not already exist in the database\n -- it's possible these exist because of a previous run that exited unexpectedly\n {% set preexisting_backup_relation = load_cached_relation(backup_relation) %}\n {% set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2557645, "supported_languages": null}, "macro.dbt.materialized_view_teardown": {"name": "materialized_view_teardown", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\materialized_view.sql", "original_file_path": "macros\\materializations\\models\\materialized_view.sql", "unique_id": "macro.dbt.materialized_view_teardown", "macro_sql": "{% macro materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) %}\n\n -- drop the temp relations if they exist to leave the database clean for the next run\n {{ drop_relation_if_exists(backup_relation) }}\n {{ drop_relation_if_exists(intermediate_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2567644, "supported_languages": null}, "macro.dbt.materialized_view_get_build_sql": {"name": "materialized_view_get_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\materialized_view.sql", "original_file_path": "macros\\materializations\\models\\materialized_view.sql", "unique_id": "macro.dbt.materialized_view_get_build_sql", "macro_sql": "{% macro materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_materialized_view_as_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_materialized_view %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = get_materialized_view_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = refresh_materialized_view(target_relation) %}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation.render() ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation.render() ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_materialized_view_as_sql", "macro.dbt.get_replace_sql", "macro.dbt.get_materialized_view_configuration_changes", "macro.dbt.refresh_materialized_view", "macro.dbt.get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2577686, "supported_languages": null}, "macro.dbt.materialized_view_execute_no_op": {"name": "materialized_view_execute_no_op", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\materialized_view.sql", "original_file_path": "macros\\materializations\\models\\materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_no_op", "macro_sql": "{% macro materialized_view_execute_no_op(target_relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ target_relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2587717, "supported_languages": null}, "macro.dbt.materialized_view_execute_build_sql": {"name": "materialized_view_execute_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\materialized_view.sql", "original_file_path": "macros\\materializations\\models\\materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_build_sql", "macro_sql": "{% macro materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) %}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2587717, "supported_languages": null}, "macro.dbt.materialization_table_default": {"name": "materialization_table_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\table.sql", "original_file_path": "macros\\materializations\\models\\table.sql", "unique_id": "macro.dbt.materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2627563, "supported_languages": ["sql"]}, "macro.dbt.materialization_view_default": {"name": "materialization_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\view.sql", "original_file_path": "macros\\materializations\\models\\view.sql", "unique_id": "macro.dbt.materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2657628, "supported_languages": ["sql"]}, "macro.dbt.can_clone_table": {"name": "can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\clone\\can_clone_table.sql", "original_file_path": "macros\\materializations\\models\\clone\\can_clone_table.sql", "unique_id": "macro.dbt.can_clone_table", "macro_sql": "{% macro can_clone_table() %}\n {{ return(adapter.dispatch('can_clone_table', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__can_clone_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2657628, "supported_languages": null}, "macro.dbt.default__can_clone_table": {"name": "default__can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\clone\\can_clone_table.sql", "original_file_path": "macros\\materializations\\models\\clone\\can_clone_table.sql", "unique_id": "macro.dbt.default__can_clone_table", "macro_sql": "{% macro default__can_clone_table() %}\n {{ return(False) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2657628, "supported_languages": null}, "macro.dbt.materialization_clone_default": {"name": "materialization_clone_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\clone\\clone.sql", "original_file_path": "macros\\materializations\\models\\clone\\clone.sql", "unique_id": "macro.dbt.materialization_clone_default", "macro_sql": "{%- materialization clone, default -%}\n\n {%- set relations = {'relations': []} -%}\n\n {%- if not defer_relation -%}\n -- nothing to do\n {{ log(\"No relation found in state manifest for \" ~ model.unique_id, info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n\n {%- if existing_relation and not flags.FULL_REFRESH -%}\n -- noop!\n {{ log(\"Relation \" ~ existing_relation ~ \" already exists\", info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set other_existing_relation = load_cached_relation(defer_relation) -%}\n\n -- If this is a database that can do zero-copy cloning of tables, and the other relation is a table, then this will be a table\n -- Otherwise, this will be a view\n\n {% set can_clone_table = can_clone_table() %}\n\n {%- if other_existing_relation and other_existing_relation.type == 'table' and can_clone_table -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {% if existing_relation is not none and not existing_relation.is_table %}\n {{ log(\"Dropping relation \" ~ existing_relation.render() ~ \" because it is of type \" ~ existing_relation.type) }}\n {{ drop_relation_if_exists(existing_relation) }}\n {% endif %}\n\n -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'\n {% call statement('main') %}\n {% if target_relation and defer_relation and target_relation == defer_relation %}\n {{ log(\"Target relation and defer relation are the same, skipping clone for relation: \" ~ target_relation.render()) }}\n {% else %}\n {{ create_or_replace_clone(target_relation, defer_relation) }}\n {% endif %}\n\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do persist_docs(target_relation, model) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n {%- else -%}\n\n {%- set target_relation = this.incorporate(type='view') -%}\n\n -- reuse the view materialization\n -- TODO: support actual dispatch for materialization macros\n -- Tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799\n {% set search_name = \"materialization_view_\" ~ adapter.type() %}\n {% if not search_name in context %}\n {% set search_name = \"materialization_view_default\" %}\n {% endif %}\n {% set materialization_macro = context[search_name] %}\n {% set relations = materialization_macro() %}\n {{ return(relations) }}\n\n {%- endif -%}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.can_clone_table", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_or_replace_clone", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2697654, "supported_languages": ["sql"]}, "macro.dbt.create_or_replace_clone": {"name": "create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\clone\\create_or_replace_clone.sql", "original_file_path": "macros\\materializations\\models\\clone\\create_or_replace_clone.sql", "unique_id": "macro.dbt.create_or_replace_clone", "macro_sql": "{% macro create_or_replace_clone(this_relation, defer_relation) %}\n {{ return(adapter.dispatch('create_or_replace_clone', 'dbt')(this_relation, defer_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_or_replace_clone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2697654, "supported_languages": null}, "macro.dbt.default__create_or_replace_clone": {"name": "default__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\clone\\create_or_replace_clone.sql", "original_file_path": "macros\\materializations\\models\\clone\\create_or_replace_clone.sql", "unique_id": "macro.dbt.default__create_or_replace_clone", "macro_sql": "{% macro default__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace table {{ this_relation.render() }} clone {{ defer_relation.render() }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2697654, "supported_languages": null}, "macro.dbt.get_quoted_csv": {"name": "get_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "original_file_path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "unique_id": "macro.dbt.get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.271787, "supported_languages": null}, "macro.dbt.diff_columns": {"name": "diff_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "original_file_path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "unique_id": "macro.dbt.diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.272765, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"name": "diff_column_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "original_file_path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "unique_id": "macro.dbt.diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.272765, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"name": "get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "original_file_path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "unique_id": "macro.dbt.get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2737641, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"name": "default__get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "original_file_path": "macros\\materializations\\models\\incremental\\column_helpers.sql", "unique_id": "macro.dbt.default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2737641, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"name": "materialization_incremental_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\incremental.sql", "original_file_path": "macros\\materializations\\models\\incremental\\incremental.sql", "unique_id": "macro.dbt.materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% set contract_config = config.get('contract') %}\n {% if not contract_config or not contract_config.enforced %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {% endif %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2808537, "supported_languages": ["sql"]}, "macro.dbt.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\is_incremental.sql", "original_file_path": "macros\\materializations\\models\\incremental\\is_incremental.sql", "unique_id": "macro.dbt.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2818594, "supported_languages": null}, "macro.dbt.get_merge_sql": {"name": "get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\merge.sql", "original_file_path": "macros\\materializations\\models\\incremental\\merge.sql", "unique_id": "macro.dbt.get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n -- back compat for old kwarg name\n {% set incremental_predicates = kwargs.get('predicates', incremental_predicates) %}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2888682, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"name": "default__get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\merge.sql", "original_file_path": "macros\\materializations\\models\\incremental\\merge.sql", "unique_id": "macro.dbt.default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n {%- set predicates = [] if incremental_predicates is none else [] + incremental_predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{\"(\" ~ predicates | join(\") and (\") ~ \")\"}}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2905972, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"name": "get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\merge.sql", "original_file_path": "macros\\materializations\\models\\incremental\\merge.sql", "unique_id": "macro.dbt.get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2905972, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"name": "default__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\merge.sql", "original_file_path": "macros\\materializations\\models\\incremental\\merge.sql", "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last}}\n {% endfor %}\n {% if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {% endif %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n )\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%};\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2915921, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"name": "get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\merge.sql", "original_file_path": "macros\\materializations\\models\\incremental\\merge.sql", "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.2915921, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"name": "default__get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\merge.sql", "original_file_path": "macros\\materializations\\models\\incremental\\merge.sql", "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.292587, "supported_languages": null}, "macro.dbt.incremental_validate_on_schema_change": {"name": "incremental_validate_on_schema_change", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "original_file_path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "unique_id": "macro.dbt.incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.29859, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"name": "check_for_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "original_file_path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "unique_id": "macro.dbt.check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3005812, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"name": "sync_column_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "original_file_path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "unique_id": "macro.dbt.sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3015885, "supported_languages": null}, "macro.dbt.process_schema_changes": {"name": "process_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "original_file_path": "macros\\materializations\\models\\incremental\\on_schema_change.sql", "unique_id": "macro.dbt.process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.302649, "supported_languages": null}, "macro.dbt.get_incremental_append_sql": {"name": "get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3045807, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"name": "default__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3045807, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"name": "get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3045807, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"name": "default__get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3045807, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"name": "get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.305588, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"name": "default__get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.305588, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"name": "get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.305588, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"name": "default__get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.305588, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"name": "get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3065825, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"name": "default__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3065825, "supported_languages": null}, "macro.dbt.get_incremental_microbatch_sql": {"name": "get_incremental_microbatch_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_incremental_microbatch_sql", "macro_sql": "{% macro get_incremental_microbatch_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_microbatch_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_microbatch_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3065825, "supported_languages": null}, "macro.dbt.default__get_incremental_microbatch_sql": {"name": "default__get_incremental_microbatch_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.default__get_incremental_microbatch_sql", "macro_sql": "{% macro default__get_incremental_microbatch_sql(arg_dict) %}\n\n {{ exceptions.raise_not_implemented('microbatch materialization strategy not implemented for adapter ' + adapter.type()) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3065825, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"name": "get_insert_into_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\models\\incremental\\strategies.sql", "original_file_path": "macros\\materializations\\models\\incremental\\strategies.sql", "unique_id": "macro.dbt.get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3075788, "supported_languages": null}, "macro.dbt.create_csv_table": {"name": "create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3115745, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"name": "default__create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3135774, "supported_languages": null}, "macro.dbt.reset_csv_table": {"name": "reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3135774, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"name": "default__reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation.render() %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3145719, "supported_languages": null}, "macro.dbt.get_csv_sql": {"name": "get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3145719, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"name": "default__get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3145719, "supported_languages": null}, "macro.dbt.get_binding_char": {"name": "get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3145719, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"name": "default__get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3145719, "supported_languages": null}, "macro.dbt.get_batch_size": {"name": "get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3155763, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"name": "default__get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3155763, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"name": "get_seed_column_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3155763, "supported_languages": null}, "macro.dbt.load_csv_rows": {"name": "load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3165772, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"name": "default__load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\helpers.sql", "original_file_path": "macros\\materializations\\seeds\\helpers.sql", "unique_id": "macro.dbt.default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.317594, "supported_languages": null}, "macro.dbt.materialization_seed_default": {"name": "materialization_seed_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\seeds\\seed.sql", "original_file_path": "macros\\materializations\\seeds\\seed.sql", "unique_id": "macro.dbt.materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparison later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation.render())) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3215895, "supported_languages": ["sql"]}, "macro.dbt.create_columns": {"name": "create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3255966, "supported_languages": null}, "macro.dbt.default__create_columns": {"name": "default__create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation.render() }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3274987, "supported_languages": null}, "macro.dbt.post_snapshot": {"name": "post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3274987, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"name": "default__post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3274987, "supported_languages": null}, "macro.dbt.get_true_sql": {"name": "get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.328508, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"name": "default__get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.328508, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"name": "snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.328508, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"name": "default__snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3306007, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"name": "build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3306007, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"name": "default__build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3306007, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3316088, "supported_languages": null}, "macro.dbt.get_updated_at_column_data_type": {"name": "get_updated_at_column_data_type", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.get_updated_at_column_data_type", "macro_sql": "{% macro get_updated_at_column_data_type(snapshot_sql) %}\n {% set snapshot_sql_column_schema = get_column_schema_from_query(snapshot_sql) %}\n {% set dbt_updated_at_data_type = null %}\n {% set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {% set ns.dbt_updated_at_data_type = null -%}\n {% for column in snapshot_sql_column_schema %}\n {% if ((column.column == 'dbt_updated_at') or (column.column == 'DBT_UPDATED_AT')) %}\n {% set ns.dbt_updated_at_data_type = column.dtype %}\n {% endif %}\n {% endfor %}\n {{ return(ns.dbt_updated_at_data_type or none) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3316088, "supported_languages": null}, "macro.dbt.check_time_data_types": {"name": "check_time_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\helpers.sql", "original_file_path": "macros\\materializations\\snapshots\\helpers.sql", "unique_id": "macro.dbt.check_time_data_types", "macro_sql": "{% macro check_time_data_types(sql) %}\n {% set dbt_updated_at_data_type = get_updated_at_column_data_type(sql) %}\n {% set snapshot_get_time_data_type = get_snapshot_get_time_data_type() %}\n {% if snapshot_get_time_data_type is not none and dbt_updated_at_data_type is not none and snapshot_get_time_data_type != dbt_updated_at_data_type %}\n {% if exceptions.warn_snapshot_timestamp_data_types %}\n {{ exceptions.warn_snapshot_timestamp_data_types(snapshot_get_time_data_type, dbt_updated_at_data_type) }}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_updated_at_column_data_type", "macro.dbt.get_snapshot_get_time_data_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.332489, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"name": "materialization_snapshot_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\snapshot.sql", "original_file_path": "macros\\materializations\\snapshots\\snapshot.sql", "unique_id": "macro.dbt.materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set build_or_select_sql = build_sql %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set build_or_select_sql = snapshot_staging_table(strategy, sql, target_relation) %}\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n\n {{ check_time_data_types(build_or_select_sql) }}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.snapshot_staging_table", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.check_time_data_types", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3394897, "supported_languages": ["sql"]}, "macro.dbt.snapshot_merge_sql": {"name": "snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\snapshot_merge.sql", "original_file_path": "macros\\materializations\\snapshots\\snapshot_merge.sql", "unique_id": "macro.dbt.snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3394897, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"name": "default__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\snapshot_merge.sql", "original_file_path": "macros\\materializations\\snapshots\\snapshot_merge.sql", "unique_id": "macro.dbt.default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target.render() }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3394897, "supported_languages": null}, "macro.dbt.strategy_dispatch": {"name": "strategy_dispatch", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3435745, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"name": "snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3435745, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"name": "default__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.344575, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"name": "snapshot_timestamp_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3455043, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"name": "snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3455043, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"name": "default__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3455043, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"name": "snapshot_check_all_get_existing_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n {#-- N.B. The whitespace below is necessary to avoid edge case issue with comments --#}\n {#-- See: https://github.com/dbt-labs/dbt-core/issues/6781 --#}\n select {{ check_cols_config | join(', ') }} from (\n {{ node['compiled_code'] }}\n ) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3474905, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"name": "snapshot_check_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\snapshots\\strategies.sql", "original_file_path": "macros\\materializations\\snapshots\\strategies.sql", "unique_id": "macro.dbt.snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3484898, "supported_languages": null}, "macro.dbt.get_test_sql": {"name": "get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\helpers.sql", "original_file_path": "macros\\materializations\\tests\\helpers.sql", "unique_id": "macro.dbt.get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.350488, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"name": "default__get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\helpers.sql", "original_file_path": "macros\\materializations\\tests\\helpers.sql", "unique_id": "macro.dbt.default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.350488, "supported_languages": null}, "macro.dbt.get_unit_test_sql": {"name": "get_unit_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\helpers.sql", "original_file_path": "macros\\materializations\\tests\\helpers.sql", "unique_id": "macro.dbt.get_unit_test_sql", "macro_sql": "{% macro get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}\n {{ adapter.dispatch('get_unit_test_sql', 'dbt')(main_sql, expected_fixture_sql, expected_column_names) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_unit_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.350488, "supported_languages": null}, "macro.dbt.default__get_unit_test_sql": {"name": "default__get_unit_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\helpers.sql", "original_file_path": "macros\\materializations\\tests\\helpers.sql", "unique_id": "macro.dbt.default__get_unit_test_sql", "macro_sql": "{% macro default__get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}\n-- Build actual result given inputs\nwith dbt_internal_unit_test_actual as (\n select\n {% for expected_column_name in expected_column_names %}{{expected_column_name}}{% if not loop.last -%},{% endif %}{%- endfor -%}, {{ dbt.string_literal(\"actual\") }} as {{ adapter.quote(\"actual_or_expected\") }}\n from (\n {{ main_sql }}\n ) _dbt_internal_unit_test_actual\n),\n-- Build expected result\ndbt_internal_unit_test_expected as (\n select\n {% for expected_column_name in expected_column_names %}{{expected_column_name}}{% if not loop.last -%}, {% endif %}{%- endfor -%}, {{ dbt.string_literal(\"expected\") }} as {{ adapter.quote(\"actual_or_expected\") }}\n from (\n {{ expected_fixture_sql }}\n ) _dbt_internal_unit_test_expected\n)\n-- Union actual and expected results\nselect * from dbt_internal_unit_test_actual\nunion all\nselect * from dbt_internal_unit_test_expected\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3514874, "supported_languages": null}, "macro.dbt.materialization_test_default": {"name": "materialization_test_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\test.sql", "original_file_path": "macros\\materializations\\tests\\test.sql", "unique_id": "macro.dbt.materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% set store_failures_as = config.get('store_failures_as') %}\n -- if `--store-failures` is invoked via command line and `store_failures_as` is not set,\n -- config.get('store_failures_as', 'table') returns None, not 'table'\n {% if store_failures_as == none %}{% set store_failures_as = 'table' %}{% endif %}\n {% if store_failures_as not in ['table', 'view'] %}\n {{ exceptions.raise_compiler_error(\n \"'\" ~ store_failures_as ~ \"' is not a valid value for `store_failures_as`. \"\n \"Accepted values are: ['ephemeral', 'table', 'view']\"\n ) }}\n {% endif %}\n\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type=store_failures_as) -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ get_create_sql(target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.get_create_sql", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3544896, "supported_languages": ["sql"]}, "macro.dbt.materialization_unit_default": {"name": "materialization_unit_default", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\unit.sql", "original_file_path": "macros\\materializations\\tests\\unit.sql", "unique_id": "macro.dbt.materialization_unit_default", "macro_sql": "{%- materialization unit, default -%}\n\n {% set relations = [] %}\n\n {% set expected_rows = config.get('expected_rows') %}\n {% set expected_sql = config.get('expected_sql') %}\n {% set tested_expected_column_names = expected_rows[0].keys() if (expected_rows | length ) > 0 else get_columns_in_query(sql) %} %}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {% do run_query(get_create_table_as_sql(True, temp_relation, get_empty_subquery_sql(sql))) %}\n {%- set columns_in_relation = adapter.get_columns_in_relation(temp_relation) -%}\n {%- set column_name_to_data_types = {} -%}\n {%- for column in columns_in_relation -%}\n {%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}\n {%- endfor -%}\n\n {% if not expected_sql %}\n {% set expected_sql = get_expected_sql(expected_rows, column_name_to_data_types) %}\n {% endif %}\n {% set unit_test_sql = get_unit_test_sql(sql, expected_sql, tested_expected_column_names) %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ unit_test_sql }}\n\n {%- endcall %}\n\n {% do adapter.drop_relation(temp_relation) %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt.make_temp_relation", "macro.dbt.run_query", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_empty_subquery_sql", "macro.dbt.get_expected_sql", "macro.dbt.get_unit_test_sql", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3566418, "supported_languages": ["sql"]}, "macro.dbt.get_where_subquery": {"name": "get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\where_subquery.sql", "original_file_path": "macros\\materializations\\tests\\where_subquery.sql", "unique_id": "macro.dbt.get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3566418, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"name": "default__get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros\\materializations\\tests\\where_subquery.sql", "original_file_path": "macros\\materializations\\tests\\where_subquery.sql", "unique_id": "macro.dbt.default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3577373, "supported_languages": null}, "macro.dbt.resolve_model_name": {"name": "resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.resolve_model_name", "macro_sql": "{% macro resolve_model_name(input_model_name) %}\n {{ return(adapter.dispatch('resolve_model_name', 'dbt')(input_model_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3587432, "supported_languages": null}, "macro.dbt.default__resolve_model_name": {"name": "default__resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.default__resolve_model_name", "macro_sql": "\n\n{%- macro default__resolve_model_name(input_model_name) -%}\n {{ input_model_name | string | replace('\"', '\\\"') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3587432, "supported_languages": null}, "macro.dbt.build_ref_function": {"name": "build_ref_function", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {% set _ref_args = [_ref.get('package'), _ref['name']] if _ref.get('package') else [_ref['name'],] %}\n {%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}\n {%- if _ref.get('version') -%}\n {% do _ref_args.extend([\"v\" ~ _ref['version']]) %}\n {%- endif -%}\n {%- do ref_dict.update({_ref_args | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef ref(*args, **kwargs):\n refs = {{ ref_dict | tojson }}\n key = '.'.join(args)\n version = kwargs.get(\"v\") or kwargs.get(\"version\")\n if version:\n key += f\".v{version}\"\n dbt_load_df_function = kwargs.get(\"dbt_load_df_function\")\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3597422, "supported_languages": null}, "macro.dbt.build_source_function": {"name": "build_source_function", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = '.'.join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3607323, "supported_languages": null}, "macro.dbt.build_config_dict": {"name": "build_config_dict", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {% set config_dbt_used = zip(model.config.config_keys_used, model.config.config_keys_defaults) | list %}\n {%- for key, default in config_dbt_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == \"language\" -%}\n {%- set value = \"python\" -%}\n {%- endif -%}\n {%- set value = model.config.get(key, default) -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.361752, "supported_languages": null}, "macro.dbt.py_script_postfix": {"name": "py_script_postfix", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = \"{{ this.database }}\"\n schema = \"{{ this.schema }}\"\n identifier = \"{{ this.identifier }}\"\n {% set this_relation_name = resolve_model_name(this) %}\n def __repr__(self):\n return '{{ this_relation_name }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args, **kwargs: ref(*args, **kwargs, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.resolve_model_name", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.361752, "supported_languages": null}, "macro.dbt.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros\\python_model\\python.sql", "original_file_path": "macros\\python_model\\python.sql", "unique_id": "macro.dbt.py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.361752, "supported_languages": null}, "macro.dbt.get_create_sql": {"name": "get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\create.sql", "original_file_path": "macros\\relations\\create.sql", "unique_id": "macro.dbt.get_create_sql", "macro_sql": "{%- macro get_create_sql(relation, sql) -%}\n {{- log('Applying CREATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3627365, "supported_languages": null}, "macro.dbt.default__get_create_sql": {"name": "default__get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\create.sql", "original_file_path": "macros\\relations\\create.sql", "unique_id": "macro.dbt.default__get_create_sql", "macro_sql": "{%- macro default__get_create_sql(relation, sql) -%}\n\n {%- if relation.is_view -%}\n {{ get_create_view_as_sql(relation, sql) }}\n\n {%- elif relation.is_table -%}\n {{ get_create_table_as_sql(False, relation, sql) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_create_materialized_view_as_sql(relation, sql) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_create_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.get_create_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3627365, "supported_languages": null}, "macro.dbt.get_create_backup_sql": {"name": "get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\create_backup.sql", "original_file_path": "macros\\relations\\create_backup.sql", "unique_id": "macro.dbt.get_create_backup_sql", "macro_sql": "{%- macro get_create_backup_sql(relation) -%}\n {{- log('Applying CREATE BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3637447, "supported_languages": null}, "macro.dbt.default__get_create_backup_sql": {"name": "default__get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\create_backup.sql", "original_file_path": "macros\\relations\\create_backup.sql", "unique_id": "macro.dbt.default__get_create_backup_sql", "macro_sql": "{%- macro default__get_create_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n -- drop any pre-existing backup\n {{ get_drop_sql(backup_relation) }};\n\n {{ get_rename_sql(relation, backup_relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3637447, "supported_languages": null}, "macro.dbt.get_create_intermediate_sql": {"name": "get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\create_intermediate.sql", "original_file_path": "macros\\relations\\create_intermediate.sql", "unique_id": "macro.dbt.get_create_intermediate_sql", "macro_sql": "{%- macro get_create_intermediate_sql(relation, sql) -%}\n {{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3647363, "supported_languages": null}, "macro.dbt.default__get_create_intermediate_sql": {"name": "default__get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\create_intermediate.sql", "original_file_path": "macros\\relations\\create_intermediate.sql", "unique_id": "macro.dbt.default__get_create_intermediate_sql", "macro_sql": "{%- macro default__get_create_intermediate_sql(relation, sql) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n -- drop any pre-existing intermediate\n {{ get_drop_sql(intermediate_relation) }};\n\n {{ get_create_sql(intermediate_relation, sql) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3647363, "supported_languages": null}, "macro.dbt.get_drop_sql": {"name": "get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop.sql", "original_file_path": "macros\\relations\\drop.sql", "unique_id": "macro.dbt.get_drop_sql", "macro_sql": "{%- macro get_drop_sql(relation) -%}\n {{- log('Applying DROP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3657403, "supported_languages": null}, "macro.dbt.default__get_drop_sql": {"name": "default__get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop.sql", "original_file_path": "macros\\relations\\drop.sql", "unique_id": "macro.dbt.default__get_drop_sql", "macro_sql": "{%- macro default__get_drop_sql(relation) -%}\n\n {%- if relation.is_view -%}\n {{ drop_view(relation) }}\n\n {%- elif relation.is_table -%}\n {{ drop_table(relation) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ drop_materialized_view(relation) }}\n\n {%- else -%}\n drop {{ relation.type }} if exists {{ relation.render() }} cascade\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.drop_view", "macro.dbt.drop_table", "macro.dbt.drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3657403, "supported_languages": null}, "macro.dbt.drop_relation": {"name": "drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop.sql", "original_file_path": "macros\\relations\\drop.sql", "unique_id": "macro.dbt.drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3657403, "supported_languages": null}, "macro.dbt.default__drop_relation": {"name": "default__drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop.sql", "original_file_path": "macros\\relations\\drop.sql", "unique_id": "macro.dbt.default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {{ get_drop_sql(relation) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3667438, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"name": "drop_relation_if_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop.sql", "original_file_path": "macros\\relations\\drop.sql", "unique_id": "macro.dbt.drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3667438, "supported_languages": null}, "macro.dbt.get_drop_backup_sql": {"name": "get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop_backup.sql", "original_file_path": "macros\\relations\\drop_backup.sql", "unique_id": "macro.dbt.get_drop_backup_sql", "macro_sql": "{%- macro get_drop_backup_sql(relation) -%}\n {{- log('Applying DROP BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3667438, "supported_languages": null}, "macro.dbt.default__get_drop_backup_sql": {"name": "default__get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\drop_backup.sql", "original_file_path": "macros\\relations\\drop_backup.sql", "unique_id": "macro.dbt.default__get_drop_backup_sql", "macro_sql": "{%- macro default__get_drop_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n {{ get_drop_sql(backup_relation) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3667438, "supported_languages": null}, "macro.dbt.get_rename_sql": {"name": "get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\rename.sql", "original_file_path": "macros\\relations\\rename.sql", "unique_id": "macro.dbt.get_rename_sql", "macro_sql": "{%- macro get_rename_sql(relation, new_name) -%}\n {{- log('Applying RENAME to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_sql', 'dbt')(relation, new_name) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3677468, "supported_languages": null}, "macro.dbt.default__get_rename_sql": {"name": "default__get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\rename.sql", "original_file_path": "macros\\relations\\rename.sql", "unique_id": "macro.dbt.default__get_rename_sql", "macro_sql": "{%- macro default__get_rename_sql(relation, new_name) -%}\n\n {%- if relation.is_view -%}\n {{ get_rename_view_sql(relation, new_name) }}\n\n {%- elif relation.is_table -%}\n {{ get_rename_table_sql(relation, new_name) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_rename_materialized_view_sql(relation, new_name) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_rename_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.get_rename_view_sql", "macro.dbt.get_rename_table_sql", "macro.dbt.get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3687372, "supported_languages": null}, "macro.dbt.rename_relation": {"name": "rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\rename.sql", "original_file_path": "macros\\relations\\rename.sql", "unique_id": "macro.dbt.rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3687372, "supported_languages": null}, "macro.dbt.default__rename_relation": {"name": "default__rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\rename.sql", "original_file_path": "macros\\relations\\rename.sql", "unique_id": "macro.dbt.default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation.render() }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3687372, "supported_languages": null}, "macro.dbt.get_rename_intermediate_sql": {"name": "get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\rename_intermediate.sql", "original_file_path": "macros\\relations\\rename_intermediate.sql", "unique_id": "macro.dbt.get_rename_intermediate_sql", "macro_sql": "{%- macro get_rename_intermediate_sql(relation) -%}\n {{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3697526, "supported_languages": null}, "macro.dbt.default__get_rename_intermediate_sql": {"name": "default__get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\rename_intermediate.sql", "original_file_path": "macros\\relations\\rename_intermediate.sql", "unique_id": "macro.dbt.default__get_rename_intermediate_sql", "macro_sql": "{%- macro default__get_rename_intermediate_sql(relation) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n {{ get_rename_sql(intermediate_relation, relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3697526, "supported_languages": null}, "macro.dbt.get_replace_sql": {"name": "get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\replace.sql", "original_file_path": "macros\\relations\\replace.sql", "unique_id": "macro.dbt.get_replace_sql", "macro_sql": "{% macro get_replace_sql(existing_relation, target_relation, sql) %}\n {{- log('Applying REPLACE to: ' ~ existing_relation) -}}\n {{- adapter.dispatch('get_replace_sql', 'dbt')(existing_relation, target_relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3707438, "supported_languages": null}, "macro.dbt.default__get_replace_sql": {"name": "default__get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\replace.sql", "original_file_path": "macros\\relations\\replace.sql", "unique_id": "macro.dbt.default__get_replace_sql", "macro_sql": "{% macro default__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {# /* use a create or replace statement if possible */ #}\n\n {% set is_replaceable = existing_relation.type == target_relation_type and existing_relation.can_be_replaced %}\n\n {% if is_replaceable and existing_relation.is_view %}\n {{ get_replace_view_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_table %}\n {{ get_replace_table_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_materialized_view %}\n {{ get_replace_materialized_view_sql(target_relation, sql) }}\n\n {# /* a create or replace statement is not possible, so try to stage and/or backup to be safe */ #}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}\n {%- elif target_relation.can_be_renamed and existing_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one without using a backup */ #}\n {%- elif target_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_drop_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }}\n\n {# /* create target_relation in place by first backing up the existing relation */ #}\n {%- elif existing_relation.can_be_renamed -%}\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* no renaming is allowed, so just drop and create */ #}\n {%- else -%}\n {{ get_drop_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }}\n\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_view_sql", "macro.dbt.get_replace_table_sql", "macro.dbt.get_replace_materialized_view_sql", "macro.dbt.get_create_intermediate_sql", "macro.dbt.get_create_backup_sql", "macro.dbt.get_rename_intermediate_sql", "macro.dbt.get_drop_backup_sql", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.372656, "supported_languages": null}, "macro.dbt.drop_schema_named": {"name": "drop_schema_named", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\schema.sql", "original_file_path": "macros\\relations\\schema.sql", "unique_id": "macro.dbt.drop_schema_named", "macro_sql": "{% macro drop_schema_named(schema_name) %}\n {{ return(adapter.dispatch('drop_schema_named', 'dbt') (schema_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_schema_named"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.372656, "supported_languages": null}, "macro.dbt.default__drop_schema_named": {"name": "default__drop_schema_named", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\schema.sql", "original_file_path": "macros\\relations\\schema.sql", "unique_id": "macro.dbt.default__drop_schema_named", "macro_sql": "{% macro default__drop_schema_named(schema_name) %}\n {% set schema_relation = api.Relation.create(schema=schema_name) %}\n {{ adapter.drop_schema(schema_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.372656, "supported_languages": null}, "macro.dbt.get_table_columns_and_constraints": {"name": "get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.get_table_columns_and_constraints", "macro_sql": "{%- macro get_table_columns_and_constraints() -%}\n {{ adapter.dispatch('get_table_columns_and_constraints', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3737366, "supported_languages": null}, "macro.dbt.default__get_table_columns_and_constraints": {"name": "default__get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_table_columns_and_constraints", "macro_sql": "{% macro default__get_table_columns_and_constraints() -%}\n {{ return(table_columns_and_constraints()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3737366, "supported_languages": null}, "macro.dbt.table_columns_and_constraints": {"name": "table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.table_columns_and_constraints", "macro_sql": "{% macro table_columns_and_constraints() %}\n {# loop through user_provided_columns to create DDL with data types and constraints #}\n {%- set raw_column_constraints = adapter.render_raw_columns_constraints(raw_columns=model['columns']) -%}\n {%- set raw_model_constraints = adapter.render_raw_model_constraints(raw_constraints=model['constraints']) -%}\n (\n {% for c in raw_column_constraints -%}\n {{ c }}{{ \",\" if not loop.last or raw_model_constraints }}\n {% endfor %}\n {% for c in raw_model_constraints -%}\n {{ c }}{{ \",\" if not loop.last }}\n {% endfor -%}\n )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3748226, "supported_languages": null}, "macro.dbt.get_assert_columns_equivalent": {"name": "get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.get_assert_columns_equivalent", "macro_sql": "\n\n{%- macro get_assert_columns_equivalent(sql) -%}\n {{ adapter.dispatch('get_assert_columns_equivalent', 'dbt')(sql) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3748226, "supported_languages": null}, "macro.dbt.default__get_assert_columns_equivalent": {"name": "default__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_assert_columns_equivalent", "macro_sql": "{% macro default__get_assert_columns_equivalent(sql) -%}\n {{ return(assert_columns_equivalent(sql)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3748226, "supported_languages": null}, "macro.dbt.assert_columns_equivalent": {"name": "assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.assert_columns_equivalent", "macro_sql": "{% macro assert_columns_equivalent(sql) %}\n\n {#-- First ensure the user has defined 'columns' in yaml specification --#}\n {%- set user_defined_columns = model['columns'] -%}\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {#-- Obtain the column schema provided by sql file. #}\n {%- set sql_file_provided_columns = get_column_schema_from_query(sql, config.get('sql_header', none)) -%}\n {#--Obtain the column schema provided by the schema file by generating an 'empty schema' query from the model's columns. #}\n {%- set schema_file_provided_columns = get_column_schema_from_query(get_empty_schema_sql(user_defined_columns)) -%}\n\n {#-- create dictionaries with name and formatted data type and strings for exception #}\n {%- set sql_columns = format_columns(sql_file_provided_columns) -%}\n {%- set yaml_columns = format_columns(schema_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['formatted'] != yaml_col[0]['formatted'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query", "macro.dbt.get_empty_schema_sql", "macro.dbt.format_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3768406, "supported_languages": null}, "macro.dbt.format_columns": {"name": "format_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.format_columns", "macro_sql": "{% macro format_columns(columns) %}\n {% set formatted_columns = [] %}\n {% for column in columns %}\n {%- set formatted_column = adapter.dispatch('format_column', 'dbt')(column) -%}\n {%- do formatted_columns.append(formatted_column) -%}\n {% endfor %}\n {{ return(formatted_columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3768406, "supported_languages": null}, "macro.dbt.default__format_column": {"name": "default__format_column", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\column\\columns_spec_ddl.sql", "original_file_path": "macros\\relations\\column\\columns_spec_ddl.sql", "unique_id": "macro.dbt.default__format_column", "macro_sql": "{% macro default__format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3778446, "supported_languages": null}, "macro.dbt.get_alter_materialized_view_as_sql": {"name": "get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\alter.sql", "original_file_path": "macros\\relations\\materialized_view\\alter.sql", "unique_id": "macro.dbt.get_alter_materialized_view_as_sql", "macro_sql": "{% macro get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{- log('Applying ALTER to: ' ~ relation) -}}\n {{- adapter.dispatch('get_alter_materialized_view_as_sql', 'dbt')(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n ) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.378754, "supported_languages": null}, "macro.dbt.default__get_alter_materialized_view_as_sql": {"name": "default__get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\alter.sql", "original_file_path": "macros\\relations\\materialized_view\\alter.sql", "unique_id": "macro.dbt.default__get_alter_materialized_view_as_sql", "macro_sql": "{% macro default__get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.378754, "supported_languages": null}, "macro.dbt.get_materialized_view_configuration_changes": {"name": "get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\alter.sql", "original_file_path": "macros\\relations\\materialized_view\\alter.sql", "unique_id": "macro.dbt.get_materialized_view_configuration_changes", "macro_sql": "{% macro get_materialized_view_configuration_changes(existing_relation, new_config) %}\n /* {#\n It's recommended that configuration changes be formatted as follows:\n {\"\": [{\"action\": \"\", \"context\": ...}]}\n\n For example:\n {\n \"indexes\": [\n {\"action\": \"drop\", \"context\": \"index_abc\"},\n {\"action\": \"create\", \"context\": {\"columns\": [\"column_1\", \"column_2\"], \"type\": \"hash\", \"unique\": True}},\n ],\n }\n\n Either way, `get_materialized_view_configuration_changes` needs to align with `get_alter_materialized_view_as_sql`.\n #} */\n {{- log('Determining configuration changes on: ' ~ existing_relation) -}}\n {%- do return(adapter.dispatch('get_materialized_view_configuration_changes', 'dbt')(existing_relation, new_config)) -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_materialized_view_configuration_changes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.378754, "supported_languages": null}, "macro.dbt.default__get_materialized_view_configuration_changes": {"name": "default__get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\alter.sql", "original_file_path": "macros\\relations\\materialized_view\\alter.sql", "unique_id": "macro.dbt.default__get_materialized_view_configuration_changes", "macro_sql": "{% macro default__get_materialized_view_configuration_changes(existing_relation, new_config) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.378754, "supported_languages": null}, "macro.dbt.get_create_materialized_view_as_sql": {"name": "get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\create.sql", "original_file_path": "macros\\relations\\materialized_view\\create.sql", "unique_id": "macro.dbt.get_create_materialized_view_as_sql", "macro_sql": "{% macro get_create_materialized_view_as_sql(relation, sql) -%}\n {{- adapter.dispatch('get_create_materialized_view_as_sql', 'dbt')(relation, sql) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.379847, "supported_languages": null}, "macro.dbt.default__get_create_materialized_view_as_sql": {"name": "default__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\create.sql", "original_file_path": "macros\\relations\\materialized_view\\create.sql", "unique_id": "macro.dbt.default__get_create_materialized_view_as_sql", "macro_sql": "{% macro default__get_create_materialized_view_as_sql(relation, sql) -%}\n {{ exceptions.raise_compiler_error(\n \"`get_create_materialized_view_as_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.379847, "supported_languages": null}, "macro.dbt.drop_materialized_view": {"name": "drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\drop.sql", "original_file_path": "macros\\relations\\materialized_view\\drop.sql", "unique_id": "macro.dbt.drop_materialized_view", "macro_sql": "{% macro drop_materialized_view(relation) -%}\n {{- adapter.dispatch('drop_materialized_view', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.379847, "supported_languages": null}, "macro.dbt.default__drop_materialized_view": {"name": "default__drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\drop.sql", "original_file_path": "macros\\relations\\materialized_view\\drop.sql", "unique_id": "macro.dbt.default__drop_materialized_view", "macro_sql": "{% macro default__drop_materialized_view(relation) -%}\n drop materialized view if exists {{ relation.render() }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.379847, "supported_languages": null}, "macro.dbt.refresh_materialized_view": {"name": "refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\refresh.sql", "original_file_path": "macros\\relations\\materialized_view\\refresh.sql", "unique_id": "macro.dbt.refresh_materialized_view", "macro_sql": "{% macro refresh_materialized_view(relation) %}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n {{- adapter.dispatch('refresh_materialized_view', 'dbt')(relation) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__refresh_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3808298, "supported_languages": null}, "macro.dbt.default__refresh_materialized_view": {"name": "default__refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\refresh.sql", "original_file_path": "macros\\relations\\materialized_view\\refresh.sql", "unique_id": "macro.dbt.default__refresh_materialized_view", "macro_sql": "{% macro default__refresh_materialized_view(relation) %}\n {{ exceptions.raise_compiler_error(\"`refresh_materialized_view` has not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3808298, "supported_languages": null}, "macro.dbt.get_rename_materialized_view_sql": {"name": "get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\rename.sql", "original_file_path": "macros\\relations\\materialized_view\\rename.sql", "unique_id": "macro.dbt.get_rename_materialized_view_sql", "macro_sql": "{% macro get_rename_materialized_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_materialized_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3808298, "supported_languages": null}, "macro.dbt.default__get_rename_materialized_view_sql": {"name": "default__get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\rename.sql", "original_file_path": "macros\\relations\\materialized_view\\rename.sql", "unique_id": "macro.dbt.default__get_rename_materialized_view_sql", "macro_sql": "{% macro default__get_rename_materialized_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3808298, "supported_languages": null}, "macro.dbt.get_replace_materialized_view_sql": {"name": "get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\replace.sql", "original_file_path": "macros\\relations\\materialized_view\\replace.sql", "unique_id": "macro.dbt.get_replace_materialized_view_sql", "macro_sql": "{% macro get_replace_materialized_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3818305, "supported_languages": null}, "macro.dbt.default__get_replace_materialized_view_sql": {"name": "default__get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\materialized_view\\replace.sql", "original_file_path": "macros\\relations\\materialized_view\\replace.sql", "unique_id": "macro.dbt.default__get_replace_materialized_view_sql", "macro_sql": "{% macro default__get_replace_materialized_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3818305, "supported_languages": null}, "macro.dbt.get_create_table_as_sql": {"name": "get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.382845, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"name": "default__get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.382845, "supported_languages": null}, "macro.dbt.create_table_as": {"name": "create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.382845, "supported_languages": null}, "macro.dbt.default__create_table_as": {"name": "default__create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced and (not temporary) %}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- set sql = get_select_subquery(sql) %}\n {% endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3838556, "supported_languages": null}, "macro.dbt.default__get_column_names": {"name": "default__get_column_names", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.default__get_column_names", "macro_sql": "{% macro default__get_column_names() %}\n {#- loop through user_provided_columns to get column names -#}\n {%- set user_provided_columns = model['columns'] -%}\n {%- for i in user_provided_columns %}\n {%- set col = user_provided_columns[i] -%}\n {%- set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] -%}\n {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.384833, "supported_languages": null}, "macro.dbt.get_select_subquery": {"name": "get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.get_select_subquery", "macro_sql": "{% macro get_select_subquery(sql) %}\n {{ return(adapter.dispatch('get_select_subquery', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.384833, "supported_languages": null}, "macro.dbt.default__get_select_subquery": {"name": "default__get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\create.sql", "original_file_path": "macros\\relations\\table\\create.sql", "unique_id": "macro.dbt.default__get_select_subquery", "macro_sql": "{% macro default__get_select_subquery(sql) %}\n select {{ adapter.dispatch('get_column_names', 'dbt')() }}\n from (\n {{ sql }}\n ) as model_subq\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.384833, "supported_languages": null}, "macro.dbt.drop_table": {"name": "drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\drop.sql", "original_file_path": "macros\\relations\\table\\drop.sql", "unique_id": "macro.dbt.drop_table", "macro_sql": "{% macro drop_table(relation) -%}\n {{- adapter.dispatch('drop_table', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.384833, "supported_languages": null}, "macro.dbt.default__drop_table": {"name": "default__drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\drop.sql", "original_file_path": "macros\\relations\\table\\drop.sql", "unique_id": "macro.dbt.default__drop_table", "macro_sql": "{% macro default__drop_table(relation) -%}\n drop table if exists {{ relation.render() }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3858385, "supported_languages": null}, "macro.dbt.get_rename_table_sql": {"name": "get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\rename.sql", "original_file_path": "macros\\relations\\table\\rename.sql", "unique_id": "macro.dbt.get_rename_table_sql", "macro_sql": "{% macro get_rename_table_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_table_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_rename_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3858385, "supported_languages": null}, "macro.dbt.default__get_rename_table_sql": {"name": "default__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\rename.sql", "original_file_path": "macros\\relations\\table\\rename.sql", "unique_id": "macro.dbt.default__get_rename_table_sql", "macro_sql": "{% macro default__get_rename_table_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3858385, "supported_languages": null}, "macro.dbt.get_replace_table_sql": {"name": "get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\replace.sql", "original_file_path": "macros\\relations\\table\\replace.sql", "unique_id": "macro.dbt.get_replace_table_sql", "macro_sql": "{% macro get_replace_table_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3858385, "supported_languages": null}, "macro.dbt.default__get_replace_table_sql": {"name": "default__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\table\\replace.sql", "original_file_path": "macros\\relations\\table\\replace.sql", "unique_id": "macro.dbt.default__get_replace_table_sql", "macro_sql": "{% macro default__get_replace_table_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3858385, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"name": "get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt.get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.386845, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"name": "default__get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt.default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.387764, "supported_languages": null}, "macro.dbt.create_view_as": {"name": "create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt.create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.387764, "supported_languages": null}, "macro.dbt.default__create_view_as": {"name": "default__create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\create.sql", "original_file_path": "macros\\relations\\view\\create.sql", "unique_id": "macro.dbt.default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation.render() }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.387764, "supported_languages": null}, "macro.dbt.drop_view": {"name": "drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\drop.sql", "original_file_path": "macros\\relations\\view\\drop.sql", "unique_id": "macro.dbt.drop_view", "macro_sql": "{% macro drop_view(relation) -%}\n {{- adapter.dispatch('drop_view', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3887613, "supported_languages": null}, "macro.dbt.default__drop_view": {"name": "default__drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\drop.sql", "original_file_path": "macros\\relations\\view\\drop.sql", "unique_id": "macro.dbt.default__drop_view", "macro_sql": "{% macro default__drop_view(relation) -%}\n drop view if exists {{ relation.render() }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3887613, "supported_languages": null}, "macro.dbt.get_rename_view_sql": {"name": "get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\rename.sql", "original_file_path": "macros\\relations\\view\\rename.sql", "unique_id": "macro.dbt.get_rename_view_sql", "macro_sql": "{% macro get_rename_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_rename_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3893507, "supported_languages": null}, "macro.dbt.default__get_rename_view_sql": {"name": "default__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\rename.sql", "original_file_path": "macros\\relations\\view\\rename.sql", "unique_id": "macro.dbt.default__get_rename_view_sql", "macro_sql": "{% macro default__get_rename_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3893507, "supported_languages": null}, "macro.dbt.get_replace_view_sql": {"name": "get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\replace.sql", "original_file_path": "macros\\relations\\view\\replace.sql", "unique_id": "macro.dbt.get_replace_view_sql", "macro_sql": "{% macro get_replace_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3893507, "supported_languages": null}, "macro.dbt.default__get_replace_view_sql": {"name": "default__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\replace.sql", "original_file_path": "macros\\relations\\view\\replace.sql", "unique_id": "macro.dbt.default__get_replace_view_sql", "macro_sql": "{% macro default__get_replace_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3904617, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"name": "create_or_replace_view", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\replace.sql", "original_file_path": "macros\\relations\\view\\replace.sql", "unique_id": "macro.dbt.create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3914447, "supported_languages": null}, "macro.dbt.handle_existing_table": {"name": "handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\replace.sql", "original_file_path": "macros\\relations\\view\\replace.sql", "unique_id": "macro.dbt.handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3914447, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"name": "default__handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros\\relations\\view\\replace.sql", "original_file_path": "macros\\relations\\view\\replace.sql", "unique_id": "macro.dbt.default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation.render() ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3914447, "supported_languages": null}, "macro.dbt.get_fixture_sql": {"name": "get_fixture_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\unit_test_sql\\get_fixture_sql.sql", "original_file_path": "macros\\unit_test_sql\\get_fixture_sql.sql", "unique_id": "macro.dbt.get_fixture_sql", "macro_sql": "{% macro get_fixture_sql(rows, column_name_to_data_types) %}\n-- Fixture for {{ model.name }}\n{% set default_row = {} %}\n\n{%- if not column_name_to_data_types -%}\n{#-- Use defer_relation IFF it is available in the manifest and 'this' is missing from the database --#}\n{%- set this_or_defer_relation = defer_relation if (defer_relation and not load_relation(this)) else this -%}\n{%- set columns_in_relation = adapter.get_columns_in_relation(this_or_defer_relation) -%}\n\n{%- set column_name_to_data_types = {} -%}\n{%- for column in columns_in_relation -%}\n{#-- This needs to be a case-insensitive comparison --#}\n{%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}\n{%- endfor -%}\n{%- endif -%}\n\n{%- if not column_name_to_data_types -%}\n {{ exceptions.raise_compiler_error(\"Not able to get columns for unit test '\" ~ model.name ~ \"' from relation \" ~ this ~ \" because the relation doesn't exist\") }}\n{%- endif -%}\n\n{%- for column_name, column_type in column_name_to_data_types.items() -%}\n {%- do default_row.update({column_name: (safe_cast(\"null\", column_type) | trim )}) -%}\n{%- endfor -%}\n\n{{ validate_fixture_rows(rows, row_number) }}\n\n{%- for row in rows -%}\n{%- set formatted_row = format_row(row, column_name_to_data_types) -%}\n{%- set default_row_copy = default_row.copy() -%}\n{%- do default_row_copy.update(formatted_row) -%}\nselect\n{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {%- endif %}\n{%- endfor %}\n{%- if not loop.last %}\nunion all\n{% endif %}\n{%- endfor -%}\n\n{%- if (rows | length) == 0 -%}\n select\n {%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%},{%- endif %}\n {%- endfor %}\n limit 0\n{%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_relation", "macro.dbt.safe_cast", "macro.dbt.validate_fixture_rows", "macro.dbt.format_row"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3953576, "supported_languages": null}, "macro.dbt.get_expected_sql": {"name": "get_expected_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros\\unit_test_sql\\get_fixture_sql.sql", "original_file_path": "macros\\unit_test_sql\\get_fixture_sql.sql", "unique_id": "macro.dbt.get_expected_sql", "macro_sql": "{% macro get_expected_sql(rows, column_name_to_data_types) %}\n\n{%- if (rows | length) == 0 -%}\n select * from dbt_internal_unit_test_actual\n limit 0\n{%- else -%}\n{%- for row in rows -%}\n{%- set formatted_row = format_row(row, column_name_to_data_types) -%}\nselect\n{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {%- endif %}\n{%- endfor %}\n{%- if not loop.last %}\nunion all\n{% endif %}\n{%- endfor -%}\n{%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.format_row"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3964365, "supported_languages": null}, "macro.dbt.format_row": {"name": "format_row", "resource_type": "macro", "package_name": "dbt", "path": "macros\\unit_test_sql\\get_fixture_sql.sql", "original_file_path": "macros\\unit_test_sql\\get_fixture_sql.sql", "unique_id": "macro.dbt.format_row", "macro_sql": "\n\n{%- macro format_row(row, column_name_to_data_types) -%}\n {#-- generate case-insensitive formatted row --#}\n {% set formatted_row = {} %}\n {%- for column_name, column_value in row.items() -%}\n {% set column_name = column_name|lower %}\n\n {%- if column_name not in column_name_to_data_types %}\n {#-- if user-provided row contains column name that relation does not contain, raise an error --#}\n {% set fixture_name = \"expected output\" if model.resource_type == 'unit_test' else (\"'\" ~ model.name ~ \"'\") %}\n {{ exceptions.raise_compiler_error(\n \"Invalid column name: '\" ~ column_name ~ \"' in unit test fixture for \" ~ fixture_name ~ \".\"\n \"\\nAccepted columns for \" ~ fixture_name ~ \" are: \" ~ (column_name_to_data_types.keys()|list)\n ) }}\n {%- endif -%}\n\n {%- set column_type = column_name_to_data_types[column_name] %}\n\n {#-- sanitize column_value: wrap yaml strings in quotes, apply cast --#}\n {%- set column_value_clean = column_value -%}\n {%- if column_value is string -%}\n {%- set column_value_clean = dbt.string_literal(dbt.escape_single_quotes(column_value)) -%}\n {%- elif column_value is none -%}\n {%- set column_value_clean = 'null' -%}\n {%- endif -%}\n\n {%- set row_update = {column_name: safe_cast(column_value_clean, column_type) } -%}\n {%- do formatted_row.update(row_update) -%}\n {%- endfor -%}\n {{ return(formatted_row) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.string_literal", "macro.dbt.escape_single_quotes", "macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3974683, "supported_languages": null}, "macro.dbt.validate_fixture_rows": {"name": "validate_fixture_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros\\unit_test_sql\\get_fixture_sql.sql", "original_file_path": "macros\\unit_test_sql\\get_fixture_sql.sql", "unique_id": "macro.dbt.validate_fixture_rows", "macro_sql": "{%- macro validate_fixture_rows(rows, row_number) -%}\n {{ return(adapter.dispatch('validate_fixture_rows', 'dbt')(rows, row_number)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__validate_fixture_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3974683, "supported_languages": null}, "macro.dbt.default__validate_fixture_rows": {"name": "default__validate_fixture_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros\\unit_test_sql\\get_fixture_sql.sql", "original_file_path": "macros\\unit_test_sql\\get_fixture_sql.sql", "unique_id": "macro.dbt.default__validate_fixture_rows", "macro_sql": "{%- macro default__validate_fixture_rows(rows, row_number) -%}\n {# This is an abstract method for adapter overrides as needed #}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3974683, "supported_languages": null}, "macro.dbt.any_value": {"name": "any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\any_value.sql", "original_file_path": "macros\\utils\\any_value.sql", "unique_id": "macro.dbt.any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3984497, "supported_languages": null}, "macro.dbt.default__any_value": {"name": "default__any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\any_value.sql", "original_file_path": "macros\\utils\\any_value.sql", "unique_id": "macro.dbt.default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3984497, "supported_languages": null}, "macro.dbt.array_append": {"name": "array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\array_append.sql", "original_file_path": "macros\\utils\\array_append.sql", "unique_id": "macro.dbt.array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3984497, "supported_languages": null}, "macro.dbt.default__array_append": {"name": "default__array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\array_append.sql", "original_file_path": "macros\\utils\\array_append.sql", "unique_id": "macro.dbt.default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.3984497, "supported_languages": null}, "macro.dbt.array_concat": {"name": "array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\array_concat.sql", "original_file_path": "macros\\utils\\array_concat.sql", "unique_id": "macro.dbt.array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.399445, "supported_languages": null}, "macro.dbt.default__array_concat": {"name": "default__array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\array_concat.sql", "original_file_path": "macros\\utils\\array_concat.sql", "unique_id": "macro.dbt.default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.399445, "supported_languages": null}, "macro.dbt.array_construct": {"name": "array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\array_construct.sql", "original_file_path": "macros\\utils\\array_construct.sql", "unique_id": "macro.dbt.array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.399445, "supported_languages": null}, "macro.dbt.default__array_construct": {"name": "default__array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\array_construct.sql", "original_file_path": "macros\\utils\\array_construct.sql", "unique_id": "macro.dbt.default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.400446, "supported_languages": null}, "macro.dbt.bool_or": {"name": "bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\bool_or.sql", "original_file_path": "macros\\utils\\bool_or.sql", "unique_id": "macro.dbt.bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.400446, "supported_languages": null}, "macro.dbt.default__bool_or": {"name": "default__bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\bool_or.sql", "original_file_path": "macros\\utils\\bool_or.sql", "unique_id": "macro.dbt.default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.400446, "supported_languages": null}, "macro.dbt.cast": {"name": "cast", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\cast.sql", "original_file_path": "macros\\utils\\cast.sql", "unique_id": "macro.dbt.cast", "macro_sql": "{% macro cast(field, type) %}\n {{ return(adapter.dispatch('cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.400446, "supported_languages": null}, "macro.dbt.default__cast": {"name": "default__cast", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\cast.sql", "original_file_path": "macros\\utils\\cast.sql", "unique_id": "macro.dbt.default__cast", "macro_sql": "{% macro default__cast(field, type) %}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.400446, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"name": "cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\cast_bool_to_text.sql", "original_file_path": "macros\\utils\\cast_bool_to_text.sql", "unique_id": "macro.dbt.cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.401444, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"name": "default__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\cast_bool_to_text.sql", "original_file_path": "macros\\utils\\cast_bool_to_text.sql", "unique_id": "macro.dbt.default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.401444, "supported_languages": null}, "macro.dbt.concat": {"name": "concat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\concat.sql", "original_file_path": "macros\\utils\\concat.sql", "unique_id": "macro.dbt.concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.401444, "supported_languages": null}, "macro.dbt.default__concat": {"name": "default__concat", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\concat.sql", "original_file_path": "macros\\utils\\concat.sql", "unique_id": "macro.dbt.default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.401444, "supported_languages": null}, "macro.dbt.type_string": {"name": "type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.403365, "supported_languages": null}, "macro.dbt.default__type_string": {"name": "default__type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.403365, "supported_languages": null}, "macro.dbt.type_timestamp": {"name": "type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.403365, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"name": "default__type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.403365, "supported_languages": null}, "macro.dbt.type_float": {"name": "type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4043574, "supported_languages": null}, "macro.dbt.default__type_float": {"name": "default__type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4043574, "supported_languages": null}, "macro.dbt.type_numeric": {"name": "type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4043574, "supported_languages": null}, "macro.dbt.default__type_numeric": {"name": "default__type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4043574, "supported_languages": null}, "macro.dbt.type_bigint": {"name": "type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4043574, "supported_languages": null}, "macro.dbt.default__type_bigint": {"name": "default__type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4043574, "supported_languages": null}, "macro.dbt.type_int": {"name": "type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4054394, "supported_languages": null}, "macro.dbt.default__type_int": {"name": "default__type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4054394, "supported_languages": null}, "macro.dbt.type_boolean": {"name": "type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4054394, "supported_languages": null}, "macro.dbt.default__type_boolean": {"name": "default__type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\data_types.sql", "original_file_path": "macros\\utils\\data_types.sql", "unique_id": "macro.dbt.default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4054394, "supported_languages": null}, "macro.dbt.date": {"name": "date", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date.sql", "original_file_path": "macros\\utils\\date.sql", "unique_id": "macro.dbt.date", "macro_sql": "{% macro date(year, month, day) %}\n {{ return(adapter.dispatch('date', 'dbt') (year, month, day)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4054394, "supported_languages": null}, "macro.dbt.default__date": {"name": "default__date", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date.sql", "original_file_path": "macros\\utils\\date.sql", "unique_id": "macro.dbt.default__date", "macro_sql": "{% macro default__date(year, month, day) -%}\n {%- set dt = modules.datetime.date(year, month, day) -%}\n {%- set iso_8601_formatted_date = dt.strftime('%Y-%m-%d') -%}\n to_date('{{ iso_8601_formatted_date }}', 'YYYY-MM-DD')\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4064415, "supported_languages": null}, "macro.dbt.dateadd": {"name": "dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\dateadd.sql", "original_file_path": "macros\\utils\\dateadd.sql", "unique_id": "macro.dbt.dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4064415, "supported_languages": null}, "macro.dbt.default__dateadd": {"name": "default__dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\dateadd.sql", "original_file_path": "macros\\utils\\dateadd.sql", "unique_id": "macro.dbt.default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4064415, "supported_languages": null}, "macro.dbt.datediff": {"name": "datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\datediff.sql", "original_file_path": "macros\\utils\\datediff.sql", "unique_id": "macro.dbt.datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4074447, "supported_languages": null}, "macro.dbt.default__datediff": {"name": "default__datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\datediff.sql", "original_file_path": "macros\\utils\\datediff.sql", "unique_id": "macro.dbt.default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4074447, "supported_languages": null}, "macro.dbt.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date_spine.sql", "original_file_path": "macros\\utils\\date_spine.sql", "unique_id": "macro.dbt.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4084554, "supported_languages": null}, "macro.dbt.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date_spine.sql", "original_file_path": "macros\\utils\\date_spine.sql", "unique_id": "macro.dbt.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4084554, "supported_languages": null}, "macro.dbt.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date_spine.sql", "original_file_path": "macros\\utils\\date_spine.sql", "unique_id": "macro.dbt.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4094512, "supported_languages": null}, "macro.dbt.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date_spine.sql", "original_file_path": "macros\\utils\\date_spine.sql", "unique_id": "macro.dbt.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n {# call as follows:\n\n date_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n ) #}\n\n\n with rawdata as (\n\n {{dbt.generate_series(\n dbt.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n ),\n\n all_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n ),\n\n filtered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n )\n\n select * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_series", "macro.dbt.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4094512, "supported_languages": null}, "macro.dbt.date_trunc": {"name": "date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date_trunc.sql", "original_file_path": "macros\\utils\\date_trunc.sql", "unique_id": "macro.dbt.date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4094512, "supported_languages": null}, "macro.dbt.default__date_trunc": {"name": "default__date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\date_trunc.sql", "original_file_path": "macros\\utils\\date_trunc.sql", "unique_id": "macro.dbt.default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4104483, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"name": "escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\escape_single_quotes.sql", "original_file_path": "macros\\utils\\escape_single_quotes.sql", "unique_id": "macro.dbt.escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4104483, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"name": "default__escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\escape_single_quotes.sql", "original_file_path": "macros\\utils\\escape_single_quotes.sql", "unique_id": "macro.dbt.default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4104483, "supported_languages": null}, "macro.dbt.except": {"name": "except", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\except.sql", "original_file_path": "macros\\utils\\except.sql", "unique_id": "macro.dbt.except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4104483, "supported_languages": null}, "macro.dbt.default__except": {"name": "default__except", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\except.sql", "original_file_path": "macros\\utils\\except.sql", "unique_id": "macro.dbt.default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4104483, "supported_languages": null}, "macro.dbt.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\generate_series.sql", "original_file_path": "macros\\utils\\generate_series.sql", "unique_id": "macro.dbt.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.411445, "supported_languages": null}, "macro.dbt.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\generate_series.sql", "original_file_path": "macros\\utils\\generate_series.sql", "unique_id": "macro.dbt.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4124599, "supported_languages": null}, "macro.dbt.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\generate_series.sql", "original_file_path": "macros\\utils\\generate_series.sql", "unique_id": "macro.dbt.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4124599, "supported_languages": null}, "macro.dbt.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\generate_series.sql", "original_file_path": "macros\\utils\\generate_series.sql", "unique_id": "macro.dbt.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4134548, "supported_languages": null}, "macro.dbt.hash": {"name": "hash", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\hash.sql", "original_file_path": "macros\\utils\\hash.sql", "unique_id": "macro.dbt.hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4134548, "supported_languages": null}, "macro.dbt.default__hash": {"name": "default__hash", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\hash.sql", "original_file_path": "macros\\utils\\hash.sql", "unique_id": "macro.dbt.default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4134548, "supported_languages": null}, "macro.dbt.intersect": {"name": "intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\intersect.sql", "original_file_path": "macros\\utils\\intersect.sql", "unique_id": "macro.dbt.intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4134548, "supported_languages": null}, "macro.dbt.default__intersect": {"name": "default__intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\intersect.sql", "original_file_path": "macros\\utils\\intersect.sql", "unique_id": "macro.dbt.default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4134548, "supported_languages": null}, "macro.dbt.last_day": {"name": "last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\last_day.sql", "original_file_path": "macros\\utils\\last_day.sql", "unique_id": "macro.dbt.last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4144516, "supported_languages": null}, "macro.dbt.default_last_day": {"name": "default_last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\last_day.sql", "original_file_path": "macros\\utils\\last_day.sql", "unique_id": "macro.dbt.default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4144516, "supported_languages": null}, "macro.dbt.default__last_day": {"name": "default__last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\last_day.sql", "original_file_path": "macros\\utils\\last_day.sql", "unique_id": "macro.dbt.default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4144516, "supported_languages": null}, "macro.dbt.length": {"name": "length", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\length.sql", "original_file_path": "macros\\utils\\length.sql", "unique_id": "macro.dbt.length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.415452, "supported_languages": null}, "macro.dbt.default__length": {"name": "default__length", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\length.sql", "original_file_path": "macros\\utils\\length.sql", "unique_id": "macro.dbt.default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.415452, "supported_languages": null}, "macro.dbt.listagg": {"name": "listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\listagg.sql", "original_file_path": "macros\\utils\\listagg.sql", "unique_id": "macro.dbt.listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.415452, "supported_languages": null}, "macro.dbt.default__listagg": {"name": "default__listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\listagg.sql", "original_file_path": "macros\\utils\\listagg.sql", "unique_id": "macro.dbt.default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.416451, "supported_languages": null}, "macro.dbt.string_literal": {"name": "string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\literal.sql", "original_file_path": "macros\\utils\\literal.sql", "unique_id": "macro.dbt.string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.416451, "supported_languages": null}, "macro.dbt.default__string_literal": {"name": "default__string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\literal.sql", "original_file_path": "macros\\utils\\literal.sql", "unique_id": "macro.dbt.default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.416451, "supported_languages": null}, "macro.dbt.position": {"name": "position", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\position.sql", "original_file_path": "macros\\utils\\position.sql", "unique_id": "macro.dbt.position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.417458, "supported_languages": null}, "macro.dbt.default__position": {"name": "default__position", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\position.sql", "original_file_path": "macros\\utils\\position.sql", "unique_id": "macro.dbt.default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.417458, "supported_languages": null}, "macro.dbt.replace": {"name": "replace", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\replace.sql", "original_file_path": "macros\\utils\\replace.sql", "unique_id": "macro.dbt.replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.417458, "supported_languages": null}, "macro.dbt.default__replace": {"name": "default__replace", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\replace.sql", "original_file_path": "macros\\utils\\replace.sql", "unique_id": "macro.dbt.default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.417458, "supported_languages": null}, "macro.dbt.right": {"name": "right", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\right.sql", "original_file_path": "macros\\utils\\right.sql", "unique_id": "macro.dbt.right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4184523, "supported_languages": null}, "macro.dbt.default__right": {"name": "default__right", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\right.sql", "original_file_path": "macros\\utils\\right.sql", "unique_id": "macro.dbt.default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4184523, "supported_languages": null}, "macro.dbt.safe_cast": {"name": "safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\safe_cast.sql", "original_file_path": "macros\\utils\\safe_cast.sql", "unique_id": "macro.dbt.safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.419361, "supported_languages": null}, "macro.dbt.default__safe_cast": {"name": "default__safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\safe_cast.sql", "original_file_path": "macros\\utils\\safe_cast.sql", "unique_id": "macro.dbt.default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.419361, "supported_languages": null}, "macro.dbt.split_part": {"name": "split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\split_part.sql", "original_file_path": "macros\\utils\\split_part.sql", "unique_id": "macro.dbt.split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.419361, "supported_languages": null}, "macro.dbt.default__split_part": {"name": "default__split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\split_part.sql", "original_file_path": "macros\\utils\\split_part.sql", "unique_id": "macro.dbt.default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4204354, "supported_languages": null}, "macro.dbt._split_part_negative": {"name": "_split_part_negative", "resource_type": "macro", "package_name": "dbt", "path": "macros\\utils\\split_part.sql", "original_file_path": "macros\\utils\\split_part.sql", "unique_id": "macro.dbt._split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 + {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4204354, "supported_languages": null}, "macro.dbt.test_unique": {"name": "test_unique", "resource_type": "macro", "package_name": "dbt", "path": "tests\\generic\\builtin.sql", "original_file_path": "tests\\generic\\builtin.sql", "unique_id": "macro.dbt.test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4204354, "supported_languages": null}, "macro.dbt.test_not_null": {"name": "test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "tests\\generic\\builtin.sql", "original_file_path": "tests\\generic\\builtin.sql", "unique_id": "macro.dbt.test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4214473, "supported_languages": null}, "macro.dbt.test_accepted_values": {"name": "test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "tests\\generic\\builtin.sql", "original_file_path": "tests\\generic\\builtin.sql", "unique_id": "macro.dbt.test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4214473, "supported_languages": null}, "macro.dbt.test_relationships": {"name": "test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "tests\\generic\\builtin.sql", "original_file_path": "tests\\generic\\builtin.sql", "unique_id": "macro.dbt.test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4224458, "supported_languages": null}, "macro.dbt_utils.test_accepted_range": {"name": "test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\accepted_range.sql", "original_file_path": "macros\\generic_tests\\accepted_range.sql", "unique_id": "macro.dbt_utils.test_accepted_range", "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_accepted_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4224458, "supported_languages": null}, "macro.dbt_utils.default__test_accepted_range": {"name": "default__test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\accepted_range.sql", "original_file_path": "macros\\generic_tests\\accepted_range.sql", "unique_id": "macro.dbt_utils.default__test_accepted_range", "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.423445, "supported_languages": null}, "macro.dbt_utils.test_at_least_one": {"name": "test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\at_least_one.sql", "original_file_path": "macros\\generic_tests\\at_least_one.sql", "unique_id": "macro.dbt_utils.test_at_least_one", "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_at_least_one"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4244425, "supported_languages": null}, "macro.dbt_utils.default__test_at_least_one": {"name": "default__test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\at_least_one.sql", "original_file_path": "macros\\generic_tests\\at_least_one.sql", "unique_id": "macro.dbt_utils.default__test_at_least_one", "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% set pruned_cols = [column_name] %}\n\n{% if group_by_columns|length() > 0 %}\n\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n {% set pruned_cols = group_by_columns %}\n\n {% if column_name not in pruned_cols %}\n {% do pruned_cols.append(column_name) %}\n {% endif %}\n\n{% endif %}\n\n{% set select_pruned_cols = pruned_cols|join(' ,') %}\n\nselect *\nfrom (\n with pruned_rows as (\n select\n {{ select_pruned_cols }}\n from {{ model }}\n {% if group_by_columns|length() == 0 %}\n where {{ column_name }} is not null\n limit 1\n {% endif %}\n )\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from pruned_rows\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.425451, "supported_languages": null}, "macro.dbt_utils.test_cardinality_equality": {"name": "test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\cardinality_equality.sql", "original_file_path": "macros\\generic_tests\\cardinality_equality.sql", "unique_id": "macro.dbt_utils.test_cardinality_equality", "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_cardinality_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.425451, "supported_languages": null}, "macro.dbt_utils.default__test_cardinality_equality": {"name": "default__test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\cardinality_equality.sql", "original_file_path": "macros\\generic_tests\\cardinality_equality.sql", "unique_id": "macro.dbt_utils.default__test_cardinality_equality", "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4264457, "supported_languages": null}, "macro.dbt_utils.test_equality": {"name": "test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\equality.sql", "original_file_path": "macros\\generic_tests\\equality.sql", "unique_id": "macro.dbt_utils.test_equality", "macro_sql": "{% test equality(model, compare_model, compare_columns=None, exclude_columns=None, precision = None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns, exclude_columns, precision)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4274511, "supported_languages": null}, "macro.dbt_utils.default__test_equality": {"name": "default__test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\equality.sql", "original_file_path": "macros\\generic_tests\\equality.sql", "unique_id": "macro.dbt_utils.default__test_equality", "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None, exclude_columns=None, precision = None) %}\n\n{%- if compare_columns and exclude_columns -%}\n {{ exceptions.raise_compiler_error(\"Both a compare and an ignore list were provided to the `equality` macro. Only one is allowed\") }}\n{%- endif -%}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{# Ensure there are no extra columns in the compare_model vs model #}\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- do dbt_utils._is_ephemeral(compare_model, 'test_equality') -%}\n\n {%- set model_columns = adapter.get_columns_in_relation(model) -%}\n {%- set compare_model_columns = adapter.get_columns_in_relation(compare_model) -%}\n\n\n {%- if exclude_columns -%}\n {#-- Lower case ignore columns for easier comparison --#}\n {%- set exclude_columns = exclude_columns | map(\"lower\") | list %}\n\n {# Filter out the excluded columns #}\n {%- set include_columns = [] %}\n {%- set include_model_columns = [] %}\n {%- for column in model_columns -%}\n {%- if column.name | lower not in exclude_columns -%}\n {% do include_columns.append(column) %}\n {%- endif %}\n {%- endfor %}\n {%- for column in compare_model_columns -%}\n {%- if column.name | lower not in exclude_columns -%}\n {% do include_model_columns.append(column) %}\n {%- endif %}\n {%- endfor %}\n\n {%- set compare_columns_set = set(include_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- set compare_model_columns_set = set(include_model_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- else -%}\n {%- set compare_columns_set = set(model_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- set compare_model_columns_set = set(compare_model_columns | map(attribute='quoted') | map(\"lower\")) %}\n {%- endif -%}\n\n {% if compare_columns_set != compare_model_columns_set %}\n {{ exceptions.raise_compiler_error(compare_model ~\" has less columns than \" ~ model ~ \", please ensure they have the same columns or use the `compare_columns` or `exclude_columns` arguments to subset them.\") }}\n {% endif %}\n\n\n{% endif %}\n\n{%- if not precision -%}\n {%- if not compare_columns -%}\n {# \n You cannot get the columns in an ephemeral model (due to not existing in the information schema),\n so if the user does not provide an explicit list of columns we must error in the case it is ephemeral\n #}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model)-%}\n\n {%- if exclude_columns -%}\n {#-- Lower case ignore columns for easier comparison --#}\n {%- set exclude_columns = exclude_columns | map(\"lower\") | list %}\n\n {# Filter out the excluded columns #}\n {%- set include_columns = [] %}\n {%- for column in compare_columns -%}\n {%- if column.name | lower not in exclude_columns -%}\n {% do include_columns.append(column) %}\n {%- endif %}\n {%- endfor %}\n\n {%- set compare_columns = include_columns | map(attribute='quoted') %}\n {%- else -%} {# Compare columns provided #}\n {%- set compare_columns = compare_columns | map(attribute='quoted') %}\n {%- endif -%}\n {%- endif -%}\n\n {% set compare_cols_csv = compare_columns | join(', ') %}\n\n{% else %} {# Precision required #}\n {#-\n If rounding is required, we need to get the types, so it cannot be ephemeral even if they provide column names\n -#}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set columns = adapter.get_columns_in_relation(model) -%}\n\n {% set columns_list = [] %}\n {%- for col in columns -%}\n {%- if (\n (col.name|lower in compare_columns|map('lower') or not compare_columns) and\n (col.name|lower not in exclude_columns|map('lower') or not exclude_columns)\n ) -%}\n {# Databricks double type is not picked up by any number type checks in dbt #}\n {%- if col.is_float() or col.is_numeric() or col.data_type == 'double' -%}\n {# Cast is required due to postgres not having round for a double precision number #}\n {%- do columns_list.append('round(cast(' ~ col.quoted ~ ' as ' ~ dbt.type_numeric() ~ '),' ~ precision ~ ') as ' ~ col.quoted) -%}\n {%- else -%} {# Non-numeric type #}\n {%- do columns_list.append(col.quoted) -%}\n {%- endif -%}\n {% endif %}\n {%- endfor -%}\n\n {% set compare_cols_csv = columns_list | join(', ') %}\n\n{% endif %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_numeric", "macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4324527, "supported_languages": null}, "macro.dbt_utils.test_equal_rowcount": {"name": "test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\equal_rowcount.sql", "original_file_path": "macros\\generic_tests\\equal_rowcount.sql", "unique_id": "macro.dbt_utils.test_equal_rowcount", "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equal_rowcount"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4334514, "supported_languages": null}, "macro.dbt_utils.default__test_equal_rowcount": {"name": "default__test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\equal_rowcount.sql", "original_file_path": "macros\\generic_tests\\equal_rowcount.sql", "unique_id": "macro.dbt_utils.default__test_equal_rowcount", "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4344509, "supported_languages": null}, "macro.dbt_utils.test_expression_is_true": {"name": "test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\expression_is_true.sql", "original_file_path": "macros\\generic_tests\\expression_is_true.sql", "unique_id": "macro.dbt_utils.test_expression_is_true", "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4354465, "supported_languages": null}, "macro.dbt_utils.default__test_expression_is_true": {"name": "default__test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\expression_is_true.sql", "original_file_path": "macros\\generic_tests\\expression_is_true.sql", "unique_id": "macro.dbt_utils.default__test_expression_is_true", "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4354465, "supported_languages": null}, "macro.dbt_utils.test_fewer_rows_than": {"name": "test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\fewer_rows_than.sql", "original_file_path": "macros\\generic_tests\\fewer_rows_than.sql", "unique_id": "macro.dbt_utils.test_fewer_rows_than", "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_fewer_rows_than"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4364412, "supported_languages": null}, "macro.dbt_utils.default__test_fewer_rows_than": {"name": "default__test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\fewer_rows_than.sql", "original_file_path": "macros\\generic_tests\\fewer_rows_than.sql", "unique_id": "macro.dbt_utils.default__test_fewer_rows_than", "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4384477, "supported_languages": null}, "macro.dbt_utils.test_mutually_exclusive_ranges": {"name": "test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\mutually_exclusive_ranges.sql", "original_file_path": "macros\\generic_tests\\mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_mutually_exclusive_ranges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.441447, "supported_languages": null}, "macro.dbt_utils.default__test_mutually_exclusive_ranges": {"name": "default__test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\mutually_exclusive_ranges.sql", "original_file_path": "macros\\generic_tests\\mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4424548, "supported_languages": null}, "macro.dbt_utils.test_not_accepted_values": {"name": "test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_accepted_values.sql", "original_file_path": "macros\\generic_tests\\not_accepted_values.sql", "unique_id": "macro.dbt_utils.test_not_accepted_values", "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4434574, "supported_languages": null}, "macro.dbt_utils.default__test_not_accepted_values": {"name": "default__test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_accepted_values.sql", "original_file_path": "macros\\generic_tests\\not_accepted_values.sql", "unique_id": "macro.dbt_utils.default__test_not_accepted_values", "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4434574, "supported_languages": null}, "macro.dbt_utils.test_not_constant": {"name": "test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_constant.sql", "original_file_path": "macros\\generic_tests\\not_constant.sql", "unique_id": "macro.dbt_utils.test_not_constant", "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_constant"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4444556, "supported_languages": null}, "macro.dbt_utils.default__test_not_constant": {"name": "default__test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_constant.sql", "original_file_path": "macros\\generic_tests\\not_constant.sql", "unique_id": "macro.dbt_utils.default__test_not_constant", "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4444556, "supported_languages": null}, "macro.dbt_utils.test_not_empty_string": {"name": "test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_empty_string.sql", "original_file_path": "macros\\generic_tests\\not_empty_string.sql", "unique_id": "macro.dbt_utils.test_not_empty_string", "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_empty_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.44545, "supported_languages": null}, "macro.dbt_utils.default__test_not_empty_string": {"name": "default__test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_empty_string.sql", "original_file_path": "macros\\generic_tests\\not_empty_string.sql", "unique_id": "macro.dbt_utils.default__test_not_empty_string", "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.44545, "supported_languages": null}, "macro.dbt_utils.test_not_null_proportion": {"name": "test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_null_proportion.sql", "original_file_path": "macros\\generic_tests\\not_null_proportion.sql", "unique_id": "macro.dbt_utils.test_not_null_proportion", "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_null_proportion"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.44646, "supported_languages": null}, "macro.dbt_utils.default__test_not_null_proportion": {"name": "default__test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\not_null_proportion.sql", "original_file_path": "macros\\generic_tests\\not_null_proportion.sql", "unique_id": "macro.dbt_utils.default__test_not_null_proportion", "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as {{ dbt.type_numeric() }}) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4474485, "supported_languages": null}, "macro.dbt_utils.test_recency": {"name": "test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\recency.sql", "original_file_path": "macros\\generic_tests\\recency.sql", "unique_id": "macro.dbt_utils.test_recency", "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_recency"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4484544, "supported_languages": null}, "macro.dbt_utils.default__test_recency": {"name": "default__test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\recency.sql", "original_file_path": "macros\\generic_tests\\recency.sql", "unique_id": "macro.dbt_utils.default__test_recency", "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.current_timestamp", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.449454, "supported_languages": null}, "macro.dbt_utils.test_relationships_where": {"name": "test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\relationships_where.sql", "original_file_path": "macros\\generic_tests\\relationships_where.sql", "unique_id": "macro.dbt_utils.test_relationships_where", "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_relationships_where"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4504488, "supported_languages": null}, "macro.dbt_utils.default__test_relationships_where": {"name": "default__test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\relationships_where.sql", "original_file_path": "macros\\generic_tests\\relationships_where.sql", "unique_id": "macro.dbt_utils.default__test_relationships_where", "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4514096, "supported_languages": null}, "macro.dbt_utils.test_sequential_values": {"name": "test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\sequential_values.sql", "original_file_path": "macros\\generic_tests\\sequential_values.sql", "unique_id": "macro.dbt_utils.test_sequential_values", "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_sequential_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4514096, "supported_languages": null}, "macro.dbt_utils.default__test_sequential_values": {"name": "default__test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\sequential_values.sql", "original_file_path": "macros\\generic_tests\\sequential_values.sql", "unique_id": "macro.dbt_utils.default__test_sequential_values", "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.slugify", "macro.dbt.type_timestamp", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4524446, "supported_languages": null}, "macro.dbt_utils.test_unique_combination_of_columns": {"name": "test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\unique_combination_of_columns.sql", "original_file_path": "macros\\generic_tests\\unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.test_unique_combination_of_columns", "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_unique_combination_of_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.45344, "supported_languages": null}, "macro.dbt_utils.default__test_unique_combination_of_columns": {"name": "default__test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\generic_tests\\unique_combination_of_columns.sql", "original_file_path": "macros\\generic_tests\\unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.454444, "supported_languages": null}, "macro.dbt_utils.log_info": {"name": "log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\log_info.sql", "original_file_path": "macros\\jinja_helpers\\log_info.sql", "unique_id": "macro.dbt_utils.log_info", "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__log_info"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.454444, "supported_languages": null}, "macro.dbt_utils.default__log_info": {"name": "default__log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\log_info.sql", "original_file_path": "macros\\jinja_helpers\\log_info.sql", "unique_id": "macro.dbt_utils.default__log_info", "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.454444, "supported_languages": null}, "macro.dbt_utils.pretty_log_format": {"name": "pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\pretty_log_format.sql", "original_file_path": "macros\\jinja_helpers\\pretty_log_format.sql", "unique_id": "macro.dbt_utils.pretty_log_format", "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4554536, "supported_languages": null}, "macro.dbt_utils.default__pretty_log_format": {"name": "default__pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\pretty_log_format.sql", "original_file_path": "macros\\jinja_helpers\\pretty_log_format.sql", "unique_id": "macro.dbt_utils.default__pretty_log_format", "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4554536, "supported_languages": null}, "macro.dbt_utils.pretty_time": {"name": "pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\pretty_time.sql", "original_file_path": "macros\\jinja_helpers\\pretty_time.sql", "unique_id": "macro.dbt_utils.pretty_time", "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4554536, "supported_languages": null}, "macro.dbt_utils.default__pretty_time": {"name": "default__pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\pretty_time.sql", "original_file_path": "macros\\jinja_helpers\\pretty_time.sql", "unique_id": "macro.dbt_utils.default__pretty_time", "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4554536, "supported_languages": null}, "macro.dbt_utils.slugify": {"name": "slugify", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\slugify.sql", "original_file_path": "macros\\jinja_helpers\\slugify.sql", "unique_id": "macro.dbt_utils.slugify", "macro_sql": "{% macro slugify(string) %}\n\n{% if not string %}\n{{ return('') }}\n{% endif %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4564478, "supported_languages": null}, "macro.dbt_utils._is_ephemeral": {"name": "_is_ephemeral", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\_is_ephemeral.sql", "original_file_path": "macros\\jinja_helpers\\_is_ephemeral.sql", "unique_id": "macro.dbt_utils._is_ephemeral", "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.457445, "supported_languages": null}, "macro.dbt_utils._is_relation": {"name": "_is_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\jinja_helpers\\_is_relation.sql", "original_file_path": "macros\\jinja_helpers\\_is_relation.sql", "unique_id": "macro.dbt_utils._is_relation", "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4584415, "supported_languages": null}, "macro.dbt_utils.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\date_spine.sql", "original_file_path": "macros\\sql\\date_spine.sql", "unique_id": "macro.dbt_utils.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4584415, "supported_languages": null}, "macro.dbt_utils.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\date_spine.sql", "original_file_path": "macros\\sql\\date_spine.sql", "unique_id": "macro.dbt_utils.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4594529, "supported_languages": null}, "macro.dbt_utils.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\date_spine.sql", "original_file_path": "macros\\sql\\date_spine.sql", "unique_id": "macro.dbt_utils.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4594529, "supported_languages": null}, "macro.dbt_utils.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\date_spine.sql", "original_file_path": "macros\\sql\\date_spine.sql", "unique_id": "macro.dbt_utils.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.generate_series", "macro.dbt_utils.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4604464, "supported_languages": null}, "macro.dbt_utils.deduplicate": {"name": "deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.deduplicate", "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.snowflake__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.461463, "supported_languages": null}, "macro.dbt_utils.default__deduplicate": {"name": "default__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.default__deduplicate", "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.461463, "supported_languages": null}, "macro.dbt_utils.redshift__deduplicate": {"name": "redshift__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.redshift__deduplicate", "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }} as tt\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.461463, "supported_languages": null}, "macro.dbt_utils.postgres__deduplicate": {"name": "postgres__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.postgres__deduplicate", "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.461463, "supported_languages": null}, "macro.dbt_utils.snowflake__deduplicate": {"name": "snowflake__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.snowflake__deduplicate", "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4624448, "supported_languages": null}, "macro.dbt_utils.databricks__deduplicate": {"name": "databricks__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.databricks__deduplicate", "macro_sql": "\n{%- macro databricks__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4624448, "supported_languages": null}, "macro.dbt_utils.bigquery__deduplicate": {"name": "bigquery__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\deduplicate.sql", "original_file_path": "macros\\sql\\deduplicate.sql", "unique_id": "macro.dbt_utils.bigquery__deduplicate", "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4624448, "supported_languages": null}, "macro.dbt_utils.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\generate_series.sql", "original_file_path": "macros\\sql\\generate_series.sql", "unique_id": "macro.dbt_utils.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4634466, "supported_languages": null}, "macro.dbt_utils.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\generate_series.sql", "original_file_path": "macros\\sql\\generate_series.sql", "unique_id": "macro.dbt_utils.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4634466, "supported_languages": null}, "macro.dbt_utils.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\generate_series.sql", "original_file_path": "macros\\sql\\generate_series.sql", "unique_id": "macro.dbt_utils.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4644578, "supported_languages": null}, "macro.dbt_utils.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\generate_series.sql", "original_file_path": "macros\\sql\\generate_series.sql", "unique_id": "macro.dbt_utils.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4644578, "supported_languages": null}, "macro.dbt_utils.generate_surrogate_key": {"name": "generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\generate_surrogate_key.sql", "original_file_path": "macros\\sql\\generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.generate_surrogate_key", "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.465458, "supported_languages": null}, "macro.dbt_utils.default__generate_surrogate_key": {"name": "default__generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\generate_surrogate_key.sql", "original_file_path": "macros\\sql\\generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.default__generate_surrogate_key", "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%}\n {%- set default_null_value = \"\" -%}\n{%- else -%}\n {%- set default_null_value = '_dbt_utils_surrogate_key_null_' -%}\n{%- endif -%}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.hash", "macro.dbt.concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.465458, "supported_languages": null}, "macro.dbt_utils.get_column_values": {"name": "get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_column_values.sql", "original_file_path": "macros\\sql\\get_column_values.sql", "unique_id": "macro.dbt_utils.get_column_values", "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_column_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4674442, "supported_languages": null}, "macro.dbt_utils.default__get_column_values": {"name": "default__get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_column_values.sql", "original_file_path": "macros\\sql\\get_column_values.sql", "unique_id": "macro.dbt_utils.default__get_column_values", "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_ephemeral", "macro.dbt.load_relation", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4694417, "supported_languages": null}, "macro.dbt_utils.get_filtered_columns_in_relation": {"name": "get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_filtered_columns_in_relation.sql", "original_file_path": "macros\\sql\\get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4704468, "supported_languages": null}, "macro.dbt_utils.default__get_filtered_columns_in_relation": {"name": "default__get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_filtered_columns_in_relation.sql", "original_file_path": "macros\\sql\\get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4714441, "supported_languages": null}, "macro.dbt_utils.get_query_results_as_dict": {"name": "get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_query_results_as_dict.sql", "original_file_path": "macros\\sql\\get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.get_query_results_as_dict", "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_query_results_as_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4714441, "supported_languages": null}, "macro.dbt_utils.default__get_query_results_as_dict": {"name": "default__get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_query_results_as_dict.sql", "original_file_path": "macros\\sql\\get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.default__get_query_results_as_dict", "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.472445, "supported_languages": null}, "macro.dbt_utils.get_relations_by_pattern": {"name": "get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_relations_by_pattern.sql", "original_file_path": "macros\\sql\\get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.get_relations_by_pattern", "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.472445, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_pattern": {"name": "default__get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_relations_by_pattern.sql", "original_file_path": "macros\\sql\\get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_pattern", "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4734423, "supported_languages": null}, "macro.dbt_utils.get_relations_by_prefix": {"name": "get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_relations_by_prefix.sql", "original_file_path": "macros\\sql\\get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.get_relations_by_prefix", "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_prefix"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4745364, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_prefix": {"name": "default__get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_relations_by_prefix.sql", "original_file_path": "macros\\sql\\get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_prefix", "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4755452, "supported_languages": null}, "macro.dbt_utils.get_single_value": {"name": "get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_single_value.sql", "original_file_path": "macros\\sql\\get_single_value.sql", "unique_id": "macro.dbt_utils.get_single_value", "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_single_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.47655, "supported_languages": null}, "macro.dbt_utils.default__get_single_value": {"name": "default__get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_single_value.sql", "original_file_path": "macros\\sql\\get_single_value.sql", "unique_id": "macro.dbt_utils.default__get_single_value", "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.47655, "supported_languages": null}, "macro.dbt_utils.get_tables_by_pattern_sql": {"name": "get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_pattern_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4795413, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_pattern_sql": {"name": "default__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_pattern_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4805477, "supported_languages": null}, "macro.dbt_utils.redshift__get_tables_by_pattern_sql": {"name": "redshift__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_pattern_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.redshift__get_tables_by_pattern_sql", "macro_sql": "{% macro redshift__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% set sql %}\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from \"{{ database }}\".\"information_schema\".\"tables\"\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n union all\n select distinct\n schemaname as {{ adapter.quote('table_schema') }},\n tablename as {{ adapter.quote('table_name') }},\n 'external' as {{ adapter.quote('table_type') }}\n from svv_external_tables\n where redshift_database_name = '{{ database }}'\n and schemaname ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n {% endset %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4805477, "supported_languages": null}, "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": {"name": "bigquery__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_pattern_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._bigquery__get_matching_schemata", "macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.481546, "supported_languages": null}, "macro.dbt_utils._bigquery__get_matching_schemata": {"name": "_bigquery__get_matching_schemata", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_pattern_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.482548, "supported_languages": null}, "macro.dbt_utils.get_tables_by_prefix_sql": {"name": "get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_prefix_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4835286, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_prefix_sql": {"name": "default__get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_tables_by_prefix_sql.sql", "original_file_path": "macros\\sql\\get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4845355, "supported_languages": null}, "macro.dbt_utils.get_table_types_sql": {"name": "get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_table_types_sql.sql", "original_file_path": "macros\\sql\\get_table_types_sql.sql", "unique_id": "macro.dbt_utils.get_table_types_sql", "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_utils.default__get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4845355, "supported_languages": null}, "macro.dbt_utils.default__get_table_types_sql": {"name": "default__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_table_types_sql.sql", "original_file_path": "macros\\sql\\get_table_types_sql.sql", "unique_id": "macro.dbt_utils.default__get_table_types_sql", "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4845355, "supported_languages": null}, "macro.dbt_utils.postgres__get_table_types_sql": {"name": "postgres__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_table_types_sql.sql", "original_file_path": "macros\\sql\\get_table_types_sql.sql", "unique_id": "macro.dbt_utils.postgres__get_table_types_sql", "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.485531, "supported_languages": null}, "macro.dbt_utils.databricks__get_table_types_sql": {"name": "databricks__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\get_table_types_sql.sql", "original_file_path": "macros\\sql\\get_table_types_sql.sql", "unique_id": "macro.dbt_utils.databricks__get_table_types_sql", "macro_sql": "{% macro databricks__get_table_types_sql() %}\n case table_type\n when 'MANAGED' then 'table'\n when 'BASE TABLE' then 'table'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.485531, "supported_languages": null}, "macro.dbt_utils.group_by": {"name": "group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\groupby.sql", "original_file_path": "macros\\sql\\groupby.sql", "unique_id": "macro.dbt_utils.group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.485531, "supported_languages": null}, "macro.dbt_utils.default__group_by": {"name": "default__group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\groupby.sql", "original_file_path": "macros\\sql\\groupby.sql", "unique_id": "macro.dbt_utils.default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4865432, "supported_languages": null}, "macro.dbt_utils.degrees_to_radians": {"name": "degrees_to_radians", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\haversine_distance.sql", "original_file_path": "macros\\sql\\haversine_distance.sql", "unique_id": "macro.dbt_utils.degrees_to_radians", "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4875338, "supported_languages": null}, "macro.dbt_utils.haversine_distance": {"name": "haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\haversine_distance.sql", "original_file_path": "macros\\sql\\haversine_distance.sql", "unique_id": "macro.dbt_utils.haversine_distance", "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__haversine_distance"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4875338, "supported_languages": null}, "macro.dbt_utils.default__haversine_distance": {"name": "default__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\haversine_distance.sql", "original_file_path": "macros\\sql\\haversine_distance.sql", "unique_id": "macro.dbt_utils.default__haversine_distance", "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4891286, "supported_languages": null}, "macro.dbt_utils.bigquery__haversine_distance": {"name": "bigquery__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\haversine_distance.sql", "original_file_path": "macros\\sql\\haversine_distance.sql", "unique_id": "macro.dbt_utils.bigquery__haversine_distance", "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.degrees_to_radians"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4902241, "supported_languages": null}, "macro.dbt_utils.nullcheck": {"name": "nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\nullcheck.sql", "original_file_path": "macros\\sql\\nullcheck.sql", "unique_id": "macro.dbt_utils.nullcheck", "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4902241, "supported_languages": null}, "macro.dbt_utils.default__nullcheck": {"name": "default__nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\nullcheck.sql", "original_file_path": "macros\\sql\\nullcheck.sql", "unique_id": "macro.dbt_utils.default__nullcheck", "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4912252, "supported_languages": null}, "macro.dbt_utils.nullcheck_table": {"name": "nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\nullcheck_table.sql", "original_file_path": "macros\\sql\\nullcheck_table.sql", "unique_id": "macro.dbt_utils.nullcheck_table", "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4912252, "supported_languages": null}, "macro.dbt_utils.default__nullcheck_table": {"name": "default__nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\nullcheck_table.sql", "original_file_path": "macros\\sql\\nullcheck_table.sql", "unique_id": "macro.dbt_utils.default__nullcheck_table", "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4912252, "supported_languages": null}, "macro.dbt_utils.pivot": {"name": "pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\pivot.sql", "original_file_path": "macros\\sql\\pivot.sql", "unique_id": "macro.dbt_utils.pivot", "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.492225, "supported_languages": null}, "macro.dbt_utils.default__pivot": {"name": "default__pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\pivot.sql", "original_file_path": "macros\\sql\\pivot.sql", "unique_id": "macro.dbt_utils.default__pivot", "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.escape_single_quotes", "macro.dbt_utils.slugify"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.493225, "supported_languages": null}, "macro.dbt_utils.safe_add": {"name": "safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\safe_add.sql", "original_file_path": "macros\\sql\\safe_add.sql", "unique_id": "macro.dbt_utils.safe_add", "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_add"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4942381, "supported_languages": null}, "macro.dbt_utils.default__safe_add": {"name": "default__safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\safe_add.sql", "original_file_path": "macros\\sql\\safe_add.sql", "unique_id": "macro.dbt_utils.default__safe_add", "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4942381, "supported_languages": null}, "macro.dbt_utils.safe_divide": {"name": "safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\safe_divide.sql", "original_file_path": "macros\\sql\\safe_divide.sql", "unique_id": "macro.dbt_utils.safe_divide", "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_divide"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4952292, "supported_languages": null}, "macro.dbt_utils.default__safe_divide": {"name": "default__safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\safe_divide.sql", "original_file_path": "macros\\sql\\safe_divide.sql", "unique_id": "macro.dbt_utils.default__safe_divide", "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4952292, "supported_languages": null}, "macro.dbt_utils.safe_subtract": {"name": "safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\safe_subtract.sql", "original_file_path": "macros\\sql\\safe_subtract.sql", "unique_id": "macro.dbt_utils.safe_subtract", "macro_sql": "{%- macro safe_subtract(field_list) -%}\n {{ return(adapter.dispatch('safe_subtract', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_subtract"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4952292, "supported_languages": null}, "macro.dbt_utils.default__safe_subtract": {"name": "default__safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\safe_subtract.sql", "original_file_path": "macros\\sql\\safe_subtract.sql", "unique_id": "macro.dbt_utils.default__safe_subtract", "macro_sql": "\n\n{%- macro default__safe_subtract(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_subtract` macro takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' -\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4962292, "supported_languages": null}, "macro.dbt_utils.star": {"name": "star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\star.sql", "original_file_path": "macros\\sql\\star.sql", "unique_id": "macro.dbt_utils.star", "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__star"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4972339, "supported_languages": null}, "macro.dbt_utils.default__star": {"name": "default__star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\star.sql", "original_file_path": "macros\\sql\\star.sql", "unique_id": "macro.dbt_utils.default__star", "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.4992404, "supported_languages": null}, "macro.dbt_utils.surrogate_key": {"name": "surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\surrogate_key.sql", "original_file_path": "macros\\sql\\surrogate_key.sql", "unique_id": "macro.dbt_utils.surrogate_key", "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5002236, "supported_languages": null}, "macro.dbt_utils.default__surrogate_key": {"name": "default__surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\surrogate_key.sql", "original_file_path": "macros\\sql\\surrogate_key.sql", "unique_id": "macro.dbt_utils.default__surrogate_key", "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5002236, "supported_languages": null}, "macro.dbt_utils.union_relations": {"name": "union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\union.sql", "original_file_path": "macros\\sql\\union.sql", "unique_id": "macro.dbt_utils.union_relations", "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__union_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.503229, "supported_languages": null}, "macro.dbt_utils.default__union_relations": {"name": "default__union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\union.sql", "original_file_path": "macros\\sql\\union.sql", "unique_id": "macro.dbt_utils.default__union_relations", "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.string_literal", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5072286, "supported_languages": null}, "macro.dbt_utils.unpivot": {"name": "unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\unpivot.sql", "original_file_path": "macros\\sql\\unpivot.sql", "unique_id": "macro.dbt_utils.unpivot", "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', quote_identifiers=False) -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name, quote_identifiers)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__unpivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.508238, "supported_languages": null}, "macro.dbt_utils.default__unpivot": {"name": "default__unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\unpivot.sql", "original_file_path": "macros\\sql\\unpivot.sql", "unique_id": "macro.dbt_utils.default__unpivot", "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', quote_identifiers=False) -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n {%- set current_col_name = adapter.quote(col.column) if quote_identifiers else col.column -%}\n select\n {%- for exclude_col in exclude %}\n {{ adapter.quote(exclude_col) if quote_identifiers else exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ adapter.quote(field_name) if quote_identifiers else field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(current_col_name) }}\n {% else %}\n {{ current_col_name }}\n {% endif %}\n as {{ cast_to }}) as {{ adapter.quote(value_name) if quote_identifiers else value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_string", "macro.dbt.cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5102243, "supported_languages": null}, "macro.dbt_utils.width_bucket": {"name": "width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\width_bucket.sql", "original_file_path": "macros\\sql\\width_bucket.sql", "unique_id": "macro.dbt_utils.width_bucket", "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.snowflake__width_bucket"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5112283, "supported_languages": null}, "macro.dbt_utils.default__width_bucket": {"name": "default__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\width_bucket.sql", "original_file_path": "macros\\sql\\width_bucket.sql", "unique_id": "macro.dbt_utils.default__width_bucket", "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5122323, "supported_languages": null}, "macro.dbt_utils.snowflake__width_bucket": {"name": "snowflake__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\sql\\width_bucket.sql", "original_file_path": "macros\\sql\\width_bucket.sql", "unique_id": "macro.dbt_utils.snowflake__width_bucket", "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5122323, "supported_languages": null}, "macro.dbt_utils.get_url_host": {"name": "get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\web\\get_url_host.sql", "original_file_path": "macros\\web\\get_url_host.sql", "unique_id": "macro.dbt_utils.get_url_host", "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_host"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5122323, "supported_languages": null}, "macro.dbt_utils.default__get_url_host": {"name": "default__get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\web\\get_url_host.sql", "original_file_path": "macros\\web\\get_url_host.sql", "unique_id": "macro.dbt_utils.default__get_url_host", "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part", "macro.dbt.replace", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.513238, "supported_languages": null}, "macro.dbt_utils.get_url_parameter": {"name": "get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\web\\get_url_parameter.sql", "original_file_path": "macros\\web\\get_url_parameter.sql", "unique_id": "macro.dbt_utils.get_url_parameter", "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_parameter"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.513238, "supported_languages": null}, "macro.dbt_utils.default__get_url_parameter": {"name": "default__get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\web\\get_url_parameter.sql", "original_file_path": "macros\\web\\get_url_parameter.sql", "unique_id": "macro.dbt_utils.default__get_url_parameter", "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.514224, "supported_languages": null}, "macro.dbt_utils.get_url_path": {"name": "get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\web\\get_url_path.sql", "original_file_path": "macros\\web\\get_url_path.sql", "unique_id": "macro.dbt_utils.get_url_path", "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_path"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.514224, "supported_languages": null}, "macro.dbt_utils.default__get_url_path": {"name": "default__get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros\\web\\get_url_path.sql", "original_file_path": "macros\\web\\get_url_path.sql", "unique_id": "macro.dbt_utils.default__get_url_path", "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.position", "macro.dbt.split_part", "macro.dbt.right", "macro.dbt.length", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.515227, "supported_languages": null}, "macro.the_tuva_project.apply_regex": {"name": "apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.apply_regex", "macro_sql": "{%- macro apply_regex(column_name, regex) -%}\r\n\r\n {{ return(adapter.dispatch('apply_regex')(column_name, regex)) }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.the_tuva_project.snowflake__apply_regex"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5162177, "supported_languages": null}, "macro.the_tuva_project.default__apply_regex": {"name": "default__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.default__apply_regex", "macro_sql": "{%- macro default__apply_regex(column_name, regex) -%}\r\n\r\n regexp_like({{ column_name }}, '{{ regex}}')\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5162177, "supported_languages": null}, "macro.the_tuva_project.snowflake__apply_regex": {"name": "snowflake__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.snowflake__apply_regex", "macro_sql": "{%- macro snowflake__apply_regex(column_name, regex) -%}\r\n\r\n regexp_like({{ column_name }}, '{{ regex }}')\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5162177, "supported_languages": null}, "macro.the_tuva_project.bigquery__apply_regex": {"name": "bigquery__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.bigquery__apply_regex", "macro_sql": "{%- macro bigquery__apply_regex(column_name, regex) -%}\r\n\r\n regexp_contains({{ column_name }}, r'{{ regex }}')\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5162177, "supported_languages": null}, "macro.the_tuva_project.postgres__apply_regex": {"name": "postgres__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.postgres__apply_regex", "macro_sql": "{%- macro postgres__apply_regex(column_name, regex) -%}\r\n\r\n {{ column_name }} similar to '{{ regex }}'\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5162177, "supported_languages": null}, "macro.the_tuva_project.redshift__apply_regex": {"name": "redshift__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.redshift__apply_regex", "macro_sql": "{%- macro redshift__apply_regex(column_name, regex) -%}\r\n\r\n {{ column_name }} similar to '{{ regex }}'\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5172238, "supported_languages": null}, "macro.the_tuva_project.duckdb__apply_regex": {"name": "duckdb__apply_regex", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\apply_regex.sql", "original_file_path": "macros\\apply_regex.sql", "unique_id": "macro.the_tuva_project.duckdb__apply_regex", "macro_sql": "{%- macro duckdb__apply_regex(column_name, regex) -%}\r\n\r\n regexp_matches({{ column_name }}, '{{ regex }}')\r\n\r\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5172238, "supported_languages": null}, "macro.the_tuva_project.date_part": {"name": "date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\date_part.sql", "original_file_path": "macros\\date_part.sql", "unique_id": "macro.the_tuva_project.date_part", "macro_sql": "{% macro date_part(datepart, date) -%}\r\n {{ adapter.dispatch('date_part') (datepart, date) }}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.default__date_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5172238, "supported_languages": null}, "macro.the_tuva_project.default__date_part": {"name": "default__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\date_part.sql", "original_file_path": "macros\\date_part.sql", "unique_id": "macro.the_tuva_project.default__date_part", "macro_sql": "{% macro default__date_part(datepart, date) -%}\r\n date_part('{{ datepart }}', {{ date }})\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5172238, "supported_languages": null}, "macro.the_tuva_project.bigquery__date_part": {"name": "bigquery__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\date_part.sql", "original_file_path": "macros\\date_part.sql", "unique_id": "macro.the_tuva_project.bigquery__date_part", "macro_sql": "{% macro bigquery__date_part(datepart, date) -%}\r\n extract({{ datepart }} from {{ date }})\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5182295, "supported_languages": null}, "macro.the_tuva_project.athena__date_part": {"name": "athena__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\date_part.sql", "original_file_path": "macros\\date_part.sql", "unique_id": "macro.the_tuva_project.athena__date_part", "macro_sql": "{% macro athena__date_part(datepart, date) -%}\r\n extract({{ datepart }} from {{ date }})\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5182295, "supported_languages": null}, "macro.the_tuva_project.fabric__date_part": {"name": "fabric__date_part", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\date_part.sql", "original_file_path": "macros\\date_part.sql", "unique_id": "macro.the_tuva_project.fabric__date_part", "macro_sql": "{% macro fabric__date_part(datepart, date) %}\r\n {% if datepart == 'year' %}\r\n YEAR({{ date }})\r\n {% elif datepart == 'month' %}\r\n MONTH({{ date }})\r\n {% else %}\r\n NULL\r\n {% endif %}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5182295, "supported_languages": null}, "macro.the_tuva_project.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\generate_schema_name.sql", "original_file_path": "macros\\generate_schema_name.sql", "unique_id": "macro.the_tuva_project.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\r\n {%- set default_schema = target.schema -%}\r\n {%- if custom_schema_name is not none -%}\r\n {{ custom_schema_name | trim }}\r\n {%- else -%}\r\n {{ default_schema }}\r\n {%- endif -%}\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5182295, "supported_languages": null}, "macro.the_tuva_project.get_selected_seeds": {"name": "get_selected_seeds", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\get_selected_seeds.sql", "original_file_path": "macros\\get_selected_seeds.sql", "unique_id": "macro.the_tuva_project.get_selected_seeds", "macro_sql": "{% macro get_selected_seeds() %}\r\n{% if execute %}\r\n {% set nodes = graph.nodes.values() %}\r\n {% set selected_nodes = selected_resources %}\r\n {% set ns = namespace(selected_seeds=[]) %}\r\n\r\n {% for node in nodes %}\r\n {% if node.resource_type == 'seed' and node.unique_id in selected_nodes and node.package_name in['the_tuva_project','tuva','integration_tests'] %}\r\n {% if adapter.config.quoting.database %}\r\n {% set db =adapter.quote(node.database) %}\r\n {% else %}\r\n {% set db = node.database %}\r\n {% endif %}\r\n {% if adapter.config.quoting.schema %}\r\n {% set sch =adapter.quote(node.schema) %}\r\n {% else %}\r\n {% set sch = node.schema %}\r\n {% endif %}\r\n {% if adapter.config.quoting.identifier %}\r\n {% set idf =adapter.quote(node.alias) %}\r\n {% else %}\r\n {% set idf = node.alias %}\r\n {% endif %}\r\n {% set fully_qualified_name = db ~ '.' ~ sch ~ '.' ~ idf %}\r\n\r\n {% do ns.selected_seeds.append(fully_qualified_name) %}\r\n {% endif %}\r\n {% endfor %}\r\n\r\n {{ return(ns.selected_seeds) }}\r\n{% else %}\r\n {{ return([]) }}\r\n{% endif %}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.521228, "supported_languages": null}, "macro.the_tuva_project.limit_zero": {"name": "limit_zero", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\limit_zero.sql", "original_file_path": "macros\\limit_zero.sql", "unique_id": "macro.the_tuva_project.limit_zero", "macro_sql": "{% macro limit_zero() -%}\r\n {% if adapter.type == 'fabric' %}\r\n {# No limit for Fabric #}\r\n {{ return('') }}\r\n {% else %}\r\n {{ adapter.dispatch('limit_zero')() }}\r\n {% endif %}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.default__limit_zero"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.521228, "supported_languages": null}, "macro.the_tuva_project.default__limit_zero": {"name": "default__limit_zero", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\limit_zero.sql", "original_file_path": "macros\\limit_zero.sql", "unique_id": "macro.the_tuva_project.default__limit_zero", "macro_sql": "{% macro default__limit_zero() -%}\r\n limit 0\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.521228, "supported_languages": null}, "macro.the_tuva_project.fabric__limit_zero": {"name": "fabric__limit_zero", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\limit_zero.sql", "original_file_path": "macros\\limit_zero.sql", "unique_id": "macro.the_tuva_project.fabric__limit_zero", "macro_sql": "{% macro fabric__limit_zero() -%}\r\n {# No limit statement for Fabric #}\r\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.521228, "supported_languages": null}, "macro.the_tuva_project.load_seed": {"name": "load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.load_seed", "macro_sql": "{% macro load_seed(uri,pattern,compression=false,headers=false,null_marker=false) %}\r\n{{ return(adapter.dispatch('load_seed', 'the_tuva_project')(uri,pattern,compression,headers,null_marker)) }}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.snowflake__load_seed"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5252357, "supported_languages": null}, "macro.the_tuva_project.duckdb__load_seed": {"name": "duckdb__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.duckdb__load_seed", "macro_sql": "{% macro duckdb__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{%- set columns = adapter.get_columns_in_relation(this) -%}\r\n{%- set collist = [] -%}\r\n\r\n{% for col in columns %}\r\n {% do collist.append(\"'\" ~col.name~\"'\" ~ \": \" ~ \"'\"~col.dtype~\"'\") %}\r\n{% endfor %}\r\n\r\n{%- set cols = collist|join(',') -%}\r\n{# { log( cols,true) } #}\r\n\r\n{% set sql %}\r\n create or replace table {{this}} as\r\n select\r\n *\r\n from\r\n read_csv('s3://{{ uri }}/{{ pattern }}*',\r\n {% if null_marker == true %} nullstr = '\\N' {% else %} nullstr = '' {% endif %},\r\n header=true,\r\n columns= { {{ cols }} } )\r\n\r\n{% endset %}\r\n\r\n{% call statement('ducksql',fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% if execute %}\r\n{# debugging { log(sql, True)} #}\r\n{% set results = load_result('ducksql') %}\r\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ uri ,True) }}\r\n{# debugging { log(results, True) } #}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5262406, "supported_languages": null}, "macro.the_tuva_project.redshift__load_seed": {"name": "redshift__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.redshift__load_seed", "macro_sql": "{% macro redshift__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{% set sql %}\r\n\r\n{% set access_key_part_1 = 'AKIA2EPVN' %}\r\n{% set access_key_part_2 = 'TV4GFRR5377' %}\r\n\r\n{% set secret_key_part_1 = 'refUFvpX0ekY6CKEBEM' %}\r\n{% set secret_key_part_2 = '7BBfwDm/aUwSmmqX/Updi' %}\r\n\r\n{% set full_access_key = access_key_part_1 ~ access_key_part_2 %}\r\n{% set full_secret_key = secret_key_part_1 ~ secret_key_part_2 %}\r\n\r\ncopy {{ this }}\r\n from 's3://{{ uri }}/{{ pattern }}'\r\n access_key_id '{{ full_access_key }}'\r\n secret_access_key '{{ full_secret_key }}'\r\n csv\r\n {% if compression == true %} gzip {% else %} {% endif %}\r\n {% if headers == true %} ignoreheader 1 {% else %} {% endif %}\r\n emptyasnull\r\n region 'us-east-1'\r\n\r\n{% endset %}\r\n\r\n{% call statement('redsql',fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% if execute %}\r\n{# debugging { log(sql, True)} #}\r\n{% set results = load_result('redsql') %}\r\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ uri ,True) }}\r\n{# debugging { log(results, True) } #}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5282462, "supported_languages": null}, "macro.the_tuva_project.athena__load_seed": {"name": "athena__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.athena__load_seed", "macro_sql": "{% macro athena__load_seed(uri, pattern, compression, headers, null_marker) %}\r\n {% if execute %}\r\n {% do adapter.load_tuva_seed(this, uri, pattern, compression, headers, null_marker) %}\r\n {% endif %}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5282462, "supported_languages": null}, "macro.the_tuva_project.snowflake__load_seed": {"name": "snowflake__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.snowflake__load_seed", "macro_sql": "{% macro snowflake__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{% set sql %}\r\ncopy into {{ this }}\r\n from s3://{{ uri }}\r\n file_format = (type = CSV\r\n {% if compression == true %} compression = 'GZIP' {% else %} compression = 'none' {% endif %}\r\n {% if headers == true %} skip_header = 1 {% else %} {% endif %}\r\n empty_field_as_null = true\r\n field_optionally_enclosed_by = '\"'\r\n)\r\npattern = '.*\\/{{pattern}}.*';\r\n{% endset %}\r\n{% call statement('snowsql',fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% if execute %}\r\n{# debugging { log(sql, True)} #}\r\n{% set results = load_result('snowsql') %}\r\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ uri ~ \"/\" ~ pattern ~ \"*\\n rows: \" ~ results['data']|sum(attribute=2),True) }}\r\n{# debugging { log(results, True)} #}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.529233, "supported_languages": null}, "macro.the_tuva_project.bigquery__load_seed": {"name": "bigquery__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.bigquery__load_seed", "macro_sql": "{% macro bigquery__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{%- set columns = adapter.get_columns_in_relation(this) -%}\r\n{%- set collist = [] -%}\r\n\r\n{% for col in columns %}\r\n {% do collist.append(col.name ~ \" \" ~ col.dtype) %}\r\n{% endfor %}\r\n\r\n{%- set cols = collist|join(',') -%}\r\n{# { log( cols,true) } #}\r\n{% set sql %}\r\nload data into {{ this }} ( {{collist|join(',')}} )\r\nfrom files (format = 'csv',\r\n uris = ['gs://{{ uri }}/{{ pattern }}*'],\r\n {% if compression == true %} compression = 'GZIP', {% else %} {% endif %}\r\n {% if headers == true %} skip_leading_rows = 1, {% else %} {% endif %}\r\n {% if null_marker == true %} null_marker = '\\\\N', {% else %} {% endif %}\r\n quote = '\"',\r\n allow_quoted_newlines = True\r\n )\r\n{% endset %}\r\n\r\n{% call statement('bigsql',fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% if execute %}\r\n{# { log(sql, True) } #}\r\n{% set results = load_result('bigsql') %}\r\n{{ log(\"Loaded data from external gs resource\\n loaded to: \" ~ this ~ \"\\n from: gs://\" ~ uri ~ \"/\" ~ pattern ~ \"*\",True) }}\r\n{# log(results, True) #}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5302317, "supported_languages": null}, "macro.the_tuva_project.databricks__load_seed": {"name": "databricks__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.databricks__load_seed", "macro_sql": "{% macro databricks__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{% if execute %}\r\n\r\n{%- set s3_path = 's3://' ~ uri ~ '/' -%}\r\n{%- set columns = adapter.get_columns_in_relation(this) -%}\r\n{%- set collist = [] -%}\r\n\r\n{% for col in columns %}\r\n {% do collist.append(\"_c\" ~ loop.index0 ~ \"::\" ~ col.dtype ~ \" AS \" ~ col.name ) %}\r\n{% endfor %}\r\n\r\n{%- set cols = collist|join(',\\n ') -%}\r\n\r\n{% set sql %}\r\nCOPY INTO {{ this }}\r\nFROM (\r\n SELECT\r\n {{ cols }}\r\n\r\n FROM '{{ s3_path }}'\r\n {% if env_var('AWS_SESSION_TOKEN', False) %}\r\n WITH (\r\n CREDENTIAL (\r\n AWS_ACCESS_KEY = \"{{ env_var('AWS_ACCESS_KEY_ID') }}\",\r\n AWS_SECRET_KEY = \"{{ env_var('AWS_SECRET_ACCESS_KEY') }}\",\r\n AWS_SESSION_TOKEN = \"{{ env_var('AWS_SESSION_TOKEN') }}\"\r\n )\r\n )\r\n {% endif %}\r\n)\r\nFILEFORMAT = CSV\r\nPATTERN = '{{ pattern }}*'\r\nFORMAT_OPTIONS (\r\n {% if headers == true %} 'skipRows' = '1', {% else %} 'skipRows' = '0', {% endif %}\r\n {% if null_marker == true %} 'nullValue' = '\\\\N', {% else %} {% endif %}\r\n 'enforceSchema' = 'false',\r\n 'inferSchema' = 'false',\r\n 'sep' = ',',\r\n 'escape' = \"\\\"\",\r\n 'multiline' = 'true'\r\n)\r\nCOPY_OPTIONS (\r\n 'mergeSchema' = 'false',\r\n 'force' = 'true'\r\n)\r\n{% endset %}\r\n\r\n{# check logs/dbt.log for output #}\r\n{{ log(cols, info=False) }}\r\n{{ log('Current model: ' ~ this ~ '\\n', info=False) }}\r\n{{ log('Full s3 path: ' ~ s3_path ~ '\\n', info=False) }}\r\n{{ log(sql, info=False) }}\r\n\r\n{% call statement('databrickssql',fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% set results = load_result('databrickssql') %}\r\n{% set rows_affected = results['data'][0][0] %}\r\n\r\n{{ log(results, info=False) }}\r\n{{ log(rows_affected, info=False) }}\r\n\r\n{{ log(\"Loaded data from external s3 resource:\", True) }}\r\n{{ log(\" source: \\t\" ~ s3_path ~ pattern, True) }}\r\n{{ log(\" target: \\t\" ~ this | replace('`',''), True) }}\r\n{{ log(\" rows: \\t\\033[92m\" ~ rows_affected ~ \"\\033[0m\", True) }}\r\n\r\n{% endif %}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.53323, "supported_languages": null}, "macro.the_tuva_project.postgres__load_seed": {"name": "postgres__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.postgres__load_seed", "macro_sql": "{% macro postgres__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{%- set columns = adapter.get_columns_in_relation(this) -%}\r\n{%- set collist = [] -%}\r\n{%- for col in columns -%}\r\n {%- do collist.append(col.name) -%}\r\n{%- endfor -%}\r\n{%- set cols = collist|join(\",\") -%}\r\n\r\n{%- set s3_bucket = var(\"tuva_seeds_s3_bucket\", uri.split(\"/\")[0]) -%}\r\n{%- set s3_key = uri.split(\"/\")[1:]|join(\"/\") + \"/\" + pattern + \"_0.csv.gz\" -%}\r\n{%- if var(\"tuva_seeds_s3_key_prefix\", \"\") != \"\" -%}\r\n{%- set s3_key = var(\"tuva_seeds_s3_key_prefix\") + \"/\" + s3_key -%}\r\n{%- endif -%}\r\n{%- set s3_region = \"us-east-1\" -%}\r\n{%- set options = [\"(\", \"format csv\", \", encoding ''utf8''\"] -%}\r\n{%- do options.append(\", null ''\\\\N''\") if null_marker == true -%}\r\n{%- do options.append(\")\") -%}\r\n{%- set options_s = options | join(\"\") -%}\r\n\r\n{% set sql %}\r\nSELECT aws_s3.table_import_from_s3(\r\n '{{ this }}',\r\n '{{ cols }}',\r\n '{{ options_s }}',\r\n aws_commons.create_s3_uri('{{s3_bucket}}', '{{s3_key}}', '{{s3_region}}')\r\n)\r\n{% endset %}\r\n\r\n{% call statement('postgressql',fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% if execute %}\r\n{# debugging { log(sql, True)} #}\r\n{% set results = load_result('postgressql') %}\r\n{{ log(\"Loaded data from external s3 resource\\n loaded to: \" ~ this ~ \"\\n from: s3://\" ~ s3_bucket ~ \"/\" ~ s3_key ,True) }}\r\n{# debugging { log(results, True) } #}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.535226, "supported_languages": null}, "macro.the_tuva_project.fabric__load_seed": {"name": "fabric__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.fabric__load_seed", "macro_sql": "{% macro fabric__load_seed(uri, pattern, compression, headers, null_marker) %}\r\n{% set sql %}\r\nCOPY INTO {{ this }}\r\nFROM 'https://tuvapublicresources.blob.core.windows.net/{{ uri }}/{{ pattern }}'\r\nWITH (\r\n FILE_TYPE = 'CSV',\r\n FIELDTERMINATOR = ',',\r\n ROWTERMINATOR = '\\n'\r\n {% if headers == true %}, FIRSTROW = 2 {% else %} {% endif %}\r\n);\r\n{% endset %}\r\n{% call statement('fabricsql', fetch_result=true) %}\r\n{{ sql }}\r\n{% endcall %}\r\n\r\n{% if execute %}\r\n{# debugging { log(sql, True)} #}\r\n{% set results = load_result('fabricsql') %}\r\n{% set rows_loaded = results['response'].rows_affected|default(0) %}\r\n{{ log(\"Loaded data from external Azure Blob Storage\\n loaded to: \" ~ this ~ \"\\n from: \" ~ uri ~ \"/\" ~ pattern ~ \"\\n rows: \" ~ rows_loaded, True) }}\r\n{# debugging { log(results, True)} #}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5362792, "supported_languages": null}, "macro.the_tuva_project.default__load_seed": {"name": "default__load_seed", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\load_seed.sql", "original_file_path": "macros\\load_seed.sql", "unique_id": "macro.the_tuva_project.default__load_seed", "macro_sql": "{% macro default__load_seed(uri,pattern,compression,headers,null_marker) %}\r\n{% if execute %}\r\n{% do log('No adapter found, seed not loaded',info = True) %}\r\n{% endif %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5362792, "supported_languages": null}, "macro.the_tuva_project.log_warning_for_seeds": {"name": "log_warning_for_seeds", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\log_warning_for_seeds.sql", "original_file_path": "macros\\log_warning_for_seeds.sql", "unique_id": "macro.the_tuva_project.log_warning_for_seeds", "macro_sql": "{% macro log_warning_for_seeds() %}\r\n\r\n {% set seeds = get_selected_seeds() %}\r\n\r\n {% for seed in seeds %}\r\n {% set sql_query = \"select count(*) as row_count from \" ~ seed %}\r\n {% set result = run_query(sql_query) %}\r\n {% set row_count = result[0][0] %}\r\n {% if row_count == 0 %}\r\n {% if var('error_empty_seeds',False) == true %}\r\n {% do exceptions.raise_compiler_error (\"The seed \" ~ seed ~ \" contains no data. Check tuva:dbt_project.yml configurations to ensure data was correctly loaded with post hook\") %}\r\n {% else %}\r\n {% do exceptions.warn(\"The seed \" ~ seed ~ \" contains no data. Check tuva:dbt_project.yml configurations to ensure data was correctly loaded with post hook\") %}\r\n {% endif %}\r\n {% endif %}\r\n {% endfor %}\r\n\r\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.get_selected_seeds", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5372262, "supported_languages": null}, "macro.the_tuva_project.ltrim": {"name": "ltrim", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\ltrim.sql", "original_file_path": "macros\\ltrim.sql", "unique_id": "macro.the_tuva_project.ltrim", "macro_sql": "\r\n\r\n{%- macro ltrim(column_name, trimstr) -%}\r\n\r\n {{ return(adapter.dispatch('ltrim')(column_name, trimstr)) }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.the_tuva_project.default__ltrim"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5372262, "supported_languages": null}, "macro.the_tuva_project.default__ltrim": {"name": "default__ltrim", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\ltrim.sql", "original_file_path": "macros\\ltrim.sql", "unique_id": "macro.the_tuva_project.default__ltrim", "macro_sql": "{%- macro default__ltrim(column_name, trimstr) -%}\r\n\r\n ltrim({{ column_name }}, '{{ trimstr }}')\r\n\r\n{%- endmacro -%}\r\n\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.538235, "supported_languages": null}, "macro.the_tuva_project.databricks__ltrim": {"name": "databricks__ltrim", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\ltrim.sql", "original_file_path": "macros\\ltrim.sql", "unique_id": "macro.the_tuva_project.databricks__ltrim", "macro_sql": "{%- macro databricks__ltrim(column_name, trimstr) -%}\r\n\r\n ltrim('{{ trimstr }}', {{ column_name }})\r\n\r\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.538235, "supported_languages": null}, "macro.the_tuva_project.quote_column": {"name": "quote_column", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\quote_column.sql", "original_file_path": "macros\\quote_column.sql", "unique_id": "macro.the_tuva_project.quote_column", "macro_sql": "{% macro quote_column(column_name) %}\r\n {%- if target.type == 'fabric' -%}\r\n \"{{ column_name }}\"\r\n {%- else -%}\r\n {{ column_name }}\r\n {%- endif -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.538235, "supported_languages": null}, "macro.the_tuva_project.substring": {"name": "substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.substring", "macro_sql": "{% macro substring(string, start, length) %}\r\n {{ return(adapter.dispatch('substring', 'macros')(string, start, length)) }}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.the_tuva_project.snowflake__substring"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5392323, "supported_languages": null}, "macro.the_tuva_project.default__substring": {"name": "default__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.default__substring", "macro_sql": "{% macro default__substring(string, start, length) %}\r\n substring({{ string }}, {{ start }}, {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5392323, "supported_languages": null}, "macro.the_tuva_project.postgres__substring": {"name": "postgres__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.postgres__substring", "macro_sql": "{% macro postgres__substring(string, start, length) %}\r\n substring({{ string }} from {{ start }} for {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5392323, "supported_languages": null}, "macro.the_tuva_project.snowflake__substring": {"name": "snowflake__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.snowflake__substring", "macro_sql": "{% macro snowflake__substring(string, start, length) %}\r\n substr({{ string }}, {{ start }}, {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.540234, "supported_languages": null}, "macro.the_tuva_project.bigquery__substring": {"name": "bigquery__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.bigquery__substring", "macro_sql": "{% macro bigquery__substring(string, start, length) %}\r\n substr({{ string }}, {{ start }}, {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.540234, "supported_languages": null}, "macro.the_tuva_project.redshift__substring": {"name": "redshift__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.redshift__substring", "macro_sql": "{% macro redshift__substring(string, start, length) %}\r\n substring({{ string }}, {{ start }}, {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.540234, "supported_languages": null}, "macro.the_tuva_project.databricks__substring": {"name": "databricks__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.databricks__substring", "macro_sql": "{% macro databricks__substring(string, start, length) %}\r\n substring({{ string }}, {{ start }}, {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.540234, "supported_languages": null}, "macro.the_tuva_project.duckdb__substring": {"name": "duckdb__substring", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\substring.sql", "original_file_path": "macros\\substring.sql", "unique_id": "macro.the_tuva_project.duckdb__substring", "macro_sql": "{% macro duckdb__substring(string, start, length) %}\r\n substring({{ string }}, {{ start }}, {{ length }})\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.540234, "supported_languages": null}, "macro.the_tuva_project.try_to_cast_date": {"name": "try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.try_to_cast_date", "macro_sql": "\r\n\r\n{%- macro try_to_cast_date(column_name, date_format='YYYY-MM-DD') -%}\r\n\r\n {{ return(adapter.dispatch('try_to_cast_date')(column_name, date_format)) }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.input_layer.snowflake__try_to_cast_date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5422337, "supported_languages": null}, "macro.the_tuva_project.bigquery__try_to_cast_date": {"name": "bigquery__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.bigquery__try_to_cast_date", "macro_sql": "{%- macro bigquery__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n safe_cast( date( {{ column_name }} ) as date )\r\n {%- else -%}\r\n safe_cast( {{ column_name }} as date )\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5422337, "supported_languages": null}, "macro.the_tuva_project.default__try_to_cast_date": {"name": "default__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.default__try_to_cast_date", "macro_sql": "{%- macro default__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5422337, "supported_languages": null}, "macro.the_tuva_project.postgres__try_to_cast_date": {"name": "postgres__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.postgres__try_to_cast_date", "macro_sql": "{%- macro postgres__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {{ dbt.safe_cast(column_name, api.Column.translate_type(\"date\")).strip() }}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": ["macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5422337, "supported_languages": null}, "macro.the_tuva_project.redshift__try_to_cast_date": {"name": "redshift__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.redshift__try_to_cast_date", "macro_sql": "{%- macro redshift__try_to_cast_date(column_name, date_format) -%}\r\n\r\n {%- if date_format == 'YYYY-MM-DD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYYMMDD' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}\\\\d{2}\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYYMMDD')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'MM/DD/YYYY' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{2}/\\\\d{2}/\\\\d{4}'\r\n then to_date( {{ column_name }}, 'MM/DD/YYYY')\r\n else date(NULL)\r\n end\r\n {%- elif date_format == 'YYYY-MM-DD HH:MI:SS' -%}\r\n case\r\n when {{ column_name }} similar to '\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2}'\r\n then to_date( {{ column_name }}, 'YYYY-MM-DD HH:MI:SS')\r\n else date(NULL)\r\n end\r\n {%- else -%}\r\n date(NULL)\r\n {%- endif -%}\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5432343, "supported_languages": null}, "macro.the_tuva_project.snowflake__try_to_cast_date": {"name": "snowflake__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.snowflake__try_to_cast_date", "macro_sql": "{%- macro snowflake__try_to_cast_date(column_name, date_format) -%}\r\n\r\n try_cast( {{ column_name }} as date )\r\n\r\n{%- endmacro -%}\r\n\r\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5432343, "supported_languages": null}, "macro.the_tuva_project.athena__try_to_cast_date": {"name": "athena__try_to_cast_date", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\try_to_cast_date.sql", "original_file_path": "macros\\try_to_cast_date.sql", "unique_id": "macro.the_tuva_project.athena__try_to_cast_date", "macro_sql": "{%- macro athena__try_to_cast_date(column_name, date_format) -%}\r\n (case\r\n when typeof({{ column_name }}) = 'date' then date({{ column_name }})\r\n else try_cast(substring(try_cast({{ column_name }} as varchar), 1, 10) as date)\r\n end)\r\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5442286, "supported_languages": null}, "macro.the_tuva_project.eligibility_denominator_invalid_values": {"name": "eligibility_denominator_invalid_values", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\eligibility_denominator_invalid_values.sql", "original_file_path": "macros\\data_quality\\eligibility_denominator_invalid_values.sql", "unique_id": "macro.the_tuva_project.eligibility_denominator_invalid_values", "macro_sql": "{% macro eligibility_denominator_invalid_values(relation) %}\r\n{%- set sql_statement -%}\r\n select test_field\r\n from {{ ref('data_quality__test_catalog') }}\r\n where source_table = 'normalized_input__eligibility'\r\n and test_category = 'invalid_values'\r\n{%- endset -%}\r\n\r\n{%- set results = run_query(sql_statement) -%}\r\n\r\n{%- if execute -%}\r\n{%- set results_list = results.columns[0].values() -%}\r\n{%- else -%}\r\n{%- set results_list = [] -%}\r\n{%- endif -%}\r\n\r\n {%- for test_field in results_list -%}\r\n select\r\n cat.test_name\r\n , count(distinct rel.patient_id) as denominator\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ relation }} as rel\r\n left join {{ ref('data_quality__test_catalog') }} as cat\r\n on cat.test_category = 'invalid_values'\r\n and cat.source_table = 'normalized_input__eligibility'\r\n and cat.test_field = '{{ test_field }}'\r\n where rel.{{ test_field }} is not null\r\n group by cat.test_name\r\n {% if not loop.last -%}\r\n union all\r\n {% endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5452313, "supported_languages": null}, "macro.the_tuva_project.eligibility_missing_column_check": {"name": "eligibility_missing_column_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\eligibility_missing_column_check.sql", "original_file_path": "macros\\data_quality\\eligibility_missing_column_check.sql", "unique_id": "macro.the_tuva_project.eligibility_missing_column_check", "macro_sql": "{% macro eligibility_missing_column_check(relation, column_list) %}\r\n {%- for column_item in column_list %}\r\n select\r\n patient_id\r\n , data_source\r\n , '{{ column_item }}' as column_checked\r\n from {{ relation }}\r\n where {{ column_item }} is null\r\n {% if not loop.last -%}\r\n union all\r\n {%- endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5462284, "supported_languages": null}, "macro.the_tuva_project.medical_claim_date_check": {"name": "medical_claim_date_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\medical_claim_date_check.sql", "original_file_path": "macros\\data_quality\\medical_claim_date_check.sql", "unique_id": "macro.the_tuva_project.medical_claim_date_check", "macro_sql": "{% macro medical_claim_date_check(relation, column_list, claim_type=false) %}\r\n {%- for column_item in column_list -%}\r\n select\r\n claim_id\r\n , data_source\r\n , '{{ column_item }}' as column_checked\r\n from {{ relation }} as rel\r\n left join {{ ref('reference_data__calendar') }} as cal\r\n on rel.{{ column_item }} = cal.full_date\r\n where cal.full_date is null\r\n and rel.{{ column_item }} is not null\r\n {% if claim_type -%}\r\n and rel.claim_type = '{{ claim_type }}'\r\n {% endif -%}\r\n {% if not loop.last -%}\r\n union all\r\n {% endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5462284, "supported_languages": null}, "macro.the_tuva_project.medical_claim_denominator_invalid_values": {"name": "medical_claim_denominator_invalid_values", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\medical_claim_denominator_invalid_values.sql", "original_file_path": "macros\\data_quality\\medical_claim_denominator_invalid_values.sql", "unique_id": "macro.the_tuva_project.medical_claim_denominator_invalid_values", "macro_sql": "{% macro medical_claim_denominator_invalid_values(relation) %}\r\n{%- set sql_statement -%}\r\n select test_field\r\n from {{ ref('data_quality__test_catalog') }}\r\n where source_table = 'normalized_input__medical_claim'\r\n and test_category = 'invalid_values'\r\n{%- endset -%}\r\n\r\n{%- set results = run_query(sql_statement) -%}\r\n\r\n{%- if execute -%}\r\n{%- set results_list = results.columns[0].values() -%}\r\n{%- else -%}\r\n{%- set results_list = [] -%}\r\n{%- endif -%}\r\n\r\n {%- for test_field in results_list -%}\r\n select\r\n cat.test_name\r\n , count(distinct rel.claim_id||rel.data_source) as denominator\r\n , '{{ var('tuva_last_run')}}' as tuva_last_run\r\n from {{ relation }} as rel\r\n left join {{ ref('data_quality__test_catalog') }} as cat\r\n on cat.test_category = 'invalid_values'\r\n and cat.source_table = 'normalized_input__medical_claim'\r\n and cat.test_field = '{{ test_field }}'\r\n where rel.{{ test_field }} is not null\r\n group by cat.test_name\r\n {% if not loop.last -%}\r\n union all\r\n {% endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.547222, "supported_languages": null}, "macro.the_tuva_project.medical_claim_header_duplicate_check": {"name": "medical_claim_header_duplicate_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\medical_claim_header_duplicate_check.sql", "original_file_path": "macros\\data_quality\\medical_claim_header_duplicate_check.sql", "unique_id": "macro.the_tuva_project.medical_claim_header_duplicate_check", "macro_sql": "{% macro medical_claim_header_duplicate_check(relation, column_list, claim_type) %}\r\n {%- for column_item in column_list %}\r\n select\r\n claim_id\r\n , data_source\r\n , '{{ column_item }}' as column_checked\r\n , count(distinct {{ column_item }}) as duplicate_count\r\n from {{ relation }}\r\n where claim_type = '{{ claim_type }}'\r\n group by\r\n claim_id\r\n , data_source\r\n having count(distinct {{ column_item }}) > 1\r\n {% if not loop.last -%}\r\n union all\r\n {%- endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.548234, "supported_languages": null}, "macro.the_tuva_project.medical_claim_missing_column_check": {"name": "medical_claim_missing_column_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\medical_claim_missing_column_check.sql", "original_file_path": "macros\\data_quality\\medical_claim_missing_column_check.sql", "unique_id": "macro.the_tuva_project.medical_claim_missing_column_check", "macro_sql": "{% macro medical_claim_missing_column_check(relation, column_list, claim_type) %}\r\n {%- for column_item in column_list %}\r\n select\r\n claim_id\r\n , data_source\r\n , '{{ column_item }}' as column_checked\r\n from {{ relation }}\r\n where {{ column_item }} is null\r\n and claim_type = '{{ claim_type }}'\r\n {% if not loop.last -%}\r\n union all\r\n {%- endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.548234, "supported_languages": null}, "macro.the_tuva_project.pharmacy_claim_header_duplicate_check": {"name": "pharmacy_claim_header_duplicate_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\pharmacy_claim_header_duplicate_check.sql", "original_file_path": "macros\\data_quality\\pharmacy_claim_header_duplicate_check.sql", "unique_id": "macro.the_tuva_project.pharmacy_claim_header_duplicate_check", "macro_sql": "{% macro pharmacy_claim_header_duplicate_check(relation, column_list) %}\r\n {%- for column_item in column_list %}\r\n select\r\n claim_id\r\n , data_source\r\n , '{{ column_item }}' as column_checked\r\n , count(distinct {{ column_item }}) as duplicate_count\r\n from {{ relation }}\r\n group by claim_id, data_source\r\n having count(distinct {{ column_item }}) > 1\r\n {% if not loop.last -%}\r\n union all\r\n {%- endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.549226, "supported_languages": null}, "macro.the_tuva_project.pharmacy_claim_missing_column_check": {"name": "pharmacy_claim_missing_column_check", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\data_quality\\pharmacy_claim_missing_column_check.sql", "original_file_path": "macros\\data_quality\\pharmacy_claim_missing_column_check.sql", "unique_id": "macro.the_tuva_project.pharmacy_claim_missing_column_check", "macro_sql": "{% macro pharmacy_claim_missing_column_check(relation, column_list) %}\r\n {%- for column_item in column_list %}\r\n select\r\n claim_id\r\n , data_source\r\n , '{{ column_item }}' as column_checked\r\n from {{ relation }}\r\n where {{ column_item }} is null\r\n {% if not loop.last -%}\r\n union all\r\n {%- endif -%}\r\n {%- endfor -%}\r\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.549226, "supported_languages": null}, "macro.the_tuva_project.test_claims_preprocessing_pipeline_checks": {"name": "test_claims_preprocessing_pipeline_checks", "resource_type": "macro", "package_name": "the_tuva_project", "path": "macros\\tests\\claims_preprocessing_pipeline_checks.sql", "original_file_path": "macros\\tests\\claims_preprocessing_pipeline_checks.sql", "unique_id": "macro.the_tuva_project.test_claims_preprocessing_pipeline_checks", "macro_sql": "{% test claims_preprocessing_pipeline_checks(model) %}\r\n\r\n select *\r\n from {{ ref('data_quality__claims_preprocessing_test_detail' )}}\r\n where pipeline_test = 1\r\n\r\n{% endtest %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1729866306.5502262, "supported_languages": null}}, "docs": {"doc.input_layer.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "input_layer", "path": "overview.md", "original_file_path": "docs\\overview.md", "unique_id": "doc.input_layer.__overview__", "block_contents": "# \ud83e\uddf0\u00a0What is The Tuva Project?\r\n\r\nHealthcare data is difficult to analyze - we're working to change that. The Tuva Project is an open source knowledge base, code base, and community for healthcare data people.\r\n\r\n### \ud83d\udd6e\u00a0[Knowledge](https://thetuvaproject.com/)\r\nWe're writing the open book on how to transform and analyze healthcare data.\r\n\r\n### \ud83d\udda5\ufe0f\u00a0[Code](https://github.com/tuva-health)\r\nWe're translating knowledge into precise code that anyone can run on their healthcare data.\r\n\r\n### \ud83e\udd1d\u00a0[Community](https://join.slack.com/t/thetuvaproject/shared_invite/zt-16iz61187-G522Mc2WGA2mHF57e0il0Q)\r\nWe're building a community we're healthcare data people can ask questions and share knowledge about healthcare data."}, "doc.dbt.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "dbt", "path": "overview.md", "original_file_path": "docs\\overview.md", "unique_id": "doc.dbt.__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}, "doc.the_tuva_project.accession_number": {"name": "accession_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.accession_number", "block_contents": "The lab order number from the source system."}, "doc.the_tuva_project.address": {"name": "address", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.address", "block_contents": "The street address of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.admission_date": {"name": "admission_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.admission_date", "block_contents": "Admission date for the claim (inpatient claims only)."}, "doc.the_tuva_project.admit_age": {"name": "admit_age", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_age", "block_contents": "The age of the patient at the time of admission."}, "doc.the_tuva_project.admit_source_code": {"name": "admit_source_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_source_code", "block_contents": "Indicates where the patient was before the healthcare encounter (inpatient claims only)."}, "doc.the_tuva_project.admit_source_description": {"name": "admit_source_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_source_description", "block_contents": "Description of the admit_source_code for the encounter."}, "doc.the_tuva_project.admit_type_code": {"name": "admit_type_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_type_code", "block_contents": "Indicates the type of admission (inpatient claims only)."}, "doc.the_tuva_project.admit_type_description": {"name": "admit_type_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.admit_type_description", "block_contents": "Description of the admit_type_code for the encounter."}, "doc.the_tuva_project.age": {"name": "age", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.age", "block_contents": "The age of the patient calculated based on their date of birth and the last time the tuva project was run."}, "doc.the_tuva_project.age_group": {"name": "age_group", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.age_group", "block_contents": "The decade age group the patient falls into based on their calculated age."}, "doc.the_tuva_project.allowed_amount": {"name": "allowed_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.allowed_amount", "block_contents": "The total amount allowed (includes amount paid by the insurer and patient)."}, "doc.the_tuva_project.ambulance_flag": {"name": "ambulance_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ambulance_flag", "block_contents": "Indicates whether ambulance services were utilized during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.apr_drg_code": {"name": "apr_drg_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.apr_drg_code", "block_contents": "APR-DRG for the claim (inpatient claims only)."}, "doc.the_tuva_project.apr_drg_description": {"name": "apr_drg_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.apr_drg_description", "block_contents": "Description of the APR-DRG code."}, "doc.the_tuva_project.atc_code": {"name": "atc_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.atc_code", "block_contents": "ATC code for the medication."}, "doc.the_tuva_project.atc_description": {"name": "atc_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.atc_description", "block_contents": "Description for the ATC code."}, "doc.the_tuva_project.atc_mapping_method": {"name": "atc_mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.atc_mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.attending_provider_id": {"name": "attending_provider_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.attending_provider_id", "block_contents": "ID for the attending provider on the encounter."}, "doc.the_tuva_project.attending_provider_name": {"name": "attending_provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.attending_provider_name", "block_contents": "Name of the attending provider on the encounter."}, "doc.the_tuva_project.bill_type_code": {"name": "bill_type_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.bill_type_code", "block_contents": "Bill type code for the claim (institutional claims only)."}, "doc.the_tuva_project.bill_type_description": {"name": "bill_type_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.bill_type_description", "block_contents": "Bill type description."}, "doc.the_tuva_project.billing_id": {"name": "billing_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.billing_id", "block_contents": "Billing ID for the claim (typically represents organization billing the claim)."}, "doc.the_tuva_project.billing_name": {"name": "billing_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.billing_name", "block_contents": "Billing provider name."}, "doc.the_tuva_project.billing_tin": {"name": "billing_tin", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.billing_tin", "block_contents": "Billing provider tax identification number (TIN)."}, "doc.the_tuva_project.birth_date": {"name": "birth_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.birth_date", "block_contents": "The birth date of the patient."}, "doc.the_tuva_project.ccs_category": {"name": "ccs_category", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ccs_category", "block_contents": "The Clinical Classifications Software (CCS) category code for the diagnosis or procedure."}, "doc.the_tuva_project.ccs_category_description": {"name": "ccs_category_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ccs_category_description", "block_contents": "Description of the Clinical Classifications Software (CCS) category."}, "doc.the_tuva_project.charge_amount": {"name": "charge_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.charge_amount", "block_contents": "The total amount charged for the services provided, before any adjustments or payments. This is typically in US dollars."}, "doc.the_tuva_project.city": {"name": "city", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.city", "block_contents": "The city of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.claim_attribution_number": {"name": "claim_attribution_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_attribution_number", "block_contents": "A unique number used for attributing or associating claims with specific entities or processes."}, "doc.the_tuva_project.claim_count": {"name": "claim_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_count", "block_contents": "The number of claims associated with the encounter or record."}, "doc.the_tuva_project.claim_end_date": {"name": "claim_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_end_date", "block_contents": "End date for the claim."}, "doc.the_tuva_project.claim_id": {"name": "claim_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_id", "block_contents": "Unique identifier for a claim. Each claim represents a distinct healthcare service or set of services provided to a patient."}, "doc.the_tuva_project.claim_line_attribution_number": {"name": "claim_line_attribution_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_attribution_number", "block_contents": "A unique number used for attributing or associating specific claim lines with entities or processes."}, "doc.the_tuva_project.claim_line_end_date": {"name": "claim_line_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_end_date", "block_contents": "End date for the claim line."}, "doc.the_tuva_project.claim_line_id": {"name": "claim_line_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_id", "block_contents": "Unique identifier for each line item within a claim."}, "doc.the_tuva_project.claim_line_number": {"name": "claim_line_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_number", "block_contents": "Indicates the line number for the particular line of the claim."}, "doc.the_tuva_project.claim_line_start_date": {"name": "claim_line_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_line_start_date", "block_contents": "Start date for the claim line."}, "doc.the_tuva_project.claim_start_date": {"name": "claim_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_start_date", "block_contents": "The date when the healthcare service was provided. Format: YYYY-MM-DD."}, "doc.the_tuva_project.claim_type": {"name": "claim_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.claim_type", "block_contents": "Indicates whether the claim is professional (CMS-1500), institutional (UB-04), dental, or vision."}, "doc.the_tuva_project.close_flag": {"name": "close_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.close_flag", "block_contents": "A flag indicating if the claim has been closed."}, "doc.the_tuva_project.coinsurance_amount": {"name": "coinsurance_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.coinsurance_amount", "block_contents": "The total coinsurance charged on the claim by the provider."}, "doc.the_tuva_project.collection_date": {"name": "collection_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.collection_date", "block_contents": "Date the test was collected."}, "doc.the_tuva_project.condition_id": {"name": "condition_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.condition_id", "block_contents": "Unique identifier for each condition in the table."}, "doc.the_tuva_project.condition_rank": {"name": "condition_rank", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.condition_rank", "block_contents": "The numerical ranking of a diagnosis code in a claim. Principle diagnosis code is given a ranking of 1. Claims data typically has a strict ranking of conditions whereas medical records will often not have this information or the information won't be accurate."}, "doc.the_tuva_project.condition_type": {"name": "condition_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.condition_type", "block_contents": "The type of condition i.e. problem, admitting, or billing."}, "doc.the_tuva_project.copayment_amount": {"name": "copayment_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.copayment_amount", "block_contents": "The total copayment charged on the claim by the provider."}, "doc.the_tuva_project.county": {"name": "county", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.county", "block_contents": "The county for the patient."}, "doc.the_tuva_project.custom_attributed_provider": {"name": "custom_attributed_provider", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider", "block_contents": "Unique identifier for the provider assigned to this patient-year_month by the user."}, "doc.the_tuva_project.custom_attributed_provider_practice": {"name": "custom_attributed_provider_practice", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider_practice", "block_contents": "Name of the practice for the attributed provider assigned by the user."}, "doc.the_tuva_project.custom_attributed_provider_organization": {"name": "custom_attributed_provider_organization", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider_organization", "block_contents": "Name of the organization for the attributed provider assigned by the user."}, "doc.the_tuva_project.custom_attributed_provider_lob": {"name": "custom_attributed_provider_lob", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.custom_attributed_provider_lob", "block_contents": "Name of the line of business for the attributed provider assigned by the user (e.g. medicare, medicaid, commercial)."}, "doc.the_tuva_project.data_source": {"name": "data_source", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.data_source", "block_contents": "User-configured field that indicates the data source."}, "doc.the_tuva_project.days_supply": {"name": "days_supply", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.days_supply", "block_contents": "The number of days supply included."}, "doc.the_tuva_project.death_date": {"name": "death_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.death_date", "block_contents": "Date the patient died if there is one."}, "doc.the_tuva_project.death_flag": {"name": "death_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.death_flag", "block_contents": "A flag indicating if the patient has died."}, "doc.the_tuva_project.deductible_amount": {"name": "deductible_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.deductible_amount", "block_contents": "The total amount charged on the claim by the provider."}, "doc.the_tuva_project.default_ccsr_category_description_ip": {"name": "default_ccsr_category_description_ip", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_description_ip", "block_contents": "Description of the default Clinical Classifications Software Refined (CCSR) category for inpatient services."}, "doc.the_tuva_project.default_ccsr_category_description_op": {"name": "default_ccsr_category_description_op", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_description_op", "block_contents": "Description of the default Clinical Classifications Software Refined (CCSR) category for outpatient services."}, "doc.the_tuva_project.default_ccsr_category_ip": {"name": "default_ccsr_category_ip", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_ip", "block_contents": "The default Clinical Classifications Software Refined (CCSR) category code for inpatient services."}, "doc.the_tuva_project.default_ccsr_category_op": {"name": "default_ccsr_category_op", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.default_ccsr_category_op", "block_contents": "The default Clinical Classifications Software Refined (CCSR) category code for outpatient services."}, "doc.the_tuva_project.delivery_flag": {"name": "delivery_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.delivery_flag", "block_contents": "Indicates whether the encounter involved a delivery (1 for yes, 0 for no)."}, "doc.the_tuva_project.delivery_type": {"name": "delivery_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.delivery_type", "block_contents": "Type of delivery that occurred during the encounter, if applicable."}, "doc.the_tuva_project.diagnosis_code_1": {"name": "diagnosis_code_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.diagnosis_code_1", "block_contents": "The primary diagnosis code for the encounter or claim."}, "doc.the_tuva_project.diagnosis_code_type": {"name": "diagnosis_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.diagnosis_code_type", "block_contents": "The coding system used for the diagnosis code (e.g., ICD-10-CM, ICD-9-CM)."}, "doc.the_tuva_project.discharge_date": {"name": "discharge_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.discharge_date", "block_contents": "Discharge date for the claim (inpatient claims only)."}, "doc.the_tuva_project.discharge_disposition_code": {"name": "discharge_disposition_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.discharge_disposition_code", "block_contents": "Indicates the type of setting the patient was discharged to (institutional inpatient claims only)."}, "doc.the_tuva_project.discharge_disposition_description": {"name": "discharge_disposition_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.discharge_disposition_description", "block_contents": "Description of the discharge_disposition_code for the encounter."}, "doc.the_tuva_project.dispensing_date": {"name": "dispensing_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.dispensing_date", "block_contents": "Date the medication was dispensed."}, "doc.the_tuva_project.dispensing_provider_id": {"name": "dispensing_provider_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.dispensing_provider_id", "block_contents": "ID for the provider that dispensed the prescription (e.g. pharmacy)."}, "doc.the_tuva_project.dispensing_provider_name": {"name": "dispensing_provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.dispensing_provider_name", "block_contents": "Dispensing provider name."}, "doc.the_tuva_project.distinct_claims": {"name": "distinct_claims", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.distinct_claims", "block_contents": "The number of distinct claims associated with the record."}, "doc.the_tuva_project.distinct_service_category_count": {"name": "distinct_service_category_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.distinct_service_category_count", "block_contents": "The count of distinct service categories associated with the claim."}, "doc.the_tuva_project.dme_flag": {"name": "dme_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.dme_flag", "block_contents": "Indicates whether durable medical equipment (DME) was used during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.dq_problem": {"name": "dq_problem", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.dq_problem", "block_contents": "A flag or description indicating a data quality issue."}, "doc.the_tuva_project.dual_status_code": {"name": "dual_status_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.dual_status_code", "block_contents": "Indicates whether the patient is dually eligible for Medicare and Medicaid."}, "doc.the_tuva_project.duplicate_row_number": {"name": "duplicate_row_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.duplicate_row_number", "block_contents": "A number assigned to duplicate rows for identification purposes."}, "doc.the_tuva_project.ed_flag": {"name": "ed_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ed_flag", "block_contents": "Indicates whether the encounter involved an emergency department visit (1 for yes, 0 for no)."}, "doc.the_tuva_project.eligibility_id": {"name": "eligibility_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.eligibility_id", "block_contents": "Unique identifier for each eligibility row in the table."}, "doc.the_tuva_project.encounter_claim_number": {"name": "encounter_claim_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_claim_number", "block_contents": "A unique identifier for the encounter or claim."}, "doc.the_tuva_project.encounter_claim_number_desc": {"name": "encounter_claim_number_desc", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_claim_number_desc", "block_contents": "A description or additional information about the encounter claim number."}, "doc.the_tuva_project.encounter_end_date": {"name": "encounter_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_end_date", "block_contents": "Date when the encounter ended."}, "doc.the_tuva_project.encounter_group": {"name": "encounter_group", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_group", "block_contents": "Categorization of the encounter into groups based on predefined criteria."}, "doc.the_tuva_project.encounter_id": {"name": "encounter_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_id", "block_contents": "Unique identifier for each encounter in the dataset."}, "doc.the_tuva_project.encounter_source_type": {"name": "encounter_source_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_source_type", "block_contents": "Indicates whether the encounter is from a claims or clinical data source"}, "doc.the_tuva_project.encounter_start_date": {"name": "encounter_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_start_date", "block_contents": "Date when the encounter started."}, "doc.the_tuva_project.encounter_type": {"name": "encounter_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.encounter_type", "block_contents": "Indicates the type of encounter e.g. acute inpatient, emergency department, etc."}, "doc.the_tuva_project.end_date": {"name": "end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.end_date", "block_contents": "The end date of the service or claim period."}, "doc.the_tuva_project.enrollment_end_date": {"name": "enrollment_end_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.enrollment_end_date", "block_contents": "Date the patient's insurance eligibility ended."}, "doc.the_tuva_project.enrollment_flag": {"name": "enrollment_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.enrollment_flag", "block_contents": "Flag indicating if the claim has corresponding enrollment during the same time period the service occurred."}, "doc.the_tuva_project.enrollment_start_date": {"name": "enrollment_start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.enrollment_start_date", "block_contents": "Date the patient's insurance eligibility began."}, "doc.the_tuva_project.facility_id": {"name": "facility_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_id", "block_contents": "Facility ID for the claim (typically represents the facility where services were performed)."}, "doc.the_tuva_project.facility_name": {"name": "facility_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_name", "block_contents": "Facility name."}, "doc.the_tuva_project.facility_npi": {"name": "facility_npi", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_npi", "block_contents": "Facility NPI for the claim (typically represents the facility where services were performed)."}, "doc.the_tuva_project.facility_type": {"name": "facility_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.facility_type", "block_contents": "The type of facility e.g. acute care hospital."}, "doc.the_tuva_project.first_name": {"name": "first_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.first_name", "block_contents": "The first name of the patient."}, "doc.the_tuva_project.gender": {"name": "gender", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.gender", "block_contents": "The gender of the patient."}, "doc.the_tuva_project.hcpcs_code": {"name": "hcpcs_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_code", "block_contents": "The CPT or HCPCS code representing the procedure or service provided. These codes are used to describe medical, surgical, and diagnostic services."}, "doc.the_tuva_project.hcpcs_modifier_1": {"name": "hcpcs_modifier_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_1", "block_contents": "1st modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_2": {"name": "hcpcs_modifier_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_2", "block_contents": "2nd modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_3": {"name": "hcpcs_modifier_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_3", "block_contents": "3rd modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_4": {"name": "hcpcs_modifier_4", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_4", "block_contents": "4th modifier for HCPCS code."}, "doc.the_tuva_project.hcpcs_modifier_5": {"name": "hcpcs_modifier_5", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.hcpcs_modifier_5", "block_contents": "5th modifier for HCPCS code."}, "doc.the_tuva_project.in_network_flag": {"name": "in_network_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.in_network_flag", "block_contents": "Flag indicating if the claim was in or out of network."}, "doc.the_tuva_project.inferred_claim_end_column_used": {"name": "inferred_claim_end_column_used", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_end_column_used", "block_contents": "The column used to infer the claim end date."}, "doc.the_tuva_project.inferred_claim_end_year_month": {"name": "inferred_claim_end_year_month", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_end_year_month", "block_contents": "The inferred year and month of the claim end date."}, "doc.the_tuva_project.inferred_claim_start_column_used": {"name": "inferred_claim_start_column_used", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_start_column_used", "block_contents": "The column used to infer the claim start date."}, "doc.the_tuva_project.inferred_claim_start_year_month": {"name": "inferred_claim_start_year_month", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.inferred_claim_start_year_month", "block_contents": "The inferred year and month of the claim start date."}, "doc.the_tuva_project.inst_claim_count": {"name": "inst_claim_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.inst_claim_count", "block_contents": "Number of institutional claims generated from the encounter."}, "doc.the_tuva_project.lab_flag": {"name": "lab_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.lab_flag", "block_contents": "Indicates whether lab services were utilized during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.lab_result_id": {"name": "lab_result_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.lab_result_id", "block_contents": "Unique identifier for each lab result."}, "doc.the_tuva_project.last_name": {"name": "last_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.last_name", "block_contents": "The last name of the patient."}, "doc.the_tuva_project.latitude": {"name": "latitude", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.latitude", "block_contents": "The latitude of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.length_of_stay": {"name": "length_of_stay", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.length_of_stay", "block_contents": "Length of the encounter calculated as encounter_end_date - encounter_start_date."}, "doc.the_tuva_project.location_id": {"name": "location_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.location_id", "block_contents": "Unique identifier for each location."}, "doc.the_tuva_project.longitude": {"name": "longitude", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.longitude", "block_contents": "The longitude of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.mapping_method": {"name": "mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.medical_claim_id": {"name": "medical_claim_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.medical_claim_id", "block_contents": "Unique identifier for each row in the table."}, "doc.the_tuva_project.medical_surgical": {"name": "medical_surgical", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.medical_surgical", "block_contents": "A flag or code indicating if the service was medical or surgical."}, "doc.the_tuva_project.medicare_status_code": {"name": "medicare_status_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.medicare_status_code", "block_contents": "Indicates how the patient became eligible for Medicare."}, "doc.the_tuva_project.medication_id": {"name": "medication_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.medication_id", "block_contents": "Unique identifier for each medication in the table."}, "doc.the_tuva_project.member_id": {"name": "member_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.member_id", "block_contents": "Identifier that links a patient to a particular insurance product or health plan. A patient can have more than one member_id because they can have more than one insurance product/plan."}, "doc.the_tuva_project.min_closing_row": {"name": "min_closing_row", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.min_closing_row", "block_contents": "The minimum row number for closing entries in the dataset."}, "doc.the_tuva_project.modality": {"name": "modality", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.modality", "block_contents": "The mode or method of treatment or service delivery."}, "doc.the_tuva_project.modifier_1": {"name": "modifier_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_1", "block_contents": "First modifier for the procedure code."}, "doc.the_tuva_project.modifier_2": {"name": "modifier_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_2", "block_contents": "Second modifier for the procedure code."}, "doc.the_tuva_project.modifier_3": {"name": "modifier_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_3", "block_contents": "Third modifier for the procedure code."}, "doc.the_tuva_project.modifier_4": {"name": "modifier_4", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_4", "block_contents": "Fourth modifier for the procedure code."}, "doc.the_tuva_project.modifier_5": {"name": "modifier_5", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.modifier_5", "block_contents": "Fifth modifier for the procedure code."}, "doc.the_tuva_project.mortality_flag": {"name": "mortality_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.mortality_flag", "block_contents": "A flag indicating if the patient died during the encounter."}, "doc.the_tuva_project.ms_drg_code": {"name": "ms_drg_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ms_drg_code", "block_contents": "MS-DRG for the claim (inpatient claims only)."}, "doc.the_tuva_project.ms_drg_description": {"name": "ms_drg_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ms_drg_description", "block_contents": "Description of the ms_drg_code."}, "doc.the_tuva_project.name": {"name": "name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.name", "block_contents": "The name of the location."}, "doc.the_tuva_project.ndc_code": {"name": "ndc_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ndc_code", "block_contents": "National drug code associated with the medication."}, "doc.the_tuva_project.ndc_description": {"name": "ndc_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ndc_description", "block_contents": "Description for the NDC."}, "doc.the_tuva_project.ndc_mapping_method": {"name": "ndc_mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ndc_mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.newborn_flag": {"name": "newborn_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.newborn_flag", "block_contents": "Indicates whether the encounter was for a newborn (1 for yes, 0 for no)."}, "doc.the_tuva_project.nicu_flag": {"name": "nicu_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.nicu_flag", "block_contents": "Indicates whether the newborn was admitted to the Neonatal Intensive Care Unit (NICU) during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.normalized_abnormal_flag": {"name": "normalized_abnormal_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_abnormal_flag", "block_contents": "Normalized abnormal flag."}, "doc.the_tuva_project.normalized_code": {"name": "normalized_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_code", "block_contents": "The normalized code."}, "doc.the_tuva_project.normalized_code_type": {"name": "normalized_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_code_type", "block_contents": "The normalized type of code."}, "doc.the_tuva_project.normalized_component": {"name": "normalized_component", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_component", "block_contents": "The normalized component."}, "doc.the_tuva_project.normalized_description": {"name": "normalized_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_description", "block_contents": "Normalized description of the code."}, "doc.the_tuva_project.normalized_reference_range_high": {"name": "normalized_reference_range_high", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_reference_range_high", "block_contents": "The normalized high end of the reference range."}, "doc.the_tuva_project.normalized_reference_range_low": {"name": "normalized_reference_range_low", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_reference_range_low", "block_contents": "The normalized low end of the reference range."}, "doc.the_tuva_project.normalized_units": {"name": "normalized_units", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.normalized_units", "block_contents": "Normalized units of the lab test."}, "doc.the_tuva_project.npi": {"name": "npi", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.npi", "block_contents": "The national provider identifier associated with the record e.g. facility_npi, provider_npi"}, "doc.the_tuva_project.observation_date": {"name": "observation_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_date", "block_contents": "Date the observation was recorded."}, "doc.the_tuva_project.observation_flag": {"name": "observation_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_flag", "block_contents": "Indicates whether the encounter was marked as an observation stay (1 for yes, 0 for no)."}, "doc.the_tuva_project.observation_id": {"name": "observation_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_id", "block_contents": "Unique identifier for each observation in the dataset."}, "doc.the_tuva_project.observation_type": {"name": "observation_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.observation_type", "block_contents": "Type of observation."}, "doc.the_tuva_project.old_encounter_id": {"name": "old_encounter_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.old_encounter_id", "block_contents": "A previous or alternative identifier for the encounter."}, "doc.the_tuva_project.onset_date": {"name": "onset_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.onset_date", "block_contents": "Date when the condition first occurred."}, "doc.the_tuva_project.ordering_practitioner_id": {"name": "ordering_practitioner_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.ordering_practitioner_id", "block_contents": "Unique identifier for the practitioner who ordered the lab test."}, "doc.the_tuva_project.original_reason_entitlement_code": {"name": "original_reason_entitlement_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.original_reason_entitlement_code", "block_contents": "Original reason for Medicare entitlement code."}, "doc.the_tuva_project.original_service_cat_2": {"name": "original_service_cat_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.original_service_cat_2", "block_contents": "The original second-level service category."}, "doc.the_tuva_project.original_service_cat_3": {"name": "original_service_cat_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.original_service_cat_3", "block_contents": "The original third-level service category."}, "doc.the_tuva_project.paid_amount": {"name": "paid_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.paid_amount", "block_contents": "The total amount paid by the insurer."}, "doc.the_tuva_project.paid_date": {"name": "paid_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.paid_date", "block_contents": "The date the claim was paid."}, "doc.the_tuva_project.panel_id": {"name": "panel_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.panel_id", "block_contents": "Unique identifier for the panel."}, "doc.the_tuva_project.parent_organization": {"name": "parent_organization", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.parent_organization", "block_contents": "The parent organization associated with the facility."}, "doc.the_tuva_project.patient_data_source_id": {"name": "patient_data_source_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.patient_data_source_id", "block_contents": "Identifier for the source system from which patient data originated."}, "doc.the_tuva_project.patient_id": {"name": "patient_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.patient_id", "block_contents": "Unique identifier for each patient in the dataset."}, "doc.the_tuva_project.patient_row_num": {"name": "patient_row_num", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.patient_row_num", "block_contents": "A row number assigned to the patient's records."}, "doc.the_tuva_project.payer": {"name": "payer", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.payer", "block_contents": "Name of the payer (i.e. health insurer) providing coverage."}, "doc.the_tuva_project.payer_attributed_provider": {"name": "payer_attributed_provider", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider", "block_contents": "Unique identifier for the provider assigned to this patient-year_month by the payer."}, "doc.the_tuva_project.payer_attributed_provider_practice": {"name": "payer_attributed_provider_practice", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider_practice", "block_contents": "Name of the practice for the payer attributed provider."}, "doc.the_tuva_project.payer_attributed_provider_organization": {"name": "payer_attributed_provider_organization", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider_organization", "block_contents": "Name of the organization for the payer attributed provider."}, "doc.the_tuva_project.payer_attributed_provider_lob": {"name": "payer_attributed_provider_lob", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_attributed_provider_lob", "block_contents": "Name of the line of business for the payer attributed provider (e.g. medicare, medicaid, commercial)."}, "doc.the_tuva_project.payer_type": {"name": "payer_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.payer_type", "block_contents": "Type of payer (e.g. commercial, medicare, medicaid, etc.)."}, "doc.the_tuva_project.pharmacy_claim_id": {"name": "pharmacy_claim_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.pharmacy_claim_id", "block_contents": "Unique identifier for each row in the table."}, "doc.the_tuva_project.pharmacy_flag": {"name": "pharmacy_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.pharmacy_flag", "block_contents": "Indicates whether pharmacy services were utilized during the encounter (1 for yes, 0 for no)."}, "doc.the_tuva_project.phone": {"name": "phone", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.phone", "block_contents": "The phone number for the patient."}, "doc.the_tuva_project.place_of_service_code": {"name": "place_of_service_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.place_of_service_code", "block_contents": "Place of service for the claim (professional claims only)."}, "doc.the_tuva_project.place_of_service_description": {"name": "place_of_service_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.place_of_service_description", "block_contents": "Place of service description."}, "doc.the_tuva_project.plan": {"name": "plan", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.plan", "block_contents": "Name of the plan (i.e. sub contract) providing coverage."}, "doc.the_tuva_project.practice_affiliation": {"name": "practice_affiliation", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.practice_affiliation", "block_contents": "Practice affiliation of the provider."}, "doc.the_tuva_project.practitioner_id": {"name": "practitioner_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.practitioner_id", "block_contents": "Unique identifier for the practitioner on record (e.g., ordered medication, performed the procedure, etc)."}, "doc.the_tuva_project.prescribing_date": {"name": "prescribing_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.prescribing_date", "block_contents": "Date the medication was prescribed."}, "doc.the_tuva_project.prescribing_provider_id": {"name": "prescribing_provider_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.prescribing_provider_id", "block_contents": "ID for the provider that wrote the prescription (e.g. priamry care physician)."}, "doc.the_tuva_project.prescribing_provider_name": {"name": "prescribing_provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.prescribing_provider_name", "block_contents": "Prescribing provider name."}, "doc.the_tuva_project.present_on_admit_code": {"name": "present_on_admit_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.present_on_admit_code", "block_contents": "The present_on_admit_code related to the condition."}, "doc.the_tuva_project.present_on_admit_description": {"name": "present_on_admit_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.present_on_admit_description", "block_contents": "The description of the present_on_admit_code for the condition."}, "doc.the_tuva_project.primary_diagnosis_code": {"name": "primary_diagnosis_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_diagnosis_code", "block_contents": "Primary diagnosis code for the encounter. If from claims the primary diagnosis code comes from the institutional claim."}, "doc.the_tuva_project.primary_diagnosis_code_type": {"name": "primary_diagnosis_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_diagnosis_code_type", "block_contents": "The type of condition code reported in the source system e.g. ICD-10-CM."}, "doc.the_tuva_project.primary_diagnosis_description": {"name": "primary_diagnosis_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_diagnosis_description", "block_contents": "Description of the primary diagnosis code."}, "doc.the_tuva_project.primary_specialty_description": {"name": "primary_specialty_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_specialty_description", "block_contents": "Description of the primary medical specialty of the provider."}, "doc.the_tuva_project.primary_taxonomy_code": {"name": "primary_taxonomy_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.primary_taxonomy_code", "block_contents": "The primary taxonomy code identifying the provider's specialty, classification, or area of practice."}, "doc.the_tuva_project.priority": {"name": "priority", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.priority", "block_contents": "The priority or urgency level of the service or claim."}, "doc.the_tuva_project.priority_number": {"name": "priority_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.priority_number", "block_contents": "A number indicating the priority or sequence of the service or claim."}, "doc.the_tuva_project.procedure_date": {"name": "procedure_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.procedure_date", "block_contents": "Date when the procedure was performed."}, "doc.the_tuva_project.procedure_id": {"name": "procedure_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.procedure_id", "block_contents": "The unique identifier for the performed procedure."}, "doc.the_tuva_project.prof_claim_count": {"name": "prof_claim_count", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.prof_claim_count", "block_contents": "Number of professional claims generated from the encounter."}, "doc.the_tuva_project.provider_first_name": {"name": "provider_first_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_first_name", "block_contents": "The first name of the healthcare provider."}, "doc.the_tuva_project.provider_last_name": {"name": "provider_last_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_last_name", "block_contents": "The last name of the healthcare provider."}, "doc.the_tuva_project.provider_name": {"name": "provider_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_name", "block_contents": "The name of the healthcare provider."}, "doc.the_tuva_project.provider_specialty": {"name": "provider_specialty", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.provider_specialty", "block_contents": "The medical specialty of the provider."}, "doc.the_tuva_project.quantity": {"name": "quantity", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.quantity", "block_contents": "The quantity of the medication."}, "doc.the_tuva_project.quantity_unit": {"name": "quantity_unit", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.quantity_unit", "block_contents": "The units for the quantity."}, "doc.the_tuva_project.race": {"name": "race", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.race", "block_contents": "The patient's race."}, "doc.the_tuva_project.recorded_date": {"name": "recorded_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.recorded_date", "block_contents": "Date when the condition was recorded."}, "doc.the_tuva_project.refills": {"name": "refills", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.refills", "block_contents": "Number of refills for the prescription."}, "doc.the_tuva_project.relative_rank": {"name": "relative_rank", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.relative_rank", "block_contents": "A ranking or order of importance for the record."}, "doc.the_tuva_project.rend_primary_specialty_description": {"name": "rend_primary_specialty_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rend_primary_specialty_description", "block_contents": "A description of the rendering provider's primary specialty."}, "doc.the_tuva_project.rendering_id": {"name": "rendering_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rendering_id", "block_contents": "Rendering ID for the claim (typically represents the physician or entity providing services)."}, "doc.the_tuva_project.rendering_name": {"name": "rendering_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rendering_name", "block_contents": "Rendering provider name."}, "doc.the_tuva_project.rendering_tin": {"name": "rendering_tin", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rendering_tin", "block_contents": "Rendering provider tax identification number (TIN)."}, "doc.the_tuva_project.resolved_date": {"name": "resolved_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.resolved_date", "block_contents": "Date when the condition was resolved."}, "doc.the_tuva_project.result": {"name": "result", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.result", "block_contents": "The result of the record (e.g., lab test, observation, etc)."}, "doc.the_tuva_project.result_date": {"name": "result_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.result_date", "block_contents": "Date of the test result."}, "doc.the_tuva_project.revenue_center_code": {"name": "revenue_center_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.revenue_center_code", "block_contents": "Revenue center code for the claim line (institutional only and typically multiple codes per claim)."}, "doc.the_tuva_project.revenue_center_description": {"name": "revenue_center_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.revenue_center_description", "block_contents": "Revenue center description."}, "doc.the_tuva_project.route": {"name": "route", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.route", "block_contents": "The route used to administer the medication."}, "doc.the_tuva_project.rxnorm_code": {"name": "rxnorm_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rxnorm_code", "block_contents": "RxNorm code associated with the medication."}, "doc.the_tuva_project.rxnorm_description": {"name": "rxnorm_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rxnorm_description", "block_contents": "Description for the RxNorm code."}, "doc.the_tuva_project.rxnorm_mapping_method": {"name": "rxnorm_mapping_method", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.rxnorm_mapping_method", "block_contents": "mapping method used to populate the normalized codes and descriptions. Can be manual (fields were populated in input layer), automatic (dictionary codes matching the source code were found and was automatically populated) or custom (populated by normalization engine)"}, "doc.the_tuva_project.service_category_1": {"name": "service_category_1", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.service_category_1", "block_contents": "The broader service category this claim belongs to."}, "doc.the_tuva_project.service_category_2": {"name": "service_category_2", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.service_category_2", "block_contents": "The more specific service category this claim belongs to."}, "doc.the_tuva_project.service_category_3": {"name": "service_category_3", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.service_category_3", "block_contents": "The most specific service category this claim belongs to."}, "doc.the_tuva_project.service_type": {"name": "service_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.service_type", "block_contents": "The type of service provided."}, "doc.the_tuva_project.service_unit_quantity": {"name": "service_unit_quantity", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.service_unit_quantity", "block_contents": "The number of units for the particular revenue center code."}, "doc.the_tuva_project.sex": {"name": "sex", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.sex", "block_contents": "The gender of the patient."}, "doc.the_tuva_project.social_security_number": {"name": "social_security_number", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.social_security_number", "block_contents": "The social security number of the patient."}, "doc.the_tuva_project.source_abnormal_flag": {"name": "source_abnormal_flag", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_abnormal_flag", "block_contents": "Indicates whether the result is abnormal or normal."}, "doc.the_tuva_project.source_code": {"name": "source_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_code", "block_contents": "The code in the source system (e.g., the ICD-10 code, NDC, lab, etc)"}, "doc.the_tuva_project.source_code_type": {"name": "source_code_type", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_code_type", "block_contents": "The type of code reported in the source system (e.g., ICD-10 code, NDC, lab, etc)"}, "doc.the_tuva_project.source_component": {"name": "source_component", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_component", "block_contents": "The description for the component of the test from the source system."}, "doc.the_tuva_project.source_description": {"name": "source_description", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_description", "block_contents": "Description of the source code in the source system."}, "doc.the_tuva_project.source_model": {"name": "source_model", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_model", "block_contents": "Indicates the DBT source relation name from which data is derived."}, "doc.the_tuva_project.source_model_name": {"name": "source_model_name", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_model_name", "block_contents": "The name of the source data model."}, "doc.the_tuva_project.source_reference_range_high": {"name": "source_reference_range_high", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_reference_range_high", "block_contents": "The high end of the reference range from the source system."}, "doc.the_tuva_project.source_reference_range_low": {"name": "source_reference_range_low", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_reference_range_low", "block_contents": "The low end of the reference range from the source system."}, "doc.the_tuva_project.source_units": {"name": "source_units", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.source_units", "block_contents": "Source units of the lab test."}, "doc.the_tuva_project.specialty": {"name": "specialty", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.specialty", "block_contents": "Specialty of the provider."}, "doc.the_tuva_project.specimen": {"name": "specimen", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.specimen", "block_contents": "The type of specimen e.g. blood, plasma, urine."}, "doc.the_tuva_project.start_date": {"name": "start_date", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.start_date", "block_contents": "The start date of the service or claim period."}, "doc.the_tuva_project.state": {"name": "state", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.state", "block_contents": "The state of the record (e.g., facility location, patient, etc)."}, "doc.the_tuva_project.status": {"name": "status", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.status", "block_contents": "Status of the record (e.g., condition, test, etc)."}, "doc.the_tuva_project.strength": {"name": "strength", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.strength", "block_contents": "The strength of the medication."}, "doc.the_tuva_project.sub_specialty": {"name": "sub_specialty", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.sub_specialty", "block_contents": "Sub specialty of the provider."}, "doc.the_tuva_project.subscriber_id": {"name": "subscriber_id", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.subscriber_id", "block_contents": "Identifier that links a patient to a particular insurance product or health plan."}, "doc.the_tuva_project.subscriber_relation": {"name": "subscriber_relation", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.subscriber_relation", "block_contents": "Identifier that links a patient to a particular insurance product or health plan."}, "doc.the_tuva_project.total_allowed_amount": {"name": "total_allowed_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.total_allowed_amount", "block_contents": "The total amount allowed by the insurance company for all services in the claim."}, "doc.the_tuva_project.total_charge_amount": {"name": "total_charge_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.total_charge_amount", "block_contents": "The total amount charged for all services in the claim."}, "doc.the_tuva_project.total_cost_amount": {"name": "total_cost_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.total_cost_amount", "block_contents": "The total amount paid on the claim by different parties."}, "doc.the_tuva_project.total_paid_amount": {"name": "total_paid_amount", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.total_paid_amount", "block_contents": "The total amount paid for all services in the claim."}, "doc.the_tuva_project.tuva_last_run": {"name": "tuva_last_run", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.tuva_last_run", "block_contents": "The last time the data was refreshed. Generated by `dbt_utils.pretty_time` as the local time of the `dbt run` environment. Timezone is configurable via the `tuva_last_run` var."}, "doc.the_tuva_project.year_month": {"name": "year_month", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.year_month", "block_contents": "Unique year-month of in the dataset computed from eligibility."}, "doc.the_tuva_project.zip_code": {"name": "zip_code", "resource_type": "doc", "package_name": "the_tuva_project", "path": "column_descriptions.md", "original_file_path": "dbt_doc_blocks\\column_descriptions.md", "unique_id": "doc.the_tuva_project.zip_code", "block_contents": "The zip code of the record (e.g., facility location, patient, etc)."}}, "exposures": {}, "metrics": {}, "groups": {}, "selectors": {}, "disabled": {"model.the_tuva_project.normalize__all_codes": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__all_codes", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__all_codes.sql", "original_file_path": "models\\normalize\\normalize__all_codes.sql", "unique_id": "model.the_tuva_project.normalize__all_codes", "fqn": ["the_tuva_project", "normalize", "normalize__all_codes"], "alias": "all_codes", "checksum": {"name": "sha256", "checksum": "09c76ec85a49f0a054da697b8fd5d34aa665a9fb9d73d144e1c02cb5d42d319e"}, "config": {"enabled": false, "alias": "all_codes", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "all_codes", "tags": "normalized", "materialized": "view", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.929304, "relation_name": "dev_thuxuan.normalize.all_codes", "raw_code": "{{ config(\r\n enabled = ( var('enable_normalize_engine', False) == True and\r\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\r\n ) | as_bool\r\n )\r\n}}\r\nwith agg_cte as (\r\n {% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n select * From {{ref('normalize__stg_unmapped_lab_result')}} union all\r\n select * From {{ref('normalize__stg_unmapped_medication')}} union all\r\n select * From {{ref('normalize__stg_unmapped_observation')}} union all\r\n {%- endif %}\r\n select * From {{ref('normalize__stg_unmapped_condition')}} union all\r\n select * From {{ref('normalize__stg_unmapped_procedure')}}\r\n)\r\n\r\nselect source_code_type,\r\n source_code,\r\n source_description,\r\n item_count,\r\n domains,\r\n data_sources,\r\n normalized_code_type,\r\n normalized_code,\r\n normalized_description,\r\n not_mapped,\r\n added_by,\r\n added_date,\r\n reviewed_by,\r\n reviewed_date,\r\n notes\r\nfrom {{ ref('custom_mapped') }}\r\n\r\n{% if target.type == 'fabric' %}\r\nunion\r\n{% else %}\r\nunion distinct\r\n{% endif %}\r\n\r\nselect un.source_code_type,\r\n un.source_code,\r\n un.source_description,\r\n un.item_count,\r\n un.domains,\r\n un.data_sources,\r\n un.normalized_code_type,\r\n un.normalized_code,\r\n un.normalized_description,\r\n un.not_mapped,\r\n un.added_by,\r\n un.added_date,\r\n un.reviewed_by,\r\n un.reviewed_date,\r\n un.notes\r\n from {{ref('normalize__all_unmapped')}} un \r\n left join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(un.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( un.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (un.source_code = custom_mapped.source_code\r\n or ( un.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (un.source_description = custom_mapped.source_description\r\n or ( un.source_description is null and custom_mapped.source_description is null)\r\n )\r\n where custom_mapped.source_code_type is null\r\n and custom_mapped.source_code is null\r\n and custom_mapped.source_description is null", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_lab_result", "package": null, "version": null}, {"name": "normalize__stg_unmapped_medication", "package": null, "version": null}, {"name": "normalize__stg_unmapped_observation", "package": null, "version": null}, {"name": "normalize__stg_unmapped_condition", "package": null, "version": null}, {"name": "normalize__stg_unmapped_procedure", "package": null, "version": null}, {"name": "custom_mapped", "package": null, "version": null}, {"name": "normalize__all_unmapped", "package": null, "version": null}, {"name": "custom_mapped", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__all_unmapped": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__all_unmapped", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__all_unmapped.sql", "original_file_path": "models\\normalize\\normalize__all_unmapped.sql", "unique_id": "model.the_tuva_project.normalize__all_unmapped", "fqn": ["the_tuva_project", "normalize", "normalize__all_unmapped"], "alias": "all_unmapped", "checksum": {"name": "sha256", "checksum": "54d9f538415c7eb96ab4ed54984498f1754fd73bdbfca384df5001567cf3815c"}, "config": {"enabled": false, "alias": "all_unmapped", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "all_unmapped", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9263022, "relation_name": "dev_thuxuan.normalize.all_unmapped", "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\r\n ) | as_bool\r\n )\r\n}}\r\nwith agg_cte as (\r\n {% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}\r\n select * From {{ref('normalize__stg_unmapped_lab_result')}} union all\r\n select * From {{ref('normalize__stg_unmapped_medication')}} union all\r\n select * From {{ref('normalize__stg_unmapped_observation')}} union all\r\n {%- endif %}\r\n select * From {{ref('normalize__stg_unmapped_condition')}} union all\r\n select * From {{ref('normalize__stg_unmapped_procedure')}}\r\n)\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n sum(i.item_count) as item_count,\r\n {{ dbt.listagg(measure=\"distinct i.domain\", delimiter_text=\"', '\", order_by_clause=\"order by i.domain\" )}} as domains,\r\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\r\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\r\n cast( null as {{ dbt.type_string() }} ) as added_by,\r\n cast( null as {{ dbt.type_string() }} ) as added_date,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\r\n cast( null as {{ dbt.type_string() }} ) as notes\r\nfrom agg_cte i\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_lab_result", "package": null, "version": null}, {"name": "normalize__stg_unmapped_medication", "package": null, "version": null}, {"name": "normalize__stg_unmapped_observation", "package": null, "version": null}, {"name": "normalize__stg_unmapped_condition", "package": null, "version": null}, {"name": "normalize__stg_unmapped_procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_condition": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__unmapped_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__unmapped_condition.sql", "original_file_path": "models\\normalize\\normalize__unmapped_condition.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_condition", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_condition"], "alias": "unmapped_condition", "checksum": {"name": "sha256", "checksum": "6271dbccfffb27274c77f737232ce2c0f3867efda3e74021333bbeab2ee7f95e"}, "config": {"enabled": false, "alias": "unmapped_condition", "schema": "normalize", "database": null, "tags": ["normalize"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalize"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_condition", "tags": "normalize", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9313023, "relation_name": "dev_thuxuan.normalize.unmapped_condition", "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\r\n ) | as_bool\r\n )\r\n}}\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n sum(i.item_count) as item_count,\r\n i.domain as domain,\r\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\r\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\r\n cast( null as {{ dbt.type_string() }} ) as added_by,\r\n cast( null as {{ dbt.type_string() }} ) as added_date,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\r\n cast( null as {{ dbt.type_string() }} ) as notes\r\nfrom {{ref('normalize__stg_unmapped_condition')}} i\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_lab_result": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__unmapped_lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__unmapped_lab_result.sql", "original_file_path": "models\\normalize\\normalize__unmapped_lab_result.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_lab_result", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_lab_result"], "alias": "unmapped_lab_result", "checksum": {"name": "sha256", "checksum": "9295d012eed959d8c42df6560c754e218190e0b771e56cc417be7c3042ff703b"}, "config": {"enabled": false, "alias": "unmapped_lab_result", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_lab_result", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9353027, "relation_name": "dev_thuxuan.normalize.unmapped_lab_result", "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('clinical_enabled', var('tuva_marts_enabled', False))\r\n ) | as_bool\r\n )\r\n}}\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n sum(i.item_count) as item_count,\r\n i.domain as domain,\r\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\r\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\r\n cast( null as {{ dbt.type_string() }} ) as added_by,\r\n cast( null as {{ dbt.type_string() }} ) as added_date,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\r\n cast( null as {{ dbt.type_string() }} ) as notes\r\nfrom {{ref('normalize__stg_unmapped_lab_result')}} i\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_medication": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__unmapped_medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__unmapped_medication.sql", "original_file_path": "models\\normalize\\normalize__unmapped_medication.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_medication", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_medication"], "alias": "unmapped_medication", "checksum": {"name": "sha256", "checksum": "c817604225008005f57b144045c7c62a20dcdb34b4d3fad0e29a3cc5e4360b4d"}, "config": {"enabled": false, "alias": "unmapped_medication", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_medication", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9383023, "relation_name": "dev_thuxuan.normalize.unmapped_medication", "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('clinical_enabled', var('tuva_marts_enabled', False))\r\n ) | as_bool\r\n )\r\n}}\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n sum(i.item_count) as item_count,\r\n i.domain as domain,\r\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\r\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\r\n cast( null as {{ dbt.type_string() }} ) as added_by,\r\n cast( null as {{ dbt.type_string() }} ) as added_date,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\r\n cast( null as {{ dbt.type_string() }} ) as notes\r\nfrom {{ref('normalize__stg_unmapped_medication')}} i\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_observation": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__unmapped_observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__unmapped_observation.sql", "original_file_path": "models\\normalize\\normalize__unmapped_observation.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_observation", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_observation"], "alias": "unmapped_observation", "checksum": {"name": "sha256", "checksum": "6cec7542b0cb8f4cb23a6135032e37843fe2d7048f150669d2c2806abf64ed30"}, "config": {"enabled": false, "alias": "unmapped_observation", "schema": "normalize", "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_observation", "tags": "normalized", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.940303, "relation_name": "dev_thuxuan.normalize.unmapped_observation", "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('clinical_enabled', var('tuva_marts_enabled', False))\r\n ) | as_bool\r\n )\r\n}}\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n sum(i.item_count) as item_count,\r\n i.domain as domain,\r\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\r\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\r\n cast( null as {{ dbt.type_string() }} ) as added_by,\r\n cast( null as {{ dbt.type_string() }} ) as added_date,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\r\n cast( null as {{ dbt.type_string() }} ) as notes\r\nfrom {{ref('normalize__stg_unmapped_observation')}} i\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__unmapped_procedure": [{"database": "dev_thuxuan", "schema": "normalize", "name": "normalize__unmapped_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\normalize__unmapped_procedure.sql", "original_file_path": "models\\normalize\\normalize__unmapped_procedure.sql", "unique_id": "model.the_tuva_project.normalize__unmapped_procedure", "fqn": ["the_tuva_project", "normalize", "normalize__unmapped_procedure"], "alias": "unmapped_procedure", "checksum": {"name": "sha256", "checksum": "0ae481eaa1f6c3aaa031bbdbd2cc27634bf6ae7b9e03dbccf187f71243c7a5da"}, "config": {"enabled": false, "alias": "unmapped_procedure", "schema": "normalize", "database": null, "tags": ["normalize"], "meta": {}, "group": null, "materialized": "table", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalize"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"schema": "normalize", "alias": "unmapped_procedure", "tags": "normalize", "materialized": "table", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9333022, "relation_name": "dev_thuxuan.normalize.unmapped_procedure", "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\r\n ) | as_bool\r\n )\r\n}}\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n sum(i.item_count) as item_count,\r\n i.domain as domain,\r\n {{ dbt.listagg(measure=\"distinct i.DATA_SOURCE\", delimiter_text=\"', '\", order_by_clause=\"order by i.DATA_SOURCE\" )}} as data_sources,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code_type,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_code,\r\n cast( null as {{ dbt.type_string() }} ) as normalized_description,\r\n cast( null as {{ dbt.type_string() }} ) as not_mapped,\r\n cast( null as {{ dbt.type_string() }} ) as added_by,\r\n cast( null as {{ dbt.type_string() }} ) as added_date,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_by,\r\n cast( null as {{ dbt.type_string() }} ) as reviewed_date,\r\n cast( null as {{ dbt.type_string() }} ) as notes\r\nfrom {{ref('normalize__stg_unmapped_procedure')}} i\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.DOMAIN", "language": "sql", "refs": [{"name": "normalize__stg_unmapped_procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.listagg", "macro.dbt.type_string"], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_condition": [{"database": "dev_thuxuan", "schema": "test", "name": "normalize__stg_unmapped_condition", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\staging\\normalize__stg_unmapped_condition.sql", "original_file_path": "models\\normalize\\staging\\normalize__stg_unmapped_condition.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_condition", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_condition"], "alias": "normalize__stg_unmapped_condition", "checksum": {"name": "sha256", "checksum": "51cfaf7cae2fdf916f11ad0b1c6121261719fa0b3bc106ee6afceca3c83eaff6"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped condition codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9413025, "relation_name": null, "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\r\n ) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) == True %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'condition' as domain,\r\n i.data_source\r\nfrom {{ref('core__condition')}} i\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (i.source_code = custom_mapped.source_code\r\n or ( i.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (i.source_description = custom_mapped.source_description\r\n or ( i.source_description is null and custom_mapped.source_description is null)\r\n )\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\n and custom_mapped.not_mapped is null\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% else %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'condition' as domain,\r\n i.data_source\r\nfrom {{ref('core__condition')}} i\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__condition", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_lab_result": [{"database": "dev_thuxuan", "schema": "test", "name": "normalize__stg_unmapped_lab_result", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\staging\\normalize__stg_unmapped_lab_result.sql", "original_file_path": "models\\normalize\\staging\\normalize__stg_unmapped_lab_result.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_lab_result", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_lab_result"], "alias": "normalize__stg_unmapped_lab_result", "checksum": {"name": "sha256", "checksum": "cef6a030750e4370c6e9215aae08b0fd10c2765f610fdea72d96be1806a6d5c1"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9443796, "relation_name": null, "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('clinical_enabled', var('tuva_marts_enabled', False))\r\n ) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) == True %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'lab_result' as domain,\r\n i.data_source\r\nfrom {{ref('core__lab_result')}} i\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (i.source_code = custom_mapped.source_code\r\n or ( i.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (i.source_description = custom_mapped.source_description\r\n or ( i.source_description is null and custom_mapped.source_description is null)\r\n )\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\n and custom_mapped.not_mapped is null\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% else %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'lab_result' as domain,\r\n i.data_source\r\nfrom {{ref('core__lab_result')}} i\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__lab_result", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_medication": [{"database": "dev_thuxuan", "schema": "test", "name": "normalize__stg_unmapped_medication", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\staging\\normalize__stg_unmapped_medication.sql", "original_file_path": "models\\normalize\\staging\\normalize__stg_unmapped_medication.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_medication", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_medication"], "alias": "normalize__stg_unmapped_medication", "checksum": {"name": "sha256", "checksum": "277ca00aa8f6dca6bee281a84f7eda59a5f01ff3bfdfc0ce5c527c9dc50d6947"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9452887, "relation_name": null, "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('clinical_enabled', var('tuva_marts_enabled', False))\r\n ) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) == True %}\r\n\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'medication' as domain,\r\n i.data_source\r\nfrom {{ref('core__medication')}} i\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (i.source_code = custom_mapped.source_code\r\n or ( i.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (i.source_description = custom_mapped.source_description\r\n or ( i.source_description is null and custom_mapped.source_description is null)\r\n )\r\nwhere i.ndc_code is null and i.ndc_description is null and i.rxnorm_code is null and i.rxnorm_description is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\n and custom_mapped.not_mapped is null\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% else %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'medication' as domain,\r\n i.data_source\r\nfrom {{ref('core__medication')}} i\r\nwhere i.ndc_code is null and i.ndc_description is null and i.rxnorm_code is null and i.rxnorm_description is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__medication", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_observation": [{"database": "dev_thuxuan", "schema": "test", "name": "normalize__stg_unmapped_observation", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\staging\\normalize__stg_unmapped_observation.sql", "original_file_path": "models\\normalize\\staging\\normalize__stg_unmapped_observation.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_observation", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_observation"], "alias": "normalize__stg_unmapped_observation", "checksum": {"name": "sha256", "checksum": "a9512ad1277bf1515e5eae6976123052c5e5b121ead7919e8f884bc56a29ab3a"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9463954, "relation_name": null, "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('clinical_enabled', var('tuva_marts_enabled', False))\r\n ) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) == True %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'observation' as domain,\r\n i.data_source\r\nfrom {{ref('core__observation')}} i\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (i.source_code = custom_mapped.source_code\r\n or ( i.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (i.source_description = custom_mapped.source_description\r\n or ( i.source_description is null and custom_mapped.source_description is null)\r\n )\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\n and custom_mapped.not_mapped is null\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% else %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'observation' as domain,\r\n i.data_source\r\nfrom {{ref('core__observation')}} i\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__observation", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "model.the_tuva_project.normalize__stg_unmapped_procedure": [{"database": "dev_thuxuan", "schema": "test", "name": "normalize__stg_unmapped_procedure", "resource_type": "model", "package_name": "the_tuva_project", "path": "normalize\\staging\\normalize__stg_unmapped_procedure.sql", "original_file_path": "models\\normalize\\staging\\normalize__stg_unmapped_procedure.sql", "unique_id": "model.the_tuva_project.normalize__stg_unmapped_procedure", "fqn": ["the_tuva_project", "normalize", "staging", "normalize__stg_unmapped_procedure"], "alias": "normalize__stg_unmapped_procedure", "checksum": {"name": "sha256", "checksum": "9214c66a73fc9a2e7f7fc5e2f78f62c6bd2fb88e8b3e0b01727a8673e6faee99"}, "config": {"enabled": false, "alias": null, "schema": null, "database": null, "tags": ["normalized"], "meta": {}, "group": null, "materialized": "ephemeral", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#1a7aa9"}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "bind": false}, "tags": ["normalized"], "description": "unmapped procedure codes\n", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#1a7aa9"}, "patch_path": "the_tuva_project://models\\normalize\\_models.yml", "build_path": null, "unrendered_config": {"tags": "normalized", "materialized": "ephemeral", "enabled": false, "bind": false, "docs": {"node_color": "#1a7aa9"}}, "created_at": 1729866317.9423032, "relation_name": null, "raw_code": "{{ config(\r\n enabled = ( ( var('enable_normalize_engine', False) == True or var('enable_normalize_engine', False) == \"unmapped\") and\r\n var('claims_enabled', var('clinical_enabled', var('tuva_marts_enabled', False)))\r\n ) | as_bool\r\n )\r\n}}\r\n\r\n{% if var('enable_normalize_engine',false) == True %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'procedure' as domain,\r\n i.data_source\r\nfrom {{ref('core__procedure')}} i\r\nleft join {{ ref('custom_mapped') }} custom_mapped\r\n on ( lower(i.source_code_type) = lower(custom_mapped.source_code_type)\r\n or ( i.source_code_type is null and custom_mapped.source_code_type is null)\r\n )\r\n and (i.source_code = custom_mapped.source_code\r\n or ( i.source_code is null and custom_mapped.source_code is null)\r\n )\r\n and (i.source_description = custom_mapped.source_description\r\n or ( i.source_description is null and custom_mapped.source_description is null)\r\n )\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\n and custom_mapped.not_mapped is null\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% else %}\r\n\r\nselect i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION,\r\n count(*) as item_count,\r\n 'procedure' as domain,\r\n i.data_source\r\nfrom {{ref('core__procedure')}} i\r\nwhere i.NORMALIZED_CODE is null and i.NORMALIZED_DESCRIPTION is null\r\n and not ( i.SOURCE_CODE is null and i.SOURCE_DESCRIPTION is null)\r\ngroup by i.SOURCE_CODE_TYPE, i.SOURCE_CODE, i.SOURCE_DESCRIPTION, i.data_source\r\n\r\n{% endif %}", "language": "sql", "refs": [{"name": "core__procedure", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}], "snapshot.the_tuva_project.cms_hcc__patient_risk_factors_snapshot": [{"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_factors_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "cms_hcc\\cms_hcc__patient_risk_factors_snapshot.sql", "original_file_path": "snapshots\\cms_hcc\\cms_hcc__patient_risk_factors_snapshot.sql", "unique_id": "snapshot.the_tuva_project.cms_hcc__patient_risk_factors_snapshot", "fqn": ["the_tuva_project", "cms_hcc", "cms_hcc__patient_risk_factors_snapshot", "cms_hcc__patient_risk_factors_snapshot"], "alias": "patient_risk_factors_snapshot", "checksum": {"name": "sha256", "checksum": "93de4ccb7b0962ce79e9d1b54e8b3ce626ab0fc1757a0a8a7583c350fd5f1c3e"}, "config": {"enabled": false, "alias": "patient_risk_factors_snapshot", "schema": null, "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "patient_id||model_version||payment_year||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "cms_hcc", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["cms_hcc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "cms_hcc", "alias": "patient_risk_factors_snapshot", "tags": ["cms_hcc"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "patient_id||model_version||payment_year||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729866313.843837, "relation_name": "dev_thuxuan.cms_hcc.patient_risk_factors_snapshot", "raw_code": "\r\n\r\n{% set schema_var %}\r\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_cms_hcc{% else %}cms_hcc{%- endif -%}\r\n{% endset %}\r\n\r\n{{\r\n config({\r\n \"target_schema\": schema_var\r\n , \"alias\": \"patient_risk_factors_snapshot\"\r\n , \"tags\": \"cms_hcc\"\r\n , \"strategy\": \"timestamp\"\r\n , \"updated_at\": \"tuva_last_run\"\r\n , \"unique_key\": \"patient_id||model_version||payment_year||tuva_last_run\"\r\n , \"enabled\": var('snapshots_enabled',False) == true and var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) == true | as_bool\r\n })\r\n}}\r\n\r\nselect * from {{ ref('cms_hcc__patient_risk_factors') }}\r\n\r\n", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_factors", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}], "snapshot.the_tuva_project.cms_hcc__patient_risk_scores_snapshot": [{"database": "dev_thuxuan", "schema": "cms_hcc", "name": "cms_hcc__patient_risk_scores_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "cms_hcc\\cms_hcc__patient_risk_scores_snapshot.sql", "original_file_path": "snapshots\\cms_hcc\\cms_hcc__patient_risk_scores_snapshot.sql", "unique_id": "snapshot.the_tuva_project.cms_hcc__patient_risk_scores_snapshot", "fqn": ["the_tuva_project", "cms_hcc", "cms_hcc__patient_risk_scores_snapshot", "cms_hcc__patient_risk_scores_snapshot"], "alias": "patient_risk_scores_snapshot", "checksum": {"name": "sha256", "checksum": "0341ef994d38335ca5a8a59a7c8acdb47696f43200dd33027fcdc2093ed44ed8"}, "config": {"enabled": false, "alias": "patient_risk_scores_snapshot", "schema": null, "database": null, "tags": ["cms_hcc"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "patient_id||payment_year||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "cms_hcc", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["cms_hcc"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "cms_hcc", "alias": "patient_risk_scores_snapshot", "tags": ["cms_hcc"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "patient_id||payment_year||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729866313.8959653, "relation_name": "dev_thuxuan.cms_hcc.patient_risk_scores_snapshot", "raw_code": "\r\n\r\n{% set schema_var %}\r\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_cms_hcc{% else %}cms_hcc{%- endif -%}\r\n{% endset %}\r\n\r\n{{\r\n config({\r\n \"target_schema\": schema_var\r\n , \"alias\": \"patient_risk_scores_snapshot\"\r\n , \"tags\": \"cms_hcc\"\r\n , \"strategy\": \"timestamp\"\r\n , \"updated_at\": \"tuva_last_run\"\r\n , \"unique_key\": \"patient_id||payment_year||tuva_last_run\"\r\n , \"enabled\": var('snapshots_enabled',False) == true and var('cms_hcc_enabled',var('claims_enabled',var('tuva_marts_enabled',False))) == true | as_bool\r\n })\r\n}}\r\n\r\nselect * from {{ ref('cms_hcc__patient_risk_scores') }}\r\n\r\n", "language": "sql", "refs": [{"name": "cms_hcc__patient_risk_scores", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}], "snapshot.the_tuva_project.quality_measures__summary_counts_snapshot": [{"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__summary_counts_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "quality_measures\\quality_measures__summary_counts_snapshot.sql", "original_file_path": "snapshots\\quality_measures\\quality_measures__summary_counts_snapshot.sql", "unique_id": "snapshot.the_tuva_project.quality_measures__summary_counts_snapshot", "fqn": ["the_tuva_project", "quality_measures", "quality_measures__summary_counts_snapshot", "quality_measures__summary_counts_snapshot"], "alias": "summary_counts_snapshot", "checksum": {"name": "sha256", "checksum": "7d70c425e79217b6b2af25984cc5901a5a70e2cd1d16eee9e6f5af049c719978"}, "config": {"enabled": false, "alias": "summary_counts_snapshot", "schema": null, "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "measure_id||measure_name||measure_version||performance_period_begin||performance_period_end||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "quality_measures", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["quality_measures"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "quality_measures", "alias": "summary_counts_snapshot", "tags": ["quality_measures"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "measure_id||measure_name||measure_version||performance_period_begin||performance_period_end||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729866313.9026082, "relation_name": "dev_thuxuan.quality_measures.summary_counts_snapshot", "raw_code": "\r\n\r\n{% set schema_var %}\r\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_quality_measures{% else %}quality_measures{%- endif -%}\r\n{% endset %}\r\n\r\n{{\r\n config({\r\n \"target_schema\": schema_var\r\n , \"alias\": \"summary_counts_snapshot\"\r\n , \"tags\": \"quality_measures\"\r\n , \"strategy\": \"timestamp\"\r\n , \"updated_at\": \"tuva_last_run\"\r\n , \"unique_key\": \"measure_id||measure_name||measure_version||performance_period_begin||performance_period_end||tuva_last_run\"\r\n , \"enabled\": var('snapshots_enabled',False) == true and var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) == true | as_bool\r\n })\r\n}}\r\n\r\nselect * from {{ ref('quality_measures__summary_counts') }}\r\n\r\n", "language": "sql", "refs": [{"name": "quality_measures__summary_counts", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}], "snapshot.the_tuva_project.quality_measures__summary_long_snapshot": [{"database": "dev_thuxuan", "schema": "quality_measures", "name": "quality_measures__summary_long_snapshot", "resource_type": "snapshot", "package_name": "the_tuva_project", "path": "quality_measures\\quality_measures__summary_long_snapshot.sql", "original_file_path": "snapshots\\quality_measures\\quality_measures__summary_long_snapshot.sql", "unique_id": "snapshot.the_tuva_project.quality_measures__summary_long_snapshot", "fqn": ["the_tuva_project", "quality_measures", "quality_measures__summary_long_snapshot", "quality_measures__summary_long_snapshot"], "alias": "summary_long_snapshot", "checksum": {"name": "sha256", "checksum": "4bfc791820a1666cb034b4056c07c14bbed4a0f1303be9230db39500626d9305"}, "config": {"enabled": false, "alias": "summary_long_snapshot", "schema": null, "database": null, "tags": ["quality_measures"], "meta": {}, "group": null, "materialized": "snapshot", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": "patient_id||denominator_flag||numerator_flag||exclusion_flag||evidence_date||exclusion_date||exclusion_reason||performance_period_begin||performance_period_end||measure_id||measure_name||measure_version||tuva_last_run", "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": "#64b0e1"}, "contract": {"enforced": false, "alias_types": true}, "strategy": "timestamp", "target_schema": "quality_measures", "target_database": null, "updated_at": "tuva_last_run", "check_cols": null}, "tags": ["quality_measures"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": "#64b0e1"}, "patch_path": null, "build_path": null, "unrendered_config": {"target_schema": "quality_measures", "alias": "summary_long_snapshot", "tags": ["quality_measures"], "strategy": "timestamp", "updated_at": "tuva_last_run", "unique_key": "patient_id||denominator_flag||numerator_flag||exclusion_flag||evidence_date||exclusion_date||exclusion_reason||performance_period_begin||performance_period_end||measure_id||measure_name||measure_version||tuva_last_run", "enabled": false, "docs": {"node_color": "#64b0e1"}}, "created_at": 1729866313.9097035, "relation_name": "dev_thuxuan.quality_measures.summary_long_snapshot", "raw_code": "\r\n\r\n{% set schema_var %}\r\n{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_quality_measures{% else %}quality_measures{%- endif -%}\r\n{% endset %}\r\n\r\n{{\r\n config({\r\n \"target_schema\": schema_var\r\n , \"alias\": \"summary_long_snapshot\"\r\n , \"tags\": \"quality_measures\"\r\n , \"strategy\": \"timestamp\"\r\n , \"updated_at\": \"tuva_last_run\"\r\n , \"unique_key\": \"patient_id||denominator_flag||numerator_flag||exclusion_flag||evidence_date||exclusion_date||exclusion_reason||performance_period_begin||performance_period_end||measure_id||measure_name||measure_version||tuva_last_run\"\r\n , \"enabled\": var('snapshots_enabled',False) == true and var('quality_measures_enabled',var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))) == true | as_bool\r\n })\r\n}}\r\n\r\nselect * from {{ ref('quality_measures__summary_long') }}\r\n\r\n", "language": "sql", "refs": [{"name": "quality_measures__summary_long", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": []}, "compiled_path": null, "contract": {"enforced": false, "alias_types": true, "checksum": null}}]}, "parent_map": {"model.input_layer.condition": [], "model.input_layer.eligibility": ["seed.input_layer.eligibility_seed"], "model.input_layer.encounter": [], "model.input_layer.lab_result": [], "model.input_layer.location": [], "model.input_layer.medical_claim": ["seed.input_layer.medical_claim_seed"], "model.input_layer.medication": [], "model.input_layer.observation": [], "model.input_layer.patient": [], "model.input_layer.pharmacy_claim": ["seed.input_layer.pharmacy_claim_seed"], "model.input_layer.practitioner": [], "model.input_layer.procedure": [], "model.input_layer.provider_attribution": ["seed.input_layer.provider_attribution_seed"], "seed.input_layer.eligibility_seed": [], "seed.input_layer.lab_result_seed": [], "seed.input_layer.medical_claim_seed": [], "seed.input_layer.observation_seed": [], "seed.input_layer.pharmacy_claim_seed": [], "seed.input_layer.provider_attribution_seed": [], "model.the_tuva_project.ahrq_measures__pqi_denom_long": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"], "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": ["model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"], "model.the_tuva_project.ahrq_measures__pqi_num_long": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "model.the_tuva_project.ahrq_measures__pqi_rate": ["model.the_tuva_project.ahrq_measures__pqi_denom_long", "model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__pqi_summary": ["model.the_tuva_project.ahrq_measures__pqi_num_long", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__measures"], "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_01_num": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_03_num": ["model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_05_num": ["model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_07_num": ["model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_08_num": ["model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_11_num": ["model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_12_num": ["model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_14_num": ["model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_15_num": ["model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_16_num": ["model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "seed.the_tuva_project.pqi__value_sets"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter"], "model.the_tuva_project.ahrq_measures__stg_pqi_condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": ["model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.ahrq_measures__stg_pqi_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.ahrq_measures__stg_pqi_procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.ccsr__long_condition_category": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.ccsr__stg_core__condition", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"], "model.the_tuva_project.ccsr__long_procedure_category": ["model.the_tuva_project.ccsr__procedure_category_map", "model.the_tuva_project.ccsr__stg_core__procedure"], "model.the_tuva_project.ccsr__singular_condition_category": ["model.the_tuva_project.ccsr__long_condition_category"], "model.the_tuva_project.ccsr__dx_vertical_pivot": ["seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map"], "model.the_tuva_project.ccsr__procedure_category_map": ["seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map"], "model.the_tuva_project.ccsr__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.ccsr__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields", "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": ["model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": ["model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy"], "model.the_tuva_project.cms_chronic_conditions__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.cms_chronic_conditions__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.medical_claim_expanded": ["model.input_layer.medical_claim"], "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.acute_inpatient__encounter_grain": ["model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.ambulance__encounter_grain": ["model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.asc__encounter_grain": ["model.the_tuva_project.asc__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.dialysis__encounter_grain": ["model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.dme__encounter_grain": ["model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.emergency_department__encounter_grain": ["model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.home_health__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_hospice__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_hospice__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_psych__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_psych__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_rehab__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_rehab__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_snf__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_snf__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.inpatient_substance_use__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_substance_use__start_end_dates", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.lab__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.office_visit__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.orphaned_claim__encounter_grain": ["model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_hospice__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_injections__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_injections__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_psych__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_ptotst__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_radiology__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_radiology__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_rehab__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_substance_use__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.outpatient_surgery__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.urgent_care__encounter_grain": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.urgent_care__generate_encounter_id", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.encounters__combined_claim_line_crosswalk": ["model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.ambulance__match_claims_to_anchor", "model.the_tuva_project.asc__match_claims_to_anchor", "model.the_tuva_project.dialysis__match_claims_to_anchor", "model.the_tuva_project.dme__match_claims_to_anchor", "model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__match_claims_to_anchor", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.lab__match_claims_to_anchor", "model.the_tuva_project.office_visits__int_office_visits_claim_line", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "model.the_tuva_project.urgent_care__match_claims_to_anchor"], "model.the_tuva_project.encounters__orphaned_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.acute_inpatient__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.acute_inpatient__prof_claims": ["model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional"], "model.the_tuva_project.acute_inpatient__start_end_dates": ["model.the_tuva_project.acute_inpatient__generate_encounter_id"], "model.the_tuva_project.ambulance__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.ambulance__generate_encounter_id": ["model.the_tuva_project.ambulance__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.ambulance__match_claims_to_anchor": ["model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__generate_encounter_id": ["model.the_tuva_project.asc__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__match_claims_to_anchor": ["model.the_tuva_project.asc__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.asc__start_end_dates": ["model.the_tuva_project.asc__generate_encounter_id"], "model.the_tuva_project.dialysis__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dialysis__generate_encounter_id": ["model.the_tuva_project.dialysis__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dialysis__match_claims_to_anchor": ["model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dme__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dme__generate_encounter_id": ["model.the_tuva_project.dme__anchor_events", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.dme__match_claims_to_anchor": ["model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.emergency_department__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.emergency_department__prof_claims": ["model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_outpatient_institutional", "model.the_tuva_project.encounters__stg_professional"], "model.the_tuva_project.emergency_department__start_end_dates": ["model.the_tuva_project.emergency_department__generate_encounter_id"], "model.the_tuva_project.home_health__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.home_health__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__anchor_events"], "model.the_tuva_project.home_health__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__generate_encounter_id"], "model.the_tuva_project.inpatient_hospice__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_hospice__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_hospice__start_end_dates"], "model.the_tuva_project.inpatient_hospice__start_end_dates": ["model.the_tuva_project.inpatient_hospice__generate_encounter_id"], "model.the_tuva_project.inpatient_psych__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_psych__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__start_end_dates"], "model.the_tuva_project.inpatient_psych__start_end_dates": ["model.the_tuva_project.inpatient_psych__generate_encounter_id"], "model.the_tuva_project.inpatient_rehab__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_rehab__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__start_end_dates"], "model.the_tuva_project.inpatient_rehab__start_end_dates": ["model.the_tuva_project.inpatient_rehab__generate_encounter_id"], "model.the_tuva_project.inpatient_snf__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_snf__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__start_end_dates"], "model.the_tuva_project.inpatient_snf__start_end_dates": ["model.the_tuva_project.inpatient_snf__generate_encounter_id"], "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.inpatient_substance_use__prof_claims": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__start_end_dates"], "model.the_tuva_project.inpatient_substance_use__start_end_dates": ["model.the_tuva_project.inpatient_substance_use__generate_encounter_id"], "model.the_tuva_project.lab__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.lab__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__anchor_events"], "model.the_tuva_project.lab__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.lab__generate_encounter_id"], "model.the_tuva_project.office_visits__int_office_visits": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.office_visits__int_office_visits_claim_line": ["model.the_tuva_project.office_visits__int_office_visits_encounter_ranking", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_em": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": ["model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_injections": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_ptotst": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_radiology": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.service_category__office_based_radiology"], "model.the_tuva_project.office_visits__int_office_visits_surgery": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_telehealth": ["model.the_tuva_project.office_visits__int_office_visits"], "model.the_tuva_project.office_visits__int_office_visits_union": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_ptotst", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_telehealth"], "model.the_tuva_project.outpatient_hospice__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_hospice__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__anchor_events"], "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospice__generate_encounter_id"], "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events"], "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"], "model.the_tuva_project.outpatient_injections__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.encounters__stg_outpatient_institutional"], "model.the_tuva_project.outpatient_injections__generate_encounter_id": ["model.the_tuva_project.outpatient_injections__anchor_events"], "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_injections__generate_encounter_id"], "model.the_tuva_project.outpatient_psych__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_psych__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__anchor_events"], "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_psych__generate_encounter_id"], "model.the_tuva_project.outpatient_ptotst__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__anchor_events"], "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id"], "model.the_tuva_project.outpatient_radiology__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_radiology__generate_encounter_id": ["model.the_tuva_project.outpatient_radiology__anchor_events"], "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_radiology__generate_encounter_id"], "model.the_tuva_project.outpatient_rehab__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_rehab__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__anchor_events"], "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_rehab__generate_encounter_id"], "model.the_tuva_project.outpatient_substance_use__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__anchor_events"], "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id"], "model.the_tuva_project.outpatient_surgery__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.outpatient_surgery__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__anchor_events"], "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.outpatient_surgery__generate_encounter_id"], "model.the_tuva_project.urgent_care__anchor_events": ["model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.urgent_care__generate_encounter_id": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__anchor_events"], "model.the_tuva_project.urgent_care__match_claims_to_anchor": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.urgent_care__generate_encounter_id"], "model.the_tuva_project.encounters__patient_data_source_id": ["model.the_tuva_project.normalized_input__eligibility", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.encounters__stg_eligibility": ["model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.encounters__stg_inpatient_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional"], "model.the_tuva_project.encounters__stg_medical_claim": ["model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.encounters__stg_outpatient_institutional": ["model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.encounters__stg_professional": ["model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.normalized_input__eligibility": ["model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "model.the_tuva_project.normalized_input__stg_eligibility"], "model.the_tuva_project.normalized_input__medical_claim": ["model.the_tuva_project.normalized_input__int_admit_source_final", "model.the_tuva_project.normalized_input__int_admit_type_final", "model.the_tuva_project.normalized_input__int_apr_drg_final", "model.the_tuva_project.normalized_input__int_bill_type_final", "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_ms_drg_final", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_present_on_admit_final", "model.the_tuva_project.normalized_input__int_procedure_code_final", "model.the_tuva_project.normalized_input__int_procedure_date_final", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.normalized_input__stg_medical_claim"], "model.the_tuva_project.normalized_input__pharmacy_claim": ["model.the_tuva_project.normalized_input__stg_pharmacy_claim", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.normalized_input__int_admit_source_final": ["model.the_tuva_project.normalized_input__int_admit_source_voting"], "model.the_tuva_project.normalized_input__int_admit_source_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source"], "model.the_tuva_project.normalized_input__int_admit_type_final": ["model.the_tuva_project.normalized_input__int_admit_type_voting"], "model.the_tuva_project.normalized_input__int_admit_type_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_type"], "model.the_tuva_project.normalized_input__int_apr_drg_final": ["model.the_tuva_project.normalized_input__int_apr_drg_voting"], "model.the_tuva_project.normalized_input__int_apr_drg_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__apr_drg"], "model.the_tuva_project.normalized_input__int_bill_type_final": ["model.the_tuva_project.normalized_input__int_bill_type_voting"], "model.the_tuva_project.normalized_input__int_bill_type_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__bill_type"], "model.the_tuva_project.normalized_input__int_diagnosis_code_final": ["model.the_tuva_project.normalized_input__int_diagnosis_code_voting"], "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm"], "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": ["model.the_tuva_project.normalized_input__int_diagnosis_code_normalize"], "model.the_tuva_project.normalized_input__int_discharge_disposition_final": ["model.the_tuva_project.normalized_input__int_discharge_disposition_voting"], "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"], "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": ["model.the_tuva_project.normalized_input__stg_eligibility", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.normalized_input__int_medical_date_aggregation": ["model.the_tuva_project.normalized_input__int_medical_claim_date_normalize"], "model.the_tuva_project.normalized_input__int_medical_npi_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.normalized_input__int_ms_drg_final": ["model.the_tuva_project.normalized_input__int_ms_drg_voting"], "model.the_tuva_project.normalized_input__int_ms_drg_voting": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.normalized_input__int_place_of_service_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__place_of_service"], "model.the_tuva_project.normalized_input__int_present_on_admit_final": ["model.the_tuva_project.normalized_input__int_present_on_admit_voting"], "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__present_on_admission"], "model.the_tuva_project.normalized_input__int_present_on_admit_voting": ["model.the_tuva_project.normalized_input__int_present_on_admit_normalize"], "model.the_tuva_project.normalized_input__int_procedure_code_final": ["model.the_tuva_project.normalized_input__int_procedure_code_voting"], "model.the_tuva_project.normalized_input__int_procedure_code_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"], "model.the_tuva_project.normalized_input__int_procedure_code_voting": ["model.the_tuva_project.normalized_input__int_procedure_code_normalize"], "model.the_tuva_project.normalized_input__int_procedure_date_final": ["model.the_tuva_project.normalized_input__int_procedure_date_voting"], "model.the_tuva_project.normalized_input__int_procedure_date_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.normalized_input__int_procedure_date_voting": ["model.the_tuva_project.normalized_input__int_procedure_date_normalize"], "model.the_tuva_project.normalized_input__int_revenue_center_normalize": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.normalized_input__int_undetermined_claim_type": ["model.the_tuva_project.normalized_input__stg_medical_claim", "seed.the_tuva_project.terminology__admit_source", "seed.the_tuva_project.terminology__admit_type", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.normalized_input__stg_eligibility": ["model.input_layer.eligibility"], "model.the_tuva_project.normalized_input__stg_medical_claim": ["model.input_layer.medical_claim"], "model.the_tuva_project.normalized_input__stg_pharmacy_claim": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.service_category__service_category_grouper": ["model.the_tuva_project.service_category__combined_institutional_header_level", "model.the_tuva_project.service_category__combined_institutional_line_level", "model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.service_category__service_categories"], "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.service_category__acute_inpatient_institutional_other": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__acute_inpatient_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__ambulance_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__ambulance_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__ambulatory_surgery_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__ambulatory_surgery_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__combined_institutional_header_level": ["model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__home_health_institutional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_surgery_institutional", "model.the_tuva_project.service_category__urgent_care_institutional"], "model.the_tuva_project.service_category__combined_institutional_line_level": ["model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__lab_institutional", "model.the_tuva_project.service_category__observation_institutional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__pharmacy_institutional"], "model.the_tuva_project.service_category__combined_professional": ["model.the_tuva_project.service_category__acute_inpatient_professional", "model.the_tuva_project.service_category__ambulance_professional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "model.the_tuva_project.service_category__inpatient_rehab_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__office_based_other_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__outpatient_rehab_professional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_surgery_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__urgent_care_professional"], "model.the_tuva_project.service_category__dialysis_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__dialysis_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__dme_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__emergency_department_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__emergency_department_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__home_health_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__home_health_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__inpatient_hospice_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_hospice_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_psychiatric_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_rehab_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_rehab_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": ["model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__inpatient_substance_use_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__lab_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__lab_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__observation_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__observation_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__office_based_other_professional": ["model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__office_based_physical_therapy_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__office_based_radiology": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__office_based_surgery_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__office_based_visit_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.service_category__outpatient_hospice_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_hospice_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_psychiatric_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__outpatient_radiology_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_radiology_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_rehab_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_rehab_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__outpatient_substance_use_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_substance_use_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__outpatient_surgery_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__outpatient_surgery_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__pharmacy_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__pharmacy_professional": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__urgent_care_institutional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__urgent_care_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__stg_inpatient_institutional": ["model.the_tuva_project.service_category__stg_medical_claim", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.service_category__stg_medical_claim": ["model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__ccs_services_procedures", "seed.the_tuva_project.terminology__ms_drg", "seed.the_tuva_project.terminology__nitos", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__provider", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.service_category__stg_office_based": ["model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.service_category__stg_professional"], "model.the_tuva_project.service_category__stg_outpatient_institutional": ["model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.service_category__stg_professional": ["model.the_tuva_project.service_category__stg_medical_claim"], "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": ["seed.the_tuva_project.clinical_concept_library__clinical_concepts", "seed.the_tuva_project.clinical_concept_library__coding_systems", "seed.the_tuva_project.clinical_concept_library__value_set_members"], "model.the_tuva_project.cms_hcc__patient_risk_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors"], "model.the_tuva_project.cms_hcc__patient_risk_scores": ["model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.cms_hcc__stg_core__member_months", "seed.the_tuva_project.cms_hcc__adjustment_rates"], "model.the_tuva_project.cms_hcc__int_demographic_factors": ["model.the_tuva_project.cms_hcc__int_members", "seed.the_tuva_project.cms_hcc__demographic_factors"], "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disabled_interaction_factors"], "model.the_tuva_project.cms_hcc__int_disease_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_factors"], "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__disease_interaction_factors"], "model.the_tuva_project.cms_hcc__int_eligible_conditions": ["model.the_tuva_project.cms_hcc__stg_core__condition", "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "seed.the_tuva_project.cms_hcc__cpt_hcpcs"], "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors"], "model.the_tuva_project.cms_hcc__int_hcc_count_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors"], "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": ["model.the_tuva_project.cms_hcc__int_hcc_mapping", "seed.the_tuva_project.cms_hcc__disease_hierarchy"], "model.the_tuva_project.cms_hcc__int_hcc_mapping": ["model.the_tuva_project.cms_hcc__int_eligible_conditions", "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings"], "model.the_tuva_project.cms_hcc__int_members": ["model.the_tuva_project.cms_hcc__stg_core__eligibility", "model.the_tuva_project.cms_hcc__stg_core__patient"], "model.the_tuva_project.cms_hcc__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.cms_hcc__stg_core__eligibility": ["model.the_tuva_project.core__eligibility"], "model.the_tuva_project.cms_hcc__stg_core__medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.cms_hcc__stg_core__member_months": ["model.the_tuva_project.core__member_months"], "model.the_tuva_project.cms_hcc__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.core__condition": ["model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_clinical_condition", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__eligibility": ["model.the_tuva_project.core__stg_claims_eligibility"], "model.the_tuva_project.core__encounter": ["model.the_tuva_project.core__stg_claims_encounter", "model.the_tuva_project.core__stg_clinical_encounter"], "model.the_tuva_project.core__lab_result": ["model.the_tuva_project.core__stg_clinical_lab_result", "seed.the_tuva_project.terminology__loinc", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__location": ["model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_clinical_location"], "model.the_tuva_project.core__medical_claim": ["model.the_tuva_project.core__stg_claims_medical_claim"], "model.the_tuva_project.core__medication": ["model.the_tuva_project.core__stg_clinical_medication", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.core__member_months": ["model.the_tuva_project.core__eligibility", "model.the_tuva_project.financial_pmpm__stg_provider_attribution", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.core__observation": ["model.the_tuva_project.core__stg_clinical_observation", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__loinc", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__patient": ["model.the_tuva_project.core__stg_claims_patient", "model.the_tuva_project.core__stg_clinical_patient"], "model.the_tuva_project.core__pharmacy_claim": ["model.the_tuva_project.core__stg_claims_pharmacy_claim"], "model.the_tuva_project.core__practitioner": ["model.the_tuva_project.core__stg_claims_practitioner", "model.the_tuva_project.core__stg_clinical_practitioner"], "model.the_tuva_project.core__procedure": ["model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.core__stg_clinical_procedure", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs", "seed.the_tuva_project.terminology__snomed_ct"], "model.the_tuva_project.core__stg_claims_condition": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__present_on_admission"], "model.the_tuva_project.core__stg_claims_eligibility": ["model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.core__stg_claims_encounter": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.core__stg_claims_location": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.core__stg_claims_medical_claim": ["model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.normalized_input__medical_claim", "model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.core__stg_claims_patient": ["model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.core__stg_claims_pharmacy_claim": ["model.the_tuva_project.normalized_input__pharmacy_claim"], "model.the_tuva_project.core__stg_claims_practitioner": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.core__stg_claims_procedure": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.normalized_input__medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.core__stg_clinical_condition": ["model.input_layer.condition"], "model.the_tuva_project.core__stg_clinical_encounter": ["model.input_layer.encounter"], "model.the_tuva_project.core__stg_clinical_lab_result": ["model.input_layer.lab_result"], "model.the_tuva_project.core__stg_clinical_location": ["model.input_layer.location"], "model.the_tuva_project.core__stg_clinical_medication": ["model.input_layer.medication"], "model.the_tuva_project.core__stg_clinical_observation": ["model.input_layer.observation"], "model.the_tuva_project.core__stg_clinical_patient": ["model.input_layer.patient"], "model.the_tuva_project.core__stg_clinical_practitioner": ["model.input_layer.practitioner"], "model.the_tuva_project.core__stg_clinical_procedure": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_to_mart"], "model.the_tuva_project.data_quality__data_quality_detail": ["model.the_tuva_project.data_quality__data_quality_claims_detail", "model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__data_quality_for_pbi": ["model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi"], "model.the_tuva_project.data_quality__quality_trend": ["model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__raw_summary": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__summary": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "model.the_tuva_project.data_quality__data_quality_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"], "model.the_tuva_project.data_quality__eligibility_address": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_birth_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_city": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_data_source": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_death_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_death_flag": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_dual_status_code": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_dual_eligibility"], "model.the_tuva_project.data_quality__eligibility_end_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_first_name": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_gender": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__gender"], "model.the_tuva_project.data_quality__eligibility_last_name": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_medicare_status_code": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_status"], "model.the_tuva_project.data_quality__eligibility_member_id": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__medicare_orec"], "model.the_tuva_project.data_quality__eligibility_patient_id": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_payer": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_payer_type": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"], "model.the_tuva_project.data_quality__eligibility_phone": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_plan": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_race": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__race"], "model.the_tuva_project.data_quality__eligibility_start_date": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_state": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__ssa_fips_state"], "model.the_tuva_project.data_quality__eligibility_zip_code": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__claim_allowed_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_charge_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_id": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_line_end_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_line_number": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_line_start_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_claim_type": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__claim_type"], "model.the_tuva_project.data_quality__claim_coinsurance_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_copayment_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_data_source": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_deductible_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_diagnosis_code_type": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__claim_hcpcs_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__claim_member_id": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_paid_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_paid_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_patient_id": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_payer": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_plan": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__claim_total_cost_amount": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_admission_date": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_admit_source_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_source"], "model.the_tuva_project.data_quality__institutional_admit_type_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__admit_type"], "model.the_tuva_project.data_quality__institutional_apr_drg_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__apr_drg"], "model.the_tuva_project.data_quality__institutional_billing_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__institutional_bill_type_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__bill_type"], "model.the_tuva_project.data_quality__institutional_claim_end_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_claim_start_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__institutional_discharge_date": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__discharge_disposition"], "model.the_tuva_project.data_quality__institutional_facility_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__institutional_ms_drg_code": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__institutional_present_on_admission_1": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_present_on_admission_2": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_present_on_admission_3": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__institutional_procedure_code_1": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.data_quality__institutional_procedure_code_2": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.data_quality__institutional_procedure_code_3": ["model.the_tuva_project.data_quality__stg_institutional_inpatient", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.data_quality__institutional_procedure_date_1": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_procedure_date_2": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_procedure_date_3": ["model.the_tuva_project.data_quality__stg_institutional_inpatient"], "model.the_tuva_project.data_quality__institutional_rendering_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__institutional_revenue_center_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.data_quality__institutional_service_unit_quantity": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__professional_billing_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__professional_claim_end_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__professional_claim_start_date": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__professional_diagnosis_code_1": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__professional_diagnosis_code_2": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__professional_diagnosis_code_3": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__professional_facility_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__professional_place_of_service_code": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__place_of_service"], "model.the_tuva_project.data_quality__professional_rendering_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_allowed_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_claim_id": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_claim_line_number": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_copayment_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_data_source": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_days_supply": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_deductible_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_dispensing_date": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_member_id": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_ndc_code": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.data_quality__pharmacy_paid_amount": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_paid_date": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_patient_id": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_payer": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_plan": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_quantity": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_refills": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__condition_claim_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_condition_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_condition_rank": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_condition_type": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_data_source": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_encounter_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_normalized_code": ["model.input_layer.condition", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__condition_normalized_code_type": ["model.input_layer.condition", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__condition_normalized_description": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_onset_date": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_patient_id": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_present_on_admit_code": ["model.input_layer.condition", "seed.the_tuva_project.terminology__present_on_admission"], "model.the_tuva_project.data_quality__condition_present_on_admit_description": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_recorded_date": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_resolved_date": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_source_code": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_source_code_type": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_source_description": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__condition_status": ["model.input_layer.condition"], "model.the_tuva_project.data_quality__encounter_admit_source_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_source"], "model.the_tuva_project.data_quality__encounter_admit_source_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_admit_type_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__admit_type"], "model.the_tuva_project.data_quality__encounter_admit_type_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_allowed_amount": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_apr_drg_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__apr_drg"], "model.the_tuva_project.data_quality__encounter_apr_drg_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_attending_provider_id": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__encounter_charge_amount": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_data_source": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__discharge_disposition"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_encounter_end_date": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_encounter_id": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_encounter_start_date": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_encounter_type": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__encounter_type"], "model.the_tuva_project.data_quality__encounter_facility_id": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__encounter_length_of_stay": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_ms_drg_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__encounter_ms_drg_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_paid_amount": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_patient_id": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": ["model.input_layer.encounter", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": ["model.input_layer.encounter", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": ["model.input_layer.encounter"], "model.the_tuva_project.data_quality__lab_result_accession_number": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_collection_date": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_data_source": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_encounter_id": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_lab_result_id": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_code": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"], "model.the_tuva_project.data_quality__lab_result_normalized_code_type": ["model.input_layer.lab_result", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__lab_result_normalized_component": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__loinc"], "model.the_tuva_project.data_quality__lab_result_normalized_description": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_normalized_units": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": ["model.input_layer.lab_result", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__lab_result_patient_id": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_result": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_result_date": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_code": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_code_type": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_component": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_description": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_source_units": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_specimen": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__lab_result_status": ["model.input_layer.lab_result"], "model.the_tuva_project.data_quality__location_address": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_city": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_data_source": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_facility_type": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_latitude": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_location_id": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_longitude": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_name": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_npi": ["model.input_layer.location", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__location_parent_organization": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_state": ["model.input_layer.location"], "model.the_tuva_project.data_quality__location_zip_code": ["model.input_layer.location"], "model.the_tuva_project.data_quality__medication_atc_code": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.data_quality__medication_atc_description": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_data_source": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_days_supply": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_dispensing_date": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_encounter_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_medication_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_ndc_code": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_ndc_description": ["model.input_layer.medication", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.data_quality__medication_patient_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_practitioner_id": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_prescribing_date": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_quantity": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_quantity_unit": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_route": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_rxnorm_code": ["model.input_layer.medication", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.data_quality__medication_rxnorm_description": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_source_code": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_source_code_type": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_source_description": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__medication_strength": ["model.input_layer.medication"], "model.the_tuva_project.data_quality__observation_data_source": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_encounter_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_code": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_code_type": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_description": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_normalized_units": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_observation_date": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_observation_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_observation_type": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_panel_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_patient_id": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_result": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_code": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_code_type": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_description": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_reference_range_high": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_reference_range_low": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__observation_source_units": ["model.input_layer.observation"], "model.the_tuva_project.data_quality__patient_address": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_birth_date": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_city": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_county": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_data_source": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_death_date": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_death_flag": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_first_name": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_last_name": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_latitude": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_longitude": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_patient_id": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_race": ["model.input_layer.patient", "seed.the_tuva_project.terminology__race"], "model.the_tuva_project.data_quality__patient_sex": ["model.input_layer.patient", "seed.the_tuva_project.terminology__gender"], "model.the_tuva_project.data_quality__patient_state": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__patient_zip_code": ["model.input_layer.patient"], "model.the_tuva_project.data_quality__practitioner_data_source": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_first_name": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_last_name": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_npi": ["model.input_layer.practitioner", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__practitioner_practice_affiliation": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_practitioner_id": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_specialty": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__practitioner_sub_specialty": ["model.input_layer.practitioner"], "model.the_tuva_project.data_quality__procedure_claim_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_data_source": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_encounter_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_modifier_1": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_2": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_3": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_4": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_modifier_5": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2"], "model.the_tuva_project.data_quality__procedure_normalized_code": ["model.input_layer.procedure", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_pcs"], "model.the_tuva_project.data_quality__procedure_normalized_code_type": ["model.input_layer.procedure", "seed.the_tuva_project.reference_data__code_type"], "model.the_tuva_project.data_quality__procedure_normalized_description": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_patient_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_practitioner_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_procedure_date": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_procedure_id": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_source_code": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_source_code_type": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__procedure_source_description": ["model.input_layer.procedure"], "model.the_tuva_project.data_quality__unique_value_examples": ["model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "model.the_tuva_project.data_quality__primary_keys_location_location_id", "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"], "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": ["model.the_tuva_project.data_quality__condition_condition_id"], "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": ["model.the_tuva_project.data_quality__encounter_encounter_id"], "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": ["model.the_tuva_project.data_quality__lab_result_lab_result_id"], "model.the_tuva_project.data_quality__primary_keys_location_location_id": ["model.the_tuva_project.data_quality__location_location_id"], "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": ["model.the_tuva_project.data_quality__medication_medication_id"], "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": ["model.the_tuva_project.data_quality__observation_observation_id"], "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": ["model.the_tuva_project.data_quality__patient_patient_id"], "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": ["model.the_tuva_project.data_quality__practitioner_practitioner_id"], "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": ["model.the_tuva_project.data_quality__procedure_procedure_id"], "model.the_tuva_project.data_quality__claim_type_summary": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__data_quality_claims_detail": ["model.the_tuva_project.data_quality__claim_allowed_amount", "model.the_tuva_project.data_quality__claim_charge_amount", "model.the_tuva_project.data_quality__claim_claim_id", "model.the_tuva_project.data_quality__claim_claim_line_end_date", "model.the_tuva_project.data_quality__claim_claim_line_number", "model.the_tuva_project.data_quality__claim_claim_line_start_date", "model.the_tuva_project.data_quality__claim_claim_type", "model.the_tuva_project.data_quality__claim_coinsurance_amount", "model.the_tuva_project.data_quality__claim_copayment_amount", "model.the_tuva_project.data_quality__claim_data_source", "model.the_tuva_project.data_quality__claim_deductible_amount", "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__claim_member_id", "model.the_tuva_project.data_quality__claim_paid_amount", "model.the_tuva_project.data_quality__claim_paid_date", "model.the_tuva_project.data_quality__claim_patient_id", "model.the_tuva_project.data_quality__claim_payer", "model.the_tuva_project.data_quality__claim_plan", "model.the_tuva_project.data_quality__claim_total_cost_amount", "model.the_tuva_project.data_quality__eligibility_address", "model.the_tuva_project.data_quality__eligibility_birth_date", "model.the_tuva_project.data_quality__eligibility_city", "model.the_tuva_project.data_quality__eligibility_data_source", "model.the_tuva_project.data_quality__eligibility_death_date", "model.the_tuva_project.data_quality__eligibility_death_flag", "model.the_tuva_project.data_quality__eligibility_dual_status_code", "model.the_tuva_project.data_quality__eligibility_end_date", "model.the_tuva_project.data_quality__eligibility_first_name", "model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__eligibility_last_name", "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "model.the_tuva_project.data_quality__eligibility_member_id", "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "model.the_tuva_project.data_quality__eligibility_patient_id", "model.the_tuva_project.data_quality__eligibility_payer", "model.the_tuva_project.data_quality__eligibility_payer_type", "model.the_tuva_project.data_quality__eligibility_phone", "model.the_tuva_project.data_quality__eligibility_plan", "model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__eligibility_start_date", "model.the_tuva_project.data_quality__eligibility_state", "model.the_tuva_project.data_quality__eligibility_zip_code", "model.the_tuva_project.data_quality__institutional_admission_date", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_claim_end_date", "model.the_tuva_project.data_quality__institutional_claim_start_date", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__institutional_discharge_date", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__institutional_procedure_date_1", "model.the_tuva_project.data_quality__institutional_procedure_date_2", "model.the_tuva_project.data_quality__institutional_procedure_date_3", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "model.the_tuva_project.data_quality__pharmacy_claim_id", "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "model.the_tuva_project.data_quality__pharmacy_data_source", "model.the_tuva_project.data_quality__pharmacy_days_supply", "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_member_id", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.data_quality__pharmacy_paid_amount", "model.the_tuva_project.data_quality__pharmacy_paid_date", "model.the_tuva_project.data_quality__pharmacy_patient_id", "model.the_tuva_project.data_quality__pharmacy_payer", "model.the_tuva_project.data_quality__pharmacy_plan", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_quantity", "model.the_tuva_project.data_quality__pharmacy_refills", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_claim_end_date", "model.the_tuva_project.data_quality__professional_claim_start_date", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.data_quality__professional_rendering_npi"], "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__data_quality_clinical_detail": ["model.the_tuva_project.data_quality__condition_claim_id", "model.the_tuva_project.data_quality__condition_condition_id", "model.the_tuva_project.data_quality__condition_condition_rank", "model.the_tuva_project.data_quality__condition_condition_type", "model.the_tuva_project.data_quality__condition_data_source", "model.the_tuva_project.data_quality__condition_encounter_id", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__condition_normalized_description", "model.the_tuva_project.data_quality__condition_onset_date", "model.the_tuva_project.data_quality__condition_patient_id", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.data_quality__condition_present_on_admit_description", "model.the_tuva_project.data_quality__condition_recorded_date", "model.the_tuva_project.data_quality__condition_resolved_date", "model.the_tuva_project.data_quality__condition_source_code", "model.the_tuva_project.data_quality__condition_source_code_type", "model.the_tuva_project.data_quality__condition_source_description", "model.the_tuva_project.data_quality__condition_status", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__encounter_admit_source_description", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__encounter_admit_type_description", "model.the_tuva_project.data_quality__encounter_allowed_amount", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__encounter_apr_drg_description", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_charge_amount", "model.the_tuva_project.data_quality__encounter_data_source", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "model.the_tuva_project.data_quality__encounter_encounter_end_date", "model.the_tuva_project.data_quality__encounter_encounter_id", "model.the_tuva_project.data_quality__encounter_encounter_start_date", "model.the_tuva_project.data_quality__encounter_encounter_type", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__encounter_length_of_stay", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__encounter_ms_drg_description", "model.the_tuva_project.data_quality__encounter_paid_amount", "model.the_tuva_project.data_quality__encounter_patient_id", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "model.the_tuva_project.data_quality__lab_result_accession_number", "model.the_tuva_project.data_quality__lab_result_collection_date", "model.the_tuva_project.data_quality__lab_result_data_source", "model.the_tuva_project.data_quality__lab_result_encounter_id", "model.the_tuva_project.data_quality__lab_result_lab_result_id", "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_component", "model.the_tuva_project.data_quality__lab_result_normalized_description", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "model.the_tuva_project.data_quality__lab_result_normalized_units", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__lab_result_patient_id", "model.the_tuva_project.data_quality__lab_result_result", "model.the_tuva_project.data_quality__lab_result_result_date", "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_source_code", "model.the_tuva_project.data_quality__lab_result_source_code_type", "model.the_tuva_project.data_quality__lab_result_source_component", "model.the_tuva_project.data_quality__lab_result_source_description", "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "model.the_tuva_project.data_quality__lab_result_source_units", "model.the_tuva_project.data_quality__lab_result_specimen", "model.the_tuva_project.data_quality__lab_result_status", "model.the_tuva_project.data_quality__location_address", "model.the_tuva_project.data_quality__location_city", "model.the_tuva_project.data_quality__location_data_source", "model.the_tuva_project.data_quality__location_facility_type", "model.the_tuva_project.data_quality__location_latitude", "model.the_tuva_project.data_quality__location_location_id", "model.the_tuva_project.data_quality__location_longitude", "model.the_tuva_project.data_quality__location_name", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__location_parent_organization", "model.the_tuva_project.data_quality__location_state", "model.the_tuva_project.data_quality__location_zip_code", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_atc_description", "model.the_tuva_project.data_quality__medication_data_source", "model.the_tuva_project.data_quality__medication_days_supply", "model.the_tuva_project.data_quality__medication_dispensing_date", "model.the_tuva_project.data_quality__medication_encounter_id", "model.the_tuva_project.data_quality__medication_medication_id", "model.the_tuva_project.data_quality__medication_ndc_code", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__medication_patient_id", "model.the_tuva_project.data_quality__medication_practitioner_id", "model.the_tuva_project.data_quality__medication_prescribing_date", "model.the_tuva_project.data_quality__medication_quantity", "model.the_tuva_project.data_quality__medication_quantity_unit", "model.the_tuva_project.data_quality__medication_route", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.data_quality__medication_rxnorm_description", "model.the_tuva_project.data_quality__medication_source_code", "model.the_tuva_project.data_quality__medication_source_code_type", "model.the_tuva_project.data_quality__medication_source_description", "model.the_tuva_project.data_quality__medication_strength", "model.the_tuva_project.data_quality__observation_data_source", "model.the_tuva_project.data_quality__observation_encounter_id", "model.the_tuva_project.data_quality__observation_normalized_code", "model.the_tuva_project.data_quality__observation_normalized_code_type", "model.the_tuva_project.data_quality__observation_normalized_description", "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "model.the_tuva_project.data_quality__observation_normalized_units", "model.the_tuva_project.data_quality__observation_observation_date", "model.the_tuva_project.data_quality__observation_observation_id", "model.the_tuva_project.data_quality__observation_observation_type", "model.the_tuva_project.data_quality__observation_panel_id", "model.the_tuva_project.data_quality__observation_patient_id", "model.the_tuva_project.data_quality__observation_result", "model.the_tuva_project.data_quality__observation_source_code", "model.the_tuva_project.data_quality__observation_source_code_type", "model.the_tuva_project.data_quality__observation_source_description", "model.the_tuva_project.data_quality__observation_source_reference_range_high", "model.the_tuva_project.data_quality__observation_source_reference_range_low", "model.the_tuva_project.data_quality__observation_source_units", "model.the_tuva_project.data_quality__patient_address", "model.the_tuva_project.data_quality__patient_birth_date", "model.the_tuva_project.data_quality__patient_city", "model.the_tuva_project.data_quality__patient_county", "model.the_tuva_project.data_quality__patient_data_source", "model.the_tuva_project.data_quality__patient_death_date", "model.the_tuva_project.data_quality__patient_death_flag", "model.the_tuva_project.data_quality__patient_first_name", "model.the_tuva_project.data_quality__patient_last_name", "model.the_tuva_project.data_quality__patient_latitude", "model.the_tuva_project.data_quality__patient_longitude", "model.the_tuva_project.data_quality__patient_patient_id", "model.the_tuva_project.data_quality__patient_race", "model.the_tuva_project.data_quality__patient_sex", "model.the_tuva_project.data_quality__patient_state", "model.the_tuva_project.data_quality__patient_zip_code", "model.the_tuva_project.data_quality__practitioner_data_source", "model.the_tuva_project.data_quality__practitioner_first_name", "model.the_tuva_project.data_quality__practitioner_last_name", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "model.the_tuva_project.data_quality__practitioner_practitioner_id", "model.the_tuva_project.data_quality__practitioner_specialty", "model.the_tuva_project.data_quality__practitioner_sub_specialty", "model.the_tuva_project.data_quality__procedure_claim_id", "model.the_tuva_project.data_quality__procedure_data_source", "model.the_tuva_project.data_quality__procedure_encounter_id", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.data_quality__procedure_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_description", "model.the_tuva_project.data_quality__procedure_patient_id", "model.the_tuva_project.data_quality__procedure_practitioner_id", "model.the_tuva_project.data_quality__procedure_procedure_date", "model.the_tuva_project.data_quality__procedure_procedure_id", "model.the_tuva_project.data_quality__procedure_source_code", "model.the_tuva_project.data_quality__procedure_source_code_type", "model.the_tuva_project.data_quality__procedure_source_description"], "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "seed.the_tuva_project.data_quality__crosswalk_field_info"], "model.the_tuva_project.mart_review__calendar_month": ["seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__claims_with_enrollment": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.mart_review__stg_medical_claim"], "model.the_tuva_project.mart_review__data_source": ["model.the_tuva_project.core__condition", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__location", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__patient", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__practitioner", "model.the_tuva_project.core__procedure"], "model.the_tuva_project.mart_review__ed_classification": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__location", "model.the_tuva_project.ed_classification__summary", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems"], "model.the_tuva_project.mart_review__enrollment_change": ["model.the_tuva_project.mart_review__stg_member_month"], "model.the_tuva_project.mart_review__generics": ["model.the_tuva_project.pharmacy__generic_available_list"], "model.the_tuva_project.mart_review__inpatient": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__location", "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems", "seed.the_tuva_project.terminology__ms_drg_weights_los"], "model.the_tuva_project.mart_review__members_with_claims": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.mart_review__stg_pharmacy_claim"], "model.the_tuva_project.mart_review__member_months": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.mart_review__number_of_conditions": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__patient"], "model.the_tuva_project.mart_review__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.mart_review__patient_risk": ["model.the_tuva_project.mart_review__patient_risk_factors"], "model.the_tuva_project.mart_review__patient_risk_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.mart_review__patient_risk_scores": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "model.the_tuva_project.mart_review__pharmacy": ["model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__practitioner", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "seed.the_tuva_project.terminology__ndc", "seed.the_tuva_project.terminology__rxnorm_brand_generic", "seed.the_tuva_project.terminology__rxnorm_to_atc"], "model.the_tuva_project.mart_review__pmpm": ["model.the_tuva_project.financial_pmpm__pmpm_payer"], "model.the_tuva_project.mart_review__quality_measures_summary_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.mart_review__quality_measures_value_set": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.mart_review__readmissions": ["model.the_tuva_project.readmissions__readmission_summary"], "model.the_tuva_project.mart_review__service_categories_long": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories", "model.the_tuva_project.mart_review__stg_medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__tuva_chronic_conditions": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__patient"], "model.the_tuva_project.mart_review__stg_medical_claim": ["model.the_tuva_project.core__medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__stg_member_month": ["model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.mart_review__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__stg_eligibility": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__stg_institutional_inpatient": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__stg_medical_claim": ["model.input_layer.medical_claim"], "model.the_tuva_project.data_quality__stg_pharmacy_claim": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__analytics_checks_summary": ["model.the_tuva_project.data_quality__acute_inpatient", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__cms_hcc", "model.the_tuva_project.data_quality__ed_classification", "model.the_tuva_project.data_quality__encounters_missing_groups_union", "model.the_tuva_project.data_quality__quality_measures", "model.the_tuva_project.data_quality__readmissions"], "model.the_tuva_project.data_quality__analytics_populated": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.cms_hcc__patient_risk_factors", "model.the_tuva_project.core__encounter", "model.the_tuva_project.financial_pmpm__pmpm_payer", "model.the_tuva_project.quality_measures__summary_long", "model.the_tuva_project.readmissions__readmission_summary", "model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.data_quality__analytics_reference_summary": ["model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__quality_measures_reference", "model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.data_quality__service_categories_pmpm"], "model.the_tuva_project.data_quality__claim_date_trends": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__core_populated": ["model.the_tuva_project.core__condition", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__encounter", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__patient", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__procedure"], "model.the_tuva_project.data_quality__data_loss": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim", "model.the_tuva_project.core__eligibility", "model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"], "model.the_tuva_project.data_quality__data_quality_test_summary": ["model.the_tuva_project.data_quality__eligibility_date_checks", "model.the_tuva_project.data_quality__eligibility_demographics", "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "model.the_tuva_project.data_quality__eligibility_missing_payer", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "model.the_tuva_project.data_quality__primary_key_check"], "model.the_tuva_project.data_quality__eligibility_trend": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": ["model.input_layer.medical_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__service_category_pmpm_trend": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__acute_inpatient": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.data_quality__acute_inpatient_prevelence": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__acute_inpatient_reference": ["model.the_tuva_project.core__encounter", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__chronic_conditions_none": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.core__patient", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__chronic_conditions_prevalence": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "model.the_tuva_project.core__eligibility", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__claim_percent": ["model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__cms_hcc": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.data_quality__cms_hcc_reference": ["model.the_tuva_project.cms_hcc__patient_risk_scores", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__dx_and_px": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__icd_10_cm", "seed.the_tuva_project.terminology__icd_10_pcs", "seed.the_tuva_project.terminology__icd_9_cm", "seed.the_tuva_project.terminology__icd_9_pcs"], "model.the_tuva_project.data_quality__ed_classification": ["model.the_tuva_project.ed_classification__summary"], "model.the_tuva_project.data_quality__ed_classification_reference": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.ed_classification__summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__eligibility_date_checks": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_demographics": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_missing_patient_id": ["model.input_layer.eligibility"], "model.the_tuva_project.data_quality__eligibility_missing_payer": ["model.input_layer.eligibility", "seed.the_tuva_project.terminology__payer_type"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization": ["model.the_tuva_project.core__encounter", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__encounters_missing_groups": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.data_quality__encounters_missing_groups_union": ["model.the_tuva_project.data_quality__encounters_missing_groups"], "model.the_tuva_project.data_quality__financial_pmpm": ["model.the_tuva_project.financial_pmpm__pmpm_prep", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__hcpcs_level_2", "seed.the_tuva_project.terminology__place_of_service", "seed.the_tuva_project.terminology__revenue_center"], "model.the_tuva_project.data_quality__medical_claim_date_checks": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage"], "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__inpatient_dq_stage", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__bill_type", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.data_quality__medical_claim_patient_id": ["model.input_layer.medical_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"], "model.the_tuva_project.data_quality__medical_claim_provider_npi": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__pharmacy_claim_ndc": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.data_quality__pharmacy_claim_npi": ["model.input_layer.pharmacy_claim", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": ["model.input_layer.pharmacy_claim", "model.the_tuva_project.data_quality__eligibility_dq_stage"], "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": ["model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__primary_key_check": ["model.input_layer.eligibility", "model.input_layer.medical_claim", "model.input_layer.pharmacy_claim"], "model.the_tuva_project.data_quality__quality_measures": ["model.the_tuva_project.quality_measures__summary_counts"], "model.the_tuva_project.data_quality__quality_measures_reference": ["model.the_tuva_project.quality_measures__summary_counts", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__readmissions": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.data_quality__readmissions_reference": ["model.the_tuva_project.readmissions__readmission_summary", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__service_categories_pmpm": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__member_months", "seed.the_tuva_project.data_quality__reference_mart_analytics"], "model.the_tuva_project.data_quality__eligibility_dq_stage": ["model.input_layer.eligibility", "seed.the_tuva_project.reference_data__calendar"], "model.the_tuva_project.data_quality__inpatient_dq_stage": ["model.input_layer.medical_claim", "seed.the_tuva_project.terminology__apr_drg", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.ed_classification__summary": ["model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "model.the_tuva_project.ed_classification__stg_patient", "seed.the_tuva_project.ed_classification__categories", "seed.the_tuva_project.terminology__provider"], "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": ["model.the_tuva_project.ed_classification__int_map_primary_dx"], "model.the_tuva_project.ed_classification__int_map_primary_dx": ["model.the_tuva_project.ed_classification__stg_encounter", "seed.the_tuva_project.ed_classification__johnston_icd10", "seed.the_tuva_project.ed_classification__johnston_icd9"], "model.the_tuva_project.ed_classification__stg_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.ed_classification__stg_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.financial_pmpm__pmpm_payer": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__pmpm_prep": ["model.the_tuva_project.core__member_months", "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot"], "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": ["model.the_tuva_project.financial_pmpm__stg_medical_claim", "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim"], "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__stg_eligibility": ["model.the_tuva_project.core__eligibility"], "model.the_tuva_project.financial_pmpm__stg_medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.financial_pmpm__stg_provider_attribution": ["model.input_layer.provider_attribution"], "model.the_tuva_project.hcc_suspecting__list": ["model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"], "model.the_tuva_project.hcc_suspecting__list_rollup": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__summary": ["model.the_tuva_project.hcc_suspecting__list", "model.the_tuva_project.hcc_suspecting__stg_core__patient"], "model.the_tuva_project.hcc_suspecting__int_all_conditions": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings"], "model.the_tuva_project.hcc_suspecting__int_all_medications": ["model.the_tuva_project.hcc_suspecting__stg_core__medication", "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim"], "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_lab_suspects": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_medication_suspects": ["model.the_tuva_project.hcc_suspecting__int_all_medications", "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_observation_suspects": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "model.the_tuva_project.hcc_suspecting__stg_core__observation", "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "seed.the_tuva_project.hcc_suspecting__hcc_descriptions"], "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": ["model.the_tuva_project.hcc_suspecting__int_all_conditions"], "model.the_tuva_project.hcc_suspecting__int_prep_conditions": ["model.the_tuva_project.hcc_suspecting__stg_core__condition", "seed.the_tuva_project.terminology__snomed_icd_10_map"], "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": ["model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "seed.the_tuva_project.hcc_suspecting__clinical_concepts"], "model.the_tuva_project.hcc_suspecting__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.hcc_suspecting__stg_core__lab_result": ["model.the_tuva_project.core__lab_result"], "model.the_tuva_project.hcc_suspecting__stg_core__medication": ["model.the_tuva_project.core__medication"], "model.the_tuva_project.hcc_suspecting__stg_core__observation": ["model.the_tuva_project.core__observation"], "model.the_tuva_project.hcc_suspecting__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.pharmacy__brand_generic_opportunity": ["model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__int_generic_cost", "model.the_tuva_project.pharmacy__stg_pharmacy_claim"], "model.the_tuva_project.pharmacy__generic_available_list": ["model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": ["model.the_tuva_project.pharmacy__brand_generic_opportunity", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic"], "model.the_tuva_project.pharmacy__int_brand_with_generic_available": ["seed.the_tuva_project.pharmacy__rxnorm_generic_available"], "model.the_tuva_project.pharmacy__int_claims_current_cost": ["model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "seed.the_tuva_project.terminology__rxnorm_brand_generic"], "model.the_tuva_project.pharmacy__int_generic_cost": ["model.the_tuva_project.pharmacy__int_claims_current_cost", "seed.the_tuva_project.pharmacy__rxnorm_generic_available"], "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": ["model.the_tuva_project.pharmacy__int_claims_current_cost", "seed.the_tuva_project.pharmacy__rxnorm_generic_available"], "model.the_tuva_project.pharmacy__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim", "seed.the_tuva_project.terminology__ndc"], "model.the_tuva_project.quality_measures__summary_counts": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__summary_long": ["model.the_tuva_project.quality_measures__int_adh_diabetes_long", "model.the_tuva_project.quality_measures__int_adhras_long", "model.the_tuva_project.quality_measures__int_cbe0055_long", "model.the_tuva_project.quality_measures__int_cbe0101_long", "model.the_tuva_project.quality_measures__int_cqm130_long", "model.the_tuva_project.quality_measures__int_cqm236_long", "model.the_tuva_project.quality_measures__int_cqm438_long", "model.the_tuva_project.quality_measures__int_cqm48_long", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0041_long", "model.the_tuva_project.quality_measures__int_nqf0053_long", "model.the_tuva_project.quality_measures__int_nqf0059_long", "model.the_tuva_project.quality_measures__int_nqf0097_long", "model.the_tuva_project.quality_measures__int_nqf0420_long", "model.the_tuva_project.quality_measures__int_nqf2372_long", "model.the_tuva_project.quality_measures__stg_core__patient"], "model.the_tuva_project.quality_measures__summary_wide": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_adhras_denominator": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adhras_exclusions": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adhras_long": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_adhras_numerator"], "model.the_tuva_project.quality_measures__int_adhras_numerator": ["model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_adhras_denominator"], "model.the_tuva_project.quality_measures__int_adhras__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_adh_diabetes_long": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"], "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": ["model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator"], "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cbe0055_denominator": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_cbe0055_long": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_numerator"], "model.the_tuva_project.quality_measures__int_cbe0055_numerator": ["model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cbe0101_denominator": ["model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0101_long": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator"], "model.the_tuva_project.quality_measures__int_cbe0101_numerator": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm130_denominator": ["model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm130_exclusions": ["model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm130_long": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator"], "model.the_tuva_project.quality_measures__int_cqm130_numerator": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm130__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm236_denominator": ["model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm236_exclusions": ["model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_cqm236_long": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_numerator"], "model.the_tuva_project.quality_measures__int_cqm236_numerator": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm236__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm438_denominator": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_exclusions": ["model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438_long": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator"], "model.the_tuva_project.quality_measures__int_cqm438_numerator": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm438__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_cqm48_denominator": ["model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm48_exclusions": ["model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"], "model.the_tuva_project.quality_measures__int_cqm48_long": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_numerator"], "model.the_tuva_project.quality_measures__int_cqm48_numerator": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_cqm48__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0034_denominator": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": ["model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf0034_long": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0034_numerator": ["model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": [], "model.the_tuva_project.quality_measures__int_nqf0041_denominator": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0041_long": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator"], "model.the_tuva_project.quality_measures__int_nqf0041_numerator": ["model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0053_denominator": ["model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": ["model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf0053_long": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_numerator"], "model.the_tuva_project.quality_measures__int_nqf0053_numerator": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0059_denominator": ["model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf0059_long": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf0059_numerator"], "model.the_tuva_project.quality_measures__int_nqf0059_numerator": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__stg_core__lab_result", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0420_denominator": ["model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0420_long": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator"], "model.the_tuva_project.quality_measures__int_nqf0420_numerator": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf2372_denominator": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": ["model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__int_nqf2372_long": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_numerator"], "model.the_tuva_project.quality_measures__int_nqf2372_numerator": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_nqf0097_denominator": ["model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__concepts", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"], "model.the_tuva_project.quality_measures__int_nqf0097_long": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "model.the_tuva_project.quality_measures__int_nqf0097_numerator"], "model.the_tuva_project.quality_measures__int_nqf0097_numerator": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__stg_core__procedure", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": ["seed.the_tuva_project.quality_measures__measures"], "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": ["model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__stg_core__medication", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": ["model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": ["model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.quality_measures__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.quality_measures__stg_medical_claim", "seed.the_tuva_project.quality_measures__value_sets"], "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": ["model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.quality_measures__stg_medical_claim"], "model.the_tuva_project.quality_measures__stg_core__condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.quality_measures__stg_core__encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.quality_measures__stg_core__lab_result": ["model.the_tuva_project.core__lab_result"], "model.the_tuva_project.quality_measures__stg_core__medication": ["model.the_tuva_project.core__medication"], "model.the_tuva_project.quality_measures__stg_core__observation": ["model.the_tuva_project.core__observation"], "model.the_tuva_project.quality_measures__stg_core__patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.quality_measures__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.quality_measures__stg_medical_claim": ["model.the_tuva_project.core__medical_claim"], "model.the_tuva_project.quality_measures__stg_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim"], "model.the_tuva_project.readmissions__encounter_augmented": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__index_admission", "model.the_tuva_project.readmissions__planned_encounter"], "model.the_tuva_project.readmissions__readmission_summary": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__encounter": ["model.the_tuva_project.readmissions__stg_core__encounter"], "model.the_tuva_project.readmissions__encounter_data_quality": ["model.the_tuva_project.readmissions__encounter_overlap", "model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.terminology__discharge_disposition", "seed.the_tuva_project.terminology__ms_drg"], "model.the_tuva_project.readmissions__encounter_overlap": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__encounter_specialty_cohort": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__specialty_cohort", "seed.the_tuva_project.readmissions__surgery_gynecology_cohort"], "model.the_tuva_project.readmissions__encounter_with_ccs": ["model.the_tuva_project.readmissions__encounter", "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs", "seed.the_tuva_project.terminology__icd_10_cm"], "model.the_tuva_project.readmissions__exclusion": ["model.the_tuva_project.readmissions__encounter_with_ccs", "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category"], "model.the_tuva_project.readmissions__index_admission": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__exclusion", "model.the_tuva_project.readmissions__index_discharge_requirement", "model.the_tuva_project.readmissions__index_time_requirement"], "model.the_tuva_project.readmissions__index_discharge_requirement": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__index_time_requirement": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__planned_encounter": ["model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__procedure_ccs", "seed.the_tuva_project.readmissions__acute_diagnosis_ccs", "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs"], "model.the_tuva_project.readmissions__procedure_ccs": ["model.the_tuva_project.readmissions__stg_core__procedure", "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs", "seed.the_tuva_project.terminology__icd_10_pcs"], "model.the_tuva_project.readmissions__readmission_crude": ["model.the_tuva_project.readmissions__encounter", "model.the_tuva_project.readmissions__encounter_overlap"], "model.the_tuva_project.readmissions__stg_core__encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.readmissions__stg_core__procedure": ["model.the_tuva_project.core__procedure"], "seed.the_tuva_project.clinical_concept_library__clinical_concepts": [], "seed.the_tuva_project.clinical_concept_library__coding_systems": [], "seed.the_tuva_project.clinical_concept_library__value_set_members": [], "seed.the_tuva_project.reference_data__ansi_fips_state": [], "seed.the_tuva_project.reference_data__calendar": [], "seed.the_tuva_project.reference_data__code_type": [], "seed.the_tuva_project.reference_data__fips_county": [], "seed.the_tuva_project.reference_data__ssa_fips_state": [], "seed.the_tuva_project.terminology__admit_source": [], "seed.the_tuva_project.terminology__admit_type": [], "seed.the_tuva_project.terminology__apr_drg": [], "seed.the_tuva_project.terminology__bill_type": [], "seed.the_tuva_project.terminology__ccs_services_procedures": [], "seed.the_tuva_project.terminology__claim_type": [], "seed.the_tuva_project.terminology__discharge_disposition": [], "seed.the_tuva_project.terminology__encounter_type": [], "seed.the_tuva_project.terminology__ethnicity": [], "seed.the_tuva_project.terminology__gender": [], "seed.the_tuva_project.terminology__hcpcs_level_2": [], "seed.the_tuva_project.terminology__hcpcs_to_rbcs": [], "seed.the_tuva_project.terminology__icd_10_cm": [], "seed.the_tuva_project.terminology__icd_10_pcs": [], "seed.the_tuva_project.terminology__icd_9_cm": [], "seed.the_tuva_project.terminology__icd_9_pcs": [], "seed.the_tuva_project.terminology__loinc": [], "seed.the_tuva_project.terminology__loinc_deprecated_mapping": [], "seed.the_tuva_project.terminology__mdc": [], "seed.the_tuva_project.terminology__medicare_dual_eligibility": [], "seed.the_tuva_project.terminology__medicare_orec": [], "seed.the_tuva_project.terminology__medicare_status": [], "seed.the_tuva_project.terminology__ms_drg": [], "seed.the_tuva_project.terminology__ms_drg_weights_los": [], "seed.the_tuva_project.terminology__ndc": [], "seed.the_tuva_project.terminology__nitos": [], "seed.the_tuva_project.terminology__other_provider_taxonomy": [], "seed.the_tuva_project.terminology__payer_type": [], "seed.the_tuva_project.terminology__place_of_service": [], "seed.the_tuva_project.terminology__present_on_admission": [], "seed.the_tuva_project.terminology__provider": [], "seed.the_tuva_project.terminology__race": [], "seed.the_tuva_project.terminology__revenue_center": [], "seed.the_tuva_project.terminology__rxnorm_brand_generic": [], "seed.the_tuva_project.terminology__rxnorm_to_atc": [], "seed.the_tuva_project.terminology__snomed_ct": [], "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": [], "seed.the_tuva_project.terminology__snomed_icd_10_map": [], "seed.the_tuva_project.pqi__measures": [], "seed.the_tuva_project.pqi__value_sets": [], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": [], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": [], "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": [], "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": [], "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": [], "seed.the_tuva_project.cms_hcc__adjustment_rates": [], "seed.the_tuva_project.cms_hcc__cpt_hcpcs": [], "seed.the_tuva_project.cms_hcc__demographic_factors": [], "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": [], "seed.the_tuva_project.cms_hcc__disease_factors": [], "seed.the_tuva_project.cms_hcc__disease_hierarchy": [], "seed.the_tuva_project.cms_hcc__disease_interaction_factors": [], "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": [], "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": [], "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": [], "seed.the_tuva_project.data_quality__crosswalk_field_info": [], "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": [], "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": [], "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": [], "seed.the_tuva_project.data_quality__reference_mart_analytics": [], "seed.the_tuva_project.ed_classification__categories": [], "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": [], "seed.the_tuva_project.ed_classification__johnston_icd10": [], "seed.the_tuva_project.ed_classification__johnston_icd9": [], "seed.the_tuva_project.hcc_suspecting__clinical_concepts": [], "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": [], "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": [], "seed.the_tuva_project.pharmacy__rxnorm_generic_available": [], "seed.the_tuva_project.quality_measures__concepts": [], "seed.the_tuva_project.quality_measures__measures": [], "seed.the_tuva_project.quality_measures__value_sets": [], "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": [], "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": [], "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": [], "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": [], "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": [], "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": [], "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": [], "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": [], "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": [], "seed.the_tuva_project.readmissions__specialty_cohort": [], "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": [], "seed.the_tuva_project.service_category__service_categories": [], "operation.the_tuva_project.the_tuva_project-on-run-end-0": [], "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617": ["seed.the_tuva_project.ed_classification__johnston_icd9"], "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0": ["seed.the_tuva_project.ed_classification__johnston_icd9"], "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd": ["seed.the_tuva_project.ed_classification__johnston_icd10"], "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7": ["seed.the_tuva_project.ed_classification__johnston_icd10"], "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"], "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d": ["model.the_tuva_project.normalized_input__medical_claim"], "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba": ["model.the_tuva_project.cms_hcc__int_demographic_factors"], "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b": ["model.the_tuva_project.cms_hcc__int_members"], "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb": ["model.the_tuva_project.cms_hcc__int_members"], "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0": ["model.the_tuva_project.core__condition"], "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a": ["model.the_tuva_project.core__eligibility"], "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792": ["model.the_tuva_project.core__encounter"], "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af": ["model.the_tuva_project.core__lab_result"], "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a": ["model.the_tuva_project.core__location"], "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708": ["model.the_tuva_project.core__medical_claim"], "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1": ["model.the_tuva_project.core__medication"], "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59": ["model.the_tuva_project.core__observation"], "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e": ["model.the_tuva_project.core__patient"], "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c": ["model.the_tuva_project.core__pharmacy_claim"], "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6": ["model.the_tuva_project.core__practitioner"], "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5": ["model.the_tuva_project.core__procedure"], "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7": ["model.the_tuva_project.pharmacy__brand_generic_opportunity"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42": ["model.the_tuva_project.pharmacy__generic_available_list"], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348": ["model.the_tuva_project.quality_measures__stg_core__condition"], "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159": ["model.the_tuva_project.quality_measures__stg_core__encounter"], "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652": ["model.the_tuva_project.quality_measures__stg_core__medication"], "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e": ["model.the_tuva_project.quality_measures__stg_core__observation"], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6": ["model.the_tuva_project.quality_measures__stg_core__patient"], "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9": ["model.the_tuva_project.quality_measures__stg_core__procedure"]}, "child_map": {"model.input_layer.condition": ["model.the_tuva_project.core__stg_clinical_condition", "model.the_tuva_project.data_quality__condition_claim_id", "model.the_tuva_project.data_quality__condition_condition_id", "model.the_tuva_project.data_quality__condition_condition_rank", "model.the_tuva_project.data_quality__condition_condition_type", "model.the_tuva_project.data_quality__condition_data_source", "model.the_tuva_project.data_quality__condition_encounter_id", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__condition_normalized_description", "model.the_tuva_project.data_quality__condition_onset_date", "model.the_tuva_project.data_quality__condition_patient_id", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.data_quality__condition_present_on_admit_description", "model.the_tuva_project.data_quality__condition_recorded_date", "model.the_tuva_project.data_quality__condition_resolved_date", "model.the_tuva_project.data_quality__condition_source_code", "model.the_tuva_project.data_quality__condition_source_code_type", "model.the_tuva_project.data_quality__condition_source_description", "model.the_tuva_project.data_quality__condition_status"], "model.input_layer.eligibility": ["model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__eligibility_address", "model.the_tuva_project.data_quality__eligibility_birth_date", "model.the_tuva_project.data_quality__eligibility_city", "model.the_tuva_project.data_quality__eligibility_data_source", "model.the_tuva_project.data_quality__eligibility_date_checks", "model.the_tuva_project.data_quality__eligibility_death_date", "model.the_tuva_project.data_quality__eligibility_death_flag", "model.the_tuva_project.data_quality__eligibility_demographics", "model.the_tuva_project.data_quality__eligibility_dq_stage", "model.the_tuva_project.data_quality__eligibility_dual_status_code", "model.the_tuva_project.data_quality__eligibility_end_date", "model.the_tuva_project.data_quality__eligibility_first_name", "model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__eligibility_last_name", "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "model.the_tuva_project.data_quality__eligibility_member_id", "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "model.the_tuva_project.data_quality__eligibility_missing_payer", "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "model.the_tuva_project.data_quality__eligibility_patient_id", "model.the_tuva_project.data_quality__eligibility_payer", "model.the_tuva_project.data_quality__eligibility_payer_type", "model.the_tuva_project.data_quality__eligibility_phone", "model.the_tuva_project.data_quality__eligibility_plan", "model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__eligibility_start_date", "model.the_tuva_project.data_quality__eligibility_state", "model.the_tuva_project.data_quality__eligibility_trend", "model.the_tuva_project.data_quality__eligibility_zip_code", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__raw_summary", "model.the_tuva_project.data_quality__stg_eligibility", "model.the_tuva_project.normalized_input__stg_eligibility"], "model.input_layer.encounter": ["model.the_tuva_project.core__stg_clinical_encounter", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__encounter_admit_source_description", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__encounter_admit_type_description", "model.the_tuva_project.data_quality__encounter_allowed_amount", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__encounter_apr_drg_description", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_charge_amount", "model.the_tuva_project.data_quality__encounter_data_source", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "model.the_tuva_project.data_quality__encounter_encounter_end_date", "model.the_tuva_project.data_quality__encounter_encounter_id", "model.the_tuva_project.data_quality__encounter_encounter_start_date", "model.the_tuva_project.data_quality__encounter_encounter_type", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__encounter_length_of_stay", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__encounter_ms_drg_description", "model.the_tuva_project.data_quality__encounter_paid_amount", "model.the_tuva_project.data_quality__encounter_patient_id", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description"], "model.input_layer.lab_result": ["model.the_tuva_project.core__stg_clinical_lab_result", "model.the_tuva_project.data_quality__lab_result_accession_number", "model.the_tuva_project.data_quality__lab_result_collection_date", "model.the_tuva_project.data_quality__lab_result_data_source", "model.the_tuva_project.data_quality__lab_result_encounter_id", "model.the_tuva_project.data_quality__lab_result_lab_result_id", "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_component", "model.the_tuva_project.data_quality__lab_result_normalized_description", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "model.the_tuva_project.data_quality__lab_result_normalized_units", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__lab_result_patient_id", "model.the_tuva_project.data_quality__lab_result_result", "model.the_tuva_project.data_quality__lab_result_result_date", "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "model.the_tuva_project.data_quality__lab_result_source_code", "model.the_tuva_project.data_quality__lab_result_source_code_type", "model.the_tuva_project.data_quality__lab_result_source_component", "model.the_tuva_project.data_quality__lab_result_source_description", "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "model.the_tuva_project.data_quality__lab_result_source_units", "model.the_tuva_project.data_quality__lab_result_specimen", "model.the_tuva_project.data_quality__lab_result_status"], "model.input_layer.location": ["model.the_tuva_project.core__stg_clinical_location", "model.the_tuva_project.data_quality__location_address", "model.the_tuva_project.data_quality__location_city", "model.the_tuva_project.data_quality__location_data_source", "model.the_tuva_project.data_quality__location_facility_type", "model.the_tuva_project.data_quality__location_latitude", "model.the_tuva_project.data_quality__location_location_id", "model.the_tuva_project.data_quality__location_longitude", "model.the_tuva_project.data_quality__location_name", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__location_parent_organization", "model.the_tuva_project.data_quality__location_state", "model.the_tuva_project.data_quality__location_zip_code"], "model.input_layer.medical_claim": ["model.the_tuva_project.data_quality__claim_allowed_amount", "model.the_tuva_project.data_quality__claim_charge_amount", "model.the_tuva_project.data_quality__claim_claim_id", "model.the_tuva_project.data_quality__claim_claim_line_end_date", "model.the_tuva_project.data_quality__claim_claim_line_number", "model.the_tuva_project.data_quality__claim_claim_line_start_date", "model.the_tuva_project.data_quality__claim_claim_type", "model.the_tuva_project.data_quality__claim_coinsurance_amount", "model.the_tuva_project.data_quality__claim_copayment_amount", "model.the_tuva_project.data_quality__claim_data_source", "model.the_tuva_project.data_quality__claim_date_trends", "model.the_tuva_project.data_quality__claim_deductible_amount", "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__claim_member_id", "model.the_tuva_project.data_quality__claim_paid_amount", "model.the_tuva_project.data_quality__claim_paid_date", "model.the_tuva_project.data_quality__claim_patient_id", "model.the_tuva_project.data_quality__claim_payer", "model.the_tuva_project.data_quality__claim_percent", "model.the_tuva_project.data_quality__claim_plan", "model.the_tuva_project.data_quality__claim_total_cost_amount", "model.the_tuva_project.data_quality__claim_type_summary", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__inpatient_dq_stage", "model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_claim_end_date", "model.the_tuva_project.data_quality__institutional_claim_start_date", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_claim_end_date", "model.the_tuva_project.data_quality__professional_claim_start_date", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.data_quality__professional_rendering_npi", "model.the_tuva_project.data_quality__raw_summary", "model.the_tuva_project.data_quality__stg_institutional_inpatient", "model.the_tuva_project.data_quality__stg_medical_claim", "model.the_tuva_project.medical_claim_expanded", "model.the_tuva_project.normalized_input__stg_medical_claim"], "model.input_layer.medication": ["model.the_tuva_project.core__stg_clinical_medication", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_atc_description", "model.the_tuva_project.data_quality__medication_data_source", "model.the_tuva_project.data_quality__medication_days_supply", "model.the_tuva_project.data_quality__medication_dispensing_date", "model.the_tuva_project.data_quality__medication_encounter_id", "model.the_tuva_project.data_quality__medication_medication_id", "model.the_tuva_project.data_quality__medication_ndc_code", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__medication_patient_id", "model.the_tuva_project.data_quality__medication_practitioner_id", "model.the_tuva_project.data_quality__medication_prescribing_date", "model.the_tuva_project.data_quality__medication_quantity", "model.the_tuva_project.data_quality__medication_quantity_unit", "model.the_tuva_project.data_quality__medication_route", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.data_quality__medication_rxnorm_description", "model.the_tuva_project.data_quality__medication_source_code", "model.the_tuva_project.data_quality__medication_source_code_type", "model.the_tuva_project.data_quality__medication_source_description", "model.the_tuva_project.data_quality__medication_strength"], "model.input_layer.observation": ["model.the_tuva_project.core__stg_clinical_observation", "model.the_tuva_project.data_quality__observation_data_source", "model.the_tuva_project.data_quality__observation_encounter_id", "model.the_tuva_project.data_quality__observation_normalized_code", "model.the_tuva_project.data_quality__observation_normalized_code_type", "model.the_tuva_project.data_quality__observation_normalized_description", "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "model.the_tuva_project.data_quality__observation_normalized_units", "model.the_tuva_project.data_quality__observation_observation_date", "model.the_tuva_project.data_quality__observation_observation_id", "model.the_tuva_project.data_quality__observation_observation_type", "model.the_tuva_project.data_quality__observation_panel_id", "model.the_tuva_project.data_quality__observation_patient_id", "model.the_tuva_project.data_quality__observation_result", "model.the_tuva_project.data_quality__observation_source_code", "model.the_tuva_project.data_quality__observation_source_code_type", "model.the_tuva_project.data_quality__observation_source_description", "model.the_tuva_project.data_quality__observation_source_reference_range_high", "model.the_tuva_project.data_quality__observation_source_reference_range_low", "model.the_tuva_project.data_quality__observation_source_units"], "model.input_layer.patient": ["model.the_tuva_project.core__stg_clinical_patient", "model.the_tuva_project.data_quality__patient_address", "model.the_tuva_project.data_quality__patient_birth_date", "model.the_tuva_project.data_quality__patient_city", "model.the_tuva_project.data_quality__patient_county", "model.the_tuva_project.data_quality__patient_data_source", "model.the_tuva_project.data_quality__patient_death_date", "model.the_tuva_project.data_quality__patient_death_flag", "model.the_tuva_project.data_quality__patient_first_name", "model.the_tuva_project.data_quality__patient_last_name", "model.the_tuva_project.data_quality__patient_latitude", "model.the_tuva_project.data_quality__patient_longitude", "model.the_tuva_project.data_quality__patient_patient_id", "model.the_tuva_project.data_quality__patient_race", "model.the_tuva_project.data_quality__patient_sex", "model.the_tuva_project.data_quality__patient_state", "model.the_tuva_project.data_quality__patient_zip_code"], "model.input_layer.pharmacy_claim": ["model.the_tuva_project.data_quality__claim_date_trends", "model.the_tuva_project.data_quality__claim_percent", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "model.the_tuva_project.data_quality__pharmacy_claim_id", "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "model.the_tuva_project.data_quality__pharmacy_data_source", "model.the_tuva_project.data_quality__pharmacy_days_supply", "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_member_id", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.data_quality__pharmacy_paid_amount", "model.the_tuva_project.data_quality__pharmacy_paid_date", "model.the_tuva_project.data_quality__pharmacy_patient_id", "model.the_tuva_project.data_quality__pharmacy_payer", "model.the_tuva_project.data_quality__pharmacy_plan", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_quantity", "model.the_tuva_project.data_quality__pharmacy_refills", "model.the_tuva_project.data_quality__primary_key_check", "model.the_tuva_project.data_quality__raw_summary", "model.the_tuva_project.data_quality__stg_pharmacy_claim", "model.the_tuva_project.normalized_input__stg_pharmacy_claim"], "model.input_layer.practitioner": ["model.the_tuva_project.core__stg_clinical_practitioner", "model.the_tuva_project.data_quality__practitioner_data_source", "model.the_tuva_project.data_quality__practitioner_first_name", "model.the_tuva_project.data_quality__practitioner_last_name", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "model.the_tuva_project.data_quality__practitioner_practitioner_id", "model.the_tuva_project.data_quality__practitioner_specialty", "model.the_tuva_project.data_quality__practitioner_sub_specialty"], "model.input_layer.procedure": ["model.the_tuva_project.core__stg_clinical_procedure", "model.the_tuva_project.data_quality__procedure_claim_id", "model.the_tuva_project.data_quality__procedure_data_source", "model.the_tuva_project.data_quality__procedure_encounter_id", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.data_quality__procedure_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_description", "model.the_tuva_project.data_quality__procedure_patient_id", "model.the_tuva_project.data_quality__procedure_practitioner_id", "model.the_tuva_project.data_quality__procedure_procedure_date", "model.the_tuva_project.data_quality__procedure_procedure_id", "model.the_tuva_project.data_quality__procedure_source_code", "model.the_tuva_project.data_quality__procedure_source_code_type", "model.the_tuva_project.data_quality__procedure_source_description"], "model.input_layer.provider_attribution": ["model.the_tuva_project.financial_pmpm__stg_provider_attribution"], "seed.input_layer.eligibility_seed": ["model.input_layer.eligibility"], "seed.input_layer.lab_result_seed": [], "seed.input_layer.medical_claim_seed": ["model.input_layer.medical_claim"], "seed.input_layer.observation_seed": [], "seed.input_layer.pharmacy_claim_seed": ["model.input_layer.pharmacy_claim"], "seed.input_layer.provider_attribution_seed": ["model.input_layer.provider_attribution"], "model.the_tuva_project.ahrq_measures__pqi_denom_long": ["model.the_tuva_project.ahrq_measures__pqi_rate"], "model.the_tuva_project.ahrq_measures__pqi_exclusion_long": [], "model.the_tuva_project.ahrq_measures__pqi_num_long": ["model.the_tuva_project.ahrq_measures__pqi_rate", "model.the_tuva_project.ahrq_measures__pqi_summary"], "model.the_tuva_project.ahrq_measures__pqi_rate": [], "model.the_tuva_project.ahrq_measures__pqi_summary": [], "model.the_tuva_project.ahrq_measures__int_pqi_01_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_01_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_03_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_03_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_05_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_05_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_07_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_07_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_08_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_08_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_11_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_11_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_12_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_12_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_14_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_14_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_15_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_15_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_16_denom": ["model.the_tuva_project.ahrq_measures__int_pqi_16_num", "model.the_tuva_project.ahrq_measures__pqi_denom_long"], "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions": ["model.the_tuva_project.ahrq_measures__int_pqi_16_num", "model.the_tuva_project.ahrq_measures__pqi_exclusion_long"], "model.the_tuva_project.ahrq_measures__int_pqi_16_num": ["model.the_tuva_project.ahrq_measures__pqi_num_long"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg": ["model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union"], "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union": ["model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions"], "model.the_tuva_project.ahrq_measures__stg_pqi_condition": ["model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_num", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "model.the_tuva_project.ahrq_measures__pqi_summary"], "model.the_tuva_project.ahrq_measures__stg_pqi_member_months": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom"], "model.the_tuva_project.ahrq_measures__stg_pqi_patient": ["model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender"], "model.the_tuva_project.ahrq_measures__stg_pqi_procedure": ["model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "model.the_tuva_project.ccsr__long_condition_category": ["model.the_tuva_project.ccsr__singular_condition_category"], "model.the_tuva_project.ccsr__long_procedure_category": [], "model.the_tuva_project.ccsr__singular_condition_category": [], "model.the_tuva_project.ccsr__dx_vertical_pivot": ["model.the_tuva_project.ccsr__long_condition_category", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient"], "model.the_tuva_project.ccsr__procedure_category_map": ["model.the_tuva_project.ccsr__long_procedure_category"], "model.the_tuva_project.ccsr__stg_core__condition": ["model.the_tuva_project.ccsr__long_condition_category"], "model.the_tuva_project.ccsr__stg_core__procedure": ["model.the_tuva_project.ccsr__long_procedure_category"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "model.the_tuva_project.data_quality__chronic_conditions_none", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide": ["test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105", "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.mart_review__number_of_conditions", "model.the_tuva_project.mart_review__tuva_chronic_conditions", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2"], "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide": ["test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561", "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b"], "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea", "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0"], "model.the_tuva_project.cms_chronic_conditions__stg_core__condition": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids"], "model.the_tuva_project.cms_chronic_conditions__stg_core__patient": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient": [], "model.the_tuva_project.medical_claim_expanded": [], "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment": ["model.the_tuva_project.core__stg_claims_medical_claim"], "model.the_tuva_project.acute_inpatient__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.ambulance__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.asc__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.dialysis__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.dme__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.emergency_department__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.home_health__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_hospice__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_psych__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_rehab__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_snf__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.inpatient_substance_use__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.lab__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.office_visit__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.orphaned_claim__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_hospice__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_injections__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_psych__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_ptotst__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_radiology__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_rehab__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_substance_use__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.outpatient_surgery__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.urgent_care__encounter_grain": ["model.the_tuva_project.core__stg_claims_encounter"], "model.the_tuva_project.encounters__combined_claim_line_crosswalk": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.encounters__orphaned_claims": ["model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.orphaned_claim__encounter_grain"], "model.the_tuva_project.acute_inpatient__generate_encounter_id": ["model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.acute_inpatient__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.acute_inpatient__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.acute_inpatient__start_end_dates": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.acute_inpatient__prof_claims"], "model.the_tuva_project.ambulance__anchor_events": ["model.the_tuva_project.ambulance__generate_encounter_id"], "model.the_tuva_project.ambulance__generate_encounter_id": ["model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.ambulance__match_claims_to_anchor"], "model.the_tuva_project.ambulance__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.asc__anchor_events": ["model.the_tuva_project.asc__generate_encounter_id"], "model.the_tuva_project.asc__generate_encounter_id": ["model.the_tuva_project.asc__start_end_dates"], "model.the_tuva_project.asc__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.asc__start_end_dates": ["model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.asc__match_claims_to_anchor"], "model.the_tuva_project.dialysis__anchor_events": ["model.the_tuva_project.dialysis__generate_encounter_id"], "model.the_tuva_project.dialysis__generate_encounter_id": ["model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dialysis__match_claims_to_anchor"], "model.the_tuva_project.dialysis__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.dme__anchor_events": ["model.the_tuva_project.dme__generate_encounter_id"], "model.the_tuva_project.dme__generate_encounter_id": ["model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.dme__match_claims_to_anchor"], "model.the_tuva_project.dme__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.emergency_department__generate_encounter_id": ["model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.emergency_department__start_end_dates", "model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.emergency_department__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.emergency_department__start_end_dates": ["model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.emergency_department__prof_claims"], "model.the_tuva_project.home_health__anchor_events": ["model.the_tuva_project.home_health__generate_encounter_id"], "model.the_tuva_project.home_health__generate_encounter_id": ["model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.home_health__match_claims_to_anchor"], "model.the_tuva_project.home_health__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_hospice__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_hospice__prof_claims", "model.the_tuva_project.inpatient_hospice__start_end_dates"], "model.the_tuva_project.inpatient_hospice__prof_claims": [], "model.the_tuva_project.inpatient_hospice__start_end_dates": ["model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_hospice__prof_claims"], "model.the_tuva_project.inpatient_psych__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_psych__start_end_dates"], "model.the_tuva_project.inpatient_psych__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_psych__start_end_dates": ["model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_psych__prof_claims"], "model.the_tuva_project.inpatient_rehab__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_rehab__start_end_dates"], "model.the_tuva_project.inpatient_rehab__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_rehab__start_end_dates": ["model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_rehab__prof_claims"], "model.the_tuva_project.inpatient_snf__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_snf__start_end_dates"], "model.the_tuva_project.inpatient_snf__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_snf__start_end_dates": ["model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_snf__prof_claims"], "model.the_tuva_project.inpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.inpatient_substance_use__start_end_dates"], "model.the_tuva_project.inpatient_substance_use__prof_claims": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.inpatient_substance_use__start_end_dates": ["model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.inpatient_substance_use__prof_claims"], "model.the_tuva_project.lab__anchor_events": ["model.the_tuva_project.lab__generate_encounter_id"], "model.the_tuva_project.lab__generate_encounter_id": ["model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.lab__match_claims_to_anchor"], "model.the_tuva_project.lab__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.office_visits__int_office_visits": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_em", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_ptotst", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.office_visits__int_office_visits_surgery", "model.the_tuva_project.office_visits__int_office_visits_telehealth", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_claim_line": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.office_visits__int_office_visits_em": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking": ["model.the_tuva_project.office_visits__int_office_visits_claim_line"], "model.the_tuva_project.office_visits__int_office_visits_injections": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_ptotst": ["model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_radiology": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_surgery": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_telehealth": ["model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits_union"], "model.the_tuva_project.office_visits__int_office_visits_union": ["model.the_tuva_project.office_visits__int_office_visits_claim_line", "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking"], "model.the_tuva_project.outpatient_hospice__anchor_events": ["model.the_tuva_project.outpatient_hospice__generate_encounter_id"], "model.the_tuva_project.outpatient_hospice__generate_encounter_id": ["model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor"], "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events": ["model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id"], "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id": ["model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor"], "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_injections__anchor_events": ["model.the_tuva_project.outpatient_injections__generate_encounter_id"], "model.the_tuva_project.outpatient_injections__generate_encounter_id": ["model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor"], "model.the_tuva_project.outpatient_injections__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_psych__anchor_events": ["model.the_tuva_project.outpatient_psych__generate_encounter_id"], "model.the_tuva_project.outpatient_psych__generate_encounter_id": ["model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor"], "model.the_tuva_project.outpatient_psych__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_ptotst__anchor_events": ["model.the_tuva_project.outpatient_ptotst__generate_encounter_id"], "model.the_tuva_project.outpatient_ptotst__generate_encounter_id": ["model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor"], "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_radiology__anchor_events": ["model.the_tuva_project.outpatient_radiology__generate_encounter_id"], "model.the_tuva_project.outpatient_radiology__generate_encounter_id": ["model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor"], "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_rehab__anchor_events": ["model.the_tuva_project.outpatient_rehab__generate_encounter_id"], "model.the_tuva_project.outpatient_rehab__generate_encounter_id": ["model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor"], "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_substance_use__anchor_events": ["model.the_tuva_project.outpatient_substance_use__generate_encounter_id"], "model.the_tuva_project.outpatient_substance_use__generate_encounter_id": ["model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor"], "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.outpatient_surgery__anchor_events": ["model.the_tuva_project.outpatient_surgery__generate_encounter_id"], "model.the_tuva_project.outpatient_surgery__generate_encounter_id": ["model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor"], "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.urgent_care__anchor_events": ["model.the_tuva_project.urgent_care__generate_encounter_id"], "model.the_tuva_project.urgent_care__generate_encounter_id": ["model.the_tuva_project.urgent_care__encounter_grain", "model.the_tuva_project.urgent_care__match_claims_to_anchor"], "model.the_tuva_project.urgent_care__match_claims_to_anchor": ["model.the_tuva_project.encounters__combined_claim_line_crosswalk"], "model.the_tuva_project.encounters__patient_data_source_id": ["model.the_tuva_project.core__stg_claims_encounter", "model.the_tuva_project.encounters__stg_eligibility", "model.the_tuva_project.encounters__stg_medical_claim"], "model.the_tuva_project.encounters__stg_eligibility": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.encounters__stg_inpatient_institutional": [], "model.the_tuva_project.encounters__stg_medical_claim": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.acute_inpatient__generate_encounter_id", "model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.ambulance__anchor_events", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.ambulance__generate_encounter_id", "model.the_tuva_project.ambulance__match_claims_to_anchor", "model.the_tuva_project.asc__anchor_events", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.asc__generate_encounter_id", "model.the_tuva_project.asc__match_claims_to_anchor", "model.the_tuva_project.dialysis__anchor_events", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dialysis__generate_encounter_id", "model.the_tuva_project.dialysis__match_claims_to_anchor", "model.the_tuva_project.dme__anchor_events", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.dme__generate_encounter_id", "model.the_tuva_project.dme__match_claims_to_anchor", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.emergency_department__generate_encounter_id", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "model.the_tuva_project.encounters__orphaned_claims", "model.the_tuva_project.home_health__anchor_events", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.home_health__generate_encounter_id", "model.the_tuva_project.home_health__match_claims_to_anchor", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "model.the_tuva_project.inpatient_hospice__prof_claims", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_psych__generate_encounter_id", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_snf__generate_encounter_id", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "model.the_tuva_project.inpatient_substance_use__prof_claims", "model.the_tuva_project.lab__anchor_events", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.lab__generate_encounter_id", "model.the_tuva_project.lab__match_claims_to_anchor", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.office_visits__int_office_visits_injections", "model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__anchor_events", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "model.the_tuva_project.outpatient_injections__anchor_events", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "model.the_tuva_project.outpatient_psych__anchor_events", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_psych__generate_encounter_id", "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "model.the_tuva_project.outpatient_ptotst__anchor_events", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "model.the_tuva_project.outpatient_radiology__anchor_events", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "model.the_tuva_project.outpatient_rehab__anchor_events", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "model.the_tuva_project.outpatient_substance_use__anchor_events", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "model.the_tuva_project.outpatient_surgery__anchor_events", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "model.the_tuva_project.urgent_care__anchor_events", "model.the_tuva_project.urgent_care__encounter_grain", "model.the_tuva_project.urgent_care__generate_encounter_id", "model.the_tuva_project.urgent_care__match_claims_to_anchor"], "model.the_tuva_project.encounters__stg_outpatient_institutional": ["model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.outpatient_injections__anchor_events"], "model.the_tuva_project.encounters__stg_professional": ["model.the_tuva_project.acute_inpatient__prof_claims", "model.the_tuva_project.emergency_department__prof_claims", "model.the_tuva_project.inpatient_hospice__prof_claims", "model.the_tuva_project.inpatient_psych__prof_claims", "model.the_tuva_project.inpatient_rehab__prof_claims", "model.the_tuva_project.inpatient_snf__prof_claims", "model.the_tuva_project.inpatient_substance_use__prof_claims"], "model.the_tuva_project.normalized_input__eligibility": ["model.the_tuva_project.core__stg_claims_eligibility", "model.the_tuva_project.core__stg_claims_patient", "model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.encounters__stg_eligibility"], "model.the_tuva_project.normalized_input__medical_claim": ["model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.encounters__patient_data_source_id", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d"], "model.the_tuva_project.normalized_input__pharmacy_claim": ["model.the_tuva_project.core__stg_claims_pharmacy_claim"], "model.the_tuva_project.normalized_input__int_admit_source_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_admit_source_voting": ["model.the_tuva_project.normalized_input__int_admit_source_final"], "model.the_tuva_project.normalized_input__int_admit_type_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_admit_type_voting": ["model.the_tuva_project.normalized_input__int_admit_type_final"], "model.the_tuva_project.normalized_input__int_apr_drg_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_apr_drg_voting": ["model.the_tuva_project.normalized_input__int_apr_drg_final"], "model.the_tuva_project.normalized_input__int_bill_type_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_bill_type_voting": ["model.the_tuva_project.normalized_input__int_bill_type_final"], "model.the_tuva_project.normalized_input__int_diagnosis_code_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize": ["model.the_tuva_project.normalized_input__int_diagnosis_code_voting"], "model.the_tuva_project.normalized_input__int_diagnosis_code_voting": ["model.the_tuva_project.normalized_input__int_diagnosis_code_final"], "model.the_tuva_project.normalized_input__int_discharge_disposition_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_discharge_disposition_voting": ["model.the_tuva_project.normalized_input__int_discharge_disposition_final"], "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize": ["model.the_tuva_project.normalized_input__eligibility"], "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize": ["model.the_tuva_project.normalized_input__int_medical_date_aggregation", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_medical_date_aggregation": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_medical_npi_normalize": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_ms_drg_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_ms_drg_voting": ["model.the_tuva_project.normalized_input__int_ms_drg_final"], "model.the_tuva_project.normalized_input__int_place_of_service_normalize": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_present_on_admit_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_present_on_admit_normalize": ["model.the_tuva_project.normalized_input__int_present_on_admit_voting"], "model.the_tuva_project.normalized_input__int_present_on_admit_voting": ["model.the_tuva_project.normalized_input__int_present_on_admit_final"], "model.the_tuva_project.normalized_input__int_procedure_code_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_procedure_code_normalize": ["model.the_tuva_project.normalized_input__int_procedure_code_voting"], "model.the_tuva_project.normalized_input__int_procedure_code_voting": ["model.the_tuva_project.normalized_input__int_procedure_code_final"], "model.the_tuva_project.normalized_input__int_procedure_date_final": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_procedure_date_normalize": ["model.the_tuva_project.normalized_input__int_procedure_date_voting"], "model.the_tuva_project.normalized_input__int_procedure_date_voting": ["model.the_tuva_project.normalized_input__int_procedure_date_final"], "model.the_tuva_project.normalized_input__int_revenue_center_normalize": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__int_undetermined_claim_type": ["model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__stg_eligibility": ["model.the_tuva_project.normalized_input__eligibility", "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize"], "model.the_tuva_project.normalized_input__stg_medical_claim": ["model.the_tuva_project.normalized_input__int_admit_source_voting", "model.the_tuva_project.normalized_input__int_admit_type_voting", "model.the_tuva_project.normalized_input__int_apr_drg_voting", "model.the_tuva_project.normalized_input__int_bill_type_voting", "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_ms_drg_voting", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_present_on_admit_normalize", "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "model.the_tuva_project.normalized_input__int_procedure_date_normalize", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.normalized_input__medical_claim"], "model.the_tuva_project.normalized_input__stg_pharmacy_claim": ["model.the_tuva_project.normalized_input__pharmacy_claim"], "model.the_tuva_project.service_category__service_category_grouper": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__stg_claims_medical_claim", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__acute_inpatient_institutional_other": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__acute_inpatient_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__ambulance_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__ambulance_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__ambulatory_surgery_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__ambulatory_surgery_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__combined_institutional_header_level": ["model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.service_category__combined_institutional_line_level": ["model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.service_category__combined_professional": ["model.the_tuva_project.office_visits__int_office_visits", "model.the_tuva_project.service_category__service_category_grouper"], "model.the_tuva_project.service_category__dialysis_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__dialysis_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__dme_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional"], "model.the_tuva_project.service_category__emergency_department_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__emergency_department_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__home_health_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__home_health_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_hospice_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__inpatient_hospice_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__inpatient_psychiatric_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_rehab_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__inpatient_rehab_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__inpatient_substance_use_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__lab_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__lab_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__observation_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__observation_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__office_based_other_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__office_based_physical_therapy_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__office_based_radiology": ["model.the_tuva_project.office_visits__int_office_visits_radiology", "model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__office_based_surgery_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__office_based_visit_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__outpatient_hospice_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_hospice_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_physical_therapy_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_psychiatric_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_psychiatric_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_radiology_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__outpatient_radiology_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_rehab_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_rehab_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_substance_use_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_substance_use_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__outpatient_surgery_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__outpatient_surgery_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__pharmacy_institutional": ["model.the_tuva_project.service_category__combined_institutional_line_level"], "model.the_tuva_project.service_category__pharmacy_professional": ["model.the_tuva_project.service_category__combined_professional", "model.the_tuva_project.service_category__office_based_other_professional"], "model.the_tuva_project.service_category__urgent_care_institutional": ["model.the_tuva_project.service_category__combined_institutional_header_level"], "model.the_tuva_project.service_category__urgent_care_professional": ["model.the_tuva_project.service_category__combined_professional"], "model.the_tuva_project.service_category__stg_inpatient_institutional": ["model.the_tuva_project.encounters__stg_inpatient_institutional", "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__pharmacy_institutional", "model.the_tuva_project.service_category__stg_outpatient_institutional"], "model.the_tuva_project.service_category__stg_medical_claim": ["model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "model.the_tuva_project.service_category__acute_inpatient_professional", "model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__ambulance_professional", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__dme_professional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_institutional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_institutional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "model.the_tuva_project.service_category__inpatient_rehab_institutional", "model.the_tuva_project.service_category__inpatient_rehab_professional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "model.the_tuva_project.service_category__lab_institutional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__observation_institutional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_rehab_professional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_surgery_institutional", "model.the_tuva_project.service_category__outpatient_surgery_professional", "model.the_tuva_project.service_category__pharmacy_institutional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__service_category_grouper", "model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_office_based", "model.the_tuva_project.service_category__stg_outpatient_institutional", "model.the_tuva_project.service_category__stg_professional", "model.the_tuva_project.service_category__urgent_care_institutional", "model.the_tuva_project.service_category__urgent_care_professional"], "model.the_tuva_project.service_category__stg_office_based": ["model.the_tuva_project.service_category__office_based_other_professional", "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "model.the_tuva_project.service_category__office_based_radiology", "model.the_tuva_project.service_category__office_based_surgery_professional", "model.the_tuva_project.service_category__office_based_visit_professional"], "model.the_tuva_project.service_category__stg_outpatient_institutional": ["model.the_tuva_project.encounters__stg_outpatient_institutional", "model.the_tuva_project.service_category__ambulance_institutional", "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "model.the_tuva_project.service_category__dialysis_institutional", "model.the_tuva_project.service_category__emergency_department_institutional", "model.the_tuva_project.service_category__lab_institutional", "model.the_tuva_project.service_category__outpatient_hospice_institutional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "model.the_tuva_project.service_category__outpatient_radiology_institutional", "model.the_tuva_project.service_category__outpatient_radiology_professional", "model.the_tuva_project.service_category__outpatient_rehab_institutional", "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "model.the_tuva_project.service_category__outpatient_surgery_institutional", "model.the_tuva_project.service_category__pharmacy_institutional"], "model.the_tuva_project.service_category__stg_professional": ["model.the_tuva_project.encounters__stg_professional", "model.the_tuva_project.service_category__ambulatory_surgery_professional", "model.the_tuva_project.service_category__dialysis_professional", "model.the_tuva_project.service_category__emergency_department_professional", "model.the_tuva_project.service_category__home_health_professional", "model.the_tuva_project.service_category__inpatient_hospice_professional", "model.the_tuva_project.service_category__lab_professional", "model.the_tuva_project.service_category__observation_professional", "model.the_tuva_project.service_category__outpatient_hospice_professional", "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "model.the_tuva_project.service_category__outpatient_substance_use_professional", "model.the_tuva_project.service_category__outpatient_surgery_professional", "model.the_tuva_project.service_category__pharmacy_professional", "model.the_tuva_project.service_category__stg_office_based"], "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields": ["model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long"], "model.the_tuva_project.cms_hcc__patient_risk_factors": ["model.the_tuva_project.cms_hcc__patient_risk_scores", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__cms_hcc", "model.the_tuva_project.mart_review__patient_risk_factors"], "model.the_tuva_project.cms_hcc__patient_risk_scores": ["model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.mart_review__patient_risk_scores", "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126"], "model.the_tuva_project.cms_hcc__int_demographic_factors": ["model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors", "model.the_tuva_project.cms_hcc__patient_risk_factors", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba"], "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_disease_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_disease_interaction_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_eligible_conditions": ["model.the_tuva_project.cms_hcc__int_hcc_mapping", "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc"], "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_hcc_count_factors": ["model.the_tuva_project.cms_hcc__patient_risk_factors"], "model.the_tuva_project.cms_hcc__int_hcc_hierarchy": ["model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "model.the_tuva_project.cms_hcc__int_disease_factors", "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "model.the_tuva_project.cms_hcc__int_hcc_count_factors"], "model.the_tuva_project.cms_hcc__int_hcc_mapping": ["model.the_tuva_project.cms_hcc__int_hcc_hierarchy"], "model.the_tuva_project.cms_hcc__int_members": ["model.the_tuva_project.cms_hcc__int_demographic_factors", "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b", "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb"], "model.the_tuva_project.cms_hcc__stg_core__condition": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "model.the_tuva_project.cms_hcc__stg_core__eligibility": ["model.the_tuva_project.cms_hcc__int_members"], "model.the_tuva_project.cms_hcc__stg_core__medical_claim": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "model.the_tuva_project.cms_hcc__stg_core__member_months": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "model.the_tuva_project.cms_hcc__stg_core__patient": ["model.the_tuva_project.cms_hcc__int_members"], "model.the_tuva_project.core__condition": ["model.the_tuva_project.ahrq_measures__stg_pqi_condition", "model.the_tuva_project.ccsr__stg_core__condition", "model.the_tuva_project.cms_chronic_conditions__stg_core__condition", "model.the_tuva_project.cms_hcc__stg_core__condition", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.hcc_suspecting__stg_core__condition", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.quality_measures__stg_core__condition", "model.the_tuva_project.tuva_chronic_conditions__stg_core__condition", "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0"], "model.the_tuva_project.core__eligibility": ["model.the_tuva_project.cms_hcc__stg_core__eligibility", "model.the_tuva_project.core__member_months", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.financial_pmpm__stg_eligibility", "model.the_tuva_project.mart_review__data_source", "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a"], "model.the_tuva_project.core__encounter": ["model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "model.the_tuva_project.data_quality__acute_inpatient", "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "model.the_tuva_project.data_quality__encounters_missing_groups", "model.the_tuva_project.ed_classification__stg_encounter", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient", "model.the_tuva_project.mart_review__service_categories_long", "model.the_tuva_project.quality_measures__stg_core__encounter", "model.the_tuva_project.readmissions__stg_core__encounter", "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792"], "model.the_tuva_project.core__lab_result": ["model.the_tuva_project.hcc_suspecting__stg_core__lab_result", "model.the_tuva_project.quality_measures__stg_core__lab_result", "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af"], "model.the_tuva_project.core__location": ["model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient", "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a"], "model.the_tuva_project.core__medical_claim": ["model.the_tuva_project.cms_chronic_conditions__stg_core__medical_claim", "model.the_tuva_project.cms_hcc__stg_core__medical_claim", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__service_categories_pmpm", "model.the_tuva_project.data_quality__service_category_pmpm_trend", "model.the_tuva_project.financial_pmpm__stg_medical_claim", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.quality_measures__stg_medical_claim", "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708"], "model.the_tuva_project.core__medication": ["model.the_tuva_project.hcc_suspecting__stg_core__medication", "model.the_tuva_project.quality_measures__stg_core__medication", "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1"], "model.the_tuva_project.core__member_months": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "model.the_tuva_project.cms_hcc__stg_core__member_months", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "model.the_tuva_project.data_quality__service_categories_pmpm", "model.the_tuva_project.data_quality__service_category_pmpm_trend", "model.the_tuva_project.financial_pmpm__pmpm_prep", "model.the_tuva_project.mart_review__claims_with_enrollment", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__member_months", "model.the_tuva_project.mart_review__members_with_claims", "model.the_tuva_project.mart_review__stg_member_month"], "model.the_tuva_project.core__observation": ["model.the_tuva_project.hcc_suspecting__stg_core__observation", "model.the_tuva_project.quality_measures__stg_core__observation", "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59"], "model.the_tuva_project.core__patient": ["model.the_tuva_project.ahrq_measures__stg_pqi_patient", "model.the_tuva_project.cms_chronic_conditions__stg_core__patient", "model.the_tuva_project.cms_hcc__stg_core__patient", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.ed_classification__stg_patient", "model.the_tuva_project.hcc_suspecting__stg_core__patient", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__number_of_conditions", "model.the_tuva_project.mart_review__patient", "model.the_tuva_project.mart_review__tuva_chronic_conditions", "model.the_tuva_project.quality_measures__stg_core__patient", "model.the_tuva_project.tuva_chronic_conditions__stg_core__patient", "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e"], "model.the_tuva_project.core__pharmacy_claim": ["model.the_tuva_project.cms_chronic_conditions__stg_core__pharmacy_claim", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim", "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.mart_review__stg_pharmacy_claim", "model.the_tuva_project.pharmacy__stg_pharmacy_claim", "model.the_tuva_project.quality_measures__stg_pharmacy_claim", "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c"], "model.the_tuva_project.core__practitioner": ["model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.mart_review__pharmacy", "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6"], "model.the_tuva_project.core__procedure": ["model.the_tuva_project.ahrq_measures__stg_pqi_procedure", "model.the_tuva_project.ccsr__stg_core__procedure", "model.the_tuva_project.cms_chronic_conditions__stg_core__procedure", "model.the_tuva_project.data_quality__core_populated", "model.the_tuva_project.mart_review__data_source", "model.the_tuva_project.quality_measures__stg_core__procedure", "model.the_tuva_project.readmissions__stg_core__procedure", "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5"], "model.the_tuva_project.core__stg_claims_condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.core__stg_claims_eligibility": ["model.the_tuva_project.core__eligibility"], "model.the_tuva_project.core__stg_claims_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.core__stg_claims_location": ["model.the_tuva_project.core__location"], "model.the_tuva_project.core__stg_claims_medical_claim": ["model.the_tuva_project.core__medical_claim", "model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_claims_practitioner"], "model.the_tuva_project.core__stg_claims_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.core__stg_claims_pharmacy_claim": ["model.the_tuva_project.core__pharmacy_claim", "model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_claims_practitioner"], "model.the_tuva_project.core__stg_claims_practitioner": ["model.the_tuva_project.core__practitioner"], "model.the_tuva_project.core__stg_claims_procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.core__stg_clinical_condition": ["model.the_tuva_project.core__condition"], "model.the_tuva_project.core__stg_clinical_encounter": ["model.the_tuva_project.core__encounter"], "model.the_tuva_project.core__stg_clinical_lab_result": ["model.the_tuva_project.core__lab_result"], "model.the_tuva_project.core__stg_clinical_location": ["model.the_tuva_project.core__location"], "model.the_tuva_project.core__stg_clinical_medication": ["model.the_tuva_project.core__medication"], "model.the_tuva_project.core__stg_clinical_observation": ["model.the_tuva_project.core__observation"], "model.the_tuva_project.core__stg_clinical_patient": ["model.the_tuva_project.core__patient"], "model.the_tuva_project.core__stg_clinical_practitioner": ["model.the_tuva_project.core__practitioner"], "model.the_tuva_project.core__stg_clinical_procedure": ["model.the_tuva_project.core__procedure"], "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk": ["model.the_tuva_project.data_quality__summary"], "model.the_tuva_project.data_quality__data_quality_detail": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "model.the_tuva_project.data_quality__quality_trend", "model.the_tuva_project.data_quality__summary"], "model.the_tuva_project.data_quality__data_quality_for_pbi": [], "model.the_tuva_project.data_quality__quality_trend": [], "model.the_tuva_project.data_quality__raw_summary": [], "model.the_tuva_project.data_quality__summary": [], "model.the_tuva_project.data_quality__eligibility_address": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_birth_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_city": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_data_source": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_death_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_death_flag": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_dual_status_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_first_name": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_gender": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_last_name": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_medicare_status_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_member_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_patient_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_payer": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_payer_type": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_phone": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_plan": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_race": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_state": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__eligibility_zip_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_allowed_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_charge_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_line_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_line_number": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_line_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_claim_type": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_coinsurance_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_copayment_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_data_source": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_deductible_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_diagnosis_code_type": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_hcpcs_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_member_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_paid_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_paid_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_patient_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_payer": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_plan": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__claim_total_cost_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_admission_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_admit_source_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_admit_type_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_apr_drg_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_billing_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_bill_type_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_claim_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_claim_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_diagnosis_code_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_discharge_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_discharge_disposition_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_facility_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_ms_drg_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_present_on_admission_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_present_on_admission_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_present_on_admission_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_code_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_code_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_code_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_date_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_date_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_procedure_date_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_rendering_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_revenue_center_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__institutional_service_unit_quantity": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_billing_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_claim_end_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_claim_start_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_diagnosis_code_1": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_diagnosis_code_2": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_diagnosis_code_3": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_facility_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_place_of_service_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__professional_rendering_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_allowed_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_claim_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_claim_line_number": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_copayment_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_data_source": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_days_supply": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_deductible_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_dispensing_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_member_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_ndc_code": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_paid_amount": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_paid_date": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_patient_id": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_payer": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_plan": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_quantity": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__pharmacy_refills": ["model.the_tuva_project.data_quality__data_quality_claims_detail"], "model.the_tuva_project.data_quality__condition_claim_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_condition_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_condition_condition_id"], "model.the_tuva_project.data_quality__condition_condition_rank": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_condition_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_onset_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_present_on_admit_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_present_on_admit_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_recorded_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_resolved_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__condition_status": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_type_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_admit_type_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_allowed_amount": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_apr_drg_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_apr_drg_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_attending_provider_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_charge_amount": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_discharge_disposition_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_end_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id"], "model.the_tuva_project.data_quality__encounter_encounter_start_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_encounter_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_facility_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_length_of_stay": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_ms_drg_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_ms_drg_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_paid_amount": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_accession_number": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_collection_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_lab_result_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id"], "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_component": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_normalized_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_result": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_result_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_component": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_source_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_specimen": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__lab_result_status": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_address": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_city": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_facility_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_latitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_location_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_location_location_id"], "model.the_tuva_project.data_quality__location_longitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_npi": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_parent_organization": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_state": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__location_zip_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_atc_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_atc_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_days_supply": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_dispensing_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_medication_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_medication_medication_id"], "model.the_tuva_project.data_quality__medication_ndc_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_ndc_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_prescribing_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_quantity": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_quantity_unit": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_route": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_rxnorm_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_rxnorm_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__medication_strength": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_normalized_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_observation_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_observation_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_observation_observation_id"], "model.the_tuva_project.data_quality__observation_observation_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_panel_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_result": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_reference_range_high": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_reference_range_low": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__observation_source_units": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_address": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_birth_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_city": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_county": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_death_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_death_flag": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_first_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_last_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_latitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_longitude": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_patient_patient_id"], "model.the_tuva_project.data_quality__patient_race": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_sex": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_state": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__patient_zip_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_first_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_last_name": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_npi": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_practice_affiliation": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id"], "model.the_tuva_project.data_quality__practitioner_specialty": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__practitioner_sub_specialty": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_claim_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_data_source": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_encounter_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_1": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_2": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_3": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_4": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_modifier_5": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_normalized_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_normalized_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_normalized_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_patient_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_practitioner_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_procedure_date": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_procedure_id": ["model.the_tuva_project.data_quality__data_quality_clinical_detail", "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id"], "model.the_tuva_project.data_quality__procedure_source_code": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_source_code_type": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__procedure_source_description": ["model.the_tuva_project.data_quality__data_quality_clinical_detail"], "model.the_tuva_project.data_quality__unique_value_examples": [], "model.the_tuva_project.data_quality__primary_keys_condition_condition_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_location_location_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_medication_medication_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_observation_observation_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_patient_patient_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id": ["model.the_tuva_project.data_quality__unique_value_examples"], "model.the_tuva_project.data_quality__claim_type_summary": [], "model.the_tuva_project.data_quality__data_quality_claims_detail": ["model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "model.the_tuva_project.data_quality__data_quality_detail"], "model.the_tuva_project.data_quality__data_quality_claims_for_pbi": ["model.the_tuva_project.data_quality__data_quality_for_pbi"], "model.the_tuva_project.data_quality__data_quality_clinical_detail": ["model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "model.the_tuva_project.data_quality__data_quality_detail"], "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi": ["model.the_tuva_project.data_quality__data_quality_for_pbi"], "model.the_tuva_project.mart_review__calendar_month": [], "model.the_tuva_project.mart_review__claims_with_enrollment": [], "model.the_tuva_project.mart_review__data_source": [], "model.the_tuva_project.mart_review__ed_classification": [], "model.the_tuva_project.mart_review__enrollment_change": [], "model.the_tuva_project.mart_review__generics": [], "model.the_tuva_project.mart_review__inpatient": [], "model.the_tuva_project.mart_review__members_with_claims": [], "model.the_tuva_project.mart_review__member_months": [], "model.the_tuva_project.mart_review__number_of_conditions": [], "model.the_tuva_project.mart_review__patient": [], "model.the_tuva_project.mart_review__patient_risk": [], "model.the_tuva_project.mart_review__patient_risk_factors": ["model.the_tuva_project.mart_review__patient_risk"], "model.the_tuva_project.mart_review__patient_risk_scores": [], "model.the_tuva_project.mart_review__pharmacy": [], "model.the_tuva_project.mart_review__pmpm": [], "model.the_tuva_project.mart_review__quality_measures_summary_long": [], "model.the_tuva_project.mart_review__quality_measures_value_set": [], "model.the_tuva_project.mart_review__readmissions": [], "model.the_tuva_project.mart_review__service_categories_long": [], "model.the_tuva_project.mart_review__tuva_chronic_conditions": [], "model.the_tuva_project.mart_review__stg_medical_claim": ["model.the_tuva_project.mart_review__claims_with_enrollment", "model.the_tuva_project.mart_review__members_with_claims", "model.the_tuva_project.mart_review__service_categories_long"], "model.the_tuva_project.mart_review__stg_member_month": ["model.the_tuva_project.mart_review__enrollment_change"], "model.the_tuva_project.mart_review__stg_pharmacy_claim": ["model.the_tuva_project.mart_review__members_with_claims"], "model.the_tuva_project.data_quality__stg_eligibility": [], "model.the_tuva_project.data_quality__stg_institutional_inpatient": ["model.the_tuva_project.data_quality__institutional_admission_date", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__institutional_discharge_date", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__institutional_procedure_date_1", "model.the_tuva_project.data_quality__institutional_procedure_date_2", "model.the_tuva_project.data_quality__institutional_procedure_date_3"], "model.the_tuva_project.data_quality__stg_medical_claim": [], "model.the_tuva_project.data_quality__stg_pharmacy_claim": [], "model.the_tuva_project.data_quality__analytics_checks_summary": ["test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a", "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0"], "model.the_tuva_project.data_quality__analytics_populated": [], "model.the_tuva_project.data_quality__analytics_reference_summary": [], "model.the_tuva_project.data_quality__claim_date_trends": [], "model.the_tuva_project.data_quality__core_populated": [], "model.the_tuva_project.data_quality__data_loss": [], "model.the_tuva_project.data_quality__data_quality_test_summary": ["test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084", "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98"], "model.the_tuva_project.data_quality__eligibility_trend": [], "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend": [], "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars": [], "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars": [], "model.the_tuva_project.data_quality__service_category_pmpm_trend": [], "model.the_tuva_project.data_quality__acute_inpatient": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__acute_inpatient_prevelence": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__acute_inpatient_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__chronic_conditions_none": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__chronic_conditions_prevalence": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__claim_percent": [], "model.the_tuva_project.data_quality__cms_hcc": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__cms_hcc_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__dx_and_px": [], "model.the_tuva_project.data_quality__ed_classification": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__ed_classification_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__eligibility_date_checks": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__eligibility_demographics": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__eligibility_missing_patient_id": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__eligibility_missing_payer": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__encounters_cost_and_utilization": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__encounters_missing_groups": ["model.the_tuva_project.data_quality__encounters_missing_groups_union"], "model.the_tuva_project.data_quality__encounters_missing_groups_union": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__financial_pmpm": [], "model.the_tuva_project.data_quality__medical_claim_claim_line_fields": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_date_checks": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_inst_header_fields": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_patient_id": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__medical_claim_provider_npi": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_date_checks": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_ndc": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_npi": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_patient_id": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__primary_key_check": ["model.the_tuva_project.data_quality__data_quality_test_summary"], "model.the_tuva_project.data_quality__quality_measures": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__quality_measures_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__readmissions": ["model.the_tuva_project.data_quality__analytics_checks_summary"], "model.the_tuva_project.data_quality__readmissions_reference": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__service_categories_pmpm": ["model.the_tuva_project.data_quality__analytics_reference_summary"], "model.the_tuva_project.data_quality__eligibility_dq_stage": ["model.the_tuva_project.data_quality__data_loss", "model.the_tuva_project.data_quality__medical_claim_patient_id", "model.the_tuva_project.data_quality__pharmacy_claim_patient_id"], "model.the_tuva_project.data_quality__inpatient_dq_stage": ["model.the_tuva_project.data_quality__medical_claim_date_checks", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields"], "model.the_tuva_project.ed_classification__summary": ["model.the_tuva_project.data_quality__ed_classification", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.mart_review__ed_classification"], "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification": ["model.the_tuva_project.ed_classification__summary"], "model.the_tuva_project.ed_classification__int_map_primary_dx": ["model.the_tuva_project.ed_classification__int_filter_encounter_with_classification"], "model.the_tuva_project.ed_classification__stg_encounter": ["model.the_tuva_project.ed_classification__int_map_primary_dx"], "model.the_tuva_project.ed_classification__stg_patient": ["model.the_tuva_project.ed_classification__summary"], "model.the_tuva_project.financial_pmpm__pmpm_payer": ["model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.mart_review__pmpm"], "model.the_tuva_project.financial_pmpm__pmpm_payer_plan": [], "model.the_tuva_project.financial_pmpm__pmpm_prep": ["model.the_tuva_project.data_quality__financial_pmpm", "model.the_tuva_project.financial_pmpm__pmpm_payer", "model.the_tuva_project.financial_pmpm__pmpm_payer_plan", "model.the_tuva_project.mart_review__member_months", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23"], "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories": ["model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "model.the_tuva_project.mart_review__service_categories_long"], "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot": ["model.the_tuva_project.financial_pmpm__pmpm_prep"], "model.the_tuva_project.financial_pmpm__stg_eligibility": [], "model.the_tuva_project.financial_pmpm__stg_medical_claim": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__stg_pharmacy_claim": ["model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories"], "model.the_tuva_project.financial_pmpm__stg_provider_attribution": ["model.the_tuva_project.core__member_months"], "model.the_tuva_project.hcc_suspecting__list": ["model.the_tuva_project.hcc_suspecting__list_rollup", "model.the_tuva_project.hcc_suspecting__summary"], "model.the_tuva_project.hcc_suspecting__list_rollup": [], "model.the_tuva_project.hcc_suspecting__summary": [], "model.the_tuva_project.hcc_suspecting__int_all_conditions": ["model.the_tuva_project.hcc_suspecting__int_patient_hcc_history"], "model.the_tuva_project.hcc_suspecting__int_all_medications": ["model.the_tuva_project.hcc_suspecting__int_medication_suspects"], "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_lab_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_medication_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_observation_suspects": ["model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history": ["model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__list"], "model.the_tuva_project.hcc_suspecting__int_prep_conditions": ["model.the_tuva_project.hcc_suspecting__int_all_conditions", "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects"], "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs": ["model.the_tuva_project.hcc_suspecting__int_lab_suspects"], "model.the_tuva_project.hcc_suspecting__stg_core__condition": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions"], "model.the_tuva_project.hcc_suspecting__stg_core__lab_result": ["model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs"], "model.the_tuva_project.hcc_suspecting__stg_core__medication": ["model.the_tuva_project.hcc_suspecting__int_all_medications"], "model.the_tuva_project.hcc_suspecting__stg_core__observation": ["model.the_tuva_project.hcc_suspecting__int_observation_suspects"], "model.the_tuva_project.hcc_suspecting__stg_core__patient": ["model.the_tuva_project.hcc_suspecting__summary"], "model.the_tuva_project.hcc_suspecting__stg_core__pharmacy_claim": ["model.the_tuva_project.hcc_suspecting__int_all_medications"], "model.the_tuva_project.pharmacy__brand_generic_opportunity": ["model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7"], "model.the_tuva_project.pharmacy__generic_available_list": ["model.the_tuva_project.mart_review__generics", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42"], "model.the_tuva_project.pharmacy__pharmacy_claim_expanded": ["model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.pharmacy__generic_available_list", "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59"], "model.the_tuva_project.pharmacy__int_brand_with_generic_available": ["model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "model.the_tuva_project.pharmacy__int_claims_current_cost": ["model.the_tuva_project.pharmacy__brand_generic_opportunity", "model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_generic_cost", "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc"], "model.the_tuva_project.pharmacy__int_generic_cost": ["model.the_tuva_project.pharmacy__brand_generic_opportunity"], "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc": [], "model.the_tuva_project.pharmacy__stg_pharmacy_claim": ["model.the_tuva_project.pharmacy__brand_generic_opportunity", "model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "model.the_tuva_project.quality_measures__summary_counts": ["model.the_tuva_project.data_quality__quality_measures", "model.the_tuva_project.data_quality__quality_measures_reference"], "model.the_tuva_project.quality_measures__summary_long": ["model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.mart_review__quality_measures_summary_long", "model.the_tuva_project.quality_measures__summary_counts", "model.the_tuva_project.quality_measures__summary_wide"], "model.the_tuva_project.quality_measures__summary_wide": [], "model.the_tuva_project.quality_measures__int_adhras_denominator": ["model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_adhras_long", "model.the_tuva_project.quality_measures__int_adhras_numerator"], "model.the_tuva_project.quality_measures__int_adhras_exclusions": ["model.the_tuva_project.quality_measures__int_adhras_long"], "model.the_tuva_project.quality_measures__int_adhras_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_adhras_numerator": ["model.the_tuva_project.quality_measures__int_adhras_long"], "model.the_tuva_project.quality_measures__int_adhras__performance_period": ["model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_adhras_numerator"], "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator": ["model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"], "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions": ["model.the_tuva_project.quality_measures__int_adh_diabetes_long"], "model.the_tuva_project.quality_measures__int_adh_diabetes_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator": ["model.the_tuva_project.quality_measures__int_adh_diabetes_long"], "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator"], "model.the_tuva_project.quality_measures__int_cbe0055_denominator": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_long", "model.the_tuva_project.quality_measures__int_cbe0055_numerator"], "model.the_tuva_project.quality_measures__int_cbe0055_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0055_long"], "model.the_tuva_project.quality_measures__int_cbe0055_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cbe0055_numerator": ["model.the_tuva_project.quality_measures__int_cbe0055_long"], "model.the_tuva_project.quality_measures__int_cbe0055__performance_period": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_numerator"], "model.the_tuva_project.quality_measures__int_cbe0101_denominator": ["model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_long", "model.the_tuva_project.quality_measures__int_cbe0101_numerator"], "model.the_tuva_project.quality_measures__int_cbe0101_exclusions": ["model.the_tuva_project.quality_measures__int_cbe0101_long"], "model.the_tuva_project.quality_measures__int_cbe0101_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cbe0101_numerator": ["model.the_tuva_project.quality_measures__int_cbe0101_long"], "model.the_tuva_project.quality_measures__int_cbe0101__performance_period": ["model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions"], "model.the_tuva_project.quality_measures__int_cqm130_denominator": ["model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_long", "model.the_tuva_project.quality_measures__int_cqm130_numerator"], "model.the_tuva_project.quality_measures__int_cqm130_exclusions": ["model.the_tuva_project.quality_measures__int_cqm130_long"], "model.the_tuva_project.quality_measures__int_cqm130_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm130_numerator": ["model.the_tuva_project.quality_measures__int_cqm130_long"], "model.the_tuva_project.quality_measures__int_cqm130__performance_period": ["model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions"], "model.the_tuva_project.quality_measures__int_cqm236_denominator": ["model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_long", "model.the_tuva_project.quality_measures__int_cqm236_numerator"], "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations": ["model.the_tuva_project.quality_measures__int_cqm236_exclusions"], "model.the_tuva_project.quality_measures__int_cqm236_exclusions": ["model.the_tuva_project.quality_measures__int_cqm236_long"], "model.the_tuva_project.quality_measures__int_cqm236_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm236_numerator": ["model.the_tuva_project.quality_measures__int_cqm236_long"], "model.the_tuva_project.quality_measures__int_cqm236__performance_period": ["model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclusions"], "model.the_tuva_project.quality_measures__int_cqm438_denominator": ["model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_long", "model.the_tuva_project.quality_measures__int_cqm438_numerator"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1": ["model.the_tuva_project.quality_measures__int_cqm438_denominator"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2": ["model.the_tuva_project.quality_measures__int_cqm438_denominator"], "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3": ["model.the_tuva_project.quality_measures__int_cqm438_denominator"], "model.the_tuva_project.quality_measures__int_cqm438_exclusions": ["model.the_tuva_project.quality_measures__int_cqm438_long"], "model.the_tuva_project.quality_measures__int_cqm438_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm438_numerator": ["model.the_tuva_project.quality_measures__int_cqm438_long"], "model.the_tuva_project.quality_measures__int_cqm438__performance_period": ["model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__int_cqm438_exclusions"], "model.the_tuva_project.quality_measures__int_cqm48_denominator": ["model.the_tuva_project.quality_measures__int_cqm48_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_long", "model.the_tuva_project.quality_measures__int_cqm48_numerator"], "model.the_tuva_project.quality_measures__int_cqm48_exclusions": ["model.the_tuva_project.quality_measures__int_cqm48_long"], "model.the_tuva_project.quality_measures__int_cqm48_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_cqm48_numerator": ["model.the_tuva_project.quality_measures__int_cqm48_long"], "model.the_tuva_project.quality_measures__int_cqm48__performance_period": ["model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0034_denominator": ["model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0034_numerator"], "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer": ["model.the_tuva_project.quality_measures__int_nqf0034_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0034_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0034_long"], "model.the_tuva_project.quality_measures__int_nqf0034_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0034_numerator": ["model.the_tuva_project.quality_measures__int_nqf0034_long"], "model.the_tuva_project.quality_measures__int_nqf0034__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0034_numerator"], "model.the_tuva_project.quality_measures__int_nqf0041_denominator": ["model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_long", "model.the_tuva_project.quality_measures__int_nqf0041_numerator"], "model.the_tuva_project.quality_measures__int_nqf0041_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0041_long"], "model.the_tuva_project.quality_measures__int_nqf0041_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0041_numerator": ["model.the_tuva_project.quality_measures__int_nqf0041_long"], "model.the_tuva_project.quality_measures__int_nqf0041__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator"], "model.the_tuva_project.quality_measures__int_nqf0053_denominator": ["model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_long", "model.the_tuva_project.quality_measures__int_nqf0053_numerator"], "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications": ["model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0053_long"], "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1": ["model.the_tuva_project.quality_measures__int_nqf0053_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0053_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0053_numerator": ["model.the_tuva_project.quality_measures__int_nqf0053_long"], "model.the_tuva_project.quality_measures__int_nqf0053__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1"], "model.the_tuva_project.quality_measures__int_nqf0059_denominator": ["model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf0059_long", "model.the_tuva_project.quality_measures__int_nqf0059_numerator"], "model.the_tuva_project.quality_measures__int_nqf0059_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0059_long"], "model.the_tuva_project.quality_measures__int_nqf0059_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0059_numerator": ["model.the_tuva_project.quality_measures__int_nqf0059_long"], "model.the_tuva_project.quality_measures__int_nqf0059__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0420_denominator": ["model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_long", "model.the_tuva_project.quality_measures__int_nqf0420_numerator"], "model.the_tuva_project.quality_measures__int_nqf0420_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0420_long"], "model.the_tuva_project.quality_measures__int_nqf0420_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0420_numerator": ["model.the_tuva_project.quality_measures__int_nqf0420_long"], "model.the_tuva_project.quality_measures__int_nqf0420__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions"], "model.the_tuva_project.quality_measures__int_nqf2372_denominator": ["model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_long", "model.the_tuva_project.quality_measures__int_nqf2372_numerator"], "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy": ["model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_nqf2372_exclusions": ["model.the_tuva_project.quality_measures__int_nqf2372_long"], "model.the_tuva_project.quality_measures__int_nqf2372_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf2372_numerator": ["model.the_tuva_project.quality_measures__int_nqf2372_long"], "model.the_tuva_project.quality_measures__int_nqf2372__performance_period": ["model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_nqf0097_denominator": ["model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "model.the_tuva_project.quality_measures__int_nqf0097_long", "model.the_tuva_project.quality_measures__int_nqf0097_numerator"], "model.the_tuva_project.quality_measures__int_nqf0097_exclusions": ["model.the_tuva_project.quality_measures__int_nqf0097_long"], "model.the_tuva_project.quality_measures__int_nqf0097_long": ["model.the_tuva_project.quality_measures__summary_long"], "model.the_tuva_project.quality_measures__int_nqf0097_numerator": ["model.the_tuva_project.quality_measures__int_nqf0097_long"], "model.the_tuva_project.quality_measures__int_nqf0097__performance_period": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia"], "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative": ["model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp": ["model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "model.the_tuva_project.quality_measures__int_nqf2372_exclusions"], "model.the_tuva_project.quality_measures__stg_core__condition": ["model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348"], "model.the_tuva_project.quality_measures__stg_core__encounter": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159"], "model.the_tuva_project.quality_measures__stg_core__lab_result": ["model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_numerator"], "model.the_tuva_project.quality_measures__stg_core__medication": ["model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652"], "model.the_tuva_project.quality_measures__stg_core__observation": ["model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e"], "model.the_tuva_project.quality_measures__stg_core__patient": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "model.the_tuva_project.quality_measures__summary_long", "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b", "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6", "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd", "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69"], "model.the_tuva_project.quality_measures__stg_core__procedure": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9"], "model.the_tuva_project.quality_measures__stg_medical_claim": ["model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp"], "model.the_tuva_project.quality_measures__stg_pharmacy_claim": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia"], "model.the_tuva_project.readmissions__encounter_augmented": ["model.the_tuva_project.data_quality__readmissions", "model.the_tuva_project.readmissions__readmission_summary"], "model.the_tuva_project.readmissions__readmission_summary": ["model.the_tuva_project.data_quality__analytics_populated", "model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.mart_review__readmissions"], "model.the_tuva_project.readmissions__encounter": ["model.the_tuva_project.readmissions__encounter_augmented", "model.the_tuva_project.readmissions__encounter_overlap", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.readmissions__index_admission", "model.the_tuva_project.readmissions__index_discharge_requirement", "model.the_tuva_project.readmissions__index_time_requirement", "model.the_tuva_project.readmissions__readmission_crude"], "model.the_tuva_project.readmissions__encounter_data_quality": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__encounter_overlap": ["model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.readmissions__readmission_crude"], "model.the_tuva_project.readmissions__encounter_specialty_cohort": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__encounter_with_ccs": ["model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__exclusion", "model.the_tuva_project.readmissions__planned_encounter"], "model.the_tuva_project.readmissions__exclusion": ["model.the_tuva_project.readmissions__index_admission"], "model.the_tuva_project.readmissions__index_admission": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__index_discharge_requirement": ["model.the_tuva_project.readmissions__index_admission"], "model.the_tuva_project.readmissions__index_time_requirement": ["model.the_tuva_project.readmissions__index_admission"], "model.the_tuva_project.readmissions__planned_encounter": ["model.the_tuva_project.readmissions__encounter_augmented"], "model.the_tuva_project.readmissions__procedure_ccs": ["model.the_tuva_project.readmissions__encounter_specialty_cohort", "model.the_tuva_project.readmissions__planned_encounter"], "model.the_tuva_project.readmissions__readmission_crude": [], "model.the_tuva_project.readmissions__stg_core__encounter": ["model.the_tuva_project.readmissions__encounter"], "model.the_tuva_project.readmissions__stg_core__procedure": ["model.the_tuva_project.readmissions__procedure_ccs"], "seed.the_tuva_project.clinical_concept_library__clinical_concepts": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"], "seed.the_tuva_project.clinical_concept_library__coding_systems": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"], "seed.the_tuva_project.clinical_concept_library__value_set_members": ["model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields"], "seed.the_tuva_project.reference_data__ansi_fips_state": [], "seed.the_tuva_project.reference_data__calendar": ["model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "model.the_tuva_project.core__member_months", "model.the_tuva_project.data_quality__claim_date_trends", "model.the_tuva_project.data_quality__eligibility_dq_stage", "model.the_tuva_project.data_quality__eligibility_trend", "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "model.the_tuva_project.data_quality__financial_pmpm", "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "model.the_tuva_project.data_quality__quality_trend", "model.the_tuva_project.data_quality__service_category_pmpm_trend", "model.the_tuva_project.mart_review__calendar_month", "model.the_tuva_project.mart_review__service_categories_long", "model.the_tuva_project.mart_review__stg_medical_claim", "model.the_tuva_project.mart_review__stg_member_month", "model.the_tuva_project.mart_review__stg_pharmacy_claim", "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "model.the_tuva_project.normalized_input__int_procedure_date_normalize"], "seed.the_tuva_project.reference_data__code_type": ["model.the_tuva_project.data_quality__claim_diagnosis_code_type", "model.the_tuva_project.data_quality__condition_normalized_code_type", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "model.the_tuva_project.data_quality__procedure_normalized_code_type"], "seed.the_tuva_project.reference_data__fips_county": [], "seed.the_tuva_project.reference_data__ssa_fips_state": ["model.the_tuva_project.data_quality__eligibility_state"], "seed.the_tuva_project.terminology__admit_source": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_admit_source_code", "model.the_tuva_project.data_quality__institutional_admit_source_code", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_admit_source_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type"], "seed.the_tuva_project.terminology__admit_type": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_admit_type_code", "model.the_tuva_project.data_quality__institutional_admit_type_code", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_admit_type_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type"], "seed.the_tuva_project.terminology__apr_drg": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_apr_drg_code", "model.the_tuva_project.data_quality__inpatient_dq_stage", "model.the_tuva_project.data_quality__institutional_apr_drg_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_apr_drg_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_inpatient_institutional"], "seed.the_tuva_project.terminology__bill_type": ["model.the_tuva_project.data_quality__institutional_bill_type_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.normalized_input__int_bill_type_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__ccs_services_procedures": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__claim_type": ["model.the_tuva_project.data_quality__claim_claim_type"], "seed.the_tuva_project.terminology__discharge_disposition": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.readmissions__encounter_data_quality"], "seed.the_tuva_project.terminology__encounter_type": ["model.the_tuva_project.data_quality__encounter_encounter_type"], "seed.the_tuva_project.terminology__ethnicity": [], "seed.the_tuva_project.terminology__gender": ["model.the_tuva_project.data_quality__eligibility_gender", "model.the_tuva_project.data_quality__patient_sex"], "seed.the_tuva_project.terminology__hcpcs_level_2": ["model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.data_quality__claim_hcpcs_code", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__procedure_modifier_1", "model.the_tuva_project.data_quality__procedure_modifier_2", "model.the_tuva_project.data_quality__procedure_modifier_3", "model.the_tuva_project.data_quality__procedure_modifier_4", "model.the_tuva_project.data_quality__procedure_modifier_5", "model.the_tuva_project.data_quality__procedure_normalized_code"], "seed.the_tuva_project.terminology__hcpcs_to_rbcs": [], "seed.the_tuva_project.terminology__icd_10_cm": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__condition", "model.the_tuva_project.core__observation", "model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.data_quality__condition_normalized_code", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.readmissions__encounter_with_ccs", "model.the_tuva_project.urgent_care__encounter_grain"], "seed.the_tuva_project.terminology__icd_10_pcs": ["model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure", "model.the_tuva_project.core__stg_claims_procedure", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__institutional_procedure_code_1", "model.the_tuva_project.data_quality__institutional_procedure_code_2", "model.the_tuva_project.data_quality__institutional_procedure_code_3", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "model.the_tuva_project.readmissions__procedure_ccs"], "seed.the_tuva_project.terminology__icd_9_cm": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__condition", "model.the_tuva_project.core__observation", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.urgent_care__encounter_grain"], "seed.the_tuva_project.terminology__icd_9_pcs": ["model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure", "model.the_tuva_project.data_quality__dx_and_px", "model.the_tuva_project.data_quality__procedure_normalized_code", "model.the_tuva_project.normalized_input__int_procedure_code_normalize"], "seed.the_tuva_project.terminology__loinc": ["model.the_tuva_project.core__lab_result", "model.the_tuva_project.core__observation", "model.the_tuva_project.data_quality__lab_result_normalized_code", "model.the_tuva_project.data_quality__lab_result_normalized_component"], "seed.the_tuva_project.terminology__loinc_deprecated_mapping": [], "seed.the_tuva_project.terminology__mdc": [], "seed.the_tuva_project.terminology__medicare_dual_eligibility": ["model.the_tuva_project.data_quality__eligibility_dual_status_code"], "seed.the_tuva_project.terminology__medicare_orec": ["model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code"], "seed.the_tuva_project.terminology__medicare_status": ["model.the_tuva_project.data_quality__eligibility_medicare_status_code"], "seed.the_tuva_project.terminology__ms_drg": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.data_quality__encounter_ms_drg_code", "model.the_tuva_project.data_quality__inpatient_dq_stage", "model.the_tuva_project.data_quality__institutional_ms_drg_code", "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.normalized_input__int_ms_drg_voting", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.readmissions__encounter_data_quality", "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "model.the_tuva_project.service_category__stg_inpatient_institutional", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__ms_drg_weights_los": ["model.the_tuva_project.mart_review__inpatient"], "seed.the_tuva_project.terminology__ndc": ["model.the_tuva_project.core__medication", "model.the_tuva_project.data_quality__medication_ndc_description", "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "model.the_tuva_project.data_quality__pharmacy_ndc_code", "model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.normalized_input__pharmacy_claim", "model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__stg_pharmacy_claim"], "seed.the_tuva_project.terminology__nitos": ["model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__other_provider_taxonomy": [], "seed.the_tuva_project.terminology__payer_type": ["model.the_tuva_project.data_quality__eligibility_missing_payer", "model.the_tuva_project.data_quality__eligibility_payer_type"], "seed.the_tuva_project.terminology__place_of_service": ["model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.data_quality__professional_place_of_service_code", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__present_on_admission": ["model.the_tuva_project.core__stg_claims_condition", "model.the_tuva_project.data_quality__condition_present_on_admit_code", "model.the_tuva_project.normalized_input__int_present_on_admit_normalize"], "seed.the_tuva_project.terminology__provider": ["model.the_tuva_project.acute_inpatient__encounter_grain", "model.the_tuva_project.ambulance__encounter_grain", "model.the_tuva_project.asc__encounter_grain", "model.the_tuva_project.core__stg_claims_location", "model.the_tuva_project.core__stg_claims_practitioner", "model.the_tuva_project.data_quality__encounter_attending_provider_id", "model.the_tuva_project.data_quality__encounter_facility_id", "model.the_tuva_project.data_quality__institutional_billing_npi", "model.the_tuva_project.data_quality__institutional_facility_npi", "model.the_tuva_project.data_quality__institutional_rendering_npi", "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "model.the_tuva_project.data_quality__location_npi", "model.the_tuva_project.data_quality__medical_claim_provider_npi", "model.the_tuva_project.data_quality__pharmacy_claim_npi", "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "model.the_tuva_project.data_quality__practitioner_npi", "model.the_tuva_project.data_quality__professional_billing_npi", "model.the_tuva_project.data_quality__professional_facility_npi", "model.the_tuva_project.data_quality__professional_rendering_npi", "model.the_tuva_project.dialysis__encounter_grain", "model.the_tuva_project.dme__encounter_grain", "model.the_tuva_project.ed_classification__summary", "model.the_tuva_project.emergency_department__encounter_grain", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.home_health__encounter_grain", "model.the_tuva_project.inpatient_hospice__encounter_grain", "model.the_tuva_project.inpatient_psych__encounter_grain", "model.the_tuva_project.inpatient_rehab__encounter_grain", "model.the_tuva_project.inpatient_snf__encounter_grain", "model.the_tuva_project.inpatient_substance_use__encounter_grain", "model.the_tuva_project.lab__encounter_grain", "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.normalized_input__pharmacy_claim", "model.the_tuva_project.office_visit__encounter_grain", "model.the_tuva_project.orphaned_claim__encounter_grain", "model.the_tuva_project.outpatient_hospice__encounter_grain", "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "model.the_tuva_project.outpatient_injections__encounter_grain", "model.the_tuva_project.outpatient_psych__encounter_grain", "model.the_tuva_project.outpatient_ptotst__encounter_grain", "model.the_tuva_project.outpatient_radiology__encounter_grain", "model.the_tuva_project.outpatient_rehab__encounter_grain", "model.the_tuva_project.outpatient_substance_use__encounter_grain", "model.the_tuva_project.outpatient_surgery__encounter_grain", "model.the_tuva_project.service_category__stg_medical_claim", "model.the_tuva_project.urgent_care__encounter_grain"], "seed.the_tuva_project.terminology__race": ["model.the_tuva_project.data_quality__eligibility_race", "model.the_tuva_project.data_quality__patient_race"], "seed.the_tuva_project.terminology__revenue_center": ["model.the_tuva_project.data_quality__institutional_revenue_center_code", "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.terminology__rxnorm_brand_generic": ["model.the_tuva_project.mart_review__pharmacy", "model.the_tuva_project.pharmacy__int_claims_current_cost", "model.the_tuva_project.pharmacy__pharmacy_claim_expanded"], "seed.the_tuva_project.terminology__rxnorm_to_atc": ["model.the_tuva_project.core__medication", "model.the_tuva_project.data_quality__medication_atc_code", "model.the_tuva_project.data_quality__medication_rxnorm_code", "model.the_tuva_project.mart_review__pharmacy"], "seed.the_tuva_project.terminology__snomed_ct": ["model.the_tuva_project.core__condition", "model.the_tuva_project.core__lab_result", "model.the_tuva_project.core__observation", "model.the_tuva_project.core__procedure"], "seed.the_tuva_project.terminology__snomed_ct_transitive_closures": [], "seed.the_tuva_project.terminology__snomed_icd_10_map": ["model.the_tuva_project.hcc_suspecting__int_prep_conditions"], "seed.the_tuva_project.pqi__measures": ["model.the_tuva_project.ahrq_measures__pqi_summary"], "seed.the_tuva_project.pqi__value_sets": ["model.the_tuva_project.ahrq_measures__int_pqi_01_num", "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "model.the_tuva_project.ahrq_measures__int_pqi_16_num"], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems": ["model.the_tuva_project.ccsr__long_condition_category", "model.the_tuva_project.mart_review__ed_classification", "model.the_tuva_project.mart_review__inpatient"], "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map": ["model.the_tuva_project.ccsr__dx_vertical_pivot", "model.the_tuva_project.encounters__stg_medical_claim", "model.the_tuva_project.service_category__stg_medical_claim"], "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map": ["model.the_tuva_project.ccsr__procedure_category_map"], "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy": ["model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide"], "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy": [], "seed.the_tuva_project.cms_hcc__adjustment_rates": ["model.the_tuva_project.cms_hcc__patient_risk_scores"], "seed.the_tuva_project.cms_hcc__cpt_hcpcs": ["model.the_tuva_project.cms_hcc__int_eligible_conditions"], "seed.the_tuva_project.cms_hcc__demographic_factors": ["model.the_tuva_project.cms_hcc__int_demographic_factors"], "seed.the_tuva_project.cms_hcc__disabled_interaction_factors": ["model.the_tuva_project.cms_hcc__int_disabled_interaction_factors"], "seed.the_tuva_project.cms_hcc__disease_factors": ["model.the_tuva_project.cms_hcc__int_disease_factors"], "seed.the_tuva_project.cms_hcc__disease_hierarchy": ["model.the_tuva_project.cms_hcc__int_hcc_hierarchy"], "seed.the_tuva_project.cms_hcc__disease_interaction_factors": ["model.the_tuva_project.cms_hcc__int_disease_interaction_factors"], "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors": ["model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors"], "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings": ["model.the_tuva_project.cms_hcc__int_hcc_mapping"], "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors": ["model.the_tuva_project.cms_hcc__int_hcc_count_factors"], "seed.the_tuva_project.data_quality__crosswalk_field_info": ["model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "model.the_tuva_project.data_quality__summary"], "seed.the_tuva_project.data_quality__crosswalk_field_to_mart": ["model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk"], "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure": [], "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges": [], "seed.the_tuva_project.data_quality__reference_mart_analytics": ["model.the_tuva_project.data_quality__acute_inpatient_prevelence", "model.the_tuva_project.data_quality__acute_inpatient_reference", "model.the_tuva_project.data_quality__chronic_conditions_none", "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "model.the_tuva_project.data_quality__cms_hcc_reference", "model.the_tuva_project.data_quality__ed_classification_reference", "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "model.the_tuva_project.data_quality__quality_measures_reference", "model.the_tuva_project.data_quality__readmissions_reference", "model.the_tuva_project.data_quality__service_categories_pmpm"], "seed.the_tuva_project.ed_classification__categories": ["model.the_tuva_project.ed_classification__summary"], "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs": [], "seed.the_tuva_project.ed_classification__johnston_icd10": ["model.the_tuva_project.ed_classification__int_map_primary_dx", "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7", "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd"], "seed.the_tuva_project.ed_classification__johnston_icd9": ["model.the_tuva_project.ed_classification__int_map_primary_dx", "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0", "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617"], "seed.the_tuva_project.hcc_suspecting__clinical_concepts": ["model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs"], "seed.the_tuva_project.hcc_suspecting__hcc_descriptions": ["model.the_tuva_project.hcc_suspecting__int_all_conditions", "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "model.the_tuva_project.hcc_suspecting__int_observation_suspects"], "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings": ["model.the_tuva_project.hcc_suspecting__int_all_conditions"], "seed.the_tuva_project.pharmacy__rxnorm_generic_available": ["model.the_tuva_project.pharmacy__generic_available_list", "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "model.the_tuva_project.pharmacy__int_generic_cost", "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc"], "seed.the_tuva_project.quality_measures__concepts": ["model.the_tuva_project.quality_measures__int_nqf0097_denominator"], "seed.the_tuva_project.quality_measures__measures": ["model.the_tuva_project.mart_review__quality_measures_value_set", "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "model.the_tuva_project.quality_measures__int_adhras__performance_period", "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "model.the_tuva_project.quality_measures__int_nqf0034_long", "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "model.the_tuva_project.quality_measures__int_nqf2372__performance_period"], "seed.the_tuva_project.quality_measures__value_sets": ["model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "model.the_tuva_project.quality_measures__int_adhras_denominator", "model.the_tuva_project.quality_measures__int_adhras_exclusions", "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "model.the_tuva_project.quality_measures__int_cqm130_denominator", "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "model.the_tuva_project.quality_measures__int_cqm130_numerator", "model.the_tuva_project.quality_measures__int_cqm236_denominator", "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "model.the_tuva_project.quality_measures__int_cqm236_numerator", "model.the_tuva_project.quality_measures__int_cqm438_denominator", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "model.the_tuva_project.quality_measures__int_cqm438_numerator", "model.the_tuva_project.quality_measures__int_cqm48_denominator", "model.the_tuva_project.quality_measures__int_cqm48_numerator", "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative"], "seed.the_tuva_project.readmissions__acute_diagnosis_ccs": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category": ["model.the_tuva_project.readmissions__exclusion"], "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs": ["model.the_tuva_project.readmissions__encounter_with_ccs"], "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs": ["model.the_tuva_project.readmissions__procedure_ccs"], "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs": ["model.the_tuva_project.readmissions__planned_encounter"], "seed.the_tuva_project.readmissions__specialty_cohort": ["model.the_tuva_project.readmissions__encounter_specialty_cohort"], "seed.the_tuva_project.readmissions__surgery_gynecology_cohort": ["model.the_tuva_project.readmissions__encounter_specialty_cohort"], "seed.the_tuva_project.service_category__service_categories": ["model.the_tuva_project.service_category__service_category_grouper"], "operation.the_tuva_project.the_tuva_project-on-run-end-0": [], "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617": [], "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0": [], "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd": [], "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7": [], "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00": [], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe": [], "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea": [], "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2": [], "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158": [], "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d": [], "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba": [], "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc": [], "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b": [], "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb": [], "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0": [], "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a": [], "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792": [], "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af": [], "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a": [], "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708": [], "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1": [], "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59": [], "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e": [], "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c": [], "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6": [], "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5": [], "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98": [], "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084": [], "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0": [], "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42": [], "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59": [], "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348": [], "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159": [], "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652": [], "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e": [], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd": [], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69": [], "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b": [], "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6": [], "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9": []}, "group_map": {}, "saved_queries": {}, "semantic_models": {}, "unit_tests": {}} \ No newline at end of file diff --git a/docs/run_results.json b/docs/run_results.json index bc148945..461d34fd 100644 --- a/docs/run_results.json +++ b/docs/run_results.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v6.json", "dbt_version": "1.8.7", "generated_at": "2024-10-22T19:20:47.880382Z", "invocation_id": "20286335-30e3-42ae-bde1-c852d2c2ff63", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.651984Z", "completed_at": "2024-10-22T19:20:30.680860Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.681561Z", "completed_at": "2024-10-22T19:20:30.681579Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0316009521484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.condition", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as condition_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as recorded_date\n , cast(null as date) as onset_date\n , cast(null as date) as resolved_date\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as condition_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as integer ) as condition_rank\n , cast(null as TEXT ) as present_on_admit_code\n , cast(null as TEXT ) as present_on_admit_description\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.671241Z", "completed_at": "2024-10-22T19:20:30.681156Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.682172Z", "completed_at": "2024-10-22T19:20:30.682176Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03165578842163086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.lab_result", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as lab_result_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as accession_number\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as source_component\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as normalized_component\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as result\n , cast(null as date) as result_date\n , cast(null as date) as collection_date\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as integer ) as source_abnormal_flag\n , cast(null as integer ) as normalized_abnormal_flag\n , cast(null as TEXT ) as specimen\n , cast(null as TEXT ) as ordering_practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.lab_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.664319Z", "completed_at": "2024-10-22T19:20:30.681328Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.682596Z", "completed_at": "2024-10-22T19:20:30.682599Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.032312870025634766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.encounter", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_type\n , cast(null as date) as encounter_start_date\n , cast(null as date) as encounter_end_date\n , cast(null as integer ) as length_of_stay\n , cast(null as TEXT ) as admit_source_code\n , cast(null as TEXT ) as admit_source_description\n , cast(null as TEXT ) as admit_type_code\n , cast(null as TEXT ) as admit_type_description\n , cast(null as TEXT ) as discharge_disposition_code\n , cast(null as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(null as TEXT ) as facility_id\n , cast(null as TEXT ) as facility_name\n , cast(null as TEXT ) as primary_diagnosis_code_type\n , cast(null as TEXT ) as primary_diagnosis_code\n , cast(null as TEXT ) as primary_diagnosis_description\n , cast(null as TEXT ) as ms_drg_code\n , cast(null as TEXT ) as ms_drg_description\n , cast(null as TEXT ) as apr_drg_code\n , cast(null as TEXT ) as apr_drg_description\n , cast(null as numeric(28,6) ) as paid_amount\n , cast(null as numeric(28,6) ) as allowed_amount\n , cast(null as numeric(28,6) ) as charge_amount\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.675911Z", "completed_at": "2024-10-22T19:20:30.681962Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.683332Z", "completed_at": "2024-10-22T19:20:30.683335Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03253293037414551, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.location", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as location_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(null as TEXT ) as parent_organization\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.686706Z", "completed_at": "2024-10-22T19:20:30.702096Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.702436Z", "completed_at": "2024-10-22T19:20:30.702441Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.017904996871948242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.medication", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as medication_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as date) as dispensing_date\n , cast(null as date) as prescribing_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as ndc_code\n , cast(null as TEXT ) as ndc_description\n , cast(null as TEXT ) as rxnorm_code\n , cast(null as TEXT ) as rxnorm_description\n , cast(null as TEXT ) as atc_code\n , cast(null as TEXT ) as atc_description\n , cast(null as TEXT ) as route\n , cast(null as TEXT ) as strength\n , cast(null as integer ) as quantity\n , cast(null as TEXT ) as quantity_unit\n , cast(null as integer ) as days_supply\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.medication"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.695872Z", "completed_at": "2024-10-22T19:20:30.702986Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.703948Z", "completed_at": "2024-10-22T19:20:30.703951Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01843404769897461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.patient", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as sex\n , cast(null as TEXT ) as race\n , cast(null as date) as birth_date\n , cast(null as date) as death_date\n , cast(null as integer ) as death_flag\n , cast(null as TEXT ) as social_security_number\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as TEXT ) as county\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.691621Z", "completed_at": "2024-10-22T19:20:30.703417Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.704528Z", "completed_at": "2024-10-22T19:20:30.704531Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.019404172897338867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.observation", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as observation_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as panel_id\n , cast(null as date) as observation_date\n , cast(null as TEXT ) as observation_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as result\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.observation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.699496Z", "completed_at": "2024-10-22T19:20:30.703576Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.704912Z", "completed_at": "2024-10-22T19:20:30.704916Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018965959548950195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.practitioner", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as practice_affiliation\n , cast(null as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.706816Z", "completed_at": "2024-10-22T19:20:30.711579Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.735649Z", "completed_at": "2024-10-22T19:20:30.735655Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03143501281738281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.procedure", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as procedure_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as procedure_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as modifier_1\n , cast(null as TEXT ) as modifier_2\n , cast(null as TEXT ) as modifier_3\n , cast(null as TEXT ) as modifier_4\n , cast(null as TEXT ) as modifier_5\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.734305Z", "completed_at": "2024-10-22T19:20:30.735332Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.736445Z", "completed_at": "2024-10-22T19:20:30.736449Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02586507797241211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.eligibility_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.711771Z", "completed_at": "2024-10-22T19:20:30.737183Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.738372Z", "completed_at": "2024-10-22T19:20:30.738376Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03199601173400879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "compiled": true, "compiled_code": "\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback periods for each type of test\n\n during the measurement period:\n - Fecal occult blood test (FOBT) during the measurement period\n\n during the measurement period or the two years prior:\n - Fecal immunochemical DNA test (FIT-DNA)\n\n during the measurement period or the four years prior:\n - Flexible sigmoidoscopy\n - Computed tomography (CT) colonography\n\n during the measurement period or the nine years prior:\n - Colonoscopy\n\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n year,\n -2,\n performance_period_end\n )\n\n as performance_period_begin_1yp\n , \n\n dateadd(\n year,\n -3,\n performance_period_end\n )\n\n as performance_period_begin_2yp\n , \n\n dateadd(\n year,\n -5,\n performance_period_end\n )\n\n as performance_period_begin_4yp\n , \n\n dateadd(\n year,\n -10,\n performance_period_end\n )\n\n as performance_period_begin_9yp\n from period_begin\n\n)\n\nselect\n cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin_1yp as date) as performance_period_begin_1yp\n , cast(performance_period_begin_2yp as date) as performance_period_begin_2yp\n , cast(performance_period_begin_4yp as date) as performance_period_begin_4yp\n , cast(performance_period_begin_9yp as date) as performance_period_begin_9yp\nfrom period_lookback", "relation_name": "cms_synthetic.quality_measures._int_nqf0034__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.740448Z", "completed_at": "2024-10-22T19:20:30.741331Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.743465Z", "completed_at": "2024-10-22T19:20:30.743470Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005468845367431641, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.lab_result_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.742384Z", "completed_at": "2024-10-22T19:20:30.743209Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.744135Z", "completed_at": "2024-10-22T19:20:30.744139Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005398988723754883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.medical_claim_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.745217Z", "completed_at": "2024-10-22T19:20:30.746065Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.746866Z", "completed_at": "2024-10-22T19:20:30.746870Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005113840103149414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.observation_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.748036Z", "completed_at": "2024-10-22T19:20:30.748858Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.750415Z", "completed_at": "2024-10-22T19:20:30.750419Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0038530826568603516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.pharmacy_claim_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.749307Z", "completed_at": "2024-10-22T19:20:30.750154Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.751119Z", "completed_at": "2024-10-22T19:20:30.751123Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003960847854614258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.provider_attribution_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.751992Z", "completed_at": "2024-10-22T19:20:30.752997Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.753853Z", "completed_at": "2024-10-22T19:20:30.753857Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00483393669128418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.755106Z", "completed_at": "2024-10-22T19:20:30.756011Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.758655Z", "completed_at": "2024-10-22T19:20:30.758660Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005151033401489258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.756548Z", "completed_at": "2024-10-22T19:20:30.758408Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.759205Z", "completed_at": "2024-10-22T19:20:30.759209Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005055904388427734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.759821Z", "completed_at": "2024-10-22T19:20:30.760788Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.761569Z", "completed_at": "2024-10-22T19:20:30.761573Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005335092544555664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.762732Z", "completed_at": "2024-10-22T19:20:30.763604Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.765212Z", "completed_at": "2024-10-22T19:20:30.765216Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003974199295043945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.764145Z", "completed_at": "2024-10-22T19:20:30.764982Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.765791Z", "completed_at": "2024-10-22T19:20:30.765795Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003915071487426758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.clinical_concept_library__clinical_concepts", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.766362Z", "completed_at": "2024-10-22T19:20:30.767297Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.768043Z", "completed_at": "2024-10-22T19:20:30.768047Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004180908203125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.clinical_concept_library__coding_systems", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.769372Z", "completed_at": "2024-10-22T19:20:30.770206Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.771701Z", "completed_at": "2024-10-22T19:20:30.771704Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003934144973754883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.clinical_concept_library__value_set_members", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.770669Z", "completed_at": "2024-10-22T19:20:30.771479Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.772284Z", "completed_at": "2024-10-22T19:20:30.772287Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003956794738769531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__adjustment_rates", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.772889Z", "completed_at": "2024-10-22T19:20:30.773747Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.774465Z", "completed_at": "2024-10-22T19:20:30.774468Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004063129425048828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__cpt_hcpcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.775587Z", "completed_at": "2024-10-22T19:20:30.776659Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.778145Z", "completed_at": "2024-10-22T19:20:30.778149Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003977060317993164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__demographic_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.777119Z", "completed_at": "2024-10-22T19:20:30.777914Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.778675Z", "completed_at": "2024-10-22T19:20:30.778678Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003944873809814453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disabled_interaction_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.779215Z", "completed_at": "2024-10-22T19:20:30.781156Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.781878Z", "completed_at": "2024-10-22T19:20:30.781882Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0050280094146728516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disease_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.783732Z", "completed_at": "2024-10-22T19:20:30.784652Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.786266Z", "completed_at": "2024-10-22T19:20:30.786271Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004674196243286133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disease_hierarchy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.785172Z", "completed_at": "2024-10-22T19:20:30.786026Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.786830Z", "completed_at": "2024-10-22T19:20:30.786834Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004647970199584961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disease_interaction_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.787433Z", "completed_at": "2024-10-22T19:20:30.788385Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.789160Z", "completed_at": "2024-10-22T19:20:30.789164Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004314899444580078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.790411Z", "completed_at": "2024-10-22T19:20:30.791242Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.793010Z", "completed_at": "2024-10-22T19:20:30.793014Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004132986068725586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.791765Z", "completed_at": "2024-10-22T19:20:30.792747Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.793596Z", "completed_at": "2024-10-22T19:20:30.793598Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004155874252319336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.794213Z", "completed_at": "2024-10-22T19:20:30.795312Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.796115Z", "completed_at": "2024-10-22T19:20:30.796119Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0046999454498291016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_info", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.797340Z", "completed_at": "2024-10-22T19:20:30.798171Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.799687Z", "completed_at": "2024-10-22T19:20:30.799691Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003866910934448242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_to_mart", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.798674Z", "completed_at": "2024-10-22T19:20:30.799463Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.800246Z", "completed_at": "2024-10-22T19:20:30.800249Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0038352012634277344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.800968Z", "completed_at": "2024-10-22T19:20:30.801797Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.802557Z", "completed_at": "2024-10-22T19:20:30.802560Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004164934158325195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.803716Z", "completed_at": "2024-10-22T19:20:30.805729Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.807222Z", "completed_at": "2024-10-22T19:20:30.807226Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004943132400512695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__reference_mart_analytics", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.806204Z", "completed_at": "2024-10-22T19:20:30.806992Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.807747Z", "completed_at": "2024-10-22T19:20:30.807750Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0049207210540771484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__categories", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.808476Z", "completed_at": "2024-10-22T19:20:30.809277Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.809998Z", "completed_at": "2024-10-22T19:20:30.810001Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004080772399902344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.811129Z", "completed_at": "2024-10-22T19:20:30.811938Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.813393Z", "completed_at": "2024-10-22T19:20:30.813397Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003693103790283203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd10", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.812387Z", "completed_at": "2024-10-22T19:20:30.813174Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.813908Z", "completed_at": "2024-10-22T19:20:30.813910Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003706216812133789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd9", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.814535Z", "completed_at": "2024-10-22T19:20:30.815296Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.816225Z", "completed_at": "2024-10-22T19:20:30.816228Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004111766815185547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.817378Z", "completed_at": "2024-10-22T19:20:30.818262Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.819856Z", "completed_at": "2024-10-22T19:20:30.819861Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003931999206542969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.818794Z", "completed_at": "2024-10-22T19:20:30.819622Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.820390Z", "completed_at": "2024-10-22T19:20:30.820393Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0038781166076660156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.820968Z", "completed_at": "2024-10-22T19:20:30.821778Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.822485Z", "completed_at": "2024-10-22T19:20:30.822489Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004002809524536133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.823665Z", "completed_at": "2024-10-22T19:20:30.824601Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.827340Z", "completed_at": "2024-10-22T19:20:30.827343Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005143165588378906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.pqi__measures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.825068Z", "completed_at": "2024-10-22T19:20:30.827106Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.827903Z", "completed_at": "2024-10-22T19:20:30.827906Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005143642425537109, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.pqi__value_sets", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.828453Z", "completed_at": "2024-10-22T19:20:30.829232Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.829921Z", "completed_at": "2024-10-22T19:20:30.829925Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005143880844116211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.quality_measures__concepts", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.831059Z", "completed_at": "2024-10-22T19:20:30.831994Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.833575Z", "completed_at": "2024-10-22T19:20:30.833579Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003932952880859375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.quality_measures__measures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.832492Z", "completed_at": "2024-10-22T19:20:30.833334Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.834170Z", "completed_at": "2024-10-22T19:20:30.834173Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003982067108154297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.quality_measures__value_sets", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.834940Z", "completed_at": "2024-10-22T19:20:30.835781Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.836549Z", "completed_at": "2024-10-22T19:20:30.836552Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004327297210693359, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.837834Z", "completed_at": "2024-10-22T19:20:30.838667Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.840741Z", "completed_at": "2024-10-22T19:20:30.840745Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004470109939575195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.839154Z", "completed_at": "2024-10-22T19:20:30.840167Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.843948Z", "completed_at": "2024-10-22T19:20:30.843952Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007147073745727539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.844646Z", "completed_at": "2024-10-22T19:20:30.845489Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.846203Z", "completed_at": "2024-10-22T19:20:30.846207Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007330179214477539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.847552Z", "completed_at": "2024-10-22T19:20:30.848388Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.849963Z", "completed_at": "2024-10-22T19:20:30.849967Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0040667057037353516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.848869Z", "completed_at": "2024-10-22T19:20:30.849719Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.850531Z", "completed_at": "2024-10-22T19:20:30.850534Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004051923751831055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.851081Z", "completed_at": "2024-10-22T19:20:30.851960Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.852680Z", "completed_at": "2024-10-22T19:20:30.852684Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004111051559448242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.853826Z", "completed_at": "2024-10-22T19:20:30.855879Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.857592Z", "completed_at": "2024-10-22T19:20:30.857596Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005208015441894531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.856575Z", "completed_at": "2024-10-22T19:20:30.857373Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.858141Z", "completed_at": "2024-10-22T19:20:30.858144Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005187034606933594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.858764Z", "completed_at": "2024-10-22T19:20:30.859550Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.860237Z", "completed_at": "2024-10-22T19:20:30.860240Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004096031188964844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__specialty_cohort", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.861337Z", "completed_at": "2024-10-22T19:20:30.862144Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.863819Z", "completed_at": "2024-10-22T19:20:30.863823Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0038690567016601562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__surgery_gynecology_cohort", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.862615Z", "completed_at": "2024-10-22T19:20:30.863387Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.864357Z", "completed_at": "2024-10-22T19:20:30.864360Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0038678646087646484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__ansi_fips_state", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.864913Z", "completed_at": "2024-10-22T19:20:30.865718Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.866427Z", "completed_at": "2024-10-22T19:20:30.866430Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004086017608642578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__calendar", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.867762Z", "completed_at": "2024-10-22T19:20:30.868629Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.870162Z", "completed_at": "2024-10-22T19:20:30.870166Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004021883010864258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__code_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.869166Z", "completed_at": "2024-10-22T19:20:30.869936Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.870685Z", "completed_at": "2024-10-22T19:20:30.870689Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004004240036010742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__fips_county", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.871286Z", "completed_at": "2024-10-22T19:20:30.872273Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.872984Z", "completed_at": "2024-10-22T19:20:30.872988Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004139900207519531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__ssa_fips_state", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.874120Z", "completed_at": "2024-10-22T19:20:30.874914Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.877886Z", "completed_at": "2024-10-22T19:20:30.877890Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005181789398193359, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.service_category__service_categories", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.875378Z", "completed_at": "2024-10-22T19:20:30.877613Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.878471Z", "completed_at": "2024-10-22T19:20:30.878474Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005223751068115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__admit_source", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.879011Z", "completed_at": "2024-10-22T19:20:30.879964Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.880748Z", "completed_at": "2024-10-22T19:20:30.880754Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005666017532348633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__admit_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.881956Z", "completed_at": "2024-10-22T19:20:30.882778Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.884436Z", "completed_at": "2024-10-22T19:20:30.884440Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004010915756225586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__apr_drg", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.883270Z", "completed_at": "2024-10-22T19:20:30.884186Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.885068Z", "completed_at": "2024-10-22T19:20:30.885071Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0040378570556640625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__bill_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.885689Z", "completed_at": "2024-10-22T19:20:30.886488Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.887173Z", "completed_at": "2024-10-22T19:20:30.887176Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004155158996582031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ccs_services_procedures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.888517Z", "completed_at": "2024-10-22T19:20:30.889316Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.890766Z", "completed_at": "2024-10-22T19:20:30.890769Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0038640499114990234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__claim_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.889760Z", "completed_at": "2024-10-22T19:20:30.890547Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.891278Z", "completed_at": "2024-10-22T19:20:30.891281Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003760814666748047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__discharge_disposition", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.891832Z", "completed_at": "2024-10-22T19:20:30.892617Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.893318Z", "completed_at": "2024-10-22T19:20:30.893322Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.003824949264526367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__encounter_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.894476Z", "completed_at": "2024-10-22T19:20:30.895484Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.897022Z", "completed_at": "2024-10-22T19:20:30.897026Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003972768783569336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ethnicity", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.895930Z", "completed_at": "2024-10-22T19:20:30.896784Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.897553Z", "completed_at": "2024-10-22T19:20:30.897556Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003952980041503906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__gender", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.898113Z", "completed_at": "2024-10-22T19:20:30.900599Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.901587Z", "completed_at": "2024-10-22T19:20:30.901591Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005934238433837891, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__hcpcs_level_2", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.902836Z", "completed_at": "2024-10-22T19:20:30.903912Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.905460Z", "completed_at": "2024-10-22T19:20:30.905464Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0042040348052978516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__hcpcs_to_rbcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.904431Z", "completed_at": "2024-10-22T19:20:30.905238Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.906020Z", "completed_at": "2024-10-22T19:20:30.906023Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004137992858886719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_10_cm", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.906575Z", "completed_at": "2024-10-22T19:20:30.907361Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.908078Z", "completed_at": "2024-10-22T19:20:30.908082Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.003957033157348633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_10_pcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.909228Z", "completed_at": "2024-10-22T19:20:30.910050Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.911789Z", "completed_at": "2024-10-22T19:20:30.911792Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004005908966064453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_9_cm", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.910474Z", "completed_at": "2024-10-22T19:20:30.911551Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.912317Z", "completed_at": "2024-10-22T19:20:30.912320Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003961086273193359, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_9_pcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.912914Z", "completed_at": "2024-10-22T19:20:30.913751Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.914489Z", "completed_at": "2024-10-22T19:20:30.914492Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0042722225189208984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__loinc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.915688Z", "completed_at": "2024-10-22T19:20:30.916670Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.918270Z", "completed_at": "2024-10-22T19:20:30.918275Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00407099723815918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__loinc_deprecated_mapping", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.917236Z", "completed_at": "2024-10-22T19:20:30.918054Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.918823Z", "completed_at": "2024-10-22T19:20:30.918826Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004079103469848633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__mdc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.919521Z", "completed_at": "2024-10-22T19:20:30.920313Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.921037Z", "completed_at": "2024-10-22T19:20:30.921041Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004126071929931641, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__medicare_dual_eligibility", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.922218Z", "completed_at": "2024-10-22T19:20:30.924330Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.925775Z", "completed_at": "2024-10-22T19:20:30.925779Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0050449371337890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__medicare_orec", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.924779Z", "completed_at": "2024-10-22T19:20:30.925535Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.926274Z", "completed_at": "2024-10-22T19:20:30.926277Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004940032958984375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__medicare_status", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.927036Z", "completed_at": "2024-10-22T19:20:30.927785Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.928465Z", "completed_at": "2024-10-22T19:20:30.928469Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.003950834274291992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ms_drg", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.929736Z", "completed_at": "2024-10-22T19:20:30.930563Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.932007Z", "completed_at": "2024-10-22T19:20:30.932011Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003844738006591797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ms_drg_weights_los", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.931014Z", "completed_at": "2024-10-22T19:20:30.931794Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.932533Z", "completed_at": "2024-10-22T19:20:30.932537Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003798961639404297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ndc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.933135Z", "completed_at": "2024-10-22T19:20:30.933977Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.934875Z", "completed_at": "2024-10-22T19:20:30.934878Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004133701324462891, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__nitos", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.936014Z", "completed_at": "2024-10-22T19:20:30.936809Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.938326Z", "completed_at": "2024-10-22T19:20:30.938329Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0037450790405273438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__other_provider_taxonomy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.937335Z", "completed_at": "2024-10-22T19:20:30.938113Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.938835Z", "completed_at": "2024-10-22T19:20:30.938838Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0037000179290771484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__payer_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.939385Z", "completed_at": "2024-10-22T19:20:30.940176Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.940899Z", "completed_at": "2024-10-22T19:20:30.940902Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.003859996795654297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__place_of_service", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.942217Z", "completed_at": "2024-10-22T19:20:30.943013Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.944491Z", "completed_at": "2024-10-22T19:20:30.944494Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0038788318634033203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__present_on_admission", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.943482Z", "completed_at": "2024-10-22T19:20:30.944270Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.944995Z", "completed_at": "2024-10-22T19:20:30.944997Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0038268566131591797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__provider", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.945550Z", "completed_at": "2024-10-22T19:20:30.947589Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.948339Z", "completed_at": "2024-10-22T19:20:30.948343Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005136013031005859, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__race", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.949735Z", "completed_at": "2024-10-22T19:20:30.950579Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.952047Z", "completed_at": "2024-10-22T19:20:30.952050Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00397801399230957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__revenue_center", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.951047Z", "completed_at": "2024-10-22T19:20:30.951811Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.952615Z", "completed_at": "2024-10-22T19:20:30.952618Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003941059112548828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__rxnorm_brand_generic", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.953193Z", "completed_at": "2024-10-22T19:20:30.953995Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.954682Z", "completed_at": "2024-10-22T19:20:30.954685Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0039017200469970703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__rxnorm_to_atc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.955854Z", "completed_at": "2024-10-22T19:20:30.956860Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.958440Z", "completed_at": "2024-10-22T19:20:30.958444Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004045248031616211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__snomed_ct", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.957343Z", "completed_at": "2024-10-22T19:20:30.958214Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.958999Z", "completed_at": "2024-10-22T19:20:30.959002Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004065990447998047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__snomed_ct_transitive_closures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.959584Z", "completed_at": "2024-10-22T19:20:30.960364Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.961033Z", "completed_at": "2024-10-22T19:20:30.961036Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004028797149658203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__snomed_icd_10_map", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.962229Z", "completed_at": "2024-10-22T19:20:30.972920Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.977452Z", "completed_at": "2024-10-22T19:20:30.977457Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016742944717407227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_condition", "compiled": true, "compiled_code": "\n\nselect\n cast(condition_id as TEXT ) as condition_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( recorded_date as date ) as recorded_date\n , try_cast( onset_date as date ) as onset_date\n , try_cast( resolved_date as date ) as resolved_date\n , cast(status as TEXT ) as status\n , cast(condition_type as TEXT ) as condition_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(condition_rank as integer ) as condition_rank\n , cast(present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.condition", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.968857Z", "completed_at": "2024-10-22T19:20:30.977845Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.978352Z", "completed_at": "2024-10-22T19:20:30.978356Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016978979110717773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_claim_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' AS field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.973415Z", "completed_at": "2024-10-22T19:20:30.979118Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.980155Z", "completed_at": "2024-10-22T19:20:30.980159Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011631965637207031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_condition_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_ID' AS field_name\n , case when m.condition_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_condition_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.980724Z", "completed_at": "2024-10-22T19:20:30.987329Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.990195Z", "completed_at": "2024-10-22T19:20:30.990200Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011512279510498047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_condition_rank", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_RANK' AS field_name\n , case when m.condition_rank is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_rank as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_condition_rank"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.984166Z", "completed_at": "2024-10-22T19:20:30.990536Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.991146Z", "completed_at": "2024-10-22T19:20:30.991150Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01070404052734375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_condition_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_TYPE' AS field_name\n , case when m.condition_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_condition_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.987615Z", "completed_at": "2024-10-22T19:20:30.991472Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:30.992201Z", "completed_at": "2024-10-22T19:20:30.992204Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00833892822265625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_data_source", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.993206Z", "completed_at": "2024-10-22T19:20:30.999189Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.003759Z", "completed_at": "2024-10-22T19:20:31.003766Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01214909553527832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_encounter_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' AS field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.996308Z", "completed_at": "2024-10-22T19:20:31.004158Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.004733Z", "completed_at": "2024-10-22T19:20:31.004737Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012032032012939453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.999431Z", "completed_at": "2024-10-22T19:20:31.005066Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.005769Z", "completed_at": "2024-10-22T19:20:31.005773Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009774923324584961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_onset_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ONSET_DATE' AS field_name\n ,case\n when m.onset_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.onset_date <= cast('1901-01-01' as date) then 'invalid'\n when m.onset_date > m.resolved_date then 'invalid'\n when m.onset_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.onset_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.onset_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.onset_date < m.resolved_date THEN 'Onset date after resolved date'\n else null\n end as invalid_reason\n ,cast(onset_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_onset_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.006757Z", "completed_at": "2024-10-22T19:20:31.014023Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.014485Z", "completed_at": "2024-10-22T19:20:31.014491Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009322881698608398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_patient_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date) ) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.009793Z", "completed_at": "2024-10-22T19:20:31.019176Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.019758Z", "completed_at": "2024-10-22T19:20:31.019770Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013528108596801758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_DESCRIPTION' AS field_name\n ,case when m.present_on_admit_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(present_on_admit_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_present_on_admit_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.014895Z", "completed_at": "2024-10-22T19:20:31.020121Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.020742Z", "completed_at": "2024-10-22T19:20:31.020745Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011295080184936523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_recorded_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'RECORDED_DATE' AS field_name\n ,CASE\n when m.recorded_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.recorded_date <= cast('1901-01-01' as date) then 'invalid'\n when m.recorded_date < m.onset_date then 'invalid'\n when m.recorded_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.recorded_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.recorded_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.recorded_date < m.onset_date THEN 'Recorded date before onset date'\n else null\n end as invalid_reason\n ,cast(recorded_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_recorded_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.021093Z", "completed_at": "2024-10-22T19:20:31.028556Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.029047Z", "completed_at": "2024-10-22T19:20:31.029051Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009631156921386719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_resolved_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'RESOLVED_DATE' AS field_name\n , CASE\n when m.resolved_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.resolved_date <= cast('1901-01-01' as date) then 'invalid'\n when m.resolved_date < m.onset_date then 'invalid'\n when m.resolved_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.resolved_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.resolved_date <= cast('1901-01-01' as date) then 'too old'\n when m.resolved_date < m.onset_date THEN 'Resolved date before onset date'\n else null\n end as invalid_reason\n , cast(resolved_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_resolved_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.025962Z", "completed_at": "2024-10-22T19:20:31.032127Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.032746Z", "completed_at": "2024-10-22T19:20:31.032751Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007979154586791992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_source_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'SOURCE_CODE' AS field_name\n ,case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.029416Z", "completed_at": "2024-10-22T19:20:31.033120Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.033786Z", "completed_at": "2024-10-22T19:20:31.033789Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008118152618408203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_source_code_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' AS field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.034114Z", "completed_at": "2024-10-22T19:20:31.038300Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.041165Z", "completed_at": "2024-10-22T19:20:31.041171Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008732080459594727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_source_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' AS field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.038501Z", "completed_at": "2024-10-22T19:20:31.047927Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.048698Z", "completed_at": "2024-10-22T19:20:31.048703Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011520862579345703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_status", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'STATUS' AS field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "cms_synthetic.data_quality.condition_status"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.041617Z", "completed_at": "2024-10-22T19:20:31.048511Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.049235Z", "completed_at": "2024-10-22T19:20:31.049237Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01122593879699707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_lab_result", "compiled": true, "compiled_code": "\n\nselect\n cast(lab_result_id as TEXT ) as lab_result_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(accession_number as TEXT ) as accession_number\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(source_component as TEXT ) as source_component\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(normalized_component as TEXT ) as normalized_component\n , cast(status as TEXT ) as status\n , cast(result as TEXT ) as result\n , try_cast( result_date as date ) as result_date\n , try_cast( collection_date as date ) as collection_date\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(source_abnormal_flag as TEXT ) as source_abnormal_flag\n , cast(normalized_abnormal_flag as TEXT ) as normalized_abnormal_flag\n , cast(specimen as TEXT ) as specimen\n , cast(ordering_practitioner_id as TEXT ) as ordering_practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.lab_result", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_lab_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.050017Z", "completed_at": "2024-10-22T19:20:31.054949Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.061218Z", "completed_at": "2024-10-22T19:20:31.061223Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01309514045715332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_accession_number", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ACCESSION_NUMBER' AS field_name\n , case when m.accession_number is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(accession_number as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_accession_number"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.055157Z", "completed_at": "2024-10-22T19:20:31.062396Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.065609Z", "completed_at": "2024-10-22T19:20:31.065614Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011736631393432617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_collection_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'COLLECTION_DATE' AS field_name\n , case\n when m.collection_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.collection_date <= cast('1901-01-01' as date) then 'invalid'\n when m.collection_date > m.result_date then 'invalid'\n when m.collection_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.collection_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.collection_date <= cast('1901-01-01' as date) then 'too old'\n when m.collection_date > m.result_date then 'Collection date after result date'\n else null\n end as invalid_reason\n , cast(collection_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_collection_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.058763Z", "completed_at": "2024-10-22T19:20:31.062630Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.065987Z", "completed_at": "2024-10-22T19:20:31.065990Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011747121810913086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.062813Z", "completed_at": "2024-10-22T19:20:31.066998Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.067672Z", "completed_at": "2024-10-22T19:20:31.067676Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005739688873291016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_encounter_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.068614Z", "completed_at": "2024-10-22T19:20:31.079650Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.080218Z", "completed_at": "2024-10-22T19:20:31.080224Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013089895248413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_lab_result_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'LAB_RESULT_ID' as field_name\n , case when m.lab_result_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(lab_result_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_lab_result_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.071290Z", "completed_at": "2024-10-22T19:20:31.079854Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.080620Z", "completed_at": "2024-10-22T19:20:31.080624Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013221979141235352, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_ABNORMAL_FLAG' as field_name\n , case when m.normalized_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_abnormal_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_abnormal_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.076955Z", "completed_at": "2024-10-22T19:20:31.080938Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.081896Z", "completed_at": "2024-10-22T19:20:31.081900Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00586390495300293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.083873Z", "completed_at": "2024-10-22T19:20:31.093752Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.094062Z", "completed_at": "2024-10-22T19:20:31.094066Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011714696884155273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.086611Z", "completed_at": "2024-10-22T19:20:31.094416Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.095074Z", "completed_at": "2024-10-22T19:20:31.095077Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01248311996459961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' as field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.089752Z", "completed_at": "2024-10-22T19:20:31.094888Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.095678Z", "completed_at": "2024-10-22T19:20:31.095681Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01206207275390625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.096939Z", "completed_at": "2024-10-22T19:20:31.103253Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.107034Z", "completed_at": "2024-10-22T19:20:31.107040Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011648178100585938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.100510Z", "completed_at": "2024-10-22T19:20:31.107711Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.108196Z", "completed_at": "2024-10-22T19:20:31.108200Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011545181274414062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_result", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT' AS field_name\n , case when m.result is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(result as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.103451Z", "completed_at": "2024-10-22T19:20:31.108523Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.109191Z", "completed_at": "2024-10-22T19:20:31.109193Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00951695442199707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_result_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT_DATE' as field_name\n , case\n when m.result_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.result_date <= cast('1901-01-01' as date) then 'invalid'\n when m.result_date < m.collection_date then 'invalid'\n when m.result_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.result_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.result_date <= cast('1901-01-01' as date) then 'too old'\n when m.result_date < m.collection_date then 'Result date before collection date'\n else null\n end as invalid_reason\n , cast(result_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_result_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.109526Z", "completed_at": "2024-10-22T19:20:31.115761Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.116996Z", "completed_at": "2024-10-22T19:20:31.117001Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009109973907470703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_ABNORMAL_FLAG' AS field_name\n , case when m.source_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_abnormal_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_abnormal_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.113254Z", "completed_at": "2024-10-22T19:20:31.120340Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.122151Z", "completed_at": "2024-10-22T19:20:31.122156Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010167121887207031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' AS field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.117520Z", "completed_at": "2024-10-22T19:20:31.122952Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.124125Z", "completed_at": "2024-10-22T19:20:31.124130Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01116800308227539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.124810Z", "completed_at": "2024-10-22T19:20:31.133179Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.133965Z", "completed_at": "2024-10-22T19:20:31.133971Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011285066604614258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_component", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_COMPONENT' AS field_name\n , case when m.source_component is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_component as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_component"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.129096Z", "completed_at": "2024-10-22T19:20:31.137499Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.138045Z", "completed_at": "2024-10-22T19:20:31.138050Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013530254364013672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.134442Z", "completed_at": "2024-10-22T19:20:31.138598Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.141719Z", "completed_at": "2024-10-22T19:20:31.141723Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01323390007019043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' AS field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.139072Z", "completed_at": "2024-10-22T19:20:31.142767Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.143418Z", "completed_at": "2024-10-22T19:20:31.143422Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005703926086425781, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' AS field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.143775Z", "completed_at": "2024-10-22T19:20:31.153272Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.153709Z", "completed_at": "2024-10-22T19:20:31.153714Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011651754379272461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n ,'LAB_RESULT' AS table_name\n ,'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n ,'SOURCE_UNITS' AS field_name\n ,case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_source_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.150429Z", "completed_at": "2024-10-22T19:20:31.154031Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.157144Z", "completed_at": "2024-10-22T19:20:31.157148Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014035224914550781, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_specimen", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SPECIMEN' as field_name\n , case when m.specimen is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specimen as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_specimen"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.154213Z", "completed_at": "2024-10-22T19:20:31.158103Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.158723Z", "completed_at": "2024-10-22T19:20:31.158727Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0057642459869384766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_status", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'STATUS' as field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "cms_synthetic.data_quality.lab_result_status"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.159237Z", "completed_at": "2024-10-22T19:20:31.170588Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.171291Z", "completed_at": "2024-10-22T19:20:31.171296Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013792037963867188, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_encounter", "compiled": true, "compiled_code": "\n\nselect\n cast(encounter_id as TEXT) as encounter_id\n , cast(patient_id as TEXT) as patient_id\n , cast(encounter_type as TEXT) as encounter_type\n , cast('clinical' as TEXT) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer) as length_of_stay\n , cast(admit_source_code as TEXT) as admit_source_code\n , cast(admit_source_description as TEXT) as admit_source_description\n , cast(admit_type_code as TEXT) as admit_type_code\n , cast(admit_type_description as TEXT) as admit_type_description\n , cast(discharge_disposition_code as TEXT) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT) as discharge_disposition_description\n , cast(attending_provider_id as TEXT) as attending_provider_id\n , cast(attending_provider_name as TEXT) as attending_provider_name\n , cast(facility_id as TEXT) as facility_id\n , cast(facility_name as TEXT) as facility_name\n , cast(null as TEXT) as facility_type\n , cast(null as integer) as observation_flag\n , cast(null as integer) as lab_flag\n , cast(null as integer) as dme_flag\n , cast(null as integer) as ambulance_flag\n , cast(null as integer) as pharmacy_flag\n , cast(null as integer) as ed_flag\n , cast(null as integer) as delivery_flag\n , cast(null as TEXT) as delivery_type\n , cast(null as integer) as newborn_flag\n , cast(null as integer) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT) as ms_drg_code\n , cast(ms_drg_description as TEXT) as ms_drg_description\n , cast(apr_drg_code as TEXT) as apr_drg_code\n , cast(apr_drg_description as TEXT) as apr_drg_description\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(null as integer) as claim_count\n , cast(null as integer) as inst_claim_count\n , cast(null as integer) as prof_claim_count\n , cast(null as TEXT) as source_model\n , cast(data_source as TEXT) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp) as tuva_last_run\nfrom tuva.input_layer.encounter", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.167960Z", "completed_at": "2024-10-22T19:20:31.172119Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.176225Z", "completed_at": "2024-10-22T19:20:31.176230Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01778101921081543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_DESCRIPTION' AS field_name\n , case when m.admit_source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(admit_source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_admit_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.172357Z", "completed_at": "2024-10-22T19:20:31.179806Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.180287Z", "completed_at": "2024-10-22T19:20:31.180291Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009523153305053711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'ADMIT_TYPE_DESCRIPTION' AS field_name\n ,case when m.admit_type_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(admit_type_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_admit_type_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.177205Z", "completed_at": "2024-10-22T19:20:31.181064Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.184073Z", "completed_at": "2024-10-22T19:20:31.184078Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008152008056640625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_allowed_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_allowed_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.181276Z", "completed_at": "2024-10-22T19:20:31.184931Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.188103Z", "completed_at": "2024-10-22T19:20:31.188108Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008152008056640625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'APR_DRG_DESCRIPTION' AS field_name\n , case when m.apr_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(apr_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_apr_drg_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.185135Z", "completed_at": "2024-10-22T19:20:31.188944Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.191927Z", "completed_at": "2024-10-22T19:20:31.191932Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008140087127685547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_charge_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_charge_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.189151Z", "completed_at": "2024-10-22T19:20:31.192752Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.195725Z", "completed_at": "2024-10-22T19:20:31.195730Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007925987243652344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_data_source", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.192959Z", "completed_at": "2024-10-22T19:20:31.196685Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.200819Z", "completed_at": "2024-10-22T19:20:31.200826Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009226083755493164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_DESCRIPTION' AS field_name\n , case when m.discharge_disposition_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(discharge_disposition_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_discharge_disposition_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.196926Z", "completed_at": "2024-10-22T19:20:31.202054Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.205438Z", "completed_at": "2024-10-22T19:20:31.205443Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010004997253417969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_end_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_END_DATE' AS field_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_end_date < m.encounter_start_date then 'invalid'\n when m.encounter_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_end_date < m.encounter_start_date then 'Encounter end date before encounter start date'\n else null\n end as invalid_reason\n , cast(encounter_end_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_encounter_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.202509Z", "completed_at": "2024-10-22T19:20:31.211136Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.211717Z", "completed_at": "2024-10-22T19:20:31.211723Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011260747909545898, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' AS field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.206357Z", "completed_at": "2024-10-22T19:20:31.212275Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.215292Z", "completed_at": "2024-10-22T19:20:31.215296Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010166168212890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_start_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_START_DATE' AS field_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_start_date > m.encounter_end_date then 'invalid'\n when m.encounter_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_start_date > m.encounter_end_date then 'Encounter start date after encounter end date'\n else null\n end as invalid_reason\n , cast(encounter_start_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_encounter_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.212787Z", "completed_at": "2024-10-22T19:20:31.216601Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.220046Z", "completed_at": "2024-10-22T19:20:31.220051Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008692026138305664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_length_of_stay", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'LENGTH_OF_STAY' AS field_name\n ,case when m.length_of_stay is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(length_of_stay as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_length_of_stay"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.216815Z", "completed_at": "2024-10-22T19:20:31.223315Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.223886Z", "completed_at": "2024-10-22T19:20:31.223890Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008297920227050781, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_DESCRIPTION' AS field_name\n , case when m.ms_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(ms_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_ms_drg_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.220574Z", "completed_at": "2024-10-22T19:20:31.224408Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.227667Z", "completed_at": "2024-10-22T19:20:31.227673Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011332035064697266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_paid_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PAID_AMOUNT' AS field_name\n ,case when m.paid_amount is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(paid_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_paid_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.225063Z", "completed_at": "2024-10-22T19:20:31.230448Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.233988Z", "completed_at": "2024-10-22T19:20:31.233993Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010432004928588867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_patient_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.230866Z", "completed_at": "2024-10-22T19:20:31.239269Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.239798Z", "completed_at": "2024-10-22T19:20:31.239803Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011355876922607422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_DESCRIPTION' AS field_name\n , case when m.primary_diagnosis_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(primary_diagnosis_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "cms_synthetic.data_quality.encounter_primary_diagnosis_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.234863Z", "completed_at": "2024-10-22T19:20:31.240311Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.241306Z", "completed_at": "2024-10-22T19:20:31.241310Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011128902435302734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_location", "compiled": true, "compiled_code": "\n\nselect\n cast(location_id as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(name as TEXT ) as name\n , cast(facility_type as TEXT ) as facility_type\n , cast(parent_organization as TEXT ) as parent_organization\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.location", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.241685Z", "completed_at": "2024-10-22T19:20:31.245710Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.249311Z", "completed_at": "2024-10-22T19:20:31.249315Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009839057922363281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_address", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ADDRESS' AS field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_address"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.245903Z", "completed_at": "2024-10-22T19:20:31.254554Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.255122Z", "completed_at": "2024-10-22T19:20:31.255128Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01046299934387207, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_city", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'CITY' AS field_name\n , case when m.city is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(city as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_city"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.249736Z", "completed_at": "2024-10-22T19:20:31.255470Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.256097Z", "completed_at": "2024-10-22T19:20:31.256101Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010653972625732422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.256571Z", "completed_at": "2024-10-22T19:20:31.263473Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.263963Z", "completed_at": "2024-10-22T19:20:31.263968Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009217977523803711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_facility_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'FACILITY_TYPE' AS field_name\n ,case when m.facility_type is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(facility_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_facility_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.260478Z", "completed_at": "2024-10-22T19:20:31.267899Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.268557Z", "completed_at": "2024-10-22T19:20:31.268562Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009155988693237305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_latitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_latitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.264491Z", "completed_at": "2024-10-22T19:20:31.269398Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.270034Z", "completed_at": "2024-10-22T19:20:31.270038Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00983285903930664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_location_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'LOCATION_ID' AS field_name\n ,case when m.location_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(location_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_location_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.270370Z", "completed_at": "2024-10-22T19:20:31.277815Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.278289Z", "completed_at": "2024-10-22T19:20:31.278294Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009502887725830078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_longitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_longitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.274491Z", "completed_at": "2024-10-22T19:20:31.278803Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.282353Z", "completed_at": "2024-10-22T19:20:31.282358Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012625694274902344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NAME' as field_name\n , case when m.name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.278972Z", "completed_at": "2024-10-22T19:20:31.283330Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.284067Z", "completed_at": "2024-10-22T19:20:31.284071Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006569862365722656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_parent_organization", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'PARENT_ORGANIZATION' AS field_name\n , case when m.parent_organization is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(parent_organization as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_parent_organization"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.284433Z", "completed_at": "2024-10-22T19:20:31.292671Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.293318Z", "completed_at": "2024-10-22T19:20:31.293323Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0106201171875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_state", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_state"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.288027Z", "completed_at": "2024-10-22T19:20:31.293123Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.299062Z", "completed_at": "2024-10-22T19:20:31.299067Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015372037887573242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_zip_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "cms_synthetic.data_quality.location_zip_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.293671Z", "completed_at": "2024-10-22T19:20:31.300628Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.301322Z", "completed_at": "2024-10-22T19:20:31.301326Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008979082107543945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_medication", "compiled": true, "compiled_code": "\n\nselect\n cast(medication_id as TEXT ) as medication_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , try_cast( dispensing_date as date ) as dispensing_date\n , try_cast( prescribing_date as date ) as prescribing_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(rxnorm_code as TEXT ) as rxnorm_code\n , cast(rxnorm_description as TEXT ) as rxnorm_description \n , cast(atc_code as TEXT ) as atc_code\n , cast(atc_description as TEXT ) as atc_description\n , cast(route as TEXT ) as route\n , cast(strength as TEXT ) as strength\n , cast(quantity as integer ) as quantity\n , cast(quantity_unit as TEXT ) as quantity_unit\n , cast(days_supply as integer ) as days_supply\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.medication", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_medication"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.308687Z", "completed_at": "2024-10-22T19:20:31.311259Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.311840Z", "completed_at": "2024-10-22T19:20:31.311845Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.003923892974853516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_days_supply", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DAYS_SUPPLY' AS field_name\n , case when m.days_supply is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_days_supply"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.305008Z", "completed_at": "2024-10-22T19:20:31.311447Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.312187Z", "completed_at": "2024-10-22T19:20:31.312191Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011385917663574219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.301862Z", "completed_at": "2024-10-22T19:20:31.311629Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.312715Z", "completed_at": "2024-10-22T19:20:31.312718Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01244211196899414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_atc_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_DESCRIPTION' as field_name\n , case when m.atc_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(atc_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_atc_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.318679Z", "completed_at": "2024-10-22T19:20:31.324153Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.324786Z", "completed_at": "2024-10-22T19:20:31.324793Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010844945907592773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_encounter_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.321580Z", "completed_at": "2024-10-22T19:20:31.324381Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.325169Z", "completed_at": "2024-10-22T19:20:31.325172Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01099395751953125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_medication_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'MEDICATION_ID' AS field_name\n , case when m.medication_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(medication_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_medication_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.315000Z", "completed_at": "2024-10-22T19:20:31.324614Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.325492Z", "completed_at": "2024-10-22T19:20:31.325496Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011740922927856445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_dispensing_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DISPENSING_DATE' as field_name\n , case\n when m.dispensing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.dispensing_date < m.prescribing_date then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'too old'\n when m.dispensing_date < m.prescribing_date then 'Dispensing date before prescribing date'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_dispensing_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.334604Z", "completed_at": "2024-10-22T19:20:31.337708Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.338313Z", "completed_at": "2024-10-22T19:20:31.338318Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011354207992553711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.327853Z", "completed_at": "2024-10-22T19:20:31.337971Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.338683Z", "completed_at": "2024-10-22T19:20:31.338687Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012126922607421875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_CODE' as field_name\n , case when m.ndc_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(ndc_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_ndc_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.330640Z", "completed_at": "2024-10-22T19:20:31.338150Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.339000Z", "completed_at": "2024-10-22T19:20:31.339003Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01222681999206543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.341400Z", "completed_at": "2024-10-22T19:20:31.350407Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.350659Z", "completed_at": "2024-10-22T19:20:31.350664Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01060795783996582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_prescribing_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRESCRIBING_DATE' as field_name\n , case\n when m.prescribing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.prescribing_date > m.dispensing_date then 'invalid'\n when m.prescribing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.prescribing_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'too old'\n when m.prescribing_date > m.dispensing_date then 'Prescribing date after dispensing date'\n else null\n end as invalid_reason\n , cast(prescribing_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_prescribing_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.345252Z", "completed_at": "2024-10-22T19:20:31.351278Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.352007Z", "completed_at": "2024-10-22T19:20:31.352010Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01170206069946289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_quantity", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY' as field_name\n , case when m.quantity is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_quantity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.347776Z", "completed_at": "2024-10-22T19:20:31.351533Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.352330Z", "completed_at": "2024-10-22T19:20:31.352333Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011774301528930664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_quantity_unit", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY_UNIT' as field_name\n , case when m.quantity_unit is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity_unit as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_quantity_unit"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.353482Z", "completed_at": "2024-10-22T19:20:31.359670Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.362521Z", "completed_at": "2024-10-22T19:20:31.362526Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010809659957885742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_route", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ROUTE' as field_name\n , case when m.route is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(route as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_route"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.357135Z", "completed_at": "2024-10-22T19:20:31.363658Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.364840Z", "completed_at": "2024-10-22T19:20:31.364846Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008848905563354492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_DESCRIPTION' as field_name\n , case when m.rxnorm_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(rxnorm_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_rxnorm_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.359953Z", "completed_at": "2024-10-22T19:20:31.364328Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.366294Z", "completed_at": "2024-10-22T19:20:31.366298Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010053873062133789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.368027Z", "completed_at": "2024-10-22T19:20:31.377601Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.381265Z", "completed_at": "2024-10-22T19:20:31.381271Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016788244247436523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.374360Z", "completed_at": "2024-10-22T19:20:31.381766Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.382379Z", "completed_at": "2024-10-22T19:20:31.382383Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010050773620605469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.378330Z", "completed_at": "2024-10-22T19:20:31.383009Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.383712Z", "completed_at": "2024-10-22T19:20:31.383716Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010573148727416992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_strength", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'STRENGTH' as field_name\n , case when m.strength is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(strength as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "cms_synthetic.data_quality.medication_strength"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.384397Z", "completed_at": "2024-10-22T19:20:31.398983Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.404242Z", "completed_at": "2024-10-22T19:20:31.404249Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.021546125411987305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_patient", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n select\n cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run_datetime\n , cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date ) as tuva_last_run_date\n)\nSELECT\n cast(patient_id as TEXT ) as patient_id\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(sex as TEXT ) as sex\n , cast(race as TEXT ) as race\n , try_cast( birth_date as date ) as birth_date\n , try_cast( death_date as date ) as death_date\n , cast(death_flag as integer ) as death_flag\n , cast(social_security_number as TEXT ) as social_security_number\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(county as TEXT ) as county\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nFROM tuva.input_layer.patient\ncross join tuva_last_run", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.395629Z", "completed_at": "2024-10-22T19:20:31.403956Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.404732Z", "completed_at": "2024-10-22T19:20:31.404735Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020661115646362305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_address", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ADDRESS' as field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_address"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.399411Z", "completed_at": "2024-10-22T19:20:31.405714Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.406411Z", "completed_at": "2024-10-22T19:20:31.406415Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011224985122680664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_birth_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'BIRTH_DATE' AS field_name\n , case\n when m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.birth_date <= cast('1901-01-01' as date) then 'invalid'\n when m.birth_date > m.death_date then 'invalid'\n when m.birth_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.birth_date <= cast('1901-01-01' as date) then 'too old'\n when m.birth_date > m.death_date then 'Birth date after death date'\n else null\n end as invalid_reason\n , cast(birth_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_birth_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.407483Z", "completed_at": "2024-10-22T19:20:31.419531Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.420276Z", "completed_at": "2024-10-22T19:20:31.420286Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014414072036743164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_city", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'CITY' AS field_name\n ,case when m.city is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(city as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_city"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.410907Z", "completed_at": "2024-10-22T19:20:31.420024Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.420703Z", "completed_at": "2024-10-22T19:20:31.420706Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014556884765625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_county", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'COUNTY' as field_name\n ,case when m.county is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(county as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_county"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.414470Z", "completed_at": "2024-10-22T19:20:31.421062Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.421879Z", "completed_at": "2024-10-22T19:20:31.421884Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008153915405273438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.423675Z", "completed_at": "2024-10-22T19:20:31.435815Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.436340Z", "completed_at": "2024-10-22T19:20:31.436345Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01408696174621582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_death_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_DATE' AS field_name\n , case\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date > m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date > m.birth_date then 'Death date after birth date'\n else null\n end as invalid_reason\n , cast(death_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_death_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.428306Z", "completed_at": "2024-10-22T19:20:31.436044Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.437121Z", "completed_at": "2024-10-22T19:20:31.437125Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014632940292358398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_death_flag", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_FLAG' as field_name\n , case when m.death_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(death_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_death_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.431888Z", "completed_at": "2024-10-22T19:20:31.436903Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.437800Z", "completed_at": "2024-10-22T19:20:31.437803Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014410018920898438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_first_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_first_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.439959Z", "completed_at": "2024-10-22T19:20:31.449885Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.450152Z", "completed_at": "2024-10-22T19:20:31.450158Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011684179306030273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_last_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' AS field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_last_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.443318Z", "completed_at": "2024-10-22T19:20:31.450837Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.451561Z", "completed_at": "2024-10-22T19:20:31.451565Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012561798095703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_latitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_latitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.446530Z", "completed_at": "2024-10-22T19:20:31.451358Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.452131Z", "completed_at": "2024-10-22T19:20:31.452136Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012655973434448242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_longitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_longitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.452934Z", "completed_at": "2024-10-22T19:20:31.457444Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.465335Z", "completed_at": "2024-10-22T19:20:31.465342Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01431417465209961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.457655Z", "completed_at": "2024-10-22T19:20:31.466672Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.472560Z", "completed_at": "2024-10-22T19:20:31.472566Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01615738868713379, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_state", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_state"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.460954Z", "completed_at": "2024-10-22T19:20:31.466854Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.473068Z", "completed_at": "2024-10-22T19:20:31.473071Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016331195831298828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_zip_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "cms_synthetic.data_quality.patient_zip_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.467029Z", "completed_at": "2024-10-22T19:20:31.474531Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.476320Z", "completed_at": "2024-10-22T19:20:31.476325Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01014399528503418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_observation", "compiled": true, "compiled_code": "\n\n\nselect\n cast(observation_id as TEXT ) as observation_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(panel_id as TEXT ) as panel_id\n , try_cast( observation_date as date ) as observation_date\n , cast(observation_type as TEXT ) as observation_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(result as TEXT ) as result\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.observation", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_observation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.483138Z", "completed_at": "2024-10-22T19:20:31.491886Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.492451Z", "completed_at": "2024-10-22T19:20:31.492456Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016444921493530273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_encounter_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' as field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.479068Z", "completed_at": "2024-10-22T19:20:31.492112Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.493266Z", "completed_at": "2024-10-22T19:20:31.493269Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01751708984375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.488639Z", "completed_at": "2024-10-22T19:20:31.492998Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.493891Z", "completed_at": "2024-10-22T19:20:31.493893Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006120920181274414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when m.normalized_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.495901Z", "completed_at": "2024-10-22T19:20:31.505243Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.505566Z", "completed_at": "2024-10-22T19:20:31.505571Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011249065399169922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when m.normalized_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.499304Z", "completed_at": "2024-10-22T19:20:31.510780Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.511216Z", "completed_at": "2024-10-22T19:20:31.511222Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0162811279296875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' as field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.502564Z", "completed_at": "2024-10-22T19:20:31.510988Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.511623Z", "completed_at": "2024-10-22T19:20:31.511626Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01619410514831543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_normalized_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.506897Z", "completed_at": "2024-10-22T19:20:31.512016Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.512927Z", "completed_at": "2024-10-22T19:20:31.512931Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006659030914306641, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' AS field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_normalized_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.515025Z", "completed_at": "2024-10-22T19:20:31.524687Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.525206Z", "completed_at": "2024-10-22T19:20:31.525212Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01190805435180664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_normalized_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.518054Z", "completed_at": "2024-10-22T19:20:31.524971Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.525816Z", "completed_at": "2024-10-22T19:20:31.525820Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012243032455444336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_observation_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_DATE' as field_name\n , case\n when m.observation_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.observation_date <= cast('1901-01-01' as date) then 'invalid'\n when m.observation_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.observation_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.observation_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(observation_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_observation_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.521856Z", "completed_at": "2024-10-22T19:20:31.525619Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.526476Z", "completed_at": "2024-10-22T19:20:31.526479Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01174616813659668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_observation_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_ID' as field_name\n , case when m.observation_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_observation_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.528512Z", "completed_at": "2024-10-22T19:20:31.537511Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.537786Z", "completed_at": "2024-10-22T19:20:31.537790Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010761260986328125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_observation_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_TYPE' as field_name\n , case when m.observation_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_observation_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.531780Z", "completed_at": "2024-10-22T19:20:31.538165Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.538938Z", "completed_at": "2024-10-22T19:20:31.538942Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01135110855102539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_panel_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PANEL_ID' as field_name\n , case when m.panel_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(panel_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_panel_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.534757Z", "completed_at": "2024-10-22T19:20:31.538565Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.539557Z", "completed_at": "2024-10-22T19:20:31.539561Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011513948440551758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.540860Z", "completed_at": "2024-10-22T19:20:31.550604Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.550992Z", "completed_at": "2024-10-22T19:20:31.550997Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011767148971557617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_result", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'RESULT' as field_name\n ,case when m.result is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(result, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.546904Z", "completed_at": "2024-10-22T19:20:31.551646Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.552256Z", "completed_at": "2024-10-22T19:20:31.552260Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008764982223510742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.544242Z", "completed_at": "2024-10-22T19:20:31.551810Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.552574Z", "completed_at": "2024-10-22T19:20:31.552577Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011983871459960938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.553653Z", "completed_at": "2024-10-22T19:20:31.562446Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.562843Z", "completed_at": "2024-10-22T19:20:31.562848Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010881900787353516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.557513Z", "completed_at": "2024-10-22T19:20:31.563463Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.563939Z", "completed_at": "2024-10-22T19:20:31.563942Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007508993148803711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' as field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_source_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.559991Z", "completed_at": "2024-10-22T19:20:31.564223Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.564907Z", "completed_at": "2024-10-22T19:20:31.564910Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00822305679321289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' as field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_source_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.565219Z", "completed_at": "2024-10-22T19:20:31.569079Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.573269Z", "completed_at": "2024-10-22T19:20:31.573275Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00963902473449707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS TABLE_NAME\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_UNITS' as field_name\n , case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_units as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "cms_synthetic.data_quality.observation_source_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.569403Z", "completed_at": "2024-10-22T19:20:31.576900Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.577473Z", "completed_at": "2024-10-22T19:20:31.577525Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009596824645996094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_practitioner", "compiled": true, "compiled_code": "\n\nselect\n cast(practitioner_id as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(practice_affiliation as TEXT ) as practice_affiliation\n , cast(specialty as TEXT ) as specialty\n , cast(sub_specialty as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.practitioner", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.573697Z", "completed_at": "2024-10-22T19:20:31.578368Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.581851Z", "completed_at": "2024-10-22T19:20:31.581855Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013067007064819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.578604Z", "completed_at": "2024-10-22T19:20:31.587496Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.588146Z", "completed_at": "2024-10-22T19:20:31.588150Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011057853698730469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_first_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_first_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.582734Z", "completed_at": "2024-10-22T19:20:31.588724Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.592305Z", "completed_at": "2024-10-22T19:20:31.592310Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01078033447265625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_last_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' as field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_last_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.589161Z", "completed_at": "2024-10-22T19:20:31.593687Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.597086Z", "completed_at": "2024-10-22T19:20:31.597091Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009323835372924805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTICE_AFFILIATION' AS field_name\n , case when m.practice_affiliation is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practice_affiliation as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_practice_affiliation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.594135Z", "completed_at": "2024-10-22T19:20:31.601442Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.601996Z", "completed_at": "2024-10-22T19:20:31.602002Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00939178466796875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.597987Z", "completed_at": "2024-10-22T19:20:31.602918Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.606404Z", "completed_at": "2024-10-22T19:20:31.606409Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012579679489135742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_specialty", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SPECIALTY' as field_name\n , case when m.specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specialty as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_specialty"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.603191Z", "completed_at": "2024-10-22T19:20:31.612255Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.612795Z", "completed_at": "2024-10-22T19:20:31.612800Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011156082153320312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_sub_specialty", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SUB_SPECIALTY' as field_name\n , case when m.sub_specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(sub_specialty as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "cms_synthetic.data_quality.practitioner_sub_specialty"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.607329Z", "completed_at": "2024-10-22T19:20:31.613340Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.616608Z", "completed_at": "2024-10-22T19:20:31.616614Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010521173477172852, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_procedure", "compiled": true, "compiled_code": "\n\nselect\n cast(procedure_id as TEXT ) as procedure_id \n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( procedure_date as date ) as procedure_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(modifier_1 as TEXT ) as modifier_1\n , cast(modifier_2 as TEXT ) as modifier_2\n , cast(modifier_3 as TEXT ) as modifier_3\n , cast(modifier_4 as TEXT ) as modifier_4\n , cast(modifier_5 as TEXT ) as modifier_5\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.procedure", "relation_name": "cms_synthetic.dbt_tom.core__stg_clinical_procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.613832Z", "completed_at": "2024-10-22T19:20:31.618044Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.621243Z", "completed_at": "2024-10-22T19:20:31.621249Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008810997009277344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_claim_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' as field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.618251Z", "completed_at": "2024-10-22T19:20:31.624551Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.625135Z", "completed_at": "2024-10-22T19:20:31.625139Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00820302963256836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.621652Z", "completed_at": "2024-10-22T19:20:31.625447Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.626070Z", "completed_at": "2024-10-22T19:20:31.626073Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008273839950561523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_encounter_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.626383Z", "completed_at": "2024-10-22T19:20:31.634165Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.634937Z", "completed_at": "2024-10-22T19:20:31.634944Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010204792022705078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.631105Z", "completed_at": "2024-10-22T19:20:31.638574Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.639411Z", "completed_at": "2024-10-22T19:20:31.639441Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009530067443847656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.635399Z", "completed_at": "2024-10-22T19:20:31.640265Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.641071Z", "completed_at": "2024-10-22T19:20:31.641076Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010418891906738281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' AS field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.641438Z", "completed_at": "2024-10-22T19:20:31.648672Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.649289Z", "completed_at": "2024-10-22T19:20:31.649295Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009541034698486328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_DATE' as field_name\n , case\n when m.procedure_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date <= cast('1901-01-01' as date) then 'invalid'\n when m.procedure_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.procedure_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(procedure_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_procedure_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.645518Z", "completed_at": "2024-10-22T19:20:31.649105Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.652674Z", "completed_at": "2024-10-22T19:20:31.652679Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011927127838134766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_ID' AS field_name\n , case when m.procedure_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(procedure_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_procedure_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.649700Z", "completed_at": "2024-10-22T19:20:31.654224Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.654816Z", "completed_at": "2024-10-22T19:20:31.654822Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006475210189819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.657941Z", "completed_at": "2024-10-22T19:20:31.662870Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.663307Z", "completed_at": "2024-10-22T19:20:31.663311Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009376049041748047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.655173Z", "completed_at": "2024-10-22T19:20:31.663057Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.663807Z", "completed_at": "2024-10-22T19:20:31.663818Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010163307189941406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "cms_synthetic.data_quality.procedure_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.661452Z", "completed_at": "2024-10-22T19:20:31.664637Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.665303Z", "completed_at": "2024-10-22T19:20:31.665307Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0043888092041015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.eligibility", "compiled": true, "compiled_code": "select\n patient_id\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , subscriber_relation\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom cms_synthetic._tuva_synthetic.eligibility_seed", "relation_name": "tuva.input_layer.eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.669905Z", "completed_at": "2024-10-22T19:20:31.673683Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.674104Z", "completed_at": "2024-10-22T19:20:31.674109Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009072065353393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.pharmacy_claim", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom cms_synthetic._tuva_synthetic.pharmacy_claim_seed", "relation_name": "tuva.input_layer.pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.666285Z", "completed_at": "2024-10-22T19:20:31.673866Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.674487Z", "completed_at": "2024-10-22T19:20:31.674490Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009702205657958984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.medical_claim", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom cms_synthetic._tuva_synthetic.medical_claim_seed", "relation_name": "tuva.input_layer.medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.672254Z", "completed_at": "2024-10-22T19:20:31.675124Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.676470Z", "completed_at": "2024-10-22T19:20:31.676475Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005099058151245117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.provider_attribution", "compiled": true, "compiled_code": "select\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , payer_attributed_provider\n , payer_attributed_provider_practice\n , payer_attributed_provider_organization\n , payer_attributed_provider_lob\n , custom_attributed_provider\n , custom_attributed_provider_practice\n , custom_attributed_provider_organization\n , custom_attributed_provider_lob\nfrom cms_synthetic._tuva_synthetic.provider_attribution_seed", "relation_name": "tuva.input_layer.provider_attribution"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.677786Z", "completed_at": "2024-10-22T19:20:31.687174Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.687630Z", "completed_at": "2024-10-22T19:20:31.687635Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011828899383544922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__dx_vertical_pivot", "compiled": true, "compiled_code": "\n\nwith codes as (\n \n select\n icd_10_cm_code as code, \n icd_10_cm_code_description as code_description,\n -- loop to generate columns for CCSR categories 1-6\n ccsr_category_1,\n ccsr_category_1_description,\n ccsr_category_2,\n ccsr_category_2_description,\n ccsr_category_3,\n ccsr_category_3_description,\n ccsr_category_4,\n ccsr_category_4_description,\n ccsr_category_5,\n ccsr_category_5_description,\n ccsr_category_6,\n ccsr_category_6_description,\n default_ccsr_category_ip,\n default_ccsr_category_op\n from cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map\n\n), long_union as (\n -- generate select & union statements to pivot category columns to rows\n \n select \n code,\n code_description,\n substring(ccsr_category_1, 1, 3) as ccsr_parent_category,\n ccsr_category_1 as ccsr_category,\n ccsr_category_1_description as ccsr_category_description,\n 1 as ccsr_category_rank,\n CASE WHEN ccsr_category_1 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_1 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_2, 1, 3) as ccsr_parent_category,\n ccsr_category_2 as ccsr_category,\n ccsr_category_2_description as ccsr_category_description,\n 2 as ccsr_category_rank,\n CASE WHEN ccsr_category_2 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_2 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_3, 1, 3) as ccsr_parent_category,\n ccsr_category_3 as ccsr_category,\n ccsr_category_3_description as ccsr_category_description,\n 3 as ccsr_category_rank,\n CASE WHEN ccsr_category_3 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_3 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_4, 1, 3) as ccsr_parent_category,\n ccsr_category_4 as ccsr_category,\n ccsr_category_4_description as ccsr_category_description,\n 4 as ccsr_category_rank,\n CASE WHEN ccsr_category_4 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_4 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_5, 1, 3) as ccsr_parent_category,\n ccsr_category_5 as ccsr_category,\n ccsr_category_5_description as ccsr_category_description,\n 5 as ccsr_category_rank,\n CASE WHEN ccsr_category_5 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_5 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_6, 1, 3) as ccsr_parent_category,\n ccsr_category_6 as ccsr_category,\n ccsr_category_6_description as ccsr_category_description,\n 6 as ccsr_category_rank,\n CASE WHEN ccsr_category_6 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_6 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n \n\n)\n\nselect distinct\n *,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom long_union\n-- as not all diagnosis codes have multiple categories, we can discard nulls\nwhere ccsr_category is not null", "relation_name": "cms_synthetic.ccsr.dx_vertical_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.682043Z", "completed_at": "2024-10-22T19:20:31.687369Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.688023Z", "completed_at": "2024-10-22T19:20:31.688026Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01120901107788086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__procedure_category_map", "compiled": true, "compiled_code": "\n\nselect \n icd_10_pcs as code,\n icd_10_pcs_description as code_description,\n prccsr as ccsr_category,\n substring(prccsr, 1, 3) as ccsr_parent_category,\n prccsr_description as ccsr_category_description,\n clinical_domain,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ccsr._value_set_prccsr_v2023_1_cleaned_map", "relation_name": "cms_synthetic.ccsr.procedure_category_map"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.685311Z", "completed_at": "2024-10-22T19:20:31.688346Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.689232Z", "completed_at": "2024-10-22T19:20:31.689235Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007543802261352539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields", "compiled": true, "compiled_code": "with value_set_member_relevant_fields as (\nselect \n aa.concept_id,\n aa.concept_name,\n aa.concept_type,\n \n bb.value_set_member_id,\n bb.code,\n bb.coding_system_id,\n bb.include_descendants,\n\n cc.coding_system_name\n \nfrom cms_synthetic.clinical_concept_library.clinical_concepts aa\n\nleft join cms_synthetic.clinical_concept_library.value_set_members bb\non aa.concept_id = bb.concept_id\n\nleft join cms_synthetic.clinical_concept_library.coding_systems cc\non bb.coding_system_id = cc.coding_system_id\n)\n\n\nselect *\nfrom value_set_member_relevant_fields", "relation_name": "cms_synthetic.clinical_concept_library.value_set_member_relevant_fields"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.697419Z", "completed_at": "2024-10-22T19:20:31.709124Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.709879Z", "completed_at": "2024-10-22T19:20:31.709885Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.020142078399658203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd10 as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.ed_classification._value_set_johnston_icd10\nwhere icd10 is not null\ngroup by icd10\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.690852Z", "completed_at": "2024-10-22T19:20:31.709565Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.710612Z", "completed_at": "2024-10-22T19:20:31.710616Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021092891693115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd10\nfrom cms_synthetic.ed_classification._value_set_johnston_icd10\nwhere icd10 is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.706576Z", "completed_at": "2024-10-22T19:20:31.710405Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.711587Z", "completed_at": "2024-10-22T19:20:31.711591Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02100515365600586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd9\nfrom cms_synthetic.ed_classification._value_set_johnston_icd9\nwhere icd9 is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.713911Z", "completed_at": "2024-10-22T19:20:31.722449Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.722883Z", "completed_at": "2024-10-22T19:20:31.722888Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010761260986328125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd9 as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.ed_classification._value_set_johnston_icd9\nwhere icd9 is not null\ngroup by icd9\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.719632Z", "completed_at": "2024-10-22T19:20:31.723514Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.724166Z", "completed_at": "2024-10-22T19:20:31.724171Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01081395149230957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__quality_measures_value_set", "compiled": true, "compiled_code": "\n\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.quality_measures._value_set_measures p", "relation_name": "cms_synthetic.data_quality.mart_review__quality_measures_value_set"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.716534Z", "completed_at": "2024-10-22T19:20:31.723696Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.724538Z", "completed_at": "2024-10-22T19:20:31.724542Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01187586784362793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "compiled": true, "compiled_code": "\n\nselect distinct \n product_rxcui as brand_with_generic_available\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.pharmacy.rxnorm_generic_available\nwhere \n ndc_product_tty in ('SCD', 'GPCK')\n \n and cast(product_startmarketingdate as date) <= current_date\n", "relation_name": "cms_synthetic.pharmacy._int_brand_with_generic_available"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.725581Z", "completed_at": "2024-10-22T19:20:31.736495Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.741291Z", "completed_at": "2024-10-22T19:20:31.741297Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01743173599243164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.731512Z", "completed_at": "2024-10-22T19:20:31.741818Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.742520Z", "completed_at": "2024-10-22T19:20:31.742523Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012087106704711914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((\n select id\n from cms_synthetic.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_id\n , cast((\n select name\n from cms_synthetic.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_name\n , cast((\n select version\n from cms_synthetic.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_adhras__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.736748Z", "completed_at": "2024-10-22T19:20:31.742026Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.742866Z", "completed_at": "2024-10-22T19:20:31.742870Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012152910232543945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_cbe0055__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.744682Z", "completed_at": "2024-10-22T19:20:31.760091Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.760477Z", "completed_at": "2024-10-22T19:20:31.760482Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01723480224609375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_cbe0101__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.755821Z", "completed_at": "2024-10-22T19:20:31.761191Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.761901Z", "completed_at": "2024-10-22T19:20:31.761904Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01747894287109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_cqm236__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.750925Z", "completed_at": "2024-10-22T19:20:31.761440Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.762252Z", "completed_at": "2024-10-22T19:20:31.762255Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018049955368041992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_cqm130__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.763315Z", "completed_at": "2024-10-22T19:20:31.769309Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.781612Z", "completed_at": "2024-10-22T19:20:31.781619Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.020029067993164062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_cqm438__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.769739Z", "completed_at": "2024-10-22T19:20:31.782560Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.783197Z", "completed_at": "2024-10-22T19:20:31.783201Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015048980712890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_cqm48__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.774071Z", "completed_at": "2024-10-22T19:20:31.782744Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.783537Z", "completed_at": "2024-10-22T19:20:31.783540Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015134334564208984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n - set quality_measures_period_end to december end for last quarter measurement period\n - set quality_measures_period_end to march end for first quarter measurement period \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 3 months prior\n for visits in influenza season\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n month,\n -3,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n lookback_period for august of either current or previous year\n for immunization qualifying date\n*/\n, lookback_period as (\n\n select\n *\n , case\n when date_part('month', performance_period_end) between 1 and 8\n then (cast(date_part('year', performance_period_end) as integer) - 1) || '-08-01'\n else date_part('year', performance_period_end) || '-08-01'\n end as lookback_period_august\n from period_begin\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_august as date) as lookback_period_august\nfrom lookback_period", "relation_name": "cms_synthetic.quality_measures._int_nqf0041__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.784778Z", "completed_at": "2024-10-22T19:20:31.792003Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.803801Z", "completed_at": "2024-10-22T19:20:31.803807Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.020977258682250977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n-- lookback_period for last june 30 and december 31\n, lookback_period as (\n\nSELECT\n *\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-06-30') as date)\n then date_part('year', performance_period_end) || '-06-30'\n else date_part('year', performance_period_begin) || '-06-30'\n end as lookback_period_june\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-12-31') as date)\n then date_part('year', performance_period_end) || '-12-31'\n else date_part('year', performance_period_begin) || '-12-31'\n end as lookback_period_december\nFROM period_begin\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_june as date) as lookback_period_june\n , cast(lookback_period_december as date) as lookback_period_december\nfrom lookback_period", "relation_name": "cms_synthetic.quality_measures._int_nqf0053__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.792197Z", "completed_at": "2024-10-22T19:20:31.804947Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.805627Z", "completed_at": "2024-10-22T19:20:31.805632Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014899969100952148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_nqf0059__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.798123Z", "completed_at": "2024-10-22T19:20:31.805397Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.806260Z", "completed_at": "2024-10-22T19:20:31.806265Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015343904495239258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_nqf0097__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.806995Z", "completed_at": "2024-10-22T19:20:31.816306Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.822012Z", "completed_at": "2024-10-22T19:20:31.822018Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01691579818725586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "cms_synthetic.quality_measures._int_nqf0420__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.817079Z", "completed_at": "2024-10-22T19:20:31.826968Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.827517Z", "completed_at": "2024-10-22T19:20:31.827523Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01252293586730957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback period to 27 months prior to the end of the\n performance period\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n month,\n -27,\n performance_period_end\n )\n\n as performance_period_lookback\n from period_begin\n\n\n)\n\nselect\n cast((select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_id\n , cast((select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_name\n , cast((select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_version\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_lookback as date) as performance_period_lookback\nfrom period_lookback", "relation_name": "cms_synthetic.quality_measures._int_nqf2372__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.822767Z", "completed_at": "2024-10-22T19:20:31.828177Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.831887Z", "completed_at": "2024-10-22T19:20:31.831893Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01621723175048828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__calendar_month", "compiled": true, "compiled_code": "\n\n\nselect distinct\ncast(year_month_int as TEXT) as year_month\n, full_date\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.reference_data.calendar c\nwhere day = 1", "relation_name": "cms_synthetic.data_quality.mart_review__calendar_month"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.828771Z", "completed_at": "2024-10-22T19:20:31.833142Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.836753Z", "completed_at": "2024-10-22T19:20:31.836759Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009652853012084961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join cms_synthetic.reference_data.code_type as term on m.normalized_code_type = term.code_type", "relation_name": "cms_synthetic.data_quality.condition_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.833593Z", "completed_at": "2024-10-22T19:20:31.840860Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.841389Z", "completed_at": "2024-10-22T19:20:31.841393Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009170055389404297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.primary_diagnosis_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code_type is not null and term.code_type is null\n then 'Primary Diagnosis Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.reference_data.code_type term on m.primary_diagnosis_code_type = term.code_type", "relation_name": "cms_synthetic.data_quality.encounter_primary_diagnosis_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.837727Z", "completed_at": "2024-10-22T19:20:31.841982Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.845042Z", "completed_at": "2024-10-22T19:20:31.845048Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011744022369384766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.reference_data.code_type term on m.normalized_code_type = term.code_type", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.842450Z", "completed_at": "2024-10-22T19:20:31.846342Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.850963Z", "completed_at": "2024-10-22T19:20:31.850969Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009942054748535156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.reference_data.code_type term on m.normalized_code_type = term.code_type", "relation_name": "cms_synthetic.data_quality.procedure_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.846781Z", "completed_at": "2024-10-22T19:20:31.854720Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.855302Z", "completed_at": "2024-10-22T19:20:31.855306Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009786128997802734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_source_code is not null and term.admit_source_code is null\n then 'Admit source code does not join to Terminology admit source table'\n else null end as invalid_reason\n , cast(m.admit_source_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.admit_source term on m.admit_source_code = term.admit_source_code", "relation_name": "cms_synthetic.data_quality.encounter_admit_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.852024Z", "completed_at": "2024-10-22T19:20:31.856023Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.859193Z", "completed_at": "2024-10-22T19:20:31.859198Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012691974639892578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_type_code is not null and term.admit_type_code is null\n then 'Admit Type Code does not join to Terminology admit_type table'\n else null end as invalid_reason\n , cast(m.admit_type_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.admit_type term on m.admit_type_code = term.admit_type_code", "relation_name": "cms_synthetic.data_quality.encounter_admit_type_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.856226Z", "completed_at": "2024-10-22T19:20:31.862601Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.863118Z", "completed_at": "2024-10-22T19:20:31.863123Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00821685791015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'APR_DRG_CODE' AS field_name\n ,case when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.apr_drg_code is not null and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology apr_drg table'\n else null end as invalid_reason\n ,cast(m.apr_drg_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.apr_drg term on m.apr_drg_code = term.apr_drg_code", "relation_name": "cms_synthetic.data_quality.encounter_apr_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.860059Z", "completed_at": "2024-10-22T19:20:31.863805Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.866797Z", "completed_at": "2024-10-22T19:20:31.866802Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007932901382446289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.discharge_disposition_code is not null and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology discharge_disposition table'\n else null end as invalid_reason\n , cast(m.discharge_disposition_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.discharge_disposition term on m.discharge_disposition_code = term.discharge_disposition_code", "relation_name": "cms_synthetic.data_quality.encounter_discharge_disposition_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.864256Z", "completed_at": "2024-10-22T19:20:31.867933Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.871441Z", "completed_at": "2024-10-22T19:20:31.871476Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008750200271606445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_TYPE' AS field_name\n , case when term.encounter_type is not null then 'valid'\n when m.encounter_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.encounter_type is not null and term.encounter_type is null\n then 'Encounter type does not join to Terminology encounter_type table'\n else null end as invalid_reason\n , cast(m.encounter_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.encounter_type term on m.encounter_type = term.encounter_type", "relation_name": "cms_synthetic.data_quality.encounter_encounter_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.868332Z", "completed_at": "2024-10-22T19:20:31.874902Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.875401Z", "completed_at": "2024-10-22T19:20:31.875407Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00828695297241211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_sex", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'SEX' as field_name\n , case when term.gender is not null then 'valid'\n when m.sex is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.sex is not null and term.gender is null\n then 'Sex does not join to Terminology gender table'\n else null end as invalid_reason\n , cast(sex as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join cms_synthetic.terminology.gender term on m.sex = term.gender", "relation_name": "cms_synthetic.data_quality.patient_sex"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.872433Z", "completed_at": "2024-10-22T19:20:31.875959Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.879018Z", "completed_at": "2024-10-22T19:20:31.879023Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010985851287841797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_1", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as SOURCE_DATE\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_1' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_1 is not null and term.hcpcs is null\n then 'Modifier 1 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_1 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_1 = term.hcpcs", "relation_name": "cms_synthetic.data_quality.procedure_modifier_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.876452Z", "completed_at": "2024-10-22T19:20:31.880356Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.883426Z", "completed_at": "2024-10-22T19:20:31.883432Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008385181427001953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_2", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_2' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_2 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_2 is not null and term.hcpcs is null\n then 'Modifier 2 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_2 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_2 = term.hcpcs", "relation_name": "cms_synthetic.data_quality.procedure_modifier_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.880558Z", "completed_at": "2024-10-22T19:20:31.888547Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.889096Z", "completed_at": "2024-10-22T19:20:31.889101Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009779930114746094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_3", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_3' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_3 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_3 is not null and term.hcpcs is null\n then 'Modifier 3 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_3 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_3 = term.hcpcs", "relation_name": "cms_synthetic.data_quality.procedure_modifier_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.883848Z", "completed_at": "2024-10-22T19:20:31.889636Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.892786Z", "completed_at": "2024-10-22T19:20:31.892791Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012721061706542969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_4", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n ,'PROCEDURE' AS table_name\n ,'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n ,'MODIFIER_4' as field_name\n ,case when term.hcpcs is not null then 'valid'\n when m.modifier_4 is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.modifier_4 is not null and term.hcpcs is null\n then 'Modifier 4 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n ,cast(modifier_4 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_4 = term.hcpcs", "relation_name": "cms_synthetic.data_quality.procedure_modifier_4"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.890121Z", "completed_at": "2024-10-22T19:20:31.893904Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.896993Z", "completed_at": "2024-10-22T19:20:31.896998Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008249759674072266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_5", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_5' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_5 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_5 is not null and term.hcpcs is null\n then 'Modifier 5 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_5 as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.modifier_5 = term.hcpcs", "relation_name": "cms_synthetic.data_quality.procedure_modifier_5"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.894371Z", "completed_at": "2024-10-22T19:20:31.900712Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.901151Z", "completed_at": "2024-10-22T19:20:31.901156Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008053064346313477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_cm is null\n then 'Normalized code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join cms_synthetic.terminology.icd_10_cm term on m.normalized_code = term.icd_10_cm", "relation_name": "cms_synthetic.data_quality.condition_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.897858Z", "completed_at": "2024-10-22T19:20:31.901457Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.907248Z", "completed_at": "2024-10-22T19:20:31.907253Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013180255889892578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.primary_diagnosis_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code is not null and term.icd_10_cm is null\n then 'Primary diagnosis code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.icd_10_cm term on m.primary_diagnosis_code = term.icd_10_cm", "relation_name": "cms_synthetic.data_quality.encounter_primary_diagnosis_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.901647Z", "completed_at": "2024-10-22T19:20:31.909494Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.910484Z", "completed_at": "2024-10-22T19:20:31.910488Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010092020034790039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code", "compiled": true, "compiled_code": "\n\nwith icd9 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_9_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_9_pcs is null\n then 'Normalized code does not join to Terminology icd_9_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n from tuva.input_layer.procedure m\n left join cms_synthetic.terminology.icd_9_pcs term on m.normalized_code = term.icd_9_pcs\n where\n m.normalized_code_type = 'icd-9-pcs'\n),\nicd10 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_10_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_pcs is null\n then 'Normalized code does not join to Terminology icd_10_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.icd_10_pcs term on m.normalized_code = term.icd_10_pcs\nwhere\n m.normalized_code_type = 'icd_10_pcs'\n),\nhcpcs_level_2 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.hcpcs is null\n then 'Normalized code does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join cms_synthetic.terminology.hcpcs_level_2 term on m.normalized_code = term.hcpcs\nwhere\n m.normalized_code_type = 'hcpcs_level_2'\n),\n\nothers as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , 'null' as bucket_name\n , 'code type does not have a matching code terminology table' as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nwhere\n m.normalized_code_type not in ('icd-9-pcs', 'icd-10-pcs','hcpcs_level_2')\n)\n\nSELECT *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM icd9\n\nunion all\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM icd10\n\nunion all\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM hcpcs_level_2\n\nunion all\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run FROM others", "relation_name": "cms_synthetic.data_quality.procedure_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.910836Z", "completed_at": "2024-10-22T19:20:31.917324Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.917809Z", "completed_at": "2024-10-22T19:20:31.917813Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00979304313659668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.loinc is null\n then 'Normalized code does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.terminology.loinc term on m.normalized_code = term.loinc", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.914568Z", "completed_at": "2024-10-22T19:20:31.918282Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.921595Z", "completed_at": "2024-10-22T19:20:31.921599Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011742115020751953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_component", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_COMPONENT' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_component is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_component is not null and term.loinc is null\n then 'Normalized component does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_component as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.terminology.loinc term on m.normalized_component = term.loinc", "relation_name": "cms_synthetic.data_quality.lab_result_normalized_component"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.918703Z", "completed_at": "2024-10-22T19:20:31.922558Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.923171Z", "completed_at": "2024-10-22T19:20:31.923175Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00615382194519043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_CODE' AS field_name\n , case when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ms_drg_code is not null and term.ms_drg_code is null\n then 'MS DRG Code does not join to Terminology ms_drg table'\n else null end as invalid_reason\n , cast(m.ms_drg_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.ms_drg term on m.ms_drg_code = term.ms_drg_code", "relation_name": "cms_synthetic.data_quality.encounter_ms_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.923502Z", "completed_at": "2024-10-22T19:20:31.930843Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.931255Z", "completed_at": "2024-10-22T19:20:31.931261Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00925898551940918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_DESCRIPTION' as field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ndc_code is not null and term.ndc is null\n then 'NDC code type does not join to Terminology ndc table'\n else null end as invalid_reason\n , cast(substring(ndc_description, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join cms_synthetic.terminology.ndc term on m.ndc_code = term.ndc", "relation_name": "cms_synthetic.data_quality.medication_ndc_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.926858Z", "completed_at": "2024-10-22T19:20:31.934243Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.934786Z", "completed_at": "2024-10-22T19:20:31.934790Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011886119842529297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_CODE' AS field_name\n ,case when term.present_on_admit_code is not null then 'valid'\n when m.present_on_admit_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.present_on_admit_code is not null and term.present_on_admit_code is null\n then 'Present On Admit Code does not join to Terminology present_on_admission table'\n else null\n end as invalid_reason\n ,cast(m.present_on_admit_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join cms_synthetic.terminology.present_on_admission term on m.present_on_admit_code = term.present_on_admit_code", "relation_name": "cms_synthetic.data_quality.condition_present_on_admit_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.931604Z", "completed_at": "2024-10-22T19:20:31.935635Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.936351Z", "completed_at": "2024-10-22T19:20:31.936355Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005843162536621094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_attending_provider_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ATTENDING_PROVIDER_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.attending_provider_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.attending_provider_id is not null and term.npi is null\n then 'Attending provider ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(attending_provider_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.provider term on m.attending_provider_id = term.npi", "relation_name": "cms_synthetic.data_quality.encounter_attending_provider_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.936671Z", "completed_at": "2024-10-22T19:20:31.943326Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.944076Z", "completed_at": "2024-10-22T19:20:31.944081Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008949041366577148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_facility_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'FACILITY_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.facility_id is not null and term.npi is null\n then 'Facility NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(facility_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join cms_synthetic.terminology.provider term on m.facility_id = term.npi", "relation_name": "cms_synthetic.data_quality.encounter_facility_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.939811Z", "completed_at": "2024-10-22T19:20:31.943901Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.947522Z", "completed_at": "2024-10-22T19:20:31.947526Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011474847793579102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ORDERING_PRACTITIONER_ID' as field_name\n , case when term.npi is not null then 'valid'\n when m.ordering_practitioner_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ordering_practitioner_id is not null and term.npi is null\n then 'Ordering practitioner ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(ordering_practitioner_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join cms_synthetic.terminology.provider term on m.ordering_practitioner_id = term.npi", "relation_name": "cms_synthetic.data_quality.lab_result_ordering_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.944434Z", "completed_at": "2024-10-22T19:20:31.948718Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.949369Z", "completed_at": "2024-10-22T19:20:31.949372Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0063359737396240234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_npi", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.location m\nleft join cms_synthetic.terminology.provider term on m.npi = term.npi", "relation_name": "cms_synthetic.data_quality.location_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.950109Z", "completed_at": "2024-10-22T19:20:31.957485Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.960823Z", "completed_at": "2024-10-22T19:20:31.960827Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012369871139526367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_npi", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m\nleft join cms_synthetic.terminology.provider term on m.npi = term.npi", "relation_name": "cms_synthetic.data_quality.practitioner_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.953723Z", "completed_at": "2024-10-22T19:20:31.960619Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.961316Z", "completed_at": "2024-10-22T19:20:31.961320Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012447118759155273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_race", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'RACE' as field_name\n , case when term.description is not null then 'valid'\n when m.race is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.race is not null and term.description is null\n then 'Race description does not join to Terminology race table'\n else null end as invalid_reason\n , cast(race as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join cms_synthetic.terminology.race term on m.race = term.description", "relation_name": "cms_synthetic.data_quality.patient_race"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.957656Z", "completed_at": "2024-10-22T19:20:31.961630Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.962354Z", "completed_at": "2024-10-22T19:20:31.962358Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005511045455932617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_atc_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_CODE' as field_name\n , case when coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is not null then 'valid'\n when m.atc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.atc_code is not null and coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is null\n then 'ATC Code does not join to Terminology rxnorm_to_atc table on any atc level'\n else null end as invalid_reason\n , cast(atc_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join cms_synthetic.terminology.rxnorm_to_atc term_1 on m.atc_code = term_1.atc_1_name\nleft join cms_synthetic.terminology.rxnorm_to_atc term_2 on m.atc_code = term_2.atc_2_name\nleft join cms_synthetic.terminology.rxnorm_to_atc term_3 on m.atc_code = term_3.atc_3_name\nleft join cms_synthetic.terminology.rxnorm_to_atc term_4 on m.atc_code = term_4.atc_4_name", "relation_name": "cms_synthetic.data_quality.medication_atc_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.966679Z", "completed_at": "2024-10-22T19:20:31.974962Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.975452Z", "completed_at": "2024-10-22T19:20:31.975458Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012629270553588867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.condition_condition_id a\n inner JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_condition_condition_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.963941Z", "completed_at": "2024-10-22T19:20:31.975262Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.976033Z", "completed_at": "2024-10-22T19:20:31.976037Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013401985168457031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_CODE' as field_name\n , case when term.rxcui is not null then 'valid'\n when m.rxnorm_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.rxnorm_code is not null and term.rxcui is null\n then 'RX norm code does not join to Terminology rxnorm_to_atc table'\n else null end as invalid_reason\n , cast(rxnorm_code as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join cms_synthetic.terminology.rxnorm_to_atc term on m.rxnorm_code = term.rxcui", "relation_name": "cms_synthetic.data_quality.medication_rxnorm_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.971566Z", "completed_at": "2024-10-22T19:20:31.975827Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.976608Z", "completed_at": "2024-10-22T19:20:31.976611Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012920141220092773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__lab_result", "compiled": true, "compiled_code": "\n\n\n\n\nselect\n labs.lab_result_id\n , labs.patient_id\n , labs.encounter_id\n , labs.accession_number\n , labs.source_code_type\n , labs.source_code\n , labs.source_description\n , labs.source_component\n , case\n when labs.normalized_code_type is not null then labs.normalized_code_type\n when loinc.loinc is not null then 'loinc'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n labs.normalized_code\n , loinc.loinc\n , snomed_ct.snomed_ct\n ) as normalized_code\n , coalesce(\n labs.normalized_description\n , loinc.long_common_name\n , snomed_ct.description\n ) normalized_description\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , labs.normalized_component\n , labs.status\n , labs.result\n , labs.result_date\n , labs.collection_date\n , labs.source_units\n , labs.normalized_units\n , labs.source_reference_range_low\n , labs.source_reference_range_high\n , labs.normalized_reference_range_low\n , labs.normalized_reference_range_high\n , labs.source_abnormal_flag\n , labs.normalized_abnormal_flag\n , labs.specimen\n , labs.ordering_practitioner_id\n , labs.data_source\n , labs.tuva_last_run\nFrom cms_synthetic.dbt_tom.core__stg_clinical_lab_result as labs\nleft join cms_synthetic.terminology.loinc loinc\n on labs.source_code_type = 'loinc'\n and labs.source_code = loinc.loinc\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on labs.source_code_type = 'snomed-ct'\n and labs.source_code = snomed_ct.snomed_ct\n\n ", "relation_name": "cms_synthetic.core.lab_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.978592Z", "completed_at": "2024-10-22T19:20:31.988955Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.989653Z", "completed_at": "2024-10-22T19:20:31.989658Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01250004768371582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.lab_result_lab_result_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_lab_result_lab_result_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.982033Z", "completed_at": "2024-10-22T19:20:31.989410Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.990240Z", "completed_at": "2024-10-22T19:20:31.990243Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012560844421386719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.encounter_encounter_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_encounter_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.985627Z", "completed_at": "2024-10-22T19:20:31.990042Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:31.990834Z", "completed_at": "2024-10-22T19:20:31.990838Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01270914077758789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_location_location_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.location_location_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_location_location_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.992718Z", "completed_at": "2024-10-22T19:20:32.003511Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.003798Z", "completed_at": "2024-10-22T19:20:32.003803Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012459039688110352, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__medication", "compiled": true, "compiled_code": "\n\n\nwith source_mapping as (\n\n select\n meds.medication_id\n , meds.patient_id\n , meds.encounter_id\n , meds.dispensing_date\n , meds.prescribing_date\n , meds.source_code_type\n , meds.source_code\n , meds.source_description\n , coalesce(\n meds.ndc_code\n , ndc.ndc\n ) as ndc_code\n , coalesce(\n meds.ndc_description\n , ndc.fda_description\n , ndc.rxnorm_description\n ) as ndc_description\n , case\n when meds.ndc_code is not null then 'manual'\n when ndc.ndc is not null then 'automatic'\n end as ndc_mapping_method\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxcui\n ) as rxnorm_code\n , coalesce(\n meds.rxnorm_description\n , rxatc.rxnorm_description\n ) as rxnorm_description\n , case\n when meds.rxnorm_code is not null then 'manual'\n when rxatc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n meds.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n meds.atc_description\n , rxatc.atc_4_name\n ) as atc_description\n , case\n when meds.atc_code is not null then 'manual'\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , meds.route\n , meds.strength\n , meds.quantity\n , meds.quantity_unit\n , meds.days_supply\n , meds.practitioner_id\n , meds.data_source\n , meds.tuva_last_run\nfrom cms_synthetic.dbt_tom.core__stg_clinical_medication meds\n left join cms_synthetic.terminology.ndc ndc\n on meds.source_code_type = 'ndc'\n and meds.source_code = ndc.ndc\n left join cms_synthetic.terminology.rxnorm_to_atc rxatc\n on meds.source_code_type = 'rxnorm'\n and meds.source_code = rxatc.rxcui\n\n\n\n )\n\n\n-- add auto rxnorm + atc\nselect\n sm.medication_id\n , sm.patient_id\n , sm.encounter_id\n , sm.dispensing_date\n , sm.prescribing_date\n , sm.source_code_type\n , sm.source_code\n , sm.source_description\n , sm.ndc_code\n , sm.ndc_description\n , sm.ndc_mapping_method\n , coalesce(\n sm.rxnorm_code\n , ndc.rxcui\n ) as rxnorm_code\n , coalesce(\n sm.rxnorm_description\n , ndc.rxnorm_description\n ) as rxnorm_description\n , case\n when sm.rxnorm_mapping_method is not null then sm.rxnorm_mapping_method\n when ndc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n sm.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n sm.atc_description\n , rxatc.atc_3_name\n ) as atc_description\n , case\n when sm.atc_mapping_method is not null then sm.atc_mapping_method\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , sm.route\n , sm.strength\n , sm.quantity\n , sm.quantity_unit\n , sm.days_supply\n , sm.practitioner_id\n , sm.data_source\n , sm.tuva_last_run\nfrom source_mapping sm\n left join cms_synthetic.terminology.ndc ndc\n on sm.ndc_code = ndc.ndc\n left join cms_synthetic.terminology.rxnorm_to_atc rxatc\n on coalesce( sm.rxnorm_code, ndc.rxcui ) = rxatc.rxcui", "relation_name": "cms_synthetic.core.medication"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:31.996923Z", "completed_at": "2024-10-22T19:20:32.004189Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.005062Z", "completed_at": "2024-10-22T19:20:32.005065Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013232946395874023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.medication_medication_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_medication_medication_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.000185Z", "completed_at": "2024-10-22T19:20:32.004561Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.005403Z", "completed_at": "2024-10-22T19:20:32.005407Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013159036636352539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.patient_patient_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_patient_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.007247Z", "completed_at": "2024-10-22T19:20:32.019913Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.020324Z", "completed_at": "2024-10-22T19:20:32.020329Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014606952667236328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__observation", "compiled": true, "compiled_code": "\n\n\nselect\n obs.observation_id\n , obs.patient_id\n , obs.encounter_id\n , obs.panel_id\n , obs.observation_date\n , obs.observation_type\n , obs.source_code_type\n , obs.source_code\n , obs.source_description\n , case\n when obs.normalized_code_type is not null then obs.normalized_code_type\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n when loinc.loinc is not null then 'loinc'\n end as normalized_code_type\n , coalesce(\n obs.normalized_code\n , icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc\n ) as normalized_code\n , coalesce(\n obs.normalized_description\n , icd10cm.short_description\n , icd9cm.short_description\n , icd10pcs.description\n , icd9pcs.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , loinc.long_common_name\n ) as normalized_description\n , case\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\n when coalesce(\n icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc) is not null then 'automatic'\n end as mapping_method\n , obs.result\n , obs.source_units\n , obs.normalized_units\n , obs.source_reference_range_low\n , obs.source_reference_range_high\n , obs.normalized_reference_range_low\n , obs.normalized_reference_range_high\n , obs.data_source\n , obs.tuva_last_run\nfrom cms_synthetic.dbt_tom.core__stg_clinical_observation obs\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on obs.source_code_type = 'icd-10-cm'\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on obs.source_code_type = 'icd-9-cm'\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\nleft join cms_synthetic.terminology.icd_10_pcs icd10pcs\n on obs.source_code_type = 'icd-10-pcs'\n and obs.source_code = icd10pcs.icd_10_pcs\nleft join cms_synthetic.terminology.icd_9_pcs icd9pcs\n on obs.source_code_type = 'icd-9-pcs'\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\nleft join cms_synthetic.terminology.hcpcs_level_2 hcpcs\n on obs.source_code_type = 'hcpcs'\n and obs.source_code = hcpcs.hcpcs\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on obs.source_code_type = 'snomed-ct'\n and obs.source_code = snomed_ct.snomed_ct\nleft join cms_synthetic.terminology.loinc loinc\n on obs.source_code_type = 'loinc'\n and obs.source_code = loinc.loinc\n\n", "relation_name": "cms_synthetic.core.observation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.011797Z", "completed_at": "2024-10-22T19:20:32.020948Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.021701Z", "completed_at": "2024-10-22T19:20:32.021704Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0149688720703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.observation_observation_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_observation_observation_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.014943Z", "completed_at": "2024-10-22T19:20:32.021406Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.022312Z", "completed_at": "2024-10-22T19:20:32.022315Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015341043472290039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.practitioner_practitioner_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_practitioner_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.023602Z", "completed_at": "2024-10-22T19:20:32.030550Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.038437Z", "completed_at": "2024-10-22T19:20:32.038442Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016436100006103516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n cms_synthetic.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n cms_synthetic.data_quality.procedure_procedure_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "cms_synthetic.data_quality.primary_keys_procedure_procedure_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.027509Z", "completed_at": "2024-10-22T19:20:32.038905Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.039661Z", "completed_at": "2024-10-22T19:20:32.039666Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016364097595214844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_address", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'eligibility' as table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ADDRESS' AS field_name\n ,case when m.address is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(address as TEXT) AS field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_address"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.030765Z", "completed_at": "2024-10-22T19:20:32.039423Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.040298Z", "completed_at": "2024-10-22T19:20:32.040302Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013567924499511719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_birth_date", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n SELECT DISTINCT member_id\n ,cast(birth_date as TEXT) as field\n ,data_source\n FROM base\n),\nclaim_grain as (\n SELECT member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n GROUP BY member_id\n ,data_source\n),\nclaim_agg as (\nSELECT\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) AS field_aggregated\nFROM\n unique_field\nGROUP BY\n data_source,\n member_id\n)\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'BIRTH_DATE' AS field_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) THEN 'invalid'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'invalid'\n WHEN m.birth_date IS NULL THEN 'null'\n ELSE 'valid' \n END AS bucket_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) THEN 'future'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'too old'\n else null\n END AS invalid_reason\n,CAST(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) AS field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.eligibility_birth_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.041529Z", "completed_at": "2024-10-22T19:20:32.054763Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.056110Z", "completed_at": "2024-10-22T19:20:32.056118Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016141653060913086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_city", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'CITY' AS field_name\n ,case when m.race is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(city as TEXT) AS field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_city"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.045434Z", "completed_at": "2024-10-22T19:20:32.056842Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.057585Z", "completed_at": "2024-10-22T19:20:32.057589Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016318082809448242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_data_source", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.048443Z", "completed_at": "2024-10-22T19:20:32.057389Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.058138Z", "completed_at": "2024-10-22T19:20:32.058141Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013466835021972656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_date_checks", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n\n, missing_start_date as (\n select\n 'Missing enrollment_start_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is null\n),\n\nmissing_end_date as (\n select\n 'Missing enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is null\n),\n\ninvalid_start_date as (\n select\n 'Enrollment_start_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is not null\n and not try_cast( enrollment_start_date as date ) is not null\n),\n\ninvalid_end_date as (\n select\n 'Enrollment_end_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is not null\n and not try_cast( enrollment_end_date as date ) is not null\n),\n\nstart_after_end as (\n select\n 'Enrollment_start_date after enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date > enrollment_end_date\n),\n\nfuture_end_date as (\n select\n 'Future enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n \n where enrollment_end_date > current_date\n \n\n),\n\nnonsensical_dates as (\n select\n 'Nonsensical dates' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date < '1900-01-01'\n or enrollment_end_date < '1900-01-01'\n or enrollment_start_date > '2100-01-01'\n)\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_start_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_end_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_start_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_end_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from start_after_end\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from future_end_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from nonsensical_dates", "relation_name": "cms_synthetic.data_quality.eligibility_date_checks"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.058748Z", "completed_at": "2024-10-22T19:20:32.064553Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.076045Z", "completed_at": "2024-10-22T19:20:32.076051Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018994808197021484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_date", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n select distinct member_id\n ,cast(death_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by member_id\n ,data_source\n),\nclaim_agg as (\nselect\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n data_source,\n member_id\n)\nselect distinct\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date <= m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date <= m.birth_date then 'death date before birth date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.eligibility_death_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.069249Z", "completed_at": "2024-10-22T19:20:32.076958Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.077603Z", "completed_at": "2024-10-22T19:20:32.077606Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013716936111450195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_demographics", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n , birth_date\n , gender\n from tuva.input_layer.eligibility\n)\n\n, missing_birth_date as(\n select\n 'Missing birthday' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_birth_date as(\n select\n 'Birthday is not a valid date' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join reference_data.calendar c\n on e.birth_date = c.full_date\n where c.full_date is null\n)\n, future_birth_date as(\n select\n 'Birthday is in the future' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where birth_date > current_date\n \n)\n, past_birth_date as(\n select\n 'Birthday is too far in the past' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where cast(floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8760.0) as integer ) > 110\n \n\n)\n, multiple_birth_date as(\n select\n 'Patient has multiple birthdays' as data_quality_check\n , count(distinct patient_id) as result_count\n from(\n select\n patient_id\n , birth_date\n , rank() over (partition by patient_id, birth_date order by birth_date) as rank_birth_date\n from eligibility_spans e\n where birth_date is not null\n )x\nwhere rank_birth_date > 1\n)\n, missing_gender as(\n select\n 'Missing gender' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_gender as(\n select\n 'Patient gender does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from future_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from past_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from multiple_birth_date\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_gender\nunion all\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_gender", "relation_name": "cms_synthetic.data_quality.eligibility_demographics"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.064733Z", "completed_at": "2024-10-22T19:20:32.077167Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.078108Z", "completed_at": "2024-10-22T19:20:32.078112Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014538049697875977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_flag", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_FLAG' AS field_name\n ,case\n when m.death_flag in (1,0) then 'valid'\n when m.death_flag is null then 'null'\n else 'invalid'\n end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(death_flag as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_death_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.079133Z", "completed_at": "2024-10-22T19:20:32.082836Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.089152Z", "completed_at": "2024-10-22T19:20:32.089158Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011867761611938477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_dq_stage", "compiled": true, "compiled_code": "\n\nwith month_start_and_end_dates as (\n select\n year_month_int as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from cms_synthetic.reference_data.calendar\n group by year_month_int\n)\n\nselect distinct\n a.patient_id\n , b.year_month\n , b.month_start_date\n , b.month_end_date\n , a.payer\n , a.plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date", "relation_name": "cms_synthetic.data_quality.data_quality__eligibility_dq_stage"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.083065Z", "completed_at": "2024-10-22T19:20:32.090237Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.090877Z", "completed_at": "2024-10-22T19:20:32.090880Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00906991958618164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_dual_status_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DUAL_STATUS_CODE' AS field_name\n ,case when m.dual_status_code is null then 'null'\n when term.dual_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.dual_status_code is not null and term.dual_status_code is null then 'Dual Status Code does not join to Terminology Medicare Dual Eligibility table'\n else null\n end as invalid_reason\n , m.dual_status_code || '|' || coalesce(term.dual_status_description,'') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.medicare_dual_eligibility term on m.dual_status_code = term.dual_status_code", "relation_name": "cms_synthetic.data_quality.eligibility_dual_status_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.086374Z", "completed_at": "2024-10-22T19:20:32.090662Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.094201Z", "completed_at": "2024-10-22T19:20:32.094205Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012148857116699219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_end_date", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id,'NULL') AS drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_END_DATE' AS field_name\n ,case\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_end_date < m.enrollment_start_date then 'invalid'\n when m.enrollment_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.enrollment_end_date < m.enrollment_start_date then 'end date before start date'\n else null\n end as invalid_reason\n ,cast(enrollment_end_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.091360Z", "completed_at": "2024-10-22T19:20:32.095402Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.096044Z", "completed_at": "2024-10-22T19:20:32.096048Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006072044372558594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_first_name", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'FIRST_NAME' AS field_name\n ,case when m.first_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(first_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_first_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.096569Z", "completed_at": "2024-10-22T19:20:32.103025Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.103632Z", "completed_at": "2024-10-22T19:20:32.103637Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008517742156982422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_gender", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'GENDER' AS field_name\n ,case when m.gender is null then 'null'\n when term.gender is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.gender is not null and term.gender is null then 'Gender does not join to Terminology Gender table'\n else null\n end as invalid_reason\n ,cast(m.gender as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.gender term on m.gender = term.gender", "relation_name": "cms_synthetic.data_quality.eligibility_gender"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.099853Z", "completed_at": "2024-10-22T19:20:32.103461Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.108536Z", "completed_at": "2024-10-22T19:20:32.108542Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012996196746826172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_last_name", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'LAST_NAME' AS field_name\n ,case when m.last_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(last_name as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_last_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.103994Z", "completed_at": "2024-10-22T19:20:32.110924Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.111827Z", "completed_at": "2024-10-22T19:20:32.111833Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009154796600341797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEDICARE_STATUS_CODE' AS field_name\n ,case when m.medicare_status_code is null then 'null'\n when term.medicare_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.medicare_status_code is not null and term.medicare_status_code is null then 'Medicare Status Code does not join to Terminology Medicare Status table'\n else null\n end as invalid_reason\n , m.medicare_status_code || '|' || coalesce(term.medicare_status_description,'') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.medicare_status term on m.medicare_status_code = term.medicare_status_code", "relation_name": "cms_synthetic.data_quality.eligibility_medicare_status_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.113151Z", "completed_at": "2024-10-22T19:20:32.124293Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.125085Z", "completed_at": "2024-10-22T19:20:32.125097Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014033317565917969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_member_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_member_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.116677Z", "completed_at": "2024-10-22T19:20:32.124772Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.125521Z", "completed_at": "2024-10-22T19:20:32.125524Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014191150665283203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n from tuva.input_layer.eligibility\n)\n\nselect\n 'Missing patient_id' as data_quality_check\n ,count(*) as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom eligibility_spans\nwhere\n patient_id is null or patient_id = ''", "relation_name": "cms_synthetic.data_quality.eligibility_missing_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.120164Z", "completed_at": "2024-10-22T19:20:32.125935Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.126665Z", "completed_at": "2024-10-22T19:20:32.126668Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007177829742431641, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_payer", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , payer\n , payer_type\n from tuva.input_layer.eligibility\n)\n\n, missing_payer_type as(\n select\n 'Missing payer type' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer_type is null\n)\n, missing_payer_name as(\n select\n 'Missing payer name' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer is null\n)\n, invalid_payer_type as(\n select\n 'Payer type does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join cms_synthetic.terminology.payer_type pt\n on e.payer_type = pt.payer_type\n where pt.payer_type is null\n)\n\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_payer_type\nunion all\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from missing_payer_name\nunion all\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from invalid_payer_type", "relation_name": "cms_synthetic.data_quality.eligibility_missing_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.128551Z", "completed_at": "2024-10-22T19:20:32.137897Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.138235Z", "completed_at": "2024-10-22T19:20:32.138241Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011290788650512695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ORIGINAL_REASON_ENTITLEMENT_CODE' AS field_name\n ,case when m.original_reason_entitlement_code is null then 'null'\n when term.original_reason_entitlement_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.original_reason_entitlement_code is not null and term.original_reason_entitlement_code is null then 'Original Reason Entitlement Code does not join to Terminology Original Reason Entitlement Code table'\n else null\n end as invalid_reason\n , m.original_reason_entitlement_code || '|' || coalesce(term.original_reason_entitlement_description,'') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.medicare_orec term on m.original_reason_entitlement_code = term.original_reason_entitlement_code", "relation_name": "cms_synthetic.data_quality.eligibility_original_reason_entitlement_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.131578Z", "completed_at": "2024-10-22T19:20:32.139045Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.139551Z", "completed_at": "2024-10-22T19:20:32.139555Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012212991714477539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_patient_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.134786Z", "completed_at": "2024-10-22T19:20:32.139871Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.140529Z", "completed_at": "2024-10-22T19:20:32.140533Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012261152267456055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.140882Z", "completed_at": "2024-10-22T19:20:32.145131Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.150376Z", "completed_at": "2024-10-22T19:20:32.150382Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011154890060424805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer_type", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER_TYPE' AS field_name\n ,case when m.payer_type is null then 'null'\n when term.payer_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.payer_type is not null and term.payer_type is null then 'Payer Type does not join to Terminology Payer Type table'\n else null\n end as invalid_reason\n ,cast(m.payer_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.payer_type term on m.payer_type = term.payer_type", "relation_name": "cms_synthetic.data_quality.eligibility_payer_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.145379Z", "completed_at": "2024-10-22T19:20:32.151038Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.155262Z", "completed_at": "2024-10-22T19:20:32.155267Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011358022689819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_phone", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PHONE' AS field_name\n ,case when m.phone is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(phone as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_phone"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.151413Z", "completed_at": "2024-10-22T19:20:32.156426Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.157083Z", "completed_at": "2024-10-22T19:20:32.157087Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012239217758178711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_plan", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(m.plan as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.157417Z", "completed_at": "2024-10-22T19:20:32.164951Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.165426Z", "completed_at": "2024-10-22T19:20:32.165431Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009587287902832031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_race", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'RACE' AS field_name\n ,case when m.race is null then 'null'\n when r.description is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.race is not null and r.description is null then 'Race does not join to terminology race table'\n else null\n end as invalid_reason\n ,cast(race as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.terminology.race r on m.race=r.description", "relation_name": "cms_synthetic.data_quality.eligibility_race"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.160832Z", "completed_at": "2024-10-22T19:20:32.165799Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.169378Z", "completed_at": "2024-10-22T19:20:32.169383Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012605905532836914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_start_date", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_START_DATE' AS field_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n ,cast(enrollment_start_date as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.165981Z", "completed_at": "2024-10-22T19:20:32.170470Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.176083Z", "completed_at": "2024-10-22T19:20:32.176089Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011437177658081055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_state", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'STATE' AS field_name\n ,case when m.state is null then 'null'\n when term.ssa_fips_state_name is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.state is not null and term.ssa_fips_state_name is null then 'State does not join to Terminology SSA_FIPS_STATE table'\n else null\n end as invalid_reason\n ,cast(state as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join cms_synthetic.reference_data.ssa_fips_state as term on m.state = term.ssa_fips_state_name", "relation_name": "cms_synthetic.data_quality.eligibility_state"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.170950Z", "completed_at": "2024-10-22T19:20:32.180160Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.180693Z", "completed_at": "2024-10-22T19:20:32.180697Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010951995849609375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_trend", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n, month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from cms_synthetic.reference_data.calendar\n group by year, month, year_month\n)\n, member_months as (\n select distinct\n eligibility_span_id\n , year_month\n from eligibility_spans es\n inner join month_start_and_end_dates d\n on es.enrollment_start_date <= d.month_end_date\n and es.enrollment_end_date >= d.month_start_date\n)\n\n\nselect\n year_month\n , count(distinct eligibility_span_id) as member_months\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom member_months\ngroup by\n year_month", "relation_name": "cms_synthetic.data_quality.eligibility_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.177061Z", "completed_at": "2024-10-22T19:20:32.181528Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.184133Z", "completed_at": "2024-10-22T19:20:32.184139Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013482093811035156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_zip_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ZIP_CODE' AS field_name\n \n ,case when m.zip_code is null then 'null'\n when length(m.zip_code) in (5,9,10) then 'valid'\n else 'invalid' end as bucket_name\n ,case\n when m.zip_code is not null and length(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\n else null\n end as invalid_reason\n \n ,cast(zip_code as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "cms_synthetic.data_quality.eligibility_zip_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.190107Z", "completed_at": "2024-10-22T19:20:32.199561Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.200386Z", "completed_at": "2024-10-22T19:20:32.200391Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01172184944152832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_allowed_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.196216Z", "completed_at": "2024-10-22T19:20:32.201500Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.206407Z", "completed_at": "2024-10-22T19:20:32.206413Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01689910888671875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when paid_date is null then 1 else 0 end) as missing_paid_date\n , max(case when dispensing_date is null then 1 else 0 end) as missing_dispensing_date\n from tuva.input_layer.pharmacy_claim\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing pharmacy_claim paid_date' as data_quality_check\n , sum(missing_paid_date) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing dispensing_date' as data_quality_check\n , sum(missing_dispensing_date) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_date_checks"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.202555Z", "completed_at": "2024-10-22T19:20:32.207588Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.208369Z", "completed_at": "2024-10-22T19:20:32.208373Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008709192276000977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_ID' AS field_name\n , case\n when m.claim_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.209025Z", "completed_at": "2024-10-22T19:20:32.216448Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.217111Z", "completed_at": "2024-10-22T19:20:32.217116Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010143041610717773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_LINE_NUMBER' AS field_name\n , case\n when m.claim_line_number is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_line_number"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.213624Z", "completed_at": "2024-10-22T19:20:32.220887Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.221536Z", "completed_at": "2024-10-22T19:20:32.221541Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012834787368774414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when term.ndc is null and m.ndc_code is not null then 1 else 0 end) as invalid_ndc\n , max(case when m.ndc_code is null then 1 else 0 end) as missing_ndc\n from tuva.input_layer.pharmacy_claim m\n left join cms_synthetic.terminology.ndc as term\n on m.ndc_code = term.ndc\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing ndc' as data_quality_check\n , sum(missing_ndc) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'invalid ndc' as data_quality_check\n , sum(invalid_ndc) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_ndc"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.217553Z", "completed_at": "2024-10-22T19:20:32.222472Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.223154Z", "completed_at": "2024-10-22T19:20:32.223158Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00988316535949707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_npi", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.prescribing_provider_npi is not null then 1 else 0 end) as invalid_prescribing_npi\n , max(case when m.prescribing_provider_npi is null then 1 else 0 end) as missing_prescribing_npi\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_prescribing_npi\n , max(case when term2.npi is null and m.dispensing_provider_npi is not null then 1 else 0 end) as invalid_dispensing_npi\n , max(case when m.dispensing_provider_npi is null then 1 else 0 end) as missing_dispensing_npi\n , max(case when term2.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_dispensing_npi\n from tuva.input_layer.pharmacy_claim as m\n left join cms_synthetic.terminology.provider as term\n on m.prescribing_provider_npi = term.npi\n left join cms_synthetic.terminology.provider as term2\n on m.dispensing_provider_npi = term2.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid prescribing_npi' as data_quality_check\n , sum(invalid_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing prescribing_npi' as data_quality_check\n , sum(missing_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type prescribing_npi' as data_quality_check\n , sum(wrong_entity_type_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'invalid dispensing_npi' as data_quality_check\n , sum(invalid_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing dispensing_npi' as data_quality_check\n , sum(missing_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type dispensing_npi' as data_quality_check\n , sum(wrong_entity_type_dispensing_npi) as result_count\nfrom pharmacy_claim\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.223485Z", "completed_at": "2024-10-22T19:20:32.230097Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.230689Z", "completed_at": "2024-10-22T19:20:32.230695Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008769035339355469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case \n when quantity is null then 1\n when quantity = 0 then 1\n else 0\n end) as missing_quantity\n , max(case \n when days_supply is null then 1\n when days_supply = 0 then 1\n else 0\n end) as missing_days_supply\n , max(case \n when refills is null then 1\n else 0\n end) as missing_refills\n from tuva.input_layer.pharmacy_claim m\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing quantity' as data_quality_check\n , sum(missing_quantity) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing days supply' as data_quality_check\n , sum(missing_days_supply) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing refills' as data_quality_check\n , sum(missing_refills) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_prescription_details"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.226984Z", "completed_at": "2024-10-22T19:20:32.231051Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.238350Z", "completed_at": "2024-10-22T19:20:32.238356Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015561819076538086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "compiled": true, "compiled_code": "\n\nselect\n c.year_month_int as year_month\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim p\nleft join cms_synthetic.reference_data.calendar c\n on coalesce(p.paid_date, p.dispensing_date) = c.full_date\ngroup by\n c.year_month_int", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_volume_and_dollars"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.231247Z", "completed_at": "2024-10-22T19:20:32.240081Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.240745Z", "completed_at": "2024-10-22T19:20:32.240750Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01096034049987793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_coinsurance_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.241126Z", "completed_at": "2024-10-22T19:20:32.312450Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.313302Z", "completed_at": "2024-10-22T19:20:32.313308Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.07405424118041992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_copayment_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.308061Z", "completed_at": "2024-10-22T19:20:32.313911Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.318652Z", "completed_at": "2024-10-22T19:20:32.318658Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07823705673217773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_data_source", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DATA_SOURCE' AS field_name\n , case\n when m.data_source is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.314875Z", "completed_at": "2024-10-22T19:20:32.320053Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.324272Z", "completed_at": "2024-10-22T19:20:32.324279Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011600017547607422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_days_supply", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DAYS_SUPPLY' AS field_name\n , case\n when m.days_supply is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_days_supply"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.320794Z", "completed_at": "2024-10-22T19:20:32.330030Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.330630Z", "completed_at": "2024-10-22T19:20:32.330635Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011626005172729492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_deductible_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.325319Z", "completed_at": "2024-10-22T19:20:32.331232Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.335926Z", "completed_at": "2024-10-22T19:20:32.335932Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015535831451416016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_DATE' AS field_name\n , case\n when m.dispensing_date > tuva_last_run then 'invalid'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > tuva_last_run then 'future'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.pharmacy_dispensing_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.331819Z", "completed_at": "2024-10-22T19:20:32.339702Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.344366Z", "completed_at": "2024-10-22T19:20:32.344371Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014191150665283203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.dispensing_provider_npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.dispensing_provider_npi is not null\n and term.npi is null\n then 'dispensing provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n , cast(m.dispensing_provider_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join cms_synthetic.terminology.provider as term on m.dispensing_provider_npi = term.npi", "relation_name": "cms_synthetic.data_quality.pharmacy_dispensing_provider_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.339947Z", "completed_at": "2024-10-22T19:20:32.349322Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.349955Z", "completed_at": "2024-10-22T19:20:32.349960Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01155996322631836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_member_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'MEMBER_ID' AS field_name\n , case\n when m.member_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_member_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.344790Z", "completed_at": "2024-10-22T19:20:32.350544Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.354581Z", "completed_at": "2024-10-22T19:20:32.354586Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015134811401367188, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_ndc_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'NDC_CODE' AS field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.ndc_code is not null\n and term.ndc is null\n then 'NDC Code does not join to Terminology NDC table'\n else null\n end as invalid_reason\n , m.ndc_code || '|' || coalesce(term.rxnorm_description, term.fda_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join cms_synthetic.terminology.ndc as term on m.ndc_code = term.ndc", "relation_name": "cms_synthetic.data_quality.pharmacy_ndc_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.350979Z", "completed_at": "2024-10-22T19:20:32.355726Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.360389Z", "completed_at": "2024-10-22T19:20:32.360395Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010842084884643555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_paid_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.356157Z", "completed_at": "2024-10-22T19:20:32.364844Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.365355Z", "completed_at": "2024-10-22T19:20:32.365360Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010455846786499023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_date", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(paid_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.pharmacy_paid_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.361402Z", "completed_at": "2024-10-22T19:20:32.366147Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.370731Z", "completed_at": "2024-10-22T19:20:32.370736Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014880895614624023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_patient_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PATIENT_ID' AS field_name\n , case\n when m.patient_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.366351Z", "completed_at": "2024-10-22T19:20:32.371666Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.375680Z", "completed_at": "2024-10-22T19:20:32.375686Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010672807693481445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_payer", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAYER' AS field_name\n , case\n when m.payer is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(payer as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.371859Z", "completed_at": "2024-10-22T19:20:32.380323Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.380828Z", "completed_at": "2024-10-22T19:20:32.380833Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010421037673950195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_plan", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PLAN' AS field_name\n , case\n when m.plan is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(plan as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.376744Z", "completed_at": "2024-10-22T19:20:32.381719Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.388291Z", "completed_at": "2024-10-22T19:20:32.388297Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012926816940307617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PRESCRIBING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.prescribing_provider_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.prescribing_provider_npi is not null\n and term.npi is null\n then 'Prescribing Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.prescribing_provider_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join cms_synthetic.terminology.provider as term on m.prescribing_provider_npi = term.npi", "relation_name": "cms_synthetic.data_quality.pharmacy_prescribing_provider_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.381907Z", "completed_at": "2024-10-22T19:20:32.389261Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.393650Z", "completed_at": "2024-10-22T19:20:32.393655Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013167858123779297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_quantity", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.quantity is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_quantity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.389522Z", "completed_at": "2024-10-22T19:20:32.395133Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.398428Z", "completed_at": "2024-10-22T19:20:32.398433Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010500192642211914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_refills", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'REFILLS' AS field_name\n , case\n when m.refills is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(refills as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "cms_synthetic.data_quality.pharmacy_refills"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.404011Z", "completed_at": "2024-10-22T19:20:32.412328Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.412865Z", "completed_at": "2024-10-22T19:20:32.412869Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010436058044433594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_allowed_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_allowed_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.408751Z", "completed_at": "2024-10-22T19:20:32.413652Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.417159Z", "completed_at": "2024-10-22T19:20:32.417165Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013441085815429688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_charge_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_charge_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.413918Z", "completed_at": "2024-10-22T19:20:32.422482Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.423023Z", "completed_at": "2024-10-22T19:20:32.423027Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01055002212524414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_ID' AS field_name\n ,case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.418130Z", "completed_at": "2024-10-22T19:20:32.423776Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.428329Z", "completed_at": "2024-10-22T19:20:32.428334Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011476993560791016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_end_date", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_END_DATE' AS field_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'invalid'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_end_date > m.claim_line_end_date then 'invalid'\n when m.claim_line_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'future'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_end_date > m.claim_end_date then 'line date greater than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_end_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.claim_claim_line_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.424041Z", "completed_at": "2024-10-22T19:20:32.429160Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.434206Z", "completed_at": "2024-10-22T19:20:32.434212Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011553049087524414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_number", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_LINE_NUMBER' AS field_name\n ,case when m.claim_line_number is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_claim_line_number"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.429400Z", "completed_at": "2024-10-22T19:20:32.435200Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.438572Z", "completed_at": "2024-10-22T19:20:32.438577Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010541200637817383, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_start_date", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_START_DATE' AS field_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'invalid'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_start_date < m.claim_start_date then 'invalid'\n when m.claim_line_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'future'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_start_date < m.claim_start_date then 'line date less than than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.claim_claim_line_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.435450Z", "completed_at": "2024-10-22T19:20:32.439539Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.443662Z", "completed_at": "2024-10-22T19:20:32.443667Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009803056716918945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_type", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_TYPE' AS field_name\n ,case when m.claim_type is null then 'null'\n when term.claim_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.claim_type is not null and term.claim_type is null then 'Claim Type does not join to Terminology Claim Type table'\n else null\n end as invalid_reason\n ,cast(m.claim_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join cms_synthetic.terminology.claim_type term on m.claim_type = term.claim_type", "relation_name": "cms_synthetic.data_quality.claim_claim_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.439738Z", "completed_at": "2024-10-22T19:20:32.444577Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.448419Z", "completed_at": "2024-10-22T19:20:32.448424Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010146856307983398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_coinsurance_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_coninsurance_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.444792Z", "completed_at": "2024-10-22T19:20:32.449362Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.453691Z", "completed_at": "2024-10-22T19:20:32.453698Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010357856750488281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_copayment_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_copayment_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.449533Z", "completed_at": "2024-10-22T19:20:32.460565Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.470804Z", "completed_at": "2024-10-22T19:20:32.470810Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02275872230529785, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_data_source", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.454889Z", "completed_at": "2024-10-22T19:20:32.475378Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.476124Z", "completed_at": "2024-10-22T19:20:32.476128Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02280116081237793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_date_trends", "compiled": true, "compiled_code": "\n\nwith date_stage as(\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_start_date' as date_field\n , cast(date_part('year', claim_start_date) as TEXT) as year\n , cast(date_part('month', claim_start_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_start_date) as TEXT)\n , cast(date_part('month', claim_start_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_end_date' as date_field\n , cast(date_part('year', claim_end_date) as TEXT) as year\n , cast(date_part('month', claim_end_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_end_date) as TEXT)\n , cast(date_part('month', claim_end_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'admission_date' as date_field\n , cast(date_part('year', admission_date) as TEXT) as year\n , cast(date_part('month', admission_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', admission_date) as TEXT)\n , cast(date_part('month', admission_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'discharge_date' as date_field\n , cast(date_part('year', discharge_date) as TEXT) as year\n , cast(date_part('month', discharge_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', discharge_date) as TEXT)\n , cast(date_part('month', discharge_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'medical paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'dispensing_date' as date_field\n , cast(date_part('year', dispensing_date) as TEXT) as year\n , cast(date_part('month', dispensing_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', dispensing_date) as TEXT)\n , cast(date_part('month', dispensing_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'pharmacy paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n)\n\n\n, all_date_range as (\n select distinct\n replace(cal.year_month,'-','') as year_month\n from cms_synthetic.reference_data.calendar cal\n where (cal.year_month >= (select min(year_month) from date_stage)\n and cal.year_month <= (select max(year_month) from date_stage))\n\n)\n\nselect\n cast(all_date.year_month as integer ) as year_month\n , claim_start.result_count as claim_start_date\n , claim_end.result_count as claim_end_date\n , admission_date.result_count as admission_date\n , discharge_date.result_count as discharge_date\n , med_paid_date.result_count as medical_paid_date\n , dispensing_date.result_count as dispensing_date\n , pharm_paid_date.result_count as pharmacy_paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom all_date_range all_date\nleft join date_stage claim_start\n on all_date.year_month = claim_start.year_month\n and claim_start.date_field = 'claim_start_date'\nleft join date_stage claim_end\n on all_date.year_month = claim_end.year_month\n and claim_end.date_field = 'claim_end_date'\nleft join date_stage admission_date\n on all_date.year_month = admission_date.year_month\n and admission_date.date_field = 'admission_date'\nleft join date_stage discharge_date\n on all_date.year_month = discharge_date.year_month\n and discharge_date.date_field = 'discharge_date'\nleft join date_stage med_paid_date\n on all_date.year_month = med_paid_date.year_month\n and med_paid_date.date_field = 'medical paid_date'\nleft join date_stage dispensing_date\n on all_date.year_month = dispensing_date.year_month\n and dispensing_date.date_field = 'dispensing_date'\nleft join date_stage pharm_paid_date\n on all_date.year_month = pharm_paid_date.year_month\n and pharm_paid_date.date_field = 'pharmacy paid_date'", "relation_name": "cms_synthetic.data_quality.claim_date_trends"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.471909Z", "completed_at": "2024-10-22T19:20:32.476942Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.480513Z", "completed_at": "2024-10-22T19:20:32.480517Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019670963287353516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_deductible_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_deductible_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.477489Z", "completed_at": "2024-10-22T19:20:32.481406Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.485638Z", "completed_at": "2024-10-22T19:20:32.485644Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009986162185668945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DIAGNOSIS_CODE_TYPE' AS field_name\n ,case when m.diagnosis_code_type is null then 'null'\n when term.code_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.diagnosis_code_type is not null and term.code_type is null then 'Diagnosis Code Type does not join to Terminology Code Type table'\n else null\n end as invalid_reason\n ,cast(m.diagnosis_code_type as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join cms_synthetic.reference_data.code_type term on m.diagnosis_code_type = term.code_type", "relation_name": "cms_synthetic.data_quality.claim_diagnosis_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.481583Z", "completed_at": "2024-10-22T19:20:32.486730Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.490026Z", "completed_at": "2024-10-22T19:20:32.490031Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009905099868774414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_hcpcs_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'HCPCS_CODE' AS field_name\n , case\n when term.hcpcs is not null then 'valid'\n when m.hcpcs_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.hcpcs_code is not null and term.hcpcs is null then 'HCPCS does not join to Terminology HCPCS_LEVEL_2 table'\n else null\n end as invalid_reason\n , m.hcpcs_code || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join cms_synthetic.terminology.hcpcs_level_2 as term on m.hcpcs_code = term.hcpcs", "relation_name": "cms_synthetic.data_quality.claim_hcpcs_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.486970Z", "completed_at": "2024-10-22T19:20:32.491045Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.495084Z", "completed_at": "2024-10-22T19:20:32.495089Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009774208068847656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_member_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_member_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.491244Z", "completed_at": "2024-10-22T19:20:32.500441Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.501015Z", "completed_at": "2024-10-22T19:20:32.501041Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011384963989257812, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_paid_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_paid_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.495956Z", "completed_at": "2024-10-22T19:20:32.502298Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.507858Z", "completed_at": "2024-10-22T19:20:32.507864Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013142108917236328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_paid_date", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date < m.claim_start_date then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.paid_date < m.claim_start_date then 'paid date before claim start date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.claim_paid_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.502832Z", "completed_at": "2024-10-22T19:20:32.509075Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.510283Z", "completed_at": "2024-10-22T19:20:32.510289Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00962686538696289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_patient_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.510654Z", "completed_at": "2024-10-22T19:20:32.517052Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.517493Z", "completed_at": "2024-10-22T19:20:32.517498Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00929713249206543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_payer", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.514639Z", "completed_at": "2024-10-22T19:20:32.520761Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.521308Z", "completed_at": "2024-10-22T19:20:32.521312Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011580228805541992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_percent", "compiled": true, "compiled_code": "\n\n\nwith cte as \n(\nselect sum(paid_amount) as paid_amount\n,claim_type\nfrom tuva.input_layer.medical_claim\ngroup by claim_type\n\nunion all\n\nselect sum(paid_amount) as paid_amount\n,'pharmacy' as claim_type\nfrom tuva.input_layer.pharmacy_claim\n)\n\n,total_cte as \n(\nselect sum(paid_amount) as total_paid_amount\nfrom cte\n)\n\nselect claim_type\n,paid_amount/total_paid_amount as percent_of_total_paid\nfrom cte\ncross join total_cte", "relation_name": "cms_synthetic.data_quality.data_quality_claim_percent"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.517831Z", "completed_at": "2024-10-22T19:20:32.522048Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.522696Z", "completed_at": "2024-10-22T19:20:32.522699Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00600886344909668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_plan", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(plan as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.523228Z", "completed_at": "2024-10-22T19:20:32.529874Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.530353Z", "completed_at": "2024-10-22T19:20:32.530357Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008578777313232422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_total_cost_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'TOTAL_COST_AMOUNT' AS field_name\n , case when m.total_cost_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(total_cost_amount as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.claim_total_cost_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.527248Z", "completed_at": "2024-10-22T19:20:32.541395Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.554743Z", "completed_at": "2024-10-22T19:20:32.554748Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03179001808166504, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_type_summary", "compiled": true, "compiled_code": "select\n data_source\n ,claim_type\n ,count(distinct claim_id) as claim_count\n ,sum(paid_amount) as paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim\ngroup by\n data_source\n ,claim_type\n\n", "relation_name": "cms_synthetic.data_quality.claim_type_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.556605Z", "completed_at": "2024-10-22T19:20:32.565708Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.566204Z", "completed_at": "2024-10-22T19:20:32.566209Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010947942733764648, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__inpatient_dq_stage", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from tuva.input_layer.medical_claim as mc\n left join cms_synthetic.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join cms_synthetic.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n )\n)\n\nselect distinct\n a.claim_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "relation_name": "cms_synthetic.data_quality.data_quality__inpatient_dq_stage"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.561524Z", "completed_at": "2024-10-22T19:20:32.565992Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.566652Z", "completed_at": "2024-10-22T19:20:32.566656Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010401010513305664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_bill_type_code", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.bill_type_code || '|' || coalesce(term.bill_type_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.bill_type as term on base.bill_type_code = term.bill_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'BILL_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.bill_type_code is not null then 'valid'\n when m.bill_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.bill_type_code is not null\n and term.bill_type_code is null\n and cg.frequency = 1\n then 'Bill Type Code does not join to Terminology Bill_Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.bill_type as term on m.bill_type_code = term.bill_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_bill_type_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.572373Z", "completed_at": "2024-10-22T19:20:32.577920Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.578339Z", "completed_at": "2024-10-22T19:20:32.578343Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010127067565917969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_end_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before claim start date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_claim_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.568930Z", "completed_at": "2024-10-22T19:20:32.578113Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.578775Z", "completed_at": "2024-10-22T19:20:32.578778Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010786056518554688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_billing_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(billing_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'BILLING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.billing_npi is not null\n and term.npi is null\n then 'NPI is not in Terminology Provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.provider as term on m.billing_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_billing_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.580783Z", "completed_at": "2024-10-22T19:20:32.592494Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.592974Z", "completed_at": "2024-10-22T19:20:32.592979Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013402938842773438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_start_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_claim_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.586985Z", "completed_at": "2024-10-22T19:20:32.593320Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.594301Z", "completed_at": "2024-10-22T19:20:32.594306Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014297962188720703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_cm as term on base.diagnosis_code_1 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_diagnosis_code_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.595638Z", "completed_at": "2024-10-22T19:20:32.605392Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.605693Z", "completed_at": "2024-10-22T19:20:32.605699Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011107683181762695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_cm as term on base.diagnosis_code_2 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_diagnosis_code_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.599859Z", "completed_at": "2024-10-22T19:20:32.606817Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.607463Z", "completed_at": "2024-10-22T19:20:32.607467Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012094974517822266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_cm as term on base.diagnosis_code_3 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_diagnosis_code_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.608284Z", "completed_at": "2024-10-22T19:20:32.616693Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.617085Z", "completed_at": "2024-10-22T19:20:32.617090Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010050058364868164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.discharge_disposition_code || '|' || coalesce(term.discharge_disposition_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.discharge_disposition as term on base.discharge_disposition_code = term.discharge_disposition_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.discharge_disposition_code is not null\n and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology Discharge_Disposition Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.discharge_disposition as term on m.discharge_disposition_code = term.discharge_disposition_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_discharge_disposition_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.613146Z", "completed_at": "2024-10-22T19:20:32.617766Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.618425Z", "completed_at": "2024-10-22T19:20:32.618429Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006038188934326172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_facility_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'FACILITY_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.facility_npi is not null\n and term.npi is null\n then 'NPI not in Terminology Provider Table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.provider as term on m.facility_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_facility_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.619777Z", "completed_at": "2024-10-22T19:20:32.627129Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.627388Z", "completed_at": "2024-10-22T19:20:32.627394Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008672952651977539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_1' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_1 in ('y','n') then 'valid'\n when m.diagnosis_poa_1 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_present_on_admission_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.623829Z", "completed_at": "2024-10-22T19:20:32.627822Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.628361Z", "completed_at": "2024-10-22T19:20:32.628365Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00887608528137207, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_2' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_2 in ('y','n') then 'valid'\n when m.diagnosis_poa_2 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_present_on_admission_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.629716Z", "completed_at": "2024-10-22T19:20:32.637285Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.637530Z", "completed_at": "2024-10-22T19:20:32.637535Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008827924728393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_3' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_3 in ('y','n') then 'valid'\n when m.diagnosis_poa_3 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_present_on_admission_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.633648Z", "completed_at": "2024-10-22T19:20:32.638228Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.638818Z", "completed_at": "2024-10-22T19:20:32.638822Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009366035461425781, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_rendering_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'RENDERING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.rendering_npi is not null\n and term.npi is null\n then 'provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.provider as term on m.rendering_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_rendering_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.639622Z", "completed_at": "2024-10-22T19:20:32.649210Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.649465Z", "completed_at": "2024-10-22T19:20:32.649469Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010996341705322266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_revenue_center_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'institutional' AS claim_type\n , 'REVENUE_CENTER_CODE' AS field_name\n , case\n when term.revenue_center_code is not null then 'valid'\n when m.revenue_center_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.revenue_center_code is not null\n and term.revenue_center_code is null\n then 'Revenue center code does not join to Terminology Revenue Center table'\n else null\n end as invalid_reason\n , m.revenue_center_code || '|' || coalesce(term.revenue_center_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join cms_synthetic.terminology.revenue_center as term on m.revenue_center_code = term.revenue_center_code", "relation_name": "cms_synthetic.data_quality.institutional_revenue_center_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.645290Z", "completed_at": "2024-10-22T19:20:32.649808Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.650277Z", "completed_at": "2024-10-22T19:20:32.650280Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005666255950927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'service_unit_quantity' as field_name\n , case when m.service_unit_quantity is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(service_unit_quantity as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "cms_synthetic.data_quality.institutional_service_unit_quantity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.651576Z", "completed_at": "2024-10-22T19:20:32.657869Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.658083Z", "completed_at": "2024-10-22T19:20:32.658088Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0075609683990478516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when hcpc.hcpcs is null and m.hcpcs_code is not null then 1 else 0 end) as invalid_hcpcs_code\n , max(case when m.claim_type = 'professional' and pos.place_of_service_code is null and m.place_of_service_code is not null then 1 else 0 end) as invalid_place_of_service_code\n , max(case when m.claim_type = 'institutional' and rev.revenue_center_code is null and m.revenue_center_code is not null then 1 else 0 end) as invalid_revenue_center_code\n , max(case when m.hcpcs_code is null then 1 else 0 end) as missing_hcpcs_code\n , max(case when m.claim_type = 'professional' and m.place_of_service_code is null then 1 else 0 end) as missing_place_of_service_code\n , max(case when m.claim_type = 'institutional' and m.revenue_center_code is null then 1 else 0 end) as missing_revenue_center_code\n from tuva.input_layer.medical_claim as m\n left join cms_synthetic.terminology.hcpcs_level_2 as hcpc\n on m.hcpcs_code = hcpc.hcpcs\n left join cms_synthetic.terminology.place_of_service as pos\n on m.place_of_service_code = pos.place_of_service_code\n left join cms_synthetic.terminology.revenue_center as rev\n on m.revenue_center_code = rev.revenue_center_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid hcpcs_code' as data_quality_check\n , sum(invalid_hcpcs_code) as result_count\n from medical_claim\n \n union all\n\n select\n 'invalid place_of_service_code' as data_quality_check\n , sum(invalid_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'invalid revenue_center_code' as data_quality_check\n , sum(invalid_revenue_center_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing hcpcs_code' as data_quality_check\n , sum(missing_hcpcs_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing place_of_service_code' as data_quality_check\n , sum(missing_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing revenue_center_code' as data_quality_check\n , sum(missing_revenue_center_code) as result_count\n from medical_claim\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.medical_claim_claim_line_fields"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.654911Z", "completed_at": "2024-10-22T19:20:32.658747Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.659233Z", "completed_at": "2024-10-22T19:20:32.659237Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007964134216308594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_provider_npi", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.rendering_npi is not null then 1 else 0 end) as invalid_rendering_npi\n , max(case when term2.npi is null and m.billing_npi is not null then 1 else 0 end) as invalid_billing_npi\n , max(case when term3.npi is null and m.facility_npi is not null then 1 else 0 end) as invalid_facility_npi\n\n , max(case when m.rendering_npi is null then 1 else 0 end) as missing_rendering_npi\n , max(case when m.billing_npi is null then 1 else 0 end) as missing_billing_npi\n , max(case when m.facility_npi is null then 1 else 0 end) as missing_facility_npi\n\n , count(distinct m.rendering_npi) as rendering_npi_count\n , count(distinct m.billing_npi) as billing_npi_count\n , count(distinct m.facility_npi) as facility_npi_count\n\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_rendering_npi\n , max(case when term3.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_facility_npi\n\n from tuva.input_layer.medical_claim as m\n left join cms_synthetic.terminology.provider as term\n on m.rendering_npi = term.npi\n left join cms_synthetic.terminology.provider as term2\n on m.billing_npi = term2.npi\n left join cms_synthetic.terminology.provider as term3\n on m.facility_npi = term3.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid rendering_npi' as data_quality_check\n , sum(invalid_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid billing_npi' as data_quality_check\n , sum(invalid_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid facility_npi' as data_quality_check\n , sum(invalid_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing rendering_npi' as data_quality_check\n , sum(missing_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing billing_npi' as data_quality_check\n , sum(missing_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing facility_npi' as data_quality_check\n , sum(missing_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type rendering_npi' as data_quality_check\n , sum(wrong_entity_type_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type facility_npi' as data_quality_check\n , sum(wrong_entity_type_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'multiple rendering_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere rendering_npi_count > 1\n\nunion all\n\nselect\n 'multiple billing_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere billing_npi_count > 1\n\nunion all\n\nselect\n 'multiple facility_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere facility_npi_count > 1\n)\n\nselect *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.medical_claim_provider_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.660190Z", "completed_at": "2024-10-22T19:20:32.664623Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.670109Z", "completed_at": "2024-10-22T19:20:32.670116Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011223077774047852, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "compiled": true, "compiled_code": "\n\nwith range_cte as (\n select\n min(claim_start_date) as first_date\n \n , current_date as last_date\n \n from tuva.input_layer.medical_claim p\n)\n\n, date_cte as (\n select distinct\n year_month_int\n from cms_synthetic.reference_data.calendar c\n inner join range_cte r\n on c.full_date between r.first_date and r.last_date\n)\n\n, medical_claim as (\n select\n c.year_month_int\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n from tuva.input_layer.medical_claim p\n left join cms_synthetic.reference_data.calendar c\n on p.claim_start_date = c.full_date\n group by\n c.year_month_int\n)\n\nselect\n d.year_month_int as year_month\n , coalesce(claim_volume, 0) as claim_volume\n , coalesce(paid_amount, 0) as paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom date_cte d\nleft join medical_claim m\n on d.year_month_int = m.year_month_int", "relation_name": "cms_synthetic.data_quality.medical_claim_volume_and_dollars"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.664820Z", "completed_at": "2024-10-22T19:20:32.671640Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.675267Z", "completed_at": "2024-10-22T19:20:32.675272Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011840105056762695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_key_check", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.pharmacy_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, medical as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.medical_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, eligibility as (\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n , count(*) as result_count\n from tuva.input_layer.eligibility p\n group by\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n having count(*) > 1\n)\n\n, final as (\n select\n 'pk errors pharmacy claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from pharmacy\n\n union all\n\n select\n 'pk errors medical claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from medical\n\n union all\n\n select\n 'pk errors eligibility' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from eligibility\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.primary_key_check"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.671864Z", "completed_at": "2024-10-22T19:20:32.676349Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.682398Z", "completed_at": "2024-10-22T19:20:32.682404Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011265993118286133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_billing_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'BILLING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.billing_npi is not null\n and term.npi is null\n then 'Billing NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.billing_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.provider as term on m.billing_npi = term.npi", "relation_name": "cms_synthetic.data_quality.professional_billing_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.676538Z", "completed_at": "2024-10-22T19:20:32.684876Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.685541Z", "completed_at": "2024-10-22T19:20:32.685545Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00966501235961914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_claim_end_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n ,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before start date'\n when m.claim_end_date is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.professional_claim_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.686320Z", "completed_at": "2024-10-22T19:20:32.694331Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.698187Z", "completed_at": "2024-10-22T19:20:32.698192Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01361989974975586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_claim_start_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.professional_claim_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.694557Z", "completed_at": "2024-10-22T19:20:32.699499Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.699911Z", "completed_at": "2024-10-22T19:20:32.699915Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006360054016113281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm", "relation_name": "cms_synthetic.data_quality.professional_diagnosis_code_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.700271Z", "completed_at": "2024-10-22T19:20:32.708232Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.708618Z", "completed_at": "2024-10-22T19:20:32.708623Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009421825408935547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm", "relation_name": "cms_synthetic.data_quality.professional_diagnosis_code_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.704835Z", "completed_at": "2024-10-22T19:20:32.709502Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.710080Z", "completed_at": "2024-10-22T19:20:32.710084Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005847930908203125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm", "relation_name": "cms_synthetic.data_quality.professional_diagnosis_code_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.710432Z", "completed_at": "2024-10-22T19:20:32.720359Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.720656Z", "completed_at": "2024-10-22T19:20:32.720662Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011456966400146484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_facility_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'FACILITY_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.facility_npi is not null\n and term.npi is null\n then 'Facility NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.facility_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.provider as term on m.facility_npi = term.npi", "relation_name": "cms_synthetic.data_quality.professional_facility_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.714525Z", "completed_at": "2024-10-22T19:20:32.721359Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.721842Z", "completed_at": "2024-10-22T19:20:32.721845Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007822036743164062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_place_of_service_code", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'PLACE_OF_SERVICE_CODE' AS field_name\n , case when term.place_of_service_code is not null then 'valid'\n when m.place_of_service_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.place_of_service_code is not null\n and term.place_of_service_code is null\n then 'Place of Service Code does not join to Terminology Place of Service table'\n else null\n end as invalid_reason\n , m.place_of_service_code || '|' || coalesce(term.place_of_service_description, '') as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.place_of_service as term on m.place_of_service_code = term.place_of_service_code", "relation_name": "cms_synthetic.data_quality.professional_place_of_service_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.722608Z", "completed_at": "2024-10-22T19:20:32.729622Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.729894Z", "completed_at": "2024-10-22T19:20:32.729901Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008412837982177734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_rendering_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'RENDERING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.rendering_npi is not null\n and term.npi is null\n then 'Rendering Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.rendering_npi as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join cms_synthetic.terminology.provider as term on m.rendering_npi = term.npi", "relation_name": "cms_synthetic.data_quality.professional_rendering_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.726749Z", "completed_at": "2024-10-22T19:20:32.730567Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.731013Z", "completed_at": "2024-10-22T19:20:32.731016Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005080699920654297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__raw_summary", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n 'input_layer' as source\n , 'eligibility' as table_name\n , count(*) as row_count\n , count(distinct patient_id) as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 2 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'raw_data' as source\n , 'eligibility' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 1 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'input_layer' as source\n , 'medical_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 4 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'medical_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 3 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'input_layer' as source\n , 'pharmacy_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 6 as table_order\n from tuva.input_layer.pharmacy_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'pharmacy_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 5 as table_order\n from tuva.input_layer.pharmacy_claim\n)\n\nselect\n cte.*\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte", "relation_name": "cms_synthetic.data_quality.raw_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.738912Z", "completed_at": "2024-10-22T19:20:32.741727Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.744320Z", "completed_at": "2024-10-22T19:20:32.744326Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006201028823852539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.medical_claim_expanded", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom tuva.input_layer.medical_claim", "relation_name": "cms_synthetic.claims_expanded.medical_claim_expanded"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.752530Z", "completed_at": "2024-10-22T19:20:32.772738Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.778078Z", "completed_at": "2024-10-22T19:20:32.778083Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.026073694229125977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_detail", "compiled": true, "compiled_code": "\n\nWITH CTE as (\nSELECT * FROM cms_synthetic.data_quality.condition_claim_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_condition_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_condition_rank\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_condition_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_onset_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_present_on_admit_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_present_on_admit_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_recorded_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_resolved_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.condition_status\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_type_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_admit_type_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_allowed_amount\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_apr_drg_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_apr_drg_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_attending_provider_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_charge_amount\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_discharge_disposition_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_discharge_disposition_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_end_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_start_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_encounter_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_facility_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_length_of_stay\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_ms_drg_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_ms_drg_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_paid_amount\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_primary_diagnosis_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_primary_diagnosis_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.encounter_primary_diagnosis_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_practice_affiliation\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_sub_specialty\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_last_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_npi\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_first_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.practitioner_specialty\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_parent_organization\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_latitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_facility_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_zip_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_city\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_npi\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_location_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_longitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_address\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_state\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.location_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_procedure_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_claim_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_procedure_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_5\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_4\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_1\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_3\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.procedure_modifier_2\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_abnormal_flag\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_specimen\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_collection_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_component\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_ordering_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_result\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_status\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_accession_number\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_result_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_abnormal_flag\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_source_component\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.lab_result_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_sex\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_state\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_city\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_longitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_county\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_race\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_death_flag\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_address\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_zip_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_first_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_last_name\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_latitude\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_birth_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_death_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.patient_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_rxnorm_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_atc_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_dispensing_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_prescribing_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_days_supply\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_strength\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_rxnorm_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_atc_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_quantity_unit\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_ndc_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_medication_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_ndc_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_quantity\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.medication_route\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_observation_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_code\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_data_source\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_panel_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_observation_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_result\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_observation_date\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_description\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_source_reference_range_high\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_units\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_normalized_code_type\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.observation_patient_id\n\n)\n\nSELECT\n data_source,\n cast(source_date as TEXT) as source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n bucket_name,\n invalid_reason,\n field_value,\n tuva_last_run,\n dense_rank() over (order by data_source, table_name, field_name) + 100000 as summary_sk\nFROM CTE", "relation_name": "cms_synthetic.data_quality.data_quality_clinical_detail"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.787909Z", "completed_at": "2024-10-22T19:20:32.790827Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.791335Z", "completed_at": "2024-10-22T19:20:32.791339Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004049062728881836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af", "compiled": true, "compiled_code": "\n \n \n\nselect\n lab_result_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.lab_result\nwhere lab_result_id is not null\ngroup by lab_result_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.805586Z", "completed_at": "2024-10-22T19:20:32.813223Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.813474Z", "completed_at": "2024-10-22T19:20:32.813480Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008997201919555664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1", "compiled": true, "compiled_code": "\n \n \n\nselect\n medication_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.medication\nwhere medication_id is not null\ngroup by medication_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.822703Z", "completed_at": "2024-10-22T19:20:32.827198Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.829024Z", "completed_at": "2024-10-22T19:20:32.829030Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014016151428222656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59", "compiled": true, "compiled_code": "\n \n \n\nselect\n observation_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.observation\nwhere observation_id is not null\ngroup by observation_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.829596Z", "completed_at": "2024-10-22T19:20:32.834194Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.837577Z", "completed_at": "2024-10-22T19:20:32.837583Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010759830474853516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__unique_value_examples", "compiled": true, "compiled_code": "\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_condition_condition_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_encounter_encounter_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_location_location_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_medication_medication_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_observation_observation_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_patient_patient_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM cms_synthetic.data_quality.primary_keys_procedure_procedure_id", "relation_name": "cms_synthetic.data_quality.unique_value_examples"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.834462Z", "completed_at": "2024-10-22T19:20:32.838900Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.839292Z", "completed_at": "2024-10-22T19:20:32.839295Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007380962371826172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_patient_id", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(\n case \n when startdts.month_start_date is null then 1\n when enddts.month_start_date is null then 1\n else 0\n end\n ) as missing_eligibility\n from tuva.input_layer.medical_claim p\n left join cms_synthetic.data_quality.data_quality__eligibility_dq_stage startdts\n on p.patient_id = startdts.patient_id\n and p.claim_start_date between startdts.month_start_date and startdts.month_end_date\n left join cms_synthetic.data_quality.data_quality__eligibility_dq_stage enddts\n on p.patient_id = enddts.patient_id\n and p.claim_end_date between enddts.month_start_date and enddts.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple medical_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from medical\n\n union all\n\n select\n 'missing medical_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from medical\n\n union all\n\n select\n 'orphaned medical_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from medical\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.medical_claim_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.841373Z", "completed_at": "2024-10-22T19:20:32.844866Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.852697Z", "completed_at": "2024-10-22T19:20:32.852703Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014129877090454102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(case when e.month_start_date is null then 1 else 0 end) as missing_eligibility\n from tuva.input_layer.pharmacy_claim p\n left join cms_synthetic.data_quality.data_quality__eligibility_dq_stage e\n on p.patient_id = e.patient_id\n and coalesce(p.paid_date, p.dispensing_date) between e.month_start_date and e.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple pharmacy_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from pharmacy\n\n union all\n\n select\n 'missing pharmacy_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from pharmacy\n\n union all\n\n select\n 'orphaned pharmacy_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from pharmacy\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.pharmacy_claim_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.845069Z", "completed_at": "2024-10-22T19:20:32.853851Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.871302Z", "completed_at": "2024-10-22T19:20:32.871308Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02704906463623047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select distinct\n elig.patient_id\n , elig.patient_id || coalesce(elig.data_source,'') || coalesce(elig.payer,'') || coalesce(elig.plan,'') || coalesce(cast(elig.enrollment_start_date as TEXT),'') || coalesce(cast(elig.enrollment_end_date as TEXT),'') as patient_id_key\n , cal_dob.full_date as normalized_birth_date\n , cal_death.full_date as normalized_death_date\n , cal_enroll_start.full_date as normalized_enrollment_start_date\n , cal_enroll_end.full_date as normalized_enrollment_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join cms_synthetic.reference_data.calendar cal_dob\n on elig.birth_date = cal_dob.full_date\nleft join cms_synthetic.reference_data.calendar cal_death\n on elig.death_date = cal_death.full_date\nleft join cms_synthetic.reference_data.calendar cal_enroll_start\n on elig.enrollment_start_date = cal_enroll_start.full_date\nleft join cms_synthetic.reference_data.calendar cal_enroll_end\n on elig.enrollment_end_date = cal_enroll_end.full_date", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_eligibility_dates_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.854082Z", "completed_at": "2024-10-22T19:20:32.873144Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.876353Z", "completed_at": "2024-10-22T19:20:32.876358Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.022961139678955078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__pharmacy_claim", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_pharmacy_claim as (\n\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim\n) select\n cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as int ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , cast(plan as TEXT ) as plan\n , cast(prescribing_provider_npi as TEXT ) as prescribing_provider_id\n , cast(coalesce(pres.provider_last_name || ', ' || pres.provider_first_name, pres.provider_organization_name) as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_npi as TEXT ) as dispensing_provider_id\n , cast(coalesce(disp.provider_last_name || ', ' || disp.provider_first_name, disp.provider_organization_name) as TEXT ) as dispensing_provider_name , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc.fda_description as TEXT ) as ndc_description\n , cast(quantity as int ) as quantity\n , cast(days_supply as int ) as days_supply\n , cast(refills as int ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_pharmacy_claim pharm\nleft join cms_synthetic.terminology.provider pres\n on pharm.prescribing_provider_npi = pres.npi\nleft join cms_synthetic.terminology.provider disp\n on pharm.dispensing_provider_npi = disp.npi\nleft join cms_synthetic.terminology.ndc ndc\n on pharm.ndc_code = ndc.ndc", "relation_name": "cms_synthetic.claims_preprocessing.normalized_input_pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.873377Z", "completed_at": "2024-10-22T19:20:32.877590Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.881661Z", "completed_at": "2024-10-22T19:20:32.881667Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00940394401550293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_date_checks", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select m.claim_id,\n max(case when claim_start_date is null then 1 else 0 end) as missing_claim_start_date,\n max(case when claim_end_date is null then 1 else 0 end) as missing_claim_end_date,\n max(case when claim_line_start_date is null then 1 else 0 end) as missing_claim_line_start_date,\n max(case when claim_line_end_date is null then 1 else 0 end) as missing_claim_line_end_date,\n max(case when admission_date is null and d.claim_id is not null then 1 else 0 end) as missing_admission_date,\n max(case when discharge_date is null and d.claim_id is not null then 1 else 0 end) as missing_discharge_date,\n max(case when paid_date is null then 1 else 0 end) as missing_paid_date,\n count(distinct case when d.claim_id is not null then claim_start_date else null end) as claim_start_count,\n count(distinct case when d.claim_id is not null then claim_end_date else null end) as claim_end_count,\n count(distinct case when d.claim_id is not null then admission_date else null end) as admission_date_count,\n count(distinct case when d.claim_id is not null then discharge_date else null end) as discharge_date_count\n from tuva.input_layer.medical_claim m\n left join cms_synthetic.data_quality.data_quality__inpatient_dq_stage d on m.claim_id = d.claim_id\n group by m.claim_id\n)\n\n,final as (\nselect 'missing claim_start_date' as data_quality_check,\n sum(missing_claim_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_end_date' as data_quality_check,\n sum(missing_claim_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_start_date' as data_quality_check,\n sum(missing_claim_line_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_end_date' as data_quality_check,\n sum(missing_claim_line_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing admission_date' as data_quality_check,\n sum(missing_admission_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing discharge_date' as data_quality_check,\n sum(missing_discharge_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing medical_claim paid_date' as data_quality_check,\n sum(missing_paid_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'claim start multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_start_count > 1\n\nunion all\n\nselect 'claim end multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_end_count > 1\n\nunion all\n\nselect 'admission date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere admission_date_count > 1\n\nunion all\n\nselect 'discharge date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere discharge_date_count > 1\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.medical_claim_date_checks"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.877836Z", "completed_at": "2024-10-22T19:20:32.889620Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.899193Z", "completed_at": "2024-10-22T19:20:32.899199Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.022155046463012695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "compiled": true, "compiled_code": "\n\nwith inst_header as (\n select\n m.claim_id\n , max(case when m.claim_type = 'institutional' and btc.bill_type_code is null and m.bill_type_code is not null then 1 else 0 end) as invalid_bill_type_code\n , max(case when m.claim_type = 'institutional' and dd.discharge_disposition_code is null and m.discharge_disposition_code is not null then 1 else 0 end) as invalid_discharge_disposition_code\n , max(case when d.claim_id is not null and ms.ms_drg_code is null and m.ms_drg_code is not null then 1 else 0 end) as invalid_ms_drg_code\n , max(case when d.claim_id is not null and apr.apr_drg_code is null and m.apr_drg_code is not null then 1 else 0 end) as invalid_apr_drg_code\n , max(case when m.claim_type = 'institutional' and m.bill_type_code is null then 1 else 0 end) as missing_bill_type_code\n , max(case when m.claim_type = 'institutional' and m.discharge_disposition_code is null then 1 else 0 end) as missing_discharge_disposition_code\n , max(case when d.claim_id is not null and m.ms_drg_code is null then 1 else 0 end) as missing_ms_drg_code\n , max(case when d.claim_id is not null and m.apr_drg_code is null then 1 else 0 end) as missing_apr_drg_code\n , count(distinct case when m.claim_type = 'institutional' then m.bill_type_code else null end) as bill_type_code_count\n , count(distinct case when m.claim_type = 'institutional' then m.discharge_disposition_code else null end) as discharge_disposition_code_count\n , count(distinct case when d.claim_id is not null then m.ms_drg_code else null end) as ms_drg_code_count\n , count(distinct case when d.claim_id is not null then m.apr_drg_code else null end) as apr_drg_code_count\n from tuva.input_layer.medical_claim as m\n left join cms_synthetic.data_quality.data_quality__inpatient_dq_stage as d\n on m.claim_id = d.claim_id\n left join cms_synthetic.terminology.bill_type as btc\n on m.bill_type_code = btc.bill_type_code\n left join cms_synthetic.terminology.ms_drg as ms\n on m.ms_drg_code = ms.ms_drg_code\n left join cms_synthetic.terminology.apr_drg as apr\n on m.ms_drg_code = apr.apr_drg_code\n left join cms_synthetic.terminology.discharge_disposition as dd\n on m.discharge_disposition_code = dd.discharge_disposition_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid bill_type_code' as data_quality_check\n , sum(invalid_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid ms_drg_code' as data_quality_check\n , sum(invalid_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid apr_drg_code' as data_quality_check\n , sum(invalid_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid discharge_disposition_code' as data_quality_check\n , sum(invalid_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing bill_type_code' as data_quality_check\n , sum(missing_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing ms_drg_code' as data_quality_check\n , sum(missing_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing apr_drg_code' as data_quality_check\n , sum(missing_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing discharge_disposition_code' as data_quality_check\n , sum(missing_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'bill_type_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where bill_type_code_count > 1\n\n union all\n\n select\n 'ms_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where ms_drg_code_count > 1\n\n union all\n\n select\n 'apr_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where apr_drg_code_count > 1\n\n union all\n\n select\n 'discharge_disposition_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where discharge_disposition_code_count > 1\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.medical_claim_inst_header_fields"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.883307Z", "completed_at": "2024-10-22T19:20:32.900282Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.900743Z", "completed_at": "2024-10-22T19:20:32.900747Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01825094223022461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_admission_date", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(admission_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'ADMISSION_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.admission_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(substring(agg.field_aggregated, 1, 255) as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_admission_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.901100Z", "completed_at": "2024-10-22T19:20:32.913750Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.928446Z", "completed_at": "2024-10-22T19:20:32.928452Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02848196029663086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_source_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_source_code || '|' || coalesce(term.admit_source_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.admit_source as term on base.admit_source_code = term.admit_source_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_source_code is not null\n and term.admit_source_code is null\n and cg. frequency = 1\n then 'Admit source code does not join to Terminology Admit Source table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.admit_source as term on m.admit_source_code = term.admit_source_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_admit_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.913970Z", "completed_at": "2024-10-22T19:20:32.942717Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.943908Z", "completed_at": "2024-10-22T19:20:32.943914Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03068089485168457, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_type_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_type_code || '|' || coalesce(term.admit_type_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.admit_type as term on base.admit_type_code = term.admit_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Member ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_type_code is not null\n and term.admit_type_code is null\n and cg.frequency = 1\n then 'Admit Type Code does not join to Terminology Admit Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.admit_type as term on m.admit_type_code = term.admit_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_admit_type_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.946224Z", "completed_at": "2024-10-22T19:20:32.977615Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.977923Z", "completed_at": "2024-10-22T19:20:32.977928Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.034610748291015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_apr_drg_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.apr_drg_code || '|' || coalesce(term.apr_drg_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.apr_drg as term on base.apr_drg_code = term.apr_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'APR_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.apr_drg_code is not null\n and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology APR DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.apr_drg as term on m.apr_drg_code = term.apr_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_apr_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.961814Z", "completed_at": "2024-10-22T19:20:32.978572Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:32.979085Z", "completed_at": "2024-10-22T19:20:32.979089Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018580913543701172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_date", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(discharge_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DISCHARGE_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.discharge_date < m.admission_date then 'invalid'\n when m.discharge_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.discharge_date < m.admission_date then 'discharge date before admission date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_discharge_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.979885Z", "completed_at": "2024-10-22T19:20:33.006345Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.007198Z", "completed_at": "2024-10-22T19:20:33.007205Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02848982810974121, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_ms_drg_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.ms_drg_code || '|' || coalesce(term.ms_drg_description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.ms_drg as term on base.ms_drg_code = term.ms_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'MS_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.ms_drg_code is not null\n and term.ms_drg_code is null\n then 'MS DRG does not join to Terminology MS DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.ms_drg as term on m.ms_drg_code = term.ms_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_ms_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.993340Z", "completed_at": "2024-10-22T19:20:33.008489Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.021038Z", "completed_at": "2024-10-22T19:20:33.021044Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02846384048461914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_1", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_1 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_1 is not null\n and term.icd_10_pcs is null\n then 'procedure code does not join to terminology procedure code table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_pcs as term on m.procedure_code_1 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_procedure_code_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.008714Z", "completed_at": "2024-10-22T19:20:33.022226Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.034793Z", "completed_at": "2024-10-22T19:20:33.034799Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0268399715423584, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_2", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_2 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_2 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_pcs as term on m.procedure_code_2 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_procedure_code_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.022500Z", "completed_at": "2024-10-22T19:20:33.035956Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.036563Z", "completed_at": "2024-10-22T19:20:33.036567Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014798641204833984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_3", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_3 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join cms_synthetic.terminology.icd_10_pcs as term on base.procedure_code_3 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_3 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join cms_synthetic.terminology.icd_10_pcs as term on m.procedure_code_3 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "cms_synthetic.data_quality.institutional_procedure_code_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.036992Z", "completed_at": "2024-10-22T19:20:33.058953Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.071609Z", "completed_at": "2024-10-22T19:20:33.071614Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03600192070007324, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_1", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(procedure_date_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_1' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_1 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_procedure_date_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.053664Z", "completed_at": "2024-10-22T19:20:33.072681Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.073168Z", "completed_at": "2024-10-22T19:20:33.073173Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02017688751220703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_2", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_2' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_2 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n when m.procedure_date_2 is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_procedure_date_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.073558Z", "completed_at": "2024-10-22T19:20:33.098572Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.105850Z", "completed_at": "2024-10-22T19:20:33.105857Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03350400924682617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_3", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run\n\n)\n\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_3' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_3 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) then 'future'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "cms_synthetic.data_quality.institutional_procedure_date_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.106565Z", "completed_at": "2024-10-22T19:20:33.116441Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.117817Z", "completed_at": "2024-10-22T19:20:33.117822Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025918960571289062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_voting", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_source_code\n\n , admit.admit_source_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.admit_source admit\n on med.admit_source_code = admit.admit_source_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n , count(*) as admit_source_occurrence_count\n from normalize_cte\n where admit_source_code is not null\n group by \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_source_code' as column_name\n , admit_source_code as normalized_code\n , admit_source_description as normalized_description\n , admit_source_occurrence_count as occurrence_count\n , coalesce(lead(admit_source_occurrence_count) \n over (partition by claim_id, data_source order by admit_source_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_source_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.119364Z", "completed_at": "2024-10-22T19:20:33.140131Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.140494Z", "completed_at": "2024-10-22T19:20:33.140501Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.023936033248901367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_type_code\n , admit.admit_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.admit_type admit\n on med.admit_type_code = admit.admit_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n , count(*) as admit_type_occurrence_count\n from normalize_cte\n\n where admit_type_code is not null\n group by \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_type_code' as column_name\n , admit_type_code as normalized_code\n , admit_type_description as normalized_description\n , admit_type_occurrence_count as occurrence_count\n , coalesce(lead(admit_type_occurrence_count) \n over (partition by claim_id, data_source order by admit_type_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_type_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_normalize_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.129771Z", "completed_at": "2024-10-22T19:20:33.141890Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.151216Z", "completed_at": "2024-10-22T19:20:33.151222Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02230978012084961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n\n select \n med.claim_id\n , med.data_source\n , apr.apr_drg_code\n , apr.apr_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.apr_drg apr\n on med.apr_drg_code = apr.apr_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n , count(*) as apr_drg_occurrence_count\n from normalize_cte\n where apr_drg_code is not null\n group by \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'apr_drg_code' as column_name\n , apr_drg_code as normalized_code\n , apr_drg_description as normalized_description\n , apr_drg_occurrence_count as occurrence_count\n , coalesce(lead(apr_drg_occurrence_count) \n over (partition by claim_id, data_source order by apr_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by apr_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.142091Z", "completed_at": "2024-10-22T19:20:33.152908Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.180587Z", "completed_at": "2024-10-22T19:20:33.180596Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.039434194564819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , bill.bill_type_code\n , bill.bill_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.bill_type bill\n on ltrim(med.bill_type_code, '0') = bill.bill_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n , count(*) as bill_type_occurrence_count\n from normalize_cte\n where bill_type_code is not null\n group by \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'bill_type_code' as column_name\n , bill_type_code as normalized_code\n , bill_type_description as normalized_description\n , bill_type_occurrence_count as occurrence_count\n , row_number() over (partition by claim_id, data_source order by bill_type_occurrence_count desc, bill_type_code asc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.153175Z", "completed_at": "2024-10-22T19:20:33.187837Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.192967Z", "completed_at": "2024-10-22T19:20:33.192972Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04083085060119629, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_diagnosis as(\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_1' as diagnosis_column\n , diagnosis_code_1 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_2' as diagnosis_column\n , diagnosis_code_2 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_3' as diagnosis_column\n , diagnosis_code_3 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_4' as diagnosis_column\n , diagnosis_code_4 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_5' as diagnosis_column\n , diagnosis_code_5 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_6' as diagnosis_column\n , diagnosis_code_6 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_7' as diagnosis_column\n , diagnosis_code_7 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_8' as diagnosis_column\n , diagnosis_code_8 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_9' as diagnosis_column\n , diagnosis_code_9 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_10' as diagnosis_column\n , diagnosis_code_10 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_11' as diagnosis_column\n , diagnosis_code_11 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_12' as diagnosis_column\n , diagnosis_code_12 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_13' as diagnosis_column\n , diagnosis_code_13 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_14' as diagnosis_column\n , diagnosis_code_14 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_15' as diagnosis_column\n , diagnosis_code_15 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_16' as diagnosis_column\n , diagnosis_code_16 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_17' as diagnosis_column\n , diagnosis_code_17 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_18' as diagnosis_column\n , diagnosis_code_18 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_19' as diagnosis_column\n , diagnosis_code_19 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_20' as diagnosis_column\n , diagnosis_code_20 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_21' as diagnosis_column\n , diagnosis_code_21 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_22' as diagnosis_column\n , diagnosis_code_22 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_23' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_24' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_25' as diagnosis_column\n , diagnosis_code_25 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm) as normalized_diagnosis_code\n , count(*) as diagnosis_code_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_diagnosis piv\nleft join cms_synthetic.terminology.icd_10_cm icd_10\n on replace(piv.diagnosis_code,'.','') = icd_10.icd_10_cm\n and piv.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd_9\n on replace(piv.diagnosis_code,'.','') = icd_9.icd_9_cm\n and piv.diagnosis_code_type = 'icd-9-cm'\nwhere claim_type <> 'undetermined'\ngroup by \n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.182492Z", "completed_at": "2024-10-22T19:20:33.194451Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.201333Z", "completed_at": "2024-10-22T19:20:33.201339Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0195157527923584, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , disch.discharge_disposition_code\n , disch.discharge_disposition_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.discharge_disposition disch\n on med.discharge_disposition_code = disch.discharge_disposition_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n , count(*) as discharge_disposition_occurrence_count\n from normalize_cte\n where discharge_disposition_code is not null\n group by \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'discharge_disposition_code' as column_name\n , discharge_disposition_code as normalized_code\n , discharge_disposition_description as normalized_description\n , discharge_disposition_occurrence_count as occurrence_count\n , coalesce(lead(discharge_disposition_occurrence_count) \n over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.194661Z", "completed_at": "2024-10-22T19:20:33.202671Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.211867Z", "completed_at": "2024-10-22T19:20:33.211874Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018092870712280273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , cal_claim_start.full_date as normalized_claim_start_date\n , cal_claim_end.full_date as normalized_claim_end_date\n , cal_claim_line_start.full_date as normalized_claim_line_start_date\n , cal_claim_line_end.full_date as normalized_claim_line_end_date\n , cal_admission.full_date as normalized_admission_date\n , cal_discharge.full_date as normalized_discharge_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.reference_data.calendar cal_claim_start\n on med.claim_start_date = cal_claim_start.full_date\nleft join cms_synthetic.reference_data.calendar cal_claim_end\n on med.claim_end_date = cal_claim_end.full_date\nleft join cms_synthetic.reference_data.calendar cal_claim_line_start\n on med.claim_line_start_date = cal_claim_line_start.full_date\nleft join cms_synthetic.reference_data.calendar cal_claim_line_end\n on med.claim_line_end_date = cal_claim_line_end.full_date\nleft join cms_synthetic.reference_data.calendar cal_admission\n on med.admission_date = cal_admission.full_date\nleft join cms_synthetic.reference_data.calendar cal_discharge\n on med.discharge_date = cal_discharge.full_date", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.202884Z", "completed_at": "2024-10-22T19:20:33.213891Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.214658Z", "completed_at": "2024-10-22T19:20:33.214662Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012542247772216797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , rend_prov.npi as normalized_rendering_npi\n , cast(coalesce(rend_prov.provider_last_name || ', ' || rend_prov.provider_first_name, rend_prov.provider_organization_name) as TEXT ) as normalized_rendering_name\n , bill_prov.npi as normalized_billing_npi\n , cast(coalesce(bill_prov.provider_last_name || ', ' || bill_prov.provider_first_name, bill_prov.provider_organization_name) as TEXT ) as normalized_billing_name\n , fac_prov.npi as normalized_facility_npi\n , cast(coalesce(fac_prov.provider_last_name || ', ' || fac_prov.provider_first_name, fac_prov.provider_organization_name) as TEXT ) as normalized_facility_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.provider rend_prov\n on med.rendering_npi = rend_prov.npi\n and rend_prov.entity_type_description = 'Individual'\nleft join cms_synthetic.terminology.provider bill_prov\n on med.billing_npi = bill_prov.npi\nleft join cms_synthetic.terminology.provider fac_prov\n on med.facility_npi = fac_prov.npi\n and fac_prov.entity_type_description = 'Organization'\n and med.claim_type = 'institutional'", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_medical_npi_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.216126Z", "completed_at": "2024-10-22T19:20:33.230704Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.231041Z", "completed_at": "2024-10-22T19:20:33.231046Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016741037368774414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , ms.ms_drg_code\n , ms.ms_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join cms_synthetic.terminology.ms_drg ms\n on med.ms_drg_code = ms.ms_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , count(*) as ms_drg_occurrence_count\n from normalize_cte\n where ms_drg_code is not null\n group by \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'ms_drg_code' as column_name\n , ms_drg_code as normalized_code\n , ms_drg_description as normalized_description\n , ms_drg_occurrence_count as occurrence_count\n , coalesce(lead(ms_drg_occurrence_count) \n over (partition by claim_id, data_source order by ms_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by ms_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.226070Z", "completed_at": "2024-10-22T19:20:33.231784Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.232285Z", "completed_at": "2024-10-22T19:20:33.232289Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00699615478515625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , pos.place_of_service_code as normalized_code\n , pos.place_of_service_description as normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.place_of_service pos\n \n on lpad(med.place_of_service_code, 2, '0') = pos.place_of_service_code\n \nwhere claim_type = 'professional'", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_place_of_service_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:32.530717Z", "completed_at": "2024-10-22T19:20:33.114919Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.116114Z", "completed_at": "2024-10-22T19:20:33.116120Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.7386507987976074, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__dx_and_px", "compiled": true, "compiled_code": "\n\nwith unpivot_diagnosis as(\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_1' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_1\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_2' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_2\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_3' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_3\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_4' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_4\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_5' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_5\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_6' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_6\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_7' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_7\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_8' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_8\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_9' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_9\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_10' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_10\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_11' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_11\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_12' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_12\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_13' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_13\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_14' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_14\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_15' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_15\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_16' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_16\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_17' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_17\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_18' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_18\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_19' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_19\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_20' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_20\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_21' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_21\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_22' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_22\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_23' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_23\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_24' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_24\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_25' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_25\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n \n)\n, unpivot_procedure as(\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_1' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_1\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_2' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_2\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_3' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_3\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_4' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_4\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_5' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_5\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_6' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_6\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_7' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_7\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_8' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_8\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_9' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_9\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_10' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_10\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_11' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_11\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_12' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_12\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_13' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_13\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_14' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_14\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_15' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_15\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_16' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_16\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_17' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_17\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_18' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_18\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_19' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_19\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_20' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_20\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_21' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_21\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_22' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_22\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_23' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_23\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_24' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_24\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_25' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_25\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n \n\n\n)\n\n, total_claims as(\n select\n cast(count(distinct claim_id) as integer ) as total_claims\n from tuva.input_layer.medical_claim\n)\n\n, claims_with_primary_dx as(\n select\n count(diagnosis_code_1) as distinct_claims_with_primary\n from tuva.input_layer.medical_claim\n)\n\n, secondary_dx_prep_cte as ( \n select\n tc.total_claims\n , cast(count(distinct claim_id) as integer) as secondary_dx_claim_count\n from unpivot_diagnosis\n cross join total_claims tc\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and\n cast(diagnosis_code as TEXT ) is not null\n group by total_claims\n ) \n\n, claims_with_secondary_dx as (\n select\n total_claims\n , cast(secondary_dx_claim_count as integer ) as secondary_dx_claim_count\n , (cast(secondary_dx_claim_count as integer ) / cast(total_claims as integer )) * 100 as result_count\n , cast('Percent of claims with secondary diagnosis' as TEXT) as data_quality_check\n from\n secondary_dx_prep_cte\n\n)\n, missing_primary_dx as (\n select\n cast('missing primary diagnosis' as TEXT) as data_quality_check\n , cast(count(distinct claim_id) as integer ) as result_count\n from tuva.input_layer.medical_claim m\n where diagnosis_code_1 is null\n)\n, invalid_primary_dx as(\n select\n data_quality_check\n , count(distinct claim_id) as result_count\n from (\n select\n cast('invalid primary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , diagnosis_code_type\n , diagnosis_column\n , diagnosis_code\n , icd_10_cm\n , icd_9_cm\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join cms_synthetic.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join cms_synthetic.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n, multiple_primary_dx as(\n\n select\n cast('multiple primary diagnosis' as TEXT) as data_quality_check\n , cast(count(*) as integer ) as result_count\n from\n (\n select\n claim_id\n , row_number() over (partition by claim_id order by claim_id) as row_nbr\n from unpivot_diagnosis\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n group by\n claim_id\n )x\n where row_nbr > 1\n\n)\n, invalid_secondary_dx as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid secondary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join cms_synthetic.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join cms_synthetic.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n\n, invalid_procedure as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid procedure' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_pcs is null and icd9.icd_9_pcs is null\n then 1\n else 0\n end as invalid_procedure\n from unpivot_procedure px\n left join cms_synthetic.terminology.icd_10_pcs icd10\n on px.procedure_code = icd10.icd_10_pcs\n left join cms_synthetic.terminology.icd_9_pcs icd9\n on px.procedure_code = icd9.icd_9_pcs\n where px.procedure_code is not null\n )x\n where invalid_procedure = 1\n group by\n data_quality_check\n)\n\n, final as (\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from missing_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from multiple_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from claims_with_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_procedure\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.dx_and_px"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.233080Z", "completed_at": "2024-10-22T19:20:33.284090Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.289277Z", "completed_at": "2024-10-22T19:20:33.289284Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.05744504928588867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_poa as(\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_1' as diagnosis_column\n , diagnosis_poa_1 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_2' as diagnosis_column\n , diagnosis_poa_2 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_3' as diagnosis_column\n , diagnosis_poa_3 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_4' as diagnosis_column\n , diagnosis_poa_4 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_5' as diagnosis_column\n , diagnosis_poa_5 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_6' as diagnosis_column\n , diagnosis_poa_6 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_7' as diagnosis_column\n , diagnosis_poa_7 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_8' as diagnosis_column\n , diagnosis_poa_8 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_9' as diagnosis_column\n , diagnosis_poa_9 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_10' as diagnosis_column\n , diagnosis_poa_10 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_11' as diagnosis_column\n , diagnosis_poa_11 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_12' as diagnosis_column\n , diagnosis_poa_12 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_13' as diagnosis_column\n , diagnosis_poa_13 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_14' as diagnosis_column\n , diagnosis_poa_14 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_15' as diagnosis_column\n , diagnosis_poa_15 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_16' as diagnosis_column\n , diagnosis_poa_16 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_17' as diagnosis_column\n , diagnosis_poa_17 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_18' as diagnosis_column\n , diagnosis_poa_18 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_19' as diagnosis_column\n , diagnosis_poa_19 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_20' as diagnosis_column\n , diagnosis_poa_20 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_21' as diagnosis_column\n , diagnosis_poa_21 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_22' as diagnosis_column\n , diagnosis_poa_22 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_23' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_24' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_25' as diagnosis_column\n , diagnosis_poa_25 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code as normalized_present_on_admit_code\n , count(*) as present_on_admit_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_poa piv\nleft join cms_synthetic.terminology.present_on_admission poa\n on replace(piv.present_on_admit_code,'.','') = poa.present_on_admit_code\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.259159Z", "completed_at": "2024-10-22T19:20:33.290477Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.317116Z", "completed_at": "2024-10-22T19:20:33.317122Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.06079411506652832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_1' as procedure_column\n , procedure_code_1 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_2' as procedure_column\n , procedure_code_2 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_3' as procedure_column\n , procedure_code_3 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_4' as procedure_column\n , procedure_code_4 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_5' as procedure_column\n , procedure_code_5 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_6' as procedure_column\n , procedure_code_6 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_7' as procedure_column\n , procedure_code_7 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_8' as procedure_column\n , procedure_code_8 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_9' as procedure_column\n , procedure_code_9 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_10' as procedure_column\n , procedure_code_10 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_11' as procedure_column\n , procedure_code_11 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_12' as procedure_column\n , procedure_code_12 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_13' as procedure_column\n , procedure_code_13 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_14' as procedure_column\n , procedure_code_14 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_15' as procedure_column\n , procedure_code_15 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_16' as procedure_column\n , procedure_code_16 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_17' as procedure_column\n , procedure_code_17 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_18' as procedure_column\n , procedure_code_18 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_19' as procedure_column\n , procedure_code_19 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_20' as procedure_column\n , procedure_code_20 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_21' as procedure_column\n , procedure_code_21 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_22' as procedure_column\n , procedure_code_22 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_23' as procedure_column\n , procedure_code_23 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_24' as procedure_column\n , procedure_code_24 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_25' as procedure_column\n , procedure_code_25 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs) as normalized_procedure_code\n , count(*) as procedure_code_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join cms_synthetic.terminology.icd_10_pcs icd_10\n on replace(piv.procedure_code,'.','') = icd_10.icd_10_pcs\n and piv.procedure_code_type = 'icd-10-pcs'\nleft join cms_synthetic.terminology.icd_9_pcs icd_9\n on replace(piv.procedure_code,'.','') = icd_9.icd_9_pcs\n and piv.procedure_code_type = 'icd-9-pcs'\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.290770Z", "completed_at": "2024-10-22T19:20:33.323340Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.323939Z", "completed_at": "2024-10-22T19:20:33.323945Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03506922721862793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_1' as procedure_column\n , procedure_date_1 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_2' as procedure_column\n , procedure_date_2 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_3' as procedure_column\n , procedure_date_3 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_4' as procedure_column\n , procedure_date_4 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_5' as procedure_column\n , procedure_date_5 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_6' as procedure_column\n , procedure_date_6 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_7' as procedure_column\n , procedure_date_7 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_8' as procedure_column\n , procedure_date_8 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_9' as procedure_column\n , procedure_date_9 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_10' as procedure_column\n , procedure_date_10 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_11' as procedure_column\n , procedure_date_11 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_12' as procedure_column\n , procedure_date_12 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_13' as procedure_column\n , procedure_date_13 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_14' as procedure_column\n , procedure_date_14 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_15' as procedure_column\n , procedure_date_15 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_16' as procedure_column\n , procedure_date_16 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_17' as procedure_column\n , procedure_date_17 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_18' as procedure_column\n , procedure_date_18 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_19' as procedure_column\n , procedure_date_19 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_20' as procedure_column\n , procedure_date_20 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_21' as procedure_column\n , procedure_date_21 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_22' as procedure_column\n , procedure_date_22 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_23' as procedure_column\n , procedure_date_23 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_24' as procedure_column\n , procedure_date_24 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_25' as procedure_column\n , procedure_date_25 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_column\n , cal.full_date as procedure_date\n , count(*) as procedure_date_occurrence_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join cms_synthetic.reference_data.calendar cal\n on piv.procedure_date = cal.full_date\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_column\n , cal.full_date", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.318390Z", "completed_at": "2024-10-22T19:20:33.325049Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.349645Z", "completed_at": "2024-10-22T19:20:33.349650Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.034386396408081055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , rev.revenue_center_code as normalized_code\n , rev.revenue_center_description as normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.revenue_center rev\n \n on lpad(med.revenue_center_code, 4, '0') = rev.revenue_center_code\n \nwhere claim_type = 'institutional'", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_revenue_center_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.325385Z", "completed_at": "2024-10-22T19:20:33.356130Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.358188Z", "completed_at": "2024-10-22T19:20:33.358195Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03467226028442383, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , ad_src.admit_source_code\n , ad_src.admit_source_description\n , ad_type.admit_type_code\n , ad_type.admit_type_description\n , dis.discharge_disposition_code\n , dis.discharge_disposition_description\n , pos.place_of_service_code\n , pos.place_of_service_description\n , tob.bill_type_code\n , tob.bill_type_description\n , msdrg.ms_drg_code\n , msdrg.ms_drg_description\n , aprdrg.apr_drg_code\n , aprdrg.apr_drg_description\n , rev.revenue_center_code\n , rev.revenue_center_description\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendnpi.npi as rendering_name\n , billing_npi\n , billnpi.npi as billing_name\n , facility_npi\n , facnpi.npi as facility_name\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.terminology.admit_source ad_src\n on med.admit_source_code = ad_src.admit_source_code\nleft join cms_synthetic.terminology.admit_type ad_type\n on med.admit_type_code = ad_type.admit_type_code\nleft join cms_synthetic.terminology.discharge_disposition dis\n on med.discharge_disposition_code = dis.discharge_disposition_code\nleft join cms_synthetic.terminology.place_of_service pos\n on med.place_of_service_code = pos.place_of_service_code\nleft join cms_synthetic.terminology.bill_type tob\n on med.bill_type_code = tob.bill_type_code\nleft join cms_synthetic.terminology.ms_drg msdrg\n on med.ms_drg_code = msdrg.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg aprdrg\n on med.apr_drg_code = aprdrg.apr_drg_code\nleft join cms_synthetic.terminology.revenue_center rev\n on med.revenue_center_code = rev.revenue_center_code\nleft join cms_synthetic.terminology.provider rendnpi\n on med.rendering_npi = rendnpi.npi\nleft join cms_synthetic.terminology.provider billnpi\n on med.billing_npi = billnpi.npi\nleft join cms_synthetic.terminology.provider facnpi\n on med.facility_npi = facnpi.npi\nwhere claim_type in ('undetermined')", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_undetermined_claim_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.350790Z", "completed_at": "2024-10-22T19:20:33.364891Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.379239Z", "completed_at": "2024-10-22T19:20:33.379244Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03006720542907715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "compiled": true, "compiled_code": "\n\nWITH Ranked_Examples as (\n SELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n FROM cms_synthetic.data_quality.data_quality_clinical_detail\n where bucket_name not in ('valid', 'null')\n group by\n data_source,\n field_name,\n table_name,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n\n),\n\npk_examples as (\n SELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.drill_down_value as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency,\n row_number() over (partition by detail.summary_sk order by detail.summary_sk) as rn\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.data_quality.data_quality_clinical_detail as detail\n left join cms_synthetic.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\n where detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 1\n GROUP BY\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.drill_down_key,\n detail.drill_down_value,\n detail.invalid_reason,\n detail.summary_sk\n\n)\n--- Null Values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value,\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality.data_quality_clinical_detail\nwhere bucket_name = 'null'\ngroup by\n data_source,\n field_name,\n table_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\n\n--- Valid Values except PKs\n\nSELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n max(detail.drill_down_value) as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality.data_quality_clinical_detail as detail\nleft join cms_synthetic.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\nWHERE\n detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 0 --- need to handle pks differently since every value is supposed to be unique\ngroup by\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.summary_sk\n\nunion all\n\n-- 5 Examples of each invalid example\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggregating all other invalid examples into single row\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'all others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value\n\nunion all\n\n--- 5 Examples of valid primary key values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggegating all other valid primary key value examples\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n 'All Others' as field_value,\n sum(frequency) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "relation_name": "cms_synthetic.data_quality.data_quality_clinical_for_pbi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.359186Z", "completed_at": "2024-10-22T19:20:33.380272Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.383540Z", "completed_at": "2024-10-22T19:20:33.383545Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025686025619506836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom cms_synthetic.core.lab_result\n\n\n), lab_result as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , status\n , result\n , result_date\n from __dbt__cte___stg_lab_result\n\n)\n\n, seed_egfr_codes as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n where lower(concept_name) = 'estimated glomerular filtration rate'\n\n)\n\n, egfr_labs as (\n\n select distinct\n lab_result.patient_id\n , lab_result.data_source\n , lab_result.code_type\n , lab_result.code\n , lab_result.result_date\n , lab_result.result\n from lab_result\n inner join seed_egfr_codes\n on lab_result.code = seed_egfr_codes.code\n and lab_result.code_type = seed_egfr_codes.code_system\n where lab_result.result is not null\n and lower(lab_result.status) not in ('cancelled', 'entered-in-error')\n\n)\n\n, numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , cast(result as numeric(28,6)) as result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, clean_non_numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , cast(case\n when lower(result) like '%unsatisfactory specimen%' then null\n when result like '%>%' then null\n when result like '%<%' then null\n when result like '%@%' then trim(replace(result,'@',''))\n when result like '%mL/min/1.73m2%' then trim(replace(result,'mL/min/1.73m2',''))\n else null\n end as numeric(28,6)) as clean_result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$') = False\n \n\n)\n\n, unioned_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from numeric_egfr_labs\n\n union all\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , clean_result as result\n from clean_non_numeric_egfr_labs\n where clean_result is not null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n from unioned_labs\n\n)\n\nselect\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_prep_egfr_labs"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.380463Z", "completed_at": "2024-10-22T19:20:33.384500Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.387874Z", "completed_at": "2024-10-22T19:20:33.387878Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008990287780761719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n) select patient_id\nfrom __dbt__cte___stg_medication\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.384740Z", "completed_at": "2024-10-22T19:20:33.394502Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.403342Z", "completed_at": "2024-10-22T19:20:33.403348Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020134925842285156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n) select patient_id\nfrom __dbt__cte___stg_observation\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.388752Z", "completed_at": "2024-10-22T19:20:33.404333Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.411025Z", "completed_at": "2024-10-22T19:20:33.411030Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.023448944091796875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__eligibility", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select\n cast(elig.patient_id as TEXT ) as patient_id\n , cast(elig.member_id as TEXT ) as member_id\n , cast(elig.subscriber_id as TEXT ) as subscriber_id\n , cast(elig.gender as TEXT ) as gender\n , cast(elig.race as TEXT ) as race\n , cast(date_norm.normalized_birth_date as date ) as birth_date\n , cast(date_norm.normalized_death_date as date ) as death_date\n , cast(elig.death_flag as int ) as death_flag\n , cast(date_norm.normalized_enrollment_start_date as date ) as enrollment_start_date\n , cast(date_norm.normalized_enrollment_end_date as date ) as enrollment_end_date\n , cast(elig.payer as TEXT ) as payer\n , cast(elig.payer_type as TEXT ) as payer_type\n , cast(elig.plan as TEXT ) as plan\n , cast(elig.original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(elig.dual_status_code as TEXT ) as dual_status_code\n , cast(elig.medicare_status_code as TEXT ) as medicare_status_code\n , cast(elig.first_name as TEXT ) as first_name\n , cast(elig.last_name as TEXT ) as last_name\n , cast(elig.social_security_number as TEXT ) as social_security_number\n , cast(elig.subscriber_relation as TEXT ) as subscriber_relation\n , cast(elig.address as TEXT ) as address\n , cast(elig.city as TEXT ) as city\n , cast(elig.state as TEXT ) as state\n , cast(elig.zip_code as TEXT ) as zip_code\n , cast(elig.phone as TEXT ) as phone\n , cast(elig.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_eligibility_dates_normalize date_norm\n on elig.patient_id_key = date_norm.patient_id_key", "relation_name": "cms_synthetic.claims_preprocessing.normalized_input_eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.404547Z", "completed_at": "2024-10-22T19:20:33.411981Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.428480Z", "completed_at": "2024-10-22T19:20:33.428487Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.025512218475341797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_pharmacy_claim", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the pharmacy_claim\n-- table in core.\n-- *************************************************\n\n\n\n\nselect\n cast(claim_id as TEXT) || '-' || cast(claim_line_number as TEXT) as pharmacy_claim_id\n , cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as integer ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , plan\n , cast(prescribing_provider_id as TEXT ) as prescribing_provider_id\n , cast(prescribing_provider_name as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_id as TEXT ) as dispensing_provider_id\n , cast(dispensing_provider_name as TEXT ) as dispensing_provider_name\n , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(quantity as integer ) as quantity\n , cast(days_supply as integer ) as days_supply\n , cast(refills as integer ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6)) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_pharmacy_claim pharm", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.587519Z", "completed_at": "2024-10-22T19:20:33.590866Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.591123Z", "completed_at": "2024-10-22T19:20:33.591129Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.13714098930358887, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.429872Z", "completed_at": "2024-10-22T19:20:33.591679Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.592610Z", "completed_at": "2024-10-22T19:20:33.592616Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.16454291343688965, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_detail", "compiled": true, "compiled_code": "\n\nWITH unioned_data as (\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_allowed_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_charge_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_line_end_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_line_number\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_line_start_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_claim_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_coninsurance_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_copayment_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_deductible_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_diagnosis_code_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_hcpcs_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_member_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_paid_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_paid_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_patient_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_payer\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_plan\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.claim_total_cost_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_address\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_birth_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_city\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_death_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_death_flag\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_dual_status_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_first_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_gender\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_last_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_medicare_status_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_original_reason_entitlement_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_payer_type\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_phone\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_race\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_state\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.eligibility_zip_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_ms_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_admission_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_admit_source_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_admit_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_apr_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_bill_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_diagnosis_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_discharge_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_discharge_disposition_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_present_on_admission_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_present_on_admission_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_present_on_admission_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_date_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_date_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_procedure_date_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_revenue_center_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.institutional_service_unit_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_allowed_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_claim_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_claim_line_number\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_coinsurance_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_copayment_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_data_source\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_days_supply\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_deductible_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_dispensing_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_dispensing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_ndc_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_paid_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_paid_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_prescribing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.pharmacy_refills\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_place_of_service_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM cms_synthetic.data_quality.professional_diagnosis_code_3\n\n)\n\n\nselect\n cast(data_source as TEXT) as data_source\n , cast(source_date as TEXT) as source_date\n , cast(table_name as TEXT) as table_name\n , cast(drill_down_key as TEXT) as drill_down_key\n , cast(drill_down_value as TEXT) as drill_down_value\n , cast(claim_type as TEXT) as claim_type\n , cast(field_name as TEXT) as field_name\n , cast(bucket_name as TEXT) as bucket_name\n , cast(invalid_reason as TEXT) as invalid_reason\n , cast(field_value as TEXT) as field_value\n , cast(tuva_last_run as TEXT) as tuva_last_run\n , dense_rank() over (\n order by data_source\n , table_name\n , claim_type\n , field_name\n ) as summary_sk\nfrom unioned_data", "relation_name": "cms_synthetic.data_quality.data_quality_claims_detail"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.594354Z", "completed_at": "2024-10-22T19:20:33.600441Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.600787Z", "completed_at": "2024-10-22T19:20:33.600792Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007803916931152344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_normalize_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.597681Z", "completed_at": "2024-10-22T19:20:33.601879Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.602306Z", "completed_at": "2024-10-22T19:20:33.602310Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008311033248901367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.602710Z", "completed_at": "2024-10-22T19:20:33.609914Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.610171Z", "completed_at": "2024-10-22T19:20:33.610176Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008579015731811523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_voting\nwhere occurrence_row_count = 1", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.606627Z", "completed_at": "2024-10-22T19:20:33.610929Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.611391Z", "completed_at": "2024-10-22T19:20:33.611394Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005239963531494141, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_diagnosis_code as normalized_code\n , norm.diagnosis_code_occurrence_count as occurrence_count\n , coalesce(lead(diagnosis_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.612208Z", "completed_at": "2024-10-22T19:20:33.618708Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.618986Z", "completed_at": "2024-10-22T19:20:33.618990Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007910013198852539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.615340Z", "completed_at": "2024-10-22T19:20:33.619809Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.620216Z", "completed_at": "2024-10-22T19:20:33.620219Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0054569244384765625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , min(normalized_admission_date) as minimum_admission_date\n , max(normalized_discharge_date) as maximum_discharge_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'institutional'\ngroup by\n claim_id\n , data_source\n\nunion all\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , null as minimum_admission_date\n , null as maximum_discharge_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'professional'\ngroup by\n claim_id\n , data_source", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_medical_date_aggregation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.620545Z", "completed_at": "2024-10-22T19:20:33.623754Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.627151Z", "completed_at": "2024-10-22T19:20:33.627158Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007627964019775391, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.623927Z", "completed_at": "2024-10-22T19:20:33.628227Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.628741Z", "completed_at": "2024-10-22T19:20:33.628745Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005452871322631836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_present_on_admit_code as normalized_code\n , norm.present_on_admit_occurrence_count as occurrence_count\n , coalesce(lead(present_on_admit_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.629701Z", "completed_at": "2024-10-22T19:20:33.636940Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.637238Z", "completed_at": "2024-10-22T19:20:33.637242Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008901119232177734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.normalized_procedure_code as normalized_code\n , norm.procedure_code_occurrence_count as occurrence_count\n , coalesce(lead(procedure_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.633806Z", "completed_at": "2024-10-22T19:20:33.638062Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.638625Z", "completed_at": "2024-10-22T19:20:33.638629Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005480051040649414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.procedure_date as normalized_code\n , norm.procedure_date_occurrence_count as occurrence_count\n , coalesce(lead(procedure_date_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc) as occurrence_row_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.639633Z", "completed_at": "2024-10-22T19:20:33.653850Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.654120Z", "completed_at": "2024-10-22T19:20:33.654125Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01583099365234375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_eligibility", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the eligibility table in core.\n-- *************************************************\n\n\n\n\nselect\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(subscriber_id as TEXT ) as subscriber_id\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(enrollment_start_date as date ) as enrollment_start_date\n , cast(enrollment_end_date as date ) as enrollment_end_date\n , cast(payer as TEXT ) as payer\n , cast(payer_type as TEXT ) as payer_type\n , plan\n , cast(original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(dual_status_code as TEXT ) as dual_status_code\n , cast(medicare_status_code as TEXT ) as medicare_status_code\n , cast(subscriber_relation as TEXT ) as subscriber_relation\n , cast(data_source as TEXT ) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_eligibility", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.644706Z", "completed_at": "2024-10-22T19:20:33.654683Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.655225Z", "completed_at": "2024-10-22T19:20:33.655228Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011063814163208008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_patient", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the patient table in core.\n-- *************************************************\n\nwith patient_stage as(\n select\n patient_id\n ,first_name\n ,last_name\n ,gender\n ,race\n ,birth_date\n ,death_date\n ,death_flag\n ,social_security_number\n ,address\n ,city\n ,state\n ,zip_code\n ,phone\n ,data_source\n ,row_number() over (\n\t partition by patient_id\n\t order by case when enrollment_end_date is null\n then cast ('2050-01-01' as date)\n else enrollment_end_date end DESC)\n as row_sequence\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp) as tuva_last_run_datetime\n , cast(substring('2024-10-22 19:20:26.762934+00:00',1,10) as date) as tuva_last_run_date\n from cms_synthetic.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(first_name as TEXT) as first_name\n , cast(last_name as TEXT) as last_name\n , cast(gender as TEXT) as sex\n , cast(race as TEXT) as race\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(death_flag as int) as death_flag\n , cast(social_security_number as TEXT) as social_security_number\n , cast(address as TEXT) as address\n , cast(city as TEXT) as city\n , cast(state as TEXT) as state\n , cast(zip_code as TEXT) as zip_code\n , cast(null as TEXT) as county\n , cast(null as float) as latitude \n , cast(null as float) as longitude\n , cast(data_source as TEXT) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nfrom patient_stage\nwhere row_sequence = 1", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.656078Z", "completed_at": "2024-10-22T19:20:33.663242Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.663544Z", "completed_at": "2024-10-22T19:20:33.663549Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008655071258544922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__pharmacy_claim", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim", "relation_name": "cms_synthetic.core.pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.658709Z", "completed_at": "2024-10-22T19:20:33.664432Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.664878Z", "completed_at": "2024-10-22T19:20:33.664883Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006855964660644531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "compiled": true, "compiled_code": "\n\nWITH ranked_examples as (\n select\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value, --all claims\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\nWHERE bucket_name not in ('valid', 'null')\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n)\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'null'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n field_value as field_value,\n count(drill_down_value) as frequency\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'valid'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-22 19:20:26.762934+00:00'\nFROM ranked_examples\nWHERE rn <= 5 -- 5 Example claims per unique SK / field value\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-22 19:20:26.762934+00:00'\nFROM ranked_examples\nWHERE rn > 5 -- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "relation_name": "cms_synthetic.data_quality.data_quality_claims_for_pbi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.665429Z", "completed_at": "2024-10-22T19:20:33.673446Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.673750Z", "completed_at": "2024-10-22T19:20:33.673756Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009603023529052734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_detail", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\tclaim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_detail\n\nunion all\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\t'CLINICAL' AS claim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_clinical_detail\n\n", "relation_name": "cms_synthetic.data_quality.data_quality_detail"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.670660Z", "completed_at": "2024-10-22T19:20:33.674612Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.675044Z", "completed_at": "2024-10-22T19:20:33.675047Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004892826080322266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'diagnosis_code_1' then normalized_code else null end) as diagnosis_code_1\n , max(case when lower(column_name) = 'diagnosis_code_2' then normalized_code else null end) as diagnosis_code_2\n , max(case when lower(column_name) = 'diagnosis_code_3' then normalized_code else null end) as diagnosis_code_3\n , max(case when lower(column_name) = 'diagnosis_code_4' then normalized_code else null end) as diagnosis_code_4\n , max(case when lower(column_name) = 'diagnosis_code_5' then normalized_code else null end) as diagnosis_code_5\n , max(case when lower(column_name) = 'diagnosis_code_6' then normalized_code else null end) as diagnosis_code_6\n , max(case when lower(column_name) = 'diagnosis_code_7' then normalized_code else null end) as diagnosis_code_7\n , max(case when lower(column_name) = 'diagnosis_code_8' then normalized_code else null end) as diagnosis_code_8\n , max(case when lower(column_name) = 'diagnosis_code_9' then normalized_code else null end) as diagnosis_code_9\n , max(case when lower(column_name) = 'diagnosis_code_10' then normalized_code else null end) as diagnosis_code_10\n , max(case when lower(column_name) = 'diagnosis_code_11' then normalized_code else null end) as diagnosis_code_11\n , max(case when lower(column_name) = 'diagnosis_code_12' then normalized_code else null end) as diagnosis_code_12\n , max(case when lower(column_name) = 'diagnosis_code_13' then normalized_code else null end) as diagnosis_code_13\n , max(case when lower(column_name) = 'diagnosis_code_14' then normalized_code else null end) as diagnosis_code_14\n , max(case when lower(column_name) = 'diagnosis_code_15' then normalized_code else null end) as diagnosis_code_15\n , max(case when lower(column_name) = 'diagnosis_code_16' then normalized_code else null end) as diagnosis_code_16\n , max(case when lower(column_name) = 'diagnosis_code_17' then normalized_code else null end) as diagnosis_code_17\n , max(case when lower(column_name) = 'diagnosis_code_18' then normalized_code else null end) as diagnosis_code_18\n , max(case when lower(column_name) = 'diagnosis_code_19' then normalized_code else null end) as diagnosis_code_19\n , max(case when lower(column_name) = 'diagnosis_code_20' then normalized_code else null end) as diagnosis_code_20\n , max(case when lower(column_name) = 'diagnosis_code_21' then normalized_code else null end) as diagnosis_code_21\n , max(case when lower(column_name) = 'diagnosis_code_22' then normalized_code else null end) as diagnosis_code_22\n , max(case when lower(column_name) = 'diagnosis_code_23' then normalized_code else null end) as diagnosis_code_23\n , max(case when lower(column_name) = 'diagnosis_code_24' then normalized_code else null end) as diagnosis_code_24\n , max(case when lower(column_name) = 'diagnosis_code_25' then normalized_code else null end) as diagnosis_code_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.675368Z", "completed_at": "2024-10-22T19:20:33.681499Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.681850Z", "completed_at": "2024-10-22T19:20:33.681854Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007559776306152344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_final", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when column_name = 'DIAGNOSIS_POA_1' then normalized_code else null end) as diagnosis_poa_1\n , max(case when column_name = 'DIAGNOSIS_POA_2' then normalized_code else null end) as diagnosis_poa_2\n , max(case when column_name = 'DIAGNOSIS_POA_3' then normalized_code else null end) as diagnosis_poa_3\n , max(case when column_name = 'DIAGNOSIS_POA_4' then normalized_code else null end) as diagnosis_poa_4\n , max(case when column_name = 'DIAGNOSIS_POA_5' then normalized_code else null end) as diagnosis_poa_5\n , max(case when column_name = 'DIAGNOSIS_POA_6' then normalized_code else null end) as diagnosis_poa_6\n , max(case when column_name = 'DIAGNOSIS_POA_7' then normalized_code else null end) as diagnosis_poa_7\n , max(case when column_name = 'DIAGNOSIS_POA_8' then normalized_code else null end) as diagnosis_poa_8\n , max(case when column_name = 'DIAGNOSIS_POA_9' then normalized_code else null end) as diagnosis_poa_9\n , max(case when column_name = 'DIAGNOSIS_POA_10' then normalized_code else null end) as diagnosis_poa_10\n , max(case when column_name = 'DIAGNOSIS_POA_11' then normalized_code else null end) as diagnosis_poa_11\n , max(case when column_name = 'DIAGNOSIS_POA_12' then normalized_code else null end) as diagnosis_poa_12\n , max(case when column_name = 'DIAGNOSIS_POA_13' then normalized_code else null end) as diagnosis_poa_13\n , max(case when column_name = 'DIAGNOSIS_POA_14' then normalized_code else null end) as diagnosis_poa_14\n , max(case when column_name = 'DIAGNOSIS_POA_15' then normalized_code else null end) as diagnosis_poa_15\n , max(case when column_name = 'DIAGNOSIS_POA_16' then normalized_code else null end) as diagnosis_poa_16\n , max(case when column_name = 'DIAGNOSIS_POA_17' then normalized_code else null end) as diagnosis_poa_17\n , max(case when column_name = 'DIAGNOSIS_POA_18' then normalized_code else null end) as diagnosis_poa_18\n , max(case when column_name = 'DIAGNOSIS_POA_19' then normalized_code else null end) as diagnosis_poa_19\n , max(case when column_name = 'DIAGNOSIS_POA_20' then normalized_code else null end) as diagnosis_poa_20\n , max(case when column_name = 'DIAGNOSIS_POA_21' then normalized_code else null end) as diagnosis_poa_21\n , max(case when column_name = 'DIAGNOSIS_POA_22' then normalized_code else null end) as diagnosis_poa_22\n , max(case when column_name = 'DIAGNOSIS_POA_23' then normalized_code else null end) as diagnosis_poa_23\n , max(case when column_name = 'DIAGNOSIS_POA_24' then normalized_code else null end) as diagnosis_poa_24\n , max(case when column_name = 'DIAGNOSIS_POA_25' then normalized_code else null end) as diagnosis_poa_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.678737Z", "completed_at": "2024-10-22T19:20:33.682755Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.683198Z", "completed_at": "2024-10-22T19:20:33.683201Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004945039749145508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_final", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_code_1' then normalized_code else null end) as procedure_code_1\n , max(case when lower(column_name) = 'procedure_code_2' then normalized_code else null end) as procedure_code_2\n , max(case when lower(column_name) = 'procedure_code_3' then normalized_code else null end) as procedure_code_3\n , max(case when lower(column_name) = 'procedure_code_4' then normalized_code else null end) as procedure_code_4\n , max(case when lower(column_name) = 'procedure_code_5' then normalized_code else null end) as procedure_code_5\n , max(case when lower(column_name) = 'procedure_code_6' then normalized_code else null end) as procedure_code_6\n , max(case when lower(column_name) = 'procedure_code_7' then normalized_code else null end) as procedure_code_7\n , max(case when lower(column_name) = 'procedure_code_8' then normalized_code else null end) as procedure_code_8\n , max(case when lower(column_name) = 'procedure_code_9' then normalized_code else null end) as procedure_code_9\n , max(case when lower(column_name) = 'procedure_code_10' then normalized_code else null end) as procedure_code_10\n , max(case when lower(column_name) = 'procedure_code_11' then normalized_code else null end) as procedure_code_11\n , max(case when lower(column_name) = 'procedure_code_12' then normalized_code else null end) as procedure_code_12\n , max(case when lower(column_name) = 'procedure_code_13' then normalized_code else null end) as procedure_code_13\n , max(case when lower(column_name) = 'procedure_code_14' then normalized_code else null end) as procedure_code_14\n , max(case when lower(column_name) = 'procedure_code_15' then normalized_code else null end) as procedure_code_15\n , max(case when lower(column_name) = 'procedure_code_16' then normalized_code else null end) as procedure_code_16\n , max(case when lower(column_name) = 'procedure_code_17' then normalized_code else null end) as procedure_code_17\n , max(case when lower(column_name) = 'procedure_code_18' then normalized_code else null end) as procedure_code_18\n , max(case when lower(column_name) = 'procedure_code_19' then normalized_code else null end) as procedure_code_19\n , max(case when lower(column_name) = 'procedure_code_20' then normalized_code else null end) as procedure_code_20\n , max(case when lower(column_name) = 'procedure_code_21' then normalized_code else null end) as procedure_code_21\n , max(case when lower(column_name) = 'procedure_code_22' then normalized_code else null end) as procedure_code_22\n , max(case when lower(column_name) = 'procedure_code_23' then normalized_code else null end) as procedure_code_23\n , max(case when lower(column_name) = 'procedure_code_24' then normalized_code else null end) as procedure_code_24\n , max(case when lower(column_name) = 'procedure_code_25' then normalized_code else null end) as procedure_code_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.683571Z", "completed_at": "2024-10-22T19:20:33.694013Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.695058Z", "completed_at": "2024-10-22T19:20:33.695065Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012647867202758789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_final", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_date_1' then normalized_code else null end) as procedure_date_1\n , max(case when lower(column_name) = 'procedure_date_2' then normalized_code else null end) as procedure_date_2\n , max(case when lower(column_name) = 'procedure_date_3' then normalized_code else null end) as procedure_date_3\n , max(case when lower(column_name) = 'procedure_date_4' then normalized_code else null end) as procedure_date_4\n , max(case when lower(column_name) = 'procedure_date_5' then normalized_code else null end) as procedure_date_5\n , max(case when lower(column_name) = 'procedure_date_6' then normalized_code else null end) as procedure_date_6\n , max(case when lower(column_name) = 'procedure_date_7' then normalized_code else null end) as procedure_date_7\n , max(case when lower(column_name) = 'procedure_date_8' then normalized_code else null end) as procedure_date_8\n , max(case when lower(column_name) = 'procedure_date_9' then normalized_code else null end) as procedure_date_9\n , max(case when lower(column_name) = 'procedure_date_10' then normalized_code else null end) as procedure_date_10\n , max(case when lower(column_name) = 'procedure_date_11' then normalized_code else null end) as procedure_date_11\n , max(case when lower(column_name) = 'procedure_date_12' then normalized_code else null end) as procedure_date_12\n , max(case when lower(column_name) = 'procedure_date_13' then normalized_code else null end) as procedure_date_13\n , max(case when lower(column_name) = 'procedure_date_14' then normalized_code else null end) as procedure_date_14\n , max(case when lower(column_name) = 'procedure_date_15' then normalized_code else null end) as procedure_date_15\n , max(case when lower(column_name) = 'procedure_date_16' then normalized_code else null end) as procedure_date_16\n , max(case when lower(column_name) = 'procedure_date_17' then normalized_code else null end) as procedure_date_17\n , max(case when lower(column_name) = 'procedure_date_18' then normalized_code else null end) as procedure_date_18\n , max(case when lower(column_name) = 'procedure_date_19' then normalized_code else null end) as procedure_date_19\n , max(case when lower(column_name) = 'procedure_date_20' then normalized_code else null end) as procedure_date_20\n , max(case when lower(column_name) = 'procedure_date_21' then normalized_code else null end) as procedure_date_21\n , max(case when lower(column_name) = 'procedure_date_22' then normalized_code else null end) as procedure_date_22\n , max(case when lower(column_name) = 'procedure_date_23' then normalized_code else null end) as procedure_date_23\n , max(case when lower(column_name) = 'procedure_date_24' then normalized_code else null end) as procedure_date_24\n , max(case when lower(column_name) = 'procedure_date_25' then normalized_code else null end) as procedure_date_25\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.690775Z", "completed_at": "2024-10-22T19:20:33.696360Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.697289Z", "completed_at": "2024-10-22T19:20:33.697292Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0072479248046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__eligibility", "compiled": true, "compiled_code": "\n\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_eligibility", "relation_name": "cms_synthetic.core.eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.699256Z", "completed_at": "2024-10-22T19:20:33.706187Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.706429Z", "completed_at": "2024-10-22T19:20:33.706434Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008873939514160156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__patient", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_patient\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_patient\n\n", "relation_name": "cms_synthetic.core.patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.717899Z", "completed_at": "2024-10-22T19:20:33.722487Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.723039Z", "completed_at": "2024-10-22T19:20:33.723043Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006104946136474609, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__stg_pharmacy_claim", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM cms_synthetic.core.pharmacy_claim mc\nleft join cms_synthetic.reference_data.calendar c on coalesce(mc.paid_date,mc.dispensing_date) = c.full_date", "relation_name": "cms_synthetic.data_quality.mart_review__stg_pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.730210Z", "completed_at": "2024-10-22T19:20:33.733188Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.733671Z", "completed_at": "2024-10-22T19:20:33.733674Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009531974792480469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c", "compiled": true, "compiled_code": "\n \n \n\nselect\n pharmacy_claim_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.pharmacy_claim\nwhere pharmacy_claim_id is not null\ngroup by pharmacy_claim_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.734615Z", "completed_at": "2024-10-22T19:20:33.743177Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.743440Z", "completed_at": "2024-10-22T19:20:33.743463Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010097265243530273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_for_pbi", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_claims_for_pbi\n\nunion all\n\nSELECT\n data_source,\n field_name,\n table_name,\n 'CLINICAL' AS claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.data_quality.data_quality_clinical_for_pbi\n\n", "relation_name": "cms_synthetic.data_quality.data_quality_for_pbi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.740489Z", "completed_at": "2024-10-22T19:20:33.744052Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.744510Z", "completed_at": "2024-10-22T19:20:33.744514Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004611968994140625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "compiled": true, "compiled_code": "\n\n\n\nwith results as (\n\n select distinct\n table_name as input_layer_table_name\n , claim_type\n , field_name\n , cast(NULL as TEXT) AS mart_name\n from cms_synthetic.data_quality.data_quality_detail\n\n union all\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n from cms_synthetic.data_quality._value_set_crosswalk_field_to_mart\n\n)\n\n, final as (\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n , DENSE_RANK () OVER (ORDER BY input_layer_table_name, claim_type, field_name) as table_claim_type_field_sk\n\t, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from results\n group by\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n\n)\n\nselect * from final", "relation_name": "cms_synthetic.dbt_tom.data_quality__crosswalk_field_to_mart_sk"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.745497Z", "completed_at": "2024-10-22T19:20:33.767707Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.785004Z", "completed_at": "2024-10-22T19:20:33.785013Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.040841102600097656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__quality_trend", "compiled": true, "compiled_code": "\n\n\nwith cte as (\nselect try_cast( d.source_date as date ) as source_date_type\n ,summary_sk\n ,SUM(CASE WHEN bucket_name = 'valid' THEN 1 ELSE 0 END) as valid_num\n ,SUM(CASE WHEN bucket_name <> 'null' THEN 1 ELSE 0 END) as fill_num\n ,COUNT(drill_down_value) as denom\nfrom cms_synthetic.data_quality.data_quality_detail d\ngroup by\n try_cast( d.source_date as date )\n ,summary_sk\n\n)\n\nselect\n c.first_day_of_month\n , summary_sk\n , sum(valid_num) as valid_num\n , sum(fill_num) as fill_num\n , sum(denom) as denom\nfrom cte\nleft join cms_synthetic.reference_data.calendar c on cte.source_date_type = c.full_date\ngroup by\n c.first_day_of_month\n , summary_sk", "relation_name": "cms_synthetic.data_quality.quality_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.748108Z", "completed_at": "2024-10-22T19:20:33.888010Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.888352Z", "completed_at": "2024-10-22T19:20:33.888359Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.14081215858459473, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__medical_claim", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n\tcast(med.claim_id as TEXT ) as claim_id\n\t, cast(med.claim_line_number as int ) as claim_line_number\n\t, cast(med.claim_type as TEXT ) as claim_type\n\t, cast(med.patient_id as TEXT ) as patient_id\n\t, cast(med.member_id as TEXT ) as member_id\n\t, cast(med.payer as TEXT ) as payer\n , cast(med.plan as TEXT ) as plan\n\t, cast(coalesce(dates.minimum_claim_start_date, undetermined.claim_start_date) as date ) as claim_start_date\n\t, cast(coalesce(dates.maximum_claim_end_date, undetermined.claim_start_date) as date ) as claim_end_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_start_date, undetermined.claim_line_start_date) as date ) as claim_line_start_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_end_date, undetermined.claim_line_end_date) as date ) as claim_line_end_date\n\t, cast(coalesce(dates.minimum_admission_date, undetermined.admission_date) as date ) as admission_date\n\t, cast(coalesce(dates.maximum_discharge_date, undetermined.discharge_date) as date ) as discharge_date\n\t, cast(coalesce(ad_source.normalized_code, undetermined.admit_source_code) as TEXT ) as admit_source_code\n , cast(coalesce(ad_source.normalized_description, undetermined.admit_source_description) as TEXT ) as admit_source_description\n\t, cast(coalesce(ad_type.normalized_code, undetermined.admit_type_code) as TEXT ) as admit_type_code\n , cast(coalesce(ad_type.normalized_description, undetermined.admit_type_description) as TEXT ) as admit_type_description\n\t, cast(coalesce(disch_disp.normalized_code, undetermined.discharge_disposition_code) as TEXT ) as discharge_disposition_code\n , cast(coalesce(disch_disp.normalized_description, undetermined.discharge_disposition_description) as TEXT ) as discharge_disposition_description\n\t, cast(coalesce(pos.normalized_code, undetermined.place_of_service_code) as TEXT ) as place_of_service_code\n , cast(coalesce(pos.normalized_description, undetermined.place_of_service_description) as TEXT ) as place_of_service_description\n\t, cast(coalesce(bill.normalized_code, undetermined.bill_type_code) as TEXT ) as bill_type_code\n , cast(coalesce(bill.normalized_description, undetermined.bill_type_description) as TEXT ) as bill_type_description\n\t, cast(coalesce(ms.normalized_code, undetermined.ms_drg_code) as TEXT ) as ms_drg_code\n , cast(coalesce(ms.normalized_description, undetermined.ms_drg_description) as TEXT ) as ms_drg_description\n\t, cast(coalesce(apr.normalized_code, undetermined.apr_drg_code) as TEXT ) as apr_drg_code\n , cast(coalesce(apr.normalized_description, undetermined.apr_drg_description) as TEXT ) as apr_drg_description\n\t, cast(coalesce(rev.normalized_code, undetermined.revenue_center_code) as TEXT ) as revenue_center_code\n , cast(coalesce(rev.normalized_description, undetermined.revenue_center_description) as TEXT ) as revenue_center_description\n\t, cast(med.service_unit_quantity as TEXT ) as service_unit_quantity\n\t, cast(med.hcpcs_code as TEXT ) as hcpcs_code\n\t, cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n\t, cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n\t, cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n\t, cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n\t, cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n\t, cast(coalesce(med_npi.normalized_rendering_npi, undetermined.rendering_npi) as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(coalesce(med_npi.normalized_rendering_name, undetermined.rendering_name) as TEXT ) as rendering_name\n\t, cast(coalesce(med_npi.normalized_billing_npi, undetermined.billing_npi) as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(coalesce(med_npi.normalized_billing_name, undetermined.billing_name) as TEXT ) as billing_name\n\t, cast(coalesce(med_npi.normalized_facility_npi, undetermined.facility_npi) as TEXT ) as facility_id\n\t, cast(coalesce(med_npi.normalized_facility_name, undetermined.facility_name) as TEXT ) as facility_name\n , cast(med.paid_date as date ) as paid_date\n\t, cast(med.paid_amount as numeric(28,6) ) as paid_amount\n\t, cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n\t, cast(med.charge_amount as numeric(28,6) ) as charge_amount\n\t, cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n\t, cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n\t, cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n\t, cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n\t, cast(med.diagnosis_code_type as TEXT ) as diagnosis_code_type\n\t, cast(coalesce(dx_code.diagnosis_code_1, undetermined.diagnosis_code_1) as TEXT ) as diagnosis_code_1\n\t, cast(coalesce(dx_code.diagnosis_code_2, undetermined.diagnosis_code_2) as TEXT ) as diagnosis_code_2\n\t, cast(coalesce(dx_code.diagnosis_code_3, undetermined.diagnosis_code_3) as TEXT ) as diagnosis_code_3\n\t, cast(coalesce(dx_code.diagnosis_code_4, undetermined.diagnosis_code_4) as TEXT ) as diagnosis_code_4\n\t, cast(coalesce(dx_code.diagnosis_code_5, undetermined.diagnosis_code_5) as TEXT ) as diagnosis_code_5\n\t, cast(coalesce(dx_code.diagnosis_code_6, undetermined.diagnosis_code_6) as TEXT ) as diagnosis_code_6\n\t, cast(coalesce(dx_code.diagnosis_code_7, undetermined.diagnosis_code_7) as TEXT ) as diagnosis_code_7\n\t, cast(coalesce(dx_code.diagnosis_code_8, undetermined.diagnosis_code_8) as TEXT ) as diagnosis_code_8\n\t, cast(coalesce(dx_code.diagnosis_code_9, undetermined.diagnosis_code_9) as TEXT ) as diagnosis_code_9\n\t, cast(coalesce(dx_code.diagnosis_code_10, undetermined.diagnosis_code_10) as TEXT ) as diagnosis_code_10\n\t, cast(coalesce(dx_code.diagnosis_code_11, undetermined.diagnosis_code_11) as TEXT ) as diagnosis_code_11\n\t, cast(coalesce(dx_code.diagnosis_code_12, undetermined.diagnosis_code_12) as TEXT ) as diagnosis_code_12\n\t, cast(coalesce(dx_code.diagnosis_code_13, undetermined.diagnosis_code_13) as TEXT ) as diagnosis_code_13\n\t, cast(coalesce(dx_code.diagnosis_code_14, undetermined.diagnosis_code_14) as TEXT ) as diagnosis_code_14\n\t, cast(coalesce(dx_code.diagnosis_code_15, undetermined.diagnosis_code_15) as TEXT ) as diagnosis_code_15\n\t, cast(coalesce(dx_code.diagnosis_code_16, undetermined.diagnosis_code_16) as TEXT ) as diagnosis_code_16\n\t, cast(coalesce(dx_code.diagnosis_code_17, undetermined.diagnosis_code_17) as TEXT ) as diagnosis_code_17\n\t, cast(coalesce(dx_code.diagnosis_code_18, undetermined.diagnosis_code_18) as TEXT ) as diagnosis_code_18\n\t, cast(coalesce(dx_code.diagnosis_code_19, undetermined.diagnosis_code_19) as TEXT ) as diagnosis_code_19\n\t, cast(coalesce(dx_code.diagnosis_code_20, undetermined.diagnosis_code_20) as TEXT ) as diagnosis_code_20\n\t, cast(coalesce(dx_code.diagnosis_code_21, undetermined.diagnosis_code_21) as TEXT ) as diagnosis_code_21\n\t, cast(coalesce(dx_code.diagnosis_code_22, undetermined.diagnosis_code_22) as TEXT ) as diagnosis_code_22\n\t, cast(coalesce(dx_code.diagnosis_code_23, undetermined.diagnosis_code_23) as TEXT ) as diagnosis_code_23\n\t, cast(coalesce(dx_code.diagnosis_code_24, undetermined.diagnosis_code_24) as TEXT ) as diagnosis_code_24\n\t, cast(coalesce(dx_code.diagnosis_code_25, undetermined.diagnosis_code_25) as TEXT ) as diagnosis_code_25\n\t, cast(coalesce(poa.diagnosis_poa_1, undetermined.diagnosis_poa_1) as TEXT ) as diagnosis_poa_1\n\t, cast(coalesce(poa.diagnosis_poa_2, undetermined.diagnosis_poa_2) as TEXT ) as diagnosis_poa_2\n\t, cast(coalesce(poa.diagnosis_poa_3, undetermined.diagnosis_poa_3) as TEXT ) as diagnosis_poa_3\n\t, cast(coalesce(poa.diagnosis_poa_4, undetermined.diagnosis_poa_4) as TEXT ) as diagnosis_poa_4\n\t, cast(coalesce(poa.diagnosis_poa_5, undetermined.diagnosis_poa_5) as TEXT ) as diagnosis_poa_5\n\t, cast(coalesce(poa.diagnosis_poa_6, undetermined.diagnosis_poa_6) as TEXT ) as diagnosis_poa_6\n\t, cast(coalesce(poa.diagnosis_poa_7, undetermined.diagnosis_poa_7) as TEXT ) as diagnosis_poa_7\n\t, cast(coalesce(poa.diagnosis_poa_8, undetermined.diagnosis_poa_8) as TEXT ) as diagnosis_poa_8\n\t, cast(coalesce(poa.diagnosis_poa_9, undetermined.diagnosis_poa_9) as TEXT ) as diagnosis_poa_9\n\t, cast(coalesce(poa.diagnosis_poa_10, undetermined.diagnosis_poa_10) as TEXT ) as diagnosis_poa_10\n\t, cast(coalesce(poa.diagnosis_poa_11, undetermined.diagnosis_poa_11) as TEXT ) as diagnosis_poa_11\n\t, cast(coalesce(poa.diagnosis_poa_12, undetermined.diagnosis_poa_12) as TEXT ) as diagnosis_poa_12\n\t, cast(coalesce(poa.diagnosis_poa_13, undetermined.diagnosis_poa_13) as TEXT ) as diagnosis_poa_13\n\t, cast(coalesce(poa.diagnosis_poa_14, undetermined.diagnosis_poa_14) as TEXT ) as diagnosis_poa_14\n\t, cast(coalesce(poa.diagnosis_poa_15, undetermined.diagnosis_poa_15) as TEXT ) as diagnosis_poa_15\n\t, cast(coalesce(poa.diagnosis_poa_16, undetermined.diagnosis_poa_16) as TEXT ) as diagnosis_poa_16\n\t, cast(coalesce(poa.diagnosis_poa_17, undetermined.diagnosis_poa_17) as TEXT ) as diagnosis_poa_17\n\t, cast(coalesce(poa.diagnosis_poa_18, undetermined.diagnosis_poa_18) as TEXT ) as diagnosis_poa_18\n\t, cast(coalesce(poa.diagnosis_poa_19, undetermined.diagnosis_poa_19) as TEXT ) as diagnosis_poa_19\n\t, cast(coalesce(poa.diagnosis_poa_20, undetermined.diagnosis_poa_20) as TEXT ) as diagnosis_poa_20\n\t, cast(coalesce(poa.diagnosis_poa_21, undetermined.diagnosis_poa_21) as TEXT ) as diagnosis_poa_21\n\t, cast(coalesce(poa.diagnosis_poa_22, undetermined.diagnosis_poa_22) as TEXT ) as diagnosis_poa_22\n\t, cast(coalesce(poa.diagnosis_poa_23, undetermined.diagnosis_poa_23) as TEXT ) as diagnosis_poa_23\n\t, cast(coalesce(poa.diagnosis_poa_24, undetermined.diagnosis_poa_24) as TEXT ) as diagnosis_poa_24\n\t, cast(coalesce(poa.diagnosis_poa_25, undetermined.diagnosis_poa_25) as TEXT ) as diagnosis_poa_25\n\t, cast(med.procedure_code_type as TEXT ) as procedure_code_type\n\t, cast(coalesce(px_code.procedure_code_1, undetermined.procedure_code_1) as TEXT ) as procedure_code_1\n\t, cast(coalesce(px_code.procedure_code_2, undetermined.procedure_code_2) as TEXT ) as procedure_code_2\n\t, cast(coalesce(px_code.procedure_code_3, undetermined.procedure_code_3) as TEXT ) as procedure_code_3\n\t, cast(coalesce(px_code.procedure_code_4, undetermined.procedure_code_4) as TEXT ) as procedure_code_4\n\t, cast(coalesce(px_code.procedure_code_5, undetermined.procedure_code_5) as TEXT ) as procedure_code_5\n\t, cast(coalesce(px_code.procedure_code_6, undetermined.procedure_code_6) as TEXT ) as procedure_code_6\n\t, cast(coalesce(px_code.procedure_code_7, undetermined.procedure_code_7) as TEXT ) as procedure_code_7\n\t, cast(coalesce(px_code.procedure_code_8, undetermined.procedure_code_8) as TEXT ) as procedure_code_8\n\t, cast(coalesce(px_code.procedure_code_9, undetermined.procedure_code_9) as TEXT ) as procedure_code_9\n\t, cast(coalesce(px_code.procedure_code_10, undetermined.procedure_code_10) as TEXT ) as procedure_code_10\n\t, cast(coalesce(px_code.procedure_code_11, undetermined.procedure_code_11) as TEXT ) as procedure_code_11\n\t, cast(coalesce(px_code.procedure_code_12, undetermined.procedure_code_12) as TEXT ) as procedure_code_12\n\t, cast(coalesce(px_code.procedure_code_13, undetermined.procedure_code_13) as TEXT ) as procedure_code_13\n\t, cast(coalesce(px_code.procedure_code_14, undetermined.procedure_code_14) as TEXT ) as procedure_code_14\n\t, cast(coalesce(px_code.procedure_code_15, undetermined.procedure_code_15) as TEXT ) as procedure_code_15\n\t, cast(coalesce(px_code.procedure_code_16, undetermined.procedure_code_16) as TEXT ) as procedure_code_16\n\t, cast(coalesce(px_code.procedure_code_17, undetermined.procedure_code_17) as TEXT ) as procedure_code_17\n\t, cast(coalesce(px_code.procedure_code_18, undetermined.procedure_code_18) as TEXT ) as procedure_code_18\n\t, cast(coalesce(px_code.procedure_code_19, undetermined.procedure_code_19) as TEXT ) as procedure_code_19\n\t, cast(coalesce(px_code.procedure_code_20, undetermined.procedure_code_20) as TEXT ) as procedure_code_20\n\t, cast(coalesce(px_code.procedure_code_21, undetermined.procedure_code_21) as TEXT ) as procedure_code_21\n\t, cast(coalesce(px_code.procedure_code_22, undetermined.procedure_code_22) as TEXT ) as procedure_code_22\n\t, cast(coalesce(px_code.procedure_code_23, undetermined.procedure_code_23) as TEXT ) as procedure_code_23\n\t, cast(coalesce(px_code.procedure_code_24, undetermined.procedure_code_24) as TEXT ) as procedure_code_24\n\t, cast(coalesce(px_code.procedure_code_25, undetermined.procedure_code_25) as TEXT ) as procedure_code_25\n\t, cast(coalesce(px_date.procedure_date_1, undetermined.procedure_date_1) as date ) as procedure_date_1\n\t, cast(coalesce(px_date.procedure_date_2, undetermined.procedure_date_2) as date ) as procedure_date_2\n\t, cast(coalesce(px_date.procedure_date_3, undetermined.procedure_date_3) as date ) as procedure_date_3\n\t, cast(coalesce(px_date.procedure_date_4, undetermined.procedure_date_4) as date ) as procedure_date_4\n\t, cast(coalesce(px_date.procedure_date_5, undetermined.procedure_date_5) as date ) as procedure_date_5\n\t, cast(coalesce(px_date.procedure_date_6, undetermined.procedure_date_6) as date ) as procedure_date_6\n\t, cast(coalesce(px_date.procedure_date_7, undetermined.procedure_date_7) as date ) as procedure_date_7\n\t, cast(coalesce(px_date.procedure_date_8, undetermined.procedure_date_8) as date ) as procedure_date_8\n\t, cast(coalesce(px_date.procedure_date_9, undetermined.procedure_date_9) as date ) as procedure_date_9\n\t, cast(coalesce(px_date.procedure_date_10, undetermined.procedure_date_10) as date ) as procedure_date_10\n\t, cast(coalesce(px_date.procedure_date_11, undetermined.procedure_date_11) as date ) as procedure_date_11\n\t, cast(coalesce(px_date.procedure_date_12, undetermined.procedure_date_12) as date ) as procedure_date_12\n\t, cast(coalesce(px_date.procedure_date_13, undetermined.procedure_date_13) as date ) as procedure_date_13\n\t, cast(coalesce(px_date.procedure_date_14, undetermined.procedure_date_14) as date ) as procedure_date_14\n\t, cast(coalesce(px_date.procedure_date_15, undetermined.procedure_date_15) as date ) as procedure_date_15\n\t, cast(coalesce(px_date.procedure_date_16, undetermined.procedure_date_16) as date ) as procedure_date_16\n\t, cast(coalesce(px_date.procedure_date_17, undetermined.procedure_date_17) as date ) as procedure_date_17\n\t, cast(coalesce(px_date.procedure_date_18, undetermined.procedure_date_18) as date ) as procedure_date_18\n\t, cast(coalesce(px_date.procedure_date_19, undetermined.procedure_date_19) as date ) as procedure_date_19\n\t, cast(coalesce(px_date.procedure_date_20, undetermined.procedure_date_20) as date ) as procedure_date_20\n\t, cast(coalesce(px_date.procedure_date_21, undetermined.procedure_date_21) as date ) as procedure_date_21\n\t, cast(coalesce(px_date.procedure_date_22, undetermined.procedure_date_22) as date ) as procedure_date_22\n\t, cast(coalesce(px_date.procedure_date_23, undetermined.procedure_date_23) as date ) as procedure_date_23\n\t, cast(coalesce(px_date.procedure_date_24, undetermined.procedure_date_24) as date ) as procedure_date_24\n\t, cast(coalesce(px_date.procedure_date_25, undetermined.procedure_date_25) as date ) as procedure_date_25\n\t, cast(med.data_source as TEXT ) as data_source\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_admit_source_final ad_source\n on med.claim_id = ad_source.claim_id\n and med.data_source = ad_source.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_admit_type_final ad_type\n on med.claim_id = ad_type.claim_id\n and med.data_source = ad_type.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_apr_drg_final apr\n on med.claim_id = apr.claim_id\n and med.data_source = apr.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_bill_type_final bill\n on med.claim_id = bill.claim_id\n and med.data_source = bill.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_medical_claim_date_normalize claim_line_dates\n on med.claim_id = claim_line_dates.claim_id\n and med.claim_line_number = claim_line_dates.claim_line_number\n and med.data_source = claim_line_dates.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_medical_date_aggregation dates\n on med.claim_id = dates.claim_id\n and med.data_source = dates.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_medical_npi_normalize med_npi\n on med.claim_id = med_npi.claim_id\n and med.claim_line_number = med_npi.claim_line_number\n and med.data_source = med_npi.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_discharge_disposition_final disch_disp\n on med.claim_id = disch_disp.claim_id\n and med.data_source = disch_disp.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_ms_drg_final ms\n on med.claim_id = ms.claim_id\n and med.data_source = ms.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_place_of_service_normalize pos\n on med.claim_id = pos.claim_id\n and med.claim_line_number = pos.claim_line_number\n and med.data_source = pos.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_diagnosis_code_final dx_code\n on med.claim_id = dx_code.claim_id\n and med.data_source = dx_code.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_present_on_admit_final poa\n on med.claim_id = poa.claim_id\n and med.data_source = poa.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_procedure_code_final px_code\n on med.claim_id = px_code.claim_id\n and med.data_source = px_code.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_procedure_date_final px_date\n on med.claim_id = px_date.claim_id\n and med.data_source = px_date.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_revenue_center_normalize rev\n on med.claim_id = rev.claim_id\n and med.claim_line_number = rev.claim_line_number\n and med.data_source = rev.data_source\nleft join cms_synthetic.claims_preprocessing._int_normalized_input_undetermined_claim_type undetermined\n on med.claim_id = undetermined.claim_id\n and med.claim_line_number = undetermined.claim_line_number\n and med.data_source = undetermined.data_source", "relation_name": "cms_synthetic.claims_preprocessing.normalized_input_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.891209Z", "completed_at": "2024-10-22T19:20:33.903760Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.904074Z", "completed_at": "2024-10-22T19:20:33.904081Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013880014419555664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__member_months", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__financial_pmpm__stg_provider_attribution as (\n\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution\n), month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from cms_synthetic.reference_data.calendar\n group by year, month, year_month\n),\n\n\nfinal_before_attribution_fields as (\nselect distinct\n a.patient_id\n , year_month\n , a.payer\n , a.plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date\n),\n\n\nadd_attribution_fields as (\nselect\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.tuva_last_run\n \n , b.payer_attributed_provider\n , b.payer_attributed_provider_practice\n , b.payer_attributed_provider_organization\n , b.payer_attributed_provider_lob\n , b.custom_attributed_provider\n , b.custom_attributed_provider_practice\n , b.custom_attributed_provider_organization\n , b.custom_attributed_provider_lob\n\nfrom final_before_attribution_fields a\nleft join __dbt__cte__financial_pmpm__stg_provider_attribution b\non a.patient_id = b.patient_id\nand a.year_month = b.year_month\nand a.payer = b.payer\nand a.plan = b.plan\nand a.data_source = b.data_source\n)\n\n\nselect *\nfrom add_attribution_fields", "relation_name": "cms_synthetic.core.member_months"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.906417Z", "completed_at": "2024-10-22T19:20:33.911293Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.911815Z", "completed_at": "2024-10-22T19:20:33.911819Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0065212249755859375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a", "compiled": true, "compiled_code": "\n \n \n\nselect\n eligibility_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.eligibility\nwhere eligibility_id is not null\ngroup by eligibility_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.928738Z", "completed_at": "2024-10-22T19:20:33.934479Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.934751Z", "completed_at": "2024-10-22T19:20:33.934757Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0070149898529052734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient", "compiled": true, "compiled_code": "\n\nSELECT *,\n patient_id || '|' || data_source as patient_data_source_key\nFROM cms_synthetic.core.patient", "relation_name": "cms_synthetic.data_quality.mart_review__patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.939777Z", "completed_at": "2024-10-22T19:20:33.942666Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.943183Z", "completed_at": "2024-10-22T19:20:33.943187Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006922006607055664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.patient\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.944416Z", "completed_at": "2024-10-22T19:20:33.964318Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.964569Z", "completed_at": "2024-10-22T19:20:33.964574Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021153926849365234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_medications", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom cms_synthetic.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , coalesce(dispensing_date, paid_date) as dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, ndc_medications as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where ndc_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'ndc'\n\n)\n\n, rxnorm_medications as (\n\n select\n patient_id\n , dispensing_date\n , rxnorm_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where rxnorm_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'rxnorm'\n\n)\n\n, unioned as (\n\n select * from pharmacy_claims\n union all\n select * from ndc_medications\n union all\n select * from rxnorm_medications\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n , cast(code_system as TEXT) as code_system\n , cast(data_source as TEXT) as data_source\n from unioned\n\n)\n\nselect\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_all_medications"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.956588Z", "completed_at": "2024-10-22T19:20:33.965401Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.965854Z", "completed_at": "2024-10-22T19:20:33.965858Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02171778678894043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_claims_current_cost", "compiled": true, "compiled_code": "\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n) /* All claims, current cost*/\n\nselect \n p.ndc_code\n , p.ndc_description\n , p.data_source\n , p.rxcui\n , r.brand_vs_generic\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end as generic_available\n , sum(paid_amount) as paid_amount\n , count(distinct claim_id) as claim_count\n , sum(paid_amount) / count(distinct claim_id) as cost_per_claim\n , sum(quantity) as total_units\n , case \n when sum(quantity) > 0 \n and sum(paid_amount) > 0 \n then sum(paid_amount) / sum(quantity) \n else null \n end as cost_per_unit\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\nleft join cms_synthetic.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\nleft join cms_synthetic.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\nwhere p.ndc_code is not null\ngroup by \n case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end\n , r.brand_vs_generic\n , p.ndc_code\n , p.rxcui\n , p.ndc_description\n , p.data_source", "relation_name": "cms_synthetic.pharmacy._int_claims_current_cost"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.966219Z", "completed_at": "2024-10-22T19:20:33.973777Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.975366Z", "completed_at": "2024-10-22T19:20:33.975373Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010241031646728516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__summary", "compiled": true, "compiled_code": "\n\nWITH CTE AS (\n SELECT DISTINCT fm.field_name\n ,fm.input_layer_table_name\n ,fm.claim_type\n ,table_claim_type_field_sk\n FROM cms_synthetic.dbt_tom.data_quality__crosswalk_field_to_mart_sk fm\n)\n\nSELECT\n summary_sk,\n fm.table_claim_type_field_sk,\n data_source,\n x.table_name,\n x.claim_type,\n x.field_name,\n sct.red,\n sct.green,\n sum(case when bucket_name = 'valid' then 1 else 0 end) as valid_num,\n sum(case when bucket_name <> 'null' then 1 else 0 end) as fill_num,\n count(drill_down_value) as denom,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM\n cms_synthetic.data_quality.data_quality_detail x\nLEFT JOIN CTE fm\n on x.field_name = fm.field_name\n and\n fm.input_layer_table_name = x.table_name\n and\n fm.claim_type = x.claim_type\nLEFT JOIN cms_synthetic.data_quality._value_set_crosswalk_field_info sct\n on x.field_name = sct.field_name\n and\n sct.input_layer_table_name = x.table_name\n and\n sct.claim_type = x.claim_type\nGROUP BY\n summary_sk,\n data_source,\n fm.table_claim_type_field_sk,\n x.claim_type,\n x.table_name,\n x.field_name,\n sct.red,\n sct.green", "relation_name": "cms_synthetic.data_quality.summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.971443Z", "completed_at": "2024-10-22T19:20:33.975753Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.979364Z", "completed_at": "2024-10-22T19:20:33.979369Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008435964584350586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__patient_data_source_id", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct patient_id\n,data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\n\n\nunion distinct\n\n\nselect distinct patient_id\n,data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\npatient_id\n,data_source\n,dense_rank() over (order by concat(patient_id,data_source)) as patient_data_source_id\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing.encounters__patient_data_source_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.982761Z", "completed_at": "2024-10-22T19:20:33.997869Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.998127Z", "completed_at": "2024-10-22T19:20:33.998133Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017992258071899414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_medical_claim", "compiled": true, "compiled_code": "\n\nselect\n m.apr_drg_code\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , rend.primary_specialty_description as rend_primary_specialty_description\n , n.modality\n , m.data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim m\nleft join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join cms_synthetic.terminology.provider p on m.facility_id = p.npi\nleft join cms_synthetic.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join cms_synthetic.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join cms_synthetic.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join cms_synthetic.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join cms_synthetic.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join cms_synthetic.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join cms_synthetic.terminology.provider rend on m.rendering_id = rend.npi", "relation_name": "cms_synthetic.dbt_tom.service_category__stg_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.989316Z", "completed_at": "2024-10-22T19:20:33.998933Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:33.999375Z", "completed_at": "2024-10-22T19:20:33.999380Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01698899269104004, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n claim_id, claim_line_number\n from cms_synthetic.claims_preprocessing.normalized_input_medical_claim\n group by claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.000322Z", "completed_at": "2024-10-22T19:20:34.008672Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.008922Z", "completed_at": "2024-10-22T19:20:34.008928Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009866952896118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "compiled": true, "compiled_code": "\n\nwith\n\ndate_int as (\n select distinct\n replace(year_month,'-','') yyyymm\n , first_day_of_month\n from cms_synthetic.reference_data.calendar as c\n)\n\nselect \n data_source\n , patient_id\n , first_day_of_month\n , d.yyyymm as year_month\n\nfrom \n cms_synthetic.core.member_months mm\ninner join date_int d on mm.year_month = d.yyyymm", "relation_name": "cms_synthetic.ahrq_measures._stg_pqi_member_months"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.003432Z", "completed_at": "2024-10-22T19:20:34.010223Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.013280Z", "completed_at": "2024-10-22T19:20:34.013285Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010468244552612305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "compiled": true, "compiled_code": "\n\n\nwith claim_dates as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , coalesce(claim_line_start_date, claim_start_date, admission_date) as inferred_claim_start_date\n , coalesce(claim_line_end_date, claim_end_date, discharge_date) as inferred_claim_end_date\n , case\n when claim_line_start_date is not null then 'claim_line_start_date'\n when claim_line_start_date is null and claim_start_date is not null then 'claim_start_date'\n when claim_line_start_date is null and claim_start_date is null and admission_date is not null then 'admission_date'\n end as inferred_claim_start_column_used\n , case\n when claim_line_end_date is not null then 'claim_line_end_date'\n when claim_line_end_date is null and claim_end_date is not null then 'claim_end_date'\n when claim_line_end_date is null and claim_end_date is null and discharge_date is not null then 'discharge_date'\n end as inferred_claim_end_column_used\n from cms_synthetic.claims_preprocessing.normalized_input_medical_claim\n)\n\n, claim_year_month as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , inferred_claim_start_date\n , inferred_claim_end_date\n , inferred_claim_start_column_used\n , inferred_claim_end_column_used\n\n , date_part('year', inferred_claim_start_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_start_date),\n 2\n )\n end as inferred_claim_start_year_month\n\n , date_part('year', inferred_claim_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_end_date),\n 2\n )\n end as inferred_claim_end_year_month\n\nfrom claim_dates\n\n)\n\nselect distinct\n claim.claim_id\n , claim.claim_line_number\n , claim.patient_id\n , claim.payer\n , claim.plan\n , claim.inferred_claim_start_year_month\n , claim.inferred_claim_end_year_month\n , claim.inferred_claim_start_column_used\n , claim.inferred_claim_end_column_used\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom cms_synthetic.core.member_months mm\ninner join claim_year_month claim\n on mm.patient_id = claim.patient_id\n and mm.payer = claim.payer\n and mm.plan = claim.plan\n and mm.year_month >= claim.inferred_claim_start_year_month\n and mm.year_month <= claim.inferred_claim_end_year_month", "relation_name": "cms_synthetic.claims_preprocessing.flag_claims_with_enrollment"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.014571Z", "completed_at": "2024-10-22T19:20:34.018408Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.018887Z", "completed_at": "2024-10-22T19:20:34.018892Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004836082458496094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__stg_member_month", "compiled": true, "compiled_code": "\n\nwith cte as\n(\nselect distinct year_month_int\n,full_date\nfrom cms_synthetic.reference_data.calendar c\nwhere day = 1\n\n)\n\nselect mm.*\n,c.year_month_int\n,c.full_date as year_month_date\nFROM cms_synthetic.core.member_months mm\nleft join cte c on cast(mm.year_month as int) = c.year_month_int", "relation_name": "cms_synthetic.data_quality.mart_review__stg_member_month"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.019280Z", "completed_at": "2024-10-22T19:20:34.028515Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.028847Z", "completed_at": "2024-10-22T19:20:34.028853Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010761022567749023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) /* Exclude patients with missing age */\nselect \n data_source\n , patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere birth_date is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusions_missing_age"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.025121Z", "completed_at": "2024-10-22T19:20:34.029486Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.029977Z", "completed_at": "2024-10-22T19:20:34.029980Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005403995513916016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) -- Exclude patients with undefined or missing gender\nselect \n data_source\n , patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere \n sex not in ('male', 'female')", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_gender"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.031047Z", "completed_at": "2024-10-22T19:20:34.101165Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.101518Z", "completed_at": "2024-10-22T19:20:34.101524Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07187271118164062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_members", "compiled": true, "compiled_code": "\n/*\nSteps for transforming eligibility data into member demographics:\n 1) Determine enrollment status using eligibility from the collection year.\n 2) Roll up to latest eligibility record for enrollment statuses.\n 3) Add age groups based on the payment year.\n 4) Determine other statuses.\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - CMS guidance: Age is calculated as of Feb 1 of the payment year.\n - The collection year is one year prior to the payment year.\n*/\n\n\n\n\nwith __dbt__cte___stg_eligibility as (\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.eligibility\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), stg_eligibility as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , row_number() over(\n partition by patient_id\n order by enrollment_end_date desc\n ) as row_num /* used to dedupe eligibility */\n from __dbt__cte___stg_eligibility\n where (\n /* Include members with any overlap in the collection or payment year */\n enrollment_start_date <= '2024-12-31'\n and enrollment_end_date >= '2023-01-01'\n )\n\n)\n\n, stg_patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , floor(datediff(\n hour,\n birth_date,\n '2024-02-01'\n ) / 8766.0) as payment_year_age\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n/* create proxy enrollment dates if outside of the collection year */\n, cap_collection_start_end_dates as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , case\n when enrollment_start_date < try_cast( '2023-01-01' as date )\n then try_cast( '2023-01-01' as date )\n else enrollment_start_date\n end as proxy_enrollment_start_date\n , case\n when enrollment_end_date > try_cast( '2024-12-31' as date )\n then try_cast( '2024-12-31' as date )\n else enrollment_end_date\n end as proxy_enrollment_end_date\n from stg_eligibility\n where (\n /* filter to members with eligibility in collection or payment year */\n \n extract(year from enrollment_start_date)\n between 2023\n and 2024\n or extract(year from enrollment_end_date)\n between 2023\n and 2024\n \n )\n\n)\n\n, calculate_prior_coverage as (\n\n select patient_id\n , sum(datediff(\n month,\n proxy_enrollment_start_date,\n proxy_enrollment_end_date\n ) + 1) as coverage_months /* include starting month */\n from cap_collection_start_end_dates\n group by patient_id\n\n)\n\n/*\n CMS guidance: A \u201cNew Enrollee\u201d status is when a beneficiary has less than\n 12 months of coverage prior to the payment year.\n*/\n, add_enrollment as (\n\n select\n patient_id\n , case\n when coverage_months < 12 then 'New'\n else 'Continuing'\n end as enrollment_status\n from calculate_prior_coverage\n\n)\n\n, latest_eligibility as (\n\n select\n stg_eligibility.patient_id\n , stg_patient.sex as gender\n , stg_patient.payment_year_age\n , stg_eligibility.original_reason_entitlement_code\n , stg_eligibility.dual_status_code\n , stg_eligibility.medicare_status_code\n /* Defaulting to \"New\" enrollment status when missing */\n , case\n when add_enrollment.enrollment_status is null then 'New'\n else add_enrollment.enrollment_status\n end as enrollment_status\n \n , case\n when add_enrollment.enrollment_status is null then TRUE\n else FALSE\n end as enrollment_status_default\n \n from stg_eligibility\n left join add_enrollment\n on stg_eligibility.patient_id = add_enrollment.patient_id\n left join stg_patient\n on stg_eligibility.patient_id = stg_patient.patient_id\n where stg_eligibility.row_num = 1\n\n)\n\n, add_age_group as (\n\n select\n patient_id\n , gender\n , payment_year_age\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , enrollment_status\n , enrollment_status_default\n , case\n when enrollment_status = 'Continuing' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'Continuing' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'Continuing' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'Continuing' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'Continuing' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'Continuing' and payment_year_age between 65 and 69 then '65-69'\n when enrollment_status = 'Continuing' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'Continuing' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'Continuing' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'Continuing' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'Continuing' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'Continuing' and payment_year_age >= 95 then '>=95'\n when enrollment_status = 'New' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'New' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'New' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'New' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'New' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'New' and payment_year_age = 65 then '65'\n when enrollment_status = 'New' and payment_year_age = 66 then '66'\n when enrollment_status = 'New' and payment_year_age = 67 then '67'\n when enrollment_status = 'New' and payment_year_age = 68 then '68'\n when enrollment_status = 'New' and payment_year_age = 69 then '69'\n when enrollment_status = 'New' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'New' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'New' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'New' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'New' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'New' and payment_year_age >= 95 then '>=95'\n end as age_group\n from latest_eligibility\n\n)\n\n, add_status_logic as (\n\n select\n patient_id\n , enrollment_status\n , case\n when gender = 'female' then 'Female'\n when gender = 'male' then 'Male'\n else null\n end as gender\n , age_group\n , case\n when dual_status_code in ('01','02','03','04','05','06','08') then 'Yes'\n else 'No'\n end as medicaid_status\n , case\n when dual_status_code in ('02','04','08') then 'Full'\n when dual_status_code in ('01','03','05','06') then 'Partial'\n else 'Non'\n end as dual_status\n /*\n The CMS-HCC model does not have factors for ESRD for these edge-cases,\n we default to 'Aged'. When OREC is missing, latest Medicare status is\n used, if available.\n */\n , case\n when original_reason_entitlement_code in ('0','2') then 'Aged'\n when original_reason_entitlement_code in ('1','3') then 'Disabled'\n when original_reason_entitlement_code is null and medicare_status_code in ('10','11','31') then 'Aged'\n when original_reason_entitlement_code is null and medicare_status_code in ('20','21') then 'Disabled'\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 'Aged'\n end as orec\n /* Defaulting everyone to non-institutional until logic is added */\n , cast('No' as TEXT) as institutional_status\n , enrollment_status_default\n , case\n \n when dual_status_code is null then TRUE\n else FALSE\n \n end as medicaid_dual_status_default\n /* Setting default true when OREC or Medicare Status is ESRD, or null */\n , case\n \n when original_reason_entitlement_code in ('2') then TRUE\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then TRUE\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then TRUE\n else FALSE\n \n end as orec_default\n /* Setting default true until institutional logic is added */\n \n , TRUE as institutional_status_default\n \n from add_age_group\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast('2024' as integer) as payment_year\n from add_status_logic\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_members"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.075181Z", "completed_at": "2024-10-22T19:20:34.102612Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.103183Z", "completed_at": "2024-10-22T19:20:34.103206Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.047872066497802734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), diabetics_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa diabetes medications'\n )\n\n)\n\n, rx_diabetes as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join diabetics_codes\n on pharmacy_claims.ndc_code = diabetics_codes.code\n and lower(diabetics_codes.code_system) = 'ndc'\n\n)\n\n, rx_diabetes_in_measurement_period as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , performance_period_end -- to use in latter cte for days in treatment period calculation\n from rx_diabetes\n inner join cms_synthetic.quality_measures._int_adh_diabetes__performance_period pp\n on dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, rx_fill_order as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n , dense_rank() over (\n partition by \n patient_id\n , performance_period_end\n order by dispensing_date\n ) as dr\n from rx_diabetes_in_measurement_period\n\n)\n\n, rx_first_fill as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n from rx_fill_order\n where dr = 1\n \n)\n\n, timely_fill_check as (\n\n select\n patient_id\n , ( 1 + datediff(\n day,\n dispensing_date,\n performance_period_end\n ) )\n as days_in_treatment_period\n /* \n Performance Period end minus dispensing date results in \n second_date non-inclusive difference, so to include both of these days\n 1 day is added\n */\n from rx_first_fill\n\n)\n\n, first_check_passed_patients as (\n\n select\n patient_id\n , days_in_treatment_period\n from timely_fill_check\n where days_in_treatment_period > 90\n\n)\n\n, second_check_passed_patients as (\n\n select\n patient_id\n from rx_fill_order\n where dr = 2\n\n)\n\n, qualifying_patients as (\n\n select\n first_check_passed_patients.patient_id\n , first_check_passed_patients.days_in_treatment_period\n from first_check_passed_patients\n inner join second_check_passed_patients\n on first_check_passed_patients.patient_id = second_check_passed_patients.patient_id \n\n)\n\n, qualifying_patients_with_age as (\n \n select\n patients.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from __dbt__cte___stg_patient patients\n inner join qualifying_patients\n on patients.patient_id = qualifying_patients.patient_id\n cross join cms_synthetic.quality_measures._int_adh_diabetes__performance_period pp\n where patients.death_date is null\n\n)\n/*\n Extracting related fields like dispensing_date, ndc_code and days_supply of qualified patients\n to avoid redundant computations in numerator model\n*/\n\n, qualifying_patients_all_claim_info as (\n\n select\n qualifying_patients_with_age.patient_id\n , qualifying_patients_with_age.age\n , rx_diabetes_in_measurement_period.dispensing_date\n , rx_diabetes_in_measurement_period.ndc_code\n , rx_diabetes_in_measurement_period.days_supply\n , qualifying_patients_with_age.days_in_treatment_period\n , qualifying_patients_with_age.performance_period_begin\n , qualifying_patients_with_age.performance_period_end\n , qualifying_patients_with_age.measure_id\n , qualifying_patients_with_age.measure_name\n , qualifying_patients_with_age.measure_version\n from qualifying_patients_with_age\n inner join rx_diabetes_in_measurement_period\n on qualifying_patients_with_age.patient_id = rx_diabetes_in_measurement_period.patient_id\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from qualifying_patients_all_claim_info\n where age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(dispensing_date as date) as dispensing_date\n , cast(ndc_code as TEXT) as ndc_code\n , cast(days_supply as integer) as days_supply\n , cast(days_in_treatment_period as integer) as days_in_treatment_period\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from denominator\n\n)\n\nselect\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.103582Z", "completed_at": "2024-10-22T19:20:34.132260Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.133452Z", "completed_at": "2024-10-22T19:20:34.133457Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03135418891906738, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) = 'pqa rasa medications'\n\n)\n\n, pharmacy_claim as (\n\n select \n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, patient_with_claim as (\n\n select\n pharmacy_claim.patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n from pharmacy_claim \n inner join visit_codes\n on pharmacy_claim.ndc_code = visit_codes.code\n \n)\n\n, patient_within_performance_period as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n from patient_with_claim as claim_patient\n inner join performance_period as pp\n on claim_patient.dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, patient_with_rank as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n from patient_within_performance_period\n\n)\n\n, patient_with_first_dispensing_date as (\n\n select\n patient_id\n , dispensing_date as first_dispensing_date\n from patient_with_rank\n where dense_rank = 1\n\n)\n\n/*\ntreatment period days is abbreviated as tpd\n*/\n\n, patient_with_tpd as (\n\n select\n patients1.patient_id\n , patients1.dispensing_date\n , patients2.first_dispensing_date\n , patients1.days_supply\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as tpd\n from patient_within_performance_period as patients1\n inner join patient_with_first_dispensing_date as patients2\n on patients1.patient_id = patients2.patient_id\n\n)\n\n, first_check_patient as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n from patient_with_tpd\n where tpd > 89\n \n)\n\n, second_check_patient as (\n\n select\n patient_id\n , ndc_code\n from patient_with_rank\n where dense_rank = 2\n\n)\n\n, both_check_patient as (\n\n select\n valid_patients1.patient_id\n , valid_patients1.dispensing_date\n , valid_patients1.first_dispensing_date\n , valid_patients1.days_supply\n , valid_patients2.ndc_code\n from first_check_patient as valid_patients1\n inner join second_check_patient as valid_patients2\n on valid_patients1.patient_id = valid_patients2.patient_id\n \n)\n\n, patient_with_age as (\n\n select\n valid_patients1.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from __dbt__cte___stg_patient as patient\n inner join both_check_patient as valid_patients1\n on patient.patient_id = valid_patients1.patient_id\n cross join performance_period as pp\n where patient.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from patient_with_age \n where age > 17\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(first_dispensing_date as date) as first_dispensing_date\n , cast(days_supply as integer) as days_supply\n , cast(ndc_code as TEXT) as ndc_code\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adhras_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.127110Z", "completed_at": "2024-10-22T19:20:34.138907Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.139245Z", "completed_at": "2024-10-22T19:20:34.139250Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012758016586303711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b", "compiled": true, "compiled_code": "\n \n \n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), all_values as (\n\n select\n sex as value_field,\n count(*) as n_records\n\n from __dbt__cte___stg_patient\n group by sex\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'female','male','unknown'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.134772Z", "completed_at": "2024-10-22T19:20:34.140303Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.143330Z", "completed_at": "2024-10-22T19:20:34.143335Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009199857711791992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n) select birth_date\nfrom __dbt__cte___stg_patient\nwhere birth_date is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.140635Z", "completed_at": "2024-10-22T19:20:34.144468Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.147296Z", "completed_at": "2024-10-22T19:20:34.147300Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0074460506439208984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n) select patient_id\nfrom __dbt__cte___stg_patient\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.144664Z", "completed_at": "2024-10-22T19:20:34.148618Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.151556Z", "completed_at": "2024-10-22T19:20:34.151561Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007559061050415039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n) select sex\nfrom __dbt__cte___stg_patient\nwhere sex is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.148852Z", "completed_at": "2024-10-22T19:20:34.152497Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.152904Z", "completed_at": "2024-10-22T19:20:34.152907Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004729747772216797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , max(case when claim_count > 0 then 1 else 0 end) as prescribed_atleast_one_generic_history\n , sum(case when total_units > 0 and paid_amount > 0 then paid_amount else null end)/sum(case when total_units > 0 and paid_amount > 0 then total_units else null end) as generic_average_cost_per_unit\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.pharmacy.rxnorm_generic_available as g\nleft join cms_synthetic.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'\ngroup by\n g.product_rxcui\n , cl.data_source", "relation_name": "cms_synthetic.pharmacy._int_generic_cost"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.153225Z", "completed_at": "2024-10-22T19:20:34.160086Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.161066Z", "completed_at": "2024-10-22T19:20:34.161072Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008882761001586914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of all generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , cl.ndc_code as generic_ndc_code\n , cl.paid_amount\n , cl.claim_count\n , cl.total_units\n , cl.cost_per_unit\n , case when claim_count > 0 then 1 else 0 end as prescribed_atleast_one_generic_history\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.pharmacy.rxnorm_generic_available as g\nleft join cms_synthetic.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'", "relation_name": "cms_synthetic.pharmacy._int_generic_cost_by_ndc"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.157410Z", "completed_at": "2024-10-22T19:20:34.163485Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.164456Z", "completed_at": "2024-10-22T19:20:34.164461Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007586240768432617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_eligibility", "compiled": true, "compiled_code": "\n\nselect\n e.patient_id\n , e.birth_date\n , e.gender\n , e.race\n , d.patient_data_source_id\n , row_number() over (partition by d.patient_data_source_id order by e.enrollment_start_date desc) patient_row_num\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_eligibility e\ninner join cms_synthetic.claims_preprocessing.encounters__patient_data_source_id d on e.patient_id = d.patient_id\nand\ne.data_source = d.data_source", "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.166621Z", "completed_at": "2024-10-22T19:20:34.173201Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.173534Z", "completed_at": "2024-10-22T19:20:34.173539Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008795976638793945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when hcpcs_code in ('59400', '59409', '59410', '59610', '59612', '59614') then 'l/d - vaginal delivery'\n when hcpcs_code in ('59510', '59514', '59515', '59618', '59620', '59622') then 'l/d - cesarean delivery'\n else 'acute inpatient - other'\n end as service_category_3\n , '_int_acute_inpatient_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and place_of_service_code = '21'", "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.170257Z", "completed_at": "2024-10-22T19:20:34.173883Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.174353Z", "completed_at": "2024-10-22T19:20:34.174357Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00805807113647461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulance_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and (\n hcpcs_code between 'A0425' and 'A0436'\n or place_of_service_code in ('41', '42')\n )", "relation_name": "cms_synthetic.claims_preprocessing._int_ambulance_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.177133Z", "completed_at": "2024-10-22T19:20:34.185518Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.185867Z", "completed_at": "2024-10-22T19:20:34.185874Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011278867721557617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__dme_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'ancillary' as service_category_1\n, 'durable medical equipment' as service_category_2\n, 'durable medical equipment' as service_category_3\n, '_int_dme_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and hcpcs_code between 'E0100' and 'E8002'", "relation_name": "cms_synthetic.claims_preprocessing._int_dme_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.181871Z", "completed_at": "2024-10-22T19:20:34.186611Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.187152Z", "completed_at": "2024-10-22T19:20:34.187156Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011184930801391602, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__home_health_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n , 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('31','32','33')", "relation_name": "cms_synthetic.claims_preprocessing._int_home_health_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.188219Z", "completed_at": "2024-10-22T19:20:34.194374Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.194626Z", "completed_at": "2024-10-22T19:20:34.194632Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007838010787963867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "compiled": true, "compiled_code": "\n\nselect distinct \nclaim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n,'_int_inpatient_psychiatric_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('51','55','56')", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.191698Z", "completed_at": "2024-10-22T19:20:34.195199Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.195876Z", "completed_at": "2024-10-22T19:20:34.195880Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0047948360443115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n,'_int_inpatient_rehab_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('61')", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_rehab_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.196678Z", "completed_at": "2024-10-22T19:20:34.202582Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.202895Z", "completed_at": "2024-10-22T19:20:34.202900Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007454872131347656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('21','22')", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.199720Z", "completed_at": "2024-10-22T19:20:34.203525Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.204310Z", "completed_at": "2024-10-22T19:20:34.204315Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0052051544189453125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__observation_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1\n, 'observation' as service_category_2\n, 'observation' as service_category_3\n, '_int_observation_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\nwhere claim_type = 'institutional'\nand (revenue_center_code in ('0762')\nor hcpcs_code in ('G0378','G0379')\n)", "relation_name": "cms_synthetic.claims_preprocessing._int_observation_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.205149Z", "completed_at": "2024-10-22T19:20:34.211051Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.211295Z", "completed_at": "2024-10-22T19:20:34.211301Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007509946823120117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n, '_int_outpatient_psychiatric_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('52','53','57','58')", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.208431Z", "completed_at": "2024-10-22T19:20:34.212081Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.212525Z", "completed_at": "2024-10-22T19:20:34.212528Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004662990570068359, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient rehabilitation' as service_category_2\n, 'outpatient rehabilitation' as service_category_3\n,'_int_outpatient_rehab_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('62')", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_rehab_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.213295Z", "completed_at": "2024-10-22T19:20:34.221488Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.221783Z", "completed_at": "2024-10-22T19:20:34.221788Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009554862976074219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_inpatient_institutional", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as mc\n left join cms_synthetic.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join cms_synthetic.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n , '21' -- SNF inpatient\n , '82' -- inpatient hospice\n )\n)\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "relation_name": "cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.217659Z", "completed_at": "2024-10-22T19:20:34.222525Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.222989Z", "completed_at": "2024-10-22T19:20:34.222993Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.005908012390136719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id as claim_line_id\n , 'professional' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nwhere a.claim_type = 'professional'", "relation_name": "cms_synthetic.dbt_tom.service_category__stg_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.223875Z", "completed_at": "2024-10-22T19:20:34.296050Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.303051Z", "completed_at": "2024-10-22T19:20:34.303058Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08041191101074219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__urgent_care_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and revenue_center_code = '0456'\n and substring(bill_type_code, 1, 2) in ('13','71','73')\n \nunion all\n\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing._int_urgent_care_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.299201Z", "completed_at": "2024-10-22T19:20:34.304411Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.306240Z", "completed_at": "2024-10-22T19:20:34.306245Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011920690536499023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__urgent_care_professional", "compiled": true, "compiled_code": "\n\nwith multiple_source as (\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('20')\n\nunion all\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim\nwhere claim_type = 'professional'\nand hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,claim_line_number\n,claim_line_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_source", "relation_name": "cms_synthetic.claims_preprocessing._int_urgent_care_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.307577Z", "completed_at": "2024-10-22T19:20:34.319772Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.320080Z", "completed_at": "2024-10-22T19:20:34.320085Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01494288444519043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_01_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.314113Z", "completed_at": "2024-10-22T19:20:34.320900Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.321416Z", "completed_at": "2024-10-22T19:20:34.321420Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00826716423034668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_03_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.321789Z", "completed_at": "2024-10-22T19:20:34.333838Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.334131Z", "completed_at": "2024-10-22T19:20:34.334136Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013521194458007812, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 40", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_05_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.328316Z", "completed_at": "2024-10-22T19:20:34.334902Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.335398Z", "completed_at": "2024-10-22T19:20:34.335402Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007578849792480469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_07_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.335709Z", "completed_at": "2024-10-22T19:20:34.348707Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.349004Z", "completed_at": "2024-10-22T19:20:34.349009Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014369964599609375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_08_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.343337Z", "completed_at": "2024-10-22T19:20:34.349879Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.350280Z", "completed_at": "2024-10-22T19:20:34.350290Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007464885711669922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_11_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.350602Z", "completed_at": "2024-10-22T19:20:34.357277Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.363928Z", "completed_at": "2024-10-22T19:20:34.363935Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014436006546020508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_12_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.357500Z", "completed_at": "2024-10-22T19:20:34.365019Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.365478Z", "completed_at": "2024-10-22T19:20:34.365482Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008737802505493164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_14_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.365801Z", "completed_at": "2024-10-22T19:20:34.373009Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.378761Z", "completed_at": "2024-10-22T19:20:34.378767Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014018058776855469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18\n and\n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) <= 39", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_15_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.373228Z", "completed_at": "2024-10-22T19:20:34.379794Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.380209Z", "completed_at": "2024-10-22T19:20:34.380213Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007748126983642578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n cms_synthetic.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_16_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.380540Z", "completed_at": "2024-10-22T19:20:34.391290Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.392338Z", "completed_at": "2024-10-22T19:20:34.392344Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012824058532714844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__enrollment_change", "compiled": true, "compiled_code": "\n\nWITH RankedMonths AS (\n SELECT\n patient_id,\n year_month,\n data_source,\n lag(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as prev_year_month,\n lead(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as next_year_month,\n year_month_date\n FROM cms_synthetic.data_quality.mart_review__stg_member_month\n),\nChanges AS (\n SELECT\n patient_id,\n data_source,\n year_month_date as change_month,\n case\n when prev_year_month is null\n or \n\n dateadd(\n month,\n -1,\n year_month_date\n )\n\n != prev_year_month\n then 'added'\n end as change_type\nFROM RankedMonths\nunion all\nSELECT\n patient_id,\n data_source,\n \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n as change_month,\n case\n when next_year_month is null\n or \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n != next_year_month\n then 'removed'\n end as change_type\nFROM RankedMonths\n\n),\nFinal AS (\n SELECT\n patient_id || '|' || change_month as membermonthkey,\n data_source,\n patient_id,\n change_month,\n change_type\n FROM Changes\n WHERE change_type IS NOT NULL\n),\nResult AS (\n SELECT\n data_source,\n change_month,\n change_type,\n count(*) as member_count\n FROM Final\n GROUP BY data_source\n , change_month\n , change_type\n)\n\n\nSELECT * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM Result", "relation_name": "cms_synthetic.data_quality.mart_review__enrollment_change"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.385076Z", "completed_at": "2024-10-22T19:20:34.394838Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.395584Z", "completed_at": "2024-10-22T19:20:34.395589Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01110386848449707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_demographic_factors", "compiled": true, "compiled_code": "\n\nwith members as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n from cms_synthetic.cms_hcc._int_members\n\n)\n\n, seed_demographic_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , coefficient\n from cms_synthetic.cms_hcc._value_set_demographic_factors\n where plan_segment is null /* data not available */\n\n)\n\n, v24_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v24_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v28_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, v28_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, unioned as (\n\n select * from v24_new_enrollees\n union all\n select * from v24_continuining_enrollees\n union all\n select * from v28_new_enrollees\n union all\n select * from v28_continuining_enrollees\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_demographic_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.397892Z", "completed_at": "2024-10-22T19:20:34.405039Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.405927Z", "completed_at": "2024-10-22T19:20:34.405932Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010088920593261719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.cms_hcc._int_members\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.401800Z", "completed_at": "2024-10-22T19:20:34.405577Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.406583Z", "completed_at": "2024-10-22T19:20:34.406587Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00898599624633789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.cms_hcc._int_members\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.415162Z", "completed_at": "2024-10-22T19:20:34.421668Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.422112Z", "completed_at": "2024-10-22T19:20:34.422117Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014028072357177734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_numerator", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_adhras_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n/*\nThe below 3 cte identifies periods of continuous medication use for each patient by:\n1. Assigning a row number and tracking the previous medication per patient.\n2. Flagging when a medication change occurs.\n3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dense_rank \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\nThis cte theoretical_end_dates to final_fills calculates adjusted medication fill dates, \ngroups fills by continuous periods of use and ensures accurate start and end dates based \non previous fills and the performance period.\n*/\n\n, theoretical_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n/* \nAdjust start dates based on the previous fill's end date + 1,\nor use the current rx_fill_date \n*/\n\n, previous_fill_end_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_fill_end_date\n from theoretical_end_dates\n\n)\n\n, adjusted_fill_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_fill_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_fill_date\n from previous_fill_end_dates\n\n)\n\n\n, actual_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_fill_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as actual_end_date\n from adjusted_fill_dates\n inner join performance_end\n on adjusted_fill_dates.adjusted_fill_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , min(adjusted_fill_date) over(partition by patient_id, group_id) as group_first\n , max(adjusted_fill_date) over(partition by patient_id, group_id) as group_last\n from actual_end_dates\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , group_first\n , group_last\n , max(\n case\n when adjusted_fill_date = group_last\n then days_supply\n else 0\n end) over (partition by patient_id, group_id) as group_last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n1. Calculates the total covered days per every medication group per patient\n2. Then, calculates the overlap between groups of medication per patient.\n3. Then, calculates the actual total covered days for each patient.\n*/\n\n, covered_days_per_groups as (\n \n select\n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_fill_date,\n actual_end_date\n ) ) as covered_days_per_group\n from final_fills\n group by \n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n\n)\n\n, with_lag as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag(group_last) over(partition by patient_id order by group_first) as lag_date\n , lag(group_last_days_supply) over(partition by patient_id order by group_first) as lag_days_supply\n from covered_days_per_groups\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag_date\n , case\n when group_first < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n group_first,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from with_lag\n\n)\n\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days_per_group) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, patient_with_treatment_period_days as (\n select\n patient_id\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as treatment_period_days\n from denominator\n\n)\n\n, patient_with_pdc as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days * 100 / treatment_period_days as numeric(28,6)), 4) as adherence\n from final_covered_days\n inner join patient_with_treatment_period_days \n on final_covered_days.patient_id = patient_with_treatment_period_days.patient_id\n\n)\n\n/*\nSelects only the patient whose pdc is greater than 80%.\n*/\n\n, valid_patients as (\n\n select \n patient_with_pdc.patient_id\n , adherence\n , denominator.dispensing_date as evidence_date\n , denominator.days_supply as evidence_value\n , 1 as numerator_flag\n from patient_with_pdc \n inner join denominator\n on patient_with_pdc.patient_id = denominator.patient_id \n where patient_with_pdc.adherence >= 80.00 \n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from valid_patients\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adhras_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.408810Z", "completed_at": "2024-10-22T19:20:34.421886Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.422480Z", "completed_at": "2024-10-22T19:20:34.422485Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01462411880493164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n/*\n The below 3 cte identifies periods of continuous medication use for each patient by:\n 1. Assigning a row number and tracking the previous medication per patient.\n 2. Flagging when a medication change occurs.\n 3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dr\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dr\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dr \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\n The ctes below calculates adjusted medication fill dates,\n groups fills by continuous periods of use and ensures accurate start and end dates based \n on previous fills and the performance period.\n*/\n\n, fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n, previous_fill_end_date as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_end_date\n from fills\n\n)\n\n, adjusted_fills as (\n \n /* Adjust start dates based on the previous fill's end date + 1,\n or use the current rx_fill_date */\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_start_date\n from previous_fill_end_date\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_start_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as final_end_date\n from adjusted_fills\n inner join performance_end\n on adjusted_fills.adjusted_start_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , min(adjusted_start_date) over(partition by patient_id, group_id) as first_disp_date\n , max(adjusted_start_date) over(partition by patient_id, group_id) as last_disp_date\n from final_fills\n\n)\n\n, last_med_end_groupwise as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , first_disp_date\n , last_disp_date\n , max(\n case\n when adjusted_start_date = last_disp_date\n then days_supply\n else null\n end) over (partition by patient_id, group_id) as last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n 1. Calculates the total covered days per medication group per patient\n 2. Then calculates the overlap between groups of medication per patient\n 3. Finally calculates the actual total covered days for each patient\n*/\n\n, covered_days_per_group as (\n \n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_start_date,\n final_end_date\n ) ) as covered_days\n from last_med_end_groupwise\n group by \n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n\n)\n\n, final_with_lag as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag(last_disp_date) over(partition by patient_id order by first_disp_date) as lag_date\n , lag(last_days_supply) over(partition by patient_id order by first_disp_date) as lag_days_supply\n from covered_days_per_group\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag_date\n , case\n when first_disp_date < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n first_disp_date,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from final_with_lag\n\n)\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, relevant_patients_from_deno as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days / days_in_treatment_period as numeric(28,6)), 4) as adherence\n , dispensing_date as evidence_date\n , days_supply as evidence_value\n from final_covered_days\n inner join denominator\n on final_covered_days.patient_id = denominator.patient_id\n \n)\n\n, numerator as (\n\n select\n patient_id\n , adherence * 100 as adherence --percent conversion\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from relevant_patients_from_deno\n where adherence >= 0.8\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.424259Z", "completed_at": "2024-10-22T19:20:34.436103Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.436523Z", "completed_at": "2024-10-22T19:20:34.436529Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013224124908447266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__brand_generic_opportunity", "compiled": true, "compiled_code": "\n\n/* claimid/line/source grain. calculates opportunity at line level*/\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n), cpu as (\nselect claim_id\n,claim_line_number\n,data_source\n,case when quantity > 0 then paid_amount/quantity else null end as brand_cost_per_unit\nfrom __dbt__cte__stg_pharmacy_claim\n)\n\n\nselect \n pc.data_source\n , pc.claim_id\n , pc.claim_line_number\n , cc.ndc_code\n , cc.ndc_description\n , cc.rxcui as brand_rxcui\n , cc.brand_vs_generic \n , cc.generic_available\n , pc.paid_amount\n , pc.quantity as total_units\n , cpu.brand_cost_per_unit\n , gc.generic_average_cost_per_unit \n , cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit as brand_less_generic_cost_per_unit\n , case \n when cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit > 0 \n then (cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit) * pc.quantity \n else 0 \n end as generic_available_total_opportunity\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as pc\ninner join cpu on pc.claim_id = cpu.claim_id\n and\n pc.claim_line_number = cpu.claim_line_number\n and\n pc.data_source = cpu.data_source\ninner join cms_synthetic.pharmacy._int_claims_current_cost cc\n on cc.ndc_code = pc.ndc_code\n and\n cc.data_source = pc.data_source\ninner join cms_synthetic.pharmacy._int_generic_cost as gc \n on cc.rxcui = gc.brand_rxcui\n and gc.data_source = cc.data_source\nwhere prescribed_atleast_one_generic_history = 1", "relation_name": "cms_synthetic.pharmacy.brand_generic_opportunity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.431870Z", "completed_at": "2024-10-22T19:20:34.436308Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.436945Z", "completed_at": "2024-10-22T19:20:34.436948Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013359785079956055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n, a.claim_line_number\n, a.claim_line_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nleft join cms_synthetic.claims_preprocessing._int_dme_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\nwhere claim_type = 'professional'\n and place_of_service_code in ('31','32')\n and (b.claim_id is null and b.claim_line_number is null)", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.438683Z", "completed_at": "2024-10-22T19:20:34.444702Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.445110Z", "completed_at": "2024-10-22T19:20:34.445115Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007381916046142578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_inpatient_institutional", "compiled": true, "compiled_code": "\n\nselect \n claim_id\n, service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional a", "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_inpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.441508Z", "completed_at": "2024-10-22T19:20:34.444890Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.445493Z", "completed_at": "2024-10-22T19:20:34.445496Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007484912872314453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when s.ms_drg_code in ('768', '796', '797', '798', '805', '806', '807') then 'l/d - vaginal delivery'\n when s.ms_drg_code in ('783', '784', '785', '786', '787', '788') then 'l/d - cesarean delivery'\n when s.ms_drg_code = '795' then 'l/d - newborn'\n when s.ms_drg_code in ('789', '790', '791', '792', '793', '794') then 'l/d - newborn nicu'\n when s.revenue_center_code in ('0173', '0174') then 'l/d - newborn nicu'\n else 'l/d - other'\n end as service_category_3\n , '_int_acute_inpatient_institutional_maternity' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join cms_synthetic.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code\nwhere \n m.mdc_code in ('MDC 14', 'MDC 15')", "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_maternity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.450042Z", "completed_at": "2024-10-22T19:20:34.455992Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.456769Z", "completed_at": "2024-10-22T19:20:34.456774Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010342836380004883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "compiled": true, "compiled_code": "\n\n\n--simplified by setting lowest priority instead of explicitly doing all the joins\nselect distinct \n a.claim_id\n , 'inpatient' as service_category_1\n, 'acute inpatient' as service_category_2\n, 'acute inpatient - other' as service_category_3\n, '_int_acute_inpatient_institutional_other' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id", "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_other"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.447179Z", "completed_at": "2024-10-22T19:20:34.456470Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.457373Z", "completed_at": "2024-10-22T19:20:34.457376Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011111974716186523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when m.medical_surgical = 'M' then 'medical'\n when m.medical_surgical = 'P' then 'surgical'\n when m.medical_surgical = 'surgical' then 'surgical'\n else 'acute inpatient - other' \n end as service_category_3\n , '_int_acute_inpatient_institutional_med_surg' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join cms_synthetic.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code", "relation_name": "cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_med_surg"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.459191Z", "completed_at": "2024-10-22T19:20:34.465406Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.465631Z", "completed_at": "2024-10-22T19:20:34.465636Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007397174835205078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n, '_int_inpatient_hospice_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id\nwhere substring(s.bill_type_code, 1, 2) in ('82')", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_hospice_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.462253Z", "completed_at": "2024-10-22T19:20:34.466199Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.466709Z", "completed_at": "2024-10-22T19:20:34.466713Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008190155029296875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n, '_int_inpatient_psychiatric_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.467573Z", "completed_at": "2024-10-22T19:20:34.474063Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.474305Z", "completed_at": "2024-10-22T19:20:34.474312Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007925033569335938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n s.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n, '_int_inpatient_rehab_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283X00000X'\n ,'273Y00000X'\n )", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_rehab_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.471309Z", "completed_at": "2024-10-22T19:20:34.474724Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.475172Z", "completed_at": "2024-10-22T19:20:34.475175Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004434108734130859, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'inpatient substance use' as service_category_2\n , 'inpatient substance use' as service_category_3\n , '_int_inpatient_substance_use_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as s\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\nwhere \n s.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )\n or s.default_ccsr_category_description_ip in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_substance_use_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.476364Z", "completed_at": "2024-10-22T19:20:34.483087Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.483399Z", "completed_at": "2024-10-22T19:20:34.483405Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007962942123413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_outpatient_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n, 'outpatient' as service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\nleft join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional i on a.claim_id = i.claim_id\nwhere i.claim_id is null\nand\na.claim_type = 'institutional'", "relation_name": "cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.480620Z", "completed_at": "2024-10-22T19:20:34.483757Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.484241Z", "completed_at": "2024-10-22T19:20:34.484244Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008147954940795898, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, claim_line_number\n, claim_line_id\n, service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_professional a", "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.485863Z", "completed_at": "2024-10-22T19:20:34.491797Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.492038Z", "completed_at": "2024-10-22T19:20:34.492043Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0072782039642333984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n, 'ambulatory surgery center' as service_category_2\n, 'ambulatory surgery center' as service_category_3\n, '_int_ambulatory_surgery_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('24')", "relation_name": "cms_synthetic.claims_preprocessing._int_ambulatory_surgery_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.489037Z", "completed_at": "2024-10-22T19:20:34.492412Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.492908Z", "completed_at": "2024-10-22T19:20:34.492911Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007314920425415039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__dialysis_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1 \n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('65')\n or med.ccs_category in ('91', '58', '57')", "relation_name": "cms_synthetic.claims_preprocessing._int_dialysis_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.497860Z", "completed_at": "2024-10-22T19:20:34.503280Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.506862Z", "completed_at": "2024-10-22T19:20:34.506867Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012881755828857422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__emergency_department_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'emergency department' as service_category_2\n, 'emergency department' as service_category_3\n, '_int_emergency_department_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '23'\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')", "relation_name": "cms_synthetic.claims_preprocessing._int_emergency_department_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.503590Z", "completed_at": "2024-10-22T19:20:34.508606Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.511851Z", "completed_at": "2024-10-22T19:20:34.511857Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014487981796264648, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__home_health_professional", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('12')", "relation_name": "cms_synthetic.claims_preprocessing._int_home_health_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.508817Z", "completed_at": "2024-10-22T19:20:34.513150Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.513574Z", "completed_at": "2024-10-22T19:20:34.513578Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005425930023193359, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_professional", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n,'_int_inpatient_hospice_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code in ('34')", "relation_name": "cms_synthetic.claims_preprocessing._int_inpatient_hospice_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.513907Z", "completed_at": "2024-10-22T19:20:34.521597Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.521904Z", "completed_at": "2024-10-22T19:20:34.521909Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009042024612426758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__lab_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '81'\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "relation_name": "cms_synthetic.claims_preprocessing._int_lab_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.517704Z", "completed_at": "2024-10-22T19:20:34.522529Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.522950Z", "completed_at": "2024-10-22T19:20:34.522953Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00577998161315918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__observation_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'observation' as service_category_2\n , 'observation' as service_category_3\n , '_int_observation_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.hcpcs_code in ('G0378', 'G0379')", "relation_name": "cms_synthetic.claims_preprocessing._int_observation_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.523708Z", "completed_at": "2024-10-22T19:20:34.530075Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.530274Z", "completed_at": "2024-10-22T19:20:34.530279Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007620096206665039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient hospice' as service_category_2\n, 'outpatient hospice' as service_category_3\n, '_int_outpatient_hospice_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere \nmed.hcpcs_code in ('Q5001','Q5002','Q5003','Q5009')", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospice_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.527318Z", "completed_at": "2024-10-22T19:20:34.530855Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.531316Z", "completed_at": "2024-10-22T19:20:34.531319Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004553794860839844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('15', '17', '19', '22', '49', '50', '60', '71', '72')", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.532292Z", "completed_at": "2024-10-22T19:20:34.538519Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.538744Z", "completed_at": "2024-10-22T19:20:34.538750Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00791311264038086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient pt/ot/st' as service_category_2\n, 'outpatient pt/ot/st' as service_category_3\n, 'service_category__outpatient_physical_therapy_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (ccs_category in ('213','212','215')\nOR\nmed.primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nAND\nplace_of_service_code <> '11'", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.535627Z", "completed_at": "2024-10-22T19:20:34.539476Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.539956Z", "completed_at": "2024-10-22T19:20:34.539960Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004926204681396484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n and med.place_of_service_code <> '11'", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.540720Z", "completed_at": "2024-10-22T19:20:34.546875Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.547115Z", "completed_at": "2024-10-22T19:20:34.547121Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0074748992919921875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\n(ccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244'))\nand\nplace_of_service_code in ('15','17','19','22','49','50','60','71','72')", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.544000Z", "completed_at": "2024-10-22T19:20:34.547985Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.548436Z", "completed_at": "2024-10-22T19:20:34.548440Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005023002624511719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__pharmacy_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , case when place_of_service_code = '11' then 'office-based' else 'outpatient' end as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n ,'service_category__pharmacy_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\nccs_category = '240' --medications", "relation_name": "cms_synthetic.claims_preprocessing.service_category__pharmacy_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.548770Z", "completed_at": "2024-10-22T19:20:34.558879Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.561120Z", "completed_at": "2024-10-22T19:20:34.561127Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013428211212158203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_office_based", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id\n , 'office based' as service_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim a\ninner join cms_synthetic.dbt_tom.service_category__stg_professional p on a.claim_id = p.claim_id \nand\na.claim_line_number = p.claim_line_number\nwhere a.place_of_service_code in ( '11' -- office\n,'02' --telehealth \n,'10' --telehealth\n)", "relation_name": "cms_synthetic.dbt_tom.service_category__stg_office_based"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.552546Z", "completed_at": "2024-10-22T19:20:34.562496Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.567995Z", "completed_at": "2024-10-22T19:20:34.568002Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01604628562927246, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_denom_long", "compiled": true, "compiled_code": "\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '01' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_01_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '03' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_03_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '05' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_05_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '07' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_07_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '08' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_08_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '11' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_11_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '12' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_12_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '14' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_14_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '15' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_15_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '16' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_16_denom as d", "relation_name": "cms_synthetic.ahrq_measures.pqi_denom_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.562763Z", "completed_at": "2024-10-22T19:20:34.569317Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.572722Z", "completed_at": "2024-10-22T19:20:34.572727Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010824918746948242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , gender\n , enrollment_status\n , medicaid_status\n , dual_status\n , institutional_status\n , description\n , coefficient\n from cms_synthetic.cms_hcc._value_set_enrollment_interaction_factors\n\n)\n\n/*\n Originally disabled interactions for non-institutional members >= 65\n*/\n, non_institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.gender = seed_interaction_factors.gender\n and demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.medicaid_status = seed_interaction_factors.medicaid_status\n and demographics.dual_status = seed_interaction_factors.dual_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'No'\n and demographics.orec = 'Disabled'\n and demographics.age_group in (\n '65-69'\n , '70-74'\n , '75-79'\n , '80-84'\n , '85-89'\n , '90-94'\n , '>=95'\n )\n\n)\n\n/*\n Medicaid interactions for institutional members\n*/\n, institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'Yes'\n and demographics.medicaid_status = 'Yes'\n\n)\n\n, unioned as (\n\n select * from non_institutional_interactions\n union all\n select * from institutional_interactions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_enrollment_interaction_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.569525Z", "completed_at": "2024-10-22T19:20:34.579267Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.586921Z", "completed_at": "2024-10-22T19:20:34.586926Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01820683479309082, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, model_version\n from cms_synthetic.cms_hcc._int_demographic_factors\n group by patient_id, model_version\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.573930Z", "completed_at": "2024-10-22T19:20:34.588137Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.588581Z", "completed_at": "2024-10-22T19:20:34.588585Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01522517204284668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n), all_drugs as (\n select \n p.data_source\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.ndc_code\n , p.ndc_description\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\n , p.paid_amount\n , p.allowed_amount\n , p.rxcui\n , r.product_name\n , r.product_tty\n , r.brand_vs_generic\n , r.brand_name\n , r.clinical_product_rxcui as generic_rxcui\n , r.clinical_product_name as generic_rxcui_description\n , r.clinical_product_tty as generic_tty\n , r.ingredient_name\n , r.dose_form_name\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else r.brand_vs_generic \n end as generic_available\n , opp.brand_cost_per_unit\n , opp.generic_average_cost_per_unit\n , opp.brand_less_generic_cost_per_unit\n , opp.generic_available_total_opportunity\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from __dbt__cte__stg_pharmacy_claim as p\n left join cms_synthetic.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\n left join cms_synthetic.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\n left join cms_synthetic.pharmacy.brand_generic_opportunity as opp \n on p.claim_id = opp.claim_id\n and p.claim_line_number = opp.claim_line_number\n and p.data_source = opp.data_source\n)\n\n, generic_available as (\n select \n *\n , row_number() over (order by ndc_code, data_source) as generic_available_sk\n from all_drugs\n where generic_available = 'brand_with_generic_available'\n)\n\nselect \n a.data_source\n , a.claim_id\n , a.claim_line_number\n , a.patient_id\n , a.member_id\n , a.prescribing_provider_id\n , a.dispensing_provider_id\n , a.dispensing_date\n , a.ndc_code\n , a.ndc_description\n , a.quantity\n , a.days_supply\n , a.refills\n , a.paid_date\n , a.paid_amount\n , a.allowed_amount\n , a.rxcui\n , a.product_name\n , a.product_tty\n , a.brand_vs_generic\n , a.brand_name\n , a.generic_rxcui\n , a.generic_rxcui_description\n , a.generic_tty\n , a.ingredient_name\n , a.dose_form_name\n , a.generic_available\n , a.brand_cost_per_unit\n , a.generic_average_cost_per_unit\n , a.brand_less_generic_cost_per_unit\n , a.generic_available_total_opportunity\n , g.generic_available_sk\nfrom all_drugs as a\nleft join generic_available as g \n on a.claim_id = g.claim_id\n and a.claim_line_number = g.claim_line_number\n and a.data_source = g.data_source", "relation_name": "cms_synthetic.pharmacy.pharmacy_claim_expanded"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.589091Z", "completed_at": "2024-10-22T19:20:34.592769Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.595790Z", "completed_at": "2024-10-22T19:20:34.595795Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007979869842529297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from cms_synthetic.pharmacy.brand_generic_opportunity\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.592986Z", "completed_at": "2024-10-22T19:20:34.596716Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.597095Z", "completed_at": "2024-10-22T19:20:34.597099Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004853010177612305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_outpatient_institutional", "compiled": true, "compiled_code": "\n\n\nselect distinct \n claim_id\n, service_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional a", "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_outpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.597452Z", "completed_at": "2024-10-22T19:20:34.605090Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.605343Z", "completed_at": "2024-10-22T19:20:34.605348Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008922815322875977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulance_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n (med.hcpcs_code between 'A0425' and 'A0436')\n or med.revenue_center_code = '0540'", "relation_name": "cms_synthetic.claims_preprocessing._int_ambulance_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.600890Z", "completed_at": "2024-10-22T19:20:34.605945Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.606438Z", "completed_at": "2024-10-22T19:20:34.606442Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006052732467651367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0490','0499')\n\nunion all\n\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere med.primary_taxonomy_code = '261QA1903X'\n)\n\nselect distinct claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing._int_ambulatory_surgery_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.607336Z", "completed_at": "2024-10-22T19:20:34.616005Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.616931Z", "completed_at": "2024-10-22T19:20:34.616937Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010841846466064453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__dialysis_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('72')\n or med.primary_taxonomy_code in (\n '2472R0900X'\n , '163WD1100X'\n , '163WH0500X'\n , '261QE0700X'\n )\n or med.ccs_category in ('91', '58', '57')\n or substring(med.revenue_center_code, 1, 3) in ('082', '083', '084', '085', '088')", "relation_name": "cms_synthetic.claims_preprocessing._int_dialysis_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.611939Z", "completed_at": "2024-10-22T19:20:34.617403Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.620217Z", "completed_at": "2024-10-22T19:20:34.620223Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008885860443115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__emergency_department_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')\n \nunion all\n\n--Adding in inpatient claims for flagging encounters with ED \nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional inp\n on med.claim_id = inp.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\n\n)\n\nselect claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,tuva_last_run\n,source_model_name\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing._int_emergency_department_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.624422Z", "completed_at": "2024-10-22T19:20:34.628868Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.632160Z", "completed_at": "2024-10-22T19:20:34.632167Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011025190353393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__lab_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.bill_type_code, 1, 2) in ('14')\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "relation_name": "cms_synthetic.claims_preprocessing._int_lab_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.629091Z", "completed_at": "2024-10-22T19:20:34.633286Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.633748Z", "completed_at": "2024-10-22T19:20:34.633752Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00966787338256836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient hospice' as service_category_2\n , 'outpatient hospice' as service_category_3\n , '_int_outpatient_hospice_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('81')\n or (\n med.hcpcs_code in ('Q5001', 'Q5002', 'Q5003', 'Q5009')\n and substring(med.bill_type_code, 1, 2) not in ('31', '32', '33')\n )\n or med.revenue_center_code in ('0651', '0652')", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospice_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.634157Z", "completed_at": "2024-10-22T19:20:34.641473Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.641852Z", "completed_at": "2024-10-22T19:20:34.641858Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008853673934936523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as m\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n substring(m.bill_type_code, 1, 2) in ('13', '71', '73')\n\n union all\n\n select distinct\n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as m\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n m.ccs_category = '227' -- Consultation, evaluation, and preventative care\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.638897Z", "completed_at": "2024-10-22T19:20:34.642703Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.643125Z", "completed_at": "2024-10-22T19:20:34.643129Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004757881164550781, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n ,'outpatient' as service_category_1 \n , 'outpatient pt/ot/st' as service_category_2\n , 'outpatient pt/ot/st' as service_category_3\n ,'service_category__outpatient_physical_therapy_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere ccs_category in ('213','212','215')", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.643475Z", "completed_at": "2024-10-22T19:20:34.650422Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.650702Z", "completed_at": "2024-10-22T19:20:34.650708Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00829005241394043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "compiled": true, "compiled_code": "\nwith multiple_sources as (\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim m\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere substring(m.bill_type_code, 1, 2) in ('52')\n\nunion all\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim m\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere m.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')\n)\n\nselect distinct claim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.647641Z", "completed_at": "2024-10-22T19:20:34.651308Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.651741Z", "completed_at": "2024-10-22T19:20:34.651744Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004614114761352539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_institutional' as source_model_name \n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.652521Z", "completed_at": "2024-10-22T19:20:34.659897Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.660117Z", "completed_at": "2024-10-22T19:20:34.660122Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008682012557983398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_professional' as source_model_name \n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null\nand\nplace_of_service_code <> '11'", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.657142Z", "completed_at": "2024-10-22T19:20:34.660784Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.661222Z", "completed_at": "2024-10-22T19:20:34.661226Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004844188690185547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient rehabilitation' as service_category_2\n , 'outpatient rehabilitation' as service_category_3\n , 'service_category__outpatient_rehab_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as m\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as i\n on m.claim_id = i.claim_id\n where \n m.primary_taxonomy_code in (\n '283X00000X'\n , '273Y00000X'\n , '261QR0400X'\n , '315D00000X'\n , '261QR0401X'\n , '208100000X'\n , '225400000X'\n , '324500000X'\n , '2278P1005X'\n , '261QR0405X'\n , '2081S0010X'\n , '261QR0404X'\n )\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_rehab_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.662022Z", "completed_at": "2024-10-22T19:20:34.668095Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.668307Z", "completed_at": "2024-10-22T19:20:34.668312Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007390260696411133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as o\n on med.claim_id = o.claim_id\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n or med.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.665306Z", "completed_at": "2024-10-22T19:20:34.668917Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.669397Z", "completed_at": "2024-10-22T19:20:34.669402Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0046520233154296875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id --claim level\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere\nccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244')", "relation_name": "cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.670249Z", "completed_at": "2024-10-22T19:20:34.677167Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.677383Z", "completed_at": "2024-10-22T19:20:34.677388Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008314132690429688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__pharmacy_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\n inner join cms_synthetic.dbt_tom.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547'\n or med.ccs_category = '240') -- medications\n\n union all\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'inpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\n inner join cms_synthetic.dbt_tom.service_category__stg_inpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547')\n)\n\nselect \n claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing.service_category__pharmacy_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.674445Z", "completed_at": "2024-10-22T19:20:34.678356Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.678824Z", "completed_at": "2024-10-22T19:20:34.678828Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.004953145980834961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based pt/ot/st' as service_category_2\n , 'office-based pt/ot/st' as service_category_3\n ,'service_category__office_based_physical_therapy_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_office_based prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (\nccs_category in ('213','212','215')\nOR\n med.rend_primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nand place_of_service_code = '11'", "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.679599Z", "completed_at": "2024-10-22T19:20:34.688476Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.688713Z", "completed_at": "2024-10-22T19:20:34.688718Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010216951370239258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_radiology", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based radiology' as service_category_2\n , case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n ,'service_category__office_based_radiology' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim med\ninner join cms_synthetic.dbt_tom.service_category__stg_office_based o on med.claim_id = o.claim_id\nand\nmed.claim_line_number = o.claim_line_number\nwhere \nmed.modality is not null\nand\nmed.place_of_service_code = '11'", "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_radiology"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.683172Z", "completed_at": "2024-10-22T19:20:34.689314Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.689789Z", "completed_at": "2024-10-22T19:20:34.689792Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00716400146484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_surgery_professional", "compiled": true, "compiled_code": "\n\n\nwith numeric_hcpcs as (\n select *\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\n where \n \n try_cast(hcpcs_code as int)\n is not null\n)\n\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n ,'office-based' as service_category_1 \n , 'office-based surgery' as service_category_2\n , 'office-based surgery' as service_category_3\n , 'service_category__office_based_surgery_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from numeric_hcpcs as med\n inner join cms_synthetic.dbt_tom.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\n where \n (hcpcs_code between '10021' and '69999')", "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.690580Z", "completed_at": "2024-10-22T19:20:34.704683Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.705505Z", "completed_at": "2024-10-22T19:20:34.705511Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01603102684020996, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_visit_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_2\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_3\n , '_int_office_based_visit_professional' as source_model_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.dbt_tom.service_category__stg_medical_claim as med\ninner join cms_synthetic.dbt_tom.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n (med.place_of_service_code = '11' and med.ccs_category = '227') -- consultation eval and preventative care\n or med.place_of_service_code in ('02', '10') -- telehealth", "relation_name": "cms_synthetic.claims_preprocessing._int_office_based_visit_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.693825Z", "completed_at": "2024-10-22T19:20:34.707901Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.708665Z", "completed_at": "2024-10-22T19:20:34.708670Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.015386819839477539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__generic_available_list", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom cms_synthetic.core.pharmacy_claim as p\nleft join cms_synthetic.terminology.ndc as n \n on p.ndc_code = n.ndc\n), generic_sk as (\n select \n generic_available_sk\n , claim_id\n , claim_line_number\n , data_source\n from cms_synthetic.pharmacy.pharmacy_claim_expanded as e\n where generic_available_sk is not null\n)\n\nselect \n sk.generic_available_sk\n , p.data_source\n , p.ndc_code as brand_ndc_code\n , p.ndc_description as brand_ndc_description\n , p.rxcui as brand_rxcui\n , p.paid_amount as brand_paid_amount\n , p.quantity as brand_units\n , case \n when p.quantity = 0 \n then 0 \n else p.paid_amount / p.quantity \n end as brand_paid_per_unit\n , ga.ndc as generic_ndc\n , n.fda_description as generic_ndc_description\n , case \n when gc.ndc_code is not null \n then 1 \n else 0 \n end as generic_prescribed_history\n , gc.cost_per_unit as generic_cost_per_unit\n , gc.cost_per_unit * p.quantity as generic_cost_at_units\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\ninner join generic_sk as sk \n on p.claim_id = sk.claim_id\n and p.claim_line_number = sk.claim_line_number\n and p.data_source = sk.data_source\ninner join cms_synthetic.pharmacy._int_brand_with_generic_available as b \n on p.rxcui = b.brand_with_generic_available\ninner join cms_synthetic.pharmacy.rxnorm_generic_available as ga \n on p.rxcui = ga.product_rxcui\n and ga.ndc_product_tty in ('SCD','GPCK')\nleft join cms_synthetic.terminology.ndc as n \n on ga.ndc = n.ndc\nleft join cms_synthetic.pharmacy._int_claims_current_cost as gc \n on ga.ndc = gc.ndc_code\n and gc.brand_vs_generic = 'generic'\n and gc.data_source = p.data_source\nwhere \n ga.product_startmarketingdate is not null\n \n and cast(ga.product_startmarketingdate as date) <= current_date\n", "relation_name": "cms_synthetic.pharmacy.generic_available_list"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.711028Z", "completed_at": "2024-10-22T19:20:34.719603Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:34.720110Z", "completed_at": "2024-10-22T19:20:34.720116Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011154890060424805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from cms_synthetic.pharmacy.pharmacy_claim_expanded\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:33.412264Z", "completed_at": "2024-10-22T19:20:35.439949Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:35.440172Z", "completed_at": "2024-10-22T19:20:35.440177Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 2.141663074493408, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_test_summary", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_claim_line_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_claim_line_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_inst_header_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_inst_header_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.medical_claim_provider_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.medical_claim_provider_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_ndc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_ndc\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_prescription_details' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_prescription_details\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.pharmacy_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.pharmacy_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.primary_key_check' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.primary_key_check\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_demographics' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_demographics\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_missing_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_missing_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.eligibility_missing_payer' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.data_quality.eligibility_missing_payer\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned_data\nwhere data_quality_check <> 'Percent of claims with secondary diagnosis'", "relation_name": "cms_synthetic.data_quality.data_quality_test_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:35.554895Z", "completed_at": "2024-10-22T19:20:35.562316Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:35.562899Z", "completed_at": "2024-10-22T19:20:35.562909Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009072065353393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_other_professional", "compiled": true, "compiled_code": "\n\n\n select distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'office-based' as service_category_1 \n, 'office-based other' as service_category_2\n, 'office-based other' as service_category_3\n, 'service_category__office_based_other_professional' as source_model_name\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from cms_synthetic.dbt_tom.service_category__stg_office_based med\n left join cms_synthetic.claims_preprocessing.service_category__pharmacy_professional pharm on med.claim_line_id = pharm.claim_line_id\n left join cms_synthetic.claims_preprocessing.service_category__office_based_radiology rad on med.claim_line_id = rad.claim_line_id\n left join cms_synthetic.claims_preprocessing._int_office_based_visit_professional visit on med.claim_line_id = visit.claim_line_id\n left join cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional surg on med.claim_line_id = surg.claim_line_id\n left join cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional pt on med.claim_line_id = pt.claim_line_id\n where pharm.claim_line_id is null \n and rad.claim_line_id is null \n and visit.claim_line_id is null\n and surg.claim_line_id is null\n and pt.claim_line_id is null", "relation_name": "cms_synthetic.claims_preprocessing.service_category__office_based_other_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:35.565174Z", "completed_at": "2024-10-22T19:20:35.568638Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:35.568862Z", "completed_at": "2024-10-22T19:20:35.568866Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004620075225830078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n generic_available_sk, generic_ndc\n from cms_synthetic.pharmacy.generic_available_list\n group by generic_available_sk, generic_ndc\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:35.570068Z", "completed_at": "2024-10-22T19:20:35.572556Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:35.572758Z", "completed_at": "2024-10-22T19:20:35.572762Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0033349990844726562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom cms_synthetic.data_quality.data_quality_test_summary\nwhere data_quality_check is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:35.573909Z", "completed_at": "2024-10-22T19:20:35.578953Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:35.579448Z", "completed_at": "2024-10-22T19:20:35.579453Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006067991256713867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.data_quality.data_quality_test_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.722148Z", "completed_at": "2024-10-22T19:20:35.579219Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:35.579810Z", "completed_at": "2024-10-22T19:20:35.579815Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.9712622165679932, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__combined_institutional_line_level", "compiled": true, "compiled_code": "\n\nWITH combine_line_models AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__pharmacy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing.service_category__pharmacy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_observation_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing._int_observation_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulance_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing._int_ambulance_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_lab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from cms_synthetic.claims_preprocessing._int_lab_institutional\n\n \n )\n\n \n)\n\nSELECT\n l.claim_id,\n l.claim_line_number,\n l.service_category_1,\n l.service_category_2,\n l.service_category_3,\n l.source_model_name\nFROM combine_line_models l", "relation_name": "cms_synthetic.claims_preprocessing._int_combined_institutional_line_level"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:34.714033Z", "completed_at": "2024-10-22T19:20:37.049569Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:37.050049Z", "completed_at": "2024-10-22T19:20:37.050056Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 2.440035104751587, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__combined_institutional_header_level", "compiled": true, "compiled_code": "\n\nWITH combine_header_models AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_other' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_other\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_maternity' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_maternity\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_med_surg' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_institutional_med_surg\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulatory_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_ambulatory_surgery_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_dialysis_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_dialysis_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_emergency_department_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_emergency_department_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_home_health_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_home_health_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_urgent_care_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_urgent_care_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_institutional\n\n \n )\n\n \n)\n\nSELECT\n h.claim_id,\n h.service_category_1,\n h.service_category_2,\n h.service_category_3,\n h.source_model_name\nFROM combine_header_models h", "relation_name": "cms_synthetic.claims_preprocessing._int_combined_institutional_header_level"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:35.581569Z", "completed_at": "2024-10-22T19:20:38.793677Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.793914Z", "completed_at": "2024-10-22T19:20:38.793919Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 3.3391940593719482, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__combined_professional", "compiled": true, "compiled_code": "\n\nWITH combined_professional_services AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_acute_inpatient_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_acute_inpatient_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulatory_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_ambulatory_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_dialysis_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_dialysis_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_emergency_department_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_emergency_department_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_home_health_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_home_health_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_lab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_lab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_other_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_other_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_radiology' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_radiology\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__office_based_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_office_based_visit_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_office_based_visit_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospital_or_clinic_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_inpatient_skilled_nursing_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_urgent_care_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_urgent_care_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_outpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_outpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__pharmacy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__pharmacy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_substance_use_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_radiology_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_observation_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_observation_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_dme_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_dme_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing._int_ambulance_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing._int_ambulance_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.claims_preprocessing.service_category__outpatient_surgery_professional\n\n \n )\n\n \n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.claim_line_id,\n p.service_category_1,\n p.service_category_2,\n p.service_category_3,\n p.tuva_last_run,\n p.source_model_name\nFROM combined_professional_services p", "relation_name": "cms_synthetic.claims_preprocessing._int_combined_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.923027Z", "completed_at": "2024-10-22T19:20:38.934363Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.934616Z", "completed_at": "2024-10-22T19:20:38.934621Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012553930282592773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__service_category_grouper", "compiled": true, "compiled_code": "\n\nwith service_category_1_mapping as(\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , b.source_model_name\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim a\n left join cms_synthetic.claims_preprocessing._int_combined_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join cms_synthetic.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'professional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , b.source_model_name\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim a\n left join cms_synthetic.claims_preprocessing._int_combined_institutional_header_level b\n on a.claim_id = b.claim_id\n left join cms_synthetic.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n , b.source_model_name\n from cms_synthetic.dbt_tom.service_category__stg_medical_claim a\n left join cms_synthetic.claims_preprocessing._int_combined_institutional_line_level b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join cms_synthetic.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n)\n\n, service_category_2_deduplication as(\n select \n claim_id\n , claim_line_number\n , claim_type\n , service_category_1\n , service_category_2\n , service_category_3\n ,original_service_cat_2\n ,original_service_cat_3\n , source_model_name\n , row_number() over (partition by claim_id, claim_line_number order by priority) as duplicate_row_number\n from service_category_1_mapping\n)\n\nselect\n d.claim_id\n , d.claim_line_number\n , d.claim_type\n , coalesce(service_category_1,'other') as service_category_1\n , coalesce(service_category_2,'other') as service_category_2\n , coalesce(service_category_3,'other') as service_category_3\n , original_service_cat_2\n , original_service_cat_3\n , duplicate_row_number\n , s.ccs_category\n , s.ccs_category_description\n , s.ms_drg_code\n , s.ms_drg_description\n , s.place_of_service_code\n , s.place_of_service_description\n , s.revenue_center_code\n , s.revenue_center_description\n , s.hcpcs_code\n , s.default_ccsr_category_ip\n , s.default_ccsr_category_op\n , s.default_ccsr_category_description_ip\n , s.default_ccsr_category_description_op\n , s.primary_taxonomy_code\n , s.primary_specialty_description\n , s.modality\n , s.bill_type_code\n , s.bill_type_description\n , d.source_model_name\n , s.data_source\nfrom service_category_2_deduplication d\ninner join cms_synthetic.dbt_tom.service_category__stg_medical_claim s on d.claim_id = s.claim_id\nand\nd.claim_line_number = s.claim_line_number\n--where duplicate_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.service_category_grouper"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.935799Z", "completed_at": "2024-10-22T19:20:38.940592Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.940808Z", "completed_at": "2024-10-22T19:20:38.940812Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005494117736816406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_medical_claim", "compiled": true, "compiled_code": "\n\n\nselect\n m.apr_drg_code\n , m.patient_id \n , d.patient_data_source_id\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , g.service_category_1\n , g.service_category_2\n , g.service_category_3\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , m.hcpcs_modifier_1\n , m.hcpcs_modifier_2\n , m.hcpcs_modifier_3\n , m.hcpcs_modifier_4\n , m.hcpcs_modifier_5\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.admit_source_code\n , m.admit_type_code\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_type\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , n.modality\n , m.billing_id\n , m.rendering_id\n , rend.primary_specialty_description as rend_primary_specialty_description\n , m.facility_id\n , m.discharge_disposition_code\n , m.paid_amount\n , m.charge_amount\n , m.allowed_amount\n , m.data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim m\ninner join cms_synthetic.claims_preprocessing.service_category_grouper g on m.claim_id = g.claim_id\nand\nm.claim_line_number = g.claim_line_number\nand g.duplicate_row_number = 1\ninner join cms_synthetic.claims_preprocessing.encounters__patient_data_source_id d on m.patient_id = d.patient_id\nand\nm.data_source = d.data_source\nleft join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join cms_synthetic.terminology.provider p on m.facility_id = p.npi\nleft join cms_synthetic.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join cms_synthetic.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join cms_synthetic.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join cms_synthetic.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join cms_synthetic.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join cms_synthetic.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join cms_synthetic.terminology.provider rend on m.rendering_id = rend.npi", "relation_name": "cms_synthetic.claims_preprocessing.encounters__stg_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.946328Z", "completed_at": "2024-10-22T19:20:38.952021Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.952481Z", "completed_at": "2024-10-22T19:20:38.952487Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010316133499145508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulance' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.ambulance__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.943370Z", "completed_at": "2024-10-22T19:20:38.952223Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.953321Z", "completed_at": "2024-10-22T19:20:38.953324Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011357307434082031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\nselect claim_id\n,patient_data_source_id\n,min(start_date) as start_date\n,max(end_date) as end_date \n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id\n ,patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id\n , enc.patient_data_source_id\n , c.start_date\n , c.end_date\n , enc.facility_id\n , enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c on enc.claim_id = c.claim_id\n and\n c.patient_data_source_id = enc.patient_data_source_id\n where\n service_category_2 in ('acute inpatient')\n and claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id\n , aa.claim_id as claim_id_a\n , bb.claim_id as claim_id_b\n , aa.row_num as row_num_a\n , bb.row_num as row_num_b\n , case\n -- Claims with same end_date and same facility_id should be merged:\n when aa.end_date = bb.end_date\n and aa.facility_id = bb.facility_id then 1\n\n -- Claims with different end_date and start_date that are\n -- adjacent (i.e. separated by 1 day) should be merged:\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n\n -- Claims with different end_date \n -- should be merged if they overlap:\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n where aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.949131Z", "completed_at": "2024-10-22T19:20:38.952955Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.954022Z", "completed_at": "2024-10-22T19:20:38.954025Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01152801513671875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n , end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulatory surgery center' -- include both professional and institutional claims as anchor events\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.asc__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.955936Z", "completed_at": "2024-10-22T19:20:38.965449Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.965917Z", "completed_at": "2024-10-22T19:20:38.965922Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011353015899658203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'dialysis' --both inst and professional as anchor\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.dialysis__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.958705Z", "completed_at": "2024-10-22T19:20:38.965719Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.966281Z", "completed_at": "2024-10-22T19:20:38.966285Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011197090148925781, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'durable medical equipment' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.dme__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.961469Z", "completed_at": "2024-10-22T19:20:38.966604Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.967558Z", "completed_at": "2024-10-22T19:20:38.967562Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01206827163696289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'emergency department' --both inst and prof\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.972037Z", "completed_at": "2024-10-22T19:20:38.977818Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.978255Z", "completed_at": "2024-10-22T19:20:38.978261Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009966135025024414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 in ('inpatient hospice')\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.969485Z", "completed_at": "2024-10-22T19:20:38.978016Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.978666Z", "completed_at": "2024-10-22T19:20:38.978669Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010585784912109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'home health' -- both prof and inst as anchors\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.home_health__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.974922Z", "completed_at": "2024-10-22T19:20:38.979210Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.980002Z", "completed_at": "2024-10-22T19:20:38.980006Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010818004608154297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient psychiatric'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.981201Z", "completed_at": "2024-10-22T19:20:38.987598Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.990813Z", "completed_at": "2024-10-22T19:20:38.990818Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011128902435302734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient rehabilitation'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.984379Z", "completed_at": "2024-10-22T19:20:38.990605Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.991231Z", "completed_at": "2024-10-22T19:20:38.991234Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01094198226928711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'skilled nursing'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b, \n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.987822Z", "completed_at": "2024-10-22T19:20:38.991862Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:38.992520Z", "completed_at": "2024-10-22T19:20:38.992523Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008437871932983398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient substance use'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.993688Z", "completed_at": "2024-10-22T19:20:39.001458Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.001909Z", "completed_at": "2024-10-22T19:20:39.001914Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009683847427368164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'lab' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.lab__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.996347Z", "completed_at": "2024-10-22T19:20:39.001713Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.002292Z", "completed_at": "2024-10-22T19:20:39.002295Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009495973587036133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits", "compiled": true, "compiled_code": "\n\nwith anchor as (\n select distinct\n mc.patient_data_source_id\n , mc.start_date\n , mc.claim_id\n , mc.claim_line_number\n , mc.service_category_1\n , mc.service_category_2\n , mc.service_category_3\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as mc\n inner join cms_synthetic.claims_preprocessing._int_combined_professional as p -- joining in all sc regardless of final priority\n on mc.claim_id = p.claim_id\n and mc.claim_line_number = p.claim_line_number\n where p.service_category_1 = 'office-based'\n)\n\nselect\n patient_data_source_id\n , start_date\n , claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:38.998955Z", "completed_at": "2024-10-22T19:20:39.002597Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.003418Z", "completed_at": "2024-10-22T19:20:39.003422Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007354021072387695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient hospice' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.005252Z", "completed_at": "2024-10-22T19:20:39.016458Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.017223Z", "completed_at": "2024-10-22T19:20:39.017228Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013519048690795898, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where \n service_category_2 in (\n 'outpatient hospital or clinic' -- both prof and inst\n , 'observation' -- orphaned obs that didn't roll up to other encounter\n )\n)\n\nselect distinct \n claim_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.009242Z", "completed_at": "2024-10-22T19:20:39.016722Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.017598Z", "completed_at": "2024-10-22T19:20:39.017600Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013649940490722656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__anchor_events", "compiled": true, "compiled_code": "\n\nwith multiple_sources as \n(\nselect distinct\n med.patient_data_source_id\n ,med.start_date\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.hcpcs_code,1,1) = 'J'\n)\n\n\nselect distinct \n patient_data_source_id\n ,start_date\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom multiple_sources", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.012955Z", "completed_at": "2024-10-22T19:20:39.017895Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.019299Z", "completed_at": "2024-10-22T19:20:39.019303Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014307975769042969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient psychiatric' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.021181Z", "completed_at": "2024-10-22T19:20:39.029846Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.030405Z", "completed_at": "2024-10-22T19:20:39.030410Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010838031768798828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient pt/ot/st' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.024045Z", "completed_at": "2024-10-22T19:20:39.030206Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.030974Z", "completed_at": "2024-10-22T19:20:39.030977Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010998010635375977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n patient_data_source_id\n , start_date\n , hcpcs_code\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient radiology' --both professional and inst\n)\n\nselect distinct \n patient_data_source_id\n , start_date\n , hcpcs_code\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.027068Z", "completed_at": "2024-10-22T19:20:39.030791Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.031642Z", "completed_at": "2024-10-22T19:20:39.031645Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010763168334960938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient rehabilitation'\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.033707Z", "completed_at": "2024-10-22T19:20:39.041187Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.041678Z", "completed_at": "2024-10-22T19:20:39.041684Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009515762329101562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient substance use'\n and claim_type = 'institutional'\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.039213Z", "completed_at": "2024-10-22T19:20:39.042339Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.043082Z", "completed_at": "2024-10-22T19:20:39.043086Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009858846664428711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__anchor_events", "compiled": true, "compiled_code": "\n\n select distinct\n claim_id\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('urgent care') --both inst and prof anchor", "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.036705Z", "completed_at": "2024-10-22T19:20:39.042549Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.043435Z", "completed_at": "2024-10-22T19:20:39.043438Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010627985000610352, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('outpatient surgery') --both inst and prof anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_category", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.044466Z", "completed_at": "2024-10-22T19:20:39.051775Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.054471Z", "completed_at": "2024-10-22T19:20:39.054477Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011768817901611328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.ambulance__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.ambulance__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.049697Z", "completed_at": "2024-10-22T19:20:39.055296Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.055981Z", "completed_at": "2024-10-22T19:20:39.055985Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007501840591430664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.052006Z", "completed_at": "2024-10-22T19:20:39.055779Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.056549Z", "completed_at": "2024-10-22T19:20:39.056553Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0078029632568359375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith base_data as (\n select distinct\n m.patient_data_source_id\n , m.start_date\n , m.end_date\n , m.claim_id\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as m\n inner join cms_synthetic.claims_preprocessing.asc__anchor_events as u\n on m.claim_id = u.claim_id\n)\n\n-- Determine Previous Maximum End Date\n, grouped_data as (\n select\n bd.*\n , max(end_date) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows between unbounded preceding and 1 preceding\n ) as previous_max_end_date\n from base_data as bd\n)\n\n-- Flag New Encounter Groups\n, flagged_data as (\n select\n gd.*\n , case \n when start_date > coalesce(previous_max_end_date, '1900-01-01') then 1 \n else 0 \n end as new_group_flag\n from grouped_data as gd\n)\n\n-- Assign Encounter Groups per Patient\n, numbered_data as (\n select\n fd.*\n , sum(new_group_flag) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows unbounded preceding\n ) as encounter_group\n from flagged_data as fd\n)\n\n-- Identify Unique Encounters\n, unique_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , min(start_date) as encounter_start_date\n from numbered_data\n group by\n patient_data_source_id\n , encounter_group\n)\n\n-- Assign asc encounter_id\n, numbered_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , row_number() over (\n order by patient_data_source_id, encounter_start_date\n ) as encounter_id\n from unique_encounters\n)\n\n-- Merge Encounters with Claims\nselect\n nd.patient_data_source_id\n , nd.start_date\n , nd.end_date\n , nd.claim_id\n , ne.encounter_id as old_encounter_id\nfrom numbered_data as nd\ninner join numbered_encounters as ne\n on nd.patient_data_source_id = ne.patient_data_source_id\n and nd.encounter_group = ne.encounter_group", "relation_name": "cms_synthetic.claims_preprocessing.asc__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.057164Z", "completed_at": "2024-10-22T19:20:39.060537Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.063084Z", "completed_at": "2024-10-22T19:20:39.063089Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007592201232910156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dialysis__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.dialysis__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.060901Z", "completed_at": "2024-10-22T19:20:39.066056Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.066740Z", "completed_at": "2024-10-22T19:20:39.066744Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006955862045288086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dme__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.dme__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.063458Z", "completed_at": "2024-10-22T19:20:39.066518Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.067317Z", "completed_at": "2024-10-22T19:20:39.067320Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007258176803588867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.068019Z", "completed_at": "2024-10-22T19:20:39.071472Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.074191Z", "completed_at": "2024-10-22T19:20:39.074197Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007999897003173828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.071847Z", "completed_at": "2024-10-22T19:20:39.077221Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.077666Z", "completed_at": "2024-10-22T19:20:39.077678Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0069849491119384766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.home_health__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.home_health__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.074666Z", "completed_at": "2024-10-22T19:20:39.077987Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.078709Z", "completed_at": "2024-10-22T19:20:39.078713Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007727146148681641, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.079048Z", "completed_at": "2024-10-22T19:20:39.086372Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.086942Z", "completed_at": "2024-10-22T19:20:39.086948Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009641885757446289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.082358Z", "completed_at": "2024-10-22T19:20:39.089973Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.090827Z", "completed_at": "2024-10-22T19:20:39.090832Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009581804275512695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.087452Z", "completed_at": "2024-10-22T19:20:39.091168Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.091885Z", "completed_at": "2024-10-22T19:20:39.091888Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009817123413085938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id\ngroup by encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.092241Z", "completed_at": "2024-10-22T19:20:39.095608Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.098222Z", "completed_at": "2024-10-22T19:20:39.098227Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007745027542114258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.lab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.lab__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.095794Z", "completed_at": "2024-10-22T19:20:39.101137Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.101757Z", "completed_at": "2024-10-22T19:20:39.101762Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007242918014526367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_em", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based visit'", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_em"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.098621Z", "completed_at": "2024-10-22T19:20:39.102118Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.102845Z", "completed_at": "2024-10-22T19:20:39.102849Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007497072219848633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_injections", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\nwhere substring(hcpcs_code,1,1) = 'J'", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_injections"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.103220Z", "completed_at": "2024-10-22T19:20:39.106609Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.109463Z", "completed_at": "2024-10-22T19:20:39.109469Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008085966110229492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_ptotst", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based pt/ot/st'", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_ptotst"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.106816Z", "completed_at": "2024-10-22T19:20:39.112233Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.112711Z", "completed_at": "2024-10-22T19:20:39.112715Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007277250289916992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_radiology", "compiled": true, "compiled_code": "\n\nwith max_encounter as (\n select max(old_encounter_id) as max_encounter_id\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits\n)\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,mc.hcpcs_code\n ,dense_rank() over (order by ov.patient_data_source_id, ov.start_date, mc.hcpcs_code) + mx.max_encounter_id as old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\ncross join max_encounter mx\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\ninner join cms_synthetic.claims_preprocessing.service_category__office_based_radiology scrad on mc.claim_id = scrad.claim_id\n and mc.claim_line_number = scrad.claim_line_number", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_radiology"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.109880Z", "completed_at": "2024-10-22T19:20:39.113016Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.113674Z", "completed_at": "2024-10-22T19:20:39.113676Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007356166839599609, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_surgery", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based surgery'", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_surgery"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.114136Z", "completed_at": "2024-10-22T19:20:39.119711Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.120265Z", "completed_at": "2024-10-22T19:20:39.120270Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007889032363891602, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_telehealth", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'telehealth visit'", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_telehealth"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.117199Z", "completed_at": "2024-10-22T19:20:39.124551Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.125274Z", "completed_at": "2024-10-22T19:20:39.125279Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009178876876831055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospice__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.120644Z", "completed_at": "2024-10-22T19:20:39.126117Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.126829Z", "completed_at": "2024-10-22T19:20:39.126833Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009922981262207031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.127250Z", "completed_at": "2024-10-22T19:20:39.133885Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.134644Z", "completed_at": "2024-10-22T19:20:39.134649Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009078741073608398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__generate_encounter_id", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom cms_synthetic.claims_preprocessing.outpatient_injections__anchor_events", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.131587Z", "completed_at": "2024-10-22T19:20:39.135452Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.138897Z", "completed_at": "2024-10-22T19:20:39.138903Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012392997741699219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_psych__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.136368Z", "completed_at": "2024-10-22T19:20:39.140438Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.143320Z", "completed_at": "2024-10-22T19:20:39.143326Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009280920028686523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_ptotst__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.140742Z", "completed_at": "2024-10-22T19:20:39.146407Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.146977Z", "completed_at": "2024-10-22T19:20:39.146981Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007748126983642578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__generate_encounter_id", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,hcpcs_code\n,dense_rank() over (order by patient_data_source_id, start_date, hcpcs_code) as old_encounter_id\nfrom cms_synthetic.claims_preprocessing.outpatient_radiology__anchor_events", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.143785Z", "completed_at": "2024-10-22T19:20:39.147308Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.148003Z", "completed_at": "2024-10-22T19:20:39.148007Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007837057113647461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_rehab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.148343Z", "completed_at": "2024-10-22T19:20:39.154028Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.154518Z", "completed_at": "2024-10-22T19:20:39.154524Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007903814315795898, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_substance_use__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.151664Z", "completed_at": "2024-10-22T19:20:39.157260Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.157848Z", "completed_at": "2024-10-22T19:20:39.157854Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007294893264770508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.urgent_care__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.154939Z", "completed_at": "2024-10-22T19:20:39.158527Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.159212Z", "completed_at": "2024-10-22T19:20:39.159216Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007835149765014648, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_surgery__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.159897Z", "completed_at": "2024-10-22T19:20:39.167086Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.167590Z", "completed_at": "2024-10-22T19:20:39.167596Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00945281982421875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.ambulance__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'ambulance'", "relation_name": "cms_synthetic.claims_preprocessing.ambulance__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.163125Z", "completed_at": "2024-10-22T19:20:39.170164Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.170721Z", "completed_at": "2024-10-22T19:20:39.170725Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01112818717956543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.168071Z", "completed_at": "2024-10-22T19:20:39.171507Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.172167Z", "completed_at": "2024-10-22T19:20:39.172170Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009356021881103516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__start_end_dates", "compiled": true, "compiled_code": "\n\nselect\n patient_data_source_id\n , old_encounter_id\n , min(start_date) as encounter_start_date\n , max(end_date) as encounter_end_date\nfrom cms_synthetic.claims_preprocessing.asc__generate_encounter_id\ngroup by\n patient_data_source_id\n , old_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.asc__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.172488Z", "completed_at": "2024-10-22T19:20:39.177819Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.178266Z", "completed_at": "2024-10-22T19:20:39.178272Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.00723719596862793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dialysis__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.dialysis__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.175180Z", "completed_at": "2024-10-22T19:20:39.181202Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.181815Z", "completed_at": "2024-10-22T19:20:39.181821Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009964704513549805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.dme__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'durable medical equipment'", "relation_name": "cms_synthetic.claims_preprocessing.dme__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.178617Z", "completed_at": "2024-10-22T19:20:39.182664Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.183254Z", "completed_at": "2024-10-22T19:20:39.183257Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005728960037231445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.emergency_department__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n\n-- ensuring each claim is only attributed to one encounter with claim_attribution_number\n,inst_and_prof as (\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date\n\nunion all \n\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,med.claim_id\n,med.claim_line_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_outpatient_institutional inst on med.claim_id = inst.claim_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date \nwhere dat.claim_id <> med.claim_id\n)\n\nselect distinct encounter_id\n,encounter_start_date\n,encounter_end_date\n,claim_id\n,claim_line_number\n,row_number () over (partition by claim_id ,claim_line_number order by encounter_id) as claim_attribution_number\nfrom inst_and_prof", "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.183569Z", "completed_at": "2024-10-22T19:20:39.189092Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.189573Z", "completed_at": "2024-10-22T19:20:39.189611Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007448911666870117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n, join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.186724Z", "completed_at": "2024-10-22T19:20:39.189936Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.192990Z", "completed_at": "2024-10-22T19:20:39.192995Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01001119613647461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.home_health__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.home_health__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.190133Z", "completed_at": "2024-10-22T19:20:39.193881Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.194536Z", "completed_at": "2024-10-22T19:20:39.194541Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0057201385498046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.194920Z", "completed_at": "2024-10-22T19:20:39.200578Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.201123Z", "completed_at": "2024-10-22T19:20:39.201148Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007811069488525391, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.197841Z", "completed_at": "2024-10-22T19:20:39.201476Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.206148Z", "completed_at": "2024-10-22T19:20:39.206153Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011928081512451172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.201673Z", "completed_at": "2024-10-22T19:20:39.207088Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.207923Z", "completed_at": "2024-10-22T19:20:39.207927Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0076389312744140625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n-- ,med.start_date\n-- ,med.end_date\n-- ,med.place_of_service_code\n-- ,med.place_of_service_description\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med\ninner join cms_synthetic.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.208248Z", "completed_at": "2024-10-22T19:20:39.215237Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.215791Z", "completed_at": "2024-10-22T19:20:39.215803Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009293794631958008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.lab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'lab'", "relation_name": "cms_synthetic.claims_preprocessing.lab__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.211027Z", "completed_at": "2024-10-22T19:20:39.216147Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.219246Z", "completed_at": "2024-10-22T19:20:39.219251Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011790990829467773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_union", "compiled": true, "compiled_code": "\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit radiology' as encounter_type\n,0 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_radiology\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit surgery' as encounter_type\n,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_surgery\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit injections' as encounter_type\n,2 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_injections\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit pt/ot/st' as encounter_type\n,3 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_ptotst\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit' as encounter_type\n,4 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_em\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'telehealth' as encounter_type\n,5 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit - other' as encounter_type\n,9999 as priority_number\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_union"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.216363Z", "completed_at": "2024-10-22T19:20:39.220188Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.220902Z", "completed_at": "2024-10-22T19:20:39.220905Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005934953689575195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospice__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.221239Z", "completed_at": "2024-10-22T19:20:39.226551Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.227051Z", "completed_at": "2024-10-22T19:20:39.227056Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007424831390380859, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.224180Z", "completed_at": "2024-10-22T19:20:39.227372Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.229921Z", "completed_at": "2024-10-22T19:20:39.229925Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009318113327026367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_injections__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.227585Z", "completed_at": "2024-10-22T19:20:39.231123Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.233812Z", "completed_at": "2024-10-22T19:20:39.233817Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007554769515991211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_psych__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.231584Z", "completed_at": "2024-10-22T19:20:39.237221Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.237817Z", "completed_at": "2024-10-22T19:20:39.237822Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.007445812225341797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_ptotst__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.234775Z", "completed_at": "2024-10-22T19:20:39.238692Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.241563Z", "completed_at": "2024-10-22T19:20:39.241568Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010291814804077148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , m.hcpcs_code\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_radiology__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nand\nm.hcpcs_code = u.hcpcs_code", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.238913Z", "completed_at": "2024-10-22T19:20:39.242443Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.246605Z", "completed_at": "2024-10-22T19:20:39.246610Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.00921010971069336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_rehab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.242649Z", "completed_at": "2024-10-22T19:20:39.247801Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.250412Z", "completed_at": "2024-10-22T19:20:39.250417Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009188175201416016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_substance_use__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.247987Z", "completed_at": "2024-10-22T19:20:39.251448Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.254350Z", "completed_at": "2024-10-22T19:20:39.254354Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008064031600952148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.urgent_care__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.251637Z", "completed_at": "2024-10-22T19:20:39.255229Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.258699Z", "completed_at": "2024-10-22T19:20:39.258705Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008587121963500977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim m\ninner join cms_synthetic.claims_preprocessing.outpatient_surgery__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.255776Z", "completed_at": "2024-10-22T19:20:39.260348Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.263568Z", "completed_at": "2024-10-22T19:20:39.263573Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.009552240371704102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect\n dat.old_encounter_id\n , dat.encounter_start_date\n , dat.encounter_end_date\n , med.claim_id\n , med.claim_line_number\n , row_number() over (\n partition by med.claim_id, med.claim_line_number\n order by dat.old_encounter_id\n ) as claim_attribution_number\nfrom cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as med\ninner join cms_synthetic.claims_preprocessing.asc__start_end_dates as dat\n on med.patient_data_source_id = dat.patient_data_source_id\n and med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "cms_synthetic.claims_preprocessing.asc__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.260575Z", "completed_at": "2024-10-22T19:20:39.264397Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.264898Z", "completed_at": "2024-10-22T19:20:39.264902Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0069577693939208984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,dist_encounter as (\nselect distinct old_encounter_id\n,encounter_type\n,priority_number\nfrom rank_cte\n)\n\nselect \nold_encounter_id\n,encounter_type\n,priority_number\n,row_number() over (partition by old_encounter_id order by priority_number) as relative_rank\nfrom dist_encounter", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_encounter_ranking"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.266038Z", "completed_at": "2024-10-22T19:20:39.268750Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.269007Z", "completed_at": "2024-10-22T19:20:39.269013Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0034661293029785156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_claim_line", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,crosswalk_cte as (\nselect old_encounter_id\n,encounter_type\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_encounter_ranking\nwhere relative_rank = 1\n)\n\nselect r.claim_id\n, r.claim_line_number\n, r.old_encounter_id\n, x.encounter_type\nfrom rank_cte r\ninner join crosswalk_cte x on r.old_encounter_id = x.old_encounter_id", "relation_name": "cms_synthetic.claims_preprocessing.office_visits__int_office_visits_claim_line"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.270182Z", "completed_at": "2024-10-22T19:20:39.276860Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.277060Z", "completed_at": "2024-10-22T19:20:39.277064Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007375955581665039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "compiled": true, "compiled_code": "\n\nwith cte as \n(\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'acute inpatient' as encounter_type\n ,'inpatient' as encounter_group\n ,0 as priority_number\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'acute inpatient' as encounter_type\n,'inpatient' as encounter_group\n,0 as priority_number\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'emergency department' as encounter_type\n,'outpatient' as encounter_group\n,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.emergency_department__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.emergency_department__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient hospice' as encounter_type\n,'inpatient' as encounter_group\n,1 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_hospice__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__generate_encounter_id enc\ninner join cms_synthetic.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,9 as priority_number --priority set in combined office visit encounter ranking model\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type = 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,10 as priority_number --priority set in combined office visit encounter ranking model\nfrom cms_synthetic.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type <> 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'urgent care' as encounter_type\n,'outpatient' as encounter_group\n,11 as priority_number --urgent care needs to be lower than ed and inpatient\nfrom cms_synthetic.claims_preprocessing.urgent_care__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient psych' as encounter_type\n,'outpatient' as encounter_group\n,12 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_psych__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient rehabilitation' as encounter_type\n,'outpatient' as encounter_group\n,13 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_rehab__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulatory surgery center' as encounter_type\n,'outpatient' as encounter_group\n,14 as priority_number \nfrom cms_synthetic.claims_preprocessing.asc__match_claims_to_anchor\n\nunion all\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospital or clinic' as encounter_type\n,'outpatient' as encounter_group\n,999 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor --lowest outpatient priority, roll up to more specific encounter type when available\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient surgery' as encounter_type\n,'outpatient' as encounter_group\n,18 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_surgery__match_claims_to_anchor \n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dialysis' as encounter_type\n,'outpatient' as encounter_group\n,15 as priority_number \nfrom cms_synthetic.claims_preprocessing.dialysis__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospice' as encounter_type\n,'outpatient' as encounter_group\n,16 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_hospice__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'home health' as encounter_type\n,'outpatient' as encounter_group\n,17 as priority_number \nfrom cms_synthetic.claims_preprocessing.home_health__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient injections' as encounter_type\n,'outpatient' as encounter_group\n,19 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_injections__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient pt/ot/st' as encounter_type\n,'outpatient' as encounter_group\n,20 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient substance use' as encounter_type\n,'outpatient' as encounter_group\n,21 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient radiology' as encounter_type\n,'outpatient' as encounter_group\n,22 as priority_number \nfrom cms_synthetic.claims_preprocessing.outpatient_radiology__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'lab - orphaned' as encounter_type\n,'other' as encounter_group\n,1000000 as priority_number \nfrom cms_synthetic.claims_preprocessing.lab__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dme - orphaned' as encounter_type\n,'other' as encounter_group\n,1000001 as priority_number \nfrom cms_synthetic.claims_preprocessing.dme__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulance - orphaned' as encounter_type\n,'other' as encounter_group\n,1000002 as priority_number \nfrom cms_synthetic.claims_preprocessing.ambulance__match_claims_to_anchor \n\n)\n\n\nselect \n claim_id\n, claim_line_number\n, encounter_id as old_encounter_id\n, dense_rank() over (order by encounter_type, encounter_id) as encounter_id\n, encounter_type\n, encounter_group\n, priority_number\n, row_number() over (partition by claim_id , claim_line_number order by priority_number) as claim_line_attribution_number\nfrom cte", "relation_name": "cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.284532Z", "completed_at": "2024-10-22T19:20:39.294372Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.294998Z", "completed_at": "2024-10-22T19:20:39.295003Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016371965408325195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.ambulance__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulance - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type -- not changing grain, but bringing into final\n, encounter_group\n\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.ambulance__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.279695Z", "completed_at": "2024-10-22T19:20:39.294591Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.295378Z", "completed_at": "2024-10-22T19:20:39.295382Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.017093181610107422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'acute inpatient'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when d.service_category_3 in ( 'l/d - cesarean delivery', 'l/d - vaginal delivery') then 1 else 0 end ) as delivery_flag\n ,max(case when d.service_category_3 ='l/d - cesarean delivery' then 1 else 0 end ) as cesarean_delivery\n ,max(case when d.service_category_3 ='l/d - vaginal delivery' then 1 else 0 end ) as vaginal_delivery\n ,max(case when d.service_category_3 in ('l/d - newborn','l/d - newborn nicu') then 1 else 0 end ) as newborn_flag\n ,max(case when d.service_category_3 ='l/d - newborn nicu' then 1 else 0 end ) as nicu_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n,encounter_group\n)\n\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, sc.observation_flag\n, sc.ed_flag\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.delivery_flag\n, case when sc.cesarean_delivery = 1 then 'cesarean'\n when sc.vaginal_delivery = 1 then 'vaginal'\n else null end as delivery_type\n, sc.newborn_flag\n, sc.nicu_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.acute_inpatient__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.acute_inpatient__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.288555Z", "completed_at": "2024-10-22T19:20:39.294770Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.295727Z", "completed_at": "2024-10-22T19:20:39.295730Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016856908798217773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__encounter_grain", "compiled": true, "compiled_code": "\n\n\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,ed.encounter_start_date \n ,ed.encounter_end_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulatory surgery center'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.asc__start_end_dates ed on cli.old_encounter_id = ed.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, datediff(\n day,\n d.encounter_start_date,\n d.encounter_end_date\n ) as length_of_stay\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.asc__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.298066Z", "completed_at": "2024-10-22T19:20:39.326109Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.326596Z", "completed_at": "2024-10-22T19:20:39.326601Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.029903173446655273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_condition", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the condition table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_1 as source_code\n , 1 as diagnosis_rank\n , diagnosis_poa_1 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere diagnosis_code_1 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n\t , discharge_date\n\t , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_2 as source_code\n , 2 as diagnosis_rank\n , diagnosis_poa_2 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_2 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_3 as source_code\n , 3 as diagnosis_rank\n , diagnosis_poa_3 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_3 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_4 as source_code\n , 4 as diagnosis_rank\n , diagnosis_poa_4 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_4 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_5 as source_code\n , 5 as diagnosis_rank\n , diagnosis_poa_5 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_5 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_6 as source_code\n , 6 as diagnosis_rank\n , diagnosis_poa_6 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_6 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_7 as source_code\n , 7 as diagnosis_rank\n , diagnosis_poa_7 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_7 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_8 as source_code\n , 8 as diagnosis_rank\n , diagnosis_poa_8 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_8 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_9 as source_code\n , 9 as diagnosis_rank\n , diagnosis_poa_9 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_9 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_10 as source_code\n , 10 as diagnosis_rank\n , diagnosis_poa_10 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_10 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_11 as source_code\n , 11 as diagnosis_rank\n , diagnosis_poa_11 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_11 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_12 as source_code\n , 12 as diagnosis_rank\n , diagnosis_poa_12 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_12 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_13 as source_code\n , 13 as diagnosis_rank\n , diagnosis_poa_13 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_13 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_14 as source_code\n , 14 as diagnosis_rank\n , diagnosis_poa_14 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_14 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_15 as source_code\n , 15 as diagnosis_rank\n , diagnosis_poa_15 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_15 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_16 as source_code\n , 16 as diagnosis_rank\n , diagnosis_poa_16 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_16 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_17 as source_code\n , 17 as diagnosis_rank\n , diagnosis_poa_17 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_17 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_18 as source_code\n , 18 as diagnosis_rank\n , diagnosis_poa_18 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_18 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_19 as source_code\n , 19 as diagnosis_rank\n , diagnosis_poa_19 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_19 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_20 as source_code\n , 20 as diagnosis_rank\n , diagnosis_poa_20 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_20 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_21 as source_code\n , 21 as diagnosis_rank\n , diagnosis_poa_21 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_21 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_22 as source_code\n , 22 as diagnosis_rank\n , diagnosis_poa_22 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_22 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_23 as source_code\n , 23 as diagnosis_rank\n , diagnosis_poa_23 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_23 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_24 as source_code\n , 24 as diagnosis_rank\n , diagnosis_poa_24 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_24 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_25 as source_code\n , 25 as diagnosis_rank\n , diagnosis_poa_25 as present_on_admit_code\n , data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(CAST(unpivot_cte.data_source AS TEXT) || '_' || CAST(unpivot_cte.claim_id AS TEXT) || '_' || CAST(unpivot_cte.diagnosis_rank AS TEXT) || '_' || CAST(unpivot_cte.source_code AS TEXT) as TEXT)\n as condition_id\n\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.recorded_date as date ) as recorded_date\n , try_cast( null as date ) as onset_date\n , try_cast( null as date ) as resolved_date\n , cast('active' as TEXT ) as status\n , cast(unpivot_cte.condition_type as TEXT ) as condition_type\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_cm is not null then 'icd-10-cm'\n end as TEXT\n ) as normalized_code_type\n , cast(icd.icd_10_cm as TEXT ) as normalized_code\n , cast(icd.long_description as TEXT ) as normalized_description\n , cast(unpivot_cte.diagnosis_rank as integer ) as condition_rank\n , cast(unpivot_cte.present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(poa.present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join cms_synthetic.terminology.icd_10_cm icd\n on unpivot_cte.source_code = icd.icd_10_cm\nleft join cms_synthetic.terminology.present_on_admission as poa\n on unpivot_cte.present_on_admit_code = poa.present_on_admit_code", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.308005Z", "completed_at": "2024-10-22T19:20:39.326338Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.326997Z", "completed_at": "2024-10-22T19:20:39.327001Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030047893524169922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_procedure", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the procedure table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id as claim_id\n , claim_line_number as procedure_sequence_id\n , patient_id as patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as procedure_date\n , 'hcpcs' as source_code_type\n , hcpcs_code as source_code\n , rendering_id as practitioner_npi\n , hcpcs_modifier_1 as modifier_1\n , hcpcs_modifier_2 as modifier_2\n , hcpcs_modifier_3 as modifier_3\n , hcpcs_modifier_4 as modifier_4\n , hcpcs_modifier_5 as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim\nwhere hcpcs_code is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 1 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_1 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_1 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_1 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 2 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_2 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_2 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_2 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 3 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_3 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_3 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_3 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 4 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_4 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_4 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_4 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 5 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_5 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_5 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_5 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 6 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_6 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_6 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_6 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 7 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_7 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_7 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_7 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 8 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_8 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_8 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_8 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 9 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_9 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_9 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_9 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 10 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_10 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_10 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_10 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 11 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_11 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_11 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_11 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 12 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_12 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_12 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_12 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 13 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_13 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_13 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_13 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 14 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_14 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_14 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_14 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 15 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_15 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_15 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_15 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 16 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_16 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_16 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_16 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 17 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_17 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_17 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_17 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 18 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_18 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_18 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_18 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 19 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_19 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_19 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_19 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 20 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_20 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_20 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_20 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 21 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_21 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_21 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_21 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 22 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_22 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_22 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_22 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 23 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_23 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_23 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_23 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 24 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_24 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_24 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_24 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 25 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_25 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_25 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(unpivot_cte.data_source || '_' || unpivot_cte.claim_id || '_' || unpivot_cte.procedure_sequence_id || '_' || unpivot_cte.source_code || case when unpivot_cte.modifier_1 is not null then CONCAT('_', unpivot_cte.modifier_1) else '' end || case when unpivot_cte.modifier_2 is not null then CONCAT('_', unpivot_cte.modifier_2) else '' end || case when unpivot_cte.modifier_3 is not null then CONCAT('_', unpivot_cte.modifier_3) else '' end || case when unpivot_cte.modifier_4 is not null then CONCAT('_', unpivot_cte.modifier_4) else '' end || case when unpivot_cte.modifier_5 is not null then CONCAT('_', unpivot_cte.modifier_5) else '' end || case when unpivot_cte.practitioner_npi is not null then CONCAT('_', unpivot_cte.practitioner_npi) else '' end as TEXT)\n as procedure_id\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.procedure_date as date ) as procedure_date\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n end\n as TEXT ) as normalized_code_type\n , cast (\n coalesce (\n icd.icd_10_pcs\n , hcpcs.hcpcs\n )\n as TEXT ) as normalized_code\n , cast (\n coalesce (\n icd.description\n , hcpcs.short_description\n )\n as TEXT ) as normalized_description\n , cast(unpivot_cte.modifier_1 as TEXT ) as modifier_1\n , cast(unpivot_cte.modifier_2 as TEXT ) as modifier_2\n , cast(unpivot_cte.modifier_3 as TEXT ) as modifier_3\n , cast(unpivot_cte.modifier_4 as TEXT ) as modifier_4\n , cast(unpivot_cte.modifier_5 as TEXT ) as modifier_5\n , cast(unpivot_cte.practitioner_npi as TEXT ) as practitioner_id\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join cms_synthetic.terminology.icd_10_pcs as icd\n on unpivot_cte.source_code = icd.icd_10_pcs\nleft join cms_synthetic.terminology.hcpcs_level_2 as hcpcs\n on unpivot_cte.source_code = hcpcs.hcpcs", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.321889Z", "completed_at": "2024-10-22T19:20:39.327326Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.328094Z", "completed_at": "2024-10-22T19:20:39.328098Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0309298038482666, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.dialysis__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dialysis'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.dialysis__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.329806Z", "completed_at": "2024-10-22T19:20:39.342709Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.343891Z", "completed_at": "2024-10-22T19:20:39.343896Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.015530109405517578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.dme__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dme - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.dme__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.333948Z", "completed_at": "2024-10-22T19:20:39.342920Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.344472Z", "completed_at": "2024-10-22T19:20:39.344476Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015847206115722656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'emergency department'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.emergency_department__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n,encounter_header_values as (\n select distinct patient_data_source_id\n ,data_source\n ,encounter_id\n from detail_values\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n, encounter_group\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, ehv.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n a.encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, sc.observation_flag\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, ehv.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.emergency_department__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\ninner join encounter_header_values ehv on x.encounter_id = ehv.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.emergency_department__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.339285Z", "completed_at": "2024-10-22T19:20:39.344250Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.346066Z", "completed_at": "2024-10-22T19:20:39.346070Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016531944274902344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__orphaned_claims", "compiled": true, "compiled_code": "\n\nwith cte as (\n select stg.claim_id\n ,stg.claim_line_number\n ,stg.service_category_1\n ,stg.service_category_2\n ,stg.service_category_3\n ,stg.claim_type\n ,stg.claim_start_date\n ,stg.claim_end_date\n ,stg.start_date\n ,stg.end_date\n ,stg.patient_data_source_id\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n left join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk enc on stg.claim_id = enc.claim_id\n and\n stg.claim_line_number = enc.claim_line_number\n where enc.claim_id is null -- missing from encounter mapping table\n)\n\n,max_encounter as (\n select max(encounter_id) max_encounter_id\n from cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk\n)\n\nselect \n claim_id\n, claim_line_number\n, dense_rank() over (order by patient_data_source_id, claim_id) + max_encounter.max_encounter_id as encounter_id\n, 'orphaned claim' as encounter_type\n, 'other' as encounter_group\nfrom cte\ncross join max_encounter", "relation_name": "cms_synthetic.claims_preprocessing.encounters__orphaned_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.349221Z", "completed_at": "2024-10-22T19:20:39.363758Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.364364Z", "completed_at": "2024-10-22T19:20:39.364370Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.017616987228393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.home_health__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'home health'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.home_health__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.353883Z", "completed_at": "2024-10-22T19:20:39.366578Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.368062Z", "completed_at": "2024-10-22T19:20:39.368069Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020364999771118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n ,encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_hospice__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_hospice__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.358939Z", "completed_at": "2024-10-22T19:20:39.366823Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.368760Z", "completed_at": "2024-10-22T19:20:39.368788Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020168066024780273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_psych__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_psych__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.370162Z", "completed_at": "2024-10-22T19:20:39.381938Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.389942Z", "completed_at": "2024-10-22T19:20:39.389949Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02259993553161621, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n, encounter_group\n ,encounter_type\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_rehab__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_rehab__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.376598Z", "completed_at": "2024-10-22T19:20:39.390788Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.391446Z", "completed_at": "2024-10-22T19:20:39.391449Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015943050384521484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient skilled nursing'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_snf__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_snf__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.382218Z", "completed_at": "2024-10-22T19:20:39.391240Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.391976Z", "completed_at": "2024-10-22T19:20:39.391979Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016199111938476562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.inpatient_substance_use__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on c.facility_id = b.npi\nleft join cms_synthetic.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join cms_synthetic.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join cms_synthetic.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join cms_synthetic.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join cms_synthetic.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.claims_preprocessing.inpatient_substance_use__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.392509Z", "completed_at": "2024-10-22T19:20:39.399112Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.408709Z", "completed_at": "2024-10-22T19:20:39.408715Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.017780780792236328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.lab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'lab - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.lab__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.404822Z", "completed_at": "2024-10-22T19:20:39.410244Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.414441Z", "completed_at": "2024-10-22T19:20:39.414446Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016040802001953125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_hospice__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospice__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.399320Z", "completed_at": "2024-10-22T19:20:39.410427Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.414830Z", "completed_at": "2024-10-22T19:20:39.414833Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016776084899902344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visit__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit surgery' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_surgery\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit injections' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_injections\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit radiology' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_radiology\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit - other' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_em\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'telehealth' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit pt/ot/st' as encounter_type\n from cms_synthetic.claims_preprocessing.office_visits__int_office_visits\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_group = 'office based'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n and\n d.encounter_type = cli.encounter_type\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_physician as \n(\n select encounter_id\n , billing_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where billing_id is not null\n group by \n encounter_id\n , billing_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, phy.billing_id\n, b2.provider_first_name || ' ' || b2.provider_last_name as provider_name\n, b2.primary_specialty_description as provider_specialty\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, hcpc.ccs_category\n, hcpc.ccs_category_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_physician phy on d.encounter_id = phy.encounter_id\nand\nphy.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.provider b2\n on phy.billing_id = b2.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.office_visit__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.410635Z", "completed_at": "2024-10-22T19:20:39.415737Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.416400Z", "completed_at": "2024-10-22T19:20:39.416403Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0066869258880615234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospital or clinic'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.421883Z", "completed_at": "2024-10-22T19:20:39.426585Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.430797Z", "completed_at": "2024-10-22T19:20:39.430801Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014698028564453125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_psych__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_psych__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.417591Z", "completed_at": "2024-10-22T19:20:39.430563Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.431234Z", "completed_at": "2024-10-22T19:20:39.431238Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015351057052612305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_injections__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient injections'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where substring(hcpcs_code,1,1)='J'\n\n group by \n encounter_id\n , hcpcs_code\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_injections__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.426826Z", "completed_at": "2024-10-22T19:20:39.431891Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.432658Z", "completed_at": "2024-10-22T19:20:39.432662Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0068891048431396484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_ptotst__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient pt/ot/st'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_ptotst__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.434078Z", "completed_at": "2024-10-22T19:20:39.444977Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.450507Z", "completed_at": "2024-10-22T19:20:39.450513Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018173933029174805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_radiology__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient radiology'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,hcpcs_code as \n(\n select distinct hcpcs_code\n ,encounter_id\n from detail_values\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join hcpcs_code hcpc on d.encounter_id = hcpc.encounter_id\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_radiology__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.438587Z", "completed_at": "2024-10-22T19:20:39.450269Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.451224Z", "completed_at": "2024-10-22T19:20:39.451227Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018291234970092773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_rehab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_rehab__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.446143Z", "completed_at": "2024-10-22T19:20:39.451994Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.453206Z", "completed_at": "2024-10-22T19:20:39.453211Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014917135238647461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_substance_use__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_substance_use__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.454480Z", "completed_at": "2024-10-22T19:20:39.463609Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.468551Z", "completed_at": "2024-10-22T19:20:39.468580Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015880823135375977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.outpatient_surgery__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient surgery'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.outpatient_surgery__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.459065Z", "completed_at": "2024-10-22T19:20:39.469101Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.469677Z", "completed_at": "2024-10-22T19:20:39.469681Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016152143478393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from cms_synthetic.claims_preprocessing.urgent_care__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'urgent care'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.urgent_care__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.463892Z", "completed_at": "2024-10-22T19:20:39.470007Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.470700Z", "completed_at": "2024-10-22T19:20:39.470704Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012258052825927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__condition", "compiled": true, "compiled_code": "\n\n\nwith all_conditions as (\n select *\nfrom cms_synthetic.dbt_tom.core__stg_claims_condition\nunion all\nselect *\nfrom cms_synthetic.dbt_tom.core__stg_clinical_condition\n\n\n)\n\n\n\n\nselect\n all_conditions.condition_id\n , all_conditions.patient_id\n , all_conditions.encounter_id\n , all_conditions.claim_id\n , all_conditions.recorded_date\n , all_conditions.onset_date\n , all_conditions.resolved_date\n , all_conditions.status\n , all_conditions.condition_type\n , all_conditions.source_code_type\n , all_conditions.source_code\n , all_conditions.source_description\n , case\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\n when icd10.icd_10_cm is not null then 'icd-10-cm'\n when icd9.icd_9_cm is not null then 'icd-9-cm'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n all_conditions.normalized_code\n , icd10.icd_10_cm\n , icd9.icd_9_cm\n , snomed_ct.snomed_ct) as normalized_code\n , coalesce(\n all_conditions.normalized_description\n , icd10.short_description\n , icd9.short_description\n , snomed_ct.description) as normalized_description\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_conditions.condition_rank\n , all_conditions.present_on_admit_code\n , all_conditions.present_on_admit_description\n , all_conditions.data_source\n , all_conditions.tuva_last_run\nfrom\nall_conditions\nleft join cms_synthetic.terminology.icd_10_cm icd10\n on all_conditions.source_code_type = 'icd-10-cm'\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\nleft join cms_synthetic.terminology.icd_9_cm icd9\n on all_conditions.source_code_type = 'icd-9-cm'\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on all_conditions.source_code_type = 'snomed-ct'\n and all_conditions.source_code = snomed_ct.snomed_ct\n\n\n\n\n", "relation_name": "cms_synthetic.core.condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.472028Z", "completed_at": "2024-10-22T19:20:39.490380Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.496678Z", "completed_at": "2024-10-22T19:20:39.496686Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02656102180480957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__procedure", "compiled": true, "compiled_code": "\n\n\nwith all_procedures as (\nselect * from cms_synthetic.dbt_tom.core__stg_claims_procedure\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_procedure\n\n\n)\n\n\n\nselect\n all_procedures.procedure_id\n , all_procedures.patient_id\n , all_procedures.encounter_id\n , all_procedures.claim_id\n , all_procedures.procedure_date\n , all_procedures.source_code_type\n , all_procedures.source_code\n , all_procedures.source_description\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n end as normalized_code_type\n , coalesce(all_procedures.normalized_code\n , icd10.icd_10_pcs\n , icd9.icd_9_pcs\n , hcpcs.hcpcs\n ,snomed_ct.snomed_ct ) as normalized_code\n , coalesce(all_procedures.normalized_description\n , icd10.description\n , icd9.short_description\n , hcpcs.short_description\n , snomed_ct.description) normalized_description\n , case when coalesce(all_procedures.normalized_code, all_procedures.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_procedures.modifier_1\n , all_procedures.modifier_2\n , all_procedures.modifier_3\n , all_procedures.modifier_4\n , all_procedures.modifier_5\n , all_procedures.practitioner_id\n , all_procedures.data_source\n , all_procedures.tuva_last_run\nfrom all_procedures\nleft join cms_synthetic.terminology.icd_10_pcs icd10\n on all_procedures.source_code_type = 'icd-10-pcs'\n and all_procedures.source_code = icd10.icd_10_pcs\nleft join cms_synthetic.terminology.icd_9_pcs icd9\n on all_procedures.source_code_type = 'icd-9-pcs'\n and all_procedures.source_code = icd9.icd_9_pcs\nleft join cms_synthetic.terminology.hcpcs_level_2 hcpcs\n on all_procedures.source_code_type = 'hcpcs'\n and all_procedures.source_code = hcpcs.hcpcs\nleft join cms_synthetic.terminology.snomed_ct snomed_ct\n on all_procedures.source_code_type = 'snomed-ct'\n and all_procedures.source_code = snomed_ct.snomed_ct\n\n\n", "relation_name": "cms_synthetic.core.procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.477445Z", "completed_at": "2024-10-22T19:20:39.497177Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.498301Z", "completed_at": "2024-10-22T19:20:39.498306Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026960134506225586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_medical_claim", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the medical_claim table\n-- in core. It adds these 4 fields to the input layer\n-- medical claim table:\n-- encounter_id\n-- service_category_1\n-- service_category_2\n-- *************************************************\n\nwith all_encounters as (\n select claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from cms_synthetic.claims_preprocessing.encounters__combined_claim_line_crosswalk\n where claim_line_attribution_number = 1\n \n union all \n\n select \n claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from cms_synthetic.claims_preprocessing.encounters__orphaned_claims\n)\n\n\nselect\n med.claim_id || '-' || med.claim_line_number as medical_claim_id\n , cast(med.claim_id as TEXT ) as claim_id\n , cast(med.claim_line_number as integer ) as claim_line_number\n , cast(x.encounter_id as int ) as encounter_id\n , cast(x.encounter_type as TEXT ) as encounter_type\n , cast(x.encounter_group as TEXT ) as encounter_group\n , cast(med.claim_type as TEXT ) as claim_type\n , cast(med.patient_id as TEXT ) as patient_id\n , cast(med.member_id as TEXT ) as member_id\n , cast(med.payer as TEXT ) as payer\n , med.plan\n , try_cast( med.claim_start_date as date ) as claim_start_date\n , try_cast( med.claim_end_date as date ) as claim_end_date\n , try_cast( med.claim_line_start_date as date ) as claim_line_start_date\n , try_cast( med.claim_line_end_date as date ) as claim_line_end_date\n , try_cast( med.admission_date as date ) as admission_date\n , try_cast( med.discharge_date as date ) as discharge_date\n , cast(srv_group.service_category_1 as TEXT ) as service_category_1\n , cast(srv_group.service_category_2 as TEXT ) as service_category_2\n , cast(srv_group.service_category_3 as TEXT ) as service_category_3\n , cast(med.admit_source_code as TEXT ) as admit_source_code\n , cast(med.admit_source_description as TEXT ) as admit_source_description\n , cast(med.admit_type_code as TEXT ) as admit_type_code\n , cast(med.admit_type_description as TEXT ) as admit_type_description\n , cast(med.discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(med.discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(med.place_of_service_code as TEXT ) as place_of_service_code\n , cast(med.place_of_service_description as TEXT ) as place_of_service_description\n , cast(med.bill_type_code as TEXT ) as bill_type_code\n , cast(med.bill_type_description as TEXT ) as bill_type_description\n , cast(med.ms_drg_code as TEXT ) as ms_drg_code\n , cast(med.ms_drg_description as TEXT ) as ms_drg_description\n , cast(med.apr_drg_code as TEXT ) as apr_drg_code\n , cast(med.apr_drg_description as TEXT ) as apr_drg_description\n , cast(med.revenue_center_code as TEXT ) as revenue_center_code\n , cast(med.revenue_center_description as TEXT ) as revenue_center_description\n , cast(med.service_unit_quantity as numeric(28,6) ) as service_unit_quantity\n , cast(med.hcpcs_code as TEXT ) as hcpcs_code\n , cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n , cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n , cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n , cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n , cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n , cast(med.rendering_id as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(med.rendering_name as TEXT ) as rendering_name\n , cast(med.billing_id as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(med.billing_name as TEXT ) as billing_name\n , cast(med.facility_id as TEXT ) as facility_id\n , cast(med.facility_name as TEXT ) as facility_name\n , try_cast( med.paid_date as date ) as paid_date\n , cast(med.paid_amount as numeric(28,6) ) as paid_amount\n , cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(med.charge_amount as numeric(28,6) ) as charge_amount\n , cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast(\n case\n when enroll.claim_id is not null then 1\n else 0\n end as int) as enrollment_flag\n , cast(med.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom cms_synthetic.claims_preprocessing.normalized_input_medical_claim as med\ninner join cms_synthetic.claims_preprocessing.service_category_grouper as srv_group\n on med.claim_id = srv_group.claim_id\n and med.claim_line_number = srv_group.claim_line_number\n and srv_group.duplicate_row_number = 1\ninner join all_encounters as x\n on med.claim_id = x.claim_id\n and med.claim_line_number = x.claim_line_number\nleft join cms_synthetic.claims_preprocessing.flag_claims_with_enrollment as enroll\n on med.claim_id = enroll.claim_id\n and med.claim_line_number = enroll.claim_line_number", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.490712Z", "completed_at": "2024-10-22T19:20:39.497997Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.499004Z", "completed_at": "2024-10-22T19:20:39.499007Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.021963119506835938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.orphaned_claim__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select\n cli.encounter_id\n , min(stg.start_date) as encounter_start_date\n , max(stg.start_date) as encounter_end_date\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim as stg\n inner join cms_synthetic.claims_preprocessing.encounters__orphaned_claims as cli\n on stg.claim_id = cli.claim_id\n and stg.claim_line_number = cli.claim_line_number\n group by\n cli.encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n ,d.encounter_end_date\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from cms_synthetic.claims_preprocessing.encounters__stg_medical_claim stg\n inner join cms_synthetic.claims_preprocessing.encounters__orphaned_claims cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n inner join encounter_date d on cli.encounter_id = d.encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from cms_synthetic.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join cms_synthetic.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join cms_synthetic.terminology.provider b\n on hf.facility_id = b.npi\nleft join cms_synthetic.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join cms_synthetic.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "cms_synthetic.claims_preprocessing.orphaned_claim__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.526564Z", "completed_at": "2024-10-22T19:20:39.532799Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.533327Z", "completed_at": "2024-10-22T19:20:39.533331Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010571956634521484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0", "compiled": true, "compiled_code": "\n \n \n\nselect\n condition_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.condition\nwhere condition_id is not null\ngroup by condition_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.550351Z", "completed_at": "2024-10-22T19:20:39.556060Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.556669Z", "completed_at": "2024-10-22T19:20:39.556674Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00992894172668457, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5", "compiled": true, "compiled_code": "\n \n \n\nselect\n procedure_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.procedure\nwhere procedure_id is not null\ngroup by procedure_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.553094Z", "completed_at": "2024-10-22T19:20:39.556242Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.557032Z", "completed_at": "2024-10-22T19:20:39.557035Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.010071992874145508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__medical_claim", "compiled": true, "compiled_code": "\n\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_medical_claim", "relation_name": "cms_synthetic.core.medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.557366Z", "completed_at": "2024-10-22T19:20:39.564416Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.564989Z", "completed_at": "2024-10-22T19:20:39.564994Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009186744689941406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_location", "compiled": true, "compiled_code": "\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom cms_synthetic.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'organization'\n)\n\n\n\nselect \n cast(npi as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(provider_organization_name as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(parent_organization_name as TEXT ) as parent_organization\n , cast(practice_address_line_1 as TEXT ) as address\n , cast(practice_city as TEXT ) as city\n , cast(practice_state as TEXT ) as state\n , cast(practice_zip_code as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast( '2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom provider", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.565311Z", "completed_at": "2024-10-22T19:20:39.583527Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.585504Z", "completed_at": "2024-10-22T19:20:39.585510Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021663904190063477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_practitioner", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the provider table \n-- in core. It includes data about all providers\n-- present in the raw claims dataset.\n-- *************************************************\n\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom cms_synthetic.dbt_tom.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom cms_synthetic.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'individual'\n)\n\n\n\nselect \n cast(npi as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(provider_first_name as TEXT ) as provider_first_name\n , cast(provider_last_name as TEXT ) as provider_last_name\n , cast(parent_organization_name as TEXT ) as practice_affiliation\n , cast(primary_specialty_description as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nfrom provider", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.586200Z", "completed_at": "2024-10-22T19:20:39.594280Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.595377Z", "completed_at": "2024-10-22T19:20:39.595383Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01221609115600586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__long_condition_category", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__condition as (\n\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere normalized_code_type = 'icd-10-cm'\n), ccsr__dx_vertical_pivot as (\n \n select * from cms_synthetic.ccsr.dx_vertical_pivot \n\n), condition as (\n \n select * from __dbt__cte__ccsr__stg_core__condition\n\n), dxccsr_body_systems as (\n\n select * from cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems\n\n)\n\nselect \n condition.encounter_id,\n condition.claim_id,\n condition.patient_id,\n condition.normalized_code,\n ccsr__dx_vertical_pivot.code_description,\n condition.condition_rank,\n ccsr__dx_vertical_pivot.ccsr_parent_category,\n dxccsr_body_systems.body_system,\n dxccsr_body_systems.parent_category_description,\n ccsr__dx_vertical_pivot.ccsr_category,\n ccsr__dx_vertical_pivot.ccsr_category_description,\n ccsr__dx_vertical_pivot.ccsr_category_rank,\n ccsr__dx_vertical_pivot.is_ip_default_category,\n ccsr__dx_vertical_pivot.is_op_default_category,\n '2023.1' as dxccsr_version,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom condition\nleft join ccsr__dx_vertical_pivot\n on condition.normalized_code = ccsr__dx_vertical_pivot.code\nleft join dxccsr_body_systems on ccsr__dx_vertical_pivot.ccsr_parent_category = dxccsr_body_systems.ccsr_parent_category", "relation_name": "cms_synthetic.ccsr.long_condition_category"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.595791Z", "completed_at": "2024-10-22T19:20:39.614140Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.620687Z", "completed_at": "2024-10-22T19:20:39.620693Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02678823471069336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom cms_synthetic.core.condition\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_condition\n\n)\n\n/*\n Default mapping guidance: Most map groups terminate with an unconditional\n rule \u2013 a rule whose predicate is \u201cTRUE\u201d or, equivalently, \u201cOTHERWISE TRUE\u201d.\n This rule is considered a \u201cdefault\u201d because it should be applied if\n nothing further is known about the patient\u2019s condition.\n*/\n, seed_snomed_icd_10_map as (\n\n select\n referenced_component_id as snomed_code\n , map_target as icd_10_code\n from cms_synthetic.terminology.snomed_icd_10_map\n where lower(map_rule) in ('true', 'otherwise true')\n and map_group = '1'\n\n)\n\n, snomed_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , 'icd-10-cm' as code_type\n , icd_10_code as code\n , data_source\n from conditions\n inner join seed_snomed_icd_10_map\n on conditions.code = seed_snomed_icd_10_map.snomed_code\n where conditions.code_type = 'snomed-ct'\n\n)\n\n, other_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from conditions\n where conditions.code_type <> 'snomed-ct'\n\n)\n\n, union_conditions as (\n\n select * from snomed_conditions\n union all\n select * from other_conditions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(data_source as TEXT) as data_source\n from union_conditions\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_prep_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.608683Z", "completed_at": "2024-10-22T19:20:39.624981Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.625321Z", "completed_at": "2024-10-22T19:20:39.625325Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0172421932220459, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), diabetes_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetes_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join diabetes_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetes_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetes_codes.code\n\n)\n\n, patients_with_diabetes as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version \n from diabetes_conditions\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_diabetes\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator_criteria3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.621985Z", "completed_at": "2024-10-22T19:20:39.625962Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.626480Z", "completed_at": "2024-10-22T19:20:39.626483Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005079030990600586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n) select patient_id\nfrom __dbt__cte___stg_condition\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.627244Z", "completed_at": "2024-10-22T19:20:39.638122Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.638378Z", "completed_at": "2024-10-22T19:20:39.638384Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012223005294799805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__tuva_chronic_conditions__stg_core__condition as (\n\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), all_conditions as (\nselect \n patient_id,\n normalized_code,\n recorded_date\n from __dbt__cte__tuva_chronic_conditions__stg_core__condition\n),\n\n\nconditions_with_first_and_last_diagnosis_date as (\nselect \n patient_id,\n normalized_code as icd_10_cm,\n min(recorded_date) as first_diagnosis_date,\n max(recorded_date) as last_diagnosis_date\nfrom all_conditions\ngroup by patient_id, normalized_code\n\n)\n\n\nselect\n aa.patient_id,\n bb.concept_name as condition,\n min(first_diagnosis_date) as first_diagnosis_date,\n max(last_diagnosis_date) as last_diagnosis_date,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom conditions_with_first_and_last_diagnosis_date aa\ninner join cms_synthetic.clinical_concept_library.value_set_member_relevant_fields bb\non aa.icd_10_cm = bb.code\ngroup by aa.patient_id, bb.concept_name", "relation_name": "cms_synthetic.chronic_conditions.tuva_chronic_conditions_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.633116Z", "completed_at": "2024-10-22T19:20:39.638724Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.639447Z", "completed_at": "2024-10-22T19:20:39.639451Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00695490837097168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__long_procedure_category", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__procedure as (\n\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), procedures as (\n\n select * from __dbt__cte__ccsr__stg_core__procedure\n\n)\n\n, ccsr__procedure_category_map as (\n\n select * from cms_synthetic.ccsr.procedure_category_map\n\n)\n\nselect distinct\n procedures.encounter_id\n , procedures.claim_id\n , procedures.patient_id\n , procedures.normalized_code\n , ccsr__procedure_category_map.code_description\n , ccsr__procedure_category_map.ccsr_parent_category\n , ccsr__procedure_category_map.ccsr_category\n , ccsr__procedure_category_map.ccsr_category_description\n , ccsr__procedure_category_map.clinical_domain\n , '2023.1' as prccsr_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom procedures\nleft join ccsr__procedure_category_map\n on procedures.normalized_code = ccsr__procedure_category_map.code", "relation_name": "cms_synthetic.ccsr.long_procedure_category"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.640911Z", "completed_at": "2024-10-22T19:20:39.676706Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.680967Z", "completed_at": "2024-10-22T19:20:39.680974Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04119515419006348, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), ascvd_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'atherosclerosis and peripheral arterial disease'\n , 'myocardial infarction'\n , 'pci'\n , 'stable and unstable angina'\n , 'cabg or pci procedure'\n , 'cabg surgeries'\n , 'cerebrovascular disease stroke or tia'\n , 'ischemic heart disease or related diagnoses'\n , 'carotid intervention'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, ascvd_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join ascvd_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = ascvd_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = ascvd_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, ascvd_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join ascvd_codes\n on procedures.code = ascvd_codes.code\n and procedures.code_type = ascvd_codes.code_system\n\n)\n\n, historical_ascvd as (\n\n select\n ascvd_conditions.patient_id\n , ascvd_conditions.evidence_date\n from ascvd_conditions\n\n union all\n\n select\n ascvd_procedures.patient_id\n , ascvd_procedures.evidence_date\n from ascvd_procedures\n\n)\n\n, patients_with_ascvd as (\n\n select\n distinct\n historical_ascvd.patient_id\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from historical_ascvd\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_ascvd\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator_criteria1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.657624Z", "completed_at": "2024-10-22T19:20:39.683025Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.683776Z", "completed_at": "2024-10-22T19:20:39.683807Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04317593574523926, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), cholesterol_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'ldl cholesterol'\n , 'familial hypercholesterolemia'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, cholesterol_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join cholesterol_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = cholesterol_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = cholesterol_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, cholesterol_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cholesterol_codes\n on procedures.code = cholesterol_codes.code\n and procedures.code_type = cholesterol_codes.code_system\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, cholesterol_tests_with_result as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date, result_date) as evidence_date\n , cholesterol_codes.concept_name\n , row_number() over(partition by labs.patient_id order by\n labs.result desc\n , result_date desc) as rn\n from labs\n inner join cholesterol_codes\n on coalesce(labs.normalized_code, labs.source_code) = cholesterol_codes.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = cholesterol_codes.code_system\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, cholesterol_labs as (\n\n select\n patient_id\n , evidence_date\n from cholesterol_tests_with_result\n where rn= 1\n and cast(evidence_value as numeric(28,6)) >= 190\n\n)\n\n, all_patients_with_cholesterol as (\n\n select\n cholesterol_conditions.patient_id\n , cholesterol_conditions.evidence_date\n from cholesterol_conditions\n\n union all\n\n select\n cholesterol_procedures.patient_id\n , cholesterol_procedures.evidence_date\n from cholesterol_procedures\n\n union all\n\n select\n cholesterol_labs.patient_id\n , cholesterol_labs.evidence_date\n from cholesterol_labs\n\n)\n\n, patients_with_cholesterol as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from all_patients_with_cholesterol\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_cholesterol\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator_criteria2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.685460Z", "completed_at": "2024-10-22T19:20:39.694759Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.695080Z", "completed_at": "2024-10-22T19:20:39.695086Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011645793914794922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n) select patient_id\nfrom __dbt__cte___stg_procedure\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.689945Z", "completed_at": "2024-10-22T19:20:39.696031Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.696491Z", "completed_at": "2024-10-22T19:20:39.696495Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0076258182525634766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__procedure_ccs", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__procedure as (\n\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n) -- Here we map every procedure code to its corresponding\n-- CCS procedure category.\n-- This model may list more than one CCS procedure category\n-- per encounter_id because different procedures associated with the\n-- encounter (different rows on the stg_procedure model) may have\n-- different associated CCS procedure categories.\n\n\n\nselect\n aa.encounter_id,\n aa.normalized_code as procedure_code,\n case\n when bb.icd_10_pcs is null then 0\n\telse 1\n end as valid_icd_10_pcs_flag,\n cc.ccs_procedure_category,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n __dbt__cte__readmissions__stg_core__procedure aa\n left join cms_synthetic.terminology.icd_10_pcs bb\n on aa.normalized_code = bb.icd_10_pcs\n left join cms_synthetic.readmissions._value_set_icd_10_pcs_to_ccs cc\n on aa.normalized_code = cc.icd_10_pcs\nwhere aa.normalized_code_type = 'icd-10-pcs'", "relation_name": "cms_synthetic.readmissions._int_procedure_ccs"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.704813Z", "completed_at": "2024-10-22T19:20:39.716669Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.716906Z", "completed_at": "2024-10-22T19:20:39.716911Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012926816940307617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_loss", "compiled": true, "compiled_code": "\n\nwith input_medical as (\n select\n cast('medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.medical_claim\n)\n\n, input_pharmacy as (\n select\n cast('pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.pharmacy_claim\n)\n\n,input_eligibility as (\nselect\n cast('eligibility' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan) as span_count\nfrom tuva.input_layer.eligibility\n)\n\n , input_member_months as (\n select\n cast('eligibility' as TEXT) as table_name\n , count(*) as member_month_count\n from cms_synthetic.data_quality.data_quality__eligibility_dq_stage e\n)\n\n-- Core layer CTEs\n, core_medical as (\n select\n cast( 'medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from cms_synthetic.core.medical_claim\n)\n\n, core_pharmacy as (\n select\n cast( 'pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from cms_synthetic.core.pharmacy_claim\n)\n\n, core_eligibility as (\n select\n cast('eligibility' as TEXT)as table_name\n , count(distinct patient_id) as patient_count\n , count(*) as span_count\n from cms_synthetic.core.eligibility\n)\n\n, core_member_months as (\n select\n cast('member_months' as TEXT) as table_name\n , count(*) as member_month_count\n from cms_synthetic.core.member_months\n)\n\n,final as (\n-- Combining both input and core layers\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\n-- Pharmacy layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\n-- Eligibility layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Eligibility Spans' as TEXT) as metric\n , input.span_count as input_layer_value\n , core.span_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Member Months' as TEXT) as metric\n , input.member_month_count as input_layer_value\n , core.member_month_count as core_value\nfrom input_member_months as input\ninner join core_member_months as core\n on input.table_name = core.table_name\n\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.data_loss"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.712657Z", "completed_at": "2024-10-22T19:20:39.717682Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.718112Z", "completed_at": "2024-10-22T19:20:39.718117Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006016969680786133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__service_categories_pmpm", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n count(1) as member_months\n from cms_synthetic.core.member_months mm\n)\n\n, pmpm as (\n select\n cast('service categories pmpm' as TEXT ) as analytics_concept\n , mc.service_category_2 as analytics_measure\n , sum(mc.paid_amount) as total_paid\n , avg(mm.member_months) as member_months\n , case when avg(mm.member_months) = 0 then null\n else sum(mc.paid_amount) / avg(mm.member_months)\n end as data_source_value\n from cms_synthetic.core.medical_claim mc\n cross join member_months mm\n group by\n mc.service_category_2\n)\n\nselect\n pmpm.*\n , ref_data.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pmpm\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data\n on pmpm.analytics_concept = ref_data.analytics_concept\n and pmpm.analytics_measure = ref_data.analytics_measure", "relation_name": "cms_synthetic.data_quality.service_categories_pmpm"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.718886Z", "completed_at": "2024-10-22T19:20:39.725599Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.725854Z", "completed_at": "2024-10-22T19:20:39.725859Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008026123046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__service_category_pmpm_trend", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from cms_synthetic.core.member_months\n group by year_month\n)\n\n, service_categories as (\n select\n cast(c.year_month_int as TEXT) as year_month\n , m.service_category_1\n , m.service_category_2\n , sum(m.paid_amount) as total_paid\n from cms_synthetic.core.medical_claim as m\n left join cms_synthetic.reference_data.calendar as c\n on m.claim_start_date = c.full_date\n group by\n cast(c.year_month_int as TEXT)\n , m.service_category_1\n , m.service_category_2\n)\n\nselect\n scat.year_month\n , scat.service_category_1\n , scat.service_category_2\n , scat.total_paid\n , scat.total_paid / mm.member_months as pmpm\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_categories as scat\ninner join member_months as mm\n on scat.year_month = mm.year_month", "relation_name": "cms_synthetic.data_quality.service_category_pmpm_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.727719Z", "completed_at": "2024-10-22T19:20:39.732518Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.732733Z", "completed_at": "2024-10-22T19:20:39.732739Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006062030792236328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__data_source", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.core.medical_claim", "relation_name": "cms_synthetic.data_quality.mart_review__data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.730304Z", "completed_at": "2024-10-22T19:20:39.733619Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.734064Z", "completed_at": "2024-10-22T19:20:39.734067Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006622791290283203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__stg_medical_claim", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM cms_synthetic.core.medical_claim mc\nleft join cms_synthetic.reference_data.calendar c on coalesce(mc.claim_line_start_date,mc.claim_start_date) = c.full_date", "relation_name": "cms_synthetic.data_quality.mart_review__stg_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.742387Z", "completed_at": "2024-10-22T19:20:39.748013Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.748932Z", "completed_at": "2024-10-22T19:20:39.748938Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00725102424621582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708", "compiled": true, "compiled_code": "\n \n \n\nselect\n medical_claim_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.medical_claim\nwhere medical_claim_id is not null\ngroup by medical_claim_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.749469Z", "completed_at": "2024-10-22T19:20:39.753933Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.757505Z", "completed_at": "2024-10-22T19:20:39.757511Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009796142578125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__location", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_location\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_location\n\n", "relation_name": "cms_synthetic.core.location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.754138Z", "completed_at": "2024-10-22T19:20:39.758686Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.759083Z", "completed_at": "2024-10-22T19:20:39.759087Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005690097808837891, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__practitioner", "compiled": true, "compiled_code": "\n\nselect * from cms_synthetic.dbt_tom.core__stg_claims_practitioner\nunion all\nselect * from cms_synthetic.dbt_tom.core__stg_clinical_practitioner\n\n", "relation_name": "cms_synthetic.core.practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.759430Z", "completed_at": "2024-10-22T19:20:39.768297Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.768635Z", "completed_at": "2024-10-22T19:20:39.768641Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010235071182250977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__singular_condition_category", "compiled": true, "compiled_code": "\n\nselect \n encounter_id,\n claim_id,\n patient_id,\n ccsr_category,\n ccsr_category_description,\n ccsr_parent_category,\n parent_category_description,\n body_system,\n '2023.1' as dxccsr_version,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ccsr.long_condition_category\nwhere\n is_ip_default_category = 1\n and condition_rank = 1", "relation_name": "cms_synthetic.ccsr.singular_condition_category"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.764296Z", "completed_at": "2024-10-22T19:20:39.769341Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.769818Z", "completed_at": "2024-10-22T19:20:39.769821Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006031036376953125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_conditions", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from cms_synthetic.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n diagnosis_code\n , cms_hcc_v28 as hcc_code\n from cms_synthetic.hcc_suspecting._value_set_icd_10_cm_mappings\n where cms_hcc_v28 is not null\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, joined as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code\n , conditions.data_source\n , seed_hcc_mapping.hcc_code\n , seed_hcc_descriptions.hcc_description\n from conditions\n left join seed_hcc_mapping\n on conditions.code = seed_hcc_mapping.diagnosis_code\n left join seed_hcc_descriptions\n on seed_hcc_mapping.hcc_code = seed_hcc_descriptions.hcc_code\n where conditions.code_type = 'icd-10-cm'\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(data_source as TEXT) as data_source\n from joined\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_all_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.770665Z", "completed_at": "2024-10-22T19:20:39.782228Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.782936Z", "completed_at": "2024-10-22T19:20:39.782942Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013520240783691406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "compiled": true, "compiled_code": "\n\nwith patients as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n),\n\nobesity as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Obesity'\n),\n\n\nosteoarthritis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoarthritis'\n),\n\ncopd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Obstructive Pulmonary Disease'\n),\n\nanxiety_disorders as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Anxiety Disorders'\n),\n\nckd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Kidney Disease'\n),\n\nt2d as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 2 Diabetes Mellitus'\n),\n\ncll as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Lymphocytic Leukemia'\n),\n\ndysplipidemias as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dyslipidemias'\n),\n\nhypertension as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hypertension'\n),\n\natherosclerosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atherosclerosis'\n),\n\ndementia as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dementia'\n),\n\nrheumatoid_arthritis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rheumatoid Arthritis'\n),\n\nceliac as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Celiac Disease'\n),\n\nhip_fracture as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hip Fracture'\n),\n\nimmunodeficiencies_and_white_blood_cell_disorders as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Specified Immunodeficiencies and White Blood Cell Disorders (HCC v28 concept #115)'\n),\n\nasthma as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Asthma'\n),\n\nt1d as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 1 Diabetes Mellitus'\n),\n\nulcerative_colitis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Ulcerative colitis'\n),\n\nchrohns as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Crohns Disease'\n),\n\nholicobacter as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Helicobacter pylori Infection'\n),\n\nbipolar as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Bipolar Affective Disorder'\n),\n\nheart_failure as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Heart Failure'\n),\n\ntabacco as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Tobacco Use'\n),\n\nlyme as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lyme Disease'\n),\n\nbreast_cancer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Breast Cancer'\n),\n\nosteoporosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoporosis'\n),\n\npulmonary_embolism as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Pulmonary Embolism, Thrombotic or Unspecified'\n),\n\nschizophrenia as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Schizophrenia'\n),\n\natrial_fibrillation as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atrial Fibrillation'\n),\n\ncolorectal_cancer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Colorectal Cancer'\n),\n\ndepression as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Major Depressive Disorder'\n),\n\ndeep_vein_thrombosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Deep Vein Thrombosis of Extremities or Central Veins'\n),\n\nalzheimer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alzheimer Disease'\n),\n\nstroke as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Stroke'\n),\n\nmyocardial_infraction as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Myocardial Infarction'\n),\n\nopiod_use_disorder as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Opioid Use Disorder'\n),\n\nlung_cancer as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lung cancer, primary or unspecified'\n),\n\nherpes as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Herpes Simplex Infection'\n),\n\nrickettsiosis as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rickettsiosis'\n),\n\nms as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Multiple Sclerosis'\n),\n\nalchohol as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alcohol Use Disorder'\n),\n\nadhd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Attention Deficit-Hyperactivity Disorder'\n),\n\nhiv as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'HIV/AIDS (HCC v28 concept #1)'\n),\n\nptsd as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Post-Traumatic Stress Disorder'\n),\n\nlupus as (\nselect distinct patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Systemic Lupus Erythematosus'\n)\n\n\n\n\nselect\n patient_id,\n case when patient_id in (select * from obesity) then 1\n else 0\n end as obesity,\n case when patient_id in (select * from osteoarthritis) then 1\n else 0\n end as osteoarthritis,\n case when patient_id in (select * from copd) then 1\n else 0\n end as copd,\n case when patient_id in (select * from anxiety_disorders) then 1\n else 0\n end as anxiety_disorders,\n case when patient_id in (select * from ckd) then 1\n else 0\n end as ckd,\n case when patient_id in (select * from t2d) then 1\n else 0\n end as t2d,\n case when patient_id in (select * from cll) then 1\n else 0\n end as cll,\n case when patient_id in (select * from dysplipidemias) then 1\n else 0\n end as dysplipidemias,\n case when patient_id in (select * from hypertension) then 1\n else 0\n end as hypertension,\n case when patient_id in (select * from atherosclerosis) then 1\n else 0\n end as atherosclerosis,\n case when patient_id in (select * from dementia) then 1\n else 0\n end as dementia,\n case when patient_id in (select * from rheumatoid_arthritis) then 1\n else 0\n end as rheumatoid_arthritis,\n case when patient_id in (select * from celiac) then 1\n else 0\n end as celiac,\n case when patient_id in (select * from hip_fracture) then 1\n else 0\n end as hip_fracture,\n case when patient_id in (select * from immunodeficiencies_and_white_blood_cell_disorders) then 1\n else 0\n end as immunodeficiencies_and_white_blood_cell_disorders,\n case when patient_id in (select * from asthma) then 1\n else 0\n end asthma,\n case when patient_id in (select * from t1d) then 1\n else 0\n end as t1d,\n case when patient_id in (select * from ulcerative_colitis) then 1\n else 0\n end as ulcerative_colitis,\n case when patient_id in (select * from chrohns) then 1\n else 0\n end as chrohns,\n case when patient_id in (select * from holicobacter) then 1\n else 0\n end as holicobacter,\n case when patient_id in (select * from bipolar) then 1\n else 0\n end as bipolar,\n case when patient_id in (select * from heart_failure) then 1\n else 0\n end as heart_failure,\n case when patient_id in (select * from tabacco) then 1\n else 0\n end as tabacco,\n case when patient_id in (select * from lyme) then 1\n else 0\n end as lyme,\n case when patient_id in (select * from breast_cancer) then 1\n else 0\n end as breast_cancer,\n case when patient_id in (select * from osteoporosis) then 1\n else 0\n end as osteoporosis,\n case when patient_id in (select * from pulmonary_embolism) then 1\n else 0\n end as pulmonary_embolism,\n case when patient_id in (select * from schizophrenia) then 1\n else 0\n end as schizophrenia,\n case when patient_id in (select * from atrial_fibrillation) then 1\n else 0\n end as atrial_fibrillation,\n case when patient_id in (select * from colorectal_cancer) then 1\n else 0\n end as colorectal_cancer,\n case when patient_id in (select * from depression) then 1\n else 0\n end as depression,\n case when patient_id in (select * from deep_vein_thrombosis) then 1\n else 0\n end as deep_vein_thrombosis,\n case when patient_id in (select * from alzheimer) then 1\n else 0\n end as alzheimer,\n case when patient_id in (select * from stroke) then 1\n else 0\n end as stroke,\n case when patient_id in (select * from myocardial_infraction) then 1\n else 0\n end as myocardial_infraction,\n case when patient_id in (select * from opiod_use_disorder) then 1\n else 0\n end as opiod_use_disorder,\n case when patient_id in (select * from lung_cancer) then 1\n else 0\n end as lung_cancer,\n case when patient_id in (select * from herpes) then 1\n else 0\n end as herpes,\n case when patient_id in (select * from rickettsiosis) then 1\n else 0\n end as rickettsiosis,\n case when patient_id in (select * from ms) then 1\n else 0\n end as ms,\n case when patient_id in (select * from alchohol) then 1\n else 0\n end as alchohol,\n case when patient_id in (select * from adhd) then 1\n else 0\n end as adhd,\n case when patient_id in (select * from hiv) then 1\n else 0\n end as hiv,\n case when patient_id in (select * from ptsd) then 1\n else 0\n end as ptsd,\n case when patient_id in (select * from lupus) then 1\n else 0\n end as lupus,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n\nfrom patients", "relation_name": "cms_synthetic.chronic_conditions.tuva_chronic_conditions_wide"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.779100Z", "completed_at": "2024-10-22T19:20:39.784353Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.785182Z", "completed_at": "2024-10-22T19:20:39.785185Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006691932678222656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "compiled": true, "compiled_code": "\n\nwith condition_counts as (\n select\n condition\n , count(distinct patient_id) as patients\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n group by condition\n)\n, total_patients as (\n select \n count(distinct patient_id) as total_distinct_patients\n from cms_synthetic.core.eligibility\n)\n\n, results_first as (\nselect\n conditions.condition\n , conditions.patients\n , CASE \n WHEN total_patients.total_distinct_patients = 0 THEN NULL\n ELSE (conditions.patients / total_patients.total_distinct_patients) * 100 \n END as percent_of_total\n\nfrom condition_counts as conditions\ncross join total_patients\n)\n\n,results_second as (\n select \n condition\n , patients\n , percent_of_total\n , ROW_NUMBER() OVER (ORDER BY percent_of_total desc) AS condition_rank\n from results_first\n)\n\n\nselect\n ref_data.analytics_concept\n , coalesce(results.condition, ref_data.analytics_measure) as analytics_measure\n , results.patients\n , results.condition_rank as value_rank\n , results.percent_of_total as data_source_value\n , ref_data.analytics_value\n , ref_data.value_rank as medicare_lds_condition_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data\nleft join results_second as results on results.condition = ref_data.analytics_measure\nwhere ref_data.analytics_concept = 'chronic conditions top 10'", "relation_name": "cms_synthetic.data_quality.chronic_conditions_prevalence"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.787290Z", "completed_at": "2024-10-22T19:20:39.794733Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.794996Z", "completed_at": "2024-10-22T19:20:39.795000Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009499311447143555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__number_of_conditions", "compiled": true, "compiled_code": "\n\nwith xwalk as (\n select distinct patient_id, data_source\n from cms_synthetic.core.patient\n),\ncte as (\n select l.patient_id,\n x.data_source,\n count(*) as numofconditions\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long l\n left join xwalk x on l.patient_id = x.patient_id\n group by l.patient_id, x.data_source\n)\nselect p.patient_id,\n p.data_source,\n p.patient_id || '|' || p.data_source as patient_source_key,\n coalesce(cte.numofconditions, 0) as numofconditions\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient p\nleft join cte on p.patient_id = cte.patient_id and p.data_source = cte.data_source", "relation_name": "cms_synthetic.data_quality.mart_review__number_of_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.791346Z", "completed_at": "2024-10-22T19:20:39.795351Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.795789Z", "completed_at": "2024-10-22T19:20:39.795792Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008861064910888672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__tuva_chronic_conditions", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n patient_id\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, patientxwalk as (\n select distinct\n patient_id\n , data_source\n from cms_synthetic.core.patient\n)\n\n, result as (\n select\n l.patient_id\n , p.data_source\n , l.condition\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long as l\n inner join patientxwalk as p\n on l.patient_id = p.patient_id\n\n union all\n\n select\n p.patient_id\n , p.data_source\n , 'No Chronic Conditions' as condition\n from cms_synthetic.core.patient as p\n left join cte\n on p.patient_id = cte.patient_id\n where cte.patient_id is null\n)\n\nselect *\n , patient_id || '|' || data_source as patient_source_key\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom result", "relation_name": "cms_synthetic.data_quality.mart_review__tuva_chronic_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.797262Z", "completed_at": "2024-10-22T19:20:39.817402Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.821254Z", "completed_at": "2024-10-22T19:20:39.821262Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025218963623046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, condition\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n group by patient_id, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.800235Z", "completed_at": "2024-10-22T19:20:39.822782Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.905338Z", "completed_at": "2024-10-22T19:20:39.905345Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.10841012001037598, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, exclusions_diagnosis as (\n\n select distinct\n patient_conditions.claim_id\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Exclude'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_ms_drg\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_diagnosis\n on inclusions_unioned.claim_id = exclusions_diagnosis.claim_id\n and inclusions_unioned.condition = exclusions_diagnosis.condition\nwhere exclusions_diagnosis.claim_id is null", "relation_name": "cms_synthetic.chronic_conditions._int_cms_chronic_condition_all"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.823045Z", "completed_at": "2024-10-22T19:20:39.908065Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.908833Z", "completed_at": "2024-10-22T19:20:39.908845Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.08658504486083984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), chronic_conditions as (\n\n select * from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE excludes encounters with the exception code. Those encounters\n will be evaluated separately.\n*/\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code <> 'R75'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE includes encounters with the exception code only where that\n patient has another encounter that is not R75.\n*/\n, exception_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n inner join inclusions_diagnosis\n on patient_conditions.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code = 'R75'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_ms_drg\n union distinct\n select * from exception_diagnosis\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom inclusions_unioned", "relation_name": "cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.910840Z", "completed_at": "2024-10-22T19:20:39.940802Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.942473Z", "completed_at": "2024-10-22T19:20:39.942480Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0340428352355957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_eligible_conditions", "compiled": true, "compiled_code": "\n/*\nSteps for staging condition data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs\n\nClaims filtering logic:\n - Professional:\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n - Inpatient:\n - Bill type code in (11X, 41X)\n - Outpatient:\n - Bill type code in (12X, 13X, 43X, 71X, 73X, 76X, 77X, 85X)\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - The collection year is one year prior to the payment year.\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), medical_claims as (\n\n select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, conditions as (\n\n select\n claim_id\n , patient_id\n , code\n from __dbt__cte___stg_condition\n where code_type = 'icd-10-cm'\n\n)\n\n, cpt_hcpcs_list as (\n\n select\n payment_year\n , hcpcs_cpt_code\n from cms_synthetic.cms_hcc._value_set_cpt_hcpcs\n\n)\n\n, professional_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'professional'\n and date_part('year', claim_end_date) = 2023\n and cpt_hcpcs_list.payment_year = 2024\n\n)\n\n\n, inpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and substring(bill_type_code, 1, 2) in ('11','41')\n\n)\n\n, outpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and cpt_hcpcs_list.payment_year = 2024\n and substring(bill_type_code, 1, 2) in ('12','13','43','71','73','76','77','85')\n\n)\n\n, eligible_claims as (\n\n select * from professional_claims\n union all\n select * from inpatient_claims\n union all\n select * from outpatient_claims\n\n)\n\n, eligible_conditions as (\n\n select distinct\n eligible_claims.claim_id\n , eligible_claims.patient_id\n , conditions.code\n from eligible_claims\n inner join conditions\n on eligible_claims.claim_id = conditions.claim_id\n and eligible_claims.patient_id = conditions.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(code as TEXT) as condition_code\n , cast('2024' as integer) as payment_year\n from eligible_conditions\n\n)\n\nselect\n patient_id\n , condition_code\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_eligible_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.928850Z", "completed_at": "2024-10-22T19:20:39.943783Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.948108Z", "completed_at": "2024-10-22T19:20:39.948114Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020108938217163086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__financial_pmpm__stg_medical_claim as (\n\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n), __dbt__cte__financial_pmpm__stg_pharmacy_claim as (\n\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n), claims_with_service_categories as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , coalesce(claim_start_date,claim_end_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_medical_claim\n)\n\n, medical_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from claims_with_service_categories\n)\n\n, rx_claims as (\n select\n patient_id\n , payer\n , plan\n , 'pharmacy' as service_category_1\n , cast(null as TEXT) as service_category_2\n , coalesce(dispensing_date, paid_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_pharmacy_claim\n)\n\n, rx_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from rx_claims\n)\n\n, combine_medical_and_rx as (\nselect *\nfrom medical_claims_year_month\n\nunion all\n\nselect *\nfrom rx_claims_year_month\n)\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , sum(paid_amount) as total_paid\n , sum(allowed_amount) as total_allowed\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n from combine_medical_and_rx\ngroup by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , data_source", "relation_name": "cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.943968Z", "completed_at": "2024-10-22T19:20:39.949149Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.949596Z", "completed_at": "2024-10-22T19:20:39.949599Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006317615509033203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__claims_with_enrollment", "compiled": true, "compiled_code": "\n\nwith enrollment_stage as(\nSELECT\n mc.data_source,\n mc.year_month,\n SUM(CASE WHEN mm.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS claims_with_enrollment,\n COUNT(*) AS claims\nFROM cms_synthetic.data_quality.mart_review__stg_medical_claim mc\nLEFT JOIN cms_synthetic.core.member_months mm\n ON mc.patient_id = mm.patient_id\n AND mc.data_source = mm.data_source\n AND mc.year_month = mm.year_month\nGROUP BY mc.data_source\n, mc.year_month\n)\n\nselect\n data_source\n , year_month\n , claims_with_enrollment\n , claims\n , cast(claims_with_enrollment / claims as numeric(28,6) ) AS percentage_claims_with_enrollment\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom enrollment_stage", "relation_name": "cms_synthetic.data_quality.mart_review__claims_with_enrollment"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.949947Z", "completed_at": "2024-10-22T19:20:39.960850Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.975640Z", "completed_at": "2024-10-22T19:20:39.975647Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02681708335876465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__members_with_claims", "compiled": true, "compiled_code": "\n\nWITH medical_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM cms_synthetic.data_quality.mart_review__stg_medical_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n\n,pharmacy_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM cms_synthetic.data_quality.mart_review__stg_pharmacy_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n, final as(\nSELECT\n mm.data_source,\n mm.year_month,\n SUM(CASE WHEN mc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_medical_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_pharmacy_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1\n WHEN mc.patient_id is not null THEN 1 ELSE 0 END) AS members_with_claims,\n COUNT(*) AS total_member_months\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.core.member_months mm\nLEFT JOIN medical_claim mc\n ON mm.patient_id = mc.patient_id\n AND mm.data_source = mc.data_source\n AND mm.year_month = mc.year_month\nLEFT JOIN pharmacy_claim pc\n ON mm.patient_id = pc.patient_id\n AND mm.data_source = pc.data_source\n AND mm.year_month = pc.year_month\nGROUP BY mm.data_source, mm.year_month\n)\n\nselect\n data_source\n , year_month\n , members_with_medical_claims\n , members_with_pharmacy_claims\n , members_with_claims\n , total_member_months\n , cast(members_with_claims/ total_member_months as numeric(28,6)) as percent_members_with_claims\n , cast(members_with_medical_claims/ total_member_months as numeric(28,6)) as percent_members_with_medical_claims\n , cast(members_with_pharmacy_claims/ total_member_months as numeric(28,6)) as percent_members_with_pharmacy_claims\nfrom final", "relation_name": "cms_synthetic.data_quality.mart_review__members_with_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.954548Z", "completed_at": "2024-10-22T19:20:39.976773Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:39.977198Z", "completed_at": "2024-10-22T19:20:39.977202Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02319478988647461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatients with a diagnosis or past history of total colectomy or colorectal cancer: G9711\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n From cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'malignant neoplasm of colon'\n , 'total colectomy'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for historical record of colectomy cancer' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom patients_with_exclusions", "relation_name": "cms_synthetic.quality_measures._int_nqf0034_exclude_colectomy_cancer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.977527Z", "completed_at": "2024-10-22T19:20:40.006945Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.025504Z", "completed_at": "2024-10-22T19:20:40.025510Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.049104928970336914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'frailty device'\n , 'frailty diagnosis'\n , 'frailty encounter'\n , 'frailty symptom'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_frailty as (\n\n select\n patients.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from patients\n inner join condition_exclusions\n on patients.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , med_claim_exclusions.concept_name as exclusion_reason\n from patients\n inner join med_claim_exclusions\n on patients.patient_id = med_claim_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from patients\n inner join observation_exclusions\n on patients.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from patients\n inner join procedure_exclusions\n on patients.patient_id = procedure_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom patients_with_frailty", "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_frailty"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.001064Z", "completed_at": "2024-10-22T19:20:40.030344Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.031767Z", "completed_at": "2024-10-22T19:20:40.031772Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03134799003601074, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatient was provided hospice services any time during the measurement period: G9687\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n From cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n , 'palliative care encounter'\n , 'palliative care diagnosis'\n , 'palliative care intervention'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition \n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n \n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'hospice_palliative' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom patients_with_exclusions", "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.034539Z", "completed_at": "2024-10-22T19:20:40.043740Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.046502Z", "completed_at": "2024-10-22T19:20:40.046520Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015815019607543945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "compiled": true, "compiled_code": "\n\n/*\n patients in institutional special needs plans (snp)\n or residing in long term care\n\n while referencing this model, patients greater or equal than 66 years of age should be taken\n\n filtering out age from this model has been stripped out as different measures calculate age varingly\n\n future enhancement: group claims into encounters\n*/\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, exclusions as (\n\n select\n patients.patient_id\n , coalesce(\n medical_claim.claim_start_date\n , medical_claim.claim_end_date\n ) as exclusion_date\n , 'institutional or long term care' as exclusion_reason\n from patients\n inner join medical_claim\n on patients.patient_id = medical_claim.patient_id\n where place_of_service_code in ('32', '33', '34', '54', '56')\n and datediff(\n day,\n medical_claim.claim_start_date,\n medical_claim.claim_end_date\n ) >= 90\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'institutional_snp' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions", "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.044189Z", "completed_at": "2024-10-22T19:20:40.047807Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.051994Z", "completed_at": "2024-10-22T19:20:40.052000Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009623050689697266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a", "compiled": true, "compiled_code": "\n \n \n\nselect\n location_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.location\nwhere location_id is not null\ngroup by location_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.048006Z", "completed_at": "2024-10-22T19:20:40.052856Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.053244Z", "completed_at": "2024-10-22T19:20:40.053249Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.005972862243652344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__pharmacy", "compiled": true, "compiled_code": "\n\n\nWITH dedup_prac AS (\n SELECT DISTINCT practitioner_id,\n provider_first_name,\n provider_last_name,\n specialty\n FROM cms_synthetic.core.practitioner\n),\ndedup_loc AS (\n SELECT DISTINCT location_id,\n npi,\n name\n FROM cms_synthetic.core.location\n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.patient_id,\n p.data_source,\n p.patient_id || '|' || p.data_source as patient_source_key,\n p.ndc_code,\n COALESCE(n.fda_description, n.rxnorm_description) AS ndc_description,\n p.paid_amount,\n p.allowed_amount,\n p.prescribing_provider_id,\n p.prescribing_provider_name,\n prac.specialty AS prescribing_specialty,\n p.dispensing_provider_id,\n p.dispensing_provider_name,\n p.paid_date,\n p.dispensing_date,\n p.days_supply,\n n.rxcui,\n n.rxnorm_description,\n r.brand_name,\n r.brand_vs_generic,\n r.ingredient_name,\n a.atc_1_name,\n a.atc_2_name,\n a.atc_3_name,\n a.atc_4_name\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cms_synthetic.core.pharmacy_claim p\nLEFT JOIN cms_synthetic.terminology.ndc n ON p.ndc_code = n.ndc\nLEFT JOIN cms_synthetic.terminology.rxnorm_brand_generic r ON n.rxcui = r.product_rxcui\nLEFT JOIN cms_synthetic.terminology.rxnorm_to_atc a ON n.rxcui = a.rxcui\nLEFT JOIN dedup_prac prac ON p.prescribing_provider_id = prac.practitioner_id\nLEFT JOIN dedup_loc l ON p.dispensing_provider_id = l.location_id", "relation_name": "cms_synthetic.data_quality.mart_review__pharmacy"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.054048Z", "completed_at": "2024-10-22T19:20:40.064268Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.064537Z", "completed_at": "2024-10-22T19:20:40.064543Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011588096618652344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6", "compiled": true, "compiled_code": "\n \n \n\nselect\n practitioner_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.practitioner\nwhere practitioner_id is not null\ngroup by practitioner_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.058221Z", "completed_at": "2024-10-22T19:20:40.064878Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.065371Z", "completed_at": "2024-10-22T19:20:40.065374Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007750034332275391, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "compiled": true, "compiled_code": "\n\nwith all_conditions as (\n\n select\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._int_all_conditions\n where hcc_code is not null\n\n)\n\n, hcc_grouped as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , min(recorded_date) as first_recorded\n , max(recorded_date) as last_recorded\n from all_conditions\n where hcc_code is not null\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, hcc_billed as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , max(recorded_date) as last_billed\n from all_conditions\n where hcc_code is not null\n and lower(condition_type) <> 'problem'\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, add_flag as (\n\n select\n hcc_grouped.patient_id\n , hcc_grouped.data_source\n , hcc_grouped.hcc_code\n , hcc_grouped.hcc_description\n , hcc_grouped.first_recorded\n , hcc_grouped.last_recorded\n , hcc_billed.last_billed\n , case\n when date_part('year', hcc_billed.last_billed) = date_part('year', convert_timezone('UTC', current_timestamp()))\n then 1\n else 0\n end as current_year_billed\n\n from hcc_grouped\n left join hcc_billed\n on hcc_grouped.patient_id = hcc_billed.patient_id\n and hcc_grouped.hcc_code = hcc_billed.hcc_code\n and hcc_grouped.data_source = hcc_billed.data_source\n\n)\n\n, all_conditions_with_flag as (\n\n select distinct\n all_conditions.patient_id\n , all_conditions.data_source\n , all_conditions.recorded_date\n , all_conditions.condition_type\n , all_conditions.icd_10_cm_code\n , all_conditions.hcc_code\n , all_conditions.hcc_description\n , add_flag.first_recorded\n , add_flag.last_recorded\n , add_flag.last_billed\n , add_flag.current_year_billed\n , cast('Prior coding history' as TEXT) as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as condition_date\n from all_conditions\n left join add_flag\n on all_conditions.patient_id = add_flag.patient_id\n and all_conditions.hcc_code = add_flag.hcc_code\n and all_conditions.data_source = add_flag.data_source\n\n)\n\n, add_standard_fields as (\n\n select distinct\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , 'Prior coding history' as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as suspect_date\n from all_conditions_with_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(icd_10_cm_code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(first_recorded as date) as first_recorded\n , cast(last_recorded as date) as last_recorded\n , cast(last_billed as date) as last_billed\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_patient_hcc_history"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.066906Z", "completed_at": "2024-10-22T19:20:40.072050Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.072271Z", "completed_at": "2024-10-22T19:20:40.072276Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006638050079345703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.069578Z", "completed_at": "2024-10-22T19:20:40.072616Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.073091Z", "completed_at": "2024-10-22T19:20:40.073095Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0064618587493896484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.074465Z", "completed_at": "2024-10-22T19:20:40.100313Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.100575Z", "completed_at": "2024-10-22T19:20:40.100581Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027251005172729492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim as (\n\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Opioid Use Disorder (OUD)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_medications as (\n\n select\n patient_id\n , claim_id\n , paid_date as start_date\n , replace(ndc_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE excludes medication encounters with the exception codes for\n Naltrexone. Those encounters will be evaluated separately.\n*/\n, inclusions_medication as (\n\n select\n patient_medications.patient_id\n , patient_medications.claim_id\n , patient_medications.start_date\n , patient_medications.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code not in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE includes patients with evidence of the chronic conditions Alcohol\n Use Disorders or Drug Use Disorders.\n*/\n, exclusions_other_chronic_conditions as (\n\n select distinct patient_id\n from cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\n where condition in (\n 'Alcohol Use Disorders'\n , 'Drug Use Disorders'\n )\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE creates the exclusion list which consists of patients with\n medication encounters for Naltrexone having Alcohol Use Disorder or Drug\n Use Disorder and missing the Opioid Use Disorder diagnosis codes.\n*/\n, exclusions_medication as (\n select distinct\n patient_medications.patient_id\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n inner join exclusions_other_chronic_conditions\n on patient_medications.patient_id = exclusions_other_chronic_conditions.patient_id\n left join inclusions_diagnosis\n on patient_medications.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n and inclusions_diagnosis.patient_id is null\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_medication\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_medication\n on inclusions_unioned.patient_id = exclusions_medication.patient_id\nwhere exclusions_medication.patient_id is null", "relation_name": "cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.096724Z", "completed_at": "2024-10-22T19:20:40.100968Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.101564Z", "completed_at": "2024-10-22T19:20:40.101567Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.027383089065551758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.103183Z", "completed_at": "2024-10-22T19:20:40.108364Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.108600Z", "completed_at": "2024-10-22T19:20:40.108605Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006676912307739258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.106010Z", "completed_at": "2024-10-22T19:20:40.108937Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.109434Z", "completed_at": "2024-10-22T19:20:40.109437Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006567239761352539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.110631Z", "completed_at": "2024-10-22T19:20:40.116088Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.116456Z", "completed_at": "2024-10-22T19:20:40.116460Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006757974624633789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.113779Z", "completed_at": "2024-10-22T19:20:40.117166Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.117695Z", "completed_at": "2024-10-22T19:20:40.117699Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0073277950286865234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.118602Z", "completed_at": "2024-10-22T19:20:40.122376Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.125838Z", "completed_at": "2024-10-22T19:20:40.125844Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008513689041137695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.123494Z", "completed_at": "2024-10-22T19:20:40.127597Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.128313Z", "completed_at": "2024-10-22T19:20:40.128318Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0070497989654541016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.128654Z", "completed_at": "2024-10-22T19:20:40.133638Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.136513Z", "completed_at": "2024-10-22T19:20:40.136520Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009272098541259766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_mapping", "compiled": true, "compiled_code": "\n/*\nSteps for staging the medical claim data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from Condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs for each CMS model version\n 4) Union results from each CMS model version\n (note: some payment years may not have results for v28)\n*/\n\nwith conditions as (\n\n select\n patient_id\n , condition_code\n , payment_year\n from cms_synthetic.cms_hcc._int_eligible_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n payment_year\n , diagnosis_code\n , cms_hcc_v24\n , cms_hcc_v24_flag\n , cms_hcc_v28\n , cms_hcc_v28_flag\n from cms_synthetic.cms_hcc._value_set_icd_10_cm_mappings\n\n)\n\n/* casting hcc_code to avoid formatting changes during union */\n, v24_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V24' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v24 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v24_flag = 'Yes'\n\n)\n\n, v28_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V28' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v28 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v28_flag = 'Yes'\n\n)\n\n, unioned as (\n\n select * from v24_mapped\n union all\n select * from v28_mapped\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(condition_code as TEXT) as condition_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , condition_code\n , hcc_code\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_hcc_mapping"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.133876Z", "completed_at": "2024-10-22T19:20:40.137502Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.137920Z", "completed_at": "2024-10-22T19:20:40.137925Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.004853010177612305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition_code\nfrom cms_synthetic.cms_hcc._int_eligible_conditions\nwhere condition_code is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.138289Z", "completed_at": "2024-10-22T19:20:40.154954Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.155419Z", "completed_at": "2024-10-22T19:20:40.155425Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01823902130126953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_allowed) as total_allowed\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_allowed\n else 0\n end\n )\n \n \n as ancillary_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "cms_synthetic.financial_pmpm._int_service_category_1_allowed_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.150302Z", "completed_at": "2024-10-22T19:20:40.156365Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.157031Z", "completed_at": "2024-10-22T19:20:40.157036Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007233858108520508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_paid) as total_paid\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_paid\n else 0\n end\n )\n \n \n as ancillary_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "cms_synthetic.financial_pmpm._int_service_category_1_paid_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.157934Z", "completed_at": "2024-10-22T19:20:40.170416Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.170716Z", "completed_at": "2024-10-22T19:20:40.170722Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014122962951660156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_allowed) as total_allowed\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as acute_inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulance_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_allowed\n else 0\n end\n )\n \n \n as dialysis_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_allowed\n else 0\n end\n )\n \n \n as durable_medical_equipment_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_allowed\n else 0\n end\n )\n \n \n as emergency_department_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_allowed\n else 0\n end\n )\n \n \n as home_health_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_allowed\n else 0\n end\n )\n \n \n as lab_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_allowed\n else 0\n end\n )\n \n \n as observation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_allowed\n else 0\n end\n )\n \n \n as skilled_nursing_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_allowed\n else 0\n end\n )\n \n \n as telehealth_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_allowed\n else 0\n end\n )\n \n \n as urgent_care_allowed\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "cms_synthetic.financial_pmpm._int_service_category_2_allowed_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.164300Z", "completed_at": "2024-10-22T19:20:40.171411Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.171876Z", "completed_at": "2024-10-22T19:20:40.171879Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008200883865356445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_paid) as total_paid\n from cms_synthetic.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as acute_inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_paid\n else 0\n end\n )\n \n \n as ambulance_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_paid\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_paid\n else 0\n end\n )\n \n \n as dialysis_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_paid\n else 0\n end\n )\n \n \n as durable_medical_equipment_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_paid\n else 0\n end\n )\n \n \n as emergency_department_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_paid\n else 0\n end\n )\n \n \n as home_health_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_paid\n else 0\n end\n )\n \n \n as lab_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_paid\n else 0\n end\n )\n \n \n as observation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_paid\n else 0\n end\n )\n \n \n as skilled_nursing_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_paid\n else 0\n end\n )\n \n \n as telehealth_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_paid\n else 0\n end\n )\n \n \n as urgent_care_paid\n \n \n \n \n\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "cms_synthetic.financial_pmpm._int_service_category_2_paid_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.172674Z", "completed_at": "2024-10-22T19:20:40.220564Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.222085Z", "completed_at": "2024-10-22T19:20:40.222090Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.050533294677734375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'advanced illness'\n , 'acute inpatient'\n , 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n where lower(exclusion_codes.concept_name) = 'advanced illness'\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, acute_inpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) = 'acute inpatient'\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) = 'acute inpatient'\n\n)\n\n, nonacute_outpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, exclusions_unioned as (\n\n select\n acute_inpatient.patient_id\n , acute_inpatient.exclusion_date\n , acute_inpatient.exclusion_reason\n , acute_inpatient.claim_start_date\n , acute_inpatient.claim_end_date\n , acute_inpatient.procedure_date\n , 'acute_inpatient' as patient_type\n from acute_inpatient\n\n union all\n\n select\n nonacute_outpatient.patient_id\n , nonacute_outpatient.exclusion_date\n , nonacute_outpatient.exclusion_reason\n , nonacute_outpatient.claim_start_date\n , nonacute_outpatient.claim_end_date\n , nonacute_outpatient.procedure_date\n , 'nonacute_outpatient' as patient_type\n from nonacute_outpatient\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'advanced_illness' as exclusion_type\n , claim_start_date\n , claim_end_date\n , procedure_date\n , patient_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions_unioned", "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.206257Z", "completed_at": "2024-10-22T19:20:40.221842Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.222767Z", "completed_at": "2024-10-22T19:20:40.222771Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.027620792388916016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dementia medications'\n )\n\n)\n\n, medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claim as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.rxnorm_code = exclusion_codes.code\n where exclusion_codes.code_system = 'rxnorm'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claim_exclusions as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date\n , pharmacy_claim.ndc_code\n , pharmacy_claim.paid_date\n , exclusion_codes.concept_name\n from pharmacy_claim\n inner join exclusion_codes\n on pharmacy_claim.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n)\n\n, frailty_with_dementia as (\n\n select\n patients_with_frailty.patient_id\n , patients_with_frailty.exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || pharmacy_claim_exclusions.concept_name as exclusion_reason\n , pharmacy_claim_exclusions.dispensing_date\n , pharmacy_claim_exclusions.paid_date\n from patients_with_frailty\n inner join pharmacy_claim_exclusions\n on patients_with_frailty.patient_id = pharmacy_claim_exclusions.patient_id\n\n union all\n\n select\n patients_with_frailty.patient_id\n , medication_exclusions.dispensing_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || medication_exclusions.concept_name as exclusion_reason\n , medication_exclusions.dispensing_date\n , null as paid_date\n from patients_with_frailty\n inner join medication_exclusions\n on patients_with_frailty.patient_id = medication_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'dementia' as exclusion_type\n , dispensing_date\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom frailty_with_dementia", "relation_name": "cms_synthetic.quality_measures._int_shared_exclusions_dementia"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.225370Z", "completed_at": "2024-10-22T19:20:40.259308Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.259585Z", "completed_at": "2024-10-22T19:20:40.259591Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03549814224243164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa esrd'\n , 'pqa insulin medications'\n )\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as exclusion_date\n , exclusion_codes.concept_name as exclusion_reason\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_exclusions as (\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and exclusion_codes.code_system = 'ndc'\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from pharmacy_exclusions\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.243353Z", "completed_at": "2024-10-22T19:20:40.260236Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.260903Z", "completed_at": "2024-10-22T19:20:40.260908Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03650093078613281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), denominator as (\n\n select\n patient_id\n from cms_synthetic.quality_measures._int_adhras_denominator\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name in (\n 'PQA ESRD'\n , 'PQA Sacubitril Valsartan Medications'\n )\n\n)\n\n, valid_esrd as (\n\n select\n condition.patient_id\n , condition.recorded_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_condition as condition\n inner join codes \n on coalesce(condition.normalized_code, condition.source_code) = codes.code \n and coalesce(condition.normalized_code_type, condition.source_code_type) = codes.code_system\n where condition.recorded_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, sacubitril_pharmacy_claim as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claim\n inner join codes\n on pharmacy_claim.ndc_code = codes.code \n where pharmacy_claim.dispensing_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_esrd\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason \n from sacubitril_pharmacy_claim\n\n)\n\n, measure_exclusions as (\n\n select \n exclusions.patient_id\n , exclusion_date\n , exclusion_reason\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from measure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run \nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adhras_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.261820Z", "completed_at": "2024-10-22T19:20:40.273770Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.274009Z", "completed_at": "2024-10-22T19:20:40.274014Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013530969619750977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from cms_synthetic.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 37 logic */\n, ckd_stage_1_or_2 as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) in (\n 'chronic kidney disease, stage 1'\n , 'chronic kidney disease, stage 2'\n )\n\n)\n\n, ckd_stage_1_or_2_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from ckd_stage_1_or_2\n where row_num = 1\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n)\n\n, diabetes_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from diabetes\n where row_num = 1\n\n)\n\n, hcc_37_suspect as (\n\n select\n diabetes_dedupe.patient_id\n , diabetes_dedupe.data_source\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , diabetes_dedupe.concept_name as condition_1_concept_name\n , diabetes_dedupe.code as condition_1_code\n , diabetes_dedupe.recorded_date as condition_1_recorded_date\n , ckd_stage_1_or_2_dedupe.concept_name as condition_2_concept_name\n , ckd_stage_1_or_2_dedupe.code as condition_2_code\n , ckd_stage_1_or_2_dedupe.recorded_date as condition_2_recorded_date\n from diabetes_dedupe\n inner join ckd_stage_1_or_2_dedupe\n on diabetes_dedupe.patient_id = ckd_stage_1_or_2_dedupe.patient_id\n and diabetes_dedupe.data_source = ckd_stage_1_or_2_dedupe.data_source\n /* ensure conditions overlap in the same year */\n and date_part('year', diabetes_dedupe.recorded_date) = date_part('year', ckd_stage_1_or_2_dedupe.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '37'\n\n)\n/* END HCC 37 logic */\n\n, unioned as (\n\n select * from hcc_37_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.condition_1_concept_name\n , unioned.condition_1_code\n , unioned.condition_1_recorded_date\n , unioned.condition_2_concept_name\n , unioned.condition_2_code\n , unioned.condition_2_recorded_date\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , cast('Comorbidity suspect' as TEXT) as reason\n , condition_1_concept_name || ' (' || condition_1_code || ') on ' || condition_1_recorded_date || ') and ' || condition_2_concept_name || ' (' || condition_2_code || ') on ' || condition_2_recorded_date as contributing_factor\n , condition_1_recorded_date as suspect_date\n from add_billed_flag\n\n)\n\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(condition_1_concept_name as TEXT) as condition_1_concept_name\n , cast(condition_1_code as TEXT) as condition_1_code\n , cast(condition_1_recorded_date as date) as condition_1_recorded_date\n , cast(condition_2_concept_name as TEXT) as condition_2_concept_name\n , cast(condition_2_code as TEXT) as condition_2_code\n , cast(condition_2_recorded_date as date) as condition_2_recorded_date\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_comorbidity_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.268319Z", "completed_at": "2024-10-22T19:20:40.274771Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.275261Z", "completed_at": "2024-10-22T19:20:40.275265Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.007569074630737305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "compiled": true, "compiled_code": "\n\nwith egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from cms_synthetic.hcc_suspecting._int_prep_egfr_labs\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN CKD logic */\n\n/*\n Find a patient\u2019s two most recent eGFR lab results that are spaced by at\n least 90 days.\n*/\n, max_lab_date as (\n\n select\n patient_id\n , data_source\n , max(result_date) as max_result_date\n from egfr_labs\n group by\n patient_id\n , data_source\n\n)\n\n, lab_lookback as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n , max(egfr_labs.result_date) as lookback_result_date\n from egfr_labs\n left join max_lab_date\n on egfr_labs.patient_id = max_lab_date.patient_id\n and egfr_labs.data_source = max_lab_date.data_source\n where egfr_labs.result_date <= \n\n dateadd(\n day,\n -90,\n max_result_date\n )\n\n\n group by\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n\n)\n\n/*\n Take the highest eGFR result that occurred between the date range.\n*/\n, eligible_labs as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , egfr_labs.code_type\n , egfr_labs.code\n , egfr_labs.result_date\n , egfr_labs.result\n , row_number() over (\n partition by\n egfr_labs.patient_id\n , egfr_labs.data_source\n order by egfr_labs.result desc\n ) as row_num\n from egfr_labs\n inner join lab_lookback\n on egfr_labs.patient_id = lab_lookback.patient_id\n and egfr_labs.data_source = lab_lookback.data_source\n where egfr_labs.result_date >= lab_lookback.lookback_result_date\n\n)\n\n/*\n Assign a patient's kidney disease stage based on the highest eGFR based on\n the following range:\n\n CKD 3a: eGFR in the range (45-59)\n CKD 3b: eGFR in the range (30-44)\n CKD 4: eGFR in the range (15-29)\n CKD 5: eGFR in the range (0-14)\n*/\n, ckd_suspects as (\n\n select\n patient_id\n , data_source\n , code_type\n , code as lab_code\n , result_date\n , result\n , case\n when result between 0 and 14 then '326'\n when result between 15 and 29 then '327'\n when result between 30 and 44 then '328'\n when result between 45 and 59 then '329'\n end as hcc_code\n , 'eGFR (' || code || ') result ' || result || ' on ' || result_date as contributing_factor\n from eligible_labs\n where row_num = 1\n\n)\n/* END CKD logic */\n\n, unioned as (\n\n select * from ckd_suspects\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.result_date\n , unioned.result\n , unioned.lab_code\n , unioned.hcc_code\n , unioned.contributing_factor\n , seed_hcc_descriptions.hcc_description\n , billed_hccs.current_year_billed\n from unioned\n inner join seed_hcc_descriptions\n on unioned.hcc_code = seed_hcc_descriptions.hcc_code\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Lab result suspect' as TEXT) as reason\n , result_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n , cast(lab_code as TEXT) as lab_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_lab_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.276068Z", "completed_at": "2024-10-22T19:20:40.293515Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.311892Z", "completed_at": "2024-10-22T19:20:40.311902Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0370020866394043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "compiled": true, "compiled_code": "\n\nwith all_medications as (\n\n select\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n from cms_synthetic.hcc_suspecting._int_all_medications\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n antidepressant medication taken within the past five years\n*/\n, hcc_155_suspect as (\n\n select\n all_medications.patient_id\n , all_medications.dispensing_date\n , all_medications.drug_code\n , all_medications.code_system\n , all_medications.data_source\n , seed_clinical_concepts.concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from all_medications\n inner join seed_clinical_concepts\n on all_medications.code_system = seed_clinical_concepts.code_system\n and all_medications.drug_code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where lower(seed_clinical_concepts.concept_name) = 'antidepressant medication'\n and all_medications.dispensing_date >= \n\n dateadd(\n year,\n -5,\n convert_timezone('UTC', current_timestamp())\n )\n\n\n\n)\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.concept_name\n , unioned.dispensing_date\n , unioned.drug_code\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , cast('Medication suspect' as TEXT) as reason\n , concept_name || drug_code || ') dispensed on ' || dispensing_date as contributing_factor\n , dispensing_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_medication_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.281888Z", "completed_at": "2024-10-22T19:20:40.345187Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.347148Z", "completed_at": "2024-10-22T19:20:40.347155Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.06586599349975586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom cms_synthetic.core.observation\n\n\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from cms_synthetic.hcc_suspecting._int_prep_conditions\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , result\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_observation\n\n)\n\n, numeric_observations as (\n\n select\n patient_id\n , observation_date\n \n , CAST(result AS numeric(28,6)) AS result\n \n , code_type\n , code\n , data_source\n from observations\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from cms_synthetic.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n\n)\n\n, depression_assessment as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.observation_date\n , numeric_observations.result\n , numeric_observations.code_type\n , numeric_observations.code\n , numeric_observations.data_source\n , seed_clinical_concepts.concept_name\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'depression assessment (phq-9)'\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n\n)\n\n, hypertension as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'essential hypertension'\n\n)\n\n, obstructive_sleep_apnea as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'obstructive sleep apnea'\n\n)\n\n/* BEGIN HCC 48 logic (Morbid Obesity) */\n, bmi_over_30_with_osa as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , obstructive_sleep_apnea.code as condition_code\n , obstructive_sleep_apnea.recorded_date as condition_date\n , obstructive_sleep_apnea.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join obstructive_sleep_apnea\n on numeric_observations.patient_id = obstructive_sleep_apnea.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', obstructive_sleep_apnea.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 30\n\n)\n\n, bmi_over_35_with_diabetes as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , diabetes.code as condition_code\n , diabetes.recorded_date as condition_date\n , diabetes.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join diabetes\n on numeric_observations.patient_id = diabetes.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', diabetes.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_35_with_hypertension as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , hypertension.code as condition_code\n , hypertension.recorded_date as condition_date\n , hypertension.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join hypertension\n on numeric_observations.patient_id = hypertension.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', hypertension.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_40 as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , cast(null as TEXT) as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 40\n\n)\n\n, hcc_48_unioned as (\n\n select * from bmi_over_30_with_osa\n union all\n select * from bmi_over_35_with_diabetes\n union all\n select * from bmi_over_35_with_hypertension\n union all\n select * from bmi_over_40\n\n)\n\n, hcc_48_suspect as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , 'BMI result ' || observation_result || case when condition_code is null then '' else ' with ' || condition_concept_name || '(' || condition_code || ' on ' || condition_date || ')' end as contributing_factor\n from hcc_48_unioned\n\n)\n/* END HCC 48 logic */\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n to determine a positive PHQ-9 assessment, we look at the past 3 screenings\n for a patient and take the highest result\n*/\n, eligible_depression_assessments as (\n\n select\n depression_assessment.patient_id\n , depression_assessment.observation_date\n , depression_assessment.result\n , depression_assessment.code_type\n , depression_assessment.code\n , depression_assessment.data_source\n , depression_assessment.concept_name\n , row_number() over (\n partition by\n depression_assessment.patient_id\n , depression_assessment.data_source\n order by\n case when depression_assessment.observation_date is null then 1 else 0 end,\n depression_assessment.observation_date desc\n ) assessment_order\n from depression_assessment\n\n)\n\n, depression_assessments_ordered as (\n\n select\n patient_id\n , observation_date\n , code_type\n , code\n , data_source\n , concept_name\n , result\n , row_number() over (\n partition by\n patient_id\n , data_source\n --order by result desc nulls last\n order by\n case when result is null then 1 else 0 end,\n result desc\n ) as result_order --order the last three assessments by result value\n from eligible_depression_assessments\n where assessment_order <= 3\n\n)\n\n, hcc_155_suspect as (\n\n select\n depression_assessments_ordered.patient_id\n , depression_assessments_ordered.data_source\n , depression_assessments_ordered.observation_date\n , depression_assessments_ordered.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , depression_assessments_ordered.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , 'PHQ-9 result ' || depression_assessments_ordered.result || ' on ' || depression_assessments_ordered.observation_date as contributing_factor\n from depression_assessments_ordered\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where result_order = 1\n and result >= 15\n\n)\n\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_48_suspect\n union all\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.observation_date\n , unioned.observation_result\n , unioned.condition_code\n , unioned.condition_date\n , unioned.condition_concept_name\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.contributing_factor\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Observation suspect' as TEXT) as reason\n , observation_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(observation_date as date) as observation_date\n , cast(observation_result as TEXT) as observation_result\n , cast(condition_code as TEXT) as condition_code\n , cast(condition_date as date) as condition_date\n , cast(condition_concept_name as TEXT) as condition_concept_name\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting._int_observation_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.341614Z", "completed_at": "2024-10-22T19:20:40.346930Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.353859Z", "completed_at": "2024-10-22T19:20:40.353866Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013084888458251953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "compiled": true, "compiled_code": "\n\n\nwith conditions_unioned as (\n\n select * from cms_synthetic.chronic_conditions._int_cms_chronic_condition_all\n union distinct\n select * from cms_synthetic.chronic_conditions._int_cms_chronic_condition_hiv_aids\n union distinct\n select * from cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\n\n)\n\n\nselect\n patient_id\n , claim_id\n , start_date\n , chronic_condition_type\n , condition_category\n , condition\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom conditions_unioned", "relation_name": "cms_synthetic.chronic_conditions.cms_chronic_conditions_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.357986Z", "completed_at": "2024-10-22T19:20:40.364301Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.364758Z", "completed_at": "2024-10-22T19:20:40.364763Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009202957153320312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Opioid Use Disorder (OUD)'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.361044Z", "completed_at": "2024-10-22T19:20:40.364520Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.369606Z", "completed_at": "2024-10-22T19:20:40.369612Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013501882553100586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.382473Z", "completed_at": "2024-10-22T19:20:40.385457Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.386188Z", "completed_at": "2024-10-22T19:20:40.386193Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01500391960144043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.372096Z", "completed_at": "2024-10-22T19:20:40.385922Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.386893Z", "completed_at": "2024-10-22T19:20:40.386897Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016109943389892578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions._int_cms_chronic_condition_oud\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.389039Z", "completed_at": "2024-10-22T19:20:40.398342Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.398679Z", "completed_at": "2024-10-22T19:20:40.398686Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010775089263916016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "compiled": true, "compiled_code": "\n/*\n Staging HCCs that will be used in disease factor calculations.\n Final output for each CMS model version includes:\n - hccs without a hierarchy\n - lower-level hccs with hierarchy where top-level hcc is missing\n - top-level hccs from hierarchy\n*/\n\nwith hcc_mapping as (\n\n select distinct\n patient_id\n , hcc_code\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_hcc_mapping\n\n)\n\n, seed_hcc_hierarchy as (\n\n select\n model_version\n , hcc_code\n , description\n , hccs_to_exclude\n from cms_synthetic.cms_hcc._value_set_disease_hierarchy\n\n)\n\n/*\n selecting hccs that do not have a hierarchy\n all codes in this cte are included in final output\n*/\n, hccs_without_hierarchy as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n left join seed_hcc_hierarchy as hcc_top_level\n on hcc_mapping.hcc_code = hcc_top_level.hcc_code\n and hcc_mapping.model_version = hcc_top_level.model_version\n left join seed_hcc_hierarchy as hcc_exclusions\n on hcc_mapping.hcc_code = hcc_exclusions.hccs_to_exclude\n and hcc_mapping.model_version = hcc_exclusions.model_version\n where hcc_top_level.hcc_code is null\n and hcc_exclusions.hccs_to_exclude is null\n\n)\n\n/*\n selecting hccs that have a hierarchy to be evaluated in the next cte\n*/\n, hccs_with_hierarchy as (\n\n select\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n , seed_hcc_hierarchy.hcc_code as top_level_hcc\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hccs_to_exclude\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n\n)\n\n/*\n applying hcc hierarchy and grouping by patient and hcc\n to account for multiple hcc combinations\n minimum HCC is included following CMS's severity logic\n*/\n, hierarchy_applied as (\n\n select\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n , min(hcc_mapping.hcc_code) as top_level_hcc\n from hccs_with_hierarchy\n left join hcc_mapping\n on hcc_mapping.patient_id = hccs_with_hierarchy.patient_id\n and hcc_mapping.hcc_code = hccs_with_hierarchy.top_level_hcc\n and hcc_mapping.model_version = hccs_with_hierarchy.model_version\n group by\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n\n)\n\n/*\n selecting lower-level hccs in hierarchy\n all codes in this cte are included in final output\n*/\n, lower_level_inclusions as (\n\n select distinct\n patient_id\n , model_version\n , payment_year\n , case\n when top_level_hcc is not null then top_level_hcc\n else hcc_code\n end as hcc_code\n from hierarchy_applied\n\n)\n\n/*\n selecting top-level hccs not in previous steps\n all codes in this cte are included in final output\n*/\n, top_level_inclusions as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hcc_code\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n left join lower_level_inclusions\n on hcc_mapping.patient_id = lower_level_inclusions.patient_id\n and hcc_mapping.hcc_code = lower_level_inclusions.hcc_code\n and hcc_mapping.model_version = lower_level_inclusions.model_version\n left join hierarchy_applied\n on hcc_mapping.patient_id = hierarchy_applied.patient_id\n and hcc_mapping.hcc_code = hierarchy_applied.hcc_code\n and hcc_mapping.model_version = hierarchy_applied.model_version\n where lower_level_inclusions.hcc_code is null\n and hierarchy_applied.top_level_hcc is null\n\n)\n\n, unioned as (\n\n select * from hccs_without_hierarchy\n union all\n select * from lower_level_inclusions\n union all\n select * from top_level_inclusions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n , cast(hcc_code as TEXT) as hcc_code\n from unioned\n\n)\n\nselect\n patient_id\n , model_version\n , payment_year\n , hcc_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_hcc_hierarchy"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.393034Z", "completed_at": "2024-10-22T19:20:40.399366Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.399906Z", "completed_at": "2024-10-22T19:20:40.399910Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01163792610168457, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_prep", "compiled": true, "compiled_code": "\n\nwith combine as (\n select\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.payer_attributed_provider\n , a.payer_attributed_provider_practice\n , a.payer_attributed_provider_organization\n , a.payer_attributed_provider_lob\n , a.custom_attributed_provider\n , a.custom_attributed_provider_practice\n , a.custom_attributed_provider_organization\n , a.custom_attributed_provider_lob\n\n -- service cat 1 paid\n , coalesce(b.inpatient_paid, 0) as inpatient_paid\n , coalesce(b.outpatient_paid, 0) as outpatient_paid\n , coalesce(b.office_based_paid, 0) as office_based_paid\n , coalesce(b.ancillary_paid, 0) as ancillary_paid\n , coalesce(b.other_paid, 0) as other_paid\n , coalesce(b.pharmacy_paid, 0) as pharmacy_paid\n\n -- service cat 2 paid\n , coalesce(c.acute_inpatient_paid, 0) as acute_inpatient_paid\n , coalesce(c.ambulance_paid, 0) as ambulance_paid\n , coalesce(c.ambulatory_surgery_center_paid, 0) as ambulatory_surgery_center_paid\n , coalesce(c.dialysis_paid, 0) as dialysis_paid\n , coalesce(c.durable_medical_equipment_paid, 0) as durable_medical_equipment_paid\n , coalesce(c.emergency_department_paid, 0) as emergency_department_paid\n , coalesce(c.home_health_paid, 0) as home_health_paid\n , coalesce(c.inpatient_hospice_paid, 0) as inpatient_hospice_paid\n , coalesce(c.inpatient_psychiatric_paid, 0) as inpatient_psychiatric_paid\n , coalesce(c.inpatient_rehabilitation_paid, 0) as inpatient_rehabilitation_paid\n , coalesce(c.lab_paid, 0) as lab_paid\n , coalesce(c.observation_paid, 0) as observation_paid\n , coalesce(c.office_based_other_paid, 0) as office_based_other_paid\n , coalesce(c.office_based_ptotst_paid, 0) as office_based_pt_ot_st_paid\n , coalesce(c.office_based_radiology_paid, 0) as office_based_radiology_paid\n , coalesce(c.office_based_surgery_paid, 0) as office_based_surgery_paid\n , coalesce(c.office_based_visit_paid, 0) as office_based_visit_paid\n , coalesce(c.other_paid, 0) as other_paid_2\n , coalesce(c.outpatient_hospice_paid, 0) as outpatient_hospice_paid\n , coalesce(c.outpatient_hospital_or_clinic_paid, 0) as outpatient_hospital_or_clinic_paid\n , coalesce(c.outpatient_ptotst_paid, 0) as outpatient_pt_ot_st_paid\n , coalesce(c.outpatient_psychiatric_paid, 0) as outpatient_psychiatric_paid\n , coalesce(c.outpatient_radiology_paid, 0) as outpatient_radiology_paid\n , coalesce(c.outpatient_rehabilitation_paid, 0) as outpatient_rehabilitation_paid\n , coalesce(c.outpatient_surgery_paid, 0) as outpatient_surgery_paid\n , coalesce(c.pharmacy_paid, 0) as pharmacy_paid_2\n , coalesce(c.skilled_nursing_paid, 0) as skilled_nursing_paid\n , coalesce(c.telehealth_visit_paid, 0) as telehealth_visit_paid\n , coalesce(c.urgent_care_paid, 0) as urgent_care_paid\n\n -- service cat 1 allowed\n , coalesce(d.inpatient_allowed, 0) as inpatient_allowed\n , coalesce(d.outpatient_allowed, 0) as outpatient_allowed\n , coalesce(d.office_based_allowed, 0) as office_based_allowed\n , coalesce(d.ancillary_allowed, 0) as ancillary_allowed\n , coalesce(d.other_allowed, 0) as other_allowed\n , coalesce(d.pharmacy_allowed, 0) as pharmacy_allowed\n\n -- service cat 2 allowed\n , coalesce(e.acute_inpatient_allowed, 0) as acute_inpatient_allowed\n , coalesce(e.ambulance_allowed, 0) as ambulance_allowed\n , coalesce(e.ambulatory_surgery_center_allowed, 0) as ambulatory_surgery_center_allowed\n , coalesce(e.dialysis_allowed, 0) as dialysis_allowed\n , coalesce(e.durable_medical_equipment_allowed, 0) as durable_medical_equipment_allowed\n , coalesce(e.emergency_department_allowed, 0) as emergency_department_allowed\n , coalesce(e.home_health_allowed, 0) as home_health_allowed\n , coalesce(e.inpatient_hospice_allowed, 0) as inpatient_hospice_allowed\n , coalesce(e.inpatient_psychiatric_allowed, 0) as inpatient_psychiatric_allowed\n , coalesce(e.inpatient_rehabilitation_allowed, 0) as inpatient_rehabilitation_allowed\n , coalesce(e.lab_allowed, 0) as lab_allowed\n , coalesce(e.observation_allowed, 0) as observation_allowed\n , coalesce(e.office_based_other_allowed, 0) as office_based_other_allowed\n , coalesce(e.office_based_ptotst_allowed, 0) as office_based_pt_ot_st_allowed\n , coalesce(e.office_based_radiology_allowed, 0) as office_based_radiology_allowed\n , coalesce(e.office_based_surgery_allowed, 0) as office_based_surgery_allowed\n , coalesce(e.office_based_visit_allowed, 0) as office_based_visit_allowed\n , coalesce(e.other_allowed, 0) as other_allowed_2\n , coalesce(e.outpatient_hospice_allowed, 0) as outpatient_hospice_allowed\n , coalesce(e.outpatient_hospital_or_clinic_allowed, 0) as outpatient_hospital_or_clinic_allowed\n , coalesce(e.outpatient_ptotst_allowed, 0) as outpatient_pt_ot_st_allowed\n , coalesce(e.outpatient_psychiatric_allowed, 0) as outpatient_psychiatric_allowed\n , coalesce(e.outpatient_radiology_allowed, 0) as outpatient_radiology_allowed\n , coalesce(e.outpatient_rehabilitation_allowed, 0) as outpatient_rehabilitation_allowed\n , coalesce(e.outpatient_surgery_allowed, 0) as outpatient_surgery_allowed\n , coalesce(e.pharmacy_allowed, 0) as pharmacy_allowed_2\n , coalesce(e.skilled_nursing_allowed, 0) as skilled_nursing_allowed\n , coalesce(e.telehealth_visit_allowed, 0) as telehealth_visit_allowed\n , coalesce(e.urgent_care_allowed, 0) as urgent_care_allowed\n\n from cms_synthetic.core.member_months as a\n left join cms_synthetic.financial_pmpm._int_service_category_1_paid_pivot as b\n on a.patient_id = b.patient_id\n and a.year_month = b.year_month\n and a.payer = b.payer\n and a.plan = b.plan\n left join cms_synthetic.financial_pmpm._int_service_category_2_paid_pivot as c\n on a.patient_id = c.patient_id\n and a.year_month = c.year_month\n and a.payer = c.payer\n and a.plan = c.plan\n left join cms_synthetic.financial_pmpm._int_service_category_1_allowed_pivot as d\n on a.patient_id = d.patient_id\n and a.year_month = d.year_month\n and a.payer = d.payer\n and a.plan = d.plan\n left join cms_synthetic.financial_pmpm._int_service_category_2_allowed_pivot as e\n on a.patient_id = e.patient_id\n and a.year_month = e.year_month\n and a.payer = e.payer\n and a.plan = e.plan\n)\n\nselect\n *\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid + pharmacy_paid as total_paid\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid as medical_paid\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed + pharmacy_allowed as total_allowed\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed as medical_allowed\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom combine", "relation_name": "cms_synthetic.financial_pmpm.pmpm_prep"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.400817Z", "completed_at": "2024-10-22T19:20:40.411407Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.411704Z", "completed_at": "2024-10-22T19:20:40.411710Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012111902236938477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_adh_diabetes_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_adh_diabetes_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adh_diabetes_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.405723Z", "completed_at": "2024-10-22T19:20:40.412419Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.412881Z", "completed_at": "2024-10-22T19:20:40.412887Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0077397823333740234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_adhras_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_adhras_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_adhras_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_adhras_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.413808Z", "completed_at": "2024-10-22T19:20:40.431791Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.432254Z", "completed_at": "2024-10-22T19:20:40.432260Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019718170166015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__list", "compiled": true, "compiled_code": "\n\nwith hcc_history_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_patient_hcc_history\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, comorbidity_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_comorbidity_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, observation_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_observation_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, lab_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_lab_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, medication_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from cms_synthetic.hcc_suspecting._int_medication_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, unioned as (\n\n select * from hcc_history_suspects\n union all\n select * from comorbidity_suspects\n union all\n select * from observation_suspects\n union all\n select * from lab_suspects\n union all\n select * from medication_suspects\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from unioned\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting.list"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.434460Z", "completed_at": "2024-10-22T19:20:40.438797Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.439099Z", "completed_at": "2024-10-22T19:20:40.439104Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005348682403564453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_none", "compiled": true, "compiled_code": "\n\nwith chronic_conditions as \n(\n select distinct patient_id \n from cms_synthetic.chronic_conditions.cms_chronic_conditions_long\n)\n\n,results as (\n select \n cast('Percent of patients without chronic conditions' as TEXT) as data_quality_check\n , sum(case when cccw.patient_id is null then 1 else 0 end) / count(distinct e.patient_id) * 100 as result_count\n from cms_synthetic.core.patient e\n left join chronic_conditions cccw \n on e.patient_id = cccw.patient_id\n)\n\nselect\n results.data_quality_check\n , results.result_count\n , ref_data.analytics_value as medicare_lds_reference\n , 0 as normally_zero \n , cast('2024-10-22 19:20:26.762934+00:00' as TEXT) as tuva_last_run\n \nfrom results\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics as ref_data \n on results.data_quality_check = ref_data.analytics_measure", "relation_name": "cms_synthetic.data_quality.chronic_conditions_none"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.440202Z", "completed_at": "2024-10-22T19:20:40.443850Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.444120Z", "completed_at": "2024-10-22T19:20:40.444125Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004451274871826172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, claim_id, start_date, condition\n from cms_synthetic.chronic_conditions.cms_chronic_conditions_long\n group by patient_id, claim_id, start_date, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.445273Z", "completed_at": "2024-10-22T19:20:40.448230Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.448466Z", "completed_at": "2024-10-22T19:20:40.448470Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0037031173706054688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_long\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.449529Z", "completed_at": "2024-10-22T19:20:40.452791Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.453361Z", "completed_at": "2024-10-22T19:20:40.453367Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00444483757019043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_long\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.454772Z", "completed_at": "2024-10-22T19:20:40.457722Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.457989Z", "completed_at": "2024-10-22T19:20:40.457994Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00384521484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_long\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.460609Z", "completed_at": "2024-10-22T19:20:40.464916Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.465189Z", "completed_at": "2024-10-22T19:20:40.465195Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0065572261810302734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , institutional_status\n , short_name\n , description\n , hcc_code\n , coefficient\n from cms_synthetic.cms_hcc._value_set_disabled_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors\n on demographics_with_hccs.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics_with_hccs.institutional_status = seed_interaction_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_interaction_factors.hcc_code\n and demographics_with_hccs.model_version = seed_interaction_factors.model_version\n\n)\n\n, add_data_types as (\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\nfrom interactions\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_disabled_interaction_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.466235Z", "completed_at": "2024-10-22T19:20:40.475302Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.475823Z", "completed_at": "2024-10-22T19:20:40.475828Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01005697250366211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_disease_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , hcc_code\n , description\n , coefficient\n from cms_synthetic.cms_hcc._value_set_disease_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.gender\n , demographics.age_group\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, disease_factors as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.hcc_code\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_disease_factors.factor_type\n , seed_disease_factors.description\n , seed_disease_factors.coefficient\n from demographics_with_hccs\n inner join seed_disease_factors\n on demographics_with_hccs.enrollment_status = seed_disease_factors.enrollment_status\n and demographics_with_hccs.medicaid_status = seed_disease_factors.medicaid_status\n and demographics_with_hccs.dual_status = seed_disease_factors.dual_status\n and demographics_with_hccs.orec = seed_disease_factors.orec\n and demographics_with_hccs.institutional_status = seed_disease_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_disease_factors.hcc_code\n and demographics_with_hccs.model_version = seed_disease_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(description as TEXT) as hcc_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_factors\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_disease_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.477991Z", "completed_at": "2024-10-22T19:20:40.482786Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.483441Z", "completed_at": "2024-10-22T19:20:40.483448Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006206989288330078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , short_name\n , description\n , hcc_code_1\n , hcc_code_2\n , coefficient\n from cms_synthetic.cms_hcc._value_set_disease_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, demographics_with_interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , interactions_code_1.factor_type\n , interactions_code_1.description\n , interactions_code_1.hcc_code_1\n , interactions_code_1.hcc_code_2\n , interactions_code_1.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors as interactions_code_1\n on demographics_with_hccs.enrollment_status = interactions_code_1.enrollment_status\n and demographics_with_hccs.medicaid_status = interactions_code_1.medicaid_status\n and demographics_with_hccs.dual_status = interactions_code_1.dual_status\n and demographics_with_hccs.orec = interactions_code_1.orec\n and demographics_with_hccs.institutional_status = interactions_code_1.institutional_status\n and demographics_with_hccs.hcc_code = interactions_code_1.hcc_code_1\n and demographics_with_hccs.model_version = interactions_code_1.model_version\n\n)\n\n, disease_interactions as (\n\n select\n demographics_with_interactions.patient_id\n , demographics_with_interactions.factor_type\n , demographics_with_interactions.hcc_code_1\n , demographics_with_interactions.hcc_code_2\n , demographics_with_interactions.description\n , demographics_with_interactions.coefficient\n , demographics_with_interactions.model_version\n , demographics_with_interactions.payment_year\n from demographics_with_interactions\n inner join demographics_with_hccs as interactions_code_2\n on demographics_with_interactions.patient_id = interactions_code_2.patient_id\n and demographics_with_interactions.hcc_code_2 = interactions_code_2.hcc_code\n and demographics_with_interactions.model_version = interactions_code_2.model_version\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code_1 as TEXT) as hcc_code_1\n , cast(hcc_code_2 as TEXT) as hcc_code_2\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_interactions\n\n)\n\nselect\n patient_id\n , hcc_code_1\n , hcc_code_2\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_disease_interaction_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.485135Z", "completed_at": "2024-10-22T19:20:40.490404Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.490666Z", "completed_at": "2024-10-22T19:20:40.490672Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0064890384674072266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_count_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, seed_payment_hcc_count_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , payment_hcc_count\n , description\n , coefficient\n from cms_synthetic.cms_hcc._value_set_payment_hcc_count_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from cms_synthetic.cms_hcc._int_hcc_hierarchy\n\n)\n\n, demographics_with_hcc_counts as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , count(hcc_hierarchy.hcc_code) as hcc_count\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n group by\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n\n)\n\n, hcc_counts_normalized as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n , case\n when hcc_count >= 10 then '>=10'\n else cast(hcc_count as TEXT)\n end as hcc_count_string\n from demographics_with_hcc_counts\n\n)\n\n, hcc_counts as (\n\n select\n hcc_counts_normalized.patient_id\n , hcc_counts_normalized.model_version\n , hcc_counts_normalized.payment_year\n , seed_payment_hcc_count_factors.factor_type\n , seed_payment_hcc_count_factors.description\n , seed_payment_hcc_count_factors.coefficient\n from hcc_counts_normalized\n inner join seed_payment_hcc_count_factors\n on hcc_counts_normalized.enrollment_status = seed_payment_hcc_count_factors.enrollment_status\n and hcc_counts_normalized.medicaid_status = seed_payment_hcc_count_factors.medicaid_status\n and hcc_counts_normalized.dual_status = seed_payment_hcc_count_factors.dual_status\n and hcc_counts_normalized.orec = seed_payment_hcc_count_factors.orec\n and hcc_counts_normalized.institutional_status = seed_payment_hcc_count_factors.institutional_status\n and hcc_counts_normalized.hcc_count_string = seed_payment_hcc_count_factors.payment_hcc_count\n and hcc_counts_normalized.model_version = seed_payment_hcc_count_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from hcc_counts\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc._int_hcc_count_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.492104Z", "completed_at": "2024-10-22T19:20:40.497149Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.497653Z", "completed_at": "2024-10-22T19:20:40.497658Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006207942962646484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__financial_pmpm", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect distinct cast(year_month_int as TEXT ) as year_month\n,year as year_number\nfrom cms_synthetic.reference_data.calendar\n)\n\nselect count(*) as member_months\n,sum(total_paid) / cast(count(*) as numeric(28,6)) as total_pmpm\n,c.year_number as year_number\nfrom cms_synthetic.financial_pmpm.pmpm_prep p \nleft join cte c on p.year_month = c.year_month \ngroup by c.year_number", "relation_name": "cms_synthetic.data_quality.data_quality_financial_pmpm"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.499443Z", "completed_at": "2024-10-22T19:20:40.503462Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.503762Z", "completed_at": "2024-10-22T19:20:40.503768Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005228996276855469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n, payer\n, data_source", "relation_name": "cms_synthetic.financial_pmpm.pmpm_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.505122Z", "completed_at": "2024-10-22T19:20:40.509997Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.510241Z", "completed_at": "2024-10-22T19:20:40.510246Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.005779266357421875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer_plan", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , plan\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n , payer\n , plan\n , data_source", "relation_name": "cms_synthetic.financial_pmpm.pmpm_payer_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.511337Z", "completed_at": "2024-10-22T19:20:40.514220Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.514415Z", "completed_at": "2024-10-22T19:20:40.514419Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0035490989685058594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__member_months", "compiled": true, "compiled_code": "\n\nSELECT m.*,\n COALESCE(p.total_paid, 0) AS total_paid,\n COALESCE(p.medical_paid, 0) AS medical_paid,\n COALESCE(p.pharmacy_paid, 0) AS pharmacy_paid,\n m.patient_id || ' | ' || m.data_source AS patient_data_source_key,\n m.patient_id || ' | ' || m.data_source || ' | ' || m.year_month AS member_month_key\nFROM cms_synthetic.core.member_months m\nLEFT JOIN cms_synthetic.financial_pmpm.pmpm_prep p ON m.patient_id = p.patient_id\n AND m.data_source = p.data_source\n AND m.year_month = p.year_month", "relation_name": "cms_synthetic.data_quality.mart_review__member_months"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.515366Z", "completed_at": "2024-10-22T19:20:40.518591Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.518840Z", "completed_at": "2024-10-22T19:20:40.518845Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.003944873809814453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, year_month, plan\n from cms_synthetic.financial_pmpm.pmpm_prep\n group by patient_id, year_month, plan\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.520004Z", "completed_at": "2024-10-22T19:20:40.523931Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.524136Z", "completed_at": "2024-10-22T19:20:40.524140Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004599809646606445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__list_rollup", "compiled": true, "compiled_code": "\n\nwith list as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , row_number() over (\n partition by\n patient_id\n , hcc_code\n order by suspect_date desc\n ) as row_num\n from cms_synthetic.hcc_suspecting.list\n\n)\n\n, list_dedupe as (\n\n select\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date as latest_suspect_date\n from list\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(latest_suspect_date as date) as latest_suspect_date\n from list_dedupe\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , latest_suspect_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting.list_rollup"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.525148Z", "completed_at": "2024-10-22T19:20:40.534444Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.534758Z", "completed_at": "2024-10-22T19:20:40.534763Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010125160217285156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__summary", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom cms_synthetic.core.patient\n), patients as (\n\n select\n patient_id\n , sex\n , birth_date\n \n , floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8766.0) as age\n \n from __dbt__cte___stg_patient\n where death_date is null\n\n)\n\n, suspecting_list as (\n\n select\n patient_id\n , count(*) as gaps\n from cms_synthetic.hcc_suspecting.list\n group by patient_id\n\n)\n\n, joined as (\n\n select\n patients.patient_id\n , patients.sex\n , patients.birth_date\n , patients.age\n , suspecting_list.gaps\n from patients\n inner join suspecting_list\n on patients.patient_id = suspecting_list.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(sex as TEXT) as patient_sex\n , cast(birth_date as date) as patient_birth_date\n , cast(age as integer) as patient_age\n , cast(gaps as integer) as suspecting_gaps\n from joined\n\n)\n\nselect\n patient_id\n , patient_sex\n , patient_birth_date\n , patient_age\n , suspecting_gaps\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.hcc_suspecting.summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.535950Z", "completed_at": "2024-10-22T19:20:40.541456Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.541658Z", "completed_at": "2024-10-22T19:20:40.541664Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006294965744018555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_factors", "compiled": true, "compiled_code": "\nwith demographic_factors as (\n\n select\n patient_id\n /* concatenate demographic risk factors */\n\n , gender || ', ' || age_group || ' Years' || ', ' || enrollment_status || ' Enrollee' || ', ' || CASE WHEN medicaid_status = 'Yes' THEN 'Medicaid' ELSE 'Non-Medicaid' END || ', ' || dual_status || ' Dual' || ', ' || orec || ', ' || CASE WHEN institutional_status = 'Yes' THEN 'Institutional' ELSE 'Non-Institutional' END as description\n\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, demographic_defaults as (\n\n select\n patient_id\n , model_version\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n from cms_synthetic.cms_hcc._int_demographic_factors\n\n)\n\n, disease_factors as (\n\n select\n patient_id\n , hcc_description || ' (HCC ' || hcc_code || ')' as description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_disease_factors\n\n)\n\n, enrollment_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_enrollment_interaction_factors\n\n)\n\n, disabled_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_disabled_interaction_factors\n\n)\n\n, disease_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_disease_interaction_factors\n\n)\n\n, hcc_counts as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc._int_hcc_count_factors\n\n)\n\n, unioned as (\n\n select * from demographic_factors\n union all\n select * from disease_factors\n union all\n select * from enrollment_interactions\n union all\n select * from disabled_interactions\n union all\n select * from disease_interactions\n union all\n select * from hcc_counts\n\n)\n\n, add_defaults as (\n\n select\n unioned.patient_id\n , demographic_defaults.enrollment_status_default\n , demographic_defaults.medicaid_dual_status_default\n , demographic_defaults.orec_default\n , demographic_defaults.institutional_status_default\n , unioned.description as risk_factor_description\n , unioned.coefficient\n , unioned.factor_type\n , unioned.model_version\n , unioned.payment_year\n from unioned\n left join demographic_defaults\n on unioned.patient_id = demographic_defaults.patient_id\n and unioned.model_version = demographic_defaults.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast(factor_type as TEXT) as factor_type\n , cast(risk_factor_description as TEXT) as risk_factor_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from add_defaults\n\n)\n\nselect\n patient_id\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , factor_type\n , risk_factor_description\n , coefficient\n , model_version\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc.patient_risk_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.542917Z", "completed_at": "2024-10-22T19:20:40.548467Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.548877Z", "completed_at": "2024-10-22T19:20:40.548883Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006547212600708008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__pmpm", "compiled": true, "compiled_code": "\n\n\nSELECT *,\n total_paid * member_months AS total_paid_absolute,\n medical_paid * member_months AS medical_paid_absolute,\n pharmacy_paid * member_months AS pharmacy_paid_absolute,\n inpatient_paid * member_months AS inpatient_paid_absolute,\n outpatient_paid * member_months AS outpatient_paid_absolute,\n office_based_paid * member_months AS office_based_paid_absolute,\n ancillary_paid * member_months AS ancillary_paid_absolute,\n other_paid * member_months AS other_paid_absolute,\n data_source || '|' || year_month as data_source_month_key\nFROM cms_synthetic.financial_pmpm.pmpm_payer", "relation_name": "cms_synthetic.data_quality.mart_review__pmpm"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.551373Z", "completed_at": "2024-10-22T19:20:40.577830Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.578046Z", "completed_at": "2024-10-22T19:20:40.578051Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02860403060913086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_scores", "compiled": true, "compiled_code": "\nwith __dbt__cte___stg_member_months as (\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.member_months\n), seed_adjustment_rates as (\n\n select\n model_version\n , payment_year\n , normalization_factor\n , ma_coding_pattern_adjustment\n from cms_synthetic.cms_hcc._value_set_adjustment_rates\n\n)\n\n, risk_factors as (\n\n select\n patient_id\n , coefficient\n , model_version\n , payment_year\n from cms_synthetic.cms_hcc.patient_risk_factors\n\n)\n\n, member_months as (\n\n select\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer) as eligible_year\n , COUNT(1) as member_months\n from __dbt__cte___stg_member_months\n group by\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer)\n)\n\n, raw_score as (\n\n select\n patient_id\n , sum(coefficient) as risk_score\n , model_version\n , payment_year\n from risk_factors\n group by\n patient_id\n , model_version\n , payment_year\n\n)\n\n/*\n CMS Guidance for the transition from v24 to v28:\n\n PY2024 risk scores will be blended using 67% of the risk score calculated\n from v24 and 33% from v28.\n\n PY2025 risk scores will be blended using 33% of the risk score calculated\n from v24 and 67% from v28.\n\n PY2026 risk scores will be 100% from v28.\n\n Prior payment years will still be calculated from v24 only.\n*/\n, transition_scores as (\n\n select\n patient_id\n , risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V24' then risk_score\n when payment_year = 2024 and model_version = 'CMS-HCC-V24' then risk_score * 0.67\n when payment_year = 2025 and model_version = 'CMS-HCC-V24' then risk_score * 0.33\n when payment_year >= 2026 and model_version = 'CMS-HCC-V24' then 0\n end as v24_risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V28' then 0\n when payment_year = 2024 and model_version = 'CMS-HCC-V28' then risk_score * 0.33\n when payment_year = 2025 and model_version = 'CMS-HCC-V28' then risk_score * 0.67\n when payment_year >= 2026 and model_version = 'CMS-HCC-V28' then risk_score\n end as v28_risk_score\n , model_version\n , payment_year\n from raw_score\n\n)\n\n/*\n Grouping by patient to create a single row per patient.\n*/\n, transition_scores_grouped as (\n\n select\n patient_id\n , max(v24_risk_score) as v24_risk_score\n , max(v28_risk_score) as v28_risk_score\n , payment_year\n from transition_scores\n group by\n patient_id\n , payment_year\n\n)\n\n, blended as (\n\n select\n patient_id\n , v24_risk_score\n , v28_risk_score\n , v24_risk_score + v28_risk_score as blended_risk_score\n , payment_year\n from transition_scores_grouped\n\n)\n\n, normalized as (\n\n select\n blended.patient_id\n , blended.v24_risk_score\n , blended.v28_risk_score\n , blended.blended_risk_score\n , blended.blended_risk_score / seed_adjustment_rates.normalization_factor as normalized_risk_score\n , blended.payment_year\n from blended\n left join seed_adjustment_rates\n on blended.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, payment as (\n\n select\n normalized.patient_id\n , normalized.v24_risk_score\n , normalized.v28_risk_score\n , normalized.blended_risk_score\n , normalized.normalized_risk_score\n , normalized.normalized_risk_score * (1 - seed_adjustment_rates.ma_coding_pattern_adjustment) as payment_risk_score\n , normalized.payment_year\n from normalized\n left join seed_adjustment_rates\n on normalized.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, weighted_score as (\n\n select\n payment.patient_id\n , payment.v24_risk_score\n , payment.v28_risk_score\n , payment.blended_risk_score\n , payment.normalized_risk_score\n , payment.payment_risk_score\n , member_months.member_months\n , payment.payment_risk_score * member_months.member_months as payment_risk_score_weighted_by_months\n , payment.payment_year\n from payment\n left join member_months\n on payment.patient_id = member_months.patient_id\n and payment.payment_year = member_months.eligible_year\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(v24_risk_score as numeric(28,6)),3) as v24_risk_score\n , round(cast(v28_risk_score as numeric(28,6)),3) as v28_risk_score\n , round(cast(blended_risk_score as numeric(28,6)),3) as blended_risk_score\n , round(cast(normalized_risk_score as numeric(28,6)),3) as normalized_risk_score\n , round(cast(payment_risk_score as numeric(28,6)),3) as payment_risk_score\n , round(cast(payment_risk_score_weighted_by_months as numeric(28,6)),3) as payment_risk_score_weighted_by_months\n , cast(member_months as integer) as member_months\n , cast(payment_year as integer) as payment_year\n from weighted_score\n\n)\n\nselect\n patient_id\n , v24_risk_score\n , v28_risk_score\n , blended_risk_score\n , normalized_risk_score\n , payment_risk_score\n , payment_risk_score_weighted_by_months\n , member_months\n , payment_year\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.cms_hcc.patient_risk_scores"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.579200Z", "completed_at": "2024-10-22T19:20:40.583684Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.588393Z", "completed_at": "2024-10-22T19:20:40.588399Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009727001190185547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__cms_hcc", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect max(case when factor_type = 'Demographic' then 1 else 0 end) demographic_factor\n,max(case when factor_type = 'Disease' then 1 else 0 end) as disease_factor\nfrom cms_synthetic.cms_hcc.patient_risk_factors\n)\n\nselect 'missing cms-hcc demographic factor' as data_quality_check\n,case when demographic_factor = 0 then 1 else 0 end as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte \n\nunion all\n\nselect 'missing cms-hcc disease factor' as data_quality_check\n,case when disease_factor = 0 then 1 else 0 end as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte", "relation_name": "cms_synthetic.data_quality.data_quality_cms_hcc"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.591213Z", "completed_at": "2024-10-22T19:20:40.594035Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.594324Z", "completed_at": "2024-10-22T19:20:40.594329Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004043102264404297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient_risk_factors", "compiled": true, "compiled_code": "\n\nselect *\n,dense_rank() over (order by patient_id, model_version, payment_year ) as patient_risk_sk\nfrom cms_synthetic.cms_hcc.patient_risk_factors p", "relation_name": "cms_synthetic.data_quality.mart_review__patient_risk_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.595928Z", "completed_at": "2024-10-22T19:20:40.598913Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.599118Z", "completed_at": "2024-10-22T19:20:40.599123Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0038738250732421875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__cms_hcc_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(normalized_risk_score) data_source_value\n,cast('normalized risk score' as TEXT) as analytics_measure\n,cast('cms-hcc' as TEXT) as analytics_concept\nfrom cms_synthetic.cms_hcc.patient_risk_scores\n)\n\nselect \n m.analytics_concept as analytics_concept\n,m.analytics_measure as analytics_measure\n,cte.data_source_value\n,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = 'cms-hcc'\nand\nm.analytics_measure = 'normalized risk score'", "relation_name": "cms_synthetic.data_quality.data_quality_cms_hcc_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.600115Z", "completed_at": "2024-10-22T19:20:40.602142Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.602347Z", "completed_at": "2024-10-22T19:20:40.602350Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0026807785034179688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient_risk_scores", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom cms_synthetic.cms_hcc.patient_risk_scores p", "relation_name": "cms_synthetic.data_quality.mart_review__patient_risk_scores"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.603333Z", "completed_at": "2024-10-22T19:20:40.607099Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.607293Z", "completed_at": "2024-10-22T19:20:40.607298Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004415035247802734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.cms_hcc.patient_risk_scores\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.608337Z", "completed_at": "2024-10-22T19:20:40.611027Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.611217Z", "completed_at": "2024-10-22T19:20:40.611221Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.00339508056640625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient_risk", "compiled": true, "compiled_code": "\n\n\nWITH cte AS (\n SELECT \n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n SUM(coefficient) AS risk_score\n FROM cms_synthetic.data_quality.mart_review__patient_risk_factors\n GROUP BY payment_year,\n patient_id,\n model_version,\n patient_risk_sk\n)\n\nSELECT \n CASE \n WHEN risk_score <= 0.5 THEN '.5'\n WHEN risk_score BETWEEN 0.5 AND 1.0 THEN '1'\n WHEN risk_score BETWEEN 1.0 AND 1.5 THEN '1.5'\n WHEN risk_score BETWEEN 1.5 AND 2.0 THEN '2'\n WHEN risk_score BETWEEN 2.0 AND 2.5 THEN '2.5'\n WHEN risk_score BETWEEN 2.5 AND 3.0 THEN '3'\n WHEN risk_score BETWEEN 3.0 AND 3.5 THEN '3.5'\n WHEN risk_score BETWEEN 3.5 AND 4.0 THEN '4'\n WHEN risk_score BETWEEN 4.0 AND 4.5 THEN '4.5'\n WHEN risk_score BETWEEN 4.5 AND 5.0 THEN '5'\n WHEN risk_score > 5.0 THEN '5+'\n ELSE null \n END AS risk_score_bucket,\n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n risk_score\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nFROM cte", "relation_name": "cms_synthetic.data_quality.mart_review__patient_risk"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.420397Z", "completed_at": "2024-10-22T19:20:40.861395Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.862127Z", "completed_at": "2024-10-22T19:20:40.862133Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.5694179534912109, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__patient as (\n\n\nselect \n patient_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), chronic_conditions as (\n\n select distinct\n condition\n , condition_column_name\n from cms_synthetic.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, conditions as (\n\n select\n chronic_conditions_unioned.patient_id\n , chronic_conditions.condition_column_name\n , 1 as condition_count\n from cms_synthetic.chronic_conditions.cms_chronic_conditions_long as chronic_conditions_unioned\n inner join chronic_conditions as chronic_conditions\n on chronic_conditions_unioned.condition = chronic_conditions.condition\n\n)\n\nselect\n p.patient_id\n , \n \n max(\n \n case\n when condition_column_name = 'acute_myocardial_infarction'\n then 1\n else 0\n end\n )\n \n \n as acute_myocardial_infarction\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'adhd_conduct_disorders_and_hyperkinetic_syndrome'\n then 1\n else 0\n end\n )\n \n \n as adhd_conduct_disorders_and_hyperkinetic_syndrome\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alcohol_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as alcohol_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alzheimers_disease'\n then 1\n else 0\n end\n )\n \n \n as alzheimers_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anemia'\n then 1\n else 0\n end\n )\n \n \n as anemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anxiety_disorders'\n then 1\n else 0\n end\n )\n \n \n as anxiety_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'asthma'\n then 1\n else 0\n end\n )\n \n \n as asthma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'atrial_fibrillation_and_flutter'\n then 1\n else 0\n end\n )\n \n \n as atrial_fibrillation_and_flutter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'autism_spectrum_disorders'\n then 1\n else 0\n end\n )\n \n \n as autism_spectrum_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'benign_prostatic_hyperplasia'\n then 1\n else 0\n end\n )\n \n \n as benign_prostatic_hyperplasia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'bipolar_disorder'\n then 1\n else 0\n end\n )\n \n \n as bipolar_disorder\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_breast'\n then 1\n else 0\n end\n )\n \n \n as cancer_breast\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_colorectal'\n then 1\n else 0\n end\n )\n \n \n as cancer_colorectal\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_endometrial'\n then 1\n else 0\n end\n )\n \n \n as cancer_endometrial\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_lung'\n then 1\n else 0\n end\n )\n \n \n as cancer_lung\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_prostate'\n then 1\n else 0\n end\n )\n \n \n as cancer_prostate\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_urologic_kidney_renal_pelvis_and_ureter'\n then 1\n else 0\n end\n )\n \n \n as cancer_urologic_kidney_renal_pelvis_and_ureter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cataract'\n then 1\n else 0\n end\n )\n \n \n as cataract\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cerebral_palsy'\n then 1\n else 0\n end\n )\n \n \n as cerebral_palsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_kidney_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_kidney_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_obstructive_pulmonary_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_obstructive_pulmonary_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cystic_fibrosis_and_other_metabolic_developmental_disorders'\n then 1\n else 0\n end\n )\n \n \n as cystic_fibrosis_and_other_metabolic_developmental_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depression_bipolar_or_other_depressive_mood_disorders'\n then 1\n else 0\n end\n )\n \n \n as depression_bipolar_or_other_depressive_mood_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depressive_disorders'\n then 1\n else 0\n end\n )\n \n \n as depressive_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'diabetes'\n then 1\n else 0\n end\n )\n \n \n as diabetes\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'drug_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as drug_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'epilepsy'\n then 1\n else 0\n end\n )\n \n \n as epilepsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'fibromyalgia_and_chronic_pain_and_fatigue'\n then 1\n else 0\n end\n )\n \n \n as fibromyalgia_and_chronic_pain_and_fatigue\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'glaucoma'\n then 1\n else 0\n end\n )\n \n \n as glaucoma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'heart_failure_and_non_ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as heart_failure_and_non_ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_a'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_a\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_acute_or_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_acute_or_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_acute'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_acute\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_d'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_d\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_e'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_e\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hip_pelvic_fracture'\n then 1\n else 0\n end\n )\n \n \n as hip_pelvic_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids'\n then 1\n else 0\n end\n )\n \n \n as human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hyperlipidemia'\n then 1\n else 0\n end\n )\n \n \n as hyperlipidemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypertension'\n then 1\n else 0\n end\n )\n \n \n as hypertension\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypothyroidism'\n then 1\n else 0\n end\n )\n \n \n as hypothyroidism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'intellectual_disabilities_and_related_conditions'\n then 1\n else 0\n end\n )\n \n \n as intellectual_disabilities_and_related_conditions\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'learning_disabilities'\n then 1\n else 0\n end\n )\n \n \n as learning_disabilities\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'leukemias_and_lymphomas'\n then 1\n else 0\n end\n )\n \n \n as leukemias_and_lymphomas\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis'\n then 1\n else 0\n end\n )\n \n \n as liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'migraine_and_chronic_headache'\n then 1\n else 0\n end\n )\n \n \n as migraine_and_chronic_headache\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'mobility_impairments'\n then 1\n else 0\n end\n )\n \n \n as mobility_impairments\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'multiple_sclerosis_and_transverse_myelitis'\n then 1\n else 0\n end\n )\n \n \n as multiple_sclerosis_and_transverse_myelitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'muscular_dystrophy'\n then 1\n else 0\n end\n )\n \n \n as muscular_dystrophy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'non_alzheimers_dementia'\n then 1\n else 0\n end\n )\n \n \n as non_alzheimers_dementia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'obesity'\n then 1\n else 0\n end\n )\n \n \n as obesity\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'opioid_use_disorder_oud'\n then 1\n else 0\n end\n )\n \n \n as opioid_use_disorder_oud\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'osteoporosis_with_or_without_pathological_fracture'\n then 1\n else 0\n end\n )\n \n \n as osteoporosis_with_or_without_pathological_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'other_developmental_delays'\n then 1\n else 0\n end\n )\n \n \n as other_developmental_delays\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'parkinsons_disease_and_secondary_parkinsonism'\n then 1\n else 0\n end\n )\n \n \n as parkinsons_disease_and_secondary_parkinsonism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'peripheral_vascular_disease_pvd'\n then 1\n else 0\n end\n )\n \n \n as peripheral_vascular_disease_pvd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'personality_disorders'\n then 1\n else 0\n end\n )\n \n \n as personality_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pneumonia_all_cause'\n then 1\n else 0\n end\n )\n \n \n as pneumonia_all_cause\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'post_traumatic_stress_disorder_ptsd'\n then 1\n else 0\n end\n )\n \n \n as post_traumatic_stress_disorder_ptsd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pressure_and_chronic_ulcers'\n then 1\n else 0\n end\n )\n \n \n as pressure_and_chronic_ulcers\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'rheumatoid_arthritis_osteoarthritis'\n then 1\n else 0\n end\n )\n \n \n as rheumatoid_arthritis_osteoarthritis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia_and_other_psychotic_disorders'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia_and_other_psychotic_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_blindness_and_visual_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_blindness_and_visual_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_deafness_and_hearing_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_deafness_and_hearing_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sickle_cell_disease'\n then 1\n else 0\n end\n )\n \n \n as sickle_cell_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spina_bifida_and_other_congenital_anomalies_of_the_nervous_system'\n then 1\n else 0\n end\n )\n \n \n as spina_bifida_and_other_congenital_anomalies_of_the_nervous_system\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spinal_cord_injury'\n then 1\n else 0\n end\n )\n \n \n as spinal_cord_injury\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'stroke_transient_ischemic_attack'\n then 1\n else 0\n end\n )\n \n \n as stroke_transient_ischemic_attack\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'tobacco_use'\n then 1\n else 0\n end\n )\n \n \n as tobacco_use\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage'\n then 1\n else 0\n end\n )\n \n \n as traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'viral_hepatitis_general'\n then 1\n else 0\n end\n )\n \n \n as viral_hepatitis_general\n \n \n \n \n\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__cms_chronic_conditions__stg_core__patient p\n left join conditions\n on p.patient_id = conditions.patient_id\ngroup by\n p.patient_id", "relation_name": "cms_synthetic.chronic_conditions.cms_chronic_conditions_wide"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.991060Z", "completed_at": "2024-10-22T19:20:40.996143Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.996581Z", "completed_at": "2024-10-22T19:20:40.996588Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0065271854400634766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:40.993715Z", "completed_at": "2024-10-22T19:20:40.996337Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:40.997023Z", "completed_at": "2024-10-22T19:20:40.997026Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006661891937255859, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:30.721883Z", "completed_at": "2024-10-22T19:20:42.048423Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:42.048943Z", "completed_at": "2024-10-22T19:20:42.048951Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 11.465576887130737, "adapter_response": {}, "message": null, "failures": null, "unique_id": "operation.the_tuva_project.the_tuva_project-on-run-end-0", "compiled": true, "compiled_code": "\n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:39.572273Z", "completed_at": "2024-10-22T19:20:43.066711Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.066949Z", "completed_at": "2024-10-22T19:20:43.066954Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 3.61628794670105, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_encounter", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the encounter table in core using dbt_utils.union_relations.\n-- *************************************************\n\n\n\nWITH base AS (\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.acute_inpatient__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(\"DELIVERY_FLAG\" as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(\"DELIVERY_TYPE\" as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(\"NEWBORN_FLAG\" as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(\"NICU_FLAG\" as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.acute_inpatient__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.emergency_department__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.emergency_department__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_snf__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_snf__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.inpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.inpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.urgent_care__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.urgent_care__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.office_visit__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(null as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"BILLING_ID\" as character varying(16777216)) as \"BILLING_ID\" ,\n cast(\"PROVIDER_NAME\" as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(\"PROVIDER_SPECIALTY\" as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(\"CCS_CATEGORY\" as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(\"CCS_CATEGORY_DESCRIPTION\" as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.office_visit__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_injections__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_injections__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_ptotst__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_ptotst__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_surgery__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_surgery__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_radiology__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_radiology__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.outpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.outpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.home_health__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.home_health__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.dialysis__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.dialysis__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.asc__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.asc__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.ambulance__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.ambulance__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.dme__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.dme__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.lab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.lab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.claims_preprocessing.orphaned_claim__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from cms_synthetic.claims_preprocessing.orphaned_claim__encounter_grain\n\n \n )\n\n \n)\n\nSELECT\n cast(encounter_id as TEXT ) as encounter_id\n , cast(p.patient_id as TEXT ) as patient_id\n , cast(encounter_type as TEXT ) as encounter_type\n , cast(encounter_group as TEXT ) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer ) as length_of_stay\n , cast(admit_source_code as TEXT ) as admit_source_code\n , cast(admit_source_description as TEXT ) as admit_source_description\n , cast(admit_type_code as TEXT ) as admit_type_code\n , cast(admit_type_description as TEXT ) as admit_type_description\n , cast(discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(facility_id as TEXT ) as facility_id\n , cast(facility_name as TEXT ) as facility_name\n , cast(facility_type as TEXT ) as facility_type\n , cast(observation_flag as integer ) as observation_flag\n , cast(lab_flag as integer ) as lab_flag\n , cast(dme_flag as integer ) as dme_flag\n , cast(ambulance_flag as integer ) as ambulance_flag\n , cast(pharmacy_flag as integer ) as pharmacy_flag\n , cast(ed_flag as integer ) as ed_flag\n , cast(delivery_flag as integer ) as delivery_flag\n , cast(delivery_type as TEXT ) as delivery_type\n , cast(newborn_flag as integer ) as newborn_flag\n , cast(nicu_flag as integer ) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT ) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT ) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT ) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT ) as ms_drg_code\n , cast(ms_drg_description as TEXT ) as ms_drg_description\n , cast(apr_drg_code as TEXT ) as apr_drg_code\n , cast(apr_drg_description as TEXT ) as apr_drg_description\n , cast(total_paid_amount as numeric(28,6) ) as paid_amount\n , cast(total_allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(total_charge_amount as numeric(28,6) ) as charge_amount\n , cast(claim_count as integer) as claim_count\n , cast(inst_claim_count as integer) as inst_claim_count\n , cast(prof_claim_count as integer) as prof_claim_count\n , cast(_dbt_source_relation as TEXT) as source_model\n , cast(base.data_source as TEXT ) as data_source\n , cast('2024-10-22 19:20:26.762934+00:00' as timestamp ) as tuva_last_run\nFROM base\ninner join cms_synthetic.claims_preprocessing.encounters__patient_data_source_id p on base.patient_data_source_id = p.patient_data_source_id", "relation_name": "cms_synthetic.dbt_tom.core__stg_claims_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.183444Z", "completed_at": "2024-10-22T19:20:43.190344Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.190561Z", "completed_at": "2024-10-22T19:20:43.190566Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.008132219314575195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__encounter", "compiled": true, "compiled_code": "\n\nselect *\n,'claim' as encounter_source_type\n from cms_synthetic.dbt_tom.core__stg_claims_encounter\nunion all\n\nselect *\n,'clinical' as encounter_source_type\n from cms_synthetic.dbt_tom.core__stg_clinical_encounter\n\n", "relation_name": "cms_synthetic.core.encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.193897Z", "completed_at": "2024-10-22T19:20:43.206720Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.207117Z", "completed_at": "2024-10-22T19:20:43.207125Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015202760696411133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "compiled": true, "compiled_code": "\n\nselect \n encounter_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , admit_source_code\n , encounter_start_date\n , encounter_end_date\n , length_of_stay\n , primary_diagnosis_code\n , patient_id\n , facility_id\n , paid_amount\n , date_part('year', encounter_start_date) as year_number\nfrom\n cms_synthetic.core.encounter\nwhere \n encounter_type = 'acute inpatient'", "relation_name": "cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.196685Z", "completed_at": "2024-10-22T19:20:43.207553Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.208423Z", "completed_at": "2024-10-22T19:20:43.208426Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01601099967956543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient", "compiled": true, "compiled_code": "\n\nwith cte as (\n select count(*) as result_count\n ,'inpatient encounter missing professional claim' as data_quality_check\n from cms_synthetic.core.encounter\n where encounter_type = 'acute inpatient'\n and prof_claim_count = 0 \n)\n\n\nselect data_quality_check\n,result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cte", "relation_name": "cms_synthetic.data_quality.data_quality_acute_inpatient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.199080Z", "completed_at": "2024-10-22T19:20:43.207763Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.208798Z", "completed_at": "2024-10-22T19:20:43.208802Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01615619659423828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "compiled": true, "compiled_code": "\n\nwith total_cte as (\nselect cast(count(*) as numeric(28,6) ) as total_encounters\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n) \n\n,cte as (\nselect \n ms_drg_code || ' - ' || ms_drg_description as ms_drg_code_and_description\n ,cast('acute inpatient drg distribution' as TEXT ) as analytics_concept\n ,cast(count(*) as numeric(28,6) )/total_encounters as encounter_percent\n ,total_encounters\n ,row_number() over (order by count(*) desc) as rank_nbr\nfrom cms_synthetic.core.encounter\ncross join total_cte \nwhere encounter_type = 'acute inpatient'\nand\nms_drg_code is not null\ngroup by \n ms_drg_code || ' - ' || ms_drg_description,\n total_encounters\n)\n\nselect \n cte.analytics_concept\n ,ms_drg_code_and_description as analytics_measure\n ,encounter_percent as data_source_value\n ,m.analytics_value\n ,rank_nbr as value_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on\nm.analytics_concept = cte.analytics_concept\nand\ncte.rank_nbr = m.value_rank\nwhere m.analytics_concept = 'acute inpatient drg distribution'\nand rank_nbr < 11", "relation_name": "cms_synthetic.data_quality.data_quality_acute_inpatient_prevelence"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.203318Z", "completed_at": "2024-10-22T19:20:43.208166Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.209407Z", "completed_at": "2024-10-22T19:20:43.209410Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01628899574279785, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(length_of_stay) los\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end) deceased_encounters\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end)/count(*) as mortality_rate\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n)\n\n\n,long_cte as (\n select 'acute inpatient' as analytics_concept\n,'length of stay' as analytics_measure\n,los as data_source_value\nfrom cte\n\nunion all \n\n select 'acute inpatient' as analytics_concept\n,'mortality rate' as analytics_measure\n,mortality_rate as data_source_value\nfrom cte\n)\n\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'length of stay'\n\nunion all \n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'mortality rate'", "relation_name": "cms_synthetic.data_quality.data_quality_acute_inpatient_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.211257Z", "completed_at": "2024-10-22T19:20:43.225283Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.225962Z", "completed_at": "2024-10-22T19:20:43.225968Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.016867876052856445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__core_populated", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n 'medical_claim' as table_name\n , count(*) as record_count\n from cms_synthetic.core.medical_claim\n)\n\n, pharmacy as (\n select\n 'pharmacy_claim' as table_name\n , count(*) as record_count\n from cms_synthetic.core.pharmacy_claim\n)\n\n, eligibility as (\n select\n 'eligibility' as table_name\n , count(*) as record_count\n from cms_synthetic.core.eligibility\n)\n\n, member_months as (\n select\n 'member_months' as table_name\n , count(*) as record_count\n from cms_synthetic.core.member_months\n)\n\n, patient as (\n select\n 'patient' as table_name\n , count(*) as record_count\n from cms_synthetic.core.patient\n)\n\n, encounter as (\n select\n 'encounter' as table_name\n , count(*) as record_count\n from cms_synthetic.core.encounter\n)\n\n, condition as (\n select\n 'condition' as table_name\n , count(*) as record_count\n from cms_synthetic.core.condition\n)\n\n, procedure_cte as (\n select\n 'procedure' as table_name\n , count(*) as record_count\n from cms_synthetic.core.procedure\n)\n\n,final as (\nselect * from medical\nunion all\nselect * from pharmacy\nunion all\nselect * from eligibility\nunion all\nselect * from member_months\nunion all\nselect * from patient\nunion all\nselect * from encounter\nunion all\nselect * from condition\nunion all\nselect * from procedure_cte\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.core_populated"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.215404Z", "completed_at": "2024-10-22T19:20:43.225737Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.226377Z", "completed_at": "2024-10-22T19:20:43.226380Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01579904556274414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select \n count(1) as member_months \n from cms_synthetic.core.member_months\n)\n,pkpy as (\nselect\n cast('encounters cost and utilization PKPY' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , count(enc.encounter_id) / avg(mm.member_months) * 12000 as data_source_value\nfrom cms_synthetic.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\n,paid_per as (\nselect\n cast('encounters cost and utilization paid per' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , sum(enc.paid_amount) / count(enc.encounter_id) as data_source_value\nfrom cms_synthetic.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\nselect\n pkpy.*\n ,ref_data.analytics_value\n ,cast('2024-10-22 19:20:26.762934+00:00' as TEXT) as tuva_last_run\nfrom pkpy\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data on pkpy.analytics_concept = ref_data.analytics_concept and pkpy.analytics_measure = ref_data.analytics_measure\nunion all\nselect\n paid_per.*\n ,ref_data.analytics_value\n ,cast('2024-10-22 19:20:26.762934+00:00' as TEXT) as tuva_last_run\nfrom paid_per\nleft join cms_synthetic.data_quality._value_set_reference_mart_analytics ref_data on paid_per.analytics_concept = paid_per.analytics_concept and paid_per.analytics_measure = paid_per.analytics_measure", "relation_name": "cms_synthetic.data_quality.encounters_cost_and_utilization"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.220180Z", "completed_at": "2024-10-22T19:20:43.226692Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.227744Z", "completed_at": "2024-10-22T19:20:43.227747Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016796112060546875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from cms_synthetic.core.member_months\n group by year_month\n)\n\n, encounters as (\n select\n cast(cal.year_month_int as TEXT) as year_month\n , e.encounter_group\n , e.encounter_type\n , e.encounter_id\n , e.paid_amount\n from cms_synthetic.core.encounter as e\n left join cms_synthetic.reference_data.calendar as cal\n on e.encounter_start_date = cal.full_date\n)\n\n, pkpy_trend as (\n select\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , count(enc.encounter_id) / mm.member_months * 12000 as pkpy\n , sum(enc.paid_amount) / nullif(count(enc.encounter_id), 0) as paid_per\n from encounters as enc\n inner join member_months as mm\n on enc.year_month = mm.year_month\n group by\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , mm.member_months\n)\n\nselect\n pkpy_trend.year_month\n , pkpy_trend.encounter_group\n , pkpy_trend.encounter_type\n , pkpy_trend.pkpy\n , pkpy_trend.paid_per\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom pkpy_trend", "relation_name": "cms_synthetic.data_quality.encounters_cost_and_utilization_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.223084Z", "completed_at": "2024-10-22T19:20:43.226894Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.228075Z", "completed_at": "2024-10-22T19:20:43.228078Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013647794723510742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups", "compiled": true, "compiled_code": "\n\nwith expected_groups as (\n select 'inpatient' as encounter_group\n union all\n select 'outpatient'\n union all\n select 'office based'\n union all\n select 'other'\n)\n\n, actual_groups as (\n select distinct\n encounter_group\n from cms_synthetic.core.encounter\n)\n\nselect\n e.encounter_group as missing_encounter_group\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom expected_groups e\n left join actual_groups a\n on e.encounter_group = a.encounter_group\nwhere a.encounter_group is null", "relation_name": "cms_synthetic.data_quality.encounters_missing_groups"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.233569Z", "completed_at": "2024-10-22T19:20:43.246871Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.247529Z", "completed_at": "2024-10-22T19:20:43.247533Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.018925905227661133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__inpatient", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n location_id\n , npi\n , name\n from cms_synthetic.core.location\n)\n\n, final as (\n select\n e.*\n , e.patient_id || '|' || e.data_source as patient_source_key\n , e.encounter_id || '|' || e.data_source as encounter_source_key\n , e.ms_drg_code || ' | ' || e.ms_drg_description as drgwithdescription\n , e.primary_diagnosis_code || ' | ' || e.primary_diagnosis_description as primary_diagnosis_and_description\n , e.admit_source_code || ' | ' || e.admit_source_description as admit_source_code_and_description\n , e.admit_type_code || ' | ' || e.admit_type_description as admit_type_code_and_description\n , e.discharge_disposition_code || ' | ' || e.discharge_disposition_description as discharge_code_and_description\n , p.ccsr_parent_category\n , p.ccsr_category\n , p.ccsr_category_description\n , p.ccsr_category || ' | ' || p.ccsr_category_description as ccsr_category_and_description\n , b.body_system\n , case \n when e.length_of_stay <= 1 then '1. 0-1 day'\n when e.length_of_stay <= 3 then '2. 2-3 days'\n when e.length_of_stay <= 5 then '3. 4-5 days'\n when e.length_of_stay <= 7 then '4. 6-7 days'\n when e.length_of_stay <= 14 then '5. 8-14 days'\n when e.length_of_stay <= 30 then '6. 15-30 days'\n end as los_groups\n from cms_synthetic.core.encounter as e\n left join cte as l\n on e.facility_id = l.location_id\n left join cms_synthetic.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\n left join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems as b\n on p.ccsr_parent_category = b.ccsr_parent_category\n where e.encounter_type = 'acute inpatient'\n)\n\nselect * from final", "relation_name": "cms_synthetic.data_quality.mart_review__inpatient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.250494Z", "completed_at": "2024-10-22T19:20:43.258853Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.261969Z", "completed_at": "2024-10-22T19:20:43.261974Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.013839960098266602, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792", "compiled": true, "compiled_code": "\n \n \n\nselect\n encounter_id as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.core.encounter\nwhere encounter_id is not null\ngroup by encounter_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.253746Z", "completed_at": "2024-10-22T19:20:43.261721Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.262542Z", "completed_at": "2024-10-22T19:20:43.262547Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013031959533691406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "compiled": true, "compiled_code": "\n-- Exclude encounters with missing start dates\nselect\n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n encounter_start_date is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.256567Z", "completed_at": "2024-10-22T19:20:43.262300Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.263381Z", "completed_at": "2024-10-22T19:20:43.263384Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013358831405639648, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with missing primary diagnosis code\nselect \n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n primary_diagnosis_code is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.259352Z", "completed_at": "2024-10-22T19:20:43.263189Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.264171Z", "completed_at": "2024-10-22T19:20:43.264174Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010972023010253906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "compiled": true, "compiled_code": "\n\n-- Exclude transfers from hospital, SNF, or other healthcare facility\nselect \n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n admit_source_code in ('4', '5', '6')", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_transfer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.265791Z", "completed_at": "2024-10-22T19:20:43.279721Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.312535Z", "completed_at": "2024-10-22T19:20:43.312541Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04870200157165527, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with ungroupable DRG\nselect \n encounter_id\n , data_source\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n ms_drg_code = '999'", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.269462Z", "completed_at": "2024-10-22T19:20:43.304702Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.313090Z", "completed_at": "2024-10-22T19:20:43.313094Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.04840874671936035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups_union", "compiled": true, "compiled_code": "\n\nselect\n 'number of missing encounter groups' as data_quality_check\n , count(*) as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality.encounters_missing_groups", "relation_name": "cms_synthetic.data_quality.encounters_missing_groups_union"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.273722Z", "completed_at": "2024-10-22T19:20:43.313902Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.315087Z", "completed_at": "2024-10-22T19:20:43.315092Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04974508285522461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ed_classification__int_map_primary_dx", "compiled": true, "compiled_code": "/*\nAll condition discharge diagnosis left join with probabilistic\nindicators of ED classification terminology\n*/\n\n\n\n\nwith __dbt__cte__ed_classification__stg_encounter as (\n\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom cms_synthetic.core.encounter\n), condition as (\n select * \n from __dbt__cte__ed_classification__stg_encounter\n where encounter_type = 'emergency department'\n)\n, icd9 as (\n select\n icd9 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from cms_synthetic.ed_classification._value_set_johnston_icd9\n)\n, icd10 as (\n select\n icd10 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from cms_synthetic.ed_classification._value_set_johnston_icd10\n)\n\nselect\n a.*\n \n , icd10.edcnnpa\n \n , icd10.edcnpa\n \n , icd10.epct\n \n , icd10.noner\n \n , icd10.injury\n \n , icd10.psych\n \n , icd10.alcohol\n \n , icd10.drug\n \n , coalesce(icd10.ed_classification_capture, 0) as ed_classification_capture\nfrom condition a\nleft join icd10\n on a.primary_diagnosis_code = icd10.code \n and a.primary_diagnosis_code_type = 'icd-10-cm'\n\nunion all\n\nselect\n a.*\n \n , icd9.edcnnpa\n \n , icd9.edcnpa\n \n , icd9.epct\n \n , icd9.noner\n \n , icd9.injury\n \n , icd9.psych\n \n , icd9.alcohol\n \n , icd9.drug\n \n , coalesce(icd9.ed_classification_capture, 0) ed_classification_capture\nfrom condition a\ninner join icd9\n on a.primary_diagnosis_code = icd9.code \n and a.primary_diagnosis_code_type = 'icd-9-cm'", "relation_name": "cms_synthetic.ed_classification._int_by_provider_parent_organization"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.283598Z", "completed_at": "2024-10-22T19:20:43.314520Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.315721Z", "completed_at": "2024-10-22T19:20:43.315726Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04681897163391113, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up' \n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'outpatient'\n , 'observation'\n , 'diabetes visit'\n , 'ophthalmological services'\n , 'diabetic retinopathy'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_cbe0055__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0055_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.317033Z", "completed_at": "2024-10-22T19:20:43.380815Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.452081Z", "completed_at": "2024-10-22T19:20:43.452089Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.1373600959777832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'audiology visit'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'occupational therapy evaluation'\n , 'office visit'\n , 'physical therapy evaluation'\n , 'online assessments'\n , 'telephone visits' \n , 'care services in long term residential facility'\n , 'discharge services nursing facility'\n , 'encounter inpatient'\n , 'ophthalmological services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, falls_screening_code as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where code = '1100F'\n /* \n Patient screened for future fall risk; documentation of two or more falls in the past year \n or any fall with injury in the past year\n */\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join falls_screening_code\n on procedures.code = falls_screening_code.code\n and procedures.code_type = falls_screening_code.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from medical_claim\n inner join falls_screening_code\n on medical_claim.hcpcs_code = falls_screening_code.code\n and lower(falls_screening_code.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, qualifying_cares_past_year as (\n\n select\n patient_id\n , evidence_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from qualifying_cares\n inner join cms_synthetic.quality_measures._int_cbe0101__performance_period pp\n on evidence_date between pp.performance_period_begin and pp.performance_period_end \n /* \n code 1100F is reported if there are two or more falls in the last year itself,\n so if it's reported in performance year, it indicates the falls in the last year\n */\n\n)\n\n, qualifying_patients as (\n\n select\n qualifying_cares_past_year.patient_id\n , patients_with_age.age\n , max_date as encounter_date\n , qualifying_cares_past_year.performance_period_begin\n , qualifying_cares_past_year.performance_period_end\n , qualifying_cares_past_year.measure_id\n , qualifying_cares_past_year.measure_name\n , qualifying_cares_past_year.measure_version\n , 1 as denominator_flag\n from qualifying_cares_past_year\n left join patients_with_age\n on qualifying_cares_past_year.patient_id = patients_with_age.patient_id\n where age >= 65\n\n)\n\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0101_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.353248Z", "completed_at": "2024-10-22T19:20:43.414979Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.455775Z", "completed_at": "2024-10-22T19:20:43.455785Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.14042901992797852, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'encounter to document medications'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as procedure_encounter_date -- alias only to enable union later\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as claims_encounter_date -- alias only to enable union later\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm130__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as procedure_encounter_date\n , try_cast( null as date ) as claims_encounter_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_cqm130__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , try_cast( null as date ) as procedure_encounter_date\n , coalesce(claim_end_date,claim_start_date) as claims_encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cqm130__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, multiple_encounters_by_patient as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , case when procedure_encounter_date >= claims_encounter_date\n then procedure_encounter_date\n else claims_encounter_date\n end as max_encounter_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id, procedure_encounter_date, claims_encounter_date\n\n)\n\n, max_encounter_dates_by_patient as (\n\n\tselect\n\t\t patient_id\n\t\t, max(max_encounter_date) as max_encounter_date\n\tfrom multiple_encounters_by_patient\n\tgroup by patient_id\n\n)\n\n, latest_patient_encounters as (\n\t\n\tselect\n\t\t max_encounter_dates_by_patient.patient_id\n\t\t, max_encounter_dates_by_patient.max_encounter_date\n\t\t, procedure_encounter_date\n\t\t, claims_encounter_date\n\tfrom max_encounter_dates_by_patient\n\tinner join multiple_encounters_by_patient\n\t\ton max_encounter_dates_by_patient.patient_id = multiple_encounters_by_patient.patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_encounter_date\n ) / 8760.0) as max_age\n from __dbt__cte___stg_patient p\n inner join latest_patient_encounters e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , patients_with_age.procedure_encounter_date\n , patients_with_age.claims_encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_cqm130__performance_period pp\n where max_age >= 18\n \n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(procedure_encounter_date as date) as procedure_encounter_date\n , cast(claims_encounter_date as date) as claims_encounter_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm130_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.398168Z", "completed_at": "2024-10-22T19:20:43.457231Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.460632Z", "completed_at": "2024-10-22T19:20:43.460637Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08473706245422363, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), patients_with_ascvd as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as criteria\n from cms_synthetic.quality_measures._int_cqm438_denominator_criteria1\n\n)\n\n, patients_with_cholesterol as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 2 as criteria\n from cms_synthetic.quality_measures._int_cqm438_denominator_criteria2\n\n)\n\n, patients_with_diabetes as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 3 as criteria\n from cms_synthetic.quality_measures._int_cqm438_denominator_criteria3\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes \n where lower(concept_name) in (\n 'annual wellness visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'outpatient encounters for preventive care'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cqm438__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n performance_period_begin\n ) / 8760.0) as age\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n and p.death_date is null\n cross join cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n, qualifying_patients_from_criteria1 as (\n\n select\n distinct\n patients_with_ascvd.patient_id\n , patients_with_age.age as age\n , patients_with_ascvd.performance_period_begin\n , patients_with_ascvd.performance_period_end\n , patients_with_ascvd.measure_id\n , patients_with_ascvd.measure_name\n , patients_with_ascvd.measure_version\n , 1 as denominator_flag\n from patients_with_ascvd\n left join patients_with_age\n on patients_with_ascvd.patient_id = patients_with_age.patient_id\n where age is not null\n\n)\n\n, qualifying_patients_from_criteria2 as (\n\n select\n distinct\n patients_with_cholesterol.patient_id\n , patients_with_age.age as age\n , patients_with_cholesterol.performance_period_begin\n , patients_with_cholesterol.performance_period_end\n , patients_with_cholesterol.measure_id\n , patients_with_cholesterol.measure_name\n , patients_with_cholesterol.measure_version\n , 1 as denominator_flag\n from patients_with_cholesterol\n left join patients_with_age\n on patients_with_cholesterol.patient_id = patients_with_age.patient_id\n where age between 20 and 75\n\n)\n\n, qualifying_patients_from_criteria3 as (\n\n select\n distinct\n patients_with_diabetes.patient_id\n , patients_with_age.age as age\n , patients_with_diabetes.performance_period_begin\n , patients_with_diabetes.performance_period_end\n , patients_with_diabetes.measure_id\n , patients_with_diabetes.measure_name\n , patients_with_diabetes.measure_version\n , 1 as denominator_flag\n from patients_with_diabetes\n left join patients_with_age\n on patients_with_diabetes.patient_id = patients_with_age.patient_id\n where age between 40 and 75\n\n)\n\n, final_denominator as (\n \n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria1\n\n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria2\n \n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria3\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from final_denominator\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.381030Z", "completed_at": "2024-10-22T19:20:43.457454Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.463206Z", "completed_at": "2024-10-22T19:20:43.463213Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.12230896949768066, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'emergency department evaluation and management visit'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm236__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'outpatient'\n , 'nonacute inpatient'\n , 'encounter inpatient'\n , 'acute_inpatient'\n , 'emergency_department'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_cqm236__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_cqm236__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, hypertension_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'essential hypertension'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, hypertension_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join hypertension_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = hypertension_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = hypertension_codes.code\n\n)\n\n, patients_with_age as (\n \n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n-- Patients 18-85 years of age who had a visit and diagnosis of essential hypertension starting before and continuing into, or starting during the first six months of the measurement period.\n, qualifying_patients as (\n\n select\n distinct\n hypertension_conditions.patient_id\n , hypertension_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from hypertension_conditions\n left join patients_with_age\n on hypertension_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_cqm236__performance_period pp\n where max_age >= 18 and min_age <= 85\n and hypertension_conditions.recorded_date between\n \n\n dateadd(\n month,\n -12,\n performance_period_begin\n )\n\n\n and \n \n\n dateadd(\n month,\n 6,\n performance_period_begin\n )\n\n\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm236_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.472484Z", "completed_at": "2024-10-22T19:20:43.521120Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.585060Z", "completed_at": "2024-10-22T19:20:43.585151Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.12505817413330078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'occupational therapy evaluation'\n , 'office visit'\n , 'outpatient'\n , 'physical therapy evaluation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_cqm48__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join cms_synthetic.quality_measures._int_cqm48__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join cms_synthetic.quality_measures._int_cqm48__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.sex = 'female'\n and p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age\n , patients_with_age.max_date as encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_cqm48__performance_period pp\n where age >= 65\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm48_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.501931Z", "completed_at": "2024-10-22T19:20:43.547024Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.589142Z", "completed_at": "2024-10-22T19:20:43.589149Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.1255629062652588, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR:\nPatients 45-75 years of age with a visit during the measurement period\nDENOMINATOR NOTE: To assess the age for exclusions, the patient\u2019s age on the date of the encounter\nshould be used\n*Signifies that this CPT Category I code is a non-covered service under the Medicare Part B Physician Fee\nSchedule (PFS). These non-covered services should be counted in the denominator population for MIPS\nCQMs.\nDenominator Criteria (Eligible Cases):\nPatients 45 to 75 years of age on date of encounter\nAND\nPatient encounter during the performance period (CPT or HCPCS): 99202, 99203, 99204, 99205,\n99212, 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350, 99386*, 99387*,\n99396*, 99397*, G0438, G0439\n*/\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'online assessments'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where encounter_type in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8766.0) as min_age\n , max_date\n ,floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8766.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null -- ensures deceased patients are not included\n\n)\n\nselect \n patient_id\n , min_age\n , max_age\n , qualifying_types\nfrom patients_with_age\nwhere max_age >= 45 and min_age <= 75", "relation_name": "cms_synthetic.quality_measures._int_nqf0034_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.521360Z", "completed_at": "2024-10-22T19:20:43.589994Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.591190Z", "completed_at": "2024-10-22T19:20:43.591203Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.09419488906860352, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'discharge services nursing facility'\n , 'hemodialysis'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'peritoneal dialysis'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services group counseling'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'preventive care services, initial office visit, 0 to 17'\n , 'preventive care, established office visit, 0 to 17'\n , 'online assessments'\n , 'patient provider interaction'\n , 'telephone visits'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , (datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age_in_decimal_point\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age_in_decimal_point as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_nqf0041__performance_period pp\n where age_in_decimal_point >= 0.5 --filters patients aged 6 months or older\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(age as numeric(28,6)), 1) as age -- ensures age is seen in one decimal point\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0041_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.547272Z", "completed_at": "2024-10-22T19:20:43.590654Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.591817Z", "completed_at": "2024-10-22T19:20:43.591821Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.09022307395935059, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes as value_sets\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n , encounter_type\n from __dbt__cte___stg_encounter as encounter\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , place_of_service_code\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, bone_fracture_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) = 'fracture diagnoses'\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, bone_fracture_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join bone_fracture_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = bone_fracture_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = bone_fracture_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient patient\n inner join encounters_by_patient e\n on patient.patient_id = e.patient_id\n where patient.death_date is null\n\n)\n\n, qualifying_patients_w_fractures as (\n\n select\n distinct\n bone_fracture_conditions.patient_id\n , bone_fracture_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from bone_fracture_conditions\n left join patients_with_age\n on bone_fracture_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_nqf0053__performance_period pp\n where max_age >= 50 and min_age <= 85\n and bone_fracture_conditions.recorded_date between\n \n\n dateadd(\n month,\n -6,\n performance_period_begin\n )\n\n\n and\n pp.lookback_period_june\n and lower(patients_with_age.sex) = 'female'\n\n)\n\n, fracture_procedures as (\n\n select\n procedures.*\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n inner join cms_synthetic.quality_measures._int_nqf0053__performance_period as pp\n on procedures.procedure_date \n between pp.performance_period_begin and pp.performance_period_end\n where lower(visit_codes.concept_name) = 'fracture procedures'\n\n)\n\n, qualifying_patients_w_encounter as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join visits_encounters\n on qualifying_patients_w_fractures.patient_id = visits_encounters.patient_id\n where \n lower(visits_encounters.encounter_type) in (\n 'acute inpatient'\n , 'annual wellness visit'\n , 'emergency department visit'\n , 'emergency department'\n , 'home healthcare services'\n , 'office visit'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'emergency department evaluation and management visit'\n , 'outpatient'\n )\n)\n\n, qualifying_patients_w_procedure as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join fracture_procedures\n on qualifying_patients_w_fractures.patient_id = fracture_procedures.patient_id\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n qualifying_patients_w_encounter.*\n from qualifying_patients_w_encounter\n left join qualifying_patients_w_procedure\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n left join claims_encounters\n on qualifying_patients_w_encounter.patient_id = claims_encounters.patient_id\n where (cast(claims_encounters.place_of_service_code as TEXT) not in ('21')\n or claims_encounters.patient_id is null)\n\n union all\n\n select\n distinct\n qualifying_patients_w_procedure.*\n from qualifying_patients_w_procedure\n left join qualifying_patients_w_encounter\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n where qualifying_patients_w_encounter.patient_id is null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , recorded_date \n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0053_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.593259Z", "completed_at": "2024-10-22T19:20:43.649956Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.707444Z", "completed_at": "2024-10-22T19:20:43.707451Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.11660981178283691, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'nutrition services'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0059__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join cms_synthetic.quality_measures._int_nqf0059__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0059__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n)\n\n, encounters_by_patient as (\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n , 'hba1c laboratory test'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join cms_synthetic.quality_measures._int_nqf0059__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0059_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.621331Z", "completed_at": "2024-10-22T19:20:43.674896Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.707911Z", "completed_at": "2024-10-22T19:20:43.707914Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.11646819114685059, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n\n)\n\n, valid_concepts as (\n\n select\n concept_name\n from cms_synthetic.quality_measures._value_set_concepts\n where concept_name in (\n 'annual wellness visit'\n , 'care services in long term residential facility'\n , 'encounter to document medications'\n , 'home healthcare services'\n , 'office visit'\n , 'outpatient'\n , 'psychoanalysis'\n )\n\n)\n\n, valid_visit_codes as (\n\n select\n visit_codes.concept_name\n , visit_codes.code\n , visit_codes.code_system\n from visit_codes\n inner join valid_concepts\n on visit_codes.concept_name = valid_concepts.concept_name\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , length_of_stay\n , encounter.encounter_end_date\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0097__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n -- all encounter types considered; inpatient encounters are filtered by length of stay being more than 0 days\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n\n inner join cms_synthetic.quality_measures._int_nqf0097__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join valid_visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = valid_visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join cms_synthetic.quality_measures._int_nqf0097__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join valid_visit_codes\n on medical_claim.hcpcs_code= valid_visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc\n , cast(null as TEXT) as proc_enc\n , cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , 'p' as proc_enc\n , cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , cast(null as TEXT) as proc_enc\n , 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , visits_encounters.encounter_end_date as discharge_date\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_nqf0097__performance_period pp\n inner join visits_encounters\n on patients_with_age.patient_id = visits_encounters.patient_id\n where max_age >= 18\n and visits_encounters.length_of_stay > 0 --ensures inpatient\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(discharge_date as date) as discharge_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0097_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.650245Z", "completed_at": "2024-10-22T19:20:43.708910Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.709815Z", "completed_at": "2024-10-22T19:20:43.709821Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08888101577758789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'home healthcare services'\n , 'office visit'\n , 'encounter to document medications'\n , 'psychological and/or neuropsychological test administration'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date, encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date, encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join cms_synthetic.quality_measures._int_nqf0420__performance_period as pp\n on coalesce(encounter.encounter_end_date, encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date, encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where coalesce(modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_5, '') not in ('GQ', 'GT', '95')\n\n)\n\n, claims as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(hcpcs_modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_5, '') not in ('GQ', 'GT', '95')\n and coalesce(place_of_service_code, '') not in ('02')\n \n)\n\n, procedure_encounters as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as min_date\n , procedures.procedure_date as max_date\n from procedures\n inner join cms_synthetic.quality_measures._int_nqf0420__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n claims.patient_id\n , claims.min_date\n , claims.max_date\n from claims\n inner join cms_synthetic.quality_measures._int_nqf0420__performance_period as pp \n on claims.max_date >= pp.performance_period_begin\n and claims.min_date <= pp.performance_period_end\n inner join visit_codes\n on claims.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select \n patient_id\n , max(max_date) max_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patient_id\n , max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join cms_synthetic.quality_measures._int_nqf0420__performance_period pp\n where max_age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0420_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.681405Z", "completed_at": "2024-10-22T19:20:43.709349Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.710456Z", "completed_at": "2024-10-22T19:20:43.710459Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.07021284103393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n , performance_period_lookback\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n, patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n from __dbt__cte___stg_encounter\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name in (\n 'Office Visit'\n , 'Home Healthcare Services'\n , 'Preventive Care Services Established Office Visit, 18 and Up'\n , 'Preventive Care Services Initial Office Visit, 18 and Up'\n , 'Annual Wellness Visit'\n , 'Telephone Visits'\n , 'Online Assessments'\n )\n\n)\n\n, patient_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , patient.birth_date\n , patient.death_date\n , performance_period.measure_id\n , performance_period.measure_name\n , performance_period.measure_version\n , performance_period.performance_period_begin\n , performance_period.performance_period_end\n , performance_period.performance_period_lookback\n , floor(datediff(\n hour,\n patient.birth_date,\n performance_period.performance_period_begin\n ) / 8760.0) as age -- 365*24 hours in a year\n from patient\n cross join performance_period\n\n)\n\n/*\n Filter patient to living women 51 - 74 years of age\n at the beginning of the measurement period\n*/\n, patient_filtered as (\n\n select\n patient_id\n , age\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , 1 as denominator_flag\n from patient_with_age\n where lower(sex) = 'female'\n and age between 51 and 74\n and death_date is null\n\n)\n\n/*\n Filter to qualifying visit types by claim procedures\n*/\n, visit_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n from medical_claim\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n where visit_codes.code_system = 'hcpcs'\n\n)\n\n/*\n Filter encounters to qualifying visit type\n*/\n, visit_encounters as (\n\n select\n patient_id\n , encounter_start_date\n from encounters\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n/*\n Filter to qualifying visit types by procedure\n*/\n, visit_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n/*\n Filter to final eligible population/denominator before exclusions\n with a qualifying visit during the measurement period\n*/\n, eligible_population as (\n\n select\n patient_filtered.patient_id\n , patient_filtered.age\n , patient_filtered.measure_id\n , patient_filtered.measure_name\n , patient_filtered.measure_version\n , patient_filtered.performance_period_begin\n , patient_filtered.performance_period_end\n , performance_period_lookback\n , patient_filtered.denominator_flag\n from patient_filtered\n left join visit_claims\n on patient_filtered.patient_id = visit_claims.patient_id\n left join visit_procedures\n on patient_filtered.patient_id = visit_procedures.patient_id\n left join visit_encounters\n on patient_filtered.patient_id = visit_encounters.patient_id\n where (\n visit_claims.claim_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_claims.claim_end_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_procedures.procedure_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_encounters.encounter_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n )\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_lookback as date) as performance_period_lookback\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from eligible_population\n\n)\n\n select distinct\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf2372_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.711936Z", "completed_at": "2024-10-22T19:20:43.721856Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.729494Z", "completed_at": "2024-10-22T19:20:43.729500Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020000934600830078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n) select patient_id\nfrom __dbt__cte___stg_encounter\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.715000Z", "completed_at": "2024-10-22T19:20:43.727874Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.731990Z", "completed_at": "2024-10-22T19:20:43.731995Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02184605598449707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__encounter as (\n\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\nwhere encounter_type = 'acute inpatient'\n) -- Staging model for the input layer:\n-- stg_encounter input layer model.\n-- This contains one row for every unique encounter in the dataset.\n\nselect\n cast(encounter_id as TEXT) as encounter_id,\n cast(patient_id as TEXT) as patient_id,\n cast(encounter_start_date as date) as admit_date,\n cast(encounter_end_date as date) as discharge_date,\n cast(discharge_disposition_code as TEXT) as discharge_disposition_code,\n cast(facility_id as TEXT) as facility_id,\n cast(ms_drg_code as TEXT) as ms_drg_code,\n cast(paid_amount as numeric(28,6)) as paid_amount,\n cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom __dbt__cte__readmissions__stg_core__encounter", "relation_name": "cms_synthetic.readmissions._int_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.722312Z", "completed_at": "2024-10-22T19:20:43.732990Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.734046Z", "completed_at": "2024-10-22T19:20:43.734049Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019340991973876953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "compiled": true, "compiled_code": "\n\n-- Missing Age Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing age' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusions_missing_age as age\n on denom.patient_id = age.patient_id\n and denom.data_source = age.data_source\n\nunion all\n\n-- Missing Gender Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing gender' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_gender as gender\n on denom.patient_id = gender.patient_id\n and denom.data_source = gender.data_source\n\nunion all\n\n-- Missing Dates Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing dates' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_dates as dates\n on denom.encounter_id = dates.encounter_id\n and denom.data_source = dates.data_source\n\nunion all\n\n-- Missing Primary Diagnosis Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing primary diagnosis' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx as dx\n on denom.encounter_id = dx.encounter_id\n and denom.data_source = dx.data_source\n\nunion all\n\n-- Transfer Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'transfer' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_transfer as tx\n on denom.encounter_id = tx.encounter_id\n and denom.data_source = tx.data_source\n\nunion all\n\n-- Ungroupable DRG Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'ungroupable DRG' as exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg as drg\n on denom.encounter_id = drg.encounter_id\n and denom.data_source = drg.data_source", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.729911Z", "completed_at": "2024-10-22T19:20:43.733799Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.734784Z", "completed_at": "2024-10-22T19:20:43.734787Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013595104217529297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "compiled": true, "compiled_code": "/*\nFilter conditions to those that were classified and pick the classification\nwith the greatest probability (that's the greatest logic). This logic removes\nany rows that were not classified.\n*/\n\n\nselect\n a.*\n , case greatest(edcnnpa, edcnpa, epct, noner, injury, psych, alcohol, drug)\n when edcnnpa then 'edcnnpa'\n when edcnpa then 'edcnpa'\n when epct then 'epct'\n when noner then 'noner'\n when injury then 'injury'\n when psych then 'psych'\n when alcohol then 'alcohol'\n when drug then 'drug'\n else 'unclassified'\n end as classification\nfrom cms_synthetic.ed_classification._int_by_provider_parent_organization a\nwhere ed_classification_capture = 1", "relation_name": "cms_synthetic.ed_classification._int_filter_encounter_with_classification"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.735598Z", "completed_at": "2024-10-22T19:20:43.757087Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.757946Z", "completed_at": "2024-10-22T19:20:43.757952Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02470993995666504, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join cms_synthetic.quality_measures._int_cbe0055_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0055_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.740982Z", "completed_at": "2024-10-22T19:20:43.757507Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.775547Z", "completed_at": "2024-10-22T19:20:43.775553Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.04202771186828613, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cbe0055_denominator\n\n)\n\n, retina_test_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetic retinal eye exam met'\n , 'retinal or dilated eye exam'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_patients as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cms_synthetic.quality_measures._int_cbe0055__performance_period pp\n on procedure_date between\n performance_period_begin and performance_period_end\n inner join retina_test_code\n on procedures.code = retina_test_code.code\n and procedures.code_type = retina_test_code.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast('1' as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0055_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.758299Z", "completed_at": "2024-10-22T19:20:43.794062Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.795107Z", "completed_at": "2024-10-22T19:20:43.795112Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03890585899353027, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_cbe0101_denominator\n\n)\n\n, exclusion_code as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where code = '0518F'\n -- further 1P modifier are only excluded\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cbe0101__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cbe0101__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_procedures as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , 'Limited Mobility' as exclusion_reason\n from procedures\n inner join exclusion_code\n on procedures.code = exclusion_code.code\n and procedures.code_type = exclusion_code.code_system\n where '1P' in (modifier_1, modifier_2, modifier_3, modifier_4, modifier_5)\n \n)\n\n, exclusion_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , 'Limited mobility' as exclusion_reason\n from __dbt__cte___stg_medical_claim medical_claim\n inner join exclusion_code\n on medical_claim.hcpcs_code = exclusion_code.code\n and lower(exclusion_code.code_system) = 'hcpcs'\n where '1P' in (hcpcs_modifier_1, hcpcs_modifier_2, hcpcs_modifier_3, hcpcs_modifier_4, hcpcs_modifier_5)\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_procedures\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_claims\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0101_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.776020Z", "completed_at": "2024-10-22T19:20:43.794411Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.795436Z", "completed_at": "2024-10-22T19:20:43.795438Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03879284858703613, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cbe0101_denominator\n\n)\n\n, fallcare_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where code = '0518F' -- Falls plan of care documented\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join fallcare_codes\n on procedures.code = fallcare_codes.code\n and procedures.code_type = fallcare_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join fallcare_codes\n on medical_claim.hcpcs_code = fallcare_codes.code\n and lower(fallcare_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of falls screening visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0101_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.796834Z", "completed_at": "2024-10-22T19:20:43.843452Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.960013Z", "completed_at": "2024-10-22T19:20:43.960020Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.16553330421447754, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medical reason'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as (\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join cms_synthetic.quality_measures._int_cqm130_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm130_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.818359Z", "completed_at": "2024-10-22T19:20:43.848802Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.960497Z", "completed_at": "2024-10-22T19:20:43.960501Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.16569900512695312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cqm130_denominator\n\n)\n\n, medication_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'eligible clinician attests to documenting current medications'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, documenting_meds_procedures as (\n\n select\n patient_id\n , procedure_date\n from procedures\n inner join medication_code\n on procedures.code = medication_code.code\n and procedures.code_type = medication_code.code_system\n\n)\n\n, documenting_meds_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date,claim_start_date) as encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join medication_code\n on medical_claim.hcpcs_code = medication_code.code\n and medication_code.code_system = 'hcpcs'\n\n)\n\n, qualifying_procedure as (\n\n select \n documenting_meds_procedures.patient_id\n , documenting_meds_procedures.procedure_date as encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_procedures\n inner join denominator\n on documenting_meds_procedures.patient_id = denominator.patient_id\n and documenting_meds_procedures.procedure_date = denominator.procedure_encounter_date\n\n)\n\n, qualifying_claims as (\n \n select \n documenting_meds_claims.patient_id\n , documenting_meds_claims.encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_claims\n inner join denominator\n on documenting_meds_claims.patient_id = denominator.patient_id\n and documenting_meds_claims.encounter_date = denominator.claims_encounter_date\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_procedure\n\n union all\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(encounter_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_cares\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm130_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.838339Z", "completed_at": "2024-10-22T19:20:43.961608Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.962679Z", "completed_at": "2024-10-22T19:20:43.962683Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.1331789493560791, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'rhabdomyolysis'\n , 'breastfeeding'\n , 'liver disease'\n , 'hepatitis a'\n , 'hepatitis b'\n , 'documentation of medical reason for no statin therapy'\n , 'statin allergen'\n , 'end stage renal disease'\n , 'statin associated muscle symptoms'\n , 'medical reason'\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n where observation_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medications as (\n \n select\n patient_id\n , coalesce(prescribing_date, dispensing_date) as exclusion_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim \n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.exclusion_date\n , exclusion_codes.concept_name as concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claims_exclusions as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , exclusion_codes.concept_name as concept_name\n from pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and lower(exclusion_codes.code_system) = 'ndc'\n\n)\n\n, patients_with_exclusions as(\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select \n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from medication_exclusions\n\n union all\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from pharmacy_claims_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join cms_synthetic.quality_measures._int_cqm438_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.931102Z", "completed_at": "2024-10-22T19:20:43.961839Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:43.964384Z", "completed_at": "2024-10-22T19:20:43.964388Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.12704205513000488, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cqm438_denominator\n\n)\n\n, statin_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'high intensity statin therapy'\n , 'low intensity statin therapy'\n , 'moderate intensity statin therapy'\n , 'statin therapy'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, procedure_statin_related as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join statin_codes\n on procedures.code = statin_codes.code\n and procedures.code_type = statin_codes.code_system\n\n)\n\n, pharmacy_claims_statin_related as (\n\n select\n patient_id\n , dispensing_date as evidence_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join statin_codes\n on pharmacy_claims.ndc_code = statin_codes.code\n and lower(statin_codes.code_system) = 'ndc'\n\n)\n\n, medication_statin_related as (\n\n select\n patient_id\n , coalesce(dispensing_date, prescribing_date) as evidence_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication as medications\n inner join statin_codes\n on medications.source_code = statin_codes.code\n and medications.source_code_type = statin_codes.code_system\n \n)\n\n, qualifying_patients as (\n\n select\n procedure_statin_related.patient_id\n , procedure_statin_related.evidence_date\n from procedure_statin_related\n\n union all\n\n select\n pharmacy_claims_statin_related.patient_id\n , pharmacy_claims_statin_related.evidence_date\n from pharmacy_claims_statin_related\n\n union all\n\n select\n medication_statin_related.patient_id\n , medication_statin_related.evidence_date\n from medication_statin_related\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n and evidence_date between \n denominator.performance_period_begin and \n denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.966775Z", "completed_at": "2024-10-22T19:20:44.043212Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.047426Z", "completed_at": "2024-10-22T19:20:44.047433Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.08511829376220703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dialysis services'\n , 'end stage renal disease'\n , 'esrd monthly outpatient services'\n , 'kidney transplant'\n , 'kidney transplant recipient'\n , 'pregnancy'\n )\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, exclusions_unioned as (\n\n select\n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, excluded_patients as (\n\n select\n exclusions_unioned.patient_id\n , exclusions_unioned.exclusion_date\n , exclusions_unioned.exclusion_reason\n , case\n when exclusion_reason = 'pregnancy' then 1\n else 0\n end as is_pregnant\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.age\n from exclusions_unioned\n inner join denominator\n on exclusions_unioned.patient_id = denominator.patient_id\n\n)\n\n, exclusions_filtered as (\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 1\n and exclusion_date between performance_period_begin and performance_period_end\n \n union all\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 0\n and exclusion_date between performance_period_begin and performance_period_end\n or (exclusion_date between \n\n dateadd(\n year,\n -1,\n performance_period_begin\n )\n\n\n and performance_period_end)\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , age\n , 'measure specific exclusion for observation procedure' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n exclusions_filtered", "relation_name": "cms_synthetic.quality_measures._int_cqm236_exclude_procedures_observations"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:43.986777Z", "completed_at": "2024-10-22T19:20:44.053761Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.067444Z", "completed_at": "2024-10-22T19:20:44.067451Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.10271906852722168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), controlled_bp_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'most recent systolic blood pressure < 140 mmhg' --G8752 hcpcs\n , 'most recent diastolic blood pressure < 90 mmhg' --G8754 hcpcs\n )\n \n)\n\n, denominator as (\n\n select\n patient_id\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n , encounter_end_date\n from __dbt__cte___stg_encounter\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , normalized_code\n , normalized_description\n , result\n from __dbt__cte___stg_observation\n where lower(normalized_description) in \n (\n 'systolic blood pressure'\n , 'diastolic blood pressure'\n )\n and normalized_code not in (\n '99473' -- Self-measured blood pressure using a device validated for clinical accuracy; patient education/training and device calibration\n , '99474' -- Separate self-measurements of two readings one minute apart, twice daily over a 30-day period (minimum of 12 readings), collection of data reported by the patient and/or caregiver to the physician or other qualified health care professional, with report of average systolic and diastolic pressures and subsequent communication of a treatment plan to the patient\n )\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , result\n , normalized_code\n from __dbt__cte___stg_lab_result\n where normalized_code in \n ('8480-6' --systolic\n ,'8462-4') --diastolic\n and\n normalized_code_type = 'loinc'\n\n)\n\n, all_procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, all_medical_claims as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, controlled_bp_procedures as (\n\n select\n all_procedures.patient_id\n , all_procedures.procedure_date as evidence_date\n , controlled_bp_codes.code\n from all_procedures\n inner join controlled_bp_codes\n on all_procedures.code_type = controlled_bp_codes.code_system\n and all_procedures.code = controlled_bp_codes.code\n\n)\n\n, controlled_bp_medical_claims as (\n\n select\n all_medical_claims.patient_id\n , coalesce(all_medical_claims.claim_end_date, all_medical_claims.claim_start_date) as evidence_date\n , controlled_bp_codes.code\n from all_medical_claims\n inner join controlled_bp_codes\n on all_medical_claims.hcpcs_code = controlled_bp_codes.code\n and controlled_bp_codes.code_system = 'hcpcs'\n\n)\n\n, controlled_bp_patients_proc_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_procedures\n\n union all\n \n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_medical_claims\n\n)\n\n, controlled_bp_within_range_proc_claims as (\n\n select\n controlled_bp_patients_proc_claims.patient_id\n , controlled_bp_patients_proc_claims.evidence_date\n , controlled_bp_patients_proc_claims.code\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from controlled_bp_patients_proc_claims\n inner join denominator\n on controlled_bp_patients_proc_claims.patient_id = denominator.patient_id\n and controlled_bp_patients_proc_claims.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, procedure_claims_w_encounters as (\n\n select\n controlled_bp_within_range_proc_claims.patient_id\n , controlled_bp_within_range_proc_claims.evidence_date\n , controlled_bp_within_range_proc_claims.code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_procedure_claims\n , controlled_bp_within_range_proc_claims.measure_id\n , controlled_bp_within_range_proc_claims.measure_name\n , controlled_bp_within_range_proc_claims.measure_version\n , controlled_bp_within_range_proc_claims.performance_period_begin\n , controlled_bp_within_range_proc_claims.performance_period_end\n from controlled_bp_within_range_proc_claims\n left join encounters\n on controlled_bp_within_range_proc_claims.patient_id = encounters.patient_id\n and controlled_bp_within_range_proc_claims.evidence_date between \n encounters.encounter_start_date and encounters.encounter_end_date \n \n)\n\n, valid_procedures_and_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from procedure_claims_w_encounters\n where is_valid_procedure_claims = 1\n\n)\n\n, systolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from valid_procedures_and_claims\n where code = 'G8752' --systolic\n\n)\n\n, diastolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n from valid_procedures_and_claims\n where code = 'G8754' --diastolic\n\n)\n\n, qualifying_controlled_bp_proc_claims as (\n\n select\n systolic_bp_from_procedure_claims.patient_id\n , systolic_bp_from_procedure_claims.evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp_from_procedure_claims\n inner join diastolic_bp_from_procedure_claims\n on systolic_bp_from_procedure_claims.patient_id = diastolic_bp_from_procedure_claims.patient_id\n and systolic_bp_from_procedure_claims.evidence_date = diastolic_bp_from_procedure_claims.evidence_date\n\n)\n\n, observations_within_range as (\n\n select\n observations.patient_id\n , observations.observation_date\n , observations.normalized_code\n , observations.normalized_description\n , observations.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from observations\n inner join denominator\n on observations.patient_id = denominator.patient_id\n and observations.observation_date between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, labs_within_range as (\n\n select\n labs.patient_id\n , labs.normalized_code\n , coalesce(labs.result_date, labs.collection_date) as observation_date\n , labs.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from labs\n inner join denominator\n on labs.patient_id = denominator.patient_id\n and coalesce(labs.result_date,labs.collection_date) between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, observations_with_encounters as (\n\n select\n observations_within_range.patient_id\n , observations_within_range.observation_date\n , observations_within_range.normalized_description\n , observations_within_range.result\n , observations_within_range.normalized_code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_observation\n , observations_within_range.measure_id\n , observations_within_range.measure_name\n , observations_within_range.measure_version\n , observations_within_range.performance_period_begin\n , observations_within_range.performance_period_end\n from observations_within_range\n left join encounters\n on observations_within_range.patient_id = encounters.patient_id\n and observations_within_range.observation_date between \n encounters.encounter_start_date and encounters.encounter_end_date\n\n)\n\n, labs_with_encounters as (\n\n select\n labs_within_range.patient_id\n , labs_within_range.normalized_code\n , labs_within_range.observation_date\n , labs_within_range.result\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_labs\n , labs_within_range.measure_id\n , labs_within_range.measure_name\n , labs_within_range.measure_version\n , labs_within_range.performance_period_begin\n , labs_within_range.performance_period_end\n from labs_within_range\n left join encounters\n on labs_within_range.patient_id = encounters.patient_id\n and labs_within_range.observation_date between\n encounters.encounter_start_date and encounters.encounter_end_date\n \n)\n\n, obs_and_labs as (\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from observations_with_encounters\n where is_valid_encounter_observation = 1\n\n union all\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , cast(null as TEXT) as normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from labs_with_encounters labs\n where is_valid_encounter_labs = 1\n\n)\n\n, systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'systolic blood pressure'\n or\n normalized_code = '8480-6'\n\n)\n\n, diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'diastolic blood pressure'\n or\n normalized_code = '8462-4'\n\n)\n\n, least_recent_systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as systolic_bp\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp\n where rn = 1\n\n)\n\n, least_recent_diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as diastolic_bp\n from diastolic_bp\n where rn = 1\n\n)\n\n, patients_with_bp_readings as (\n\n select\n least_recent_systolic_bp.patient_id\n , least_recent_systolic_bp.systolic_bp\n , least_recent_diastolic_bp.diastolic_bp\n , least_recent_systolic_bp.observation_date\n , least_recent_systolic_bp.measure_id\n , least_recent_systolic_bp.measure_name\n , least_recent_systolic_bp.measure_version\n , least_recent_systolic_bp.performance_period_begin\n , least_recent_systolic_bp.performance_period_end\n from least_recent_systolic_bp\n inner join least_recent_diastolic_bp\n on least_recent_systolic_bp.patient_id = least_recent_diastolic_bp.patient_id\n and least_recent_systolic_bp.observation_date = least_recent_diastolic_bp.observation_date\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , case\n when systolic_bp < 140.0 and diastolic_bp < 90.0\n then 1\n else 0\n end as numerator_flag\n from patients_with_bp_readings\n\n union all\n\n select\n patient_id\n , evidence_date as observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as numerator_flag\n from qualifying_controlled_bp_proc_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(observation_date as date) as observation_date\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , observation_date\n , numerator_flag\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm236_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.043679Z", "completed_at": "2024-10-22T19:20:44.067251Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.068244Z", "completed_at": "2024-10-22T19:20:44.068248Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08224892616271973, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm48__performance_period\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm48__performance_period\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select\n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n from valid_hospice_exclusions\n inner join cms_synthetic.quality_measures._int_cqm48_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm48_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.048019Z", "completed_at": "2024-10-22T19:20:44.068625Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.069772Z", "completed_at": "2024-10-22T19:20:44.069776Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.08338093757629395, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_cqm48_denominator\n\n)\n\n, involuntary_urination_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'presence or absence of urinary incontinence assessed'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join involuntary_urination_codes\n on procedures.code = involuntary_urination_codes.code\n and procedures.code_type = involuntary_urination_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join involuntary_urination_codes\n on medical_claim.hcpcs_code = involuntary_urination_codes.code\n and lower(involuntary_urination_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm48_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.070376Z", "completed_at": "2024-10-22T19:20:44.083992Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.129007Z", "completed_at": "2024-10-22T19:20:44.129015Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.06120014190673828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , max_age as age\n from cms_synthetic.quality_measures._int_nqf0034_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n and lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, measure_specific_colectomy_colorectal_cancer_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_nqf0034_exclude_colectomy_cancer\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from measure_specific_colectomy_colorectal_cancer_exclusion\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type not in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n and age >= 66\n\n union all\n\n select * from combined_exclusions --age irrelvant exclusions\n where exclusion_type in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0034_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.108415Z", "completed_at": "2024-10-22T19:20:44.146434Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.147273Z", "completed_at": "2024-10-22T19:20:44.147278Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07099699974060059, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0041_denominator\n\n)\n\n, exclusion_codes as (\n\n select \n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza immunization not ordered or administered reason documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from hospice_palliative\n where exclusion_reason in (\n 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select\n valid_exclusions.patient_id\n , valid_exclusions.exclusion_date\n , valid_exclusions.exclusion_reason\n from valid_exclusions\n inner join denominator\n on valid_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0041_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.077691Z", "completed_at": "2024-10-22T19:20:44.146658Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.147806Z", "completed_at": "2024-10-22T19:20:44.147810Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.07772421836853027, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "compiled": true, "compiled_code": "\n\n\n/*\nPatients with one or more screenings for colorectal cancer. Appropriate screenings are defined by any one of the\nfollowing criteria:\n- Fecal occult blood test (FOBT) during the measurement period\n- Flexible sigmoidoscopy during the measurement period or the four years prior to the measurement period\n- Colonoscopy during the measurement period or the nine years prior to the measurement period\n- Computed tomography (CT) colonography during the measurement period or the four years prior to the\nmeasurement period.\n- Fecal immunochemical DNA test (FIT-DNA) during the measurement period or the two years prior to the\nmeasurement period.\n\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0034_denominator\n\n)\n\n, screening_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'fecal occult blood test (fobt)' -- mp\n , 'flexible sigmoidoscopy' --mp+4\n , 'colonoscopy' -- mp+9\n , 'ct colonography' -- mp+4\n , 'sdna fit test' -- mp+2\n )\n\n)\n\n, screening_periods as (\n\n select \n code\n , code_system\n , concept_name\n , case concept_name\n when 'Fecal Occult Blood Test (FOBT)' then pp.performance_period_begin --mp\n when 'Flexible Sigmoidoscopy' then pp.performance_period_begin_4yp --mp+4\n when 'Colonoscopy' then pp.performance_period_begin_9yp -- mp+9\n when 'CT Colonography' then pp.performance_period_begin_4yp -- mp+4\n when 'sDNA FIT Test' then pp.performance_period_begin_2yp -- mp+2\n else pp.performance_period_begin \n end as effective_performance_period_begin\n , performance_period_end\n from screening_codes\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n \n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , coalesce( medical_claim.claim_start_date, medical_claim.claim_end_date) as claim_date\n , screening_codes.concept_name\n from medical_claim\n inner join screening_periods\n on medical_claim.claim_start_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n or medical_claim.claim_end_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on medical_claim.hcpcs_code = screening_codes.code\n where screening_codes.code_system in ('hcpcs', 'cpt' )\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n , screening_codes.concept_name\n from observations\n inner join screening_periods\n on observations.observation_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on observations.code = screening_codes.code\n and observations.code_type = screening_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , screening_codes.concept_name\n from procedures\n inner join screening_periods\n on procedures.procedure_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on procedures.code = screening_codes.code\n and procedures.code_type = screening_codes.code_system\n\n)\n\n, normalized_code_labs as (\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.normalized_code = screening_codes.code\n and labs.normalized_code_type = screening_codes.code_system\n)\n\n, source_code_labs as (\n\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.source_code = screening_codes.code\n and labs.source_code_type = screening_codes.code_system\n\n)\n\n, qualifying_labs_union as (\n\n select \n patient_id\n , lab_date\n , concept_name\n from normalized_code_labs\n\n union all\n\n select \n patient_id\n , lab_date\n , concept_name\n from source_code_labs\n\n)\n\n, qualifying_labs as (\n\n select distinct\n patient_id\n , lab_date\n , concept_name\n from qualifying_labs_union\n\n)\n\n, qualifying_events as (\n\n select\n patient_id\n , claim_date as evidence_date\n , concept_name as evidence\n from qualifying_claims\n\n union all\n\n select\n patient_id\n , observation_date as evidence_date\n , concept_name as evidence\n from qualifying_observations\n\n union all\n\n select\n patient_id\n , procedure_date as evidence_date\n , concept_name as evidence\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , lab_date as evidence_date\n , concept_name as evidence\n from qualifying_labs\n\n)\n\nselect\n cast( qualifying_events.patient_id as TEXT) as patient_id\n , cast( evidence_date as date) as evidence_date\n , cast( evidence as TEXT) as evidence\nfrom qualifying_events\ninner join denominator\n on qualifying_events.patient_id = denominator.patient_id", "relation_name": "cms_synthetic.quality_measures._int_nqf0034_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.129563Z", "completed_at": "2024-10-22T19:20:44.147612Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.148648Z", "completed_at": "2024-10-22T19:20:44.148652Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0712590217590332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0041_denominator\n\n)\n\n, influenza_vaccination_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza vaccination'\n , 'influenza vaccine'\n , 'influenza virus laiv immunization'\n , 'influenza virus laiv procedure'\n )\n\n)\n\n, procedure_vaccination as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procedures\n inner join influenza_vaccination_code\n on coalesce(procedures.normalized_code, procedures.source_code) = influenza_vaccination_code.code\n and coalesce(procedures.normalized_code_type, procedures.source_code_type) = influenza_vaccination_code.code_system\n\n)\n\n, claims_vaccination as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join influenza_vaccination_code\n on medical_claim.hcpcs_code = influenza_vaccination_code.code\n\n)\n\n, qualifying_procedures as (\n\n select\n procedure_vaccination.patient_id\n , procedure_vaccination.procedure_date as evidence_date\n from procedure_vaccination\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period pp\n on procedure_date between \n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualifying_claims as (\n\n select \n claims_vaccination.patient_id\n , claims_vaccination.max_date as evidence_date\n from claims_vaccination\n inner join cms_synthetic.quality_measures._int_nqf0041__performance_period pp\n on max_date between\n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualified_patients as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualified_patients.patient_id\n , qualified_patients.evidence_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , 1 as numerator_flag\n from qualified_patients\n inner join denominator\n on qualified_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0041_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.149281Z", "completed_at": "2024-10-22T19:20:44.173605Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.208138Z", "completed_at": "2024-10-22T19:20:44.208144Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.06125187873840332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medications as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, bone_density_test_codes as (\n\n select\n concept_name\n , code\n , code_system\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests hcpcs'\n , 'bone mineral density tests icd10pcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n )\n\n)\n\n, osteoporosis_medication_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, bone_density_test_procedures as (\n\n select\n procedures.*\n , bone_density_test_codes.concept_name\n from procedures\n inner join bone_density_test_codes\n on procedures.code = bone_density_test_codes.code\n and procedures.code_type = bone_density_test_codes.code_system\n\n)\n\n, osteoporosis_pharmacy_claims as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , pharmacy_claims.ndc_code\n , osteoporosis_medication_codes.concept_name\n from pharmacy_claims\n inner join osteoporosis_medication_codes\n on pharmacy_claims.ndc_code = osteoporosis_medication_codes.code\n and lower(osteoporosis_medication_codes.code_system) = 'ndc'\n \n)\n\n, osteoporosis_medications as (\n\n select\n medications.patient_id\n , medications.encounter_id\n , medications.prescribing_date\n , medications.dispensing_date\n , medications.source_code\n , medications.source_code_type\n , osteoporosis_medication_codes.concept_name\n from medications\n inner join osteoporosis_medication_codes\n on medications.source_code = osteoporosis_medication_codes.code\n and medications.source_code_type = osteoporosis_medication_codes.code_system\n\n)\n\n, valid_osteoporosis_medications_procedures as (\n\n select\n denominator.patient_id\n , osteoporosis_pharmacy_claims.concept_name as exclusion_reason\n , osteoporosis_pharmacy_claims.dispensing_date as exclusion_date\n from denominator\n inner join osteoporosis_pharmacy_claims\n on denominator.patient_id = osteoporosis_pharmacy_claims.patient_id\n where osteoporosis_pharmacy_claims.dispensing_date\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n \n union all\n\n select\n denominator.patient_id\n , osteoporosis_medications.concept_name as exclusion_reason\n , coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date) as exclusion_date\n from denominator\n inner join osteoporosis_medications\n on denominator.patient_id = osteoporosis_medications.patient_id\n and coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date)\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_tests_performed as (\n\n select\n denominator.patient_id\n , bone_density_test_procedures.concept_name as exclusion_reason\n , procedure_date as exclusion_date\n from denominator\n inner join bone_density_test_procedures\n on denominator.patient_id = bone_density_test_procedures.patient_id\n where bone_density_test_procedures.procedure_date\n between \n \n\n dateadd(\n year,\n -2,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_exclusions as (\n\n select * from valid_tests_performed\n\n union all\n\n select * from valid_osteoporosis_medications_procedures\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for procedure medication' as exclusion_type\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n valid_exclusions", "relation_name": "cms_synthetic.quality_measures._int_nqf0053_exclude_procedures_medications"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.173835Z", "completed_at": "2024-10-22T19:20:44.225356Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.228825Z", "completed_at": "2024-10-22T19:20:44.228830Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.05712890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medication\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , recorded_date\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n \n)\n\n, osteo_procedure_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests icd10pcs'\n , 'bone mineral density tests hcpcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n , 'central dual energy x-ray absorptiometry (dxa)'\n , 'spinal densitometry x-ray' \n , 'ultrasonography for densitometry' \n , 'ct bone density axial'\n , 'peripheral dual-energy x-ray absorptiometry (dxa)'\n , 'osteoporosis medication'\n )\n\n)\n\n, procedures_osteo_related as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procs\n inner join osteo_procedure_codes\n on coalesce(procs.normalized_code, procs.source_code) = osteo_procedure_codes.code\n and coalesce(procs.normalized_code_type, procs.source_code_type) = osteo_procedure_codes.code_system\n\n)\n\n, qualifying_procedures as (\n\n select\n procedures_osteo_related.patient_id\n , procedures_osteo_related.procedure_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from procedures_osteo_related\n inner join denominator\n on procedures_osteo_related.patient_id = denominator.patient_id\n and \n procedures_osteo_related.procedure_date between\n denominator.recorded_date \n and\n \n\n dateadd(\n month,\n 6,\n denominator.recorded_date\n )\n\n \n\n)\n\n, denominator_patients_disqualified_from_procedure as (\n \n select \n denominator.patient_id\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end \n from denominator\n left join qualifying_procedures \n on denominator.patient_id = qualifying_procedures.patient_id\n where qualifying_procedures.patient_id is null\n\n)\n\n-- pharmacy_claim begin\n\n, osteo_rx_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) \n in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, pharmacy_claims_osteo_related as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code \n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join osteo_rx_codes\n on pharmacy_claims.ndc_code = osteo_rx_codes.code\n and lower(osteo_rx_codes.code_system) = 'ndc'\n\n)\n\n, qualifying_pharmacy_claims as (\n\n select \n pharmacy_claims_osteo_related.patient_id\n , pharmacy_claims_osteo_related.dispensing_date\n , pharmacy_claims_osteo_related.ndc_code\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from pharmacy_claims_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on pharmacy_claims_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and pharmacy_claims_osteo_related.dispensing_date \n between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n)\n\n-- medication begin\n\n, medication_osteo_related as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication as medications\n inner join osteo_rx_codes\n on medications.source_code = osteo_rx_codes.code\n and medications.source_code_type = osteo_rx_codes.code_system\n\n)\n\n, qualifying_medications as (\n\n select\n medication_osteo_related.patient_id\n , medication_osteo_related.encounter_id\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from medication_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on medication_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and coalesce(medication_osteo_related.prescribing_date, medication_osteo_related.dispensing_date) between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n\n)\n\n, numerator as (\n\n select\n qualifying_procedures.patient_id\n , qualifying_procedures.performance_period_begin\n , qualifying_procedures.performance_period_end\n , qualifying_procedures.measure_id\n , qualifying_procedures.measure_name\n , qualifying_procedures.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_procedures\n\n union all\n\n select \n qualifying_pharmacy_claims.patient_id\n , qualifying_pharmacy_claims.performance_period_begin\n , qualifying_pharmacy_claims.performance_period_end\n , qualifying_pharmacy_claims.measure_id\n , qualifying_pharmacy_claims.measure_name\n , qualifying_pharmacy_claims.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_pharmacy_claims\n\n union all\n\n select \n qualifying_medications.patient_id\n , qualifying_medications.performance_period_begin\n , qualifying_medications.performance_period_end\n , qualifying_medications.measure_id\n , qualifying_medications.measure_name\n , qualifying_medications.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_medications\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0053_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.202386Z", "completed_at": "2024-10-22T19:20:44.229238Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.230293Z", "completed_at": "2024-10-22T19:20:44.230297Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.05773806571960449, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join cms_synthetic.quality_measures._int_nqf0059_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0059_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.208618Z", "completed_at": "2024-10-22T19:20:44.230036Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.231094Z", "completed_at": "2024-10-22T19:20:44.231097Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.05796980857849121, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0059_denominator\n\n)\n\n, hba1c_test_code as (\n\n select\n code\n , code_system\n , concept_name\n From cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hba1c laboratory test'\n )\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_labs as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date,result_date) as evidence_date\n , hba1c_test_code.concept_name\n , row_number() over(partition by labs.patient_id order by coalesce(collection_date,result_date) desc) as rn\n from labs\n inner join hba1c_test_code\n on coalesce(labs.normalized_code, labs.source_code) = hba1c_test_code.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = hba1c_test_code.code_system\n left join denominator\n on labs.patient_id = denominator.patient_id\n where coalesce(collection_date,result_date) <= denominator.performance_period_end\n \n and regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, recent_readings as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from qualifying_labs\n where rn = 1\n\n)\n\n, qualifying_patients as (\n\n select\n denominator.*\n , recent_readings.evidence_date\n , recent_readings.evidence_value\n from denominator\n left join recent_readings\n on denominator.patient_id = recent_readings.patient_id\n\n)\n\n, test_not_performed as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from qualifying_patients\n where\n (evidence_date not between performance_period_begin and performance_period_end)\n or evidence_date is null\n\n)\n\n, valid_patients as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , case\n when cast(evidence_value as numeric(28,6)) > 9.0 then 1\n else 0\n end as numerator_flag\n from qualifying_patients\n where evidence_date between performance_period_begin and performance_period_end\n\n)\n\n, numerator as (\n\n select * from valid_patients\n\n union all\n\n select * from test_not_performed\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0059_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.231677Z", "completed_at": "2024-10-22T19:20:44.251689Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.252562Z", "completed_at": "2024-10-22T19:20:44.252568Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.023169994354248047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0097__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0097__performance_period\n\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select \n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n , valid_hospice_exclusions.exclusion_type\n from valid_hospice_exclusions\n inner join cms_synthetic.quality_measures._int_nqf0097_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0097_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.236832Z", "completed_at": "2024-10-22T19:20:44.253029Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.287306Z", "completed_at": "2024-10-22T19:20:44.287312Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.05653715133666992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n from cms_synthetic.quality_measures._int_nqf0097_denominator\n\n)\n\n, reconciliation_codes as (\n\n select\n concept_name\n , code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medication reconciliation post discharge'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, reconciliation_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join reconciliation_codes\n on procedures.code = reconciliation_codes.code\n and procedures.code_type = reconciliation_codes.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , reconciliation_procedures.procedure_date as evidence_date\n , 1 as numerator_flag\n from denominator\n inner join reconciliation_procedures\n on denominator.patient_id = reconciliation_procedures.patient_id\n where datediff(\n day,\n denominator.discharge_date,\n reconciliation_procedures.procedure_date\n ) between 0 and 30\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0097_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.253244Z", "completed_at": "2024-10-22T19:20:44.288449Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.289419Z", "completed_at": "2024-10-22T19:20:44.289423Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.05295610427856445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0420_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'patient is not eligible for a pain assessment'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as(\n \n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0420_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.269348Z", "completed_at": "2024-10-22T19:20:44.288643Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.289764Z", "completed_at": "2024-10-22T19:20:44.289768Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03844571113586426, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf0420_denominator\n\n)\n\n, pain_assessment_code as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pain assessment documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pain_assessment_procedures as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join pain_assessment_code\n on procedures.code = pain_assessment_code.code\n and procedures.code_type = pain_assessment_code.code_system\n\n)\n\n, pain_assessment_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join pain_assessment_code\n on medical_claim.hcpcs_code = pain_assessment_code.code\n and lower(pain_assessment_code.code_system) = 'hcpcs'\n\n)\n\n, time_unbounded_qualifying_patients as (\n\n select\n patient_id\n , evidence_date\n from pain_assessment_procedures\n \n union all\n\n select\n patient_id\n , evidence_date\n from pain_assessment_claims\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n time_unbounded_qualifying_patients.patient_id\n , time_unbounded_qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from time_unbounded_qualifying_patients\n inner join denominator\n on time_unbounded_qualifying_patients.patient_id = denominator.patient_id\n and time_unbounded_qualifying_patients.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0420_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.290087Z", "completed_at": "2024-10-22T19:20:44.342616Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.343464Z", "completed_at": "2024-10-22T19:20:44.343469Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.05571603775024414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "compiled": true, "compiled_code": "\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy or for whom there is evidence of a right and a left\n unilateral mastectomy\n*/\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.condition\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n , 'Status Post Left Mastectomy'\n , 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Left'\n , 'Unilateral Mastectomy Right'\n , 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, all_mastectomy as (\n\n select\n denominator.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from denominator\n inner join condition_exclusions\n on denominator.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from denominator\n inner join observation_exclusions\n on denominator.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from denominator\n inner join procedure_exclusions\n on denominator.patient_id = procedure_exclusions.patient_id\n\n)\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy\n*/\n, bilateral_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n )\n\n)\n\n, right_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Right'\n )\n\n)\n\n, left_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Left Mastectomy'\n , 'Unilateral Mastectomy Left'\n )\n\n)\n\n, unspecified_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n/*\n Women for whom there is evidence of a right AND a left unilateral mastectomy\n or unspecific mastectomies on different dates\n*/\n, unilateral_mastectomy as (\n\n select\n right_mastectomy.patient_id\n , right_mastectomy.exclusion_date\n , right_mastectomy.exclusion_reason\n from right_mastectomy\n inner join left_mastectomy\n on right_mastectomy.patient_id = left_mastectomy.patient_id\n\n union all\n\n select\n unspecified_mastectomy.patient_id\n , unspecified_mastectomy.exclusion_date\n , unspecified_mastectomy.exclusion_reason\n from unspecified_mastectomy\n inner join unspecified_mastectomy as self_join\n on unspecified_mastectomy.patient_id = self_join.patient_id\n and unspecified_mastectomy.exclusion_date <> self_join.exclusion_date\n\n)\n\n, unioned as (\n\n select * from bilateral_mastectomy\n union all\n select * from unilateral_mastectomy\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned", "relation_name": "cms_synthetic.quality_measures._int_nqf2372_exclude_mastectomy"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.316247Z", "completed_at": "2024-10-22T19:20:44.344105Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.350240Z", "completed_at": "2024-10-22T19:20:44.350244Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.061125993728637695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "compiled": true, "compiled_code": "\n\n/*\n Eligible population from the denominator model before exclusions\n*/\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n from cms_synthetic.quality_measures._int_nqf2372_denominator\n\n)\n\n, mammography_codes as (\n\n select\n code\n , code_system\n from cms_synthetic.quality_measures._value_set_codes\n where concept_name = 'Mammography'\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n from medical_claim\n inner join mammography_codes\n on medical_claim.hcpcs_code = mammography_codes.code\n where mammography_codes.code_system = 'hcpcs'\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n from observations\n inner join mammography_codes\n on observations.code = mammography_codes.code\n and observations.code_type = mammography_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join mammography_codes\n on procedures.code = mammography_codes.code\n and procedures.code_type = mammography_codes.code_system\n\n)\n\n/*\n Check if patients in the eligible population have had a screening,\n diagnostic, film, digital or digital breast tomosynthesis (3D)\n mammography results documented and reviewed.\n*/\n\n, patients_with_mammograms as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.performance_period_lookback\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_start_date\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_end_date\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_observations.observation_date\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_procedures.procedure_date\n else null\n end as evidence_date\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n else 0\n end as numerator_flag\n from denominator\n left join qualifying_claims\n on denominator.patient_id = qualifying_claims.patient_id\n left join qualifying_observations\n on denominator.patient_id = qualifying_observations.patient_id\n left join qualifying_procedures\n on denominator.patient_id = qualifying_procedures.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(numerator_flag as integer) as numerator_flag\n from patients_with_mammograms\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , numerator_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf2372_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.344309Z", "completed_at": "2024-10-22T19:20:44.351285Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.352146Z", "completed_at": "2024-10-22T19:20:44.352150Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.011962890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_overlap", "compiled": true, "compiled_code": "\n\n-- Here we give a list of all pairs of encounters\n-- that have some date overlap.\n\n\nwith encounters_with_row_num as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over (\n partition by patient_id order by encounter_id\n\t) as row_num\nfrom cms_synthetic.readmissions._int_encounter\n),\n\n\ncartesian as (\nselect\n aa.encounter_id as encounter_id_A,\n bb.encounter_id as encounter_id_B,\n aa.patient_id,\n aa.admit_date as Ai,\n aa.discharge_date as Af,\n bb.admit_date as Bi,\n bb.discharge_date as Bf,\n case\n when (aa.admit_date between bb.admit_date and bb.discharge_date) or (aa.discharge_date between bb.admit_date and bb.discharge_date) or\n (bb.admit_date between aa.admit_date and aa.discharge_date) or (bb.discharge_date between aa.admit_date and aa.discharge_date)\n then 1\n else 0\n end as overlap\n from encounters_with_row_num aa\n left join encounters_with_row_num bb\n on aa.patient_id = bb.patient_id and aa.row_num < bb.row_num\n),\n\n\noverlapping_pairs\nas\n(\n select\n patient_id,\n encounter_id_A,\n\tencounter_id_B\n from cartesian\n where overlap = 1\n)\n\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom overlapping_pairs", "relation_name": "cms_synthetic.readmissions._int_encounter_overlap"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.347464Z", "completed_at": "2024-10-22T19:20:44.351707Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.355560Z", "completed_at": "2024-10-22T19:20:44.355565Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012731790542602539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_with_ccs", "compiled": true, "compiled_code": "\n\n-- Here we add a CCS diagnosis category to\n-- every encounter that we can add a CCS diagnosis category to.\n-- The CCS diagnosis category is found using\n-- the encounter's primary diagnosis code.\n\n\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.primary_diagnosis_code,\n\n case\n when bb.icd_10_cm is not null then 1\n else 0\n end as valid_primary_diagnosis_code_flag,\n\n cc.ccs_diagnosis_category,\n\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\n\nfrom\n cms_synthetic.readmissions._int_encounter aa\n left join cms_synthetic.terminology.icd_10_cm bb\n on aa.primary_diagnosis_code = bb.icd_10_cm\n left join cms_synthetic.readmissions._value_set_icd_10_cm_to_ccs cc\n on aa.primary_diagnosis_code = cc.icd_10_cm", "relation_name": "cms_synthetic.readmissions._int_encounter_with_ccs"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.352485Z", "completed_at": "2024-10-22T19:20:44.359882Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.360617Z", "completed_at": "2024-10-22T19:20:44.360622Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.010045051574707031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__index_discharge_requirement", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the discharge_disposition_code requirements to be an\n-- index admission:\n-- *** Must NOT be discharged to another acute care hospital\n-- *** Must NOT have left against medical advice\n-- *** Patient must be alive at discharge\n\n\n\nwith all_invalid_discharges as (\nselect encounter_id\nfrom cms_synthetic.readmissions._int_encounter\nwhere discharge_disposition_code in (\n '02' -- Patient discharged/transferred to other short term general hospital for inpatient care.\n ,'07' -- Patient left against medical advice\n ,'20' -- Patient died\n )\n)\n\n-- All discharges that meet the discharge_disposition_code\n-- requirements to be an index admission\nselect a.encounter_id, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter a\nleft join all_invalid_discharges b\n on a.encounter_id = b.encounter_id\nwhere b.encounter_id is null", "relation_name": "cms_synthetic.readmissions._int_index_discharge_requirement"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.356732Z", "completed_at": "2024-10-22T19:20:44.361163Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.366795Z", "completed_at": "2024-10-22T19:20:44.366801Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014974832534790039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__index_time_requirement", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the time requirement to be an index admission:\n-- The discharge date must be at least 30 days\n-- earlier than the last discharge date available\n-- in the dataset.\n\n\nwith cte as (\n select max(discharge_date) max_discharge\n from cms_synthetic.readmissions._int_encounter\n)\n\nselect encounter_id\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter\ncross join cte\nwhere discharge_date <= \n\n dateadd(\n day,\n -30,\n cte.max_discharge\n )\n\n", "relation_name": "cms_synthetic.readmissions._int_index_time_requirement"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.361371Z", "completed_at": "2024-10-22T19:20:44.367567Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.368492Z", "completed_at": "2024-10-22T19:20:44.368495Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.008910179138183594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_01_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.364307Z", "completed_at": "2024-10-22T19:20:44.368087Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.369190Z", "completed_at": "2024-10-22T19:20:44.369193Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009127140045166016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_03_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.369503Z", "completed_at": "2024-10-22T19:20:44.389051Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.389861Z", "completed_at": "2024-10-22T19:20:44.389866Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022665977478027344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system'\n and pqi_number = '05'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_05_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.377998Z", "completed_at": "2024-10-22T19:20:44.403212Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.408894Z", "completed_at": "2024-10-22T19:20:44.408909Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.040509939193725586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nckd as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'exclusion_kidney_disease_diagnosis_codes'\n and pqi_number = '07'\n where c.encounter_id is not null\n),\n\naccess as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'exclusion_dialysis_access_procedure_codes'\n and pqi.pqi_number = '07'\n where c.encounter_id is not null\n),\n\ncombine as (\n select\n c.encounter_id\n , c.data_source\n , 'ckd' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join ckd \n on c.encounter_id = ckd.encounter_id\n and c.data_source = ckd.data_source\n inner join access as a \n on c.encounter_id = a.encounter_id\n and c.data_source = a.data_source\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from combine\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_07_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.390258Z", "completed_at": "2024-10-22T19:20:44.409898Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.411118Z", "completed_at": "2024-10-22T19:20:44.411122Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03349184989929199, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi.pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_08_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.397130Z", "completed_at": "2024-10-22T19:20:44.410941Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.412081Z", "completed_at": "2024-10-22T19:20:44.412086Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02336716651916504, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), sickle_cell as (\n select distinct\n encounter_id\n , data_source\n , 'sickle cell' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'sickle_cell_anemia_or_hb-s_disease_diagnosis_codes'\n and pqi.pqi_number = '11'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from sickle_cell\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_11_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.412771Z", "completed_at": "2024-10-22T19:20:44.427651Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.428492Z", "completed_at": "2024-10-22T19:20:44.428498Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018409013748168945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), kidney as (\n select distinct\n encounter_id\n , data_source\n , 'kidney' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'kidney_or_urinary_tract_disorder_diagnosis_codes'\n and pqi.pqi_number = '12'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from kidney\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_12_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.424424Z", "completed_at": "2024-10-22T19:20:44.434169Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.446312Z", "completed_at": "2024-10-22T19:20:44.446319Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03460097312927246, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_14_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.428901Z", "completed_at": "2024-10-22T19:20:44.447450Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.448480Z", "completed_at": "2024-10-22T19:20:44.448484Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.02449822425842285, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system_diagnosis_codes'\n and pqi.pqi_number = '15'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_15_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.436881Z", "completed_at": "2024-10-22T19:20:44.447763Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.448854Z", "completed_at": "2024-10-22T19:20:44.448859Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0215909481048584, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), amputation as (\n select distinct\n encounter_id\n , data_source\n , 'amputation' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'traumatic_amputation_of_the_lower_extremity_diagnosis_codes'\n and pqi.pqi_number = '16'\n where c.encounter_id is not null\n),\n\npregnancy as (\n select distinct\n encounter_id\n , data_source\n , 'pregnancy' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'mdc_14_principal_diagnosis_codes'\n and pqi.pqi_number = 'appendix_f'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cms_synthetic.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from amputation\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from pregnancy\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_16_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.449225Z", "completed_at": "2024-10-22T19:20:44.464556Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.465367Z", "completed_at": "2024-10-22T19:20:44.465373Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018532752990722656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ed_classification__summary", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__ed_classification__stg_patient as (\n\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom cms_synthetic.core.patient\n) select\n class.encounter_id\n , cat.classification_name as ed_classification_description\n , cat.classification_order as ed_classification_order\n , class.patient_id\n , class.encounter_end_date\n , date_part('year', class.encounter_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '00' || date_part('month', class.encounter_end_date),\n 2\n )\n end as year_month\n , class.primary_diagnosis_code\n , class.primary_diagnosis_description\n , class.paid_amount\n , class.allowed_amount\n , class.charge_amount\n , class.facility_id\n , fac_prov.provider_organization_name as facility_name\n , practice_state as facility_state\n , practice_city as facility_city\n , practice_zip_code as facility_zip_code\n , pat.sex as patient_sex\n , floor(datediff(\n hour,\n pat.birth_date,\n class.encounter_end_date\n ) / 8766.0) as patient_age\n , zip_code as patient_zip_code\n , latitude as patient_latitude\n , longitude as patient_longitude\n , race as patient_race\nfrom cms_synthetic.ed_classification._int_filter_encounter_with_classification class\ninner join cms_synthetic.ed_classification._value_set_categories cat\n on class.classification = cat.classification\nleft join cms_synthetic.terminology.provider fac_prov \n on class.facility_id = fac_prov.npi\nleft join __dbt__cte__ed_classification__stg_patient pat\n on class.patient_id = pat.patient_id", "relation_name": "cms_synthetic.ed_classification.summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.459669Z", "completed_at": "2024-10-22T19:20:44.465734Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.470615Z", "completed_at": "2024-10-22T19:20:44.470620Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022454023361206055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cbe0055_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cbe0055_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cbe0055_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0055_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.466139Z", "completed_at": "2024-10-22T19:20:44.475569Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.476283Z", "completed_at": "2024-10-22T19:20:44.476288Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.012043237686157227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cbe0101_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cbe0101_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cbe0101_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cbe0101_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.471174Z", "completed_at": "2024-10-22T19:20:44.476615Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.482508Z", "completed_at": "2024-10-22T19:20:44.482513Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01771402359008789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm130_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cqm130_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm130_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm130_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.476821Z", "completed_at": "2024-10-22T19:20:44.489204Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.490131Z", "completed_at": "2024-10-22T19:20:44.490136Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015212774276733398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm438_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cqm438_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm438_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm438_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.482912Z", "completed_at": "2024-10-22T19:20:44.490830Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.495967Z", "completed_at": "2024-10-22T19:20:44.495973Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019999980926513672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, measure_specific_procedure_observation_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n , age\n from cms_synthetic.quality_measures._int_cqm236_exclude_procedures_observations\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, frailty_exclusion_older_than_80 as (\n\n select\n frailty.patient_id\n , frailty.exclusion_date\n , frailty.exclusion_reason\n , 'measure specific exclusion for patients older than 80' as exclusion_type\n , denominator.age\n from frailty\n inner join denominator\n on frailty.patient_id = denominator.patient_id\n where denominator.age >= 81\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select * from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n union all\n\n select * from frailty_exclusion_older_than_80\n\n union all\n\n select * from measure_specific_procedure_observation_exclusion\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm236_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.491086Z", "completed_at": "2024-10-22T19:20:44.501905Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.503383Z", "completed_at": "2024-10-22T19:20:44.503388Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014564037322998047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm48_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_cqm48_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm48_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm48_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.496648Z", "completed_at": "2024-10-22T19:20:44.508148Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.508999Z", "completed_at": "2024-10-22T19:20:44.509041Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01857900619506836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_long", "compiled": true, "compiled_code": "with denominator as (\n\n select\n patient_id\n from cms_synthetic.quality_measures._int_nqf0034_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n from cms_synthetic.quality_measures._int_nqf0034_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0034_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , pp.performance_period_begin\n , pp.performance_period_end\n , (\n select id\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n ) as measure_id\n , (\n\n select name\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_name\n , (\n select version\nfrom cms_synthetic.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_version\n from denominator\n inner join cms_synthetic.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0034_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.504157Z", "completed_at": "2024-10-22T19:20:44.514844Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.516589Z", "completed_at": "2024-10-22T19:20:44.516593Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02027297019958496, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0041_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0041_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0041_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0041_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.509726Z", "completed_at": "2024-10-22T19:20:44.521665Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.522438Z", "completed_at": "2024-10-22T19:20:44.522443Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018733978271484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, frailty_within_defined_window as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n lookback_period_december\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, exclusion_procedure_and_medication as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_nqf0053_exclude_procedures_medications\n\n)\n\n, valid_institutional_snp as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n\n and (\n select\n lookback_period_december\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from cms_synthetic.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, frailty_patients_within_defined_window as (\n\n select\n frailty_within_defined_window.patient_id\n , frailty_within_defined_window.exclusion_date\n , frailty_within_defined_window.exclusion_reason\n , 'measure specific exclusion for defined window' as exclusion_type\n from frailty_within_defined_window\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n union all\n\n select * from exclusion_procedure_and_medication\n\n union all\n\n select * from frailty_patients_within_defined_window\n\n)\n\nselect\n *\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions", "relation_name": "cms_synthetic.quality_measures._int_nqf0053_exclusions_stage_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.517254Z", "completed_at": "2024-10-22T19:20:44.528291Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.529123Z", "completed_at": "2024-10-22T19:20:44.529137Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.019721269607543945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0059_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0059_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0059_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0059_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.523071Z", "completed_at": "2024-10-22T19:20:44.529781Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.534447Z", "completed_at": "2024-10-22T19:20:44.534452Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01752305030822754, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_long", "compiled": true, "compiled_code": "\n\n/* selecting the full patient population as the grain of this table */\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0097_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0097_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0097_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0097_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.529972Z", "completed_at": "2024-10-22T19:20:44.541008Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.541796Z", "completed_at": "2024-10-22T19:20:44.541802Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01902627944946289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0420_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0420_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0420_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0420_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.535079Z", "completed_at": "2024-10-22T19:20:44.545883Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.546711Z", "completed_at": "2024-10-22T19:20:44.546716Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017208099365234375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from cms_synthetic.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_mastectomy_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf2372_exclude_mastectomy\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_hospice_palliative\n where lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n and\n exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from cms_synthetic.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from cms_synthetic.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from cms_synthetic.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n)\n-- advanced illness end\n\n, valid_mastectomy_patients_with_exclusion_type as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'mastectomy_performed' as exclusion_type\n from valid_mastectomy_patients\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join cms_synthetic.quality_measures._int_nqf2372_denominator denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type != 'hospice_palliative' \n and age >= 66\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, valid_exclusions_with_mastectomy as (\n\n select *\n from valid_exclusions\n\n union all\n\n select *\n from valid_mastectomy_patients_with_exclusion_type\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions_with_mastectomy\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf2372_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.542470Z", "completed_at": "2024-10-22T19:20:44.550401Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.551368Z", "completed_at": "2024-10-22T19:20:44.551373Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016601085662841797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__readmission_crude", "compiled": true, "compiled_code": "\n\n-- Here we calculate readmissions using all encounters\n-- that have valid admit and discharge dates and no overlap.\n-- This is meant to give a crude sense of the readmission\n-- rate without taking into account all the CMS HWR logic.\n\n\nwith encounter_info as (\nselect\n enc.encounter_id,\n enc.patient_id,\n enc.admit_date,\n enc.discharge_date\nfrom cms_synthetic.readmissions._int_encounter enc\nleft join cms_synthetic.readmissions._int_encounter_overlap over_a\n on enc.encounter_id = over_a.encounter_id_A\nleft join cms_synthetic.readmissions._int_encounter_overlap over_b\n on enc.encounter_id = over_b.encounter_id_B\nwhere\n admit_date is not null\n and\n discharge_date is not null\n and\n admit_date <= discharge_date\nand over_a.encounter_id_A is null and over_b.encounter_id_B is null\n ),\n\n\nencounter_sequence as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom encounter_info\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n case\n when bb.encounter_id is not null then 1\n\telse 0\n end as had_readmission_flag,\n datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n )) <= 30 then 1\n\telse 0\n end as readmit_30_flag\nfrom encounter_sequence aa left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom readmission_calc", "relation_name": "cms_synthetic.readmissions._int_readmission_crude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.547336Z", "completed_at": "2024-10-22T19:20:44.555304Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.556084Z", "completed_at": "2024-10-22T19:20:44.556088Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013926982879638672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_data_quality", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter table\n-- with data quality flags that may disqualify them from\n-- being used for readmission measures \n\n\n-- Flag several potential data quality issues\n-- with all encounters.\n-- Every encounter_id from the stg_encounter model\n-- will be here. This CTE should have the same\n-- number of rows as the stg_encounter model, i.e.,\n-- there is a one to one correspondence between the\n-- rows in stg_encounter and this CTE.\nwith encounter_data_quality_issues as (\nselect\n aa.encounter_id,\n case\n when aa.admit_date is null then 1\n\telse 0\n end as missing_admit_date_flag,\n case\n when aa.discharge_date is null then 1\n\telse 0\n end as missing_discharge_date_flag,\n case\n when aa.admit_date > aa.discharge_date then 1\n\telse 0\n end as admit_after_discharge_flag,\n case\n when aa.discharge_disposition_code is null then 1\n\telse 0\n end as missing_discharge_disposition_code_flag,\n case\n when\n\t (aa.discharge_disposition_code is not null)\n\t and\n\t (bb.discharge_disposition_code is null) then 1\n\telse 0\n end as invalid_discharge_disposition_code_flag,\n case\n when aa.primary_diagnosis_code is null then 1\n else 0\n end as missing_primary_diagnosis_flag,\n case\n when aa.valid_primary_diagnosis_code_flag = 0 then 1\n\telse 0\n end as invalid_primary_diagnosis_code_flag,\n case\n when aa.ccs_diagnosis_category is null then 1\n\telse 0\n end as no_diagnosis_ccs_flag,\n aa.ccs_diagnosis_category as diagnosis_ccs,\n case\n when aa.encounter_id in (select distinct encounter_id_A\n\t from cms_synthetic.readmissions._int_encounter_overlap )\n\t or\n\t aa.encounter_id in (select distinct encounter_id_B\n\t from cms_synthetic.readmissions._int_encounter_overlap )\n\tthen 1\n\telse 0\n end as overlaps_with_another_encounter_flag,\n case\n when aa.ms_drg_code is null then 1\n\telse 0\n end as missing_ms_drg_flag,\n case\n when cc.ms_drg_code is null then 1\n\telse 0\n end as invalid_ms_drg_flag\n\nfrom cms_synthetic.readmissions._int_encounter_with_ccs aa\n left join cms_synthetic.terminology.discharge_disposition bb\n on aa.discharge_disposition_code = bb.discharge_disposition_code\n left join cms_synthetic.terminology.ms_drg cc\n on aa.ms_drg_code = cc.ms_drg_code\n),\n\n\n-- Here we add a disqualified_encounter_flag.\n-- This disqualified_encounter_flag = 1\n-- when any of the critical data quality flags\n-- from the above CTE are equal to 1.\nall_data_quality_flags as (\nselect\n encounter_id,\n diagnosis_ccs,\n case\n when\n\t (missing_admit_date_flag = 1)\n\t or\n\t (missing_discharge_date_flag = 1)\n\t or\n\t (admit_after_discharge_flag = 1)\n\t or\n\t (missing_discharge_disposition_code_flag = 1)\n\t or\n\t (invalid_discharge_disposition_code_flag = 1)\n\t or\n\t (missing_primary_diagnosis_flag = 1)\n\t or\n\t (invalid_primary_diagnosis_code_flag = 1)\n\t or\n\t (no_diagnosis_ccs_flag = 1)\n\t or\n\t (overlaps_with_another_encounter_flag = 1)\n\t or\n\t (missing_ms_drg_flag = 1)\n\t or\n\t (invalid_ms_drg_flag = 1)\n\t then 1\n\telse 0\n end as disqualified_encounter_flag,\n missing_admit_date_flag,\n missing_discharge_date_flag,\n admit_after_discharge_flag,\n missing_discharge_disposition_code_flag,\n invalid_discharge_disposition_code_flag,\n missing_primary_diagnosis_flag,\n invalid_primary_diagnosis_code_flag,\n no_diagnosis_ccs_flag,\n overlaps_with_another_encounter_flag,\n missing_ms_drg_flag,\n invalid_ms_drg_flag\nfrom encounter_data_quality_issues\n) \n\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom all_data_quality_flags", "relation_name": "cms_synthetic.readmissions._int_encounter_data_quality"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.552025Z", "completed_at": "2024-10-22T19:20:44.559470Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.560268Z", "completed_at": "2024-10-22T19:20:44.560272Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.013236045837402344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_specialty_cohort", "compiled": true, "compiled_code": "\n\n-- Here we list the specialty cohort for each encounter that has\n-- an associated specialty cohort.\n-- There are 5 possible specialty cohorts:\n-- [1] Medicine\n-- [2] Surgery/Gynecology\n-- [3] Cardiology\n-- [4] Cardiovascular\n-- [5] Neurology\n-- An encounter that has an ICD-10-PCS procedure code or a\n-- CCS procedure category that corresponds to the\n-- 'Surgery/Gynecology' cohort will always be in that cohort.\n-- For encounters that are not in the 'Surgery/Gynecology' cohort,\n-- we then check to see if they are in one of the other 4 cohorts.\n\n--ranking to eventually assign a cohort to encounters in multiple cohorts\nwith cohort_ranks as (\n select 'Surgery/Gynecology' as cohort, 1 as c_rank\n union all\n select 'Cardiorespiratory' as cohort, 2 as c_rank\n union all\n select 'Cardiovascular' as cohort, 3 as c_rank\n union all\n select 'Neurology' as cohort, 4 as c_rank\n union all\n select 'Medicine' as cohort, 5 as c_rank\n)\n\n\n--get all encounter ids in any procedure or diagnosis based cohorts\n, all_encounter_cohorts as (\n\n --encounter ids in procedure based cohorts\n select procs.encounter_id, 1 as c_rank\n from cms_synthetic.readmissions._int_procedure_ccs procs\n left join cms_synthetic.readmissions._value_set_surgery_gynecology_cohort sgc\n on procs.procedure_code = sgc.icd_10_pcs\n left join cms_synthetic.readmissions._value_set_specialty_cohort sgsc\n on procs.ccs_procedure_category = sgsc.ccs and sgsc.specialty_cohort = 'Surgery/Gynecology'\n where sgc.icd_10_pcs is not null or sgsc.ccs is not null\n\n union all\n\n --encounter ids in diagnosis based cohorts\n select diag.encounter_id, cohort_ranks.c_rank\n from cms_synthetic.readmissions._int_encounter_with_ccs diag\n inner join cms_synthetic.readmissions._value_set_specialty_cohort sc\n on diag.ccs_diagnosis_category = sc.ccs and sc.procedure_or_diagnosis = 'Diagnosis'\n inner join cohort_ranks\n on sc.specialty_cohort = cohort_ranks.cohort\n)\n\n\n-- getting one cohort per encounter\n, main_encounter_cohort as (\n select encounter_id, min(c_rank) as main_c_rank\n from all_encounter_cohorts\n group by encounter_id\n\n)\n\n\n--getting all encounters, with labeled cohorts, if no cohort cohort is \"medicine\"\nselect enc.encounter_id, coalesce(cohort_ranks.cohort, 'Medicine') as specialty_cohort, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter enc\nleft join main_encounter_cohort mec\n on enc.encounter_id = mec.encounter_id\nleft join cohort_ranks\n on mec.main_c_rank = cohort_ranks.c_rank", "relation_name": "cms_synthetic.readmissions._int_encounter_specialty_cohort"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.556677Z", "completed_at": "2024-10-22T19:20:44.560850Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.566641Z", "completed_at": "2024-10-22T19:20:44.566646Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014915943145751953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__exclusion", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that are excluded\n-- from being index admissions because they\n-- belong to one of these categories:\n-- [1] Medical Treatment of Cancer\n-- [2] Rehabilitation\n-- [3] Psychiatric\n\n\n-- encounter_ids for encounters that should be\n-- excluded because they belong to one of the\n-- exclusion categories\nwith exclusions as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_encounter_with_ccs\nwhere\n(ccs_diagnosis_category is not null)\nand\n(\nccs_diagnosis_category in\n (select distinct ccs_diagnosis_category\n from cms_synthetic.readmissions._value_set_exclusion_ccs_diagnosis_category )\n)\n)\n\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom exclusions", "relation_name": "cms_synthetic.readmissions._int_exclusion"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.561044Z", "completed_at": "2024-10-22T19:20:44.571519Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.572315Z", "completed_at": "2024-10-22T19:20:44.572321Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.01595926284790039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__planned_encounter", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids for all encounters\n-- that are planned.\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a procedure category\n-- that is only present for planned encounters \nwith always_planned_px as (\nselect distinct pccs.encounter_id\nfrom cms_synthetic.readmissions._int_procedure_ccs pccs\ninner join cms_synthetic.readmissions._value_set_always_planned_ccs_procedure_category apc\n on pccs.ccs_procedure_category = apc.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a diagnosis category\n-- that is only present for planned encounters\nalways_planned_dx as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_encounter_with_ccs dccs\ninner join cms_synthetic.readmissions._value_set_always_planned_ccs_diagnosis_category apd\n on dccs.ccs_diagnosis_category = apd.ccs_diagnosis_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on one of their CCS procedure categories.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_ccs as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_procedure_ccs pccs\ninner join cms_synthetic.readmissions._value_set_potentially_planned_ccs_procedure_category pcs\n on pccs.ccs_procedure_category = pcs.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on their ICD-10-PCS procedure codes.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_icd_10_pcs as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_procedure_ccs pcs\ninner join cms_synthetic.readmissions._value_set_potentially_planned_icd_10_pcs pps\n on pcs.procedure_code = pps.icd_10_pcs\n),\n\n\n-- encounter_ids for encounters that are acute based\n-- on their primary diagnosis code or their CCS diagnosis category\nacute_encounters as (\nselect distinct encounter_id\nfrom cms_synthetic.readmissions._int_encounter_with_ccs dccs\nleft join cms_synthetic.readmissions._value_set_acute_diagnosis_icd_10_cm adi\n on dccs.primary_diagnosis_code = adi.icd_10_cm\nleft join cms_synthetic.readmissions._value_set_acute_diagnosis_ccs adc\n on dccs.ccs_diagnosis_category = adc.ccs_diagnosis_category\nwhere adi.icd_10_cm is not null or adc.ccs_diagnosis_category is not null\n),\n\n\n-- encounter_ids for encounters that are:\n-- [1] potentially planned, based on one of\n-- their CCS procedure categories or\n-- their ICD-10-PCS procedure codes\n-- [2] not acute, based on their primary diagnosis code\n-- or their CCS diagnosis category\n-- These encounters are therefore confirmed to be planned\npotentially_planned_that_are_actually_planned as (\nselect distinct ppp.encounter_id\nfrom (\n select * from potentially_planned_px_ccs\n union all\n select * from potentially_planned_px_icd_10_pcs) ppp\nleft join acute_encounters\n on ppp.encounter_id = acute_encounters.encounter_id\nwhere acute_encounters.encounter_id is null\n\n)\n\n\n-- Aggregate of all encounter_ids for planned encounters\n\nselect * , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from always_planned_px\n\nunion distinct\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from always_planned_dx\n\nunion distinct\n\nselect *, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run from potentially_planned_that_are_actually_planned", "relation_name": "cms_synthetic.readmissions._int_planned_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.567280Z", "completed_at": "2024-10-22T19:20:44.572976Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.577000Z", "completed_at": "2024-10-22T19:20:44.577005Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01642322540283203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_short-term_complications_diagnosis_codes'\n and pqi.pqi_number = '01'\ninner join cms_synthetic.ahrq_measures._int_pqi_01_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_01_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_01_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.573295Z", "completed_at": "2024-10-22T19:20:44.577687Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.581496Z", "completed_at": "2024-10-22T19:20:44.581502Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.014544010162353516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_long-term_complications_diagnosis_codes'\n and pqi.pqi_number = '03'\ninner join cms_synthetic.ahrq_measures._int_pqi_03_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_03_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_03_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.577882Z", "completed_at": "2024-10-22T19:20:44.585307Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.586328Z", "completed_at": "2024-10-22T19:20:44.586334Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013659954071044922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._int_pqi_05_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._value_set_pqi as copd\n on e.primary_diagnosis_code = copd.code\n and copd.value_set_name = 'chronic_obstructive_pulmonary_disorder'\n and copd.pqi_number = '05'\nleft join cms_synthetic.ahrq_measures._value_set_pqi asthma\n on e.primary_diagnosis_code = asthma.code\n and asthma.value_set_name = 'asthma'\n and asthma.pqi_number = '05'\nleft join cms_synthetic.ahrq_measures._int_pqi_05_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null\n and (\n asthma.code is not null \n or copd.code is not null\n )", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_05_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.582210Z", "completed_at": "2024-10-22T19:20:44.586932Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.590861Z", "completed_at": "2024-10-22T19:20:44.590867Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013544321060180664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'hypertension_diagnosis_codes'\n and hyp.pqi_number = '07'\ninner join cms_synthetic.ahrq_measures._int_pqi_07_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_07_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_07_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.587129Z", "completed_at": "2024-10-22T19:20:44.594788Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.595568Z", "completed_at": "2024-10-22T19:20:44.595573Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01370382308959961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'heart_failure_diagnosis_codes'\n and hyp.pqi_number = '08'\ninner join cms_synthetic.ahrq_measures._int_pqi_08_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_08_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_08_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.591521Z", "completed_at": "2024-10-22T19:20:44.595891Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.599662Z", "completed_at": "2024-10-22T19:20:44.599668Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.013009786605834961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'community_acquired_bacterial_pneumonia_diagnosis_codes'\n and hyp.pqi_number = '11'\ninner join cms_synthetic.ahrq_measures._int_pqi_11_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_11_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_11_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.596116Z", "completed_at": "2024-10-22T19:20:44.603574Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.604662Z", "completed_at": "2024-10-22T19:20:44.604667Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013434171676635742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'urinary_tract_infection_diagnosis_codes'\n and hyp.pqi_number = '12'\ninner join cms_synthetic.ahrq_measures._int_pqi_12_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_12_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_12_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.600079Z", "completed_at": "2024-10-22T19:20:44.604330Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.608279Z", "completed_at": "2024-10-22T19:20:44.608285Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.013020992279052734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'uncontrolled_diabetes_diagnosis_codes'\n and hyp.pqi_number = '14'\ninner join cms_synthetic.ahrq_measures._int_pqi_14_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_14_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_14_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.605008Z", "completed_at": "2024-10-22T19:20:44.619191Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.620208Z", "completed_at": "2024-10-22T19:20:44.620214Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01718878746032715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'asthma_diagnosis_codes'\n and hyp.pqi_number = '15'\ninner join cms_synthetic.ahrq_measures._int_pqi_15_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join cms_synthetic.ahrq_measures._int_pqi_15_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_15_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.609033Z", "completed_at": "2024-10-22T19:20:44.620551Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.621561Z", "completed_at": "2024-10-22T19:20:44.621565Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.017508983612060547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_num", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n cms_synthetic.core.procedure\n), diagnosis as (\n select distinct\n c.encounter_id\n , c.data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'diabetes_diagnosis_codes'\n and pqi_number = '16'\n where c.encounter_id is not null\n),\n\n\nprocedures as (\n select distinct\n p.encounter_id\n , p.data_source\n from __dbt__cte___stg_pqi_procedure as p\n inner join diagnosis as d \n on p.encounter_id = d.encounter_id\n and d.data_source = p.data_source\n inner join cms_synthetic.ahrq_measures._value_set_pqi as pqi\n on p.normalized_code = pqi.code\n and p.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'lower-extremity_amputation_procedure_codes'\n and pqi_number = '16'\n)\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join cms_synthetic.ahrq_measures._int_pqi_16_denom as denom \n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\n inner join procedures as p\n on e.encounter_id = p.encounter_id\n and e.data_source = p.data_source\nleft join cms_synthetic.ahrq_measures._int_pqi_16_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "cms_synthetic.ahrq_measures._int_pqi_16_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.629823Z", "completed_at": "2024-10-22T19:20:44.633674Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.638615Z", "completed_at": "2024-10-22T19:20:44.638620Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.018764734268188477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__ed_classification", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n max(case when ed_classification_description = 'Emergent, ED Care Needed, Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_preventable,\n max(case when ed_classification_description = 'Emergent, Primary Care Treatable' then 1 else 0 end) as pc_treatable,\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Not Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_not_preventable,\n max(case when ed_classification_description = 'Non-Emergent' then 1 else 0 end) as non_emergent\n from cms_synthetic.ed_classification.summary\n)\n\n,final as (\nselect 'ed classification missing ed_care_needed_preventable' as data_quality_check,\n case when ed_care_needed_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing pc_treatable' as data_quality_check,\n case when pc_treatable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing ed_care_needed_not_preventable' as data_quality_check,\n case when ed_care_needed_not_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing non_emergent' as data_quality_check,\n case when non_emergent = 0 then 1 else 0 end as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.data_quality_ed_classification"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.621926Z", "completed_at": "2024-10-22T19:20:44.638136Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.639081Z", "completed_at": "2024-10-22T19:20:44.639085Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01964712142944336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_exclusion_long", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 1 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_01_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 3 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_03_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 5 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_05_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 7 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_07_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 8 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_08_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 11 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_11_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 12 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_12_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 14 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_14_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 15 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_15_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 16 as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_16_exclusions as e", "relation_name": "cms_synthetic.ahrq_measures.pqi_exclusion_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.633901Z", "completed_at": "2024-10-22T19:20:44.643544Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.644512Z", "completed_at": "2024-10-22T19:20:44.644517Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012129783630371094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__ed_classification_reference", "compiled": true, "compiled_code": "\n\nwith total_cte as \n(\nselect count(*) as total_encounters\nfrom cms_synthetic.core.encounter\nwhere encounter_type = cast('emergency department' as TEXT)\n) \n\n,final as (\nselect coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT)) as ed_classification_description\n,count(*) as encounters\n,total_cte.total_encounters\n,count(*)/total_cte.total_encounters as percent_of_total\n,row_number() over (order by count(*) desc) as value_rank\nfrom cms_synthetic.core.encounter e\ncross join total_cte\nleft join cms_synthetic.ed_classification.summary s on e.encounter_id = s.encounter_id \nwhere encounter_type = cast('emergency department' as TEXT)\ngroup by coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT))\n,total_cte.total_encounters\n)\n\n,actually_final as (\nselect cast('ed classification' as TEXT) as analytics_concept\n,ed_classification_description as analytics_measure\n,percent_of_total as data_source_value\n,value_rank as value_rank\nfrom final\n)\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n,m.value_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join actually_final on actually_final.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = actually_final.analytics_concept\nwhere m.analytics_concept = cast('ed classification' as TEXT)", "relation_name": "cms_synthetic.data_quality.data_quality_ed_classification_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.639449Z", "completed_at": "2024-10-22T19:20:44.645310Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.646153Z", "completed_at": "2024-10-22T19:20:44.646156Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012734174728393555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__ed_classification", "compiled": true, "compiled_code": "\n\nWITH cte AS\n(\n SELECT DISTINCT location_id, npi, name\n FROM cms_synthetic.core.location\n)\n\nSELECT\n e.encounter_id,\n case when s.encounter_id is null then 'Not Classified' else s.ed_classification_description end as ed_classification_description,\n CASE\n when s.encounter_id is null then 'Non-Avoidable'\n when cast(s.ed_classification_order as int) <= 3 then s.ed_classification_description\n ELSE 'Non-Avoidable' END AS avoidable_category,\n e.paid_amount,\n e.primary_diagnosis_code,\n e.primary_diagnosis_description,\n e.primary_diagnosis_code || ' | ' || e.primary_diagnosis_description as primary_diagnosis_and_description,\n p.ccsr_parent_category,\n p.ccsr_category,\n p.ccsr_category_description,\n p.ccsr_category || ' | ' || p.ccsr_category_description as ccsr_parent_category_and_description,\n b.body_system,\n e.facility_id,\n e.allowed_amount,\n e.charge_amount,\n e.data_source,\n e.length_of_stay,\n e.discharge_disposition_code || ' | ' || e.discharge_disposition_description as discharge_code_and_description,\n e.patient_id || ' | ' || e.data_source as patient_source_key,\n e.facility_name,\n e.encounter_start_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.encounter e\nleft join cms_synthetic.ed_classification.summary s on e.encounter_id = s.encounter_id\nleft join cte on e.facility_id = cte.location_id\nleft join cms_synthetic.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\nleft join cms_synthetic.ccsr._value_set_dxccsr_v2023_1_body_systems b on p.ccsr_parent_category = b.ccsr_parent_category\nwhere e.encounter_type = 'emergency department'", "relation_name": "cms_synthetic.data_quality.mart_review__ed_classification"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.650582Z", "completed_at": "2024-10-22T19:20:44.660275Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.660972Z", "completed_at": "2024-10-22T19:20:44.660978Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01591968536376953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "compiled": true, "compiled_code": "\n\nwith\n\ncombined_exclusions as (\n\n select\n exclusions.*\n , denominator.age\n from cms_synthetic.quality_measures._int_nqf0053_exclusions_stage_1 as exclusions\n inner join cms_synthetic.quality_measures._int_nqf0053_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'institutional_snp'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'advanced_illness'\n , 'dementia'\n )\n and age between 66 and 80\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'measure specific exclusion for defined window'\n and age >= 81\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'measure specific exclusion for procedure medication'\n , 'hospice_palliative'\n )\n\n)\n\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0053_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.646738Z", "completed_at": "2024-10-22T19:20:44.660519Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.661408Z", "completed_at": "2024-10-22T19:20:44.661412Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016597986221313477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_cqm236_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n from cms_synthetic.quality_measures._int_cqm236_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_cqm236_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.observation_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.observation_date is null then 1 else 0 end,\n numerator.observation_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , observation_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(observation_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_cqm236_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.654978Z", "completed_at": "2024-10-22T19:20:44.664909Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.665764Z", "completed_at": "2024-10-22T19:20:44.665769Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019335031509399414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf2372_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , numerator_flag\n from cms_synthetic.quality_measures._int_nqf2372_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n from cms_synthetic.quality_measures._int_nqf2372_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then denominator.denominator_flag\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null\n then numerator.numerator_flag\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null\n then exclusions.exclusion_flag\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf2372_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.661766Z", "completed_at": "2024-10-22T19:20:44.666552Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.675408Z", "completed_at": "2024-10-22T19:20:44.675415Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020898103713989258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__index_admission", "compiled": true, "compiled_code": "\n\n-- Here we list all index admissions for the hospital wide readmissions\n-- measure.\n-- These represent encounter_ids that meet the requirements to be an\n-- index admission for the HWR measure.\n-- These are the requirements for a hospitalization to be an index admission\n-- for the HWR measure:\n--\n-- Time Requirement: The discharge data must be at least 30 days\n-- earlier than the last dischareg date available\n-- in the dataset.\n-- \n-- Discharge Requirements: The patient must not be discharged to another\n-- acute care hospital; the patient must not have\n-- left against medical advice; and the patient\n-- must be alive at discharge.\n--\n-- Diagnosis Requirements: Exclude encounters where based on the CCS\n-- (exclusions) diagnosis category we know the encounter was\n-- for medical treatment of cancer, rehabilitation,\n-- or psychiatric reasons.\n\n\n\nselect distinct a.encounter_id, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.readmissions._int_encounter a\ninner join cms_synthetic.readmissions._int_index_time_requirement b\n on a.encounter_id = b.encounter_id\ninner join cms_synthetic.readmissions._int_index_discharge_requirement c\n on a.encounter_id = c.encounter_id\nleft join cms_synthetic.readmissions._int_exclusion d\n on a.encounter_id = d.encounter_id\nwhere d.encounter_id is null", "relation_name": "cms_synthetic.readmissions._int_index_admission"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.666989Z", "completed_at": "2024-10-22T19:20:44.680481Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.680980Z", "completed_at": "2024-10-22T19:20:44.680984Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01554107666015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_num_long", "compiled": true, "compiled_code": "\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '01' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_01_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '03' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_03_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '05' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_05_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '07' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_07_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '08' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_08_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '11' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_11_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '12' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_12_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '14' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_14_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '15' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_15_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '16' as pqi_number\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures._int_pqi_16_num as n", "relation_name": "cms_synthetic.ahrq_measures.pqi_num_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.675931Z", "completed_at": "2024-10-22T19:20:44.681309Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.682166Z", "completed_at": "2024-10-22T19:20:44.682169Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.016084909439086914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from cms_synthetic.quality_measures._int_nqf0053_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from cms_synthetic.quality_measures._int_nqf0053_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from cms_synthetic.quality_measures._int_nqf0053_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures._int_nqf0053_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.682491Z", "completed_at": "2024-10-22T19:20:44.687354Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.693515Z", "completed_at": "2024-10-22T19:20:44.693521Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012861967086791992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_augmented", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter model\n-- and we augment them with extra fields\n-- that are relevant for readmission measures\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n datediff(\n day,\n aa.admit_date,\n aa.discharge_date\n ) as length_of_stay,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as index_admission_flag,\n case\n when cc.encounter_id is not null then 1\n\t else 0\n end as planned_flag,\n dd.specialty_cohort,\n case\n when aa.discharge_disposition_code = '20' then 1\n\t else 0\n end as died_flag,\n ee.diagnosis_ccs,\n ee.disqualified_encounter_flag,\n ee.missing_admit_date_flag,\n ee.missing_discharge_date_flag,\n ee.admit_after_discharge_flag,\n ee.missing_discharge_disposition_code_flag,\n ee.invalid_discharge_disposition_code_flag,\n ee.missing_primary_diagnosis_flag,\n ee.invalid_primary_diagnosis_code_flag,\n ee.no_diagnosis_ccs_flag,\n ee.overlaps_with_another_encounter_flag,\n ee.missing_ms_drg_flag,\n ee.invalid_ms_drg_flag,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n cms_synthetic.readmissions._int_encounter aa\n left join cms_synthetic.readmissions._int_index_admission bb\n on aa.encounter_id = bb.encounter_id\n left join cms_synthetic.readmissions._int_planned_encounter cc\n on aa.encounter_id = cc.encounter_id \n left join cms_synthetic.readmissions._int_encounter_specialty_cohort dd\n on aa.encounter_id = dd.encounter_id\n left join cms_synthetic.readmissions._int_encounter_data_quality ee\n on aa.encounter_id = ee.encounter_id", "relation_name": "cms_synthetic.readmissions.encounter_augmented"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.690282Z", "completed_at": "2024-10-22T19:20:44.694080Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.701338Z", "completed_at": "2024-10-22T19:20:44.701345Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015280961990356445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_summary", "compiled": true, "compiled_code": "\n\nselect p.pqi_number\n , m.pqi_name\n , e.year_number\n , e.encounter_id\n , e.data_source\n , e.patient_id\n , e.facility_id\n , e.ms_drg_code\n , e.ms_drg_description\n , e.encounter_start_date\n , e.encounter_end_date\n , e.length_of_stay\n , e.paid_amount\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.ahrq_measures.pqi_num_long p \ninner join cms_synthetic.ahrq_measures._stg_pqi_inpatient_encounter e\n on p.encounter_id = e.encounter_id\n and p.data_source = e.data_source\ninner join cms_synthetic.ahrq_measures._value_set_pqi_measures m on cast(p.pqi_number as TEXT) = m.pqi_number", "relation_name": "cms_synthetic.ahrq_measures.pqi_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.687545Z", "completed_at": "2024-10-22T19:20:44.694260Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.701952Z", "completed_at": "2024-10-22T19:20:44.701956Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.016164302825927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_rate", "compiled": true, "compiled_code": "\n\nwith num as (\n select\n data_source\n , year_number\n , pqi_number\n , count(encounter_id) as num_count\n from cms_synthetic.ahrq_measures.pqi_num_long\n group by\n data_source\n , year_number\n , pqi_number\n)\n\n, denom as (\n select\n data_source\n , year_number\n , pqi_number\n , count(patient_id) as denom_count\n from cms_synthetic.ahrq_measures.pqi_denom_long as d\n group by\n data_source\n , year_number\n , pqi_number\n)\n\nselect\n d.data_source\n , d.year_number\n , d.pqi_number\n , d.denom_count\n , coalesce(num.num_count, 0) as num_count\n , coalesce(num.num_count, 0) / d.denom_count * 100000 as rate_per_100_thousand\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom denom as d\nleft join num\n on d.pqi_number = num.pqi_number\n and d.year_number = num.year_number\n and d.data_source = num.data_source", "relation_name": "cms_synthetic.ahrq_measures.pqi_rate"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.708869Z", "completed_at": "2024-10-22T19:20:44.714201Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.714511Z", "completed_at": "2024-10-22T19:20:44.714516Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011350870132446289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__readmission_summary", "compiled": true, "compiled_code": "\n\n-- Here calculate days to readmission for encounters\n-- that had a readmission and create readmission flags\n\n\n-- We create the encounter_sequence integer count\n-- which keeps track of what number of encounter each\n-- encounter is for a given patient\nwith encounter_sequence as (\nselect\n *,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom cms_synthetic.readmissions.encounter_augmented\nwhere disqualified_encounter_flag = 0\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.length_of_stay,\n aa.index_admission_flag,\n aa.planned_flag,\n aa.specialty_cohort,\n aa.died_flag,\n aa.diagnosis_ccs,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as had_readmission_flag,\n datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30 then 1\n\t else 0\n end as readmit_30_flag,\n case\n when\n\t ((datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30) and (bb.planned_flag = 0) then 1\n\t else 0\n end as unplanned_readmit_30_flag,\n bb.encounter_id as readmission_encounter_id,\n bb.admit_date as readmission_admit_date,\n bb.discharge_date as readmission_discharge_date,\n bb.discharge_disposition_code as readmission_discharge_disposition_code,\n bb.facility_id as readmission_facility,\n bb.ms_drg_code as readmission_ms_drg,\n bb.length_of_stay as readmission_length_of_stay,\n bb.index_admission_flag as readmission_index_admission_flag,\n bb.planned_flag as readmission_planned_flag,\n bb.specialty_cohort as readmission_specialty_cohort,\n bb.died_flag as readmission_died_flag,\n bb.diagnosis_ccs as readmission_diagnosis_ccs,\n '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom\n encounter_sequence aa\n left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\nselect *\nfrom readmission_calc", "relation_name": "cms_synthetic.readmissions.readmission_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.717236Z", "completed_at": "2024-10-22T19:20:44.723152Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.723390Z", "completed_at": "2024-10-22T19:20:44.723396Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.0074579715728759766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__readmissions_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('readmission rate' as TEXT) as analytics_measure\n ,cast('readmissions' as TEXT) as analytics_concept\n ,sum(unplanned_readmit_30_flag)/cast(count(*) as numeric(28,6) ) as data_source_value\nfrom cms_synthetic.readmissions.readmission_summary r \nwhere index_admission_flag = 1\n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('readmissions' as TEXT)", "relation_name": "cms_synthetic.data_quality.data_quality_readmissions_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.720768Z", "completed_at": "2024-10-22T19:20:44.723743Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:44.724019Z", "completed_at": "2024-10-22T19:20:44.724023Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007584810256958008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__readmissions", "compiled": true, "compiled_code": "\n\nSELECT *\nFROM cms_synthetic.readmissions.readmission_summary\nWHERE index_admission_flag = 1", "relation_name": "cms_synthetic.data_quality.mart_review__readmissions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.703923Z", "completed_at": "2024-10-22T19:20:45.017092Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:45.017621Z", "completed_at": "2024-10-22T19:20:45.017631Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.42595577239990234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__readmissions", "compiled": true, "compiled_code": "\n\n\nwith disqualified_unpivot as (\n select\n encounter_id,\n\n cast('MISSING_ADMIT_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_ADMIT_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('ADMIT_AFTER_DISCHARGE_FLAG' as TEXT) as disqualified_reason,\n cast( \n ADMIT_AFTER_DISCHARGE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_PRIMARY_DIAGNOSIS_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_PRIMARY_DIAGNOSIS_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('NO_DIAGNOSIS_CCS_FLAG' as TEXT) as disqualified_reason,\n cast( \n NO_DIAGNOSIS_CCS_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG' as TEXT) as disqualified_reason,\n cast( \n OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from cms_synthetic.readmissions.encounter_augmented\n\n \n)\n\n-- Using the transformed data to perform aggregation\nselect \n 'inpatient encounter ' || d.disqualified_reason as data_quality_check\n , count(distinct encounter_id) as result_count\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom disqualified_unpivot d\nwhere cast(flagvalue as integer ) = 1 \ngroup by disqualified_reason", "relation_name": "cms_synthetic.data_quality.data_quality_readmissions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:44.694434Z", "completed_at": "2024-10-22T19:20:46.425478Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.425728Z", "completed_at": "2024-10-22T19:20:46.425734Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 1.8461329936981201, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__summary_long", "compiled": true, "compiled_code": "\n\n/* measures should already be at the full eligibility population grain */\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.core.patient\n), union_measures as (\n\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf2372_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf2372_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0034_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0034_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0059_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0059_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm236_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm236_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0053_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0053_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cbe0055_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cbe0055_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0097_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0097_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm438_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm438_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0041_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0041_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cbe0101_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cbe0101_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm48_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm48_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_cqm130_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_cqm130_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_nqf0420_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_nqf0420_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_adh_diabetes_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_adh_diabetes_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.quality_measures._int_adhras_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from cms_synthetic.quality_measures._int_adhras_long\n\n \n )\n\n \n\n)\n\n, patient as (\n\n select distinct patient_id\n from __dbt__cte___stg_patient\n\n)\n\n/* selecting the full patient population as the grain of this table */\n, joined as (\n\n select distinct\n patient.patient_id\n , union_measures.denominator_flag\n , union_measures.numerator_flag\n , union_measures.exclusion_flag\n , case\n when union_measures.exclusion_flag = 1 then null\n when union_measures.numerator_flag = 1 then 1\n when union_measures.denominator_flag = 1 then 0\n else null\n end as performance_flag\n , union_measures.evidence_date\n , union_measures.evidence_value\n , union_measures.exclusion_date\n , union_measures.exclusion_reason\n , union_measures.performance_period_begin\n , union_measures.performance_period_end\n , union_measures.measure_id\n , union_measures.measure_name\n , union_measures.measure_version\n from patient\n left join union_measures\n on patient.patient_id = union_measures.patient_id\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(performance_flag as integer) as performance_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from joined\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures.summary_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.538839Z", "completed_at": "2024-10-22T19:20:46.553318Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.554382Z", "completed_at": "2024-10-22T19:20:46.554389Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018062114715576172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__analytics_populated", "compiled": true, "compiled_code": "\n\nwith tuva_chronic_condition_long as (\n select\n 'tuva_chronic_condition_long' as table_name\n , count(*) as record_count\n from cms_synthetic.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, cms_hcc_patient_risk_factors as (\n select\n 'cms_hcc__patient_risk_factors' as table_name\n , count(*) as record_count\n from cms_synthetic.cms_hcc.patient_risk_factors\n)\n\n, service_category_grouper as (\n select\n 'service_category__service_category_grouper' as table_name\n , count(*) as record_count\n from cms_synthetic.claims_preprocessing.service_category_grouper\n)\n\n, financial_pmpm_payer as (\n select\n 'financial_pmpm__pmpm_payer' as table_name\n , count(*) as record_count\n from cms_synthetic.financial_pmpm.pmpm_payer\n)\n\n, readmission_summary as (\n select\n 'readmissions__readmission_summary' as table_name\n , count(*) as record_count\n from cms_synthetic.readmissions.readmission_summary\n)\n\n, quality_measures_summary_long as (\n select\n 'quality_measures__summary_long' as table_name\n , count(*) as record_count\n from cms_synthetic.quality_measures.summary_long\n)\n\n, acute_inpatient_visits as (\n select\n 'acute_inpatient_visits' as table_name\n , count(*) as record_count\n from cms_synthetic.core.encounter\n where encounter_type = 'acute inpatient'\n)\n\n, ed_visits as (\n select\n 'ed_visits' as table_name\n , count(*) as record_count\n from cms_synthetic.core.encounter\n where encounter_type = 'emergency department'\n)\n\n,final as (\nselect * from tuva_chronic_condition_long\nunion all\nselect * from cms_hcc_patient_risk_factors\nunion all\nselect * from service_category_grouper\nunion all\nselect * from financial_pmpm_payer\nunion all\nselect * from readmission_summary\nunion all\nselect * from quality_measures_summary_long\nunion all\nselect * from acute_inpatient_visits\nunion all\nselect * from ed_visits\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.analytics_populated"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.542835Z", "completed_at": "2024-10-22T19:20:46.554831Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.556102Z", "completed_at": "2024-10-22T19:20:46.556111Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01920795440673828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__quality_measures_summary_long", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom cms_synthetic.quality_measures.summary_long s", "relation_name": "cms_synthetic.data_quality.mart_review__quality_measures_summary_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.545168Z", "completed_at": "2024-10-22T19:20:46.555043Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.556635Z", "completed_at": "2024-10-22T19:20:46.556639Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019346952438354492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__summary_counts", "compiled": true, "compiled_code": "\n\nwith summary_long as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n from cms_synthetic.quality_measures.summary_long\n where measure_id is not null\n\n)\n\n, calculate_performance_rate as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , sum(denominator_flag) as denominator_sum\n , sum(numerator_flag) as numerator_sum\n , sum(exclusion_flag) as exclusion_sum\n , (\n cast(sum(performance_flag) as numeric(28,6)) /\n (cast(count(performance_flag) as numeric(28,6)) )\n )*100 as performance_rate\n from summary_long\n group by\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(denominator_sum as integer) as denominator_sum\n , cast(numerator_sum as integer) as numerator_sum\n , cast(exclusion_sum as integer) as exclusion_sum\n , round(cast(performance_rate as numeric(28,6)),3) as performance_rate\n from calculate_performance_rate\n\n)\n\nselect\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_sum\n , numerator_sum\n , exclusion_sum\n , performance_rate\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures.summary_counts"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.548604Z", "completed_at": "2024-10-22T19:20:46.555683Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.557022Z", "completed_at": "2024-10-22T19:20:46.557026Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.019327402114868164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__summary_wide", "compiled": true, "compiled_code": "\n\n/*\n Each measure is pivoted into a boolean column by evaluating the\n denominator, numerator, and exclusion flags.\n*/\nwith measures_long as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , measure_id\n from cms_synthetic.quality_measures.summary_long\n\n)\n\n, nqf_2372 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF2372'\n\n)\n\n, nqf_0034 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0034'\n\n)\n\n, nqf_0059 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0059'\n\n)\n\n, cqm_236 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM236'\n\n)\n\n, nqf_0053 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0053'\n\n)\n\n, cbe_0055 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0055'\n\n)\n\n, nqf_0097 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0097'\n\n)\n\n, cqm_438 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM438'\n\n)\n\n, nqf_0041 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0041'\n\n)\n\n, cbe_0101 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0101'\n\n)\n\n, cqm_48 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM48'\n\n)\n\n, cqm_130 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM130'\n\n)\n\n, nqf_0420 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0420'\n\n)\n\n, adh_diabetes as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-Diabetes'\n\n)\n\n, adh_ras as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-RAS'\n \n)\n\n, joined as (\n\n select\n measures_long.patient_id\n , max(nqf_2372.performance_flag) as nqf_2372\n , max(nqf_0034.performance_flag) as nqf_0034\n , max(nqf_0059.performance_flag) as nqf_0059\n , max(cqm_236.performance_flag) as cqm_236\n , max(nqf_0053.performance_flag) as nqf_0053\n , max(cbe_0055.performance_flag) as cbe_0055\n , max(nqf_0097.performance_flag) as nqf_0097\n , max(cqm_438.performance_flag) as cqm_438\n , max(nqf_0041.performance_flag) as nqf_0041\n , max(cbe_0101.performance_flag) as cbe_0101\n , max(cqm_48.performance_flag) as cqm_48\n , max(cqm_130.performance_flag) as cqm_130\n , max(nqf_0420.performance_flag) as nqf_0420\n , max(adh_diabetes.performance_flag) as adh_diabetes\n , max(adh_ras.performance_flag) as adh_ras\n from measures_long\n left join nqf_2372\n on measures_long.patient_id = nqf_2372.patient_id\n left join nqf_0034\n on measures_long.patient_id = nqf_0034.patient_id\n left join nqf_0059\n on measures_long.patient_id = nqf_0059.patient_id\n left join cqm_236\n on measures_long.patient_id = cqm_236.patient_id\n left join nqf_0053\n on measures_long.patient_id = nqf_0053.patient_id\n left join cbe_0055\n on measures_long.patient_id = cbe_0055.patient_id\n left join nqf_0097\n on measures_long.patient_id = nqf_0097.patient_id\n left join cqm_438\n on measures_long.patient_id = cqm_438.patient_id\n left join nqf_0041\n on measures_long.patient_id = nqf_0041.patient_id\n left join cbe_0101\n on measures_long.patient_id = cbe_0101.patient_id\n left join cqm_48\n on measures_long.patient_id = cqm_48.patient_id\n left join cqm_130\n on measures_long.patient_id = cqm_130.patient_id\n left join nqf_0420\n on measures_long.patient_id = nqf_0420.patient_id\n left join adh_diabetes\n on measures_long.patient_id = adh_diabetes.patient_id\n left join adh_ras\n on measures_long.patient_id = adh_ras.patient_id\n group by measures_long.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(nqf_2372 as integer) as nqf_2372\n , cast(nqf_0034 as integer) as nqf_0034\n , cast(nqf_0059 as integer) as nqf_0059\n , cast(cqm_236 as integer) as cqm_236\n , cast(nqf_0053 as integer) as nqf_0053\n , cast(cbe_0055 as integer) as cbe_0055\n , cast(nqf_0097 as integer) as nqf_0097\n , cast(cqm_438 as integer) as cqm_438 \n , cast(nqf_0041 as integer) as nqf_0041\n , cast(cbe_0101 as integer) as cbe_0101\n , cast(cqm_48 as integer) as cqm_48\n , cast(cqm_130 as integer) as cqm_130\n , cast(nqf_0420 as integer) as nqf_0420\n , cast(adh_diabetes as integer) as adh_diabetes\n , cast(adh_ras as integer) as adh_ras\n from joined\n\n)\n\nselect\n patient_id\n , nqf_2372\n , nqf_0034\n , nqf_0059\n , cqm_236\n , nqf_0053\n , cbe_0055\n , nqf_0097\n , cqm_438\n , nqf_0041\n , cbe_0101\n , cqm_48\n , cqm_130\n , nqf_0420\n , adh_diabetes\n , adh_ras\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "cms_synthetic.quality_measures.summary_wide"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.561300Z", "completed_at": "2024-10-22T19:20:46.564359Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.564796Z", "completed_at": "2024-10-22T19:20:46.564801Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.006623983383178711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__quality_measures_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('quality measures' as TEXT) as analytics_concept\n ,measure_name as analytics_measure\n ,performance_rate as data_source_value\nfrom cms_synthetic.quality_measures.summary_counts r \n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom cms_synthetic.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('quality measures' as TEXT)", "relation_name": "cms_synthetic.data_quality.data_quality_quality_measures_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.558796Z", "completed_at": "2024-10-22T19:20:46.564554Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:46.565144Z", "completed_at": "2024-10-22T19:20:46.565148Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.007200956344604492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__quality_measures", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect sum(case when numerator_sum = 0 then 1 else 0 end) as numerator_zero_count\n,sum(case when denominator_sum = 0 then 1 else 0 end) as denominator_zero_count\nfrom cms_synthetic.quality_measures.summary_counts \n)\n\n,final as (\nselect 'quality measure numerator zero' as data_quality_check\n,numerator_zero_count as result_count\nfrom cte \n\nunion all \n\nselect 'quality measure denominator zero' as data_quality_check\n,denominator_zero_count as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom final", "relation_name": "cms_synthetic.data_quality.data_quality_quality_measures"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.572679Z", "completed_at": "2024-10-22T19:20:47.667275Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:47.667827Z", "completed_at": "2024-10-22T19:20:47.667836Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 1.2155170440673828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__analytics_checks_summary", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_readmissions' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_readmissions\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.chronic_conditions_none' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"MEDICARE_LDS_REFERENCE\" as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(\"NORMALLY_ZERO\" as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.chronic_conditions_none\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_cms_hcc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_cms_hcc\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_quality_measures' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_quality_measures\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.encounters_missing_groups_union' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.encounters_missing_groups_union\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_acute_inpatient' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_acute_inpatient\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_ed_classification' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from cms_synthetic.data_quality.data_quality_ed_classification\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , coalesce(normally_zero ,1) as normally_zero\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned_data", "relation_name": "cms_synthetic.data_quality.analytics_checks_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:47.784881Z", "completed_at": "2024-10-22T19:20:47.790222Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:47.790686Z", "completed_at": "2024-10-22T19:20:47.790691Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.007040977478027344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom cms_synthetic.data_quality.analytics_checks_summary\nwhere data_quality_check is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:47.787724Z", "completed_at": "2024-10-22T19:20:47.790463Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:47.791075Z", "completed_at": "2024-10-22T19:20:47.791087Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.006985187530517578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom cms_synthetic.data_quality.analytics_checks_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-22T19:20:46.566942Z", "completed_at": "2024-10-22T19:20:47.765327Z"}, {"name": "execute", "started_at": "2024-10-22T19:20:47.765831Z", "completed_at": "2024-10-22T19:20:47.765841Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 1.310034990310669, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__analytics_reference_summary", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_readmissions_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_readmissions_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_cms_hcc_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_cms_hcc_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.chronic_conditions_prevalence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"PATIENTS\" as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(\"MEDICARE_LDS_CONDITION_RANK\" as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.chronic_conditions_prevalence\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_quality_measures_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_quality_measures_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_acute_inpatient_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_acute_inpatient_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_acute_inpatient_prevelence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_acute_inpatient_prevelence\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.encounters_cost_and_utilization' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.encounters_cost_and_utilization\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.data_quality_ed_classification_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.data_quality_ed_classification_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('cms_synthetic.data_quality.service_categories_pmpm' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(\"TOTAL_PAID\" as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(\"MEMBER_MONTHS\" as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from cms_synthetic.data_quality.service_categories_pmpm\n\n \n )\n\n \n\n)\n\nselect\n analytics_concept \n , analytics_measure\n , data_source_value\n , analytics_value\n , value_rank\n , '2024-10-22 19:20:26.762934+00:00' as tuva_last_run\nfrom unioned_data", "relation_name": "cms_synthetic.data_quality.analytics_reference_summary"}], "elapsed_time": 20.190436124801636, "args": {"exclude": [], "favor_state": false, "select": [], "compile": true, "invocation_command": "dbt docs generate --target-path ../target", "log_level_file": "debug", "indirect_selection": "eager", "vars": {}, "log_path": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate/logs", "send_anonymous_usage_stats": true, "printer_width": 80, "target_path": "../target", "project_dir": "/Users/tomsherwood/Documents/02-Areas/repos/tuva/integration_tests/docs_generate", "partial_parse": true, "populate_cache": true, "partial_parse_file_diff": true, "source_freshness_run_project_hooks": false, "log_level": "info", "log_file_max_bytes": 10485760, "require_resource_names_without_spaces": false, "use_colors_file": true, "show_resource_report": false, "profiles_dir": "/Users/tomsherwood/.dbt", "static": false, "require_explicit_package_overrides_for_builtin_materializations": true, "write_json": true, "which": "generate", "empty_catalog": false, "log_format_file": "debug", "introspect": true, "enable_legacy_logger": false, "quiet": false, "strict_mode": false, "cache_selected_only": false, "log_format": "default", "static_parser": true, "version_check": true, "warn_error_options": {"include": [], "exclude": []}, "use_colors": true, "print": true, "macro_debugging": false, "defer": false}} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v6.json", "dbt_version": "1.8.6", "generated_at": "2024-10-25T14:34:55.368960Z", "invocation_id": "7a3fb5b6-66c4-4d4a-b7ed-a46ac2f1bdcb", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.540337Z", "completed_at": "2024-10-25T14:34:33.574288Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.597838Z", "completed_at": "2024-10-25T14:34:33.597838Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.06359148025512695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.condition", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as condition_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as recorded_date\n , cast(null as date) as onset_date\n , cast(null as date) as resolved_date\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as condition_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as integer ) as condition_rank\n , cast(null as TEXT ) as present_on_admit_code\n , cast(null as TEXT ) as present_on_admit_description\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.557998Z", "completed_at": "2024-10-25T14:34:33.598850Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.602032Z", "completed_at": "2024-10-25T14:34:33.602032Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.06472086906433105, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.encounter", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_type\n , cast(null as date) as encounter_start_date\n , cast(null as date) as encounter_end_date\n , cast(null as integer ) as length_of_stay\n , cast(null as TEXT ) as admit_source_code\n , cast(null as TEXT ) as admit_source_description\n , cast(null as TEXT ) as admit_type_code\n , cast(null as TEXT ) as admit_type_description\n , cast(null as TEXT ) as discharge_disposition_code\n , cast(null as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(null as TEXT ) as facility_id\n , cast(null as TEXT ) as facility_name\n , cast(null as TEXT ) as primary_diagnosis_code_type\n , cast(null as TEXT ) as primary_diagnosis_code\n , cast(null as TEXT ) as primary_diagnosis_description\n , cast(null as TEXT ) as ms_drg_code\n , cast(null as TEXT ) as ms_drg_description\n , cast(null as TEXT ) as apr_drg_code\n , cast(null as TEXT ) as apr_drg_description\n , cast(null as numeric(28,6) ) as paid_amount\n , cast(null as numeric(28,6) ) as allowed_amount\n , cast(null as numeric(28,6) ) as charge_amount\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.567005Z", "completed_at": "2024-10-25T14:34:33.599845Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.603030Z", "completed_at": "2024-10-25T14:34:33.603030Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.06478095054626465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.lab_result", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as lab_result_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as accession_number\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as source_component\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as normalized_component\n , cast(null as TEXT ) as status\n , cast(null as TEXT ) as result\n , cast(null as date) as result_date\n , cast(null as date) as collection_date\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as integer ) as source_abnormal_flag\n , cast(null as integer ) as normalized_abnormal_flag\n , cast(null as TEXT ) as specimen\n , cast(null as TEXT ) as ordering_practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.lab_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.575288Z", "completed_at": "2024-10-25T14:34:33.599845Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.603030Z", "completed_at": "2024-10-25T14:34:33.603030Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.06478095054626465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.location", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as location_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(null as TEXT ) as parent_organization\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.585299Z", "completed_at": "2024-10-25T14:34:33.602032Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.604033Z", "completed_at": "2024-10-25T14:34:33.604033Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.06478524208068848, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.medication", "compiled": true, "compiled_code": "select \n cast(null as TEXT ) as medication_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as date) as dispensing_date\n , cast(null as date) as prescribing_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as ndc_code\n , cast(null as TEXT ) as ndc_description\n , cast(null as TEXT ) as rxnorm_code\n , cast(null as TEXT ) as rxnorm_description\n , cast(null as TEXT ) as atc_code\n , cast(null as TEXT ) as atc_description\n , cast(null as TEXT ) as route\n , cast(null as TEXT ) as strength\n , cast(null as integer ) as quantity\n , cast(null as TEXT ) as quantity_unit\n , cast(null as integer ) as days_supply\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.medication"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.609033Z", "completed_at": "2024-10-25T14:34:33.618033Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.648997Z", "completed_at": "2024-10-25T14:34:33.648997Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.04496335983276367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.observation", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as observation_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as panel_id\n , cast(null as date) as observation_date\n , cast(null as TEXT ) as observation_type\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as result\n , cast(null as TEXT ) as source_units\n , cast(null as TEXT ) as normalized_units\n , cast(null as TEXT ) as source_reference_range_low\n , cast(null as TEXT ) as source_reference_range_high\n , cast(null as TEXT ) as normalized_reference_range_low\n , cast(null as TEXT ) as normalized_reference_range_high\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.observation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.618033Z", "completed_at": "2024-10-25T14:34:33.650241Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.652727Z", "completed_at": "2024-10-25T14:34:33.652727Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04469418525695801, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.patient", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as sex\n , cast(null as TEXT ) as race\n , cast(null as date) as birth_date\n , cast(null as date) as death_date\n , cast(null as integer ) as death_flag\n , cast(null as TEXT ) as social_security_number\n , cast(null as TEXT ) as address\n , cast(null as TEXT ) as city\n , cast(null as TEXT ) as state\n , cast(null as TEXT ) as zip_code\n , cast(null as TEXT ) as county\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.624735Z", "completed_at": "2024-10-25T14:34:33.651269Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.653856Z", "completed_at": "2024-10-25T14:34:33.653856Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.045823097229003906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.practitioner", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as npi\n , cast(null as TEXT ) as first_name\n , cast(null as TEXT ) as last_name\n , cast(null as TEXT ) as practice_affiliation\n , cast(null as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.629840Z", "completed_at": "2024-10-25T14:34:33.651269Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.654857Z", "completed_at": "2024-10-25T14:34:33.654857Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04582357406616211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.procedure", "compiled": true, "compiled_code": "select\n cast(null as TEXT ) as procedure_id\n , cast(null as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id\n , cast(null as TEXT ) as claim_id\n , cast(null as date) as procedure_date\n , cast(null as TEXT ) as source_code_type\n , cast(null as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(null as TEXT ) as normalized_code_type\n , cast(null as TEXT ) as normalized_code\n , cast(null as TEXT ) as normalized_description\n , cast(null as TEXT ) as modifier_1\n , cast(null as TEXT ) as modifier_2\n , cast(null as TEXT ) as modifier_3\n , cast(null as TEXT ) as modifier_4\n , cast(null as TEXT ) as modifier_5\n , cast(null as TEXT ) as practitioner_id\n , cast(null as TEXT ) as data_source\n , cast(null as TEXT ) as file_name\n , cast(null as timestamp ) as ingest_datetime\nlimit 0", "relation_name": "tuva.input_layer.procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.636182Z", "completed_at": "2024-10-25T14:34:33.653856Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.656736Z", "completed_at": "2024-10-25T14:34:33.656736Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04070544242858887, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034__performance_period", "compiled": true, "compiled_code": "\n/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback periods for each type of test\n\n during the measurement period:\n - Fecal occult blood test (FOBT) during the measurement period\n\n during the measurement period or the two years prior:\n - Fecal immunochemical DNA test (FIT-DNA)\n\n during the measurement period or the four years prior:\n - Flexible sigmoidoscopy\n - Computed tomography (CT) colonography\n\n during the measurement period or the nine years prior:\n - Colonoscopy\n\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n year,\n -2,\n performance_period_end\n )\n\n as performance_period_begin_1yp\n , \n\n dateadd(\n year,\n -3,\n performance_period_end\n )\n\n as performance_period_begin_2yp\n , \n\n dateadd(\n year,\n -5,\n performance_period_end\n )\n\n as performance_period_begin_4yp\n , \n\n dateadd(\n year,\n -10,\n performance_period_end\n )\n\n as performance_period_begin_9yp\n from period_begin\n\n)\n\nselect\n cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin_1yp as date) as performance_period_begin_1yp\n , cast(performance_period_begin_2yp as date) as performance_period_begin_2yp\n , cast(performance_period_begin_4yp as date) as performance_period_begin_4yp\n , cast(performance_period_begin_9yp as date) as performance_period_begin_9yp\nfrom period_lookback", "relation_name": "dev_thuxuan.quality_measures._int_nqf0034__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.683574Z", "completed_at": "2024-10-25T14:34:33.685661Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.690579Z", "completed_at": "2024-10-25T14:34:33.690579Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030841827392578125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.eligibility_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.686605Z", "completed_at": "2024-10-25T14:34:33.687705Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.692582Z", "completed_at": "2024-10-25T14:34:33.692582Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03081989288330078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.lab_result_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.687705Z", "completed_at": "2024-10-25T14:34:33.689582Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.693675Z", "completed_at": "2024-10-25T14:34:33.693675Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03191351890563965, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.medical_claim_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.690579Z", "completed_at": "2024-10-25T14:34:33.692582Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.696617Z", "completed_at": "2024-10-25T14:34:33.696617Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014606714248657227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.observation_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.702216Z", "completed_at": "2024-10-25T14:34:33.704224Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.709745Z", "completed_at": "2024-10-25T14:34:33.709745Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011106252670288086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.pharmacy_claim_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.705956Z", "completed_at": "2024-10-25T14:34:33.706964Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.711882Z", "completed_at": "2024-10-25T14:34:33.711882Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012205362319946289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.input_layer.provider_attribution_seed", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.707976Z", "completed_at": "2024-10-25T14:34:33.708982Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.712755Z", "completed_at": "2024-10-25T14:34:33.712755Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013078451156616211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_body_systems", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.709745Z", "completed_at": "2024-10-25T14:34:33.711882Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.713784Z", "completed_at": "2024-10-25T14:34:33.713784Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.013114452362060547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ccsr__dxccsr_v2023_1_cleaned_map", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.719754Z", "completed_at": "2024-10-25T14:34:33.722568Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.728319Z", "completed_at": "2024-10-25T14:34:33.728319Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012565851211547852, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ccsr__prccsr_v2023_1_cleaned_map", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.723580Z", "completed_at": "2024-10-25T14:34:33.725576Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.730915Z", "completed_at": "2024-10-25T14:34:33.730915Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01413106918334961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.chronic_conditions__cms_chronic_conditions_hierarchy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.726498Z", "completed_at": "2024-10-25T14:34:33.727515Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.731921Z", "completed_at": "2024-10-25T14:34:33.731921Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01416778564453125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.chronic_conditions__tuva_chronic_conditions_hierarchy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.728319Z", "completed_at": "2024-10-25T14:34:33.730327Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.732926Z", "completed_at": "2024-10-25T14:34:33.732926Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014175176620483398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.clinical_concept_library__clinical_concepts", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.738926Z", "completed_at": "2024-10-25T14:34:33.740926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.745926Z", "completed_at": "2024-10-25T14:34:33.745926Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011000871658325195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.clinical_concept_library__coding_systems", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.741926Z", "completed_at": "2024-10-25T14:34:33.742926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.751437Z", "completed_at": "2024-10-25T14:34:33.751437Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015512466430664062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.clinical_concept_library__value_set_members", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.743925Z", "completed_at": "2024-10-25T14:34:33.745926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.752436Z", "completed_at": "2024-10-25T14:34:33.752436Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015509605407714844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__adjustment_rates", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.747431Z", "completed_at": "2024-10-25T14:34:33.750437Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.753641Z", "completed_at": "2024-10-25T14:34:33.753641Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016721487045288086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__cpt_hcpcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.760647Z", "completed_at": "2024-10-25T14:34:33.762648Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.767649Z", "completed_at": "2024-10-25T14:34:33.767649Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011999845504760742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__demographic_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.763648Z", "completed_at": "2024-10-25T14:34:33.764648Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.771647Z", "completed_at": "2024-10-25T14:34:33.771647Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01399850845336914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disabled_interaction_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.765648Z", "completed_at": "2024-10-25T14:34:33.767649Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.772648Z", "completed_at": "2024-10-25T14:34:33.772648Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014999628067016602, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disease_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.768648Z", "completed_at": "2024-10-25T14:34:33.771647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.773647Z", "completed_at": "2024-10-25T14:34:33.773647Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01599907875061035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disease_hierarchy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.780647Z", "completed_at": "2024-10-25T14:34:33.782648Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.789647Z", "completed_at": "2024-10-25T14:34:33.789647Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012998342514038086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__disease_interaction_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.783647Z", "completed_at": "2024-10-25T14:34:33.786647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.793647Z", "completed_at": "2024-10-25T14:34:33.793647Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015999794006347656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__enrollment_interaction_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.786647Z", "completed_at": "2024-10-25T14:34:33.788647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.794646Z", "completed_at": "2024-10-25T14:34:33.794646Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0169985294342041, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__icd_10_cm_mappings", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.790648Z", "completed_at": "2024-10-25T14:34:33.792647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.795647Z", "completed_at": "2024-10-25T14:34:33.795647Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.017000198364257812, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.cms_hcc__payment_hcc_count_factors", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.802646Z", "completed_at": "2024-10-25T14:34:33.804647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.810648Z", "completed_at": "2024-10-25T14:34:33.810648Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012000322341918945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_info", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.805648Z", "completed_at": "2024-10-25T14:34:33.806647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.813648Z", "completed_at": "2024-10-25T14:34:33.814647Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.014999151229858398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_field_to_mart", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.807646Z", "completed_at": "2024-10-25T14:34:33.809647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.814647Z", "completed_at": "2024-10-25T14:34:33.814647Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016000747680664062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_mart_to_outcome_measure", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.810648Z", "completed_at": "2024-10-25T14:34:33.813648Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.816670Z", "completed_at": "2024-10-25T14:34:33.816670Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016022205352783203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__crosswalk_measure_reasonable_ranges", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.822648Z", "completed_at": "2024-10-25T14:34:33.824664Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.831647Z", "completed_at": "2024-10-25T14:34:33.831647Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014000177383422852, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.data_quality__reference_mart_analytics", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.825666Z", "completed_at": "2024-10-25T14:34:33.828664Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.835653Z", "completed_at": "2024-10-25T14:34:33.835653Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01700592041015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__categories", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.828664Z", "completed_at": "2024-10-25T14:34:33.831647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.836653Z", "completed_at": "2024-10-25T14:34:33.836653Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017006635665893555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__icd_10_cm_to_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.832653Z", "completed_at": "2024-10-25T14:34:33.834653Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.837654Z", "completed_at": "2024-10-25T14:34:33.837654Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01700615882873535, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd10", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.843653Z", "completed_at": "2024-10-25T14:34:33.846654Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.851997Z", "completed_at": "2024-10-25T14:34:33.851997Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013344764709472656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.ed_classification__johnston_icd9", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.847653Z", "completed_at": "2024-10-25T14:34:33.848997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.855997Z", "completed_at": "2024-10-25T14:34:33.855997Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015344381332397461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.hcc_suspecting__clinical_concepts", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.848997Z", "completed_at": "2024-10-25T14:34:33.851997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.856997Z", "completed_at": "2024-10-25T14:34:33.856997Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01534414291381836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.hcc_suspecting__hcc_descriptions", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.852997Z", "completed_at": "2024-10-25T14:34:33.855997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.858997Z", "completed_at": "2024-10-25T14:34:33.858997Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016344070434570312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.hcc_suspecting__icd_10_cm_mappings", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.864997Z", "completed_at": "2024-10-25T14:34:33.867013Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.875000Z", "completed_at": "2024-10-25T14:34:33.875000Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014001846313476562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.pharmacy__rxnorm_generic_available", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.868997Z", "completed_at": "2024-10-25T14:34:33.871013Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.877997Z", "completed_at": "2024-10-25T14:34:33.877997Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015997648239135742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.pqi__measures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.872013Z", "completed_at": "2024-10-25T14:34:33.873999Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.878996Z", "completed_at": "2024-10-25T14:34:33.878996Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016996145248413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.pqi__value_sets", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.875000Z", "completed_at": "2024-10-25T14:34:33.876999Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.879996Z", "completed_at": "2024-10-25T14:34:33.879996Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016996383666992188, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.quality_measures__concepts", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.885999Z", "completed_at": "2024-10-25T14:34:33.888013Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.895996Z", "completed_at": "2024-10-25T14:34:33.895996Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013997077941894531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.quality_measures__measures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.889013Z", "completed_at": "2024-10-25T14:34:33.892014Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.898998Z", "completed_at": "2024-10-25T14:34:33.898998Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01599907875061035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.quality_measures__value_sets", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.893000Z", "completed_at": "2024-10-25T14:34:33.894997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.899997Z", "completed_at": "2024-10-25T14:34:33.899997Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0169980525970459, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.897025Z", "completed_at": "2024-10-25T14:34:33.898000Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.900996Z", "completed_at": "2024-10-25T14:34:33.900996Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016997337341308594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__acute_diagnosis_icd_10_cm", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.906997Z", "completed_at": "2024-10-25T14:34:33.909998Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.915997Z", "completed_at": "2024-10-25T14:34:33.915997Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013000011444091797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_diagnosis_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.910998Z", "completed_at": "2024-10-25T14:34:33.911998Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.919997Z", "completed_at": "2024-10-25T14:34:33.919997Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015975475311279297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__always_planned_ccs_procedure_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.912997Z", "completed_at": "2024-10-25T14:34:33.914997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.919997Z", "completed_at": "2024-10-25T14:34:33.919997Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01597428321838379, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__exclusion_ccs_diagnosis_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.916998Z", "completed_at": "2024-10-25T14:34:33.918997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.921998Z", "completed_at": "2024-10-25T14:34:33.921998Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016000747680664062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__icd_10_cm_to_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.928505Z", "completed_at": "2024-10-25T14:34:33.930504Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.937508Z", "completed_at": "2024-10-25T14:34:33.937508Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01351165771484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__icd_10_pcs_to_ccs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.931506Z", "completed_at": "2024-10-25T14:34:33.933507Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.941626Z", "completed_at": "2024-10-25T14:34:33.941626Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.016629695892333984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_ccs_procedure_category", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.934508Z", "completed_at": "2024-10-25T14:34:33.936509Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.941626Z", "completed_at": "2024-10-25T14:34:33.941626Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01663804054260254, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__potentially_planned_icd_10_pcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.937508Z", "completed_at": "2024-10-25T14:34:33.940509Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.943665Z", "completed_at": "2024-10-25T14:34:33.943665Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.016159534454345703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__specialty_cohort", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.949147Z", "completed_at": "2024-10-25T14:34:33.952170Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.958147Z", "completed_at": "2024-10-25T14:34:33.958147Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01348423957824707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.readmissions__surgery_gynecology_cohort", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.953150Z", "completed_at": "2024-10-25T14:34:33.955169Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.962149Z", "completed_at": "2024-10-25T14:34:33.962149Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015514612197875977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__ansi_fips_state", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.956168Z", "completed_at": "2024-10-25T14:34:33.958147Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.963174Z", "completed_at": "2024-10-25T14:34:33.963174Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01653909683227539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__calendar", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.959172Z", "completed_at": "2024-10-25T14:34:33.961148Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.964146Z", "completed_at": "2024-10-25T14:34:33.964146Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01600480079650879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__code_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.970147Z", "completed_at": "2024-10-25T14:34:33.972163Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.978147Z", "completed_at": "2024-10-25T14:34:33.978147Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012997150421142578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__fips_county", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.974147Z", "completed_at": "2024-10-25T14:34:33.975147Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.982146Z", "completed_at": "2024-10-25T14:34:33.982146Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.014997005462646484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.reference_data__ssa_fips_state", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.975147Z", "completed_at": "2024-10-25T14:34:33.978147Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.983147Z", "completed_at": "2024-10-25T14:34:33.983147Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015997886657714844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.service_category__service_categories", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.979146Z", "completed_at": "2024-10-25T14:34:33.982146Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.984147Z", "completed_at": "2024-10-25T14:34:33.984147Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015000343322753906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__admit_source", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.991147Z", "completed_at": "2024-10-25T14:34:33.992168Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.998053Z", "completed_at": "2024-10-25T14:34:33.998053Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011905670166015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__admit_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.993522Z", "completed_at": "2024-10-25T14:34:33.995528Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:33.999748Z", "completed_at": "2024-10-25T14:34:33.999748Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012601613998413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__apr_drg", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.996182Z", "completed_at": "2024-10-25T14:34:33.997201Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.000747Z", "completed_at": "2024-10-25T14:34:34.000747Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012600183486938477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__bill_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.998727Z", "completed_at": "2024-10-25T14:34:33.999748Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.001746Z", "completed_at": "2024-10-25T14:34:34.001746Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.012599706649780273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ccs_services_procedures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.007805Z", "completed_at": "2024-10-25T14:34:34.008824Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.013804Z", "completed_at": "2024-10-25T14:34:34.013804Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010055065155029297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__claim_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.009806Z", "completed_at": "2024-10-25T14:34:34.010836Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.016918Z", "completed_at": "2024-10-25T14:34:34.016918Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012119770050048828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__discharge_disposition", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.011811Z", "completed_at": "2024-10-25T14:34:34.012807Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.017565Z", "completed_at": "2024-10-25T14:34:34.017565Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012766599655151367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__encounter_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.013804Z", "completed_at": "2024-10-25T14:34:34.015805Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.018586Z", "completed_at": "2024-10-25T14:34:34.018586Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.012780904769897461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ethnicity", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.027351Z", "completed_at": "2024-10-25T14:34:34.029351Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.033466Z", "completed_at": "2024-10-25T14:34:34.033466Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013137578964233398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__gender", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.030390Z", "completed_at": "2024-10-25T14:34:34.031355Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.036437Z", "completed_at": "2024-10-25T14:34:34.036437Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.015086650848388672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__hcpcs_level_2", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.032351Z", "completed_at": "2024-10-25T14:34:34.033466Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.037355Z", "completed_at": "2024-10-25T14:34:34.037355Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01600480079650879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__hcpcs_to_rbcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.034356Z", "completed_at": "2024-10-25T14:34:34.035439Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.038381Z", "completed_at": "2024-10-25T14:34:34.038381Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015031814575195312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_10_cm", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.043061Z", "completed_at": "2024-10-25T14:34:34.046063Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.049682Z", "completed_at": "2024-10-25T14:34:34.049682Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.009593486785888672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_10_pcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.046063Z", "completed_at": "2024-10-25T14:34:34.047568Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.052574Z", "completed_at": "2024-10-25T14:34:34.052574Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.011533498764038086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_9_cm", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.048574Z", "completed_at": "2024-10-25T14:34:34.049682Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.053607Z", "completed_at": "2024-10-25T14:34:34.053607Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01256704330444336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__icd_9_pcs", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.050578Z", "completed_at": "2024-10-25T14:34:34.052574Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.054612Z", "completed_at": "2024-10-25T14:34:34.054612Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.012503623962402344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__loinc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.059616Z", "completed_at": "2024-10-25T14:34:34.060577Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.065676Z", "completed_at": "2024-10-25T14:34:34.065676Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.010102272033691406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__loinc_deprecated_mapping", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.061574Z", "completed_at": "2024-10-25T14:34:34.062574Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.068694Z", "completed_at": "2024-10-25T14:34:34.068694Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012071609497070312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__mdc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.063654Z", "completed_at": "2024-10-25T14:34:34.065676Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.069332Z", "completed_at": "2024-10-25T14:34:34.069332Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011740446090698242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__medicare_dual_eligibility", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.066700Z", "completed_at": "2024-10-25T14:34:34.067678Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.069988Z", "completed_at": "2024-10-25T14:34:34.069988Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.011409997940063477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__medicare_orec", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.076996Z", "completed_at": "2024-10-25T14:34:34.077997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.083994Z", "completed_at": "2024-10-25T14:34:34.083994Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012000560760498047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ms_drg", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.074996Z", "completed_at": "2024-10-25T14:34:34.075996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.079997Z", "completed_at": "2024-10-25T14:34:34.079997Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.008002996444702148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__medicare_status", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.077997Z", "completed_at": "2024-10-25T14:34:34.079997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.084997Z", "completed_at": "2024-10-25T14:34:34.084997Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.012001991271972656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ms_drg_weights_los", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.080997Z", "completed_at": "2024-10-25T14:34:34.082995Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.085995Z", "completed_at": "2024-10-25T14:34:34.085995Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.012002229690551758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__ndc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.090995Z", "completed_at": "2024-10-25T14:34:34.092996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.097993Z", "completed_at": "2024-10-25T14:34:34.097993Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.009999990463256836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__nitos", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.094999Z", "completed_at": "2024-10-25T14:34:34.096998Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.100996Z", "completed_at": "2024-10-25T14:34:34.100996Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010999441146850586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__payer_type", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.098998Z", "completed_at": "2024-10-25T14:34:34.100996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.103995Z", "completed_at": "2024-10-25T14:34:34.103995Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015000104904174805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__other_provider_taxonomy", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.101997Z", "completed_at": "2024-10-25T14:34:34.102997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.104995Z", "completed_at": "2024-10-25T14:34:34.104995Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014998435974121094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__place_of_service", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.108996Z", "completed_at": "2024-10-25T14:34:34.109995Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.112997Z", "completed_at": "2024-10-25T14:34:34.112997Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.007000923156738281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__present_on_admission", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.110993Z", "completed_at": "2024-10-25T14:34:34.111996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.116993Z", "completed_at": "2024-10-25T14:34:34.116993Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010996818542480469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__provider", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.113995Z", "completed_at": "2024-10-25T14:34:34.115996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.118996Z", "completed_at": "2024-10-25T14:34:34.118996Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011998891830444336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__race", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.116993Z", "completed_at": "2024-10-25T14:34:34.118996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.120993Z", "completed_at": "2024-10-25T14:34:34.120993Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01299738883972168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__revenue_center", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.124996Z", "completed_at": "2024-10-25T14:34:34.125997Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.128993Z", "completed_at": "2024-10-25T14:34:34.128993Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.009002923965454102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__rxnorm_brand_generic", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.126995Z", "completed_at": "2024-10-25T14:34:34.127996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.131997Z", "completed_at": "2024-10-25T14:34:34.131997Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010000944137573242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__rxnorm_to_atc", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.129996Z", "completed_at": "2024-10-25T14:34:34.130996Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.135005Z", "completed_at": "2024-10-25T14:34:34.135005Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012011528015136719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__snomed_ct", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.131997Z", "completed_at": "2024-10-25T14:34:34.134005Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.136004Z", "completed_at": "2024-10-25T14:34:34.136004Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01300811767578125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__snomed_ct_transitive_closures", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.140001Z", "completed_at": "2024-10-25T14:34:34.142005Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.155184Z", "completed_at": "2024-10-25T14:34:34.155184Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01818060874938965, "adapter_response": {}, "message": null, "failures": null, "unique_id": "seed.the_tuva_project.terminology__snomed_icd_10_map", "compiled": null, "compiled_code": null, "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.143002Z", "completed_at": "2024-10-25T14:34:34.166184Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.167183Z", "completed_at": "2024-10-25T14:34:34.167183Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.030179262161254883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_condition", "compiled": true, "compiled_code": "\n\nselect\n cast(condition_id as TEXT ) as condition_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( recorded_date as date ) as recorded_date\n , try_cast( onset_date as date ) as onset_date\n , try_cast( resolved_date as date ) as resolved_date\n , cast(status as TEXT ) as status\n , cast(condition_type as TEXT ) as condition_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(condition_rank as integer ) as condition_rank\n , cast(present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.condition", "relation_name": "dev_thuxuan.test.core__stg_clinical_condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.156187Z", "completed_at": "2024-10-25T14:34:34.168184Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.170183Z", "completed_at": "2024-10-25T14:34:34.170183Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03117966651916504, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_claim_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' AS field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.161184Z", "completed_at": "2024-10-25T14:34:34.169187Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.171185Z", "completed_at": "2024-10-25T14:34:34.171185Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.031183958053588867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_condition_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_ID' AS field_name\n , case when m.condition_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_condition_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.172185Z", "completed_at": "2024-10-25T14:34:34.181184Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.186185Z", "completed_at": "2024-10-25T14:34:34.186185Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.016998291015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_condition_rank", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_RANK' AS field_name\n , case when m.condition_rank is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_rank as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_condition_rank"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.181184Z", "completed_at": "2024-10-25T14:34:34.191184Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.196183Z", "completed_at": "2024-10-25T14:34:34.196183Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024997711181640625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_condition_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'CONDITION_TYPE' AS field_name\n , case when m.condition_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(condition_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_condition_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.187185Z", "completed_at": "2024-10-25T14:34:34.196183Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.198184Z", "completed_at": "2024-10-25T14:34:34.198184Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.017998218536376953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_data_source", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.191184Z", "completed_at": "2024-10-25T14:34:34.197184Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.199187Z", "completed_at": "2024-10-25T14:34:34.199187Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019001245498657227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_encounter_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' AS field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.201183Z", "completed_at": "2024-10-25T14:34:34.206186Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.216183Z", "completed_at": "2024-10-25T14:34:34.216183Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018999814987182617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.207187Z", "completed_at": "2024-10-25T14:34:34.323729Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.329730Z", "completed_at": "2024-10-25T14:34:34.329730Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.13054180145263672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_onset_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'ONSET_DATE' AS field_name\n ,case\n when m.onset_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.onset_date <= cast('1901-01-01' as date) then 'invalid'\n when m.onset_date > m.resolved_date then 'invalid'\n when m.onset_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.onset_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.onset_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.onset_date < m.resolved_date THEN 'Onset date after resolved date'\n else null\n end as invalid_reason\n ,cast(onset_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_onset_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.217184Z", "completed_at": "2024-10-25T14:34:34.330729Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.334737Z", "completed_at": "2024-10-25T14:34:34.334737Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.12955141067504883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_patient_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date) ) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.324730Z", "completed_at": "2024-10-25T14:34:34.333737Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.335734Z", "completed_at": "2024-10-25T14:34:34.335734Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.1295480728149414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_DESCRIPTION' AS field_name\n ,case when m.present_on_admit_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(present_on_admit_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_present_on_admit_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.337737Z", "completed_at": "2024-10-25T14:34:34.350255Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.352251Z", "completed_at": "2024-10-25T14:34:34.352251Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.019520998001098633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_recorded_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'RECORDED_DATE' AS field_name\n ,CASE\n when m.recorded_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.recorded_date <= cast('1901-01-01' as date) then 'invalid'\n when m.recorded_date < m.onset_date then 'invalid'\n when m.recorded_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.recorded_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.recorded_date <= cast('1901-01-01' as date) then 'too old'\n WHEN m.recorded_date < m.onset_date THEN 'Recorded date before onset date'\n else null\n end as invalid_reason\n ,cast(recorded_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_recorded_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.344739Z", "completed_at": "2024-10-25T14:34:34.352251Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.359251Z", "completed_at": "2024-10-25T14:34:34.359251Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.023517608642578125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_resolved_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'RESOLVED_DATE' AS field_name\n , CASE\n when m.resolved_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.resolved_date <= cast('1901-01-01' as date) then 'invalid'\n when m.resolved_date < m.onset_date then 'invalid'\n when m.resolved_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.resolved_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.resolved_date <= cast('1901-01-01' as date) then 'too old'\n when m.resolved_date < m.onset_date THEN 'Resolved date before onset date'\n else null\n end as invalid_reason\n , cast(resolved_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_resolved_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.353252Z", "completed_at": "2024-10-25T14:34:34.365252Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.366254Z", "completed_at": "2024-10-25T14:34:34.366254Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0215151309967041, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_source_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'SOURCE_CODE' AS field_name\n ,case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.360253Z", "completed_at": "2024-10-25T14:34:34.367255Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.369254Z", "completed_at": "2024-10-25T14:34:34.369254Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01799917221069336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_source_code_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' AS field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.369254Z", "completed_at": "2024-10-25T14:34:34.378255Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.380252Z", "completed_at": "2024-10-25T14:34:34.380252Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.014999866485595703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_source_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' AS field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.374254Z", "completed_at": "2024-10-25T14:34:34.392355Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.394353Z", "completed_at": "2024-10-25T14:34:34.394353Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026101350784301758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_status", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'STATUS' AS field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m", "relation_name": "dev_thuxuan.data_quality.condition_status"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.381347Z", "completed_at": "2024-10-25T14:34:34.395353Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.400354Z", "completed_at": "2024-10-25T14:34:34.400354Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02709794044494629, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_encounter", "compiled": true, "compiled_code": "\n\nselect\n cast(encounter_id as TEXT) as encounter_id\n , cast(patient_id as TEXT) as patient_id\n , cast(encounter_type as TEXT) as encounter_type\n , cast('clinical' as TEXT) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer) as length_of_stay\n , cast(admit_source_code as TEXT) as admit_source_code\n , cast(admit_source_description as TEXT) as admit_source_description\n , cast(admit_type_code as TEXT) as admit_type_code\n , cast(admit_type_description as TEXT) as admit_type_description\n , cast(discharge_disposition_code as TEXT) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT) as discharge_disposition_description\n , cast(attending_provider_id as TEXT) as attending_provider_id\n , cast(attending_provider_name as TEXT) as attending_provider_name\n , cast(facility_id as TEXT) as facility_id\n , cast(facility_name as TEXT) as facility_name\n , cast(null as TEXT) as facility_type\n , cast(null as integer) as observation_flag\n , cast(null as integer) as lab_flag\n , cast(null as integer) as dme_flag\n , cast(null as integer) as ambulance_flag\n , cast(null as integer) as pharmacy_flag\n , cast(null as integer) as ed_flag\n , cast(null as integer) as delivery_flag\n , cast(null as TEXT) as delivery_type\n , cast(null as integer) as newborn_flag\n , cast(null as integer) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT) as ms_drg_code\n , cast(ms_drg_description as TEXT) as ms_drg_description\n , cast(apr_drg_code as TEXT) as apr_drg_code\n , cast(apr_drg_description as TEXT) as apr_drg_description\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(null as integer) as claim_count\n , cast(null as integer) as inst_claim_count\n , cast(null as integer) as prof_claim_count\n , cast(null as TEXT) as source_model\n , cast(data_source as TEXT) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp) as tuva_last_run\nfrom tuva.input_layer.encounter", "relation_name": "dev_thuxuan.test.core__stg_clinical_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.395353Z", "completed_at": "2024-10-25T14:34:34.402356Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.407354Z", "completed_at": "2024-10-25T14:34:34.407354Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02810072898864746, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_DESCRIPTION' AS field_name\n , case when m.admit_source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(admit_source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_admit_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.402356Z", "completed_at": "2024-10-25T14:34:34.412356Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.413352Z", "completed_at": "2024-10-25T14:34:34.414353Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.014996051788330078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'ADMIT_TYPE_DESCRIPTION' AS field_name\n ,case when m.admit_type_description is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(admit_type_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_admit_type_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.408352Z", "completed_at": "2024-10-25T14:34:34.414353Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.419356Z", "completed_at": "2024-10-25T14:34:34.419356Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01800251007080078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_allowed_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_allowed_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.415352Z", "completed_at": "2024-10-25T14:34:34.421353Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.426354Z", "completed_at": "2024-10-25T14:34:34.426354Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018999338150024414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'APR_DRG_DESCRIPTION' AS field_name\n , case when m.apr_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(apr_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_apr_drg_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.422352Z", "completed_at": "2024-10-25T14:34:34.434811Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.435813Z", "completed_at": "2024-10-25T14:34:34.435813Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020461082458496094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_charge_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_charge_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.428800Z", "completed_at": "2024-10-25T14:34:34.436814Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.441813Z", "completed_at": "2024-10-25T14:34:34.441813Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.021452903747558594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_data_source", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.436814Z", "completed_at": "2024-10-25T14:34:34.442813Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.449330Z", "completed_at": "2024-10-25T14:34:34.449330Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02297663688659668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_DESCRIPTION' AS field_name\n , case when m.discharge_disposition_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(discharge_disposition_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_discharge_disposition_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.443811Z", "completed_at": "2024-10-25T14:34:34.455330Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.456329Z", "completed_at": "2024-10-25T14:34:34.456329Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019514083862304688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_end_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_END_DATE' AS field_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_end_date < m.encounter_start_date then 'invalid'\n when m.encounter_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.encounter_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_end_date < m.encounter_start_date then 'Encounter end date before encounter start date'\n else null\n end as invalid_reason\n , cast(encounter_end_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_encounter_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.451327Z", "completed_at": "2024-10-25T14:34:34.457330Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.465332Z", "completed_at": "2024-10-25T14:34:34.465332Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02152109146118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' AS field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.457330Z", "completed_at": "2024-10-25T14:34:34.472331Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.474327Z", "completed_at": "2024-10-25T14:34:34.474327Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02399897575378418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_start_date", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_START_DATE' AS field_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.encounter_start_date > m.encounter_end_date then 'invalid'\n when m.encounter_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.encounter_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.encounter_start_date <= cast('1901-01-01' as date) then 'too old'\n when m.encounter_start_date > m.encounter_end_date then 'Encounter start date after encounter end date'\n else null\n end as invalid_reason\n , cast(encounter_start_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_encounter_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.466330Z", "completed_at": "2024-10-25T14:34:34.475586Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.477593Z", "completed_at": "2024-10-25T14:34:34.477593Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022263050079345703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_length_of_stay", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'LENGTH_OF_STAY' AS field_name\n ,case when m.length_of_stay is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(length_of_stay as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_length_of_stay"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.478592Z", "completed_at": "2024-10-25T14:34:34.488592Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.494591Z", "completed_at": "2024-10-25T14:34:34.494591Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022260665893554688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_DESCRIPTION' AS field_name\n , case when m.ms_drg_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(ms_drg_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_ms_drg_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.484591Z", "completed_at": "2024-10-25T14:34:34.493594Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.495593Z", "completed_at": "2024-10-25T14:34:34.495593Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020006895065307617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_paid_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PAID_AMOUNT' AS field_name\n ,case when m.paid_amount is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(paid_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_paid_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.489592Z", "completed_at": "2024-10-25T14:34:34.495593Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.503594Z", "completed_at": "2024-10-25T14:34:34.503594Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020003795623779297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_patient_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.496595Z", "completed_at": "2024-10-25T14:34:34.504592Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.505593Z", "completed_at": "2024-10-25T14:34:34.505593Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01700139045715332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_description", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_DESCRIPTION' AS field_name\n , case when m.primary_diagnosis_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(primary_diagnosis_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m", "relation_name": "dev_thuxuan.data_quality.encounter_primary_diagnosis_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.506595Z", "completed_at": "2024-10-25T14:34:34.521591Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.528593Z", "completed_at": "2024-10-25T14:34:34.528593Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026000022888183594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_accession_number", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ACCESSION_NUMBER' AS field_name\n , case when m.accession_number is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(accession_number as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_accession_number"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.510601Z", "completed_at": "2024-10-25T14:34:34.522592Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.529594Z", "completed_at": "2024-10-25T14:34:34.529594Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02700185775756836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_lab_result", "compiled": true, "compiled_code": "\n\nselect\n cast(lab_result_id as TEXT ) as lab_result_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(accession_number as TEXT ) as accession_number\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(source_component as TEXT ) as source_component\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(normalized_component as TEXT ) as normalized_component\n , cast(status as TEXT ) as status\n , cast(result as TEXT ) as result\n , try_cast( result_date as date ) as result_date\n , try_cast( collection_date as date ) as collection_date\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(source_abnormal_flag as TEXT ) as source_abnormal_flag\n , cast(normalized_abnormal_flag as TEXT ) as normalized_abnormal_flag\n , cast(specimen as TEXT ) as specimen\n , cast(ordering_practitioner_id as TEXT ) as ordering_practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.lab_result", "relation_name": "dev_thuxuan.test.core__stg_clinical_lab_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.523594Z", "completed_at": "2024-10-25T14:34:34.534598Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.536597Z", "completed_at": "2024-10-25T14:34:34.536597Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01700139045715332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_collection_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'COLLECTION_DATE' AS field_name\n , case\n when m.collection_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.collection_date <= cast('1901-01-01' as date) then 'invalid'\n when m.collection_date > m.result_date then 'invalid'\n when m.collection_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.collection_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.collection_date <= cast('1901-01-01' as date) then 'too old'\n when m.collection_date > m.result_date then 'Collection date after result date'\n else null\n end as invalid_reason\n , cast(collection_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_collection_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.530592Z", "completed_at": "2024-10-25T14:34:34.536597Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.539861Z", "completed_at": "2024-10-25T14:34:34.539861Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017269611358642578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.540862Z", "completed_at": "2024-10-25T14:34:34.550377Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.555381Z", "completed_at": "2024-10-25T14:34:34.555381Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020769357681274414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_encounter_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.545864Z", "completed_at": "2024-10-25T14:34:34.556380Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.558380Z", "completed_at": "2024-10-25T14:34:34.558380Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019524812698364258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_lab_result_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'LAB_RESULT_ID' as field_name\n , case when m.lab_result_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(lab_result_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_lab_result_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.551376Z", "completed_at": "2024-10-25T14:34:34.557377Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.563380Z", "completed_at": "2024-10-25T14:34:34.563380Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018516063690185547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_abnormal_flag", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_ABNORMAL_FLAG' as field_name\n , case when m.normalized_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_abnormal_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_abnormal_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.558380Z", "completed_at": "2024-10-25T14:34:34.564379Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.571377Z", "completed_at": "2024-10-25T14:34:34.571377Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02100062370300293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.566380Z", "completed_at": "2024-10-25T14:34:34.574323Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.580332Z", "completed_at": "2024-10-25T14:34:34.580332Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.017951011657714844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.575327Z", "completed_at": "2024-10-25T14:34:34.588329Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.595332Z", "completed_at": "2024-10-25T14:34:34.595332Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.029955148696899414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' as field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.581330Z", "completed_at": "2024-10-25T14:34:34.594332Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.597373Z", "completed_at": "2024-10-25T14:34:34.597373Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.026994943618774414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.589332Z", "completed_at": "2024-10-25T14:34:34.598372Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.606375Z", "completed_at": "2024-10-25T14:34:34.606375Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026042699813842773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.602374Z", "completed_at": "2024-10-25T14:34:34.609371Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.612869Z", "completed_at": "2024-10-25T14:34:34.612869Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.018537044525146484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_result", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT' AS field_name\n , case when m.result is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(result as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.612869Z", "completed_at": "2024-10-25T14:34:34.630186Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.631164Z", "completed_at": "2024-10-25T14:34:34.631164Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023790597915649414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_result_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'RESULT_DATE' as field_name\n , case\n when m.result_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.result_date <= cast('1901-01-01' as date) then 'invalid'\n when m.result_date < m.collection_date then 'invalid'\n when m.result_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.result_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.result_date <= cast('1901-01-01' as date) then 'too old'\n when m.result_date < m.collection_date then 'Result date before collection date'\n else null\n end as invalid_reason\n , cast(result_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_result_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.618952Z", "completed_at": "2024-10-25T14:34:34.630186Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.632636Z", "completed_at": "2024-10-25T14:34:34.632636Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.024263620376586914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_abnormal_flag", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_ABNORMAL_FLAG' AS field_name\n , case when m.source_abnormal_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_abnormal_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_abnormal_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.625145Z", "completed_at": "2024-10-25T14:34:34.632636Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.637625Z", "completed_at": "2024-10-25T14:34:34.637625Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025783777236938477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' AS field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.633581Z", "completed_at": "2024-10-25T14:34:34.639602Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.641603Z", "completed_at": "2024-10-25T14:34:34.641603Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.011416435241699219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.642602Z", "completed_at": "2024-10-25T14:34:34.656311Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.657959Z", "completed_at": "2024-10-25T14:34:34.657959Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01935720443725586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_component", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_COMPONENT' AS field_name\n , case when m.source_component is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_component as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_component"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.646604Z", "completed_at": "2024-10-25T14:34:34.656311Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.657959Z", "completed_at": "2024-10-25T14:34:34.657959Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018357276916503906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.651568Z", "completed_at": "2024-10-25T14:34:34.657318Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.658980Z", "completed_at": "2024-10-25T14:34:34.658980Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018375873565673828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' AS field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.659991Z", "completed_at": "2024-10-25T14:34:34.668981Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.670979Z", "completed_at": "2024-10-25T14:34:34.670979Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01539158821105957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' AS field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.671982Z", "completed_at": "2024-10-25T14:34:34.686070Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.688063Z", "completed_at": "2024-10-25T14:34:34.688063Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02001500129699707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_source_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n ,'LAB_RESULT' AS table_name\n ,'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n ,'SOURCE_UNITS' AS field_name\n ,case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(source_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_source_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.675979Z", "completed_at": "2024-10-25T14:34:34.687655Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.689375Z", "completed_at": "2024-10-25T14:34:34.689375Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02039313316345215, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_specimen", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'SPECIMEN' as field_name\n , case when m.specimen is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specimen as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_specimen"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.681979Z", "completed_at": "2024-10-25T14:34:34.689068Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.690452Z", "completed_at": "2024-10-25T14:34:34.690452Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02147078514099121, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_status", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'STATUS' as field_name\n , case when m.status is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(status as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m", "relation_name": "dev_thuxuan.data_quality.lab_result_status"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.691460Z", "completed_at": "2024-10-25T14:34:34.700381Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.702387Z", "completed_at": "2024-10-25T14:34:34.702387Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015168905258178711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_location", "compiled": true, "compiled_code": "\n\nselect\n cast(location_id as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(name as TEXT ) as name\n , cast(facility_type as TEXT ) as facility_type\n , cast(parent_organization as TEXT ) as parent_organization\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.location", "relation_name": "dev_thuxuan.test.core__stg_clinical_location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.702387Z", "completed_at": "2024-10-25T14:34:34.722027Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.725033Z", "completed_at": "2024-10-25T14:34:34.725033Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.026653528213500977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_address", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ADDRESS' AS field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_address"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.710471Z", "completed_at": "2024-10-25T14:34:34.724055Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.727036Z", "completed_at": "2024-10-25T14:34:34.727036Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.027649879455566406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_city", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'CITY' AS field_name\n , case when m.city is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(city as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_city"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.717439Z", "completed_at": "2024-10-25T14:34:34.726036Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.728032Z", "completed_at": "2024-10-25T14:34:34.728032Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026651859283447266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.730033Z", "completed_at": "2024-10-25T14:34:34.737129Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.743130Z", "completed_at": "2024-10-25T14:34:34.743130Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019075632095336914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_facility_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'FACILITY_TYPE' AS field_name\n ,case when m.facility_type is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(facility_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_facility_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.738129Z", "completed_at": "2024-10-25T14:34:34.754839Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.756837Z", "completed_at": "2024-10-25T14:34:34.756837Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021614789962768555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_latitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_latitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.744129Z", "completed_at": "2024-10-25T14:34:34.754839Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.757937Z", "completed_at": "2024-10-25T14:34:34.757937Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.021807432174682617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_location_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'LOCATION' AS table_name\n ,'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n ,'LOCATION_ID' AS field_name\n ,case when m.location_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(location_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_location_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.749839Z", "completed_at": "2024-10-25T14:34:34.757937Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.759837Z", "completed_at": "2024-10-25T14:34:34.759837Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02170848846435547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_longitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_longitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.761732Z", "completed_at": "2024-10-25T14:34:34.769130Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.775138Z", "completed_at": "2024-10-25T14:34:34.775138Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01930093765258789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NAME' as field_name\n , case when m.name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.769130Z", "completed_at": "2024-10-25T14:34:34.786136Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.788390Z", "completed_at": "2024-10-25T14:34:34.788390Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02256011962890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_parent_organization", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'PARENT_ORGANIZATION' AS field_name\n , case when m.parent_organization is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(parent_organization as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_parent_organization"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.775138Z", "completed_at": "2024-10-25T14:34:34.787135Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.789399Z", "completed_at": "2024-10-25T14:34:34.789399Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.023662567138671875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_state", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_state"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.780250Z", "completed_at": "2024-10-25T14:34:34.789399Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.791403Z", "completed_at": "2024-10-25T14:34:34.791403Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.023409366607666016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_zip_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m", "relation_name": "dev_thuxuan.data_quality.location_zip_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.792410Z", "completed_at": "2024-10-25T14:34:34.805220Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.807329Z", "completed_at": "2024-10-25T14:34:34.807329Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020194053649902344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_medication", "compiled": true, "compiled_code": "\n\nselect\n cast(medication_id as TEXT ) as medication_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , try_cast( dispensing_date as date ) as dispensing_date\n , try_cast( prescribing_date as date ) as prescribing_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(rxnorm_code as TEXT ) as rxnorm_code\n , cast(rxnorm_description as TEXT ) as rxnorm_description \n , cast(atc_code as TEXT ) as atc_code\n , cast(atc_description as TEXT ) as atc_description\n , cast(route as TEXT ) as route\n , cast(strength as TEXT ) as strength\n , cast(quantity as integer ) as quantity\n , cast(quantity_unit as TEXT ) as quantity_unit\n , cast(days_supply as integer ) as days_supply\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.medication", "relation_name": "dev_thuxuan.test.core__stg_clinical_medication"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.808422Z", "completed_at": "2024-10-25T14:34:34.823352Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.824211Z", "completed_at": "2024-10-25T14:34:34.824211Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022738218307495117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_atc_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_DESCRIPTION' as field_name\n , case when m.atc_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(atc_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_atc_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.813356Z", "completed_at": "2024-10-25T14:34:34.824211Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.826217Z", "completed_at": "2024-10-25T14:34:34.826217Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020997047424316406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' AS field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.818354Z", "completed_at": "2024-10-25T14:34:34.825276Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.833573Z", "completed_at": "2024-10-25T14:34:34.833573Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02734684944152832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_days_supply", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DAYS_SUPPLY' AS field_name\n , case when m.days_supply is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_days_supply"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.828567Z", "completed_at": "2024-10-25T14:34:34.836607Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.838605Z", "completed_at": "2024-10-25T14:34:34.838605Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015253067016601562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_dispensing_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'DISPENSING_DATE' as field_name\n , case\n when m.dispensing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.dispensing_date < m.prescribing_date then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.dispensing_date <= cast('1901-01-01' as date) then 'too old'\n when m.dispensing_date < m.prescribing_date then 'Dispensing date before prescribing date'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_dispensing_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.838605Z", "completed_at": "2024-10-25T14:34:34.852329Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.854230Z", "completed_at": "2024-10-25T14:34:34.854230Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01963019371032715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_encounter_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.843606Z", "completed_at": "2024-10-25T14:34:34.853229Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.855229Z", "completed_at": "2024-10-25T14:34:34.855998Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020337820053100586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_medication_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'MEDICATION_ID' AS field_name\n , case when m.medication_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(medication_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_medication_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.847607Z", "completed_at": "2024-10-25T14:34:34.854230Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.855998Z", "completed_at": "2024-10-25T14:34:34.855998Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01834845542907715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_CODE' as field_name\n , case when m.ndc_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(ndc_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_ndc_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.857002Z", "completed_at": "2024-10-25T14:34:34.864007Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.866831Z", "completed_at": "2024-10-25T14:34:34.866831Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014501810073852539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.867960Z", "completed_at": "2024-10-25T14:34:34.884147Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.887151Z", "completed_at": "2024-10-25T14:34:34.887151Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024143218994140625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.873142Z", "completed_at": "2024-10-25T14:34:34.885147Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.888147Z", "completed_at": "2024-10-25T14:34:34.888147Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.024139881134033203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_prescribing_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'PRESCRIBING_DATE' as field_name\n , case\n when m.prescribing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'invalid'\n when m.prescribing_date > m.dispensing_date then 'invalid'\n when m.prescribing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.prescribing_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.prescribing_date <= cast('1901-01-01' as date) then 'too old'\n when m.prescribing_date > m.dispensing_date then 'Prescribing date after dispensing date'\n else null\n end as invalid_reason\n , cast(prescribing_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_prescribing_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.878200Z", "completed_at": "2024-10-25T14:34:34.887151Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.890472Z", "completed_at": "2024-10-25T14:34:34.890472Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02546525001525879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_quantity", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY' as field_name\n , case when m.quantity is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_quantity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.890472Z", "completed_at": "2024-10-25T14:34:34.899497Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.905501Z", "completed_at": "2024-10-25T14:34:34.905501Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021353721618652344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_quantity_unit", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'QUANTITY_UNIT' as field_name\n , case when m.quantity_unit is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity_unit as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_quantity_unit"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.901536Z", "completed_at": "2024-10-25T14:34:34.919498Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.921503Z", "completed_at": "2024-10-25T14:34:34.921503Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0240023136138916, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_route", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ROUTE' as field_name\n , case when m.route is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(route as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_route"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.906578Z", "completed_at": "2024-10-25T14:34:34.920498Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.923400Z", "completed_at": "2024-10-25T14:34:34.923400Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02490234375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_DESCRIPTION' as field_name\n , case when m.rxnorm_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(rxnorm_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_rxnorm_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.913498Z", "completed_at": "2024-10-25T14:34:34.922504Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.928991Z", "completed_at": "2024-10-25T14:34:34.928991Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.028423547744750977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.924555Z", "completed_at": "2024-10-25T14:34:34.931072Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.933042Z", "completed_at": "2024-10-25T14:34:34.933042Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.013544321060180664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.934045Z", "completed_at": "2024-10-25T14:34:34.952873Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.954383Z", "completed_at": "2024-10-25T14:34:34.954383Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024377822875976562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.939050Z", "completed_at": "2024-10-25T14:34:34.952873Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.955465Z", "completed_at": "2024-10-25T14:34:34.955465Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.023453712463378906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_strength", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'STRENGTH' as field_name\n , case when m.strength is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(strength as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m", "relation_name": "dev_thuxuan.data_quality.medication_strength"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.943141Z", "completed_at": "2024-10-25T14:34:34.954383Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.959389Z", "completed_at": "2024-10-25T14:34:34.959389Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027503252029418945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_observation", "compiled": true, "compiled_code": "\n\n\nselect\n cast(observation_id as TEXT ) as observation_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(panel_id as TEXT ) as panel_id\n , try_cast( observation_date as date ) as observation_date\n , cast(observation_type as TEXT ) as observation_type\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(result as TEXT ) as result\n , cast(source_units as TEXT ) as source_units\n , cast(normalized_units as TEXT ) as normalized_units\n , cast(source_reference_range_low as TEXT ) as source_reference_range_low\n , cast(source_reference_range_high as TEXT ) as source_reference_range_high\n , cast(normalized_reference_range_low as TEXT ) as normalized_reference_range_low\n , cast(normalized_reference_range_high as TEXT ) as normalized_reference_range_high\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.observation", "relation_name": "dev_thuxuan.test.core__stg_clinical_observation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.955465Z", "completed_at": "2024-10-25T14:34:34.963545Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.964547Z", "completed_at": "2024-10-25T14:34:34.964547Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.013350963592529297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.966579Z", "completed_at": "2024-10-25T14:34:34.979300Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.981320Z", "completed_at": "2024-10-25T14:34:34.981320Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018774986267089844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_encounter_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'ENCOUNTER_ID' as field_name\n ,case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.971247Z", "completed_at": "2024-10-25T14:34:34.981320Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.986801Z", "completed_at": "2024-10-25T14:34:34.986801Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02325606346130371, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when m.normalized_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.975273Z", "completed_at": "2024-10-25T14:34:34.982429Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.987913Z", "completed_at": "2024-10-25T14:34:34.987913Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024254322052001953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when m.normalized_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.982795Z", "completed_at": "2024-10-25T14:34:34.989801Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:34.991838Z", "completed_at": "2024-10-25T14:34:34.991838Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01253819465637207, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' as field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.994841Z", "completed_at": "2024-10-25T14:34:35.008386Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.015387Z", "completed_at": "2024-10-25T14:34:35.015387Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02455306053161621, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_HIGH' as field_name\n , case when m.normalized_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_normalized_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:34.999256Z", "completed_at": "2024-10-25T14:34:35.009387Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.017390Z", "completed_at": "2024-10-25T14:34:35.017390Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.025551795959472656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_REFERENCE_RANGE_LOW' AS field_name\n , case when m.normalized_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_normalized_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.003388Z", "completed_at": "2024-10-25T14:34:35.017390Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.020390Z", "completed_at": "2024-10-25T14:34:35.020390Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027471542358398438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_normalized_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_UNITS' as field_name\n , case when m.normalized_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(normalized_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_normalized_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.010386Z", "completed_at": "2024-10-25T14:34:35.020390Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.023389Z", "completed_at": "2024-10-25T14:34:35.023389Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020998001098632812, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_observation_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_DATE' as field_name\n , case\n when m.observation_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.observation_date <= cast('1901-01-01' as date) then 'invalid'\n when m.observation_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.observation_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.observation_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(observation_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_observation_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.027386Z", "completed_at": "2024-10-25T14:34:35.039582Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.048588Z", "completed_at": "2024-10-25T14:34:35.048588Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02620244026184082, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_observation_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_ID' as field_name\n , case when m.observation_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_observation_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.034646Z", "completed_at": "2024-10-25T14:34:35.048588Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.050737Z", "completed_at": "2024-10-25T14:34:35.050737Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.027348995208740234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_observation_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'OBSERVATION_TYPE' as field_name\n , case when m.observation_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(observation_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_observation_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.040590Z", "completed_at": "2024-10-25T14:34:35.049632Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.052737Z", "completed_at": "2024-10-25T14:34:35.052737Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026350975036621094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_panel_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PANEL_ID' as field_name\n , case when m.panel_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(panel_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_panel_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.044593Z", "completed_at": "2024-10-25T14:34:35.050737Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.053738Z", "completed_at": "2024-10-25T14:34:35.053738Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020218610763549805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.056749Z", "completed_at": "2024-10-25T14:34:35.063097Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.075101Z", "completed_at": "2024-10-25T14:34:35.075101Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023363351821899414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_result", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n ,'OBSERVATION' AS table_name\n ,'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n ,'RESULT' as field_name\n ,case when m.result is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(substring(result, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.063097Z", "completed_at": "2024-10-25T14:34:35.077221Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.078149Z", "completed_at": "2024-10-25T14:34:35.078149Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02191329002380371, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.068202Z", "completed_at": "2024-10-25T14:34:35.078149Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.079800Z", "completed_at": "2024-10-25T14:34:35.079800Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020045042037963867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.072101Z", "completed_at": "2024-10-25T14:34:35.079800Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.081805Z", "completed_at": "2024-10-25T14:34:35.081805Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02071404457092285, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.082805Z", "completed_at": "2024-10-25T14:34:35.092806Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.100469Z", "completed_at": "2024-10-25T14:34:35.100469Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021178245544433594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_high", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_HIGH' as field_name\n , case when m.source_reference_range_high is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_high as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_source_reference_range_high"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.093805Z", "completed_at": "2024-10-25T14:34:35.115308Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.125001Z", "completed_at": "2024-10-25T14:34:35.125001Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04219627380371094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_reference_range_low", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS table_name\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_REFERENCE_RANGE_LOW' as field_name\n , case when m.source_reference_range_low is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_reference_range_low as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_source_reference_range_low"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.101258Z", "completed_at": "2024-10-25T14:34:35.124003Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.126004Z", "completed_at": "2024-10-25T14:34:35.126004Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03719925880432129, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__observation_source_units", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.observation_date,cast('1900-01-01' as date)) as source_date\n , 'OBSERVATION' AS TABLE_NAME\n , 'Observation ID' as drill_down_key\n , coalesce(observation_id, 'NULL') AS drill_down_value\n , 'SOURCE_UNITS' as field_name\n , case when m.source_units is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_units as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.observation m", "relation_name": "dev_thuxuan.data_quality.observation_source_units"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.106299Z", "completed_at": "2024-10-25T14:34:35.127001Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.129001Z", "completed_at": "2024-10-25T14:34:35.129001Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03719592094421387, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_patient", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n select\n cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run_datetime\n , cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date ) as tuva_last_run_date\n)\nSELECT\n cast(patient_id as TEXT ) as patient_id\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(sex as TEXT ) as sex\n , cast(race as TEXT ) as race\n , try_cast( birth_date as date ) as birth_date\n , try_cast( death_date as date ) as death_date\n , cast(death_flag as integer ) as death_flag\n , cast(social_security_number as TEXT ) as social_security_number\n , cast(address as TEXT ) as address\n , cast(city as TEXT ) as city\n , cast(state as TEXT ) as state\n , cast(zip_code as TEXT ) as zip_code\n , cast(county as TEXT ) as county\n , cast(latitude as float ) as latitude\n , cast(longitude as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nFROM tuva.input_layer.patient\ncross join tuva_last_run", "relation_name": "dev_thuxuan.test.core__stg_clinical_patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.131002Z", "completed_at": "2024-10-25T14:34:35.138793Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.150385Z", "completed_at": "2024-10-25T14:34:35.150385Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024380922317504883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_address", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ADDRESS' as field_name\n , case when m.address is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(address as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_address"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.138793Z", "completed_at": "2024-10-25T14:34:35.151128Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.158134Z", "completed_at": "2024-10-25T14:34:35.158134Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.028132200241088867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_birth_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'BIRTH_DATE' AS field_name\n , case\n when m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.birth_date <= cast('1901-01-01' as date) then 'invalid'\n when m.birth_date > m.death_date then 'invalid'\n when m.birth_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.birth_date <= cast('1901-01-01' as date) then 'too old'\n when m.birth_date > m.death_date then 'Birth date after death date'\n else null\n end as invalid_reason\n , cast(birth_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_birth_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.144799Z", "completed_at": "2024-10-25T14:34:35.157145Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.159137Z", "completed_at": "2024-10-25T14:34:35.159137Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02304220199584961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_city", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'CITY' AS field_name\n ,case when m.city is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(city as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_city"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.151128Z", "completed_at": "2024-10-25T14:34:35.159137Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.161155Z", "completed_at": "2024-10-25T14:34:35.161155Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.023062944412231445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_county", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n ,'PATIENT' AS table_name\n ,'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n ,'COUNTY' as field_name\n ,case when m.county is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(county as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_county"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.164136Z", "completed_at": "2024-10-25T14:34:35.181325Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.182327Z", "completed_at": "2024-10-25T14:34:35.182327Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022162675857543945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.170318Z", "completed_at": "2024-10-25T14:34:35.183327Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.189683Z", "completed_at": "2024-10-25T14:34:35.189683Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02754688262939453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_death_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_DATE' AS field_name\n , case\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date > m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date > m.birth_date then 'Death date after birth date'\n else null\n end as invalid_reason\n , cast(death_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_death_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.175423Z", "completed_at": "2024-10-25T14:34:35.188302Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.190685Z", "completed_at": "2024-10-25T14:34:35.190685Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02754831314086914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_death_flag", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'DEATH_FLAG' as field_name\n , case when m.death_flag is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(death_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_death_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.183327Z", "completed_at": "2024-10-25T14:34:35.192613Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.195987Z", "completed_at": "2024-10-25T14:34:35.195987Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026174068450927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_first_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_first_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.197986Z", "completed_at": "2024-10-25T14:34:35.217094Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.217911Z", "completed_at": "2024-10-25T14:34:35.217911Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.026226043701171875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_last_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' AS field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_last_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.206984Z", "completed_at": "2024-10-25T14:34:35.219015Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.224673Z", "completed_at": "2024-10-25T14:34:35.224673Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.027689218521118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_latitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LATITUDE' as field_name\n , case when m.latitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(latitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_latitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.212493Z", "completed_at": "2024-10-25T14:34:35.219015Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.225680Z", "completed_at": "2024-10-25T14:34:35.225680Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.028696537017822266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_longitude", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'LONGITUDE' as field_name\n , case when m.longitude is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(longitude as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_longitude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.219943Z", "completed_at": "2024-10-25T14:34:35.227681Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.229679Z", "completed_at": "2024-10-25T14:34:35.229679Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022695302963256836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' as field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.230681Z", "completed_at": "2024-10-25T14:34:35.243702Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.250106Z", "completed_at": "2024-10-25T14:34:35.250106Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02342510223388672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_state", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'STATE' as field_name\n , case when m.state is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(state as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_state"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.236799Z", "completed_at": "2024-10-25T14:34:35.250833Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.257218Z", "completed_at": "2024-10-25T14:34:35.257218Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.028520822525024414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_zip_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'ZIP_CODE' as field_name\n , case when m.zip_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(zip_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m", "relation_name": "dev_thuxuan.data_quality.patient_zip_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.244116Z", "completed_at": "2024-10-25T14:34:35.256703Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.259316Z", "completed_at": "2024-10-25T14:34:35.259316Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.029636621475219727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_practitioner", "compiled": true, "compiled_code": "\n\nselect\n cast(practitioner_id as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(first_name as TEXT ) as first_name\n , cast(last_name as TEXT ) as last_name\n , cast(practice_affiliation as TEXT ) as practice_affiliation\n , cast(specialty as TEXT ) as specialty\n , cast(sub_specialty as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.practitioner", "relation_name": "dev_thuxuan.test.core__stg_clinical_practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.250833Z", "completed_at": "2024-10-25T14:34:35.258804Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.260986Z", "completed_at": "2024-10-25T14:34:35.260986Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01807999610900879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.262600Z", "completed_at": "2024-10-25T14:34:35.271156Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.282678Z", "completed_at": "2024-10-25T14:34:35.282678Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024389266967773438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_first_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'FIRST_NAME' as field_name\n , case when m.first_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(first_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_first_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.272550Z", "completed_at": "2024-10-25T14:34:35.289553Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.291946Z", "completed_at": "2024-10-25T14:34:35.291946Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.029861927032470703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_last_name", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'LAST_NAME' as field_name\n , case when m.last_name is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(last_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_last_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.277553Z", "completed_at": "2024-10-25T14:34:35.289975Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.293755Z", "completed_at": "2024-10-25T14:34:35.293755Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025971651077270508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_practice_affiliation", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTICE_AFFILIATION' AS field_name\n , case when m.practice_affiliation is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practice_affiliation as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_practice_affiliation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.284552Z", "completed_at": "2024-10-25T14:34:35.293314Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.294896Z", "completed_at": "2024-10-25T14:34:35.294896Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02510356903076172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' as field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.297778Z", "completed_at": "2024-10-25T14:34:35.310191Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.319139Z", "completed_at": "2024-10-25T14:34:35.319139Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025383710861206055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_specialty", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SPECIALTY' as field_name\n , case when m.specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(specialty as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_specialty"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.305780Z", "completed_at": "2024-10-25T14:34:35.324227Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.326138Z", "completed_at": "2024-10-25T14:34:35.326138Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02935504913330078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_sub_specialty", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'SUB_SPECIALTY' as field_name\n , case when m.sub_specialty is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(sub_specialty as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m", "relation_name": "dev_thuxuan.data_quality.practitioner_sub_specialty"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.310997Z", "completed_at": "2024-10-25T14:34:35.325167Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.327139Z", "completed_at": "2024-10-25T14:34:35.327139Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025356292724609375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_clinical_procedure", "compiled": true, "compiled_code": "\n\nselect\n cast(procedure_id as TEXT ) as procedure_id \n , cast(patient_id as TEXT ) as patient_id\n , cast(encounter_id as TEXT ) as encounter_id\n , cast(claim_id as TEXT ) as claim_id\n , try_cast( procedure_date as date ) as procedure_date\n , cast(source_code_type as TEXT ) as source_code_type\n , cast(source_code as TEXT ) as source_code\n , cast(source_description as TEXT ) as source_description\n , cast(normalized_code_type as TEXT ) as normalized_code_type\n , cast(normalized_code as TEXT ) as normalized_code\n , cast(normalized_description as TEXT ) as normalized_description\n , cast(modifier_1 as TEXT ) as modifier_1\n , cast(modifier_2 as TEXT ) as modifier_2\n , cast(modifier_3 as TEXT ) as modifier_3\n , cast(modifier_4 as TEXT ) as modifier_4\n , cast(modifier_5 as TEXT ) as modifier_5\n , cast(practitioner_id as TEXT ) as practitioner_id\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom tuva.input_layer.procedure", "relation_name": "dev_thuxuan.test.core__stg_clinical_procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.319139Z", "completed_at": "2024-10-25T14:34:35.327139Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.329703Z", "completed_at": "2024-10-25T14:34:35.329703Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025923967361450195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_claim_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'CLAIM_ID' as field_name\n , case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(claim_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.330757Z", "completed_at": "2024-10-25T14:34:35.337007Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.342324Z", "completed_at": "2024-10-25T14:34:35.342324Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01518559455871582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_data_source", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'DATA_SOURCE' as field_name\n , case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.338302Z", "completed_at": "2024-10-25T14:34:35.351822Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.353823Z", "completed_at": "2024-10-25T14:34:35.353823Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.023065805435180664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_encounter_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_ID' as field_name\n , case when m.encounter_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(encounter_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.343383Z", "completed_at": "2024-10-25T14:34:35.352822Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.355036Z", "completed_at": "2024-10-25T14:34:35.355036Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019082069396972656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_DESCRIPTION' AS field_name\n , case when m.normalized_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(normalized_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_normalized_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.347307Z", "completed_at": "2024-10-25T14:34:35.353823Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.356582Z", "completed_at": "2024-10-25T14:34:35.356582Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019574880599975586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_patient_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PATIENT_ID' AS field_name\n , case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.357606Z", "completed_at": "2024-10-25T14:34:35.365638Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.371614Z", "completed_at": "2024-10-25T14:34:35.371614Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018792390823364258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PRACTITIONER_ID' AS field_name\n , case when m.practitioner_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.366605Z", "completed_at": "2024-10-25T14:34:35.381605Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.383608Z", "completed_at": "2024-10-25T14:34:35.383608Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020899534225463867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_date", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_DATE' as field_name\n , case\n when m.procedure_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date <= cast('1901-01-01' as date) then 'invalid'\n when m.procedure_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.procedure_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n , cast(procedure_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_procedure_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.372612Z", "completed_at": "2024-10-25T14:34:35.383608Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.385608Z", "completed_at": "2024-10-25T14:34:35.385608Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022000551223754883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_procedure_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'PROCEDURE_ID' AS field_name\n , case when m.procedure_id is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(procedure_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_procedure_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.376701Z", "completed_at": "2024-10-25T14:34:35.384606Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.386605Z", "completed_at": "2024-10-25T14:34:35.386605Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02199721336364746, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE' as field_name\n , case when m.source_code is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.387605Z", "completed_at": "2024-10-25T14:34:35.393307Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.400511Z", "completed_at": "2024-10-25T14:34:35.400511Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01790595054626465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_source_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_CODE_TYPE' as field_name\n , case when m.source_code_type is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(source_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_source_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.395477Z", "completed_at": "2024-10-25T14:34:35.407500Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.409499Z", "completed_at": "2024-10-25T14:34:35.409499Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018198013305664062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_source_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'SOURCE_DESCRIPTION' as field_name\n , case when m.source_description is not null then 'valid' else 'null' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(substring(source_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m", "relation_name": "dev_thuxuan.data_quality.procedure_source_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.401501Z", "completed_at": "2024-10-25T14:34:35.408500Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.410544Z", "completed_at": "2024-10-25T14:34:35.410544Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01723766326904297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.eligibility", "compiled": true, "compiled_code": "select\n patient_id\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , subscriber_relation\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom dev_thuxuan._tuva_synthetic.eligibility_seed", "relation_name": "tuva.input_layer.eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.404595Z", "completed_at": "2024-10-25T14:34:35.410544Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.414446Z", "completed_at": "2024-10-25T14:34:35.414446Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019870996475219727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.medical_claim", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom dev_thuxuan._tuva_synthetic.medical_claim_seed", "relation_name": "tuva.input_layer.medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.412026Z", "completed_at": "2024-10-25T14:34:35.418613Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.420611Z", "completed_at": "2024-10-25T14:34:35.420611Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.013110637664794922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.pharmacy_claim", "compiled": true, "compiled_code": "select\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom dev_thuxuan._tuva_synthetic.pharmacy_claim_seed", "relation_name": "tuva.input_layer.pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.420611Z", "completed_at": "2024-10-25T14:34:35.435616Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.437419Z", "completed_at": "2024-10-25T14:34:35.437419Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.021812915802001953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.input_layer.provider_attribution", "compiled": true, "compiled_code": "select\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , payer_attributed_provider\n , payer_attributed_provider_practice\n , payer_attributed_provider_organization\n , payer_attributed_provider_lob\n , custom_attributed_provider\n , custom_attributed_provider_practice\n , custom_attributed_provider_organization\n , custom_attributed_provider_lob\nfrom dev_thuxuan._tuva_synthetic.provider_attribution_seed", "relation_name": "tuva.input_layer.provider_attribution"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.423612Z", "completed_at": "2024-10-25T14:34:35.437419Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.438426Z", "completed_at": "2024-10-25T14:34:35.438426Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02081441879272461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__dx_vertical_pivot", "compiled": true, "compiled_code": "\n\nwith codes as (\n \n select\n icd_10_cm_code as code, \n icd_10_cm_code_description as code_description,\n -- loop to generate columns for CCSR categories 1-6\n ccsr_category_1,\n ccsr_category_1_description,\n ccsr_category_2,\n ccsr_category_2_description,\n ccsr_category_3,\n ccsr_category_3_description,\n ccsr_category_4,\n ccsr_category_4_description,\n ccsr_category_5,\n ccsr_category_5_description,\n ccsr_category_6,\n ccsr_category_6_description,\n default_ccsr_category_ip,\n default_ccsr_category_op\n from dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map\n\n), long_union as (\n -- generate select & union statements to pivot category columns to rows\n \n select \n code,\n code_description,\n substring(ccsr_category_1, 1, 3) as ccsr_parent_category,\n ccsr_category_1 as ccsr_category,\n ccsr_category_1_description as ccsr_category_description,\n 1 as ccsr_category_rank,\n CASE WHEN ccsr_category_1 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_1 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_2, 1, 3) as ccsr_parent_category,\n ccsr_category_2 as ccsr_category,\n ccsr_category_2_description as ccsr_category_description,\n 2 as ccsr_category_rank,\n CASE WHEN ccsr_category_2 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_2 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_3, 1, 3) as ccsr_parent_category,\n ccsr_category_3 as ccsr_category,\n ccsr_category_3_description as ccsr_category_description,\n 3 as ccsr_category_rank,\n CASE WHEN ccsr_category_3 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_3 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_4, 1, 3) as ccsr_parent_category,\n ccsr_category_4 as ccsr_category,\n ccsr_category_4_description as ccsr_category_description,\n 4 as ccsr_category_rank,\n CASE WHEN ccsr_category_4 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_4 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_5, 1, 3) as ccsr_parent_category,\n ccsr_category_5 as ccsr_category,\n ccsr_category_5_description as ccsr_category_description,\n 5 as ccsr_category_rank,\n CASE WHEN ccsr_category_5 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_5 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n union all\n select \n code,\n code_description,\n substring(ccsr_category_6, 1, 3) as ccsr_parent_category,\n ccsr_category_6 as ccsr_category,\n ccsr_category_6_description as ccsr_category_description,\n 6 as ccsr_category_rank,\n CASE WHEN ccsr_category_6 = default_ccsr_category_ip THEN 1 ELSE 0 END as is_ip_default_category,\n CASE WHEN ccsr_category_6 = default_ccsr_category_op THEN 1 ELSE 0 END as is_op_default_category\n from codes \n \n\n)\n\nselect distinct\n *,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom long_union\n-- as not all diagnosis codes have multiple categories, we can discard nulls\nwhere ccsr_category is not null", "relation_name": "dev_thuxuan.ccsr.dx_vertical_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.431612Z", "completed_at": "2024-10-25T14:34:35.438426Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.443430Z", "completed_at": "2024-10-25T14:34:35.443430Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.023818492889404297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__procedure_category_map", "compiled": true, "compiled_code": "\n\nselect \n icd_10_pcs as code,\n icd_10_pcs_description as code_description,\n prccsr as ccsr_category,\n substring(prccsr, 1, 3) as ccsr_parent_category,\n prccsr_description as ccsr_category_description,\n clinical_domain,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ccsr._value_set_prccsr_v2023_1_cleaned_map", "relation_name": "dev_thuxuan.ccsr.procedure_category_map"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.440427Z", "completed_at": "2024-10-25T14:34:35.445425Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.447425Z", "completed_at": "2024-10-25T14:34:35.447425Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01080942153930664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.clinical_concept_library__value_set_member_relevant_fields", "compiled": true, "compiled_code": "with value_set_member_relevant_fields as (\nselect \n aa.concept_id,\n aa.concept_name,\n aa.concept_type,\n \n bb.value_set_member_id,\n bb.code,\n bb.coding_system_id,\n bb.include_descendants,\n\n cc.coding_system_name\n \nfrom dev_thuxuan.clinical_concept_library.clinical_concepts aa\n\nleft join dev_thuxuan.clinical_concept_library.value_set_members bb\non aa.concept_id = bb.concept_id\n\nleft join dev_thuxuan.clinical_concept_library.coding_systems cc\non bb.coding_system_id = cc.coding_system_id\n)\n\n\nselect *\nfrom value_set_member_relevant_fields", "relation_name": "dev_thuxuan.clinical_concept_library.value_set_member_relevant_fields"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.448425Z", "completed_at": "2024-10-25T14:34:35.467936Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.468939Z", "completed_at": "2024-10-25T14:34:35.468939Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.024513959884643555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd10_icd10.d04e7f84c7", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd10\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd10\nwhere icd10 is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.458935Z", "completed_at": "2024-10-25T14:34:35.469935Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.470935Z", "completed_at": "2024-10-25T14:34:35.470935Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025509357452392578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd10_icd10.3d55f2b2dd", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd10 as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd10\nwhere icd10 is not null\ngroup by icd10\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.463935Z", "completed_at": "2024-10-25T14:34:35.470935Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.475416Z", "completed_at": "2024-10-25T14:34:35.475416Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.028987646102905273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_ed_classification__johnston_icd9_icd9.a7feea49c0", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect icd9\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd9\nwhere icd9 is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.471935Z", "completed_at": "2024-10-25T14:34:35.478412Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.479412Z", "completed_at": "2024-10-25T14:34:35.479412Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011476278305053711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_ed_classification__johnston_icd9_icd9.08c1dc4617", "compiled": true, "compiled_code": "\n \n \n\nselect\n icd9 as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.ed_classification._value_set_johnston_icd9\nwhere icd9 is not null\ngroup by icd9\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.480412Z", "completed_at": "2024-10-25T14:34:35.491311Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.498418Z", "completed_at": "2024-10-25T14:34:35.498418Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022005796432495117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_brand_with_generic_available", "compiled": true, "compiled_code": "\n\nselect distinct \n product_rxcui as brand_with_generic_available\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.pharmacy.rxnorm_generic_available\nwhere \n ndc_product_tty in ('SCD', 'GPCK')\n \n and cast(product_startmarketingdate as date) <= current_date\n", "relation_name": "dev_thuxuan.pharmacy._int_brand_with_generic_available"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.485412Z", "completed_at": "2024-10-25T14:34:35.499435Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.501407Z", "completed_at": "2024-10-25T14:34:35.501407Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022994518280029297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__quality_measures_value_set", "compiled": true, "compiled_code": "\n\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.quality_measures._value_set_measures p", "relation_name": "dev_thuxuan.data_quality.mart_review__quality_measures_value_set"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.491311Z", "completed_at": "2024-10-25T14:34:35.500418Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.509420Z", "completed_at": "2024-10-25T14:34:35.509420Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.030997753143310547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'ADH-Diabetes') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.501407Z", "completed_at": "2024-10-25T14:34:35.511415Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.519411Z", "completed_at": "2024-10-25T14:34:35.519411Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02199864387512207, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((\n select id\n from dev_thuxuan.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_id\n , cast((\n select name\n from dev_thuxuan.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_name\n , cast((\n select version\n from dev_thuxuan.quality_measures._value_set_measures\n where id = 'ADH-RAS'\n) as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_adhras__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.512414Z", "completed_at": "2024-10-25T14:34:35.522357Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.529410Z", "completed_at": "2024-10-25T14:34:35.529410Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01999044418334961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0055') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_cbe0055__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.522357Z", "completed_at": "2024-10-25T14:34:35.540510Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.552032Z", "completed_at": "2024-10-25T14:34:35.552032Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.039618492126464844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CBE0101') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_cbe0101__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.541420Z", "completed_at": "2024-10-25T14:34:35.553092Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.555027Z", "completed_at": "2024-10-25T14:34:35.555027Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02561664581298828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM236') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_cqm236__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.530412Z", "completed_at": "2024-10-25T14:34:35.555027Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.568033Z", "completed_at": "2024-10-25T14:34:35.568033Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04763507843017578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM130') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_cqm130__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.557099Z", "completed_at": "2024-10-25T14:34:35.569093Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.589145Z", "completed_at": "2024-10-25T14:34:35.589145Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04012036323547363, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM438') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_cqm438__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.570112Z", "completed_at": "2024-10-25T14:34:35.593036Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.595139Z", "completed_at": "2024-10-25T14:34:35.595139Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04002714157104492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n - set quality_measures_period_end to december end for last quarter measurement period\n - set quality_measures_period_end to march end for first quarter measurement period \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 3 months prior\n for visits in influenza season\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n month,\n -3,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n lookback_period for august of either current or previous year\n for immunization qualifying date\n*/\n, lookback_period as (\n\n select\n *\n , case\n when date_part('month', performance_period_end) between 1 and 8\n then (cast(date_part('year', performance_period_end) as integer) - 1) || '-08-01'\n else date_part('year', performance_period_end) || '-08-01'\n end as lookback_period_august\n from period_begin\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0041') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_august as date) as lookback_period_august\nfrom lookback_period", "relation_name": "dev_thuxuan.quality_measures._int_nqf0041__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.596133Z", "completed_at": "2024-10-25T14:34:35.619065Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.630119Z", "completed_at": "2024-10-25T14:34:35.630119Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03998112678527832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided \n*/\n\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'CQM48') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_cqm48__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.604175Z", "completed_at": "2024-10-25T14:34:35.629136Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.631105Z", "completed_at": "2024-10-25T14:34:35.631105Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03898930549621582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n-- lookback_period for last june 30 and december 31\n, lookback_period as (\n\nSELECT\n *\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-06-30') as date)\n then date_part('year', performance_period_end) || '-06-30'\n else date_part('year', performance_period_begin) || '-06-30'\n end as lookback_period_june\n , case\n when performance_period_end >= cast((date_part('year', performance_period_end) || '-12-31') as date)\n then date_part('year', performance_period_end) || '-12-31'\n else date_part('year', performance_period_begin) || '-12-31'\n end as lookback_period_december\nFROM period_begin\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0053') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(lookback_period_june as date) as lookback_period_june\n , cast(lookback_period_december as date) as lookback_period_december\nfrom lookback_period", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.620028Z", "completed_at": "2024-10-25T14:34:35.632036Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.643237Z", "completed_at": "2024-10-25T14:34:35.643237Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.048098087310791016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0059') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_nqf0059__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.634135Z", "completed_at": "2024-10-25T14:34:35.647217Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.656927Z", "completed_at": "2024-10-25T14:34:35.656927Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02779078483581543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0097') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_nqf0097__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.649188Z", "completed_at": "2024-10-25T14:34:35.670924Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.678933Z", "completed_at": "2024-10-25T14:34:35.678933Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.035695552825927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n \n)\n\n/*\n set performance period begin to following day of 1 year prior\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0420') as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\nfrom period_begin", "relation_name": "dev_thuxuan.quality_measures._int_nqf0420__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.657939Z", "completed_at": "2024-10-25T14:34:35.679926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.682915Z", "completed_at": "2024-10-25T14:34:35.682915Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03870201110839844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372__performance_period", "compiled": true, "compiled_code": "/*\n set performance period end to the end of the current calendar year\n or use the quality_measures_period_end variable if provided\n*/\nwith period_end as (\n\n select\n cast(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n year,\n 1,\n date_trunc('year', convert_timezone('UTC', current_timestamp()))\n )\n\n\n )\n\n\n as date)\n \n as performance_period_end\n)\n\n/*\n set performance period begin to a year and a day prior\n for a complete calendar year\n*/\n, period_begin as (\n\n select\n performance_period_end\n , \n\n dateadd(\n day,\n 1,\n \n\n dateadd(\n year,\n -1,\n performance_period_end\n )\n\n\n )\n\n as performance_period_begin\n from period_end\n\n)\n\n/*\n set performance lookback period to 27 months prior to the end of the\n performance period\n*/\n, period_lookback as (\n\n select\n performance_period_end\n , performance_period_begin\n , \n\n dateadd(\n month,\n -27,\n performance_period_end\n )\n\n as performance_period_lookback\n from period_begin\n\n\n)\n\nselect\n cast((select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_id\n , cast((select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_name\n , cast((select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF2372') as TEXT) as measure_version\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_lookback as date) as performance_period_lookback\nfrom period_lookback", "relation_name": "dev_thuxuan.quality_measures._int_nqf2372__performance_period"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.671948Z", "completed_at": "2024-10-25T14:34:35.681923Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.690963Z", "completed_at": "2024-10-25T14:34:35.690963Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04274725914001465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__calendar_month", "compiled": true, "compiled_code": "\n\n\nselect distinct\ncast(year_month_int as TEXT) as year_month\n, full_date\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.reference_data.calendar c\nwhere day = 1", "relation_name": "dev_thuxuan.data_quality.mart_review__calendar_month"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.683934Z", "completed_at": "2024-10-25T14:34:35.692933Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.699926Z", "completed_at": "2024-10-25T14:34:35.699926Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021996021270751953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join dev_thuxuan.reference_data.code_type as term on m.normalized_code_type = term.code_type", "relation_name": "dev_thuxuan.data_quality.condition_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.695928Z", "completed_at": "2024-10-25T14:34:35.703926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.713936Z", "completed_at": "2024-10-25T14:34:35.713936Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024016380310058594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE_TYPE' AS field_name\n , case when term.code_type is not null then 'valid'\n when m.primary_diagnosis_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code_type is not null and term.code_type is null\n then 'Primary Diagnosis Code Type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.reference_data.code_type term on m.primary_diagnosis_code_type = term.code_type", "relation_name": "dev_thuxuan.data_quality.encounter_primary_diagnosis_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.703926Z", "completed_at": "2024-10-25T14:34:35.715930Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.722934Z", "completed_at": "2024-10-25T14:34:35.722934Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.028022289276123047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.reference_data.code_type term on m.normalized_code_type = term.code_type", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.709922Z", "completed_at": "2024-10-25T14:34:35.716931Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.723897Z", "completed_at": "2024-10-25T14:34:35.723897Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022986888885498047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code_type", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE_TYPE' as field_name\n , case when term.code_type is not null then 'valid'\n when m.normalized_code_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code_type is not null and term.code_type is null\n then 'Normalized code type does not join to Terminology code_type table'\n else null end as invalid_reason\n , cast(normalized_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.reference_data.code_type term on m.normalized_code_type = term.code_type", "relation_name": "dev_thuxuan.data_quality.procedure_normalized_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.716931Z", "completed_at": "2024-10-25T14:34:35.725877Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.732925Z", "completed_at": "2024-10-25T14:34:35.732925Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02398991584777832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_source_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_source_code is not null and term.admit_source_code is null\n then 'Admit source code does not join to Terminology admit source table'\n else null end as invalid_reason\n , cast(m.admit_source_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.admit_source term on m.admit_source_code = term.admit_source_code", "relation_name": "dev_thuxuan.data_quality.encounter_admit_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.726928Z", "completed_at": "2024-10-25T14:34:35.736039Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.747024Z", "completed_at": "2024-10-25T14:34:35.747024Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024090051651000977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_admit_type_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.admit_type_code is not null and term.admit_type_code is null\n then 'Admit Type Code does not join to Terminology admit_type table'\n else null end as invalid_reason\n , cast(m.admit_type_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.admit_type term on m.admit_type_code = term.admit_type_code", "relation_name": "dev_thuxuan.data_quality.encounter_admit_type_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.737033Z", "completed_at": "2024-10-25T14:34:35.749031Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.757768Z", "completed_at": "2024-10-25T14:34:35.757768Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03083968162536621, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_apr_drg_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n ,'ENCOUNTER' AS table_name\n ,'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n ,'APR_DRG_CODE' AS field_name\n ,case when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.apr_drg_code is not null and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology apr_drg table'\n else null end as invalid_reason\n ,cast(m.apr_drg_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.apr_drg term on m.apr_drg_code = term.apr_drg_code", "relation_name": "dev_thuxuan.data_quality.encounter_apr_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.743029Z", "completed_at": "2024-10-25T14:34:35.756720Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.759746Z", "completed_at": "2024-10-25T14:34:35.759746Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.025830745697021484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_discharge_disposition_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.discharge_disposition_code is not null and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology discharge_disposition table'\n else null end as invalid_reason\n , cast(m.discharge_disposition_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.discharge_disposition term on m.discharge_disposition_code = term.discharge_disposition_code", "relation_name": "dev_thuxuan.data_quality.encounter_discharge_disposition_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.750629Z", "completed_at": "2024-10-25T14:34:35.760728Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.762713Z", "completed_at": "2024-10-25T14:34:35.762713Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020685911178588867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_encounter_type", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ENCOUNTER_TYPE' AS field_name\n , case when term.encounter_type is not null then 'valid'\n when m.encounter_type is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.encounter_type is not null and term.encounter_type is null\n then 'Encounter type does not join to Terminology encounter_type table'\n else null end as invalid_reason\n , cast(m.encounter_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.encounter_type term on m.encounter_type = term.encounter_type", "relation_name": "dev_thuxuan.data_quality.encounter_encounter_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.763717Z", "completed_at": "2024-10-25T14:34:35.776756Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.782731Z", "completed_at": "2024-10-25T14:34:35.782731Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0240170955657959, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_sex", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'SEX' as field_name\n , case when term.gender is not null then 'valid'\n when m.sex is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.sex is not null and term.gender is null\n then 'Sex does not join to Terminology gender table'\n else null end as invalid_reason\n , cast(sex as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join dev_thuxuan.terminology.gender term on m.sex = term.gender", "relation_name": "dev_thuxuan.data_quality.patient_sex"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.771733Z", "completed_at": "2024-10-25T14:34:35.783733Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.785724Z", "completed_at": "2024-10-25T14:34:35.785724Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.024007797241210938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_1", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as SOURCE_DATE\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_1' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_1 is not null and term.hcpcs is null\n then 'Modifier 1 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_1 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_1 = term.hcpcs", "relation_name": "dev_thuxuan.data_quality.procedure_modifier_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.778736Z", "completed_at": "2024-10-25T14:34:35.786721Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.792726Z", "completed_at": "2024-10-25T14:34:35.792726Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02398848533630371, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_2", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_2' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_2 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_2 is not null and term.hcpcs is null\n then 'Modifier 2 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_2 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_2 = term.hcpcs", "relation_name": "dev_thuxuan.data_quality.procedure_modifier_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.787719Z", "completed_at": "2024-10-25T14:34:35.794727Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.799713Z", "completed_at": "2024-10-25T14:34:35.799713Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021978139877319336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_3", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_3' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_3 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_3 is not null and term.hcpcs is null\n then 'Modifier 3 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_3 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_3 = term.hcpcs", "relation_name": "dev_thuxuan.data_quality.procedure_modifier_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.795741Z", "completed_at": "2024-10-25T14:34:35.805752Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.807732Z", "completed_at": "2024-10-25T14:34:35.807732Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015994787216186523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_4", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n ,coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n ,'PROCEDURE' AS table_name\n ,'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n ,'MODIFIER_4' as field_name\n ,case when term.hcpcs is not null then 'valid'\n when m.modifier_4 is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.modifier_4 is not null and term.hcpcs is null\n then 'Modifier 4 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n ,cast(modifier_4 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_4 = term.hcpcs", "relation_name": "dev_thuxuan.data_quality.procedure_modifier_4"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.801640Z", "completed_at": "2024-10-25T14:34:35.807732Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.812738Z", "completed_at": "2024-10-25T14:34:35.812738Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020010948181152344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_modifier_5", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'MODIFIER_5' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.modifier_5 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.modifier_5 is not null and term.hcpcs is null\n then 'Modifier 5 does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(modifier_5 as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.modifier_5 = term.hcpcs", "relation_name": "dev_thuxuan.data_quality.procedure_modifier_5"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.808688Z", "completed_at": "2024-10-25T14:34:35.818739Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.820722Z", "completed_at": "2024-10-25T14:34:35.820722Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.019951581954956055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_normalized_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n , 'CONDITION' AS table_name\n , 'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_cm is null\n then 'Normalized code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join dev_thuxuan.terminology.icd_10_cm term on m.normalized_code = term.icd_10_cm", "relation_name": "dev_thuxuan.data_quality.condition_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.813736Z", "completed_at": "2024-10-25T14:34:35.821647Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.829722Z", "completed_at": "2024-10-25T14:34:35.829722Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022991657257080078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_primary_diagnosis_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'PRIMARY_DIAGNOSIS_CODE' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.primary_diagnosis_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.primary_diagnosis_code is not null and term.icd_10_cm is null\n then 'Primary diagnosis code does not join to Terminology icd_10_cm table'\n else null end as invalid_reason\n , cast(primary_diagnosis_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.icd_10_cm term on m.primary_diagnosis_code = term.icd_10_cm", "relation_name": "dev_thuxuan.data_quality.encounter_primary_diagnosis_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.822667Z", "completed_at": "2024-10-25T14:34:35.835724Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.837809Z", "completed_at": "2024-10-25T14:34:35.837809Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018129587173461914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__procedure_normalized_code", "compiled": true, "compiled_code": "\n\nwith icd9 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_9_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_9_pcs is null\n then 'Normalized code does not join to Terminology icd_9_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n from tuva.input_layer.procedure m\n left join dev_thuxuan.terminology.icd_9_pcs term on m.normalized_code = term.icd_9_pcs\n where\n m.normalized_code_type = 'icd-9-pcs'\n),\nicd10 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.icd_10_pcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.icd_10_pcs is null\n then 'Normalized code does not join to Terminology icd_10_pcs table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.icd_10_pcs term on m.normalized_code = term.icd_10_pcs\nwhere\n m.normalized_code_type = 'icd_10_pcs'\n),\nhcpcs_level_2 as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.hcpcs is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.hcpcs is null\n then 'Normalized code does not join to Terminology hcpcs_level_2 table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nleft join dev_thuxuan.terminology.hcpcs_level_2 term on m.normalized_code = term.hcpcs\nwhere\n m.normalized_code_type = 'hcpcs_level_2'\n),\n\nothers as (\n SELECT\n m.data_source\n , coalesce(m.procedure_date,cast('1900-01-01' as date)) as source_date\n , 'PROCEDURE' AS table_name\n , 'Procedure ID' as drill_down_key\n , coalesce(procedure_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , 'null' as bucket_name\n , 'code type does not have a matching code terminology table' as invalid_reason\n , cast(normalized_code as TEXT) as field_value\nfrom tuva.input_layer.procedure m\nwhere\n m.normalized_code_type not in ('icd-9-pcs', 'icd-10-pcs','hcpcs_level_2')\n)\n\nSELECT *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM icd9\n\nunion all\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM icd10\n\nunion all\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM hcpcs_level_2\n\nunion all\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run FROM others", "relation_name": "dev_thuxuan.data_quality.procedure_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.831725Z", "completed_at": "2024-10-25T14:34:35.841813Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.842837Z", "completed_at": "2024-10-25T14:34:35.842837Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022164106369018555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_CODE' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_code is not null and term.loinc is null\n then 'Normalized code does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.terminology.loinc term on m.normalized_code = term.loinc", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.837809Z", "completed_at": "2024-10-25T14:34:35.843811Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.848820Z", "completed_at": "2024-10-25T14:34:35.848820Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01814746856689453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_normalized_component", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'NORMALIZED_COMPONENT' as field_name\n , case when term.loinc is not null then 'valid'\n when m.normalized_component is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.normalized_component is not null and term.loinc is null\n then 'Normalized component does not join to Terminology loinc table'\n else null end as invalid_reason\n , cast(normalized_component as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.terminology.loinc term on m.normalized_component = term.loinc", "relation_name": "dev_thuxuan.data_quality.lab_result_normalized_component"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.843811Z", "completed_at": "2024-10-25T14:34:35.850810Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.856511Z", "completed_at": "2024-10-25T14:34:35.856511Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01974034309387207, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_ms_drg_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'MS_DRG_CODE' AS field_name\n , case when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ms_drg_code is not null and term.ms_drg_code is null\n then 'MS DRG Code does not join to Terminology ms_drg table'\n else null end as invalid_reason\n , cast(m.ms_drg_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.ms_drg term on m.ms_drg_code = term.ms_drg_code", "relation_name": "dev_thuxuan.data_quality.encounter_ms_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.851401Z", "completed_at": "2024-10-25T14:34:35.858485Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.864490Z", "completed_at": "2024-10-25T14:34:35.864490Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016680240631103516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_ndc_description", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'NDC_DESCRIPTION' as field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ndc_code is not null and term.ndc is null\n then 'NDC code type does not join to Terminology ndc table'\n else null end as invalid_reason\n , cast(substring(ndc_description, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join dev_thuxuan.terminology.ndc term on m.ndc_code = term.ndc", "relation_name": "dev_thuxuan.data_quality.medication_ndc_description"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.858485Z", "completed_at": "2024-10-25T14:34:35.869496Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.871488Z", "completed_at": "2024-10-25T14:34:35.871488Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020678281784057617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__condition_present_on_admit_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(m.recorded_date,cast('1900-01-01' as date)) as source_date\n ,'CONDITION' AS table_name\n ,'Condition ID' as drill_down_key\n , coalesce(condition_id, 'NULL') AS drill_down_value\n ,'PRESENT_ON_ADMIT_CODE' AS field_name\n ,case when term.present_on_admit_code is not null then 'valid'\n when m.present_on_admit_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n ,case when m.present_on_admit_code is not null and term.present_on_admit_code is null\n then 'Present On Admit Code does not join to Terminology present_on_admission table'\n else null\n end as invalid_reason\n ,cast(m.present_on_admit_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.condition m\nleft join dev_thuxuan.terminology.present_on_admission term on m.present_on_admit_code = term.present_on_admit_code", "relation_name": "dev_thuxuan.data_quality.condition_present_on_admit_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.865497Z", "completed_at": "2024-10-25T14:34:35.871488Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.876489Z", "completed_at": "2024-10-25T14:34:35.876489Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01900029182434082, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_attending_provider_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'ATTENDING_PROVIDER_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.attending_provider_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.attending_provider_id is not null and term.npi is null\n then 'Attending provider ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(attending_provider_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.provider term on m.attending_provider_id = term.npi", "relation_name": "dev_thuxuan.data_quality.encounter_attending_provider_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.872496Z", "completed_at": "2024-10-25T14:34:35.878513Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.883509Z", "completed_at": "2024-10-25T14:34:35.883509Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019989967346191406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounter_facility_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(m.encounter_start_date,cast('1900-01-01' as date)) as source_date\n , 'ENCOUNTER' AS table_name\n , 'Encounter ID' as drill_down_key\n , coalesce(encounter_id, 'NULL') AS drill_down_value\n , 'FACILITY_ID' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.facility_id is not null and term.npi is null\n then 'Facility NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(facility_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.encounter m\nleft join dev_thuxuan.terminology.provider term on m.facility_id = term.npi", "relation_name": "dev_thuxuan.data_quality.encounter_facility_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.879493Z", "completed_at": "2024-10-25T14:34:35.885491Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.891507Z", "completed_at": "2024-10-25T14:34:35.891507Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017002105712890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__lab_result_ordering_practitioner_id", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.result_date,cast('1900-01-01' as date)) as source_date\n , 'LAB_RESULT' AS table_name\n , 'Lab Result ID' as drill_down_key\n , coalesce(lab_result_id, 'NULL') AS drill_down_value\n , 'ORDERING_PRACTITIONER_ID' as field_name\n , case when term.npi is not null then 'valid'\n when m.ordering_practitioner_id is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.ordering_practitioner_id is not null and term.npi is null\n then 'Ordering practitioner ID does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(ordering_practitioner_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.lab_result m\nleft join dev_thuxuan.terminology.provider term on m.ordering_practitioner_id = term.npi", "relation_name": "dev_thuxuan.data_quality.lab_result_ordering_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.885491Z", "completed_at": "2024-10-25T14:34:35.897493Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.899503Z", "completed_at": "2024-10-25T14:34:35.899503Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020991086959838867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__location_npi", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'LOCATION' AS table_name\n , 'Location ID' as drill_down_key\n , coalesce(location_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.location m\nleft join dev_thuxuan.terminology.provider term on m.npi = term.npi", "relation_name": "dev_thuxuan.data_quality.location_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.892497Z", "completed_at": "2024-10-25T14:34:35.899503Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.905487Z", "completed_at": "2024-10-25T14:34:35.905487Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020963430404663086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__practitioner_npi", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PRACTITIONER' AS table_name\n , 'Practitioner ID' as drill_down_key\n , coalesce(practitioner_id, 'NULL') AS drill_down_value\n , 'NPI' as field_name\n , case when term.npi is not null then 'valid'\n when m.npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.npi is not null and term.npi is null\n then 'NPI does not join to Terminology provider table'\n else null end as invalid_reason\n , cast(m.npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.practitioner m\nleft join dev_thuxuan.terminology.provider term on m.npi = term.npi", "relation_name": "dev_thuxuan.data_quality.practitioner_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.900513Z", "completed_at": "2024-10-25T14:34:35.906518Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.912499Z", "completed_at": "2024-10-25T14:34:35.912499Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020991802215576172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__patient_race", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n \n , cast(coalesce(convert_timezone('UTC', current_timestamp()), cast('1900-01-01' as date)) as date) as source_date\n \n , 'PATIENT' AS table_name\n , 'Patient ID' as drill_down_key\n , coalesce(patient_id, 'NULL') AS drill_down_value\n , 'RACE' as field_name\n , case when term.description is not null then 'valid'\n when m.race is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.race is not null and term.description is null\n then 'Race description does not join to Terminology race table'\n else null end as invalid_reason\n , cast(race as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.patient m\nleft join dev_thuxuan.terminology.race term on m.race = term.description", "relation_name": "dev_thuxuan.data_quality.patient_race"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.907492Z", "completed_at": "2024-10-25T14:34:35.918487Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.919524Z", "completed_at": "2024-10-25T14:34:35.919524Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016001224517822266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_atc_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'ATC_CODE' as field_name\n , case when coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is not null then 'valid'\n when m.atc_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.atc_code is not null and coalesce(term_1.atc_1_name,term_2.atc_2_name,term_3.atc_3_name,term_4.atc_4_name) is null\n then 'ATC Code does not join to Terminology rxnorm_to_atc table on any atc level'\n else null end as invalid_reason\n , cast(atc_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_1 on m.atc_code = term_1.atc_1_name\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_2 on m.atc_code = term_2.atc_2_name\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_3 on m.atc_code = term_3.atc_3_name\nleft join dev_thuxuan.terminology.rxnorm_to_atc term_4 on m.atc_code = term_4.atc_4_name", "relation_name": "dev_thuxuan.data_quality.medication_atc_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.914496Z", "completed_at": "2024-10-25T14:34:35.920491Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.926514Z", "completed_at": "2024-10-25T14:34:35.926514Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019995927810668945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medication_rxnorm_code", "compiled": true, "compiled_code": "\n\n\nSELECT\n m.data_source\n , coalesce(m.dispensing_date,cast('1900-01-01' as date)) as source_date\n , 'MEDICATION' AS table_name\n , 'Medication ID' as drill_down_key\n , coalesce(medication_id, 'NULL') AS drill_down_value\n , 'RXNORM_CODE' as field_name\n , case when term.rxcui is not null then 'valid'\n when m.rxnorm_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case when m.rxnorm_code is not null and term.rxcui is null\n then 'RX norm code does not join to Terminology rxnorm_to_atc table'\n else null end as invalid_reason\n , cast(rxnorm_code as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medication m\nleft join dev_thuxuan.terminology.rxnorm_to_atc term on m.rxnorm_code = term.rxcui", "relation_name": "dev_thuxuan.data_quality.medication_rxnorm_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.920491Z", "completed_at": "2024-10-25T14:34:35.933492Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.934488Z", "completed_at": "2024-10-25T14:34:35.934488Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020995140075683594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_condition_condition_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.condition_condition_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.condition_condition_id a\n inner JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_condition_condition_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.927496Z", "completed_at": "2024-10-25T14:34:35.935407Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.936526Z", "completed_at": "2024-10-25T14:34:35.936526Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.017001867294311523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_encounter_encounter_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.encounter_encounter_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.encounter_encounter_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_encounter_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.937496Z", "completed_at": "2024-10-25T14:34:35.948491Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.949504Z", "completed_at": "2024-10-25T14:34:35.949504Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016011714935302734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__lab_result", "compiled": true, "compiled_code": "\n\n\n\n\nselect\n labs.lab_result_id\n , labs.patient_id\n , labs.encounter_id\n , labs.accession_number\n , labs.source_code_type\n , labs.source_code\n , labs.source_description\n , labs.source_component\n , case\n when labs.normalized_code_type is not null then labs.normalized_code_type\n when loinc.loinc is not null then 'loinc'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n labs.normalized_code\n , loinc.loinc\n , snomed_ct.snomed_ct\n ) as normalized_code\n , coalesce(\n labs.normalized_description\n , loinc.long_common_name\n , snomed_ct.description\n ) normalized_description\n , case when coalesce(labs.normalized_code, labs.normalized_description) is not null then 'manual'\n when coalesce(loinc.loinc,snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , labs.normalized_component\n , labs.status\n , labs.result\n , labs.result_date\n , labs.collection_date\n , labs.source_units\n , labs.normalized_units\n , labs.source_reference_range_low\n , labs.source_reference_range_high\n , labs.normalized_reference_range_low\n , labs.normalized_reference_range_high\n , labs.source_abnormal_flag\n , labs.normalized_abnormal_flag\n , labs.specimen\n , labs.ordering_practitioner_id\n , labs.data_source\n , labs.tuva_last_run\nFrom dev_thuxuan.test.core__stg_clinical_lab_result as labs\nleft join dev_thuxuan.terminology.loinc loinc\n on labs.source_code_type = 'loinc'\n and labs.source_code = loinc.loinc\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on labs.source_code_type = 'snomed-ct'\n and labs.source_code = snomed_ct.snomed_ct\n\n ", "relation_name": "dev_thuxuan.core.lab_result"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.943511Z", "completed_at": "2024-10-25T14:34:35.949504Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.956189Z", "completed_at": "2024-10-25T14:34:35.956189Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019663095474243164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_lab_result_lab_result_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.lab_result_lab_result_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.lab_result_lab_result_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_lab_result_lab_result_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.949504Z", "completed_at": "2024-10-25T14:34:35.962234Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.964195Z", "completed_at": "2024-10-25T14:34:35.964195Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.021698951721191406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_location_location_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.location_location_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.location_location_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_location_location_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.957205Z", "completed_at": "2024-10-25T14:34:35.964195Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.966188Z", "completed_at": "2024-10-25T14:34:35.966188Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01769709587097168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__medication", "compiled": true, "compiled_code": "\n\n\nwith source_mapping as (\n\n select\n meds.medication_id\n , meds.patient_id\n , meds.encounter_id\n , meds.dispensing_date\n , meds.prescribing_date\n , meds.source_code_type\n , meds.source_code\n , meds.source_description\n , coalesce(\n meds.ndc_code\n , ndc.ndc\n ) as ndc_code\n , coalesce(\n meds.ndc_description\n , ndc.fda_description\n , ndc.rxnorm_description\n ) as ndc_description\n , case\n when meds.ndc_code is not null then 'manual'\n when ndc.ndc is not null then 'automatic'\n end as ndc_mapping_method\n , coalesce(\n meds.rxnorm_code\n , rxatc.rxcui\n ) as rxnorm_code\n , coalesce(\n meds.rxnorm_description\n , rxatc.rxnorm_description\n ) as rxnorm_description\n , case\n when meds.rxnorm_code is not null then 'manual'\n when rxatc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n meds.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n meds.atc_description\n , rxatc.atc_4_name\n ) as atc_description\n , case\n when meds.atc_code is not null then 'manual'\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , meds.route\n , meds.strength\n , meds.quantity\n , meds.quantity_unit\n , meds.days_supply\n , meds.practitioner_id\n , meds.data_source\n , meds.tuva_last_run\nfrom dev_thuxuan.test.core__stg_clinical_medication meds\n left join dev_thuxuan.terminology.ndc ndc\n on meds.source_code_type = 'ndc'\n and meds.source_code = ndc.ndc\n left join dev_thuxuan.terminology.rxnorm_to_atc rxatc\n on meds.source_code_type = 'rxnorm'\n and meds.source_code = rxatc.rxcui\n\n\n\n )\n\n\n-- add auto rxnorm + atc\nselect\n sm.medication_id\n , sm.patient_id\n , sm.encounter_id\n , sm.dispensing_date\n , sm.prescribing_date\n , sm.source_code_type\n , sm.source_code\n , sm.source_description\n , sm.ndc_code\n , sm.ndc_description\n , sm.ndc_mapping_method\n , coalesce(\n sm.rxnorm_code\n , ndc.rxcui\n ) as rxnorm_code\n , coalesce(\n sm.rxnorm_description\n , ndc.rxnorm_description\n ) as rxnorm_description\n , case\n when sm.rxnorm_mapping_method is not null then sm.rxnorm_mapping_method\n when ndc.rxcui is not null then 'automatic'\n end as rxnorm_mapping_method\n , coalesce(\n sm.atc_code\n , rxatc.atc_3_code\n ) as atc_code\n , coalesce(\n sm.atc_description\n , rxatc.atc_3_name\n ) as atc_description\n , case\n when sm.atc_mapping_method is not null then sm.atc_mapping_method\n when rxatc.atc_3_name is not null then 'automatic'\n end as atc_mapping_method\n , sm.route\n , sm.strength\n , sm.quantity\n , sm.quantity_unit\n , sm.days_supply\n , sm.practitioner_id\n , sm.data_source\n , sm.tuva_last_run\nfrom source_mapping sm\n left join dev_thuxuan.terminology.ndc ndc\n on sm.ndc_code = ndc.ndc\n left join dev_thuxuan.terminology.rxnorm_to_atc rxatc\n on coalesce( sm.rxnorm_code, ndc.rxcui ) = rxatc.rxcui", "relation_name": "dev_thuxuan.core.medication"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.967191Z", "completed_at": "2024-10-25T14:34:35.980190Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.981191Z", "completed_at": "2024-10-25T14:34:35.981191Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018004179000854492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_medication_medication_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.medication_medication_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.medication_medication_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_medication_medication_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.974135Z", "completed_at": "2024-10-25T14:34:35.982227Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.987205Z", "completed_at": "2024-10-25T14:34:35.987205Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022962570190429688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__observation", "compiled": true, "compiled_code": "\n\n\nselect\n obs.observation_id\n , obs.patient_id\n , obs.encounter_id\n , obs.panel_id\n , obs.observation_date\n , obs.observation_type\n , obs.source_code_type\n , obs.source_code\n , obs.source_description\n , case\n when obs.normalized_code_type is not null then obs.normalized_code_type\n when icd10cm.icd_10_cm is not null then 'icd-10-cm'\n when icd9cm.icd_9_cm is not null then 'icd-9-cm'\n when icd10pcs.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9pcs.icd_9_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n when loinc.loinc is not null then 'loinc'\n end as normalized_code_type\n , coalesce(\n obs.normalized_code\n , icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc\n ) as normalized_code\n , coalesce(\n obs.normalized_description\n , icd10cm.short_description\n , icd9cm.short_description\n , icd10pcs.description\n , icd9pcs.short_description\n , hcpcs.short_description\n , snomed_ct.description\n , loinc.long_common_name\n ) as normalized_description\n , case\n when coalesce(obs.normalized_code, obs.normalized_description) is not null then 'manual'\n when coalesce(\n icd10cm.icd_10_cm\n , icd9cm.icd_9_cm\n , icd10pcs.icd_10_pcs\n , icd9pcs.icd_9_pcs\n , hcpcs.hcpcs\n , snomed_ct.snomed_ct\n , loinc.loinc) is not null then 'automatic'\n end as mapping_method\n , obs.result\n , obs.source_units\n , obs.normalized_units\n , obs.source_reference_range_low\n , obs.source_reference_range_high\n , obs.normalized_reference_range_low\n , obs.normalized_reference_range_high\n , obs.data_source\n , obs.tuva_last_run\nfrom dev_thuxuan.test.core__stg_clinical_observation obs\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on obs.source_code_type = 'icd-10-cm'\n and replace(obs.source_code,'.','') = icd10cm.icd_10_cm\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on obs.source_code_type = 'icd-9-cm'\n and replace(obs.source_code,'.','') = icd9cm.icd_9_cm\nleft join dev_thuxuan.terminology.icd_10_pcs icd10pcs\n on obs.source_code_type = 'icd-10-pcs'\n and obs.source_code = icd10pcs.icd_10_pcs\nleft join dev_thuxuan.terminology.icd_9_pcs icd9pcs\n on obs.source_code_type = 'icd-9-pcs'\n and replace(obs.source_code,'.','') = icd9pcs.icd_9_pcs\nleft join dev_thuxuan.terminology.hcpcs_level_2 hcpcs\n on obs.source_code_type = 'hcpcs'\n and obs.source_code = hcpcs.hcpcs\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on obs.source_code_type = 'snomed-ct'\n and obs.source_code = snomed_ct.snomed_ct\nleft join dev_thuxuan.terminology.loinc loinc\n on obs.source_code_type = 'loinc'\n and obs.source_code = loinc.loinc\n\n", "relation_name": "dev_thuxuan.core.observation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.982227Z", "completed_at": "2024-10-25T14:34:35.993226Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:35.995200Z", "completed_at": "2024-10-25T14:34:35.995200Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.023012876510620117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_observation_observation_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.observation_observation_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.observation_observation_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_observation_observation_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.988186Z", "completed_at": "2024-10-25T14:34:35.996211Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.002190Z", "completed_at": "2024-10-25T14:34:36.002190Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02200007438659668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_patient_patient_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.patient_patient_id\n WHERE\n bucket_name = 'valid'\n\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.patient_patient_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_patient_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:35.997199Z", "completed_at": "2024-10-25T14:34:36.004211Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.010188Z", "completed_at": "2024-10-25T14:34:36.010188Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01600027084350586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_practitioner_practitioner_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.practitioner_practitioner_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.practitioner_practitioner_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_practitioner_practitioner_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.004211Z", "completed_at": "2024-10-25T14:34:36.016208Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.017218Z", "completed_at": "2024-10-25T14:34:36.017218Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02100658416748047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_keys_procedure_procedure_id", "compiled": true, "compiled_code": "\n\nWITH valid_conditions AS (\n SELECT\n *\n FROM\n dev_thuxuan.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n, uniqueness_check as (\n SELECT\n field_value,\n COUNT(*) AS duplicate_count\n FROM\n valid_conditions\n GROUP BY\n field_value\n HAVING\n COUNT(*) > 1\n)\n\n, random_sample AS (\n SELECT\n data_source,\n source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n field_value,\n bucket_name,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.procedure_procedure_id\n WHERE\n bucket_name = 'valid'\n)\n\n, duplicates_summary AS (\n SELECT\n a.data_source,\n a.source_date,\n a.table_name,\n a.drill_down_key,\n a.drill_down_value,\n a.field_name,\n a.field_value,\n a.bucket_name,\n b.duplicate_count,\n row_number() over (order by drill_down_key) as row_number_value\n FROM\n dev_thuxuan.data_quality.procedure_procedure_id a\n JOIN\n uniqueness_check b on a.field_value = b.field_value\n)\n\nSELECT\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n duplicates_summary\nwhere row_number_value <= 5\n\nunion all\n\nSELECT\n *,\n 0 as duplicate_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n random_sample\nWHERE\n row_number_value <= 5\n and NOT EXISTS (SELECT 1 FROM duplicates_summary)", "relation_name": "dev_thuxuan.data_quality.primary_keys_procedure_procedure_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.010188Z", "completed_at": "2024-10-25T14:34:36.018188Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.030189Z", "completed_at": "2024-10-25T14:34:36.030189Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.026999473571777344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_address", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'eligibility' as table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ADDRESS' AS field_name\n ,case when m.address is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(address as TEXT) AS field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_address"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.018188Z", "completed_at": "2024-10-25T14:34:36.031202Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.037375Z", "completed_at": "2024-10-25T14:34:36.037375Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.028181076049804688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_birth_date", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n SELECT DISTINCT member_id\n ,cast(birth_date as TEXT) as field\n ,data_source\n FROM base\n),\nclaim_grain as (\n SELECT member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n GROUP BY member_id\n ,data_source\n),\nclaim_agg as (\nSELECT\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) AS field_aggregated\nFROM\n unique_field\nGROUP BY\n data_source,\n member_id\n)\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'BIRTH_DATE' AS field_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) THEN 'invalid'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'invalid'\n WHEN m.birth_date IS NULL THEN 'null'\n ELSE 'valid' \n END AS bucket_name\n ,CASE \n WHEN cg.frequency > 1 THEN 'multiple'\n WHEN m.birth_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) THEN 'future'\n WHEN m.birth_date <= cast('1901-01-01' as date) THEN 'too old'\n else null\n END AS invalid_reason\n,CAST(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) AS field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.eligibility_birth_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.032195Z", "completed_at": "2024-10-25T14:34:36.043319Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.045313Z", "completed_at": "2024-10-25T14:34:36.045313Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0161130428314209, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_city", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'CITY' AS field_name\n ,case when m.race is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,CAST(city as TEXT) AS field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_city"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.039330Z", "completed_at": "2024-10-25T14:34:36.045313Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.058012Z", "completed_at": "2024-10-25T14:34:36.058012Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02581644058227539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_data_source", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.046313Z", "completed_at": "2024-10-25T14:34:36.065016Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.067072Z", "completed_at": "2024-10-25T14:34:36.067072Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.028750181198120117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_date_checks", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n\n, missing_start_date as (\n select\n 'Missing enrollment_start_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is null\n),\n\nmissing_end_date as (\n select\n 'Missing enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is null\n),\n\ninvalid_start_date as (\n select\n 'Enrollment_start_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date is not null\n and not try_cast( enrollment_start_date as date ) is not null\n),\n\ninvalid_end_date as (\n select\n 'Enrollment_end_date populated with something other than a date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_end_date is not null\n and not try_cast( enrollment_end_date as date ) is not null\n),\n\nstart_after_end as (\n select\n 'Enrollment_start_date after enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date > enrollment_end_date\n),\n\nfuture_end_date as (\n select\n 'Future enrollment_end_date' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n \n where enrollment_end_date > current_date\n \n\n),\n\nnonsensical_dates as (\n select\n 'Nonsensical dates' as data_quality_check,\n count(*) as result_count\n from eligibility_spans\n where enrollment_start_date < '1900-01-01'\n or enrollment_end_date < '1900-01-01'\n or enrollment_start_date > '2100-01-01'\n)\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_start_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_end_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_start_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_end_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from start_after_end\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from future_end_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from nonsensical_dates", "relation_name": "dev_thuxuan.data_quality.eligibility_date_checks"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.059010Z", "completed_at": "2024-10-25T14:34:36.068012Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.069003Z", "completed_at": "2024-10-25T14:34:36.069003Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024684667587280273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_date", "compiled": true, "compiled_code": "\n\nWITH base as (\n SELECT * \n FROM tuva.input_layer.eligibility\n\n),\nunique_field as (\n select distinct member_id\n ,cast(death_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select member_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by member_id\n ,data_source\n),\nclaim_agg as (\nselect\n member_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n data_source,\n member_id\n)\nselect distinct\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.death_date <= cast('1901-01-01' as date) then 'invalid'\n when m.death_date <= m.birth_date then 'invalid'\n when m.death_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.death_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.death_date <= cast('1901-01-01' as date) then 'too old'\n when m.death_date <= m.birth_date then 'death date before birth date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.member_id = cg.member_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.member_id = agg.member_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.eligibility_death_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.070010Z", "completed_at": "2024-10-25T14:34:36.083003Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.087017Z", "completed_at": "2024-10-25T14:34:36.087017Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022000789642333984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_death_flag", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DEATH_FLAG' AS field_name\n ,case\n when m.death_flag in (1,0) then 'valid'\n when m.death_flag is null then 'null'\n else 'invalid'\n end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(death_flag as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_death_flag"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.075004Z", "completed_at": "2024-10-25T14:34:36.092011Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.098925Z", "completed_at": "2024-10-25T14:34:36.098925Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.030913114547729492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_demographics", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n , birth_date\n , gender\n from tuva.input_layer.eligibility\n)\n\n, missing_birth_date as(\n select\n 'Missing birthday' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_birth_date as(\n select\n 'Birthday is not a valid date' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join reference_data.calendar c\n on e.birth_date = c.full_date\n where c.full_date is null\n)\n, future_birth_date as(\n select\n 'Birthday is in the future' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where birth_date > current_date\n \n)\n, past_birth_date as(\n select\n 'Birthday is too far in the past' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n \n where cast(floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8760.0) as integer ) > 110\n \n\n)\n, multiple_birth_date as(\n select\n 'Patient has multiple birthdays' as data_quality_check\n , count(distinct patient_id) as result_count\n from(\n select\n patient_id\n , birth_date\n , rank() over (partition by patient_id, birth_date order by birth_date) as rank_birth_date\n from eligibility_spans e\n where birth_date is not null\n )x\nwhere rank_birth_date > 1\n)\n, missing_gender as(\n select\n 'Missing gender' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n, invalid_gender as(\n select\n 'Patient gender does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where birth_date is null\n)\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from future_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from past_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from multiple_birth_date\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_gender\nunion all\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_gender", "relation_name": "dev_thuxuan.data_quality.eligibility_demographics"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.087017Z", "completed_at": "2024-10-25T14:34:36.098011Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.100004Z", "completed_at": "2024-10-25T14:34:36.100004Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.025991201400756836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_dq_stage", "compiled": true, "compiled_code": "\n\nwith month_start_and_end_dates as (\n select\n year_month_int as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from dev_thuxuan.reference_data.calendar\n group by year_month_int\n)\n\nselect distinct\n a.patient_id\n , b.year_month\n , b.month_start_date\n , b.month_end_date\n , a.payer\n , a.plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date", "relation_name": "dev_thuxuan.data_quality.data_quality__eligibility_dq_stage"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.093005Z", "completed_at": "2024-10-25T14:34:36.101009Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.102015Z", "completed_at": "2024-10-25T14:34:36.102015Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0160064697265625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_dual_status_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'DUAL_STATUS_CODE' AS field_name\n ,case when m.dual_status_code is null then 'null'\n when term.dual_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.dual_status_code is not null and term.dual_status_code is null then 'Dual Status Code does not join to Terminology Medicare Dual Eligibility table'\n else null\n end as invalid_reason\n , m.dual_status_code || '|' || coalesce(term.dual_status_description,'') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.medicare_dual_eligibility term on m.dual_status_code = term.dual_status_code", "relation_name": "dev_thuxuan.data_quality.eligibility_dual_status_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.103006Z", "completed_at": "2024-10-25T14:34:36.222035Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.233057Z", "completed_at": "2024-10-25T14:34:36.233057Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.13413214683532715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_end_date", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id,'NULL') AS drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_END_DATE' AS field_name\n ,case\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_end_date < m.enrollment_start_date then 'invalid'\n when m.enrollment_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n\n when m.enrollment_end_date <= cast('1901-01-01' as date) then 'too old'\n when m.enrollment_end_date < m.enrollment_start_date then 'end date before start date'\n else null\n end as invalid_reason\n ,cast(enrollment_end_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.223057Z", "completed_at": "2024-10-25T14:34:36.235056Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.241075Z", "completed_at": "2024-10-25T14:34:36.241075Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.13806891441345215, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_first_name", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'FIRST_NAME' AS field_name\n ,case when m.first_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(first_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_first_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.228059Z", "completed_at": "2024-10-25T14:34:36.240064Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.242068Z", "completed_at": "2024-10-25T14:34:36.242068Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022018909454345703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_gender", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'GENDER' AS field_name\n ,case when m.gender is null then 'null'\n when term.gender is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.gender is not null and term.gender is null then 'Gender does not join to Terminology Gender table'\n else null\n end as invalid_reason\n ,cast(m.gender as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.gender term on m.gender = term.gender", "relation_name": "dev_thuxuan.data_quality.eligibility_gender"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.236057Z", "completed_at": "2024-10-25T14:34:36.243062Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.249069Z", "completed_at": "2024-10-25T14:34:36.249069Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.027004241943359375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_last_name", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'LAST_NAME' AS field_name\n ,case when m.last_name is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(last_name as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_last_name"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.245061Z", "completed_at": "2024-10-25T14:34:36.253702Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.265073Z", "completed_at": "2024-10-25T14:34:36.265073Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.023997783660888672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_medicare_status_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEDICARE_STATUS_CODE' AS field_name\n ,case when m.medicare_status_code is null then 'null'\n when term.medicare_status_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.medicare_status_code is not null and term.medicare_status_code is null then 'Medicare Status Code does not join to Terminology Medicare Status table'\n else null\n end as invalid_reason\n , m.medicare_status_code || '|' || coalesce(term.medicare_status_description,'') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.medicare_status term on m.medicare_status_code = term.medicare_status_code", "relation_name": "dev_thuxuan.data_quality.eligibility_medicare_status_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.255707Z", "completed_at": "2024-10-25T14:34:36.268669Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.275670Z", "completed_at": "2024-10-25T14:34:36.275670Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025608301162719727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_member_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_member_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.260743Z", "completed_at": "2024-10-25T14:34:36.268669Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.277669Z", "completed_at": "2024-10-25T14:34:36.277669Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02760767936706543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_patient_id", "compiled": true, "compiled_code": "\n\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , patient_id\n from tuva.input_layer.eligibility\n)\n\nselect\n 'Missing patient_id' as data_quality_check\n ,count(*) as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom eligibility_spans\nwhere\n patient_id is null or patient_id = ''", "relation_name": "dev_thuxuan.data_quality.eligibility_missing_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.269669Z", "completed_at": "2024-10-25T14:34:36.279668Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.285697Z", "completed_at": "2024-10-25T14:34:36.285697Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030980825424194336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_missing_payer", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , payer\n , payer_type\n from tuva.input_layer.eligibility\n)\n\n, missing_payer_type as(\n select\n 'Missing payer type' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer_type is null\n)\n, missing_payer_name as(\n select\n 'Missing payer name' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans\n where payer is null\n)\n, invalid_payer_type as(\n select\n 'Payer type does not join to terminology table' as data_quality_check\n , count(distinct eligibility_span_id) as result_count\n from eligibility_spans e\n left join dev_thuxuan.terminology.payer_type pt\n on e.payer_type = pt.payer_type\n where pt.payer_type is null\n)\n\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_payer_type\nunion all\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from missing_payer_name\nunion all\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from invalid_payer_type", "relation_name": "dev_thuxuan.data_quality.eligibility_missing_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.280669Z", "completed_at": "2024-10-25T14:34:36.287718Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.294799Z", "completed_at": "2024-10-25T14:34:36.294799Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01912975311279297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_original_reason_entitlement_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ORIGINAL_REASON_ENTITLEMENT_CODE' AS field_name\n ,case when m.original_reason_entitlement_code is null then 'null'\n when term.original_reason_entitlement_code is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.original_reason_entitlement_code is not null and term.original_reason_entitlement_code is null then 'Original Reason Entitlement Code does not join to Terminology Original Reason Entitlement Code table'\n else null\n end as invalid_reason\n , m.original_reason_entitlement_code || '|' || coalesce(term.original_reason_entitlement_description,'') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.medicare_orec term on m.original_reason_entitlement_code = term.original_reason_entitlement_code", "relation_name": "dev_thuxuan.data_quality.eligibility_original_reason_entitlement_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.288700Z", "completed_at": "2024-10-25T14:34:36.300509Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.307506Z", "completed_at": "2024-10-25T14:34:36.307506Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02229595184326172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_patient_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.295486Z", "completed_at": "2024-10-25T14:34:36.305523Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.307506Z", "completed_at": "2024-10-25T14:34:36.307506Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022809982299804688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.300509Z", "completed_at": "2024-10-25T14:34:36.308507Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.310506Z", "completed_at": "2024-10-25T14:34:36.310506Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016796588897705078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_payer_type", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PAYER_TYPE' AS field_name\n ,case when m.payer_type is null then 'null'\n when term.payer_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.payer_type is not null and term.payer_type is null then 'Payer Type does not join to Terminology Payer Type table'\n else null\n end as invalid_reason\n ,cast(m.payer_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.payer_type term on m.payer_type = term.payer_type", "relation_name": "dev_thuxuan.data_quality.eligibility_payer_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.310506Z", "completed_at": "2024-10-25T14:34:36.316966Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.323292Z", "completed_at": "2024-10-25T14:34:36.323292Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016785144805908203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_phone", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PHONE' AS field_name\n ,case when m.phone is null then 'null'\n else 'valid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(phone as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_phone"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.317972Z", "completed_at": "2024-10-25T14:34:36.329784Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.336835Z", "completed_at": "2024-10-25T14:34:36.336835Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021311283111572266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_plan", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(m.plan as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.323292Z", "completed_at": "2024-10-25T14:34:36.335793Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.337872Z", "completed_at": "2024-10-25T14:34:36.337872Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02179551124572754, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_race", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'RACE' AS field_name\n ,case when m.race is null then 'null'\n when r.description is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.race is not null and r.description is null then 'Race does not join to terminology race table'\n else null\n end as invalid_reason\n ,cast(race as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.terminology.race r on m.race=r.description", "relation_name": "dev_thuxuan.data_quality.eligibility_race"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.330793Z", "completed_at": "2024-10-25T14:34:36.339360Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.344885Z", "completed_at": "2024-10-25T14:34:36.344885Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02691364288330078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_start_date", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ENROLLMENT_START_DATE' AS field_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'invalid'\n when m.enrollment_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when m.enrollment_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.enrollment_start_date <= cast('1901-01-01' as date) then 'too old'\n else null\n end as invalid_reason\n ,cast(enrollment_start_date as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.340776Z", "completed_at": "2024-10-25T14:34:36.347782Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.356552Z", "completed_at": "2024-10-25T14:34:36.356552Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01971745491027832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_state", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT \n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'STATE' AS field_name\n ,case when m.state is null then 'null'\n when term.ssa_fips_state_name is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.state is not null and term.ssa_fips_state_name is null then 'State does not join to Terminology SSA_FIPS_STATE table'\n else null\n end as invalid_reason\n ,cast(state as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m\nleft join dev_thuxuan.reference_data.ssa_fips_state as term on m.state = term.ssa_fips_state_name", "relation_name": "dev_thuxuan.data_quality.eligibility_state"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.348783Z", "completed_at": "2024-10-25T14:34:36.363036Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.367419Z", "completed_at": "2024-10-25T14:34:36.367419Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022585630416870117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_trend", "compiled": true, "compiled_code": "\n\nwith eligibility_spans as(\n select distinct\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_span_id\n , enrollment_start_date\n , enrollment_end_date\n from tuva.input_layer.eligibility\n)\n, month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from dev_thuxuan.reference_data.calendar\n group by year, month, year_month\n)\n, member_months as (\n select distinct\n eligibility_span_id\n , year_month\n from eligibility_spans es\n inner join month_start_and_end_dates d\n on es.enrollment_start_date <= d.month_end_date\n and es.enrollment_end_date >= d.month_start_date\n)\n\n\nselect\n year_month\n , count(distinct eligibility_span_id) as member_months\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom member_months\ngroup by\n year_month", "relation_name": "dev_thuxuan.data_quality.eligibility_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.357303Z", "completed_at": "2024-10-25T14:34:36.366436Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.369411Z", "completed_at": "2024-10-25T14:34:36.369411Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.023588895797729492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__eligibility_zip_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.enrollment_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'ELIGIBILITY' AS table_name\n ,'Member ID | Enrollment Start Date' AS drill_down_key\n ,coalesce(m.member_id, 'NULL') as drill_down_value\n ,'ELIGIBILITY' AS claim_type\n ,'ZIP_CODE' AS field_name\n \n ,case when m.zip_code is null then 'null'\n when length(m.zip_code) in (5,9,10) then 'valid'\n else 'invalid' end as bucket_name\n ,case\n when m.zip_code is not null and length(m.zip_code) NOT IN (5,9,10) then 'Invalid Zip Code Length'\n else null\n end as invalid_reason\n \n ,cast(zip_code as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.eligibility m", "relation_name": "dev_thuxuan.data_quality.eligibility_zip_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.381132Z", "completed_at": "2024-10-25T14:34:36.397358Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.398356Z", "completed_at": "2024-10-25T14:34:36.398356Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020900726318359375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_allowed_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_allowed_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.387396Z", "completed_at": "2024-10-25T14:34:36.398356Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.406357Z", "completed_at": "2024-10-25T14:34:36.406357Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.027917861938476562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_charge_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CHARGE_AMOUNT' AS field_name\n , case when m.charge_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(charge_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_charge_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.392404Z", "completed_at": "2024-10-25T14:34:36.399356Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.408364Z", "completed_at": "2024-10-25T14:34:36.408364Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.029925107955932617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_ID' AS field_name\n ,case when m.claim_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.399356Z", "completed_at": "2024-10-25T14:34:36.410357Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.411356Z", "completed_at": "2024-10-25T14:34:36.411356Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016005277633666992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_end_date", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_END_DATE' AS field_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'invalid'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_end_date > m.claim_line_end_date then 'invalid'\n when m.claim_line_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_end_date > tuva_last_run then 'future'\n when m.claim_line_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_end_date > m.claim_end_date then 'line date greater than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_end_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.claim_claim_line_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.413946Z", "completed_at": "2024-10-25T14:34:36.426224Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.431226Z", "completed_at": "2024-10-25T14:34:36.431226Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021869182586669922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_number", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_LINE_NUMBER' AS field_name\n ,case when m.claim_line_number is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_claim_line_number"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.419225Z", "completed_at": "2024-10-25T14:34:36.431226Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.437858Z", "completed_at": "2024-10-25T14:34:36.437858Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02650165557861328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_line_start_date", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'CLAIM_LINE_START_DATE' AS field_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'invalid'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_line_start_date < m.claim_start_date then 'invalid'\n when m.claim_line_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.claim_line_start_date > tuva_last_run then 'future'\n when m.claim_line_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_line_start_date < m.claim_start_date then 'line date less than than claim date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.claim_claim_line_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.426224Z", "completed_at": "2024-10-25T14:34:36.437430Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.439003Z", "completed_at": "2024-10-25T14:34:36.439003Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025977134704589844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_claim_type", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'CLAIM_TYPE' AS field_name\n ,case when m.claim_type is null then 'null'\n when term.claim_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.claim_type is not null and term.claim_type is null then 'Claim Type does not join to Terminology Claim Type table'\n else null\n end as invalid_reason\n ,cast(m.claim_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join dev_thuxuan.terminology.claim_type term on m.claim_type = term.claim_type", "relation_name": "dev_thuxuan.data_quality.claim_claim_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.432258Z", "completed_at": "2024-10-25T14:34:36.440436Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.442442Z", "completed_at": "2024-10-25T14:34:36.442442Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017216205596923828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_coinsurance_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_coninsurance_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.449442Z", "completed_at": "2024-10-25T14:34:36.466727Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.467816Z", "completed_at": "2024-10-25T14:34:36.467816Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.027379751205444336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_copayment_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_copayment_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.456540Z", "completed_at": "2024-10-25T14:34:36.467816Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.472931Z", "completed_at": "2024-10-25T14:34:36.472931Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03145456314086914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_data_source", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DATA_SOURCE' AS field_name\n ,case when m.data_source is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.461675Z", "completed_at": "2024-10-25T14:34:36.472931Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.474842Z", "completed_at": "2024-10-25T14:34:36.474842Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.029267072677612305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_deductible_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_deductible_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.468822Z", "completed_at": "2024-10-25T14:34:36.475823Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.477862Z", "completed_at": "2024-10-25T14:34:36.477862Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01673126220703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_diagnosis_code_type", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' as drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'DIAGNOSIS_CODE_TYPE' AS field_name\n ,case when m.diagnosis_code_type is null then 'null'\n when term.code_type is null then 'invalid'\n else 'valid' end as bucket_name\n ,case\n when m.diagnosis_code_type is not null and term.code_type is null then 'Diagnosis Code Type does not join to Terminology Code Type table'\n else null\n end as invalid_reason\n ,cast(m.diagnosis_code_type as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\nleft join dev_thuxuan.reference_data.code_type term on m.diagnosis_code_type = term.code_type", "relation_name": "dev_thuxuan.data_quality.claim_diagnosis_code_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.479821Z", "completed_at": "2024-10-25T14:34:36.495897Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.497393Z", "completed_at": "2024-10-25T14:34:36.497393Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021570682525634766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_hcpcs_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'HCPCS_CODE' AS field_name\n , case\n when term.hcpcs is not null then 'valid'\n when m.hcpcs_code is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.hcpcs_code is not null and term.hcpcs is null then 'HCPCS does not join to Terminology HCPCS_LEVEL_2 table'\n else null\n end as invalid_reason\n , m.hcpcs_code || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join dev_thuxuan.terminology.hcpcs_level_2 as term on m.hcpcs_code = term.hcpcs", "relation_name": "dev_thuxuan.data_quality.claim_hcpcs_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.485826Z", "completed_at": "2024-10-25T14:34:36.497393Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.504663Z", "completed_at": "2024-10-25T14:34:36.504663Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.027840137481689453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_member_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'MEMBER_ID' AS field_name\n ,case when m.member_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_member_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.491361Z", "completed_at": "2024-10-25T14:34:36.504663Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.506663Z", "completed_at": "2024-10-25T14:34:36.506663Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.028803110122680664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_paid_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_paid_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.498526Z", "completed_at": "2024-10-25T14:34:36.506663Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.508665Z", "completed_at": "2024-10-25T14:34:36.508665Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017795085906982422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_paid_date", "compiled": true, "compiled_code": "\n\nwith tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date < m.claim_start_date then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.paid_date < m.claim_start_date then 'paid date before claim start date'\n else null\n end as invalid_reason\n , cast(claim_line_start_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.claim_paid_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.510665Z", "completed_at": "2024-10-25T14:34:36.520665Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.530999Z", "completed_at": "2024-10-25T14:34:36.530999Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.023336410522460938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_patient_id", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PATIENT_ID' AS field_name\n ,case when m.patient_id is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.515662Z", "completed_at": "2024-10-25T14:34:36.521663Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.536000Z", "completed_at": "2024-10-25T14:34:36.536000Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02933526039123535, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_payer", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain \n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PAYER' AS field_name\n ,case when m.payer is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(payer as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.522991Z", "completed_at": "2024-10-25T14:34:36.539003Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.540005Z", "completed_at": "2024-10-25T14:34:36.540005Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02933979034423828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_plan", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n,coalesce(claim_id, 'NULL') AS drill_down_value\n ,m.claim_type as claim_type\n ,'PLAN' AS field_name\n ,case when m.plan is not null then 'valid' else 'null' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(plan as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.530999Z", "completed_at": "2024-10-25T14:34:36.539003Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.541004Z", "completed_at": "2024-10-25T14:34:36.541004Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021337032318115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_total_cost_amount", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'TOTAL_COST_AMOUNT' AS field_name\n , case when m.total_cost_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(total_cost_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.claim_total_cost_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.543005Z", "completed_at": "2024-10-25T14:34:36.582959Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.583960Z", "completed_at": "2024-10-25T14:34:36.583960Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04395484924316406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_type_summary", "compiled": true, "compiled_code": "select\n data_source\n ,claim_type\n ,count(distinct claim_id) as claim_count\n ,sum(paid_amount) as paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim\ngroup by\n data_source\n ,claim_type\n\n", "relation_name": "dev_thuxuan.data_quality.claim_type_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.584960Z", "completed_at": "2024-10-25T14:34:36.598958Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.600959Z", "completed_at": "2024-10-25T14:34:36.600959Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020001649856567383, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__inpatient_dq_stage", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from tuva.input_layer.medical_claim as mc\n left join dev_thuxuan.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join dev_thuxuan.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n )\n)\n\nselect distinct\n a.claim_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "relation_name": "dev_thuxuan.data_quality.data_quality__inpatient_dq_stage"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.590961Z", "completed_at": "2024-10-25T14:34:36.598958Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.601959Z", "completed_at": "2024-10-25T14:34:36.601959Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020002365112304688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_bill_type_code", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.bill_type_code || '|' || coalesce(term.bill_type_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.bill_type as term on base.bill_type_code = term.bill_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'BILL_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.bill_type_code is not null then 'valid'\n when m.bill_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.bill_type_code is not null\n and term.bill_type_code is null\n and cg.frequency = 1\n then 'Bill Type Code does not join to Terminology Bill_Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.bill_type as term on m.bill_type_code = term.bill_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_bill_type_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.602960Z", "completed_at": "2024-10-25T14:34:36.610958Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.610958Z", "completed_at": "2024-10-25T14:34:36.610958Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.010998249053955078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_billing_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(billing_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'BILLING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.billing_npi is not null\n and term.npi is null\n then 'NPI is not in Terminology Provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.provider as term on m.billing_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_billing_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.613960Z", "completed_at": "2024-10-25T14:34:36.637963Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.639964Z", "completed_at": "2024-10-25T14:34:36.639964Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03100442886352539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_end_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before claim start date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_claim_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.622960Z", "completed_at": "2024-10-25T14:34:36.638963Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.640964Z", "completed_at": "2024-10-25T14:34:36.640964Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.031006336212158203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_claim_start_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_claim_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.630958Z", "completed_at": "2024-10-25T14:34:36.638963Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.641964Z", "completed_at": "2024-10-25T14:34:36.641964Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.030005216598510742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_1", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_cm as term on base.diagnosis_code_1 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_diagnosis_code_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.649964Z", "completed_at": "2024-10-25T14:34:36.694480Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.697473Z", "completed_at": "2024-10-25T14:34:36.697473Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.05150890350341797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_disposition_code", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , base.discharge_disposition_code || '|' || coalesce(term.discharge_disposition_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.discharge_disposition as term on base.discharge_disposition_code = term.discharge_disposition_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DISCHARGE_DISPOSITION_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.discharge_disposition_code is not null then 'valid'\n when m.discharge_disposition_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.discharge_disposition_code is not null\n and term.discharge_disposition_code is null\n then 'Discharge Disposition Code does not join to Terminology Discharge_Disposition Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.discharge_disposition as term on m.discharge_disposition_code = term.discharge_disposition_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_discharge_disposition_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.669474Z", "completed_at": "2024-10-25T14:34:36.696474Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.698474Z", "completed_at": "2024-10-25T14:34:36.698474Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.05350995063781738, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_2", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_cm as term on base.diagnosis_code_2 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_diagnosis_code_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.678475Z", "completed_at": "2024-10-25T14:34:36.699473Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.700473Z", "completed_at": "2024-10-25T14:34:36.700473Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.05550885200500488, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_diagnosis_code_3", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\n\nunique_field as (\n select distinct claim_id\n , diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_cm as term on base.diagnosis_code_3 = term.icd_10_cm\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code is not in Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_diagnosis_code_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.704473Z", "completed_at": "2024-10-25T14:34:36.722328Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.723328Z", "completed_at": "2024-10-25T14:34:36.723328Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02185511589050293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_facility_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'FACILITY_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.facility_npi is not null\n and term.npi is null\n then 'NPI not in Terminology Provider Table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.provider as term on m.facility_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_facility_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.709472Z", "completed_at": "2024-10-25T14:34:36.722328Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.724329Z", "completed_at": "2024-10-25T14:34:36.724329Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02285623550415039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_1", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_1' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_1 in ('y','n') then 'valid'\n when m.diagnosis_poa_1 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_present_on_admission_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.717327Z", "completed_at": "2024-10-25T14:34:36.725328Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.726327Z", "completed_at": "2024-10-25T14:34:36.726327Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.023856163024902344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_2", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_2' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_2 in ('y','n') then 'valid'\n when m.diagnosis_poa_2 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_present_on_admission_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.731328Z", "completed_at": "2024-10-25T14:34:36.760873Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.761879Z", "completed_at": "2024-10-25T14:34:36.761879Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03455042839050293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_present_on_admission_3", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(diagnosis_poa_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DIAGNOSIS_POA_3' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when m.diagnosis_poa_3 in ('y','n') then 'valid'\n when m.diagnosis_poa_3 is null then 'null'\n else 'invalid' end as bucket_name\n ,cast(null as TEXT) as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_present_on_admission_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.740672Z", "completed_at": "2024-10-25T14:34:36.760873Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.762879Z", "completed_at": "2024-10-25T14:34:36.762879Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.034551382064819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_rendering_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n),\nunique_field as (\n select distinct claim_id\n ,cast(facility_npi as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'RENDERING_NPI' AS field_name\n ,case when cg.frequency > 1 then 'multiple'\n when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n ,case\n when cg.frequency = 1\n and m.rendering_npi is not null\n and term.npi is null\n then 'provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.provider as term on m.rendering_npi = term.npi\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_rendering_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.750695Z", "completed_at": "2024-10-25T14:34:36.762879Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.764878Z", "completed_at": "2024-10-25T14:34:36.764878Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03455018997192383, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_revenue_center_code", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'institutional' AS claim_type\n , 'REVENUE_CENTER_CODE' AS field_name\n , case\n when term.revenue_center_code is not null then 'valid'\n when m.revenue_center_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.revenue_center_code is not null\n and term.revenue_center_code is null\n then 'Revenue center code does not join to Terminology Revenue Center table'\n else null\n end as invalid_reason\n , m.revenue_center_code || '|' || coalesce(term.revenue_center_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from tuva.input_layer.medical_claim m\nleft join dev_thuxuan.terminology.revenue_center as term on m.revenue_center_code = term.revenue_center_code", "relation_name": "dev_thuxuan.data_quality.institutional_revenue_center_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.768879Z", "completed_at": "2024-10-25T14:34:36.787880Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.788878Z", "completed_at": "2024-10-25T14:34:36.788878Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02299952507019043, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_service_unit_quantity", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , m.claim_type as claim_type\n , 'service_unit_quantity' as field_name\n , case when m.service_unit_quantity is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(service_unit_quantity as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.medical_claim m", "relation_name": "dev_thuxuan.data_quality.institutional_service_unit_quantity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.775881Z", "completed_at": "2024-10-25T14:34:36.788878Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.789878Z", "completed_at": "2024-10-25T14:34:36.789878Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023000240325927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_claim_line_fields", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when hcpc.hcpcs is null and m.hcpcs_code is not null then 1 else 0 end) as invalid_hcpcs_code\n , max(case when m.claim_type = 'professional' and pos.place_of_service_code is null and m.place_of_service_code is not null then 1 else 0 end) as invalid_place_of_service_code\n , max(case when m.claim_type = 'institutional' and rev.revenue_center_code is null and m.revenue_center_code is not null then 1 else 0 end) as invalid_revenue_center_code\n , max(case when m.hcpcs_code is null then 1 else 0 end) as missing_hcpcs_code\n , max(case when m.claim_type = 'professional' and m.place_of_service_code is null then 1 else 0 end) as missing_place_of_service_code\n , max(case when m.claim_type = 'institutional' and m.revenue_center_code is null then 1 else 0 end) as missing_revenue_center_code\n from tuva.input_layer.medical_claim as m\n left join dev_thuxuan.terminology.hcpcs_level_2 as hcpc\n on m.hcpcs_code = hcpc.hcpcs\n left join dev_thuxuan.terminology.place_of_service as pos\n on m.place_of_service_code = pos.place_of_service_code\n left join dev_thuxuan.terminology.revenue_center as rev\n on m.revenue_center_code = rev.revenue_center_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid hcpcs_code' as data_quality_check\n , sum(invalid_hcpcs_code) as result_count\n from medical_claim\n \n union all\n\n select\n 'invalid place_of_service_code' as data_quality_check\n , sum(invalid_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'invalid revenue_center_code' as data_quality_check\n , sum(invalid_revenue_center_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing hcpcs_code' as data_quality_check\n , sum(missing_hcpcs_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing place_of_service_code' as data_quality_check\n , sum(missing_place_of_service_code) as result_count\n from medical_claim\n\n union all\n\n select\n 'missing revenue_center_code' as data_quality_check\n , sum(missing_revenue_center_code) as result_count\n from medical_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.medical_claim_claim_line_fields"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.779880Z", "completed_at": "2024-10-25T14:34:36.790879Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.792879Z", "completed_at": "2024-10-25T14:34:36.792879Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025000333786010742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_provider_npi", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.rendering_npi is not null then 1 else 0 end) as invalid_rendering_npi\n , max(case when term2.npi is null and m.billing_npi is not null then 1 else 0 end) as invalid_billing_npi\n , max(case when term3.npi is null and m.facility_npi is not null then 1 else 0 end) as invalid_facility_npi\n\n , max(case when m.rendering_npi is null then 1 else 0 end) as missing_rendering_npi\n , max(case when m.billing_npi is null then 1 else 0 end) as missing_billing_npi\n , max(case when m.facility_npi is null then 1 else 0 end) as missing_facility_npi\n\n , count(distinct m.rendering_npi) as rendering_npi_count\n , count(distinct m.billing_npi) as billing_npi_count\n , count(distinct m.facility_npi) as facility_npi_count\n\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_rendering_npi\n , max(case when term3.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_facility_npi\n\n from tuva.input_layer.medical_claim as m\n left join dev_thuxuan.terminology.provider as term\n on m.rendering_npi = term.npi\n left join dev_thuxuan.terminology.provider as term2\n on m.billing_npi = term2.npi\n left join dev_thuxuan.terminology.provider as term3\n on m.facility_npi = term3.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid rendering_npi' as data_quality_check\n , sum(invalid_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid billing_npi' as data_quality_check\n , sum(invalid_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'invalid facility_npi' as data_quality_check\n , sum(invalid_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing rendering_npi' as data_quality_check\n , sum(missing_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing billing_npi' as data_quality_check\n , sum(missing_billing_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'missing facility_npi' as data_quality_check\n , sum(missing_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type rendering_npi' as data_quality_check\n , sum(wrong_entity_type_rendering_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'wrong entity type facility_npi' as data_quality_check\n , sum(wrong_entity_type_facility_npi) as result_count\nfrom medical_claim\n\nunion all\n\nselect\n 'multiple rendering_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere rendering_npi_count > 1\n\nunion all\n\nselect\n 'multiple billing_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere billing_npi_count > 1\n\nunion all\n\nselect\n 'multiple facility_npi values' as data_quality_check\n , count(distinct claim_id) as result_count\nfrom medical_claim\nwhere facility_npi_count > 1\n)\n\nselect *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.medical_claim_provider_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.795879Z", "completed_at": "2024-10-25T14:34:36.817877Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.818880Z", "completed_at": "2024-10-25T14:34:36.818880Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0260009765625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_volume_and_dollars", "compiled": true, "compiled_code": "\n\nwith range_cte as (\n select\n min(claim_start_date) as first_date\n \n , current_date as last_date\n \n from tuva.input_layer.medical_claim p\n)\n\n, date_cte as (\n select distinct\n year_month_int\n from dev_thuxuan.reference_data.calendar c\n inner join range_cte r\n on c.full_date between r.first_date and r.last_date\n)\n\n, medical_claim as (\n select\n c.year_month_int\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n from tuva.input_layer.medical_claim p\n left join dev_thuxuan.reference_data.calendar c\n on p.claim_start_date = c.full_date\n group by\n c.year_month_int\n)\n\nselect\n d.year_month_int as year_month\n , coalesce(claim_volume, 0) as claim_volume\n , coalesce(paid_amount, 0) as paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom date_cte d\nleft join medical_claim m\n on d.year_month_int = m.year_month_int", "relation_name": "dev_thuxuan.data_quality.medical_claim_volume_and_dollars"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.801878Z", "completed_at": "2024-10-25T14:34:36.817877Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.820879Z", "completed_at": "2024-10-25T14:34:36.820879Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.027001380920410156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_billing_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'BILLING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.billing_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.billing_npi is not null\n and term.npi is null\n then 'Billing NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.billing_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.provider as term on m.billing_npi = term.npi", "relation_name": "dev_thuxuan.data_quality.professional_billing_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.809879Z", "completed_at": "2024-10-25T14:34:36.819879Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.821886Z", "completed_at": "2024-10-25T14:34:36.821886Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026007413864135742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_claim_end_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'institutional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n ,unique_field as (\n select distinct claim_id\n ,cast(claim_end_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_END_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_end_date < m.claim_start_date then 'invalid'\n when m.claim_end_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_end_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_end_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.claim_end_date < m.claim_start_date then 'claim end date before start date'\n when m.claim_end_date is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.professional_claim_end_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.825892Z", "completed_at": "2024-10-25T14:34:36.854431Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.855434Z", "completed_at": "2024-10-25T14:34:36.855434Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.032517433166503906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_claim_start_date", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(claim_start_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id,'NULL') AS drill_down_value\n ,'professional' AS claim_type\n ,'CLAIM_START_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.claim_start_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.claim_start_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.claim_start_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.professional_claim_start_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.839920Z", "completed_at": "2024-10-25T14:34:36.854431Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.855434Z", "completed_at": "2024-10-25T14:34:36.855434Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.032540082931518555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_1", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_1' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_1 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_1 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_1 = term.icd_10_cm", "relation_name": "dev_thuxuan.data_quality.professional_diagnosis_code_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.845920Z", "completed_at": "2024-10-25T14:34:36.856432Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.858433Z", "completed_at": "2024-10-25T14:34:36.858433Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03354167938232422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_2", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_2' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_2 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_2 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_2 = term.icd_10_cm", "relation_name": "dev_thuxuan.data_quality.professional_diagnosis_code_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.862431Z", "completed_at": "2024-10-25T14:34:36.880432Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.882431Z", "completed_at": "2024-10-25T14:34:36.882431Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02299785614013672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_diagnosis_code_3", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'DIAGNOSIS_CODE_3' AS field_name\n , case when term.icd_10_cm is not null then 'valid'\n when m.diagnosis_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.diagnosis_code_3 is not null\n and term.icd_10_cm is null\n then 'Diagnosis Code does not join to Terminology ICD_10_CM table'\n else null\n end as invalid_reason\n , m.diagnosis_code_3 || '|' || coalesce(term.short_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.icd_10_cm as term on m.diagnosis_code_3 = term.icd_10_cm", "relation_name": "dev_thuxuan.data_quality.professional_diagnosis_code_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.868433Z", "completed_at": "2024-10-25T14:34:36.881431Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.883432Z", "completed_at": "2024-10-25T14:34:36.883432Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023998737335205078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_facility_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'FACILITY_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.facility_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.facility_npi is not null\n and term.npi is null\n then 'Facility NPI does not join to Terminology Provider Table'\n else null\n end as invalid_reason\n , cast(m.facility_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.provider as term on m.facility_npi = term.npi", "relation_name": "dev_thuxuan.data_quality.professional_facility_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.875433Z", "completed_at": "2024-10-25T14:34:36.883432Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.885432Z", "completed_at": "2024-10-25T14:34:36.885432Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02400064468383789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_place_of_service_code", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'PLACE_OF_SERVICE_CODE' AS field_name\n , case when term.place_of_service_code is not null then 'valid'\n when m.place_of_service_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.place_of_service_code is not null\n and term.place_of_service_code is null\n then 'Place of Service Code does not join to Terminology Place of Service table'\n else null\n end as invalid_reason\n , m.place_of_service_code || '|' || coalesce(term.place_of_service_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.place_of_service as term on m.place_of_service_code = term.place_of_service_code", "relation_name": "dev_thuxuan.data_quality.professional_place_of_service_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.889432Z", "completed_at": "2024-10-25T14:34:36.907118Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.907951Z", "completed_at": "2024-10-25T14:34:36.907951Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021518707275390625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__professional_rendering_npi", "compiled": true, "compiled_code": "\n\nwith base as (\n select *\n from tuva.input_layer.medical_claim\n where claim_type = 'professional'\n)\n\nselect\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'professional' AS claim_type\n , 'RENDERING_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.rendering_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.rendering_npi is not null\n and term.npi is null\n then 'Rendering Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.rendering_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join dev_thuxuan.terminology.provider as term on m.rendering_npi = term.npi", "relation_name": "dev_thuxuan.data_quality.professional_rendering_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.913603Z", "completed_at": "2024-10-25T14:34:36.950443Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.952960Z", "completed_at": "2024-10-25T14:34:36.952960Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04180717468261719, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.medical_claim_expanded", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom tuva.input_layer.medical_claim", "relation_name": "dev_thuxuan.claims_expanded.medical_claim_expanded"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.920601Z", "completed_at": "2024-10-25T14:34:36.953972Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.955971Z", "completed_at": "2024-10-25T14:34:36.955971Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.043790578842163086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_date_trends", "compiled": true, "compiled_code": "\n\nwith date_stage as(\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_start_date' as date_field\n , cast(date_part('year', claim_start_date) as TEXT) as year\n , cast(date_part('month', claim_start_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_start_date) as TEXT)\n , cast(date_part('month', claim_start_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'claim_end_date' as date_field\n , cast(date_part('year', claim_end_date) as TEXT) as year\n , cast(date_part('month', claim_end_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', claim_end_date) as TEXT)\n , cast(date_part('month', claim_end_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'admission_date' as date_field\n , cast(date_part('year', admission_date) as TEXT) as year\n , cast(date_part('month', admission_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', admission_date) as TEXT)\n , cast(date_part('month', admission_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'discharge_date' as date_field\n , cast(date_part('year', discharge_date) as TEXT) as year\n , cast(date_part('month', discharge_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', discharge_date) as TEXT)\n , cast(date_part('month', discharge_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'medical paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.medical_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'dispensing_date' as date_field\n , cast(date_part('year', dispensing_date) as TEXT) as year\n , cast(date_part('month', dispensing_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', dispensing_date) as TEXT)\n , cast(date_part('month', dispensing_date) as TEXT)\n )x\n\n union all\n\n select\n date_field\n , year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , result_count\n from\n (\n select\n 'pharmacy paid_date' as date_field\n , cast(date_part('year', paid_date) as TEXT) as year\n , cast(date_part('month', paid_date) as TEXT) as month\n , count(distinct claim_id) as result_count\n from tuva.input_layer.pharmacy_claim\n group by\n cast(date_part('year', paid_date) as TEXT)\n , cast(date_part('month', paid_date) as TEXT)\n )x\n\n)\n\n\n, all_date_range as (\n select distinct\n replace(cal.year_month,'-','') as year_month\n from dev_thuxuan.reference_data.calendar cal\n where (cal.year_month >= (select min(year_month) from date_stage)\n and cal.year_month <= (select max(year_month) from date_stage))\n\n)\n\nselect\n cast(all_date.year_month as integer ) as year_month\n , claim_start.result_count as claim_start_date\n , claim_end.result_count as claim_end_date\n , admission_date.result_count as admission_date\n , discharge_date.result_count as discharge_date\n , med_paid_date.result_count as medical_paid_date\n , dispensing_date.result_count as dispensing_date\n , pharm_paid_date.result_count as pharmacy_paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom all_date_range all_date\nleft join date_stage claim_start\n on all_date.year_month = claim_start.year_month\n and claim_start.date_field = 'claim_start_date'\nleft join date_stage claim_end\n on all_date.year_month = claim_end.year_month\n and claim_end.date_field = 'claim_end_date'\nleft join date_stage admission_date\n on all_date.year_month = admission_date.year_month\n and admission_date.date_field = 'admission_date'\nleft join date_stage discharge_date\n on all_date.year_month = discharge_date.year_month\n and discharge_date.date_field = 'discharge_date'\nleft join date_stage med_paid_date\n on all_date.year_month = med_paid_date.year_month\n and med_paid_date.date_field = 'medical paid_date'\nleft join date_stage dispensing_date\n on all_date.year_month = dispensing_date.year_month\n and dispensing_date.date_field = 'dispensing_date'\nleft join date_stage pharm_paid_date\n on all_date.year_month = pharm_paid_date.year_month\n and pharm_paid_date.date_field = 'pharmacy paid_date'", "relation_name": "dev_thuxuan.data_quality.claim_date_trends"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.957970Z", "completed_at": "2024-10-25T14:34:36.968150Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.973167Z", "completed_at": "2024-10-25T14:34:36.973167Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01819634437561035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__claim_percent", "compiled": true, "compiled_code": "\n\n\nwith cte as \n(\nselect sum(paid_amount) as paid_amount\n,claim_type\nfrom tuva.input_layer.medical_claim\ngroup by claim_type\n\nunion all\n\nselect sum(paid_amount) as paid_amount\n,'pharmacy' as claim_type\nfrom tuva.input_layer.pharmacy_claim\n)\n\n,total_cte as \n(\nselect sum(paid_amount) as total_paid_amount\nfrom cte\n)\n\nselect claim_type\n,paid_amount/total_paid_amount as percent_of_total_paid\nfrom cte\ncross join total_cte", "relation_name": "dev_thuxuan.data_quality.data_quality_claim_percent"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.963107Z", "completed_at": "2024-10-25T14:34:36.973167Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.974191Z", "completed_at": "2024-10-25T14:34:36.974191Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01722097396850586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_allowed_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'ALLOWED_AMOUNT' AS field_name\n , case when m.allowed_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(allowed_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_allowed_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.969127Z", "completed_at": "2024-10-25T14:34:36.975198Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.976189Z", "completed_at": "2024-10-25T14:34:36.976189Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01456141471862793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_date_checks", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when paid_date is null then 1 else 0 end) as missing_paid_date\n , max(case when dispensing_date is null then 1 else 0 end) as missing_dispensing_date\n from tuva.input_layer.pharmacy_claim\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing pharmacy_claim paid_date' as data_quality_check\n , sum(missing_paid_date) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing dispensing_date' as data_quality_check\n , sum(missing_dispensing_date) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_date_checks"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.979189Z", "completed_at": "2024-10-25T14:34:36.990189Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.997209Z", "completed_at": "2024-10-25T14:34:36.997209Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021019935607910156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_ID' AS field_name\n , case\n when m.claim_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.984190Z", "completed_at": "2024-10-25T14:34:36.998192Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:36.999190Z", "completed_at": "2024-10-25T14:34:36.999190Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022000551223754883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_line_number", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'CLAIM_LINE_NUMBER' AS field_name\n , case\n when m.claim_line_number is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_line_number"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.990189Z", "completed_at": "2024-10-25T14:34:37.000190Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.001190Z", "completed_at": "2024-10-25T14:34:37.001190Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016999483108520508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_ndc", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case when term.ndc is null and m.ndc_code is not null then 1 else 0 end) as invalid_ndc\n , max(case when m.ndc_code is null then 1 else 0 end) as missing_ndc\n from tuva.input_layer.pharmacy_claim m\n left join dev_thuxuan.terminology.ndc as term\n on m.ndc_code = term.ndc\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing ndc' as data_quality_check\n , sum(missing_ndc) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'invalid ndc' as data_quality_check\n , sum(invalid_ndc) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_ndc"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.003190Z", "completed_at": "2024-10-25T14:34:37.013169Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.014036Z", "completed_at": "2024-10-25T14:34:37.014036Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01384592056274414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_npi", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n m.claim_id\n , max(case when term.npi is null and m.prescribing_provider_npi is not null then 1 else 0 end) as invalid_prescribing_npi\n , max(case when m.prescribing_provider_npi is null then 1 else 0 end) as missing_prescribing_npi\n , max(case when term.entity_type_code = '2' then 1 else 0 end) as wrong_entity_type_prescribing_npi\n , max(case when term2.npi is null and m.dispensing_provider_npi is not null then 1 else 0 end) as invalid_dispensing_npi\n , max(case when m.dispensing_provider_npi is null then 1 else 0 end) as missing_dispensing_npi\n , max(case when term2.entity_type_code = '1' then 1 else 0 end) as wrong_entity_type_dispensing_npi\n from tuva.input_layer.pharmacy_claim as m\n left join dev_thuxuan.terminology.provider as term\n on m.prescribing_provider_npi = term.npi\n left join dev_thuxuan.terminology.provider as term2\n on m.dispensing_provider_npi = term2.npi\n group by\n m.claim_id\n)\n\n,final as (\nselect\n 'invalid prescribing_npi' as data_quality_check\n , sum(invalid_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing prescribing_npi' as data_quality_check\n , sum(missing_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type prescribing_npi' as data_quality_check\n , sum(wrong_entity_type_prescribing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'invalid dispensing_npi' as data_quality_check\n , sum(invalid_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'missing dispensing_npi' as data_quality_check\n , sum(missing_dispensing_npi) as result_count\nfrom pharmacy_claim\n\nunion all\n\nselect\n 'wrong entity type dispensing_npi' as data_quality_check\n , sum(wrong_entity_type_dispensing_npi) as result_count\nfrom pharmacy_claim\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.009100Z", "completed_at": "2024-10-25T14:34:37.015093Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.020663Z", "completed_at": "2024-10-25T14:34:37.020663Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0184633731842041, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_prescription_details", "compiled": true, "compiled_code": "\n\nwith pharmacy_claim as (\n select\n claim_id\n , max(case \n when quantity is null then 1\n when quantity = 0 then 1\n else 0\n end) as missing_quantity\n , max(case \n when days_supply is null then 1\n when days_supply = 0 then 1\n else 0\n end) as missing_days_supply\n , max(case \n when refills is null then 1\n else 0\n end) as missing_refills\n from tuva.input_layer.pharmacy_claim m\n group by\n claim_id\n)\n\n, final as (\n select\n 'missing quantity' as data_quality_check\n , sum(missing_quantity) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing days supply' as data_quality_check\n , sum(missing_days_supply) as result_count\n from pharmacy_claim\n\n union all\n\n select\n 'missing refills' as data_quality_check\n , sum(missing_refills) as result_count\n from pharmacy_claim\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_prescription_details"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.015483Z", "completed_at": "2024-10-25T14:34:37.021708Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.023685Z", "completed_at": "2024-10-25T14:34:37.023685Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015496253967285156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_volume_and_dollars", "compiled": true, "compiled_code": "\n\nselect\n c.year_month_int as year_month\n , count(distinct p.claim_id) as claim_volume\n , sum(p.paid_amount) as paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim p\nleft join dev_thuxuan.reference_data.calendar c\n on coalesce(p.paid_date, p.dispensing_date) = c.full_date\ngroup by\n c.year_month_int", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_volume_and_dollars"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.025124Z", "completed_at": "2024-10-25T14:34:37.038139Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.039138Z", "completed_at": "2024-10-25T14:34:37.039138Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01743006706237793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_coinsurance_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COINSURANCE_AMOUNT' AS field_name\n , case when m.coinsurance_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(coinsurance_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_coinsurance_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.033129Z", "completed_at": "2024-10-25T14:34:37.040167Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.045999Z", "completed_at": "2024-10-25T14:34:37.045999Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022313594818115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_copayment_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'COPAYMENT_AMOUNT' AS field_name\n , case when m.copayment_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(copayment_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_copayment_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.040167Z", "completed_at": "2024-10-25T14:34:37.047709Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.048707Z", "completed_at": "2024-10-25T14:34:37.048707Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01657724380493164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_data_source", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DATA_SOURCE' AS field_name\n , case\n when m.data_source is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(data_source as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.049705Z", "completed_at": "2024-10-25T14:34:37.066872Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.069277Z", "completed_at": "2024-10-25T14:34:37.069277Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022588253021240234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_days_supply", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DAYS_SUPPLY' AS field_name\n , case\n when m.days_supply is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(days_supply as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_days_supply"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.061242Z", "completed_at": "2024-10-25T14:34:37.068246Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.077258Z", "completed_at": "2024-10-25T14:34:37.077258Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02954888343811035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_deductible_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DEDUCTIBLE_AMOUNT' AS field_name\n , case when m.deductible_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(deductible_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_deductible_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.070296Z", "completed_at": "2024-10-25T14:34:37.079508Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.081505Z", "completed_at": "2024-10-25T14:34:37.081505Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0146331787109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_date", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_DATE' AS field_name\n , case\n when m.dispensing_date > tuva_last_run then 'invalid'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.dispensing_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.dispensing_date > tuva_last_run then 'future'\n when m.dispensing_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(dispensing_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.pharmacy_dispensing_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.082506Z", "completed_at": "2024-10-25T14:34:37.094506Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.095431Z", "completed_at": "2024-10-25T14:34:37.095431Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015923261642456055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_dispensing_provider_npi", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'DISPENSING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.dispensing_provider_npi is not null then 'invalid'\n else 'null'\n end as bucket_name\n , case\n when m.dispensing_provider_npi is not null\n and term.npi is null\n then 'dispensing provider npi does not join to terminology provider table'\n else null\n end as invalid_reason\n , cast(m.dispensing_provider_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join dev_thuxuan.terminology.provider as term on m.dispensing_provider_npi = term.npi", "relation_name": "dev_thuxuan.data_quality.pharmacy_dispensing_provider_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.088526Z", "completed_at": "2024-10-25T14:34:37.095431Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.102562Z", "completed_at": "2024-10-25T14:34:37.102562Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022055864334106445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_member_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'MEMBER_ID' AS field_name\n , case\n when m.member_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(member_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_member_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.096449Z", "completed_at": "2024-10-25T14:34:37.104561Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.106561Z", "completed_at": "2024-10-25T14:34:37.106561Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.013038396835327148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_ndc_code", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'NDC_CODE' AS field_name\n , case when term.ndc is not null then 'valid'\n when m.ndc_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.ndc_code is not null\n and term.ndc is null\n then 'NDC Code does not join to Terminology NDC table'\n else null\n end as invalid_reason\n , m.ndc_code || '|' || coalesce(term.rxnorm_description, term.fda_description, '') as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join dev_thuxuan.terminology.ndc as term on m.ndc_code = term.ndc", "relation_name": "dev_thuxuan.data_quality.pharmacy_ndc_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.108560Z", "completed_at": "2024-10-25T14:34:37.120561Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.121560Z", "completed_at": "2024-10-25T14:34:37.121560Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015999555587768555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_amount", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_AMOUNT' AS field_name\n , case when m.paid_amount is null then 'null'\n else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(paid_amount as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_paid_amount"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.113560Z", "completed_at": "2024-10-25T14:34:37.120561Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.126561Z", "completed_at": "2024-10-25T14:34:37.126561Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021000146865844727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_paid_date", "compiled": true, "compiled_code": "\nwith tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.paid_date > tuva_last_run then 'invalid'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.paid_date is null then 'null'\n else 'valid'\n end as bucket_name\n , case\n when m.paid_date > tuva_last_run then 'future'\n when m.paid_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n , cast(paid_date as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.pharmacy_paid_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.121560Z", "completed_at": "2024-10-25T14:34:37.128561Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.129564Z", "completed_at": "2024-10-25T14:34:37.129564Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010003089904785156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_patient_id", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PATIENT_ID' AS field_name\n , case\n when m.patient_id is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(patient_id as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.131562Z", "completed_at": "2024-10-25T14:34:37.144349Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.153035Z", "completed_at": "2024-10-25T14:34:37.153035Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.024474382400512695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_payer", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAYER' AS field_name\n , case\n when m.payer is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(payer as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.136564Z", "completed_at": "2024-10-25T14:34:37.150464Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.154128Z", "completed_at": "2024-10-25T14:34:37.154128Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024564266204833984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_plan", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PLAN' AS field_name\n , case\n when m.plan is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(plan as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.144349Z", "completed_at": "2024-10-25T14:34:37.176139Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.179122Z", "completed_at": "2024-10-25T14:34:37.179122Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03655672073364258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_prescribing_provider_npi", "compiled": true, "compiled_code": "\n\nSELECT DISTINCT -- to bring to claim_ID grain\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PRESCRIBING_PROVIDER_NPI' AS field_name\n , case when term.npi is not null then 'valid'\n when m.prescribing_provider_npi is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.prescribing_provider_npi is not null\n and term.npi is null\n then 'Prescribing Provider NPI does not join to Terminology Provider table'\n else null\n end as invalid_reason\n , cast(m.prescribing_provider_npi as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m\nleft join dev_thuxuan.terminology.provider as term on m.prescribing_provider_npi = term.npi", "relation_name": "dev_thuxuan.data_quality.pharmacy_prescribing_provider_npi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.186131Z", "completed_at": "2024-10-25T14:34:37.207160Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.208205Z", "completed_at": "2024-10-25T14:34:37.208205Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02805638313293457, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_quantity", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'PAID_DATE' AS field_name\n , case\n when m.quantity is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(quantity as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_quantity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.192140Z", "completed_at": "2024-10-25T14:34:37.207160Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.209507Z", "completed_at": "2024-10-25T14:34:37.209507Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.028464317321777344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_refills", "compiled": true, "compiled_code": "\n\nSELECT\n m.data_source\n , coalesce(cast(m.paid_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'PHARMACY_CLAIM' AS table_name\n , 'Claim ID | Claim Line Number' AS drill_down_key\n , coalesce(cast(m.claim_id as TEXT), 'null') || '|' || coalesce(cast(m.claim_line_number as TEXT), 'null') as drill_down_value\n , 'PHARMACY' AS claim_type\n , 'REFILLS' AS field_name\n , case\n when m.refills is null then 'null' else 'valid' end as bucket_name\n , cast(null as TEXT) as invalid_reason\n , cast(refills as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom tuva.input_layer.pharmacy_claim m", "relation_name": "dev_thuxuan.data_quality.pharmacy_refills"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.202138Z", "completed_at": "2024-10-25T14:34:37.208205Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.210514Z", "completed_at": "2024-10-25T14:34:37.210514Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025394439697265625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__primary_key_check", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.pharmacy_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, medical as (\n select\n claim_id\n , claim_line_number\n , data_source\n , count(*) as result_count\n from tuva.input_layer.medical_claim p\n group by\n claim_id\n , claim_line_number\n , data_source\n having count(*) > 1\n)\n\n, eligibility as (\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n , count(*) as result_count\n from tuva.input_layer.eligibility p\n group by\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , plan\n , data_source\n having count(*) > 1\n)\n\n, final as (\n select\n 'pk errors pharmacy claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from pharmacy\n\n union all\n\n select\n 'pk errors medical claim' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from medical\n\n union all\n\n select\n 'pk errors eligibility' as data_quality_check\n , coalesce(sum(result_count), 0) as result_count\n from eligibility\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.primary_key_check"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.216526Z", "completed_at": "2024-10-25T14:34:37.228526Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.230546Z", "completed_at": "2024-10-25T14:34:37.230546Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.017664194107055664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__raw_summary", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n 'input_layer' as source\n , 'eligibility' as table_name\n , count(*) as row_count\n , count(distinct patient_id) as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 2 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'raw_data' as source\n , 'eligibility' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Patient Count' as unique_check_desc\n , 1 as table_order\n from tuva.input_layer.eligibility\n\n union all\n\n select \n 'input_layer' as source\n , 'medical_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 4 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'medical_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 3 as table_order\n from tuva.input_layer.medical_claim\n\n union all\n\n select \n 'input_layer' as source\n , 'pharmacy_claim' as table_name\n , count(*) as row_count\n , count(distinct claim_id) as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 6 as table_order\n from tuva.input_layer.pharmacy_claim\n\n union all\n\n select \n 'raw_data' as source\n , 'pharmacy_claim' as table_name\n , null as row_count\n , null as unique_check\n , 'Unique Claim Count' as unique_check_desc\n , 5 as table_order\n from tuva.input_layer.pharmacy_claim\n)\n\nselect\n cte.*\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte", "relation_name": "dev_thuxuan.data_quality.raw_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.245814Z", "completed_at": "2024-10-25T14:34:37.311081Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.313078Z", "completed_at": "2024-10-25T14:34:37.313078Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0803227424621582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_detail", "compiled": true, "compiled_code": "\n\nWITH CTE as (\nSELECT * FROM dev_thuxuan.data_quality.condition_claim_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_condition_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_condition_rank\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_condition_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_onset_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_present_on_admit_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_present_on_admit_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_recorded_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_resolved_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.condition_status\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_type_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_admit_type_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_allowed_amount\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_apr_drg_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_apr_drg_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_attending_provider_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_charge_amount\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_discharge_disposition_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_discharge_disposition_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_end_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_start_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_encounter_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_facility_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_length_of_stay\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_ms_drg_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_ms_drg_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_paid_amount\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_primary_diagnosis_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_primary_diagnosis_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.encounter_primary_diagnosis_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_practice_affiliation\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_sub_specialty\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_last_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_npi\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_first_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.practitioner_specialty\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_parent_organization\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_latitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_facility_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_zip_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_city\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_npi\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_location_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_longitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_address\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_state\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.location_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_procedure_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_claim_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_procedure_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_5\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_4\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_1\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_3\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.procedure_modifier_2\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_abnormal_flag\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_specimen\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_collection_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_component\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_ordering_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_result\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_status\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_accession_number\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_result_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_abnormal_flag\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_source_component\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.lab_result_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_sex\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_state\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_city\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_longitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_county\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_race\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_death_flag\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_address\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_zip_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_first_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_last_name\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_latitude\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_birth_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_death_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.patient_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_rxnorm_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_atc_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_dispensing_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_prescribing_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_days_supply\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_strength\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_rxnorm_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_atc_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_quantity_unit\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_ndc_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_medication_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_ndc_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_quantity\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.medication_route\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_observation_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_code\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_data_source\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_panel_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_observation_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_result\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_reference_range_low\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_observation_date\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_description\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_source_reference_range_high\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_units\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_normalized_code_type\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.observation_patient_id\n\n)\n\nSELECT\n data_source,\n cast(source_date as TEXT) as source_date,\n table_name,\n drill_down_key,\n drill_down_value,\n field_name,\n bucket_name,\n invalid_reason,\n field_value,\n tuva_last_run,\n dense_rank() over (order by data_source, table_name, field_name) + 100000 as summary_sk\nFROM CTE", "relation_name": "dev_thuxuan.data_quality.data_quality_clinical_detail"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.331081Z", "completed_at": "2024-10-25T14:34:37.344085Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.345085Z", "completed_at": "2024-10-25T14:34:37.345085Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027007341384887695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__lab_result_lab_result_id.0ee4fe47af", "compiled": true, "compiled_code": "\n \n \n\nselect\n lab_result_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.lab_result\nwhere lab_result_id is not null\ngroup by lab_result_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.357593Z", "completed_at": "2024-10-25T14:34:37.371593Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.372593Z", "completed_at": "2024-10-25T14:34:37.372593Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01799941062927246, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__medication_medication_id.124fd11fa1", "compiled": true, "compiled_code": "\n \n \n\nselect\n medication_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.medication\nwhere medication_id is not null\ngroup by medication_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.387593Z", "completed_at": "2024-10-25T14:34:37.398594Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.400593Z", "completed_at": "2024-10-25T14:34:37.400593Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015000343322753906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__observation_observation_id.ff5f21de59", "compiled": true, "compiled_code": "\n \n \n\nselect\n observation_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.observation\nwhere observation_id is not null\ngroup by observation_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.392593Z", "completed_at": "2024-10-25T14:34:37.400593Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.407276Z", "completed_at": "2024-10-25T14:34:37.407276Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021683692932128906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__unique_value_examples", "compiled": true, "compiled_code": "\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_condition_condition_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_encounter_encounter_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_lab_result_lab_result_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_location_location_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_medication_medication_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_observation_observation_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_patient_patient_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_practitioner_practitioner_id\n\nunion all\n\nSELECT * FROM dev_thuxuan.data_quality.primary_keys_procedure_procedure_id", "relation_name": "dev_thuxuan.data_quality.unique_value_examples"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.402594Z", "completed_at": "2024-10-25T14:34:37.409591Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.410601Z", "completed_at": "2024-10-25T14:34:37.410601Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01300191879272461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_patient_id", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(\n case \n when startdts.month_start_date is null then 1\n when enddts.month_start_date is null then 1\n else 0\n end\n ) as missing_eligibility\n from tuva.input_layer.medical_claim p\n left join dev_thuxuan.data_quality.data_quality__eligibility_dq_stage startdts\n on p.patient_id = startdts.patient_id\n and p.claim_start_date between startdts.month_start_date and startdts.month_end_date\n left join dev_thuxuan.data_quality.data_quality__eligibility_dq_stage enddts\n on p.patient_id = enddts.patient_id\n and p.claim_end_date between enddts.month_start_date and enddts.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple medical_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from medical\n\n union all\n\n select\n 'missing medical_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from medical\n\n union all\n\n select\n 'orphaned medical_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from medical\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.medical_claim_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:36.547006Z", "completed_at": "2024-10-25T14:34:37.314078Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.317081Z", "completed_at": "2024-10-25T14:34:37.317081Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.8921740055084229, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__dx_and_px", "compiled": true, "compiled_code": "\n\nwith unpivot_diagnosis as(\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_1' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_1\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_2' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_2\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_3' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_3\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_4' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_4\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_5' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_5\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_6' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_6\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_7' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_7\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_8' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_8\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_9' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_9\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_10' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_10\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_11' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_11\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_12' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_12\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_13' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_13\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_14' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_14\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_15' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_15\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_16' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_16\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_17' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_17\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_18' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_18\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_19' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_19\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_20' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_20\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_21' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_21\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_22' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_22\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_23' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_23\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_24' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_24\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n diagnosis_code_type,\n\n cast('DIAGNOSIS_CODE_25' as TEXT) as diagnosis_column,\n cast( \n DIAGNOSIS_CODE_25\n \n as TEXT) as diagnosis_code\n\n from tuva.input_layer.medical_claim\n\n \n)\n, unpivot_procedure as(\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_1' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_1\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_2' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_2\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_3' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_3\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_4' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_4\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_5' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_5\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_6' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_6\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_7' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_7\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_8' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_8\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_9' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_9\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_10' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_10\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_11' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_11\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_12' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_12\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_13' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_13\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_14' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_14\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_15' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_15\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_16' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_16\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_17' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_17\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_18' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_18\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_19' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_19\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_20' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_20\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_21' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_21\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_22' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_22\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_23' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_23\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_24' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_24\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n union all\n select\n claim_id,\n procedure_code_type,\n\n cast('PROCEDURE_CODE_25' as TEXT) as procedure_column,\n cast( \n PROCEDURE_CODE_25\n \n as TEXT) as procedure_code\n\n from tuva.input_layer.medical_claim\n\n \n\n\n)\n\n, total_claims as(\n select\n cast(count(distinct claim_id) as integer ) as total_claims\n from tuva.input_layer.medical_claim\n)\n\n, claims_with_primary_dx as(\n select\n count(diagnosis_code_1) as distinct_claims_with_primary\n from tuva.input_layer.medical_claim\n)\n\n, secondary_dx_prep_cte as ( \n select\n tc.total_claims\n , cast(count(distinct claim_id) as integer) as secondary_dx_claim_count\n from unpivot_diagnosis\n cross join total_claims tc\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and\n cast(diagnosis_code as TEXT ) is not null\n group by total_claims\n ) \n\n, claims_with_secondary_dx as (\n select\n total_claims\n , cast(secondary_dx_claim_count as integer ) as secondary_dx_claim_count\n , (cast(secondary_dx_claim_count as integer ) / cast(total_claims as integer )) * 100 as result_count\n , cast('Percent of claims with secondary diagnosis' as TEXT) as data_quality_check\n from\n secondary_dx_prep_cte\n\n)\n, missing_primary_dx as (\n select\n cast('missing primary diagnosis' as TEXT) as data_quality_check\n , cast(count(distinct claim_id) as integer ) as result_count\n from tuva.input_layer.medical_claim m\n where diagnosis_code_1 is null\n)\n, invalid_primary_dx as(\n select\n data_quality_check\n , count(distinct claim_id) as result_count\n from (\n select\n cast('invalid primary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , diagnosis_code_type\n , diagnosis_column\n , diagnosis_code\n , icd_10_cm\n , icd_9_cm\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join dev_thuxuan.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join dev_thuxuan.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n, multiple_primary_dx as(\n\n select\n cast('multiple primary diagnosis' as TEXT) as data_quality_check\n , cast(count(*) as integer ) as result_count\n from\n (\n select\n claim_id\n , row_number() over (partition by claim_id order by claim_id) as row_nbr\n from unpivot_diagnosis\n where diagnosis_column = 'DIAGNOSIS_CODE_1'\n group by\n claim_id\n )x\n where row_nbr > 1\n\n)\n, invalid_secondary_dx as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid secondary diagnosis' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_cm is null and icd9.icd_9_cm is null\n then 1\n else 0\n end as invalid_diagnosis\n from unpivot_diagnosis dx\n left join dev_thuxuan.terminology.icd_10_cm icd10\n on dx.diagnosis_code = icd10.icd_10_cm\n left join dev_thuxuan.terminology.icd_9_cm icd9\n on dx.diagnosis_code = icd9.icd_9_cm\n where diagnosis_column <> 'DIAGNOSIS_CODE_1'\n and diagnosis_code is not null\n )x\n where invalid_diagnosis = 1\n group by\n data_quality_check\n)\n\n, invalid_procedure as(\n select\n data_quality_check\n , count(*) as result_count\n from (\n select\n cast('invalid procedure' as TEXT) as data_quality_check\n , claim_id\n , case\n when icd10.icd_10_pcs is null and icd9.icd_9_pcs is null\n then 1\n else 0\n end as invalid_procedure\n from unpivot_procedure px\n left join dev_thuxuan.terminology.icd_10_pcs icd10\n on px.procedure_code = icd10.icd_10_pcs\n left join dev_thuxuan.terminology.icd_9_pcs icd9\n on px.procedure_code = icd9.icd_9_pcs\n where px.procedure_code is not null\n )x\n where invalid_procedure = 1\n group by\n data_quality_check\n)\n\n, final as (\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from missing_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from multiple_primary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from claims_with_secondary_dx\n\n union all\n\n select cast(data_quality_check as TEXT ) as data_quality_check\n ,result_count\n from invalid_procedure\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.dx_and_px"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.413180Z", "completed_at": "2024-10-25T14:34:37.434180Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.439931Z", "completed_at": "2024-10-25T14:34:37.439931Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.030339956283569336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__pharmacy_claim_patient_id", "compiled": true, "compiled_code": "\n\nwith pharmacy as (\n select\n claim_id\n , count(distinct p.patient_id) as patient_id_count\n , max(case when p.patient_id is null then 1 else 0 end) as missing_patient_id\n , max(case when e.month_start_date is null then 1 else 0 end) as missing_eligibility\n from tuva.input_layer.pharmacy_claim p\n left join dev_thuxuan.data_quality.data_quality__eligibility_dq_stage e\n on p.patient_id = e.patient_id\n and coalesce(p.paid_date, p.dispensing_date) between e.month_start_date and e.month_end_date\n group by\n claim_id\n)\n\n, final as (\n select\n 'multiple pharmacy_claim patient_ids' as data_quality_check\n , sum(case when patient_id_count > 1 then 1 else 0 end) as result_count\n from pharmacy\n\n union all\n\n select\n 'missing pharmacy_claim patient_id' as data_quality_check\n , sum(missing_patient_id) as result_count\n from pharmacy\n\n union all\n\n select\n 'orphaned pharmacy_claim claims' as data_quality_check\n , sum(missing_eligibility) as result_count\n from pharmacy\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.pharmacy_claim_patient_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.420196Z", "completed_at": "2024-10-25T14:34:37.434791Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.440938Z", "completed_at": "2024-10-25T14:34:37.440938Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.030336856842041016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_eligibility_dates_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select distinct\n elig.patient_id\n , elig.patient_id || coalesce(elig.data_source,'') || coalesce(elig.payer,'') || coalesce(elig.plan,'') || coalesce(cast(elig.enrollment_start_date as TEXT),'') || coalesce(cast(elig.enrollment_end_date as TEXT),'') as patient_id_key\n , cal_dob.full_date as normalized_birth_date\n , cal_death.full_date as normalized_death_date\n , cal_enroll_start.full_date as normalized_enrollment_start_date\n , cal_enroll_end.full_date as normalized_enrollment_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join dev_thuxuan.reference_data.calendar cal_dob\n on elig.birth_date = cal_dob.full_date\nleft join dev_thuxuan.reference_data.calendar cal_death\n on elig.death_date = cal_death.full_date\nleft join dev_thuxuan.reference_data.calendar cal_enroll_start\n on elig.enrollment_start_date = cal_enroll_start.full_date\nleft join dev_thuxuan.reference_data.calendar cal_enroll_end\n on elig.enrollment_end_date = cal_enroll_end.full_date", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_eligibility_dates_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.435663Z", "completed_at": "2024-10-25T14:34:37.441942Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.443938Z", "completed_at": "2024-10-25T14:34:37.443938Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.012759685516357422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_date_checks", "compiled": true, "compiled_code": "\n\nwith medical_claim as (\n select m.claim_id,\n max(case when claim_start_date is null then 1 else 0 end) as missing_claim_start_date,\n max(case when claim_end_date is null then 1 else 0 end) as missing_claim_end_date,\n max(case when claim_line_start_date is null then 1 else 0 end) as missing_claim_line_start_date,\n max(case when claim_line_end_date is null then 1 else 0 end) as missing_claim_line_end_date,\n max(case when admission_date is null and d.claim_id is not null then 1 else 0 end) as missing_admission_date,\n max(case when discharge_date is null and d.claim_id is not null then 1 else 0 end) as missing_discharge_date,\n max(case when paid_date is null then 1 else 0 end) as missing_paid_date,\n count(distinct case when d.claim_id is not null then claim_start_date else null end) as claim_start_count,\n count(distinct case when d.claim_id is not null then claim_end_date else null end) as claim_end_count,\n count(distinct case when d.claim_id is not null then admission_date else null end) as admission_date_count,\n count(distinct case when d.claim_id is not null then discharge_date else null end) as discharge_date_count\n from tuva.input_layer.medical_claim m\n left join dev_thuxuan.data_quality.data_quality__inpatient_dq_stage d on m.claim_id = d.claim_id\n group by m.claim_id\n)\n\n,final as (\nselect 'missing claim_start_date' as data_quality_check,\n sum(missing_claim_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_end_date' as data_quality_check,\n sum(missing_claim_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_start_date' as data_quality_check,\n sum(missing_claim_line_start_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing claim_line_end_date' as data_quality_check,\n sum(missing_claim_line_end_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing admission_date' as data_quality_check,\n sum(missing_admission_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing discharge_date' as data_quality_check,\n sum(missing_discharge_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'missing medical_claim paid_date' as data_quality_check,\n sum(missing_paid_date) as result_count\nfrom medical_claim\n\nunion all\n\nselect 'claim start multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_start_count > 1\n\nunion all\n\nselect 'claim end multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere claim_end_count > 1\n\nunion all\n\nselect 'admission date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere admission_date_count > 1\n\nunion all\n\nselect 'discharge date multiple' as data_quality_check,\n count(distinct claim_id) as result_count\nfrom medical_claim\nwhere discharge_date_count > 1\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.medical_claim_date_checks"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.445941Z", "completed_at": "2024-10-25T14:34:37.453474Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.498926Z", "completed_at": "2024-10-25T14:34:37.498926Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.05798840522766113, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__medical_claim_inst_header_fields", "compiled": true, "compiled_code": "\n\nwith inst_header as (\n select\n m.claim_id\n , max(case when m.claim_type = 'institutional' and btc.bill_type_code is null and m.bill_type_code is not null then 1 else 0 end) as invalid_bill_type_code\n , max(case when m.claim_type = 'institutional' and dd.discharge_disposition_code is null and m.discharge_disposition_code is not null then 1 else 0 end) as invalid_discharge_disposition_code\n , max(case when d.claim_id is not null and ms.ms_drg_code is null and m.ms_drg_code is not null then 1 else 0 end) as invalid_ms_drg_code\n , max(case when d.claim_id is not null and apr.apr_drg_code is null and m.apr_drg_code is not null then 1 else 0 end) as invalid_apr_drg_code\n , max(case when m.claim_type = 'institutional' and m.bill_type_code is null then 1 else 0 end) as missing_bill_type_code\n , max(case when m.claim_type = 'institutional' and m.discharge_disposition_code is null then 1 else 0 end) as missing_discharge_disposition_code\n , max(case when d.claim_id is not null and m.ms_drg_code is null then 1 else 0 end) as missing_ms_drg_code\n , max(case when d.claim_id is not null and m.apr_drg_code is null then 1 else 0 end) as missing_apr_drg_code\n , count(distinct case when m.claim_type = 'institutional' then m.bill_type_code else null end) as bill_type_code_count\n , count(distinct case when m.claim_type = 'institutional' then m.discharge_disposition_code else null end) as discharge_disposition_code_count\n , count(distinct case when d.claim_id is not null then m.ms_drg_code else null end) as ms_drg_code_count\n , count(distinct case when d.claim_id is not null then m.apr_drg_code else null end) as apr_drg_code_count\n from tuva.input_layer.medical_claim as m\n left join dev_thuxuan.data_quality.data_quality__inpatient_dq_stage as d\n on m.claim_id = d.claim_id\n left join dev_thuxuan.terminology.bill_type as btc\n on m.bill_type_code = btc.bill_type_code\n left join dev_thuxuan.terminology.ms_drg as ms\n on m.ms_drg_code = ms.ms_drg_code\n left join dev_thuxuan.terminology.apr_drg as apr\n on m.ms_drg_code = apr.apr_drg_code\n left join dev_thuxuan.terminology.discharge_disposition as dd\n on m.discharge_disposition_code = dd.discharge_disposition_code\n group by m.claim_id\n)\n\n, final as (\n select\n 'invalid bill_type_code' as data_quality_check\n , sum(invalid_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid ms_drg_code' as data_quality_check\n , sum(invalid_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid apr_drg_code' as data_quality_check\n , sum(invalid_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'invalid discharge_disposition_code' as data_quality_check\n , sum(invalid_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing bill_type_code' as data_quality_check\n , sum(missing_bill_type_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing ms_drg_code' as data_quality_check\n , sum(missing_ms_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing apr_drg_code' as data_quality_check\n , sum(missing_apr_drg_code) as result_count\n from inst_header\n\n union all\n\n select\n 'missing discharge_disposition_code' as data_quality_check\n , sum(missing_discharge_disposition_code) as result_count\n from inst_header\n\n union all\n\n select\n 'bill_type_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where bill_type_code_count > 1\n\n union all\n\n select\n 'ms_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where ms_drg_code_count > 1\n\n union all\n\n select\n 'apr_drg_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where apr_drg_code_count > 1\n\n union all\n\n select\n 'discharge_disposition_code multiple' as data_quality_check\n , count(distinct claim_id) as result_count\n from inst_header\n where discharge_disposition_code_count > 1\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.medical_claim_inst_header_fields"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.454509Z", "completed_at": "2024-10-25T14:34:37.518925Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.519926Z", "completed_at": "2024-10-25T14:34:37.519926Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0759882926940918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_admission_date", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(admission_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'ADMISSION_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.admission_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.admission_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.admission_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n else null\n end as invalid_reason\n ,cast(substring(agg.field_aggregated, 1, 255) as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_admission_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.477849Z", "completed_at": "2024-10-25T14:34:37.519926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.521926Z", "completed_at": "2024-10-25T14:34:37.521926Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07698726654052734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_source_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_source_code || '|' || coalesce(term.admit_source_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.admit_source as term on base.admit_source_code = term.admit_source_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_SOURCE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_source_code is not null then 'valid'\n when m.admit_source_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_source_code is not null\n and term.admit_source_code is null\n and cg. frequency = 1\n then 'Admit source code does not join to Terminology Admit Source table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.admit_source as term on m.admit_source_code = term.admit_source_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_admit_source_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.499929Z", "completed_at": "2024-10-25T14:34:37.520927Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.522926Z", "completed_at": "2024-10-25T14:34:37.522926Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.06945180892944336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_admit_type_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.admit_type_code || '|' || coalesce(term.admit_type_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.admit_type as term on base.admit_type_code = term.admit_type_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Member ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'ADMIT_TYPE_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.admit_type_code is not null then 'valid'\n when m.admit_type_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when m.admit_type_code is not null\n and term.admit_type_code is null\n and cg.frequency = 1\n then 'Admit Type Code does not join to Terminology Admit Type table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.admit_type as term on m.admit_type_code = term.admit_type_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_admit_type_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.524928Z", "completed_at": "2024-10-25T14:34:37.577821Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.597822Z", "completed_at": "2024-10-25T14:34:37.597822Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.07589602470397949, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_apr_drg_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.apr_drg_code || '|' || coalesce(term.apr_drg_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.apr_drg as term on base.apr_drg_code = term.apr_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'APR_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.apr_drg_code is not null then 'valid'\n when m.apr_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.apr_drg_code is not null\n and term.apr_drg_code is null\n then 'APR DRG Code does not join to Terminology APR DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.apr_drg as term on m.apr_drg_code = term.apr_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_apr_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.547950Z", "completed_at": "2024-10-25T14:34:37.590822Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.599823Z", "completed_at": "2024-10-25T14:34:37.599823Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.07589340209960938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_discharge_date", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n,unique_field as (\n select distinct claim_id\n ,cast(discharge_date as TEXT) as field\n ,data_source\n from base\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'DISCHARGE_DATE' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when m.discharge_date < m.admission_date then 'invalid'\n when m.discharge_date is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.discharge_date > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.discharge_date < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when m.discharge_date < m.admission_date then 'discharge date before admission date'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_discharge_date"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.578821Z", "completed_at": "2024-10-25T14:34:37.622824Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.623821Z", "completed_at": "2024-10-25T14:34:37.623821Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07889199256896973, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_ms_drg_code", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , base.ms_drg_code || '|' || coalesce(term.ms_drg_description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.ms_drg as term on base.ms_drg_code = term.ms_drg_code\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'MS_DRG_CODE' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.ms_drg_code is not null then 'valid'\n when m.ms_drg_code is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.ms_drg_code is not null\n and term.ms_drg_code is null\n then 'MS DRG does not join to Terminology MS DRG table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.ms_drg as term on m.ms_drg_code = term.ms_drg_code\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_ms_drg_code"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.601822Z", "completed_at": "2024-10-25T14:34:37.624823Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.626824Z", "completed_at": "2024-10-25T14:34:37.626824Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04900217056274414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_1", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_1 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_1' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_1 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_1 is not null\n and term.icd_10_pcs is null\n then 'procedure code does not join to terminology procedure code table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_pcs as term on m.procedure_code_1 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_procedure_code_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.627824Z", "completed_at": "2024-10-25T14:34:37.668345Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.703343Z", "completed_at": "2024-10-25T14:34:37.703343Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.07952165603637695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_2", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_2 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_pcs as term on base.procedure_code_1 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n\t)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_2' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_2 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_2 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_pcs as term on m.procedure_code_2 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_procedure_code_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.648828Z", "completed_at": "2024-10-25T14:34:37.703343Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.732387Z", "completed_at": "2024-10-25T14:34:37.732387Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.10855340957641602, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_code_3", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n),\n\nunique_field as (\n select distinct claim_id\n , procedure_code_3 || '|' || coalesce(term.description, '') as field\n , data_source\n from base\n left join dev_thuxuan.terminology.icd_10_pcs as term on base.procedure_code_3 = term.icd_10_pcs\n),\n\nclaim_grain as (\n select claim_id\n , data_source\n , count(*) as frequency\n from unique_field\n group by claim_id\n , data_source\n),\n\nclaim_agg as (\nselect\n claim_id\n , data_source\n , \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id\n , data_source\n)\n\nselect distinct -- to bring to claim_id grain\n m.data_source\n , coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n , 'MEDICAL_CLAIM' AS table_name\n , 'Claim ID' AS drill_down_key\n , coalesce(m.claim_id, 'NULL') AS drill_down_value\n , 'institutional' AS claim_type\n , 'PROCEDURE_CODE_3' AS field_name\n , case when cg.frequency > 1 then 'multiple'\n when term.icd_10_pcs is not null then 'valid'\n when m.procedure_code_3 is not null then 'invalid'\n else 'null' end as bucket_name\n , case\n when cg.frequency = 1\n and m.procedure_code_3 is not null\n and term.icd_10_pcs is null\n then 'Procedure Code does not join to Terminology Procedure Code Table'\n else null\n end as invalid_reason\n , cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join dev_thuxuan.terminology.icd_10_pcs as term on m.procedure_code_3 = term.icd_10_pcs\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source", "relation_name": "dev_thuxuan.data_quality.institutional_procedure_code_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.670347Z", "completed_at": "2024-10-25T14:34:37.732387Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.735391Z", "completed_at": "2024-10-25T14:34:37.735391Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08756327629089355, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_1", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n)\n, unique_field as (\n select distinct claim_id\n ,cast(procedure_date_1 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_1' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_1 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_1 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date_1 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_1 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_procedure_date_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.707342Z", "completed_at": "2024-10-25T14:34:37.736444Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.739471Z", "completed_at": "2024-10-25T14:34:37.739471Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.07112598419189453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_2", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_2 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_2' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_2 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_2 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date_2 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_2 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n when m.procedure_date_2 is null then null\n else 'valid'\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_procedure_date_2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.742471Z", "completed_at": "2024-10-25T14:34:37.800930Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.817234Z", "completed_at": "2024-10-25T14:34:37.817234Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.07982635498046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__institutional_procedure_date_3", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__data_quality__stg_institutional_inpatient as (\n\n\n\n SELECT *\n FROM tuva.input_layer.medical_claim\n WHERE claim_type = 'institutional'\n AND \n substr(bill_type_code, 1, 2)\n = '11'\n), base as (\nselect *\nfrom __dbt__cte__data_quality__stg_institutional_inpatient\n)\n, tuva_last_run as(\n\n select cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run\n\n)\n\n,unique_field as (\n select distinct claim_id\n ,cast(procedure_date_3 as TEXT) as field\n ,data_source\n from base\n\n),\nclaim_grain as (\n select claim_id\n ,data_source\n ,count(*) as frequency\n from unique_field\n group by claim_id\n ,data_source\n),\nclaim_agg as (\nselect\n claim_id,\n data_source,\n \n listagg(\n coalesce(field, 'null'),\n ', '\n )\n within group (order by field desc) as field_aggregated\nfrom\n unique_field\ngroup by\n claim_id,\n data_source\n\t)\nselect distinct -- to bring to claim_id grain\n m.data_source\n ,coalesce(cast(m.claim_start_date as TEXT),cast('1900-01-01' as TEXT)) as source_date\n ,'MEDICAL_CLAIM' AS table_name\n ,'Claim ID' AS drill_down_key\n ,coalesce(m.claim_id, 'NULL') AS drill_down_value\n ,'institutional' AS claim_type\n ,'PROCEDURE_DATE_3' AS field_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'invalid'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'invalid'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'invalid'\n when m.procedure_date_3 is null then 'null'\n else 'valid'\n end as bucket_name\n ,case\n when cg.frequency > 1 then 'multiple'\n when m.procedure_date_3 > cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) then 'future'\n when m.procedure_date_3 < \n\n dateadd(\n year,\n -10,\n cte.tuva_last_run\n )\n\n then 'too old'\n when not (m.procedure_date_3 between m.claim_start_date and m.claim_end_date) then 'procedure date not between claim start and end dates'\n else null\n end as invalid_reason\n ,cast(\n substr(agg.field_aggregated, 1, 255)\n as TEXT) as field_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom base m\nleft join claim_grain cg on m.claim_id = cg.claim_id and m.data_source = cg.data_source\nleft join claim_agg agg on m.claim_id = agg.claim_id and m.data_source = agg.data_source\ncross join tuva_last_run cte", "relation_name": "dev_thuxuan.data_quality.institutional_procedure_date_3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.770791Z", "completed_at": "2024-10-25T14:34:37.815763Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.819235Z", "completed_at": "2024-10-25T14:34:37.819235Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.07876348495483398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_voting", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_source_code\n\n , admit.admit_source_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.admit_source admit\n on med.admit_source_code = admit.admit_source_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n , count(*) as admit_source_occurrence_count\n from normalize_cte\n where admit_source_code is not null\n group by \n claim_id\n , data_source\n , admit_source_code\n , admit_source_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_source_code' as column_name\n , admit_source_code as normalized_code\n , admit_source_description as normalized_description\n , admit_source_occurrence_count as occurrence_count\n , coalesce(lead(admit_source_occurrence_count) \n over (partition by claim_id, data_source order by admit_source_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_source_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.784905Z", "completed_at": "2024-10-25T14:34:37.816229Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.820234Z", "completed_at": "2024-10-25T14:34:37.820234Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07876467704772949, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , admit.admit_type_code\n , admit.admit_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.admit_type admit\n on med.admit_type_code = admit.admit_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n , count(*) as admit_type_occurrence_count\n from normalize_cte\n\n where admit_type_code is not null\n group by \n claim_id\n , data_source\n , admit_type_code\n , admit_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'admit_type_code' as column_name\n , admit_type_code as normalized_code\n , admit_type_description as normalized_description\n , admit_type_occurrence_count as occurrence_count\n , coalesce(lead(admit_type_occurrence_count) \n over (partition by claim_id, data_source order by admit_type_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by admit_type_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_normalize_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.800930Z", "completed_at": "2024-10-25T14:34:37.820234Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.824276Z", "completed_at": "2024-10-25T14:34:37.824276Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.05421257019042969, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n\n select \n med.claim_id\n , med.data_source\n , apr.apr_drg_code\n , apr.apr_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.apr_drg apr\n on med.apr_drg_code = apr.apr_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n , count(*) as apr_drg_occurrence_count\n from normalize_cte\n where apr_drg_code is not null\n group by \n claim_id\n , data_source\n , apr_drg_code\n , apr_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'apr_drg_code' as column_name\n , apr_drg_code as normalized_code\n , apr_drg_description as normalized_description\n , apr_drg_occurrence_count as occurrence_count\n , coalesce(lead(apr_drg_occurrence_count) \n over (partition by claim_id, data_source order by apr_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by apr_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.847338Z", "completed_at": "2024-10-25T14:34:37.923025Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.926030Z", "completed_at": "2024-10-25T14:34:37.926030Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.09879040718078613, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_diagnosis as(\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_1' as diagnosis_column\n , diagnosis_code_1 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_2' as diagnosis_column\n , diagnosis_code_2 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_3' as diagnosis_column\n , diagnosis_code_3 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_4' as diagnosis_column\n , diagnosis_code_4 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_5' as diagnosis_column\n , diagnosis_code_5 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_6' as diagnosis_column\n , diagnosis_code_6 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_7' as diagnosis_column\n , diagnosis_code_7 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_8' as diagnosis_column\n , diagnosis_code_8 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_9' as diagnosis_column\n , diagnosis_code_9 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_10' as diagnosis_column\n , diagnosis_code_10 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_11' as diagnosis_column\n , diagnosis_code_11 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_12' as diagnosis_column\n , diagnosis_code_12 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_13' as diagnosis_column\n , diagnosis_code_13 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_14' as diagnosis_column\n , diagnosis_code_14 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_15' as diagnosis_column\n , diagnosis_code_15 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_16' as diagnosis_column\n , diagnosis_code_16 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_17' as diagnosis_column\n , diagnosis_code_17 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_18' as diagnosis_column\n , diagnosis_code_18 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_19' as diagnosis_column\n , diagnosis_code_19 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_20' as diagnosis_column\n , diagnosis_code_20 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_21' as diagnosis_column\n , diagnosis_code_21 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_22' as diagnosis_column\n , diagnosis_code_22 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_23' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_24' as diagnosis_column\n , diagnosis_code_24 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , diagnosis_code_type\n , 'diagnosis_code_25' as diagnosis_column\n , diagnosis_code_25 as diagnosis_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm) as normalized_diagnosis_code\n , count(*) as diagnosis_code_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_diagnosis piv\nleft join dev_thuxuan.terminology.icd_10_cm icd_10\n on replace(piv.diagnosis_code,'.','') = icd_10.icd_10_cm\n and piv.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd_9\n on replace(piv.diagnosis_code,'.','') = icd_9.icd_9_cm\n and piv.diagnosis_code_type = 'icd-9-cm'\nwhere claim_type <> 'undetermined'\ngroup by \n claim_id\n , data_source\n , diagnosis_code_type\n , diagnosis_column\n , coalesce(icd_9.icd_9_cm,icd_10.icd_10_cm)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.893845Z", "completed_at": "2024-10-25T14:34:37.924030Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.927031Z", "completed_at": "2024-10-25T14:34:37.927031Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.09979104995727539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , disch.discharge_disposition_code\n , disch.discharge_disposition_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.discharge_disposition disch\n on med.discharge_disposition_code = disch.discharge_disposition_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n , count(*) as discharge_disposition_occurrence_count\n from normalize_cte\n where discharge_disposition_code is not null\n group by \n claim_id\n , data_source\n , discharge_disposition_code\n , discharge_disposition_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'discharge_disposition_code' as column_name\n , discharge_disposition_code as normalized_code\n , discharge_disposition_description as normalized_description\n , discharge_disposition_occurrence_count as occurrence_count\n , coalesce(lead(discharge_disposition_occurrence_count) \n over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by discharge_disposition_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.831240Z", "completed_at": "2024-10-25T14:34:37.926030Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.928030Z", "completed_at": "2024-10-25T14:34:37.928030Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.10279083251953125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , bill.bill_type_code\n , bill.bill_type_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.bill_type bill\n on ltrim(med.bill_type_code, '0') = bill.bill_type_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n , count(*) as bill_type_occurrence_count\n from normalize_cte\n where bill_type_code is not null\n group by \n claim_id\n , data_source\n , bill_type_code\n , bill_type_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'bill_type_code' as column_name\n , bill_type_code as normalized_code\n , bill_type_description as normalized_description\n , bill_type_occurrence_count as occurrence_count\n , row_number() over (partition by claim_id, data_source order by bill_type_occurrence_count desc, bill_type_code asc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.909971Z", "completed_at": "2024-10-25T14:34:37.926030Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:37.929030Z", "completed_at": "2024-10-25T14:34:37.929030Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.09879040718078613, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_medical_claim_date_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , cal_claim_start.full_date as normalized_claim_start_date\n , cal_claim_end.full_date as normalized_claim_end_date\n , cal_claim_line_start.full_date as normalized_claim_line_start_date\n , cal_claim_line_end.full_date as normalized_claim_line_end_date\n , cal_admission.full_date as normalized_admission_date\n , cal_discharge.full_date as normalized_discharge_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.reference_data.calendar cal_claim_start\n on med.claim_start_date = cal_claim_start.full_date\nleft join dev_thuxuan.reference_data.calendar cal_claim_end\n on med.claim_end_date = cal_claim_end.full_date\nleft join dev_thuxuan.reference_data.calendar cal_claim_line_start\n on med.claim_line_start_date = cal_claim_line_start.full_date\nleft join dev_thuxuan.reference_data.calendar cal_claim_line_end\n on med.claim_line_end_date = cal_claim_line_end.full_date\nleft join dev_thuxuan.reference_data.calendar cal_admission\n on med.admission_date = cal_admission.full_date\nleft join dev_thuxuan.reference_data.calendar cal_discharge\n on med.discharge_date = cal_discharge.full_date", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.948039Z", "completed_at": "2024-10-25T14:34:38.011645Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.012642Z", "completed_at": "2024-10-25T14:34:38.012642Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07961177825927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_voting", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), normalize_cte as(\n select \n med.claim_id\n , med.data_source\n , ms.ms_drg_code\n , ms.ms_drg_description\n from __dbt__cte__normalized_input__stg_medical_claim med\n inner join dev_thuxuan.terminology.ms_drg ms\n on med.ms_drg_code = ms.ms_drg_code\n where claim_type = 'institutional'\n)\n, distinct_counts as(\n select \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , count(*) as ms_drg_occurrence_count\n from normalize_cte\n where ms_drg_code is not null\n group by \n claim_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n)\n\n, occurence_comparison as(\n select\n claim_id\n , data_source\n , 'ms_drg_code' as column_name\n , ms_drg_code as normalized_code\n , ms_drg_description as normalized_description\n , ms_drg_occurrence_count as occurrence_count\n , coalesce(lead(ms_drg_occurrence_count) \n over (partition by claim_id, data_source order by ms_drg_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by claim_id, data_source order by ms_drg_occurrence_count desc) as occurrence_row_count\n from distinct_counts dist\n)\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom occurence_comparison", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.936030Z", "completed_at": "2024-10-25T14:34:38.011645Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.014644Z", "completed_at": "2024-10-25T14:34:38.014644Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.08261322975158691, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_medical_npi_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_type\n , med.data_source\n , rend_prov.npi as normalized_rendering_npi\n , cast(coalesce(rend_prov.provider_last_name || ', ' || rend_prov.provider_first_name, rend_prov.provider_organization_name) as TEXT ) as normalized_rendering_name\n , bill_prov.npi as normalized_billing_npi\n , cast(coalesce(bill_prov.provider_last_name || ', ' || bill_prov.provider_first_name, bill_prov.provider_organization_name) as TEXT ) as normalized_billing_name\n , fac_prov.npi as normalized_facility_npi\n , cast(coalesce(fac_prov.provider_last_name || ', ' || fac_prov.provider_first_name, fac_prov.provider_organization_name) as TEXT ) as normalized_facility_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.provider rend_prov\n on med.rendering_npi = rend_prov.npi\n and rend_prov.entity_type_description = 'Individual'\nleft join dev_thuxuan.terminology.provider bill_prov\n on med.billing_npi = bill_prov.npi\nleft join dev_thuxuan.terminology.provider fac_prov\n on med.facility_npi = fac_prov.npi\n and fac_prov.entity_type_description = 'Organization'\n and med.claim_type = 'institutional'", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_medical_npi_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.962693Z", "completed_at": "2024-10-25T14:34:38.013642Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.016643Z", "completed_at": "2024-10-25T14:34:38.016643Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.08361291885375977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_place_of_service_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , pos.place_of_service_code as normalized_code\n , pos.place_of_service_description as normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.place_of_service pos\n \n on lpad(med.place_of_service_code, 2, '0') = pos.place_of_service_code\n \nwhere claim_type = 'professional'", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_place_of_service_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:37.970682Z", "completed_at": "2024-10-25T14:34:38.013642Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.016643Z", "completed_at": "2024-10-25T14:34:38.016643Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.08361077308654785, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_poa as(\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_1' as diagnosis_column\n , diagnosis_poa_1 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_2' as diagnosis_column\n , diagnosis_poa_2 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_3' as diagnosis_column\n , diagnosis_poa_3 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_4' as diagnosis_column\n , diagnosis_poa_4 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_5' as diagnosis_column\n , diagnosis_poa_5 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_6' as diagnosis_column\n , diagnosis_poa_6 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_7' as diagnosis_column\n , diagnosis_poa_7 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_8' as diagnosis_column\n , diagnosis_poa_8 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_9' as diagnosis_column\n , diagnosis_poa_9 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_10' as diagnosis_column\n , diagnosis_poa_10 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_11' as diagnosis_column\n , diagnosis_poa_11 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_12' as diagnosis_column\n , diagnosis_poa_12 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_13' as diagnosis_column\n , diagnosis_poa_13 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_14' as diagnosis_column\n , diagnosis_poa_14 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_15' as diagnosis_column\n , diagnosis_poa_15 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_16' as diagnosis_column\n , diagnosis_poa_16 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_17' as diagnosis_column\n , diagnosis_poa_17 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_18' as diagnosis_column\n , diagnosis_poa_18 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_19' as diagnosis_column\n , diagnosis_poa_19 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_20' as diagnosis_column\n , diagnosis_poa_20 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_21' as diagnosis_column\n , diagnosis_poa_21 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_22' as diagnosis_column\n , diagnosis_poa_22 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_23' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_24' as diagnosis_column\n , diagnosis_poa_24 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'diagnosis_poa_25' as diagnosis_column\n , diagnosis_poa_25 as present_on_admit_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code as normalized_present_on_admit_code\n , count(*) as present_on_admit_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_poa piv\nleft join dev_thuxuan.terminology.present_on_admission poa\n on replace(piv.present_on_admit_code,'.','') = poa.present_on_admit_code\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , diagnosis_column\n , poa.present_on_admit_code", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.022006Z", "completed_at": "2024-10-25T14:34:38.155219Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.158217Z", "completed_at": "2024-10-25T14:34:38.158217Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.13921594619750977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_1' as procedure_column\n , procedure_code_1 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_2' as procedure_column\n , procedure_code_2 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_3' as procedure_column\n , procedure_code_3 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_4' as procedure_column\n , procedure_code_4 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_5' as procedure_column\n , procedure_code_5 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_6' as procedure_column\n , procedure_code_6 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_7' as procedure_column\n , procedure_code_7 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_8' as procedure_column\n , procedure_code_8 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_9' as procedure_column\n , procedure_code_9 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_10' as procedure_column\n , procedure_code_10 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_11' as procedure_column\n , procedure_code_11 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_12' as procedure_column\n , procedure_code_12 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_13' as procedure_column\n , procedure_code_13 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_14' as procedure_column\n , procedure_code_14 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_15' as procedure_column\n , procedure_code_15 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_16' as procedure_column\n , procedure_code_16 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_17' as procedure_column\n , procedure_code_17 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_18' as procedure_column\n , procedure_code_18 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_19' as procedure_column\n , procedure_code_19 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_20' as procedure_column\n , procedure_code_20 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_21' as procedure_column\n , procedure_code_21 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_22' as procedure_column\n , procedure_code_22 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_23' as procedure_column\n , procedure_code_23 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_24' as procedure_column\n , procedure_code_24 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , procedure_code_type\n , 'procedure_code_25' as procedure_column\n , procedure_code_25 as procedure_code\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs) as normalized_procedure_code\n , count(*) as procedure_code_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join dev_thuxuan.terminology.icd_10_pcs icd_10\n on replace(piv.procedure_code,'.','') = icd_10.icd_10_pcs\n and piv.procedure_code_type = 'icd-10-pcs'\nleft join dev_thuxuan.terminology.icd_9_pcs icd_9\n on replace(piv.procedure_code,'.','') = icd_9.icd_9_pcs\n and piv.procedure_code_type = 'icd-9-pcs'\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_code_type\n , procedure_column\n , coalesce(icd_9.icd_9_pcs,icd_10.icd_10_pcs)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.067531Z", "completed_at": "2024-10-25T14:34:38.158217Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.160217Z", "completed_at": "2024-10-25T14:34:38.160217Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.1402111053466797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n), pivot_procedure as(\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_1' as procedure_column\n , procedure_date_1 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_2' as procedure_column\n , procedure_date_2 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_3' as procedure_column\n , procedure_date_3 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_4' as procedure_column\n , procedure_date_4 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_5' as procedure_column\n , procedure_date_5 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_6' as procedure_column\n , procedure_date_6 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_7' as procedure_column\n , procedure_date_7 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_8' as procedure_column\n , procedure_date_8 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_9' as procedure_column\n , procedure_date_9 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_10' as procedure_column\n , procedure_date_10 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_11' as procedure_column\n , procedure_date_11 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_12' as procedure_column\n , procedure_date_12 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_13' as procedure_column\n , procedure_date_13 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_14' as procedure_column\n , procedure_date_14 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_15' as procedure_column\n , procedure_date_15 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_16' as procedure_column\n , procedure_date_16 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_17' as procedure_column\n , procedure_date_17 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_18' as procedure_column\n , procedure_date_18 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_19' as procedure_column\n , procedure_date_19 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_20' as procedure_column\n , procedure_date_20 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_21' as procedure_column\n , procedure_date_21 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_22' as procedure_column\n , procedure_date_22 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_23' as procedure_column\n , procedure_date_23 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_24' as procedure_column\n , procedure_date_24 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n\n union all\n\n select\n claim_id\n , claim_type\n , data_source\n , 'procedure_date_25' as procedure_column\n , procedure_date_25 as procedure_date\n from __dbt__cte__normalized_input__stg_medical_claim\n)\n\nselect\n claim_id\n , data_source\n , procedure_column\n , cal.full_date as procedure_date\n , count(*) as procedure_date_occurrence_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pivot_procedure piv\nleft join dev_thuxuan.reference_data.calendar cal\n on piv.procedure_date = cal.full_date\nwhere claim_type = 'institutional'\ngroup by \n claim_id\n , data_source\n , procedure_column\n , cal.full_date", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.107534Z", "completed_at": "2024-10-25T14:34:38.160217Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.162217Z", "completed_at": "2024-10-25T14:34:38.162217Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.14121222496032715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_revenue_center_normalize", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , data_source\n , rev.revenue_center_code as normalized_code\n , rev.revenue_center_description as normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.revenue_center rev\n \n on lpad(med.revenue_center_code, 4, '0') = rev.revenue_center_code\n \nwhere claim_type = 'institutional'", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_revenue_center_normalize"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.114531Z", "completed_at": "2024-10-25T14:34:38.160217Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.163219Z", "completed_at": "2024-10-25T14:34:38.163219Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.1422138214111328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_undetermined_claim_type", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , ad_src.admit_source_code\n , ad_src.admit_source_description\n , ad_type.admit_type_code\n , ad_type.admit_type_description\n , dis.discharge_disposition_code\n , dis.discharge_disposition_description\n , pos.place_of_service_code\n , pos.place_of_service_description\n , tob.bill_type_code\n , tob.bill_type_description\n , msdrg.ms_drg_code\n , msdrg.ms_drg_description\n , aprdrg.apr_drg_code\n , aprdrg.apr_drg_description\n , rev.revenue_center_code\n , rev.revenue_center_description\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendnpi.npi as rendering_name\n , billing_npi\n , billnpi.npi as billing_name\n , facility_npi\n , facnpi.npi as facility_name\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.terminology.admit_source ad_src\n on med.admit_source_code = ad_src.admit_source_code\nleft join dev_thuxuan.terminology.admit_type ad_type\n on med.admit_type_code = ad_type.admit_type_code\nleft join dev_thuxuan.terminology.discharge_disposition dis\n on med.discharge_disposition_code = dis.discharge_disposition_code\nleft join dev_thuxuan.terminology.place_of_service pos\n on med.place_of_service_code = pos.place_of_service_code\nleft join dev_thuxuan.terminology.bill_type tob\n on med.bill_type_code = tob.bill_type_code\nleft join dev_thuxuan.terminology.ms_drg msdrg\n on med.ms_drg_code = msdrg.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg aprdrg\n on med.apr_drg_code = aprdrg.apr_drg_code\nleft join dev_thuxuan.terminology.revenue_center rev\n on med.revenue_center_code = rev.revenue_center_code\nleft join dev_thuxuan.terminology.provider rendnpi\n on med.rendering_npi = rendnpi.npi\nleft join dev_thuxuan.terminology.provider billnpi\n on med.billing_npi = billnpi.npi\nleft join dev_thuxuan.terminology.provider facnpi\n on med.facility_npi = facnpi.npi\nwhere claim_type in ('undetermined')", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_undetermined_claim_type"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.168216Z", "completed_at": "2024-10-25T14:34:38.245239Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.252792Z", "completed_at": "2024-10-25T14:34:38.252792Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08757495880126953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__pharmacy_claim", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_pharmacy_claim as (\n\n\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , member_id\n , payer\n , plan\n , prescribing_provider_npi\n , dispensing_provider_npi\n , dispensing_date\n , ndc_code\n , quantity\n , days_supply\n , refills\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , in_network_flag\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.pharmacy_claim\n) select\n cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as int ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , cast(plan as TEXT ) as plan\n , cast(prescribing_provider_npi as TEXT ) as prescribing_provider_id\n , cast(coalesce(pres.provider_last_name || ', ' || pres.provider_first_name, pres.provider_organization_name) as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_npi as TEXT ) as dispensing_provider_id\n , cast(coalesce(disp.provider_last_name || ', ' || disp.provider_first_name, disp.provider_organization_name) as TEXT ) as dispensing_provider_name , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc.fda_description as TEXT ) as ndc_description\n , cast(quantity as int ) as quantity\n , cast(days_supply as int ) as days_supply\n , cast(refills as int ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6) ) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_pharmacy_claim pharm\nleft join dev_thuxuan.terminology.provider pres\n on pharm.prescribing_provider_npi = pres.npi\nleft join dev_thuxuan.terminology.provider disp\n on pharm.dispensing_provider_npi = disp.npi\nleft join dev_thuxuan.terminology.ndc ndc\n on pharm.ndc_code = ndc.ndc", "relation_name": "dev_thuxuan.claims_preprocessing.normalized_input_pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.196218Z", "completed_at": "2024-10-25T14:34:38.252792Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.254297Z", "completed_at": "2024-10-25T14:34:38.254297Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.08808088302612305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_egfr_labs", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n lab_result_id\n , patient_id\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , status\n , result\n , result_date\n , data_source\nfrom dev_thuxuan.core.lab_result\n\n\n), lab_result as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , status\n , result\n , result_date\n from __dbt__cte___stg_lab_result\n\n)\n\n, seed_egfr_codes as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n where lower(concept_name) = 'estimated glomerular filtration rate'\n\n)\n\n, egfr_labs as (\n\n select distinct\n lab_result.patient_id\n , lab_result.data_source\n , lab_result.code_type\n , lab_result.code\n , lab_result.result_date\n , lab_result.result\n from lab_result\n inner join seed_egfr_codes\n on lab_result.code = seed_egfr_codes.code\n and lab_result.code_type = seed_egfr_codes.code_system\n where lab_result.result is not null\n and lower(lab_result.status) not in ('cancelled', 'entered-in-error')\n\n)\n\n, numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , cast(result as numeric(28,6)) as result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, clean_non_numeric_egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , cast(case\n when lower(result) like '%unsatisfactory specimen%' then null\n when result like '%>%' then null\n when result like '%<%' then null\n when result like '%@%' then trim(replace(result,'@',''))\n when result like '%mL/min/1.73m2%' then trim(replace(result,'mL/min/1.73m2',''))\n else null\n end as numeric(28,6)) as clean_result\n from egfr_labs\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$') = False\n \n\n)\n\n, unioned_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from numeric_egfr_labs\n\n union all\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , clean_result as result\n from clean_non_numeric_egfr_labs\n where clean_result is not null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n from unioned_labs\n\n)\n\nselect\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_prep_egfr_labs"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.232217Z", "completed_at": "2024-10-25T14:34:38.252792Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.256635Z", "completed_at": "2024-10-25T14:34:38.256635Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.08941817283630371, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_clinical_for_pbi", "compiled": true, "compiled_code": "\n\nWITH Ranked_Examples as (\n SELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n FROM dev_thuxuan.data_quality.data_quality_clinical_detail\n where bucket_name not in ('valid', 'null')\n group by\n data_source,\n field_name,\n table_name,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n\n),\n\npk_examples as (\n SELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.drill_down_value as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency,\n row_number() over (partition by detail.summary_sk order by detail.summary_sk) as rn\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.data_quality.data_quality_clinical_detail as detail\n left join dev_thuxuan.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\n where detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 1\n GROUP BY\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.drill_down_key,\n detail.drill_down_value,\n detail.invalid_reason,\n detail.summary_sk\n\n)\n--- Null Values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value,\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality.data_quality_clinical_detail\nwhere bucket_name = 'null'\ngroup by\n data_source,\n field_name,\n table_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\n\n--- Valid Values except PKs\n\nSELECT\n detail.summary_sk,\n detail.data_source,\n detail.table_name,\n detail.field_name,\n detail.bucket_name,\n detail.invalid_reason,\n detail.drill_down_key,\n max(detail.drill_down_value) as drill_down_value,\n detail.field_value as field_value,\n count(detail.drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality.data_quality_clinical_detail as detail\nleft join dev_thuxuan.data_quality._value_set_crosswalk_field_info as field_info on detail.table_name = field_info.input_layer_table_name\n and detail.field_name = field_info.field_name\nWHERE\n detail.bucket_name = 'valid'\n and field_info.unique_values_expected_flag = 0 --- need to handle pks differently since every value is supposed to be unique\ngroup by\n detail.data_source,\n detail.field_name,\n detail.table_name,\n detail.bucket_name,\n detail.field_value,\n detail.invalid_reason,\n detail.drill_down_key,\n detail.summary_sk\n\nunion all\n\n-- 5 Examples of each invalid example\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggregating all other invalid examples into single row\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'all others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM Ranked_Examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value\n\nunion all\n\n--- 5 Examples of valid primary key values\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn <= 5\n\nunion all\n\n--- Aggegating all other valid primary key value examples\n\nSELECT\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n 'All Others' as field_value,\n sum(frequency) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM pk_examples\nWHERE rn > 5 --- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "relation_name": "dev_thuxuan.data_quality.data_quality_clinical_for_pbi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.246643Z", "completed_at": "2024-10-25T14:34:38.255798Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.258644Z", "completed_at": "2024-10-25T14:34:38.258644Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.09142827987670898, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__medication_patient_id.0aaf3a0652", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n) select patient_id\nfrom __dbt__cte___stg_medication\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.267667Z", "completed_at": "2024-10-25T14:34:38.321670Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.322655Z", "completed_at": "2024-10-25T14:34:38.322655Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.06200885772705078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__eligibility", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_eligibility as (\n\n\n\nselect\n patient_id\n , patient_id || coalesce(data_source,'') || coalesce(payer,'') || coalesce(plan,'') || coalesce(cast(enrollment_start_date as TEXT),'') || coalesce(cast(enrollment_end_date as TEXT),'') as patient_id_key\n , member_id\n , subscriber_id\n , gender\n , race\n , birth_date\n , death_date\n , death_flag\n , enrollment_start_date\n , enrollment_end_date\n , payer\n , payer_type\n , plan\n , subscriber_relation\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , first_name\n , last_name\n , social_security_number\n , address\n , city\n , state\n , zip_code\n , phone\n , data_source\n , file_name\n , ingest_datetime\nfrom tuva.input_layer.eligibility\n) select\n cast(elig.patient_id as TEXT ) as patient_id\n , cast(elig.member_id as TEXT ) as member_id\n , cast(elig.subscriber_id as TEXT ) as subscriber_id\n , cast(elig.gender as TEXT ) as gender\n , cast(elig.race as TEXT ) as race\n , cast(date_norm.normalized_birth_date as date ) as birth_date\n , cast(date_norm.normalized_death_date as date ) as death_date\n , cast(elig.death_flag as int ) as death_flag\n , cast(date_norm.normalized_enrollment_start_date as date ) as enrollment_start_date\n , cast(date_norm.normalized_enrollment_end_date as date ) as enrollment_end_date\n , cast(elig.payer as TEXT ) as payer\n , cast(elig.payer_type as TEXT ) as payer_type\n , cast(elig.plan as TEXT ) as plan\n , cast(elig.original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(elig.dual_status_code as TEXT ) as dual_status_code\n , cast(elig.medicare_status_code as TEXT ) as medicare_status_code\n , cast(elig.first_name as TEXT ) as first_name\n , cast(elig.last_name as TEXT ) as last_name\n , cast(elig.social_security_number as TEXT ) as social_security_number\n , cast(elig.subscriber_relation as TEXT ) as subscriber_relation\n , cast(elig.address as TEXT ) as address\n , cast(elig.city as TEXT ) as city\n , cast(elig.state as TEXT ) as state\n , cast(elig.zip_code as TEXT ) as zip_code\n , cast(elig.phone as TEXT ) as phone\n , cast(elig.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_eligibility elig\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_eligibility_dates_normalize date_norm\n on elig.patient_id_key = date_norm.patient_id_key", "relation_name": "dev_thuxuan.claims_preprocessing.normalized_input_eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.262645Z", "completed_at": "2024-10-25T14:34:38.348226Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.673467Z", "completed_at": "2024-10-25T14:34:38.673467Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.4138212203979492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__observation_patient_id.31e33f2d7e", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n) select patient_id\nfrom __dbt__cte___stg_observation\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.324664Z", "completed_at": "2024-10-25T14:34:38.676440Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.681063Z", "completed_at": "2024-10-25T14:34:38.681063Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.41841864585876465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_detail", "compiled": true, "compiled_code": "\n\nWITH unioned_data as (\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_allowed_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_charge_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_line_end_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_line_number\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_line_start_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_claim_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_coninsurance_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_copayment_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_deductible_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_diagnosis_code_type\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_hcpcs_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_member_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_paid_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_paid_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_patient_id\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_payer\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_plan\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.claim_total_cost_amount\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_address\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_birth_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_city\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_data_source\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_death_date\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_death_flag\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_dual_status_code\n\nunion all\n\nSELECT\n cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_first_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_gender\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_last_name\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_medicare_status_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_original_reason_entitlement_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_payer_type\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_phone\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_race\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_state\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.eligibility_zip_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_ms_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_admission_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_admit_source_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_admit_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_apr_drg_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_bill_type_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_diagnosis_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_discharge_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_discharge_disposition_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_present_on_admission_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_present_on_admission_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_present_on_admission_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_code_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_date_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_date_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_procedure_date_3\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_revenue_center_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.institutional_service_unit_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_allowed_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_claim_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_claim_line_number\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_coinsurance_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_copayment_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_data_source\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_days_supply\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_deductible_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_dispensing_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_dispensing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_member_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_ndc_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_paid_amount\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_paid_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_patient_id\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_payer\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_plan\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_prescribing_provider_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_quantity\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.pharmacy_refills\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_billing_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_facility_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_place_of_service_code\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_rendering_npi\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_claim_end_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_claim_start_date\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_diagnosis_code_1\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_diagnosis_code_2\n\nunion all\n\nSELECT cast(data_source as TEXT) as data_source\n\t, cast(source_date as TEXT) as source_date\n\t, cast(table_name as TEXT) as table_name\n\t, cast(drill_down_key as TEXT) as drill_down_key\n\t, cast(drill_down_value as TEXT) as drill_down_value\n\t, cast(claim_type as TEXT) as claim_type\n\t, cast(field_name as TEXT) as field_name\n\t, cast(bucket_name as TEXT) as bucket_name\n\t, cast(invalid_reason as TEXT) as invalid_reason\n\t, cast(field_value as TEXT) as field_value\n\t, cast(tuva_last_run as TEXT) as tuva_last_run\n\tFROM dev_thuxuan.data_quality.professional_diagnosis_code_3\n\n)\n\n\nselect\n cast(data_source as TEXT) as data_source\n , cast(source_date as TEXT) as source_date\n , cast(table_name as TEXT) as table_name\n , cast(drill_down_key as TEXT) as drill_down_key\n , cast(drill_down_value as TEXT) as drill_down_value\n , cast(claim_type as TEXT) as claim_type\n , cast(field_name as TEXT) as field_name\n , cast(bucket_name as TEXT) as bucket_name\n , cast(invalid_reason as TEXT) as invalid_reason\n , cast(field_value as TEXT) as field_value\n , cast(tuva_last_run as TEXT) as tuva_last_run\n , dense_rank() over (\n order by data_source\n , table_name\n , claim_type\n , field_name\n ) as summary_sk\nfrom unioned_data", "relation_name": "dev_thuxuan.data_quality.data_quality_claims_detail"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.683102Z", "completed_at": "2024-10-25T14:34:38.693064Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.695068Z", "completed_at": "2024-10-25T14:34:38.695068Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020636796951293945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_source_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.689064Z", "completed_at": "2024-10-25T14:34:38.696066Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.702384Z", "completed_at": "2024-10-25T14:34:38.702384Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020316600799560547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_admit_type_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_normalize_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.696066Z", "completed_at": "2024-10-25T14:34:38.704444Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.705645Z", "completed_at": "2024-10-25T14:34:38.705645Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.017588138580322266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_apr_drg_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.707766Z", "completed_at": "2024-10-25T14:34:38.721652Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.722651Z", "completed_at": "2024-10-25T14:34:38.722651Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019213199615478516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_diagnosis_code as normalized_code\n , norm.diagnosis_code_occurrence_count as occurrence_count\n , coalesce(lead(diagnosis_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by diagnosis_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.717650Z", "completed_at": "2024-10-25T14:34:38.730651Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.731650Z", "completed_at": "2024-10-25T14:34:38.731650Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024997472763061523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_discharge_disposition_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.723651Z", "completed_at": "2024-10-25T14:34:38.732650Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.734649Z", "completed_at": "2024-10-25T14:34:38.734649Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.017998456954956055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_bill_type_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_voting\nwhere occurrence_row_count = 1", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.736649Z", "completed_at": "2024-10-25T14:34:38.750654Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.751653Z", "completed_at": "2024-10-25T14:34:38.751653Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01800227165222168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_medical_date_aggregation", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , min(normalized_admission_date) as minimum_admission_date\n , max(normalized_discharge_date) as maximum_discharge_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'institutional'\ngroup by\n claim_id\n , data_source\n\nunion all\n\nselect\n claim_id\n , data_source\n , min(normalized_claim_start_date) as minimum_claim_start_date\n , max(normalized_claim_end_date) as maximum_claim_end_date\n , null as minimum_admission_date\n , null as maximum_discharge_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize\nwhere claim_type = 'professional'\ngroup by\n claim_id\n , data_source", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_medical_date_aggregation"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.743652Z", "completed_at": "2024-10-25T14:34:38.752653Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.763160Z", "completed_at": "2024-10-25T14:34:38.763160Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027509212493896484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_ms_drg_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , column_name\n , normalized_code\n , normalized_description\n , occurrence_count\n , next_occurrence_count\n , occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.753652Z", "completed_at": "2024-10-25T14:34:38.766162Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.768161Z", "completed_at": "2024-10-25T14:34:38.768161Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02550959587097168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , diagnosis_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_normalize\n group by\n claim_id\n , data_source\n , diagnosis_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.diagnosis_column as column_name\n , norm.normalized_present_on_admit_code as normalized_code\n , norm.present_on_admit_occurrence_count as occurrence_count\n , coalesce(lead(present_on_admit_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.diagnosis_column order by present_on_admit_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.diagnosis_column = dist.diagnosis_column", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.772162Z", "completed_at": "2024-10-25T14:34:38.789162Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.803168Z", "completed_at": "2024-10-25T14:34:38.803168Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03699922561645508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.normalized_procedure_code as normalized_code\n , norm.procedure_code_occurrence_count as occurrence_count\n , coalesce(lead(procedure_code_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_code_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.780163Z", "completed_at": "2024-10-25T14:34:38.803168Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.805162Z", "completed_at": "2024-10-25T14:34:38.805162Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03500056266784668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_voting", "compiled": true, "compiled_code": "\n\nwith distinct_count as(\n select\n claim_id\n , data_source\n , procedure_column\n , count(*) as distinct_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_normalize\n group by\n claim_id\n , data_source\n , procedure_column\n)\n\nselect \n norm.claim_id\n , norm.data_source\n , norm.procedure_column as column_name\n , norm.procedure_date as normalized_code\n , norm.procedure_date_occurrence_count as occurrence_count\n , coalesce(lead(procedure_date_occurrence_count) \n over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc),0) as next_occurrence_count\n , row_number() over (partition by norm.claim_id, norm.data_source, norm.procedure_column order by procedure_date_occurrence_count desc) as occurrence_row_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_normalize norm\ninner join distinct_count dist\n on norm.claim_id = dist.claim_id\n and norm.data_source = dist.data_source\n and norm.procedure_column = dist.procedure_column", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_voting"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.790161Z", "completed_at": "2024-10-25T14:34:38.806161Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.808162Z", "completed_at": "2024-10-25T14:34:38.808162Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.029001474380493164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_pharmacy_claim", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the pharmacy_claim\n-- table in core.\n-- *************************************************\n\n\n\n\nselect\n cast(claim_id as TEXT) || '-' || cast(claim_line_number as TEXT) as pharmacy_claim_id\n , cast(claim_id as TEXT ) as claim_id\n , cast(claim_line_number as integer ) as claim_line_number\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(payer as TEXT ) as payer\n , plan\n , cast(prescribing_provider_id as TEXT ) as prescribing_provider_id\n , cast(prescribing_provider_name as TEXT ) as prescribing_provider_name\n , cast(dispensing_provider_id as TEXT ) as dispensing_provider_id\n , cast(dispensing_provider_name as TEXT ) as dispensing_provider_name\n , cast(dispensing_date as date ) as dispensing_date\n , cast(ndc_code as TEXT ) as ndc_code\n , cast(ndc_description as TEXT ) as ndc_description\n , cast(quantity as integer ) as quantity\n , cast(days_supply as integer ) as days_supply\n , cast(refills as integer ) as refills\n , cast(paid_date as date ) as paid_date\n , cast(paid_amount as numeric(28,6)) as paid_amount\n , cast(allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(charge_amount as numeric(28,6) ) as charge_amount\n , cast(coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(in_network_flag as int ) as in_network_flag\n , cast(data_source as TEXT ) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_pharmacy_claim pharm", "relation_name": "dev_thuxuan.test.core__stg_claims_pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.812162Z", "completed_at": "2024-10-25T14:34:38.845167Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.846168Z", "completed_at": "2024-10-25T14:34:38.846168Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03700375556945801, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_eligibility", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the eligibility table in core.\n-- *************************************************\n\n\n\n\nselect\n member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan as eligibility_id\n , cast(patient_id as TEXT ) as patient_id\n , cast(member_id as TEXT ) as member_id\n , cast(subscriber_id as TEXT ) as subscriber_id\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(enrollment_start_date as date ) as enrollment_start_date\n , cast(enrollment_end_date as date ) as enrollment_end_date\n , cast(payer as TEXT ) as payer\n , cast(payer_type as TEXT ) as payer_type\n , plan\n , cast(original_reason_entitlement_code as TEXT ) as original_reason_entitlement_code\n , cast(dual_status_code as TEXT ) as dual_status_code\n , cast(medicare_status_code as TEXT ) as medicare_status_code\n , cast(subscriber_relation as TEXT ) as subscriber_relation\n , cast(data_source as TEXT ) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_eligibility", "relation_name": "dev_thuxuan.test.core__stg_claims_eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.819163Z", "completed_at": "2024-10-25T14:34:38.845167Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.847167Z", "completed_at": "2024-10-25T14:34:38.847167Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.038002729415893555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_patient", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the patient table in core.\n-- *************************************************\n\nwith patient_stage as(\n select\n patient_id\n ,first_name\n ,last_name\n ,gender\n ,race\n ,birth_date\n ,death_date\n ,death_flag\n ,social_security_number\n ,address\n ,city\n ,state\n ,zip_code\n ,phone\n ,data_source\n ,row_number() over (\n\t partition by patient_id\n\t order by case when enrollment_end_date is null\n then cast ('2050-01-01' as date)\n else enrollment_end_date end DESC)\n as row_sequence\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp) as tuva_last_run_datetime\n , cast(substring('2024-10-25 14:34:26.237057+00:00',1,10) as date) as tuva_last_run_date\n from dev_thuxuan.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(first_name as TEXT) as first_name\n , cast(last_name as TEXT) as last_name\n , cast(gender as TEXT) as sex\n , cast(race as TEXT) as race\n , cast(birth_date as date) as birth_date\n , cast(death_date as date) as death_date\n , cast(death_flag as int) as death_flag\n , cast(social_security_number as TEXT) as social_security_number\n , cast(address as TEXT) as address\n , cast(city as TEXT) as city\n , cast(state as TEXT) as state\n , cast(zip_code as TEXT) as zip_code\n , cast(null as TEXT) as county\n , cast(null as float) as latitude \n , cast(null as float) as longitude\n , cast(data_source as TEXT) as data_source\n , cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) as age\n , cast(\n CASE\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 10 THEN '0-9'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 20 THEN '10-19'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 30 THEN '20-29'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 40 THEN '30-39'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 50 THEN '40-49'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 60 THEN '50-59'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 70 THEN '60-69'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 80 THEN '70-79'\n WHEN cast(floor(datediff(\n hour,\n birth_date,\n tuva_last_run_date\n ) / 8760.0) as integer ) < 90 THEN '80-89'\n ELSE '90+'\n END as TEXT\n ) AS age_group\n , tuva_last_run_datetime as tuva_last_run\nfrom patient_stage\nwhere row_sequence = 1", "relation_name": "dev_thuxuan.test.core__stg_claims_patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.833162Z", "completed_at": "2024-10-25T14:34:38.846168Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.848194Z", "completed_at": "2024-10-25T14:34:38.848194Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.037030696868896484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_claims_for_pbi", "compiled": true, "compiled_code": "\n\nWITH ranked_examples as (\n select\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value, --all claims\n field_value as field_value,\n count(drill_down_value) as frequency,\n row_number() over (partition by summary_sk, bucket_name, field_value order by field_value) as rn\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\nWHERE bucket_name not in ('valid', 'null')\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk\n)\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n null as field_value,\n count(drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'null'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n max(drill_down_value) as drill_down_value, --1 sample claim\n field_value as field_value,\n count(drill_down_value) as frequency\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\nWHERE bucket_name = 'valid'\nGROUP BY\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n invalid_reason,\n drill_down_key,\n summary_sk\n\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n drill_down_value as drill_down_value,\n field_value as field_value,\n frequency\n , '2024-10-25 14:34:26.237057+00:00'\nFROM ranked_examples\nWHERE rn <= 5 -- 5 Example claims per unique SK / field value\nunion all\nSELECT\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n 'All Others' as drill_down_value,\n field_value as field_value,\n sum(frequency) as frequency\n , '2024-10-25 14:34:26.237057+00:00'\nFROM ranked_examples\nWHERE rn > 5 -- Aggregating all other rows\nGROUP BY\n summary_sk,\n data_source,\n table_name,\n claim_type,\n field_name,\n bucket_name,\n invalid_reason,\n drill_down_key,\n field_value", "relation_name": "dev_thuxuan.data_quality.data_quality_claims_for_pbi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.854674Z", "completed_at": "2024-10-25T14:34:38.877743Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.881742Z", "completed_at": "2024-10-25T14:34:38.881742Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03157377243041992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_detail", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\tclaim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_detail\n\nunion all\n\nSELECT\n data_source,\n\tsource_date,\n\ttable_name,\n\tdrill_down_key,\n\tdrill_down_value,\n\t'CLINICAL' AS claim_type,\n\tfield_name,\n\tbucket_name,\n\tinvalid_reason,\n\tfield_value,\n\tsummary_sk,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_clinical_detail\n\n", "relation_name": "dev_thuxuan.data_quality.data_quality_detail"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.863695Z", "completed_at": "2024-10-25T14:34:38.880742Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.882742Z", "completed_at": "2024-10-25T14:34:38.882742Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.031572818756103516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_diagnosis_code_final", "compiled": true, "compiled_code": "\n\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'diagnosis_code_1' then normalized_code else null end) as diagnosis_code_1\n , max(case when lower(column_name) = 'diagnosis_code_2' then normalized_code else null end) as diagnosis_code_2\n , max(case when lower(column_name) = 'diagnosis_code_3' then normalized_code else null end) as diagnosis_code_3\n , max(case when lower(column_name) = 'diagnosis_code_4' then normalized_code else null end) as diagnosis_code_4\n , max(case when lower(column_name) = 'diagnosis_code_5' then normalized_code else null end) as diagnosis_code_5\n , max(case when lower(column_name) = 'diagnosis_code_6' then normalized_code else null end) as diagnosis_code_6\n , max(case when lower(column_name) = 'diagnosis_code_7' then normalized_code else null end) as diagnosis_code_7\n , max(case when lower(column_name) = 'diagnosis_code_8' then normalized_code else null end) as diagnosis_code_8\n , max(case when lower(column_name) = 'diagnosis_code_9' then normalized_code else null end) as diagnosis_code_9\n , max(case when lower(column_name) = 'diagnosis_code_10' then normalized_code else null end) as diagnosis_code_10\n , max(case when lower(column_name) = 'diagnosis_code_11' then normalized_code else null end) as diagnosis_code_11\n , max(case when lower(column_name) = 'diagnosis_code_12' then normalized_code else null end) as diagnosis_code_12\n , max(case when lower(column_name) = 'diagnosis_code_13' then normalized_code else null end) as diagnosis_code_13\n , max(case when lower(column_name) = 'diagnosis_code_14' then normalized_code else null end) as diagnosis_code_14\n , max(case when lower(column_name) = 'diagnosis_code_15' then normalized_code else null end) as diagnosis_code_15\n , max(case when lower(column_name) = 'diagnosis_code_16' then normalized_code else null end) as diagnosis_code_16\n , max(case when lower(column_name) = 'diagnosis_code_17' then normalized_code else null end) as diagnosis_code_17\n , max(case when lower(column_name) = 'diagnosis_code_18' then normalized_code else null end) as diagnosis_code_18\n , max(case when lower(column_name) = 'diagnosis_code_19' then normalized_code else null end) as diagnosis_code_19\n , max(case when lower(column_name) = 'diagnosis_code_20' then normalized_code else null end) as diagnosis_code_20\n , max(case when lower(column_name) = 'diagnosis_code_21' then normalized_code else null end) as diagnosis_code_21\n , max(case when lower(column_name) = 'diagnosis_code_22' then normalized_code else null end) as diagnosis_code_22\n , max(case when lower(column_name) = 'diagnosis_code_23' then normalized_code else null end) as diagnosis_code_23\n , max(case when lower(column_name) = 'diagnosis_code_24' then normalized_code else null end) as diagnosis_code_24\n , max(case when lower(column_name) = 'diagnosis_code_25' then normalized_code else null end) as diagnosis_code_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.870741Z", "completed_at": "2024-10-25T14:34:38.882742Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.884741Z", "completed_at": "2024-10-25T14:34:38.884741Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.031571149826049805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_present_on_admit_final", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when column_name = 'DIAGNOSIS_POA_1' then normalized_code else null end) as diagnosis_poa_1\n , max(case when column_name = 'DIAGNOSIS_POA_2' then normalized_code else null end) as diagnosis_poa_2\n , max(case when column_name = 'DIAGNOSIS_POA_3' then normalized_code else null end) as diagnosis_poa_3\n , max(case when column_name = 'DIAGNOSIS_POA_4' then normalized_code else null end) as diagnosis_poa_4\n , max(case when column_name = 'DIAGNOSIS_POA_5' then normalized_code else null end) as diagnosis_poa_5\n , max(case when column_name = 'DIAGNOSIS_POA_6' then normalized_code else null end) as diagnosis_poa_6\n , max(case when column_name = 'DIAGNOSIS_POA_7' then normalized_code else null end) as diagnosis_poa_7\n , max(case when column_name = 'DIAGNOSIS_POA_8' then normalized_code else null end) as diagnosis_poa_8\n , max(case when column_name = 'DIAGNOSIS_POA_9' then normalized_code else null end) as diagnosis_poa_9\n , max(case when column_name = 'DIAGNOSIS_POA_10' then normalized_code else null end) as diagnosis_poa_10\n , max(case when column_name = 'DIAGNOSIS_POA_11' then normalized_code else null end) as diagnosis_poa_11\n , max(case when column_name = 'DIAGNOSIS_POA_12' then normalized_code else null end) as diagnosis_poa_12\n , max(case when column_name = 'DIAGNOSIS_POA_13' then normalized_code else null end) as diagnosis_poa_13\n , max(case when column_name = 'DIAGNOSIS_POA_14' then normalized_code else null end) as diagnosis_poa_14\n , max(case when column_name = 'DIAGNOSIS_POA_15' then normalized_code else null end) as diagnosis_poa_15\n , max(case when column_name = 'DIAGNOSIS_POA_16' then normalized_code else null end) as diagnosis_poa_16\n , max(case when column_name = 'DIAGNOSIS_POA_17' then normalized_code else null end) as diagnosis_poa_17\n , max(case when column_name = 'DIAGNOSIS_POA_18' then normalized_code else null end) as diagnosis_poa_18\n , max(case when column_name = 'DIAGNOSIS_POA_19' then normalized_code else null end) as diagnosis_poa_19\n , max(case when column_name = 'DIAGNOSIS_POA_20' then normalized_code else null end) as diagnosis_poa_20\n , max(case when column_name = 'DIAGNOSIS_POA_21' then normalized_code else null end) as diagnosis_poa_21\n , max(case when column_name = 'DIAGNOSIS_POA_22' then normalized_code else null end) as diagnosis_poa_22\n , max(case when column_name = 'DIAGNOSIS_POA_23' then normalized_code else null end) as diagnosis_poa_23\n , max(case when column_name = 'DIAGNOSIS_POA_24' then normalized_code else null end) as diagnosis_poa_24\n , max(case when column_name = 'DIAGNOSIS_POA_25' then normalized_code else null end) as diagnosis_poa_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.888741Z", "completed_at": "2024-10-25T14:34:38.902741Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.902741Z", "completed_at": "2024-10-25T14:34:38.902741Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.018000125885009766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_code_final", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_code_1' then normalized_code else null end) as procedure_code_1\n , max(case when lower(column_name) = 'procedure_code_2' then normalized_code else null end) as procedure_code_2\n , max(case when lower(column_name) = 'procedure_code_3' then normalized_code else null end) as procedure_code_3\n , max(case when lower(column_name) = 'procedure_code_4' then normalized_code else null end) as procedure_code_4\n , max(case when lower(column_name) = 'procedure_code_5' then normalized_code else null end) as procedure_code_5\n , max(case when lower(column_name) = 'procedure_code_6' then normalized_code else null end) as procedure_code_6\n , max(case when lower(column_name) = 'procedure_code_7' then normalized_code else null end) as procedure_code_7\n , max(case when lower(column_name) = 'procedure_code_8' then normalized_code else null end) as procedure_code_8\n , max(case when lower(column_name) = 'procedure_code_9' then normalized_code else null end) as procedure_code_9\n , max(case when lower(column_name) = 'procedure_code_10' then normalized_code else null end) as procedure_code_10\n , max(case when lower(column_name) = 'procedure_code_11' then normalized_code else null end) as procedure_code_11\n , max(case when lower(column_name) = 'procedure_code_12' then normalized_code else null end) as procedure_code_12\n , max(case when lower(column_name) = 'procedure_code_13' then normalized_code else null end) as procedure_code_13\n , max(case when lower(column_name) = 'procedure_code_14' then normalized_code else null end) as procedure_code_14\n , max(case when lower(column_name) = 'procedure_code_15' then normalized_code else null end) as procedure_code_15\n , max(case when lower(column_name) = 'procedure_code_16' then normalized_code else null end) as procedure_code_16\n , max(case when lower(column_name) = 'procedure_code_17' then normalized_code else null end) as procedure_code_17\n , max(case when lower(column_name) = 'procedure_code_18' then normalized_code else null end) as procedure_code_18\n , max(case when lower(column_name) = 'procedure_code_19' then normalized_code else null end) as procedure_code_19\n , max(case when lower(column_name) = 'procedure_code_20' then normalized_code else null end) as procedure_code_20\n , max(case when lower(column_name) = 'procedure_code_21' then normalized_code else null end) as procedure_code_21\n , max(case when lower(column_name) = 'procedure_code_22' then normalized_code else null end) as procedure_code_22\n , max(case when lower(column_name) = 'procedure_code_23' then normalized_code else null end) as procedure_code_23\n , max(case when lower(column_name) = 'procedure_code_24' then normalized_code else null end) as procedure_code_24\n , max(case when lower(column_name) = 'procedure_code_25' then normalized_code else null end) as procedure_code_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.893740Z", "completed_at": "2024-10-25T14:34:38.903741Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.905741Z", "completed_at": "2024-10-25T14:34:38.905741Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018999576568603516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__int_procedure_date_final", "compiled": true, "compiled_code": "\n\nselect\n claim_id\n , data_source\n , max(case when lower(column_name) = 'procedure_date_1' then normalized_code else null end) as procedure_date_1\n , max(case when lower(column_name) = 'procedure_date_2' then normalized_code else null end) as procedure_date_2\n , max(case when lower(column_name) = 'procedure_date_3' then normalized_code else null end) as procedure_date_3\n , max(case when lower(column_name) = 'procedure_date_4' then normalized_code else null end) as procedure_date_4\n , max(case when lower(column_name) = 'procedure_date_5' then normalized_code else null end) as procedure_date_5\n , max(case when lower(column_name) = 'procedure_date_6' then normalized_code else null end) as procedure_date_6\n , max(case when lower(column_name) = 'procedure_date_7' then normalized_code else null end) as procedure_date_7\n , max(case when lower(column_name) = 'procedure_date_8' then normalized_code else null end) as procedure_date_8\n , max(case when lower(column_name) = 'procedure_date_9' then normalized_code else null end) as procedure_date_9\n , max(case when lower(column_name) = 'procedure_date_10' then normalized_code else null end) as procedure_date_10\n , max(case when lower(column_name) = 'procedure_date_11' then normalized_code else null end) as procedure_date_11\n , max(case when lower(column_name) = 'procedure_date_12' then normalized_code else null end) as procedure_date_12\n , max(case when lower(column_name) = 'procedure_date_13' then normalized_code else null end) as procedure_date_13\n , max(case when lower(column_name) = 'procedure_date_14' then normalized_code else null end) as procedure_date_14\n , max(case when lower(column_name) = 'procedure_date_15' then normalized_code else null end) as procedure_date_15\n , max(case when lower(column_name) = 'procedure_date_16' then normalized_code else null end) as procedure_date_16\n , max(case when lower(column_name) = 'procedure_date_17' then normalized_code else null end) as procedure_date_17\n , max(case when lower(column_name) = 'procedure_date_18' then normalized_code else null end) as procedure_date_18\n , max(case when lower(column_name) = 'procedure_date_19' then normalized_code else null end) as procedure_date_19\n , max(case when lower(column_name) = 'procedure_date_20' then normalized_code else null end) as procedure_date_20\n , max(case when lower(column_name) = 'procedure_date_21' then normalized_code else null end) as procedure_date_21\n , max(case when lower(column_name) = 'procedure_date_22' then normalized_code else null end) as procedure_date_22\n , max(case when lower(column_name) = 'procedure_date_23' then normalized_code else null end) as procedure_date_23\n , max(case when lower(column_name) = 'procedure_date_24' then normalized_code else null end) as procedure_date_24\n , max(case when lower(column_name) = 'procedure_date_25' then normalized_code else null end) as procedure_date_25\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_voting\nwhere (occurrence_row_count = 1\n and occurrence_count > next_occurrence_count)\ngroup by\n claim_id\n , data_source", "relation_name": "dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_final"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.898740Z", "completed_at": "2024-10-25T14:34:38.903741Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.906741Z", "completed_at": "2024-10-25T14:34:38.906741Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019000530242919922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__pharmacy_claim", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_pharmacy_claim", "relation_name": "dev_thuxuan.core.pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.910741Z", "completed_at": "2024-10-25T14:34:38.924744Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.933805Z", "completed_at": "2024-10-25T14:34:38.933805Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.028047561645507812, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__eligibility", "compiled": true, "compiled_code": "\n\n\nselect * from dev_thuxuan.test.core__stg_claims_eligibility", "relation_name": "dev_thuxuan.core.eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.914742Z", "completed_at": "2024-10-25T14:34:38.934789Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.936800Z", "completed_at": "2024-10-25T14:34:38.936800Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.028058767318725586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__patient", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_patient\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_patient\n\n", "relation_name": "dev_thuxuan.core.patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.924744Z", "completed_at": "2024-10-25T14:34:38.938652Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:38.940677Z", "completed_at": "2024-10-25T14:34:38.940677Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030936002731323242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_for_pbi", "compiled": true, "compiled_code": "\n\nSELECT\n data_source,\n field_name,\n table_name,\n claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_claims_for_pbi\n\nunion all\n\nSELECT\n data_source,\n field_name,\n table_name,\n 'CLINICAL' AS claim_type,\n bucket_name,\n field_value,\n drill_down_key,\n drill_down_value,\n invalid_reason,\n summary_sk,\n frequency,\n\t'2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.data_quality.data_quality_clinical_for_pbi\n\n", "relation_name": "dev_thuxuan.data_quality.data_quality_for_pbi"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.942676Z", "completed_at": "2024-10-25T14:34:38.955148Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.041775Z", "completed_at": "2024-10-25T14:34:39.041775Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.10312271118164062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__crosswalk_field_to_mart_sk", "compiled": true, "compiled_code": "\n\n\n\nwith results as (\n\n select distinct\n table_name as input_layer_table_name\n , claim_type\n , field_name\n , cast(NULL as TEXT) AS mart_name\n from dev_thuxuan.data_quality.data_quality_detail\n\n union all\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n from dev_thuxuan.data_quality._value_set_crosswalk_field_to_mart\n\n)\n\n, final as (\n\n select\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n , DENSE_RANK () OVER (ORDER BY input_layer_table_name, claim_type, field_name) as table_claim_type_field_sk\n\t, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from results\n group by\n input_layer_table_name\n , claim_type\n , field_name\n , mart_name\n\n)\n\nselect * from final", "relation_name": "dev_thuxuan.data_quality.crosswalk_field_to_mart_sk"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.949676Z", "completed_at": "2024-10-25T14:34:39.025775Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.191956Z", "completed_at": "2024-10-25T14:34:39.191956Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.2502782344818115, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__quality_trend", "compiled": true, "compiled_code": "\n\n\nwith cte as (\nselect try_cast( d.source_date as date ) as source_date_type\n ,summary_sk\n ,SUM(CASE WHEN bucket_name = 'valid' THEN 1 ELSE 0 END) as valid_num\n ,SUM(CASE WHEN bucket_name <> 'null' THEN 1 ELSE 0 END) as fill_num\n ,COUNT(drill_down_value) as denom\nfrom dev_thuxuan.data_quality.data_quality_detail d\ngroup by\n try_cast( d.source_date as date )\n ,summary_sk\n\n)\n\nselect\n c.first_day_of_month\n , summary_sk\n , sum(valid_num) as valid_num\n , sum(fill_num) as fill_num\n , sum(denom) as denom\nfrom cte\nleft join dev_thuxuan.reference_data.calendar c on cte.source_date_type = c.full_date\ngroup by\n c.first_day_of_month\n , summary_sk", "relation_name": "dev_thuxuan.data_quality.quality_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.955526Z", "completed_at": "2024-10-25T14:34:39.195954Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.197956Z", "completed_at": "2024-10-25T14:34:39.197956Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.24927973747253418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.normalized_input__medical_claim", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__normalized_input__stg_medical_claim as (\n\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , member_id\n , payer\n , plan\n , claim_start_date\n , claim_end_date\n , claim_line_start_date\n , claim_line_end_date\n , admission_date\n , discharge_date\n , admit_source_code\n , admit_type_code\n , discharge_disposition_code\n , place_of_service_code\n , bill_type_code\n , ms_drg_code\n , apr_drg_code\n , revenue_center_code\n , service_unit_quantity\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , rendering_npi\n , rendering_tin\n , billing_npi\n , billing_tin\n , facility_npi\n , paid_date\n , paid_amount\n , allowed_amount\n , charge_amount\n , coinsurance_amount\n , copayment_amount\n , deductible_amount\n , total_cost_amount\n , diagnosis_code_type\n , diagnosis_code_1\n , diagnosis_code_2\n , diagnosis_code_3\n , diagnosis_code_4\n , diagnosis_code_5\n , diagnosis_code_6\n , diagnosis_code_7\n , diagnosis_code_8\n , diagnosis_code_9\n , diagnosis_code_10\n , diagnosis_code_11\n , diagnosis_code_12\n , diagnosis_code_13\n , diagnosis_code_14\n , diagnosis_code_15\n , diagnosis_code_16\n , diagnosis_code_17\n , diagnosis_code_18\n , diagnosis_code_19\n , diagnosis_code_20\n , diagnosis_code_21\n , diagnosis_code_22\n , diagnosis_code_23\n , diagnosis_code_24\n , diagnosis_code_25\n , diagnosis_poa_1\n , diagnosis_poa_2\n , diagnosis_poa_3\n , diagnosis_poa_4\n , diagnosis_poa_5\n , diagnosis_poa_6\n , diagnosis_poa_7\n , diagnosis_poa_8\n , diagnosis_poa_9\n , diagnosis_poa_10\n , diagnosis_poa_11\n , diagnosis_poa_12\n , diagnosis_poa_13\n , diagnosis_poa_14\n , diagnosis_poa_15\n , diagnosis_poa_16\n , diagnosis_poa_17\n , diagnosis_poa_18\n , diagnosis_poa_19\n , diagnosis_poa_20\n , diagnosis_poa_21\n , diagnosis_poa_22\n , diagnosis_poa_23\n , diagnosis_poa_24\n , diagnosis_poa_25\n , procedure_code_type\n , procedure_code_1\n , procedure_code_2\n , procedure_code_3\n , procedure_code_4\n , procedure_code_5\n , procedure_code_6\n , procedure_code_7\n , procedure_code_8\n , procedure_code_9\n , procedure_code_10\n , procedure_code_11\n , procedure_code_12\n , procedure_code_13\n , procedure_code_14\n , procedure_code_15\n , procedure_code_16\n , procedure_code_17\n , procedure_code_18\n , procedure_code_19\n , procedure_code_20\n , procedure_code_21\n , procedure_code_22\n , procedure_code_23\n , procedure_code_24\n , procedure_code_25\n , procedure_date_1\n , procedure_date_2\n , procedure_date_3\n , procedure_date_4\n , procedure_date_5\n , procedure_date_6\n , procedure_date_7\n , procedure_date_8\n , procedure_date_9\n , procedure_date_10\n , procedure_date_11\n , procedure_date_12\n , procedure_date_13\n , procedure_date_14\n , procedure_date_15\n , procedure_date_16\n , procedure_date_17\n , procedure_date_18\n , procedure_date_19\n , procedure_date_20\n , procedure_date_21\n , procedure_date_22\n , procedure_date_23\n , procedure_date_24\n , procedure_date_25\n , in_network_flag\n , data_source\nfrom tuva.input_layer.medical_claim\n) select\n\tcast(med.claim_id as TEXT ) as claim_id\n\t, cast(med.claim_line_number as int ) as claim_line_number\n\t, cast(med.claim_type as TEXT ) as claim_type\n\t, cast(med.patient_id as TEXT ) as patient_id\n\t, cast(med.member_id as TEXT ) as member_id\n\t, cast(med.payer as TEXT ) as payer\n , cast(med.plan as TEXT ) as plan\n\t, cast(coalesce(dates.minimum_claim_start_date, undetermined.claim_start_date) as date ) as claim_start_date\n\t, cast(coalesce(dates.maximum_claim_end_date, undetermined.claim_start_date) as date ) as claim_end_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_start_date, undetermined.claim_line_start_date) as date ) as claim_line_start_date\n\t, cast(coalesce(claim_line_dates.normalized_claim_line_end_date, undetermined.claim_line_end_date) as date ) as claim_line_end_date\n\t, cast(coalesce(dates.minimum_admission_date, undetermined.admission_date) as date ) as admission_date\n\t, cast(coalesce(dates.maximum_discharge_date, undetermined.discharge_date) as date ) as discharge_date\n\t, cast(coalesce(ad_source.normalized_code, undetermined.admit_source_code) as TEXT ) as admit_source_code\n , cast(coalesce(ad_source.normalized_description, undetermined.admit_source_description) as TEXT ) as admit_source_description\n\t, cast(coalesce(ad_type.normalized_code, undetermined.admit_type_code) as TEXT ) as admit_type_code\n , cast(coalesce(ad_type.normalized_description, undetermined.admit_type_description) as TEXT ) as admit_type_description\n\t, cast(coalesce(disch_disp.normalized_code, undetermined.discharge_disposition_code) as TEXT ) as discharge_disposition_code\n , cast(coalesce(disch_disp.normalized_description, undetermined.discharge_disposition_description) as TEXT ) as discharge_disposition_description\n\t, cast(coalesce(pos.normalized_code, undetermined.place_of_service_code) as TEXT ) as place_of_service_code\n , cast(coalesce(pos.normalized_description, undetermined.place_of_service_description) as TEXT ) as place_of_service_description\n\t, cast(coalesce(bill.normalized_code, undetermined.bill_type_code) as TEXT ) as bill_type_code\n , cast(coalesce(bill.normalized_description, undetermined.bill_type_description) as TEXT ) as bill_type_description\n\t, cast(coalesce(ms.normalized_code, undetermined.ms_drg_code) as TEXT ) as ms_drg_code\n , cast(coalesce(ms.normalized_description, undetermined.ms_drg_description) as TEXT ) as ms_drg_description\n\t, cast(coalesce(apr.normalized_code, undetermined.apr_drg_code) as TEXT ) as apr_drg_code\n , cast(coalesce(apr.normalized_description, undetermined.apr_drg_description) as TEXT ) as apr_drg_description\n\t, cast(coalesce(rev.normalized_code, undetermined.revenue_center_code) as TEXT ) as revenue_center_code\n , cast(coalesce(rev.normalized_description, undetermined.revenue_center_description) as TEXT ) as revenue_center_description\n\t, cast(med.service_unit_quantity as TEXT ) as service_unit_quantity\n\t, cast(med.hcpcs_code as TEXT ) as hcpcs_code\n\t, cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n\t, cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n\t, cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n\t, cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n\t, cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n\t, cast(coalesce(med_npi.normalized_rendering_npi, undetermined.rendering_npi) as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(coalesce(med_npi.normalized_rendering_name, undetermined.rendering_name) as TEXT ) as rendering_name\n\t, cast(coalesce(med_npi.normalized_billing_npi, undetermined.billing_npi) as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(coalesce(med_npi.normalized_billing_name, undetermined.billing_name) as TEXT ) as billing_name\n\t, cast(coalesce(med_npi.normalized_facility_npi, undetermined.facility_npi) as TEXT ) as facility_id\n\t, cast(coalesce(med_npi.normalized_facility_name, undetermined.facility_name) as TEXT ) as facility_name\n , cast(med.paid_date as date ) as paid_date\n\t, cast(med.paid_amount as numeric(28,6) ) as paid_amount\n\t, cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n\t, cast(med.charge_amount as numeric(28,6) ) as charge_amount\n\t, cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n\t, cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n\t, cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n\t, cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n\t, cast(med.diagnosis_code_type as TEXT ) as diagnosis_code_type\n\t, cast(coalesce(dx_code.diagnosis_code_1, undetermined.diagnosis_code_1) as TEXT ) as diagnosis_code_1\n\t, cast(coalesce(dx_code.diagnosis_code_2, undetermined.diagnosis_code_2) as TEXT ) as diagnosis_code_2\n\t, cast(coalesce(dx_code.diagnosis_code_3, undetermined.diagnosis_code_3) as TEXT ) as diagnosis_code_3\n\t, cast(coalesce(dx_code.diagnosis_code_4, undetermined.diagnosis_code_4) as TEXT ) as diagnosis_code_4\n\t, cast(coalesce(dx_code.diagnosis_code_5, undetermined.diagnosis_code_5) as TEXT ) as diagnosis_code_5\n\t, cast(coalesce(dx_code.diagnosis_code_6, undetermined.diagnosis_code_6) as TEXT ) as diagnosis_code_6\n\t, cast(coalesce(dx_code.diagnosis_code_7, undetermined.diagnosis_code_7) as TEXT ) as diagnosis_code_7\n\t, cast(coalesce(dx_code.diagnosis_code_8, undetermined.diagnosis_code_8) as TEXT ) as diagnosis_code_8\n\t, cast(coalesce(dx_code.diagnosis_code_9, undetermined.diagnosis_code_9) as TEXT ) as diagnosis_code_9\n\t, cast(coalesce(dx_code.diagnosis_code_10, undetermined.diagnosis_code_10) as TEXT ) as diagnosis_code_10\n\t, cast(coalesce(dx_code.diagnosis_code_11, undetermined.diagnosis_code_11) as TEXT ) as diagnosis_code_11\n\t, cast(coalesce(dx_code.diagnosis_code_12, undetermined.diagnosis_code_12) as TEXT ) as diagnosis_code_12\n\t, cast(coalesce(dx_code.diagnosis_code_13, undetermined.diagnosis_code_13) as TEXT ) as diagnosis_code_13\n\t, cast(coalesce(dx_code.diagnosis_code_14, undetermined.diagnosis_code_14) as TEXT ) as diagnosis_code_14\n\t, cast(coalesce(dx_code.diagnosis_code_15, undetermined.diagnosis_code_15) as TEXT ) as diagnosis_code_15\n\t, cast(coalesce(dx_code.diagnosis_code_16, undetermined.diagnosis_code_16) as TEXT ) as diagnosis_code_16\n\t, cast(coalesce(dx_code.diagnosis_code_17, undetermined.diagnosis_code_17) as TEXT ) as diagnosis_code_17\n\t, cast(coalesce(dx_code.diagnosis_code_18, undetermined.diagnosis_code_18) as TEXT ) as diagnosis_code_18\n\t, cast(coalesce(dx_code.diagnosis_code_19, undetermined.diagnosis_code_19) as TEXT ) as diagnosis_code_19\n\t, cast(coalesce(dx_code.diagnosis_code_20, undetermined.diagnosis_code_20) as TEXT ) as diagnosis_code_20\n\t, cast(coalesce(dx_code.diagnosis_code_21, undetermined.diagnosis_code_21) as TEXT ) as diagnosis_code_21\n\t, cast(coalesce(dx_code.diagnosis_code_22, undetermined.diagnosis_code_22) as TEXT ) as diagnosis_code_22\n\t, cast(coalesce(dx_code.diagnosis_code_23, undetermined.diagnosis_code_23) as TEXT ) as diagnosis_code_23\n\t, cast(coalesce(dx_code.diagnosis_code_24, undetermined.diagnosis_code_24) as TEXT ) as diagnosis_code_24\n\t, cast(coalesce(dx_code.diagnosis_code_25, undetermined.diagnosis_code_25) as TEXT ) as diagnosis_code_25\n\t, cast(coalesce(poa.diagnosis_poa_1, undetermined.diagnosis_poa_1) as TEXT ) as diagnosis_poa_1\n\t, cast(coalesce(poa.diagnosis_poa_2, undetermined.diagnosis_poa_2) as TEXT ) as diagnosis_poa_2\n\t, cast(coalesce(poa.diagnosis_poa_3, undetermined.diagnosis_poa_3) as TEXT ) as diagnosis_poa_3\n\t, cast(coalesce(poa.diagnosis_poa_4, undetermined.diagnosis_poa_4) as TEXT ) as diagnosis_poa_4\n\t, cast(coalesce(poa.diagnosis_poa_5, undetermined.diagnosis_poa_5) as TEXT ) as diagnosis_poa_5\n\t, cast(coalesce(poa.diagnosis_poa_6, undetermined.diagnosis_poa_6) as TEXT ) as diagnosis_poa_6\n\t, cast(coalesce(poa.diagnosis_poa_7, undetermined.diagnosis_poa_7) as TEXT ) as diagnosis_poa_7\n\t, cast(coalesce(poa.diagnosis_poa_8, undetermined.diagnosis_poa_8) as TEXT ) as diagnosis_poa_8\n\t, cast(coalesce(poa.diagnosis_poa_9, undetermined.diagnosis_poa_9) as TEXT ) as diagnosis_poa_9\n\t, cast(coalesce(poa.diagnosis_poa_10, undetermined.diagnosis_poa_10) as TEXT ) as diagnosis_poa_10\n\t, cast(coalesce(poa.diagnosis_poa_11, undetermined.diagnosis_poa_11) as TEXT ) as diagnosis_poa_11\n\t, cast(coalesce(poa.diagnosis_poa_12, undetermined.diagnosis_poa_12) as TEXT ) as diagnosis_poa_12\n\t, cast(coalesce(poa.diagnosis_poa_13, undetermined.diagnosis_poa_13) as TEXT ) as diagnosis_poa_13\n\t, cast(coalesce(poa.diagnosis_poa_14, undetermined.diagnosis_poa_14) as TEXT ) as diagnosis_poa_14\n\t, cast(coalesce(poa.diagnosis_poa_15, undetermined.diagnosis_poa_15) as TEXT ) as diagnosis_poa_15\n\t, cast(coalesce(poa.diagnosis_poa_16, undetermined.diagnosis_poa_16) as TEXT ) as diagnosis_poa_16\n\t, cast(coalesce(poa.diagnosis_poa_17, undetermined.diagnosis_poa_17) as TEXT ) as diagnosis_poa_17\n\t, cast(coalesce(poa.diagnosis_poa_18, undetermined.diagnosis_poa_18) as TEXT ) as diagnosis_poa_18\n\t, cast(coalesce(poa.diagnosis_poa_19, undetermined.diagnosis_poa_19) as TEXT ) as diagnosis_poa_19\n\t, cast(coalesce(poa.diagnosis_poa_20, undetermined.diagnosis_poa_20) as TEXT ) as diagnosis_poa_20\n\t, cast(coalesce(poa.diagnosis_poa_21, undetermined.diagnosis_poa_21) as TEXT ) as diagnosis_poa_21\n\t, cast(coalesce(poa.diagnosis_poa_22, undetermined.diagnosis_poa_22) as TEXT ) as diagnosis_poa_22\n\t, cast(coalesce(poa.diagnosis_poa_23, undetermined.diagnosis_poa_23) as TEXT ) as diagnosis_poa_23\n\t, cast(coalesce(poa.diagnosis_poa_24, undetermined.diagnosis_poa_24) as TEXT ) as diagnosis_poa_24\n\t, cast(coalesce(poa.diagnosis_poa_25, undetermined.diagnosis_poa_25) as TEXT ) as diagnosis_poa_25\n\t, cast(med.procedure_code_type as TEXT ) as procedure_code_type\n\t, cast(coalesce(px_code.procedure_code_1, undetermined.procedure_code_1) as TEXT ) as procedure_code_1\n\t, cast(coalesce(px_code.procedure_code_2, undetermined.procedure_code_2) as TEXT ) as procedure_code_2\n\t, cast(coalesce(px_code.procedure_code_3, undetermined.procedure_code_3) as TEXT ) as procedure_code_3\n\t, cast(coalesce(px_code.procedure_code_4, undetermined.procedure_code_4) as TEXT ) as procedure_code_4\n\t, cast(coalesce(px_code.procedure_code_5, undetermined.procedure_code_5) as TEXT ) as procedure_code_5\n\t, cast(coalesce(px_code.procedure_code_6, undetermined.procedure_code_6) as TEXT ) as procedure_code_6\n\t, cast(coalesce(px_code.procedure_code_7, undetermined.procedure_code_7) as TEXT ) as procedure_code_7\n\t, cast(coalesce(px_code.procedure_code_8, undetermined.procedure_code_8) as TEXT ) as procedure_code_8\n\t, cast(coalesce(px_code.procedure_code_9, undetermined.procedure_code_9) as TEXT ) as procedure_code_9\n\t, cast(coalesce(px_code.procedure_code_10, undetermined.procedure_code_10) as TEXT ) as procedure_code_10\n\t, cast(coalesce(px_code.procedure_code_11, undetermined.procedure_code_11) as TEXT ) as procedure_code_11\n\t, cast(coalesce(px_code.procedure_code_12, undetermined.procedure_code_12) as TEXT ) as procedure_code_12\n\t, cast(coalesce(px_code.procedure_code_13, undetermined.procedure_code_13) as TEXT ) as procedure_code_13\n\t, cast(coalesce(px_code.procedure_code_14, undetermined.procedure_code_14) as TEXT ) as procedure_code_14\n\t, cast(coalesce(px_code.procedure_code_15, undetermined.procedure_code_15) as TEXT ) as procedure_code_15\n\t, cast(coalesce(px_code.procedure_code_16, undetermined.procedure_code_16) as TEXT ) as procedure_code_16\n\t, cast(coalesce(px_code.procedure_code_17, undetermined.procedure_code_17) as TEXT ) as procedure_code_17\n\t, cast(coalesce(px_code.procedure_code_18, undetermined.procedure_code_18) as TEXT ) as procedure_code_18\n\t, cast(coalesce(px_code.procedure_code_19, undetermined.procedure_code_19) as TEXT ) as procedure_code_19\n\t, cast(coalesce(px_code.procedure_code_20, undetermined.procedure_code_20) as TEXT ) as procedure_code_20\n\t, cast(coalesce(px_code.procedure_code_21, undetermined.procedure_code_21) as TEXT ) as procedure_code_21\n\t, cast(coalesce(px_code.procedure_code_22, undetermined.procedure_code_22) as TEXT ) as procedure_code_22\n\t, cast(coalesce(px_code.procedure_code_23, undetermined.procedure_code_23) as TEXT ) as procedure_code_23\n\t, cast(coalesce(px_code.procedure_code_24, undetermined.procedure_code_24) as TEXT ) as procedure_code_24\n\t, cast(coalesce(px_code.procedure_code_25, undetermined.procedure_code_25) as TEXT ) as procedure_code_25\n\t, cast(coalesce(px_date.procedure_date_1, undetermined.procedure_date_1) as date ) as procedure_date_1\n\t, cast(coalesce(px_date.procedure_date_2, undetermined.procedure_date_2) as date ) as procedure_date_2\n\t, cast(coalesce(px_date.procedure_date_3, undetermined.procedure_date_3) as date ) as procedure_date_3\n\t, cast(coalesce(px_date.procedure_date_4, undetermined.procedure_date_4) as date ) as procedure_date_4\n\t, cast(coalesce(px_date.procedure_date_5, undetermined.procedure_date_5) as date ) as procedure_date_5\n\t, cast(coalesce(px_date.procedure_date_6, undetermined.procedure_date_6) as date ) as procedure_date_6\n\t, cast(coalesce(px_date.procedure_date_7, undetermined.procedure_date_7) as date ) as procedure_date_7\n\t, cast(coalesce(px_date.procedure_date_8, undetermined.procedure_date_8) as date ) as procedure_date_8\n\t, cast(coalesce(px_date.procedure_date_9, undetermined.procedure_date_9) as date ) as procedure_date_9\n\t, cast(coalesce(px_date.procedure_date_10, undetermined.procedure_date_10) as date ) as procedure_date_10\n\t, cast(coalesce(px_date.procedure_date_11, undetermined.procedure_date_11) as date ) as procedure_date_11\n\t, cast(coalesce(px_date.procedure_date_12, undetermined.procedure_date_12) as date ) as procedure_date_12\n\t, cast(coalesce(px_date.procedure_date_13, undetermined.procedure_date_13) as date ) as procedure_date_13\n\t, cast(coalesce(px_date.procedure_date_14, undetermined.procedure_date_14) as date ) as procedure_date_14\n\t, cast(coalesce(px_date.procedure_date_15, undetermined.procedure_date_15) as date ) as procedure_date_15\n\t, cast(coalesce(px_date.procedure_date_16, undetermined.procedure_date_16) as date ) as procedure_date_16\n\t, cast(coalesce(px_date.procedure_date_17, undetermined.procedure_date_17) as date ) as procedure_date_17\n\t, cast(coalesce(px_date.procedure_date_18, undetermined.procedure_date_18) as date ) as procedure_date_18\n\t, cast(coalesce(px_date.procedure_date_19, undetermined.procedure_date_19) as date ) as procedure_date_19\n\t, cast(coalesce(px_date.procedure_date_20, undetermined.procedure_date_20) as date ) as procedure_date_20\n\t, cast(coalesce(px_date.procedure_date_21, undetermined.procedure_date_21) as date ) as procedure_date_21\n\t, cast(coalesce(px_date.procedure_date_22, undetermined.procedure_date_22) as date ) as procedure_date_22\n\t, cast(coalesce(px_date.procedure_date_23, undetermined.procedure_date_23) as date ) as procedure_date_23\n\t, cast(coalesce(px_date.procedure_date_24, undetermined.procedure_date_24) as date ) as procedure_date_24\n\t, cast(coalesce(px_date.procedure_date_25, undetermined.procedure_date_25) as date ) as procedure_date_25\n\t, cast(med.data_source as TEXT ) as data_source\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT ) as tuva_last_run\nfrom __dbt__cte__normalized_input__stg_medical_claim med\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_admit_source_final ad_source\n on med.claim_id = ad_source.claim_id\n and med.data_source = ad_source.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_admit_type_final ad_type\n on med.claim_id = ad_type.claim_id\n and med.data_source = ad_type.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_apr_drg_final apr\n on med.claim_id = apr.claim_id\n and med.data_source = apr.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_bill_type_final bill\n on med.claim_id = bill.claim_id\n and med.data_source = bill.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_medical_claim_date_normalize claim_line_dates\n on med.claim_id = claim_line_dates.claim_id\n and med.claim_line_number = claim_line_dates.claim_line_number\n and med.data_source = claim_line_dates.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_medical_date_aggregation dates\n on med.claim_id = dates.claim_id\n and med.data_source = dates.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_medical_npi_normalize med_npi\n on med.claim_id = med_npi.claim_id\n and med.claim_line_number = med_npi.claim_line_number\n and med.data_source = med_npi.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_discharge_disposition_final disch_disp\n on med.claim_id = disch_disp.claim_id\n and med.data_source = disch_disp.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_ms_drg_final ms\n on med.claim_id = ms.claim_id\n and med.data_source = ms.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_place_of_service_normalize pos\n on med.claim_id = pos.claim_id\n and med.claim_line_number = pos.claim_line_number\n and med.data_source = pos.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_diagnosis_code_final dx_code\n on med.claim_id = dx_code.claim_id\n and med.data_source = dx_code.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_present_on_admit_final poa\n on med.claim_id = poa.claim_id\n and med.data_source = poa.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_code_final px_code\n on med.claim_id = px_code.claim_id\n and med.data_source = px_code.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_procedure_date_final px_date\n on med.claim_id = px_date.claim_id\n and med.data_source = px_date.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_revenue_center_normalize rev\n on med.claim_id = rev.claim_id\n and med.claim_line_number = rev.claim_line_number\n and med.data_source = rev.data_source\nleft join dev_thuxuan.claims_preprocessing._int_normalized_input_undetermined_claim_type undetermined\n on med.claim_id = undetermined.claim_id\n and med.claim_line_number = undetermined.claim_line_number\n and med.data_source = undetermined.data_source", "relation_name": "dev_thuxuan.claims_preprocessing.normalized_input_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.233366Z", "completed_at": "2024-10-25T14:34:39.241213Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.242217Z", "completed_at": "2024-10-25T14:34:39.242217Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024254560470581055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__stg_pharmacy_claim", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM dev_thuxuan.core.pharmacy_claim mc\nleft join dev_thuxuan.reference_data.calendar c on coalesce(mc.paid_date,mc.dispensing_date) = c.full_date", "relation_name": "dev_thuxuan.data_quality.mart_review__stg_pharmacy_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.254542Z", "completed_at": "2024-10-25T14:34:39.259538Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.266163Z", "completed_at": "2024-10-25T14:34:39.266163Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.023946285247802734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__pharmacy_claim_pharmacy_claim_id.a91e86c79c", "compiled": true, "compiled_code": "\n \n \n\nselect\n pharmacy_claim_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.pharmacy_claim\nwhere pharmacy_claim_id is not null\ngroup by pharmacy_claim_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.269189Z", "completed_at": "2024-10-25T14:34:39.289257Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.290163Z", "completed_at": "2024-10-25T14:34:39.290163Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023972511291503906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__member_months", "compiled": true, "compiled_code": "\n\n\n\nwith __dbt__cte__financial_pmpm__stg_provider_attribution as (\n\n\nselect\n cast(patient_id as TEXT ) as patient_id\n , cast(year_month as TEXT ) as year_month\n , cast(payer as TEXT ) as payer\n , plan\n , cast(data_source as TEXT ) as data_source\n \n , cast(payer_attributed_provider as TEXT )\n as payer_attributed_provider\n , cast(payer_attributed_provider_practice as TEXT )\n as payer_attributed_provider_practice\n , cast(payer_attributed_provider_organization as TEXT )\n as payer_attributed_provider_organization\n , cast(payer_attributed_provider_lob as TEXT )\n as payer_attributed_provider_lob\n\n , cast(custom_attributed_provider as TEXT )\n as custom_attributed_provider\n , cast(custom_attributed_provider_practice as TEXT )\n as custom_attributed_provider_practice\n , cast(custom_attributed_provider_organization as TEXT )\n as custom_attributed_provider_organization\n , cast(custom_attributed_provider_lob as TEXT )\n as custom_attributed_provider_lob\n\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n \nfrom tuva.input_layer.provider_attribution\n), month_start_and_end_dates as (\n select\n year || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || month,\n 2\n )\n end as year_month\n , min(full_date) as month_start_date\n , max(full_date) as month_end_date\n from dev_thuxuan.reference_data.calendar\n group by year, month, year_month\n),\n\n\nfinal_before_attribution_fields as (\nselect distinct\n a.patient_id\n , year_month\n , a.payer\n , a.plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility a\ninner join month_start_and_end_dates b\n on a.enrollment_start_date <= b.month_end_date\n and a.enrollment_end_date >= b.month_start_date\n),\n\n\nadd_attribution_fields as (\nselect\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.tuva_last_run\n \n , b.payer_attributed_provider\n , b.payer_attributed_provider_practice\n , b.payer_attributed_provider_organization\n , b.payer_attributed_provider_lob\n , b.custom_attributed_provider\n , b.custom_attributed_provider_practice\n , b.custom_attributed_provider_organization\n , b.custom_attributed_provider_lob\n\nfrom final_before_attribution_fields a\nleft join __dbt__cte__financial_pmpm__stg_provider_attribution b\non a.patient_id = b.patient_id\nand a.year_month = b.year_month\nand a.payer = b.payer\nand a.plan = b.plan\nand a.data_source = b.data_source\n)\n\n\nselect *\nfrom add_attribution_fields", "relation_name": "dev_thuxuan.core.member_months"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.292246Z", "completed_at": "2024-10-25T14:34:39.299174Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.302172Z", "completed_at": "2024-10-25T14:34:39.302172Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01703619956970215, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__eligibility_eligibility_id.f0f050366a", "compiled": true, "compiled_code": "\n \n \n\nselect\n eligibility_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.eligibility\nwhere eligibility_id is not null\ngroup by eligibility_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.336886Z", "completed_at": "2024-10-25T14:34:39.352990Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.354891Z", "completed_at": "2024-10-25T14:34:39.354891Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02100658416748047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient", "compiled": true, "compiled_code": "\n\nSELECT *,\n patient_id || '|' || data_source as patient_data_source_key\nFROM dev_thuxuan.core.patient", "relation_name": "dev_thuxuan.data_quality.mart_review__patient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.359586Z", "completed_at": "2024-10-25T14:34:39.370583Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.375609Z", "completed_at": "2024-10-25T14:34:39.375609Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01897597312927246, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__patient_patient_id.8fc869ed1e", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.patient\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.366621Z", "completed_at": "2024-10-25T14:34:39.376589Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.377609Z", "completed_at": "2024-10-25T14:34:39.377609Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019003629684448242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__summary", "compiled": true, "compiled_code": "\n\nWITH CTE AS (\n SELECT DISTINCT fm.field_name\n ,fm.input_layer_table_name\n ,fm.claim_type\n ,table_claim_type_field_sk\n FROM dev_thuxuan.data_quality.crosswalk_field_to_mart_sk fm\n)\n\nSELECT\n summary_sk,\n fm.table_claim_type_field_sk,\n data_source,\n x.table_name,\n x.claim_type,\n x.field_name,\n sct.red,\n sct.green,\n sum(case when bucket_name = 'valid' then 1 else 0 end) as valid_num,\n sum(case when bucket_name <> 'null' then 1 else 0 end) as fill_num,\n count(drill_down_value) as denom,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM\n dev_thuxuan.data_quality.data_quality_detail x\nLEFT JOIN CTE fm\n on x.field_name = fm.field_name\n and\n fm.input_layer_table_name = x.table_name\n and\n fm.claim_type = x.claim_type\nLEFT JOIN dev_thuxuan.data_quality._value_set_crosswalk_field_info sct\n on x.field_name = sct.field_name\n and\n sct.input_layer_table_name = x.table_name\n and\n sct.claim_type = x.claim_type\nGROUP BY\n summary_sk,\n data_source,\n fm.table_claim_type_field_sk,\n x.claim_type,\n x.table_name,\n x.field_name,\n sct.red,\n sct.green", "relation_name": "dev_thuxuan.data_quality.summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.371585Z", "completed_at": "2024-10-25T14:34:39.377609Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.379605Z", "completed_at": "2024-10-25T14:34:39.379605Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02001953125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__patient_data_source_id", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct patient_id\n,data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\n\n\nunion distinct\n\n\nselect distinct patient_id\n,data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_eligibility\n)\n\nselect\npatient_id\n,data_source\n,dense_rank() over (order by concat(patient_id,data_source)) as patient_data_source_id\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.381596Z", "completed_at": "2024-10-25T14:34:39.390577Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.400609Z", "completed_at": "2024-10-25T14:34:39.400609Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02203226089477539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_medical_claim", "compiled": true, "compiled_code": "\n\nselect\n m.apr_drg_code\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , rend.primary_specialty_description as rend_primary_specialty_description\n , n.modality\n , m.data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim m\nleft join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join dev_thuxuan.terminology.provider p on m.facility_id = p.npi\nleft join dev_thuxuan.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join dev_thuxuan.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join dev_thuxuan.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join dev_thuxuan.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join dev_thuxuan.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join dev_thuxuan.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join dev_thuxuan.terminology.provider rend on m.rendering_id = rend.npi", "relation_name": "dev_thuxuan.test.service_category__stg_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.390577Z", "completed_at": "2024-10-25T14:34:39.401599Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.421579Z", "completed_at": "2024-10-25T14:34:39.421579Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04202079772949219, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_normalized_input__medical_claim_claim_id__claim_line_number.6d94c0c08d", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n claim_id, claim_line_number\n from dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\n group by claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.401599Z", "completed_at": "2024-10-25T14:34:39.427697Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.428722Z", "completed_at": "2024-10-25T14:34:39.428722Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04113507270812988, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_medications", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\nselect\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\nfrom dev_thuxuan.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n , data_source\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n , data_source\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , coalesce(dispensing_date, paid_date) as dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, ndc_medications as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where ndc_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'ndc' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'ndc'\n\n)\n\n, rxnorm_medications as (\n\n select\n patient_id\n , dispensing_date\n , rxnorm_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where rxnorm_code is not null\n\n union all\n\n select\n patient_id\n , dispensing_date\n , source_code as drug_code\n , 'rxnorm' as code_system\n , data_source\n from medications\n where lower(source_code_type) = 'rxnorm'\n\n)\n\n, unioned as (\n\n select * from pharmacy_claims\n union all\n select * from ndc_medications\n union all\n select * from rxnorm_medications\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n , cast(code_system as TEXT) as code_system\n , cast(data_source as TEXT) as data_source\n from unioned\n\n)\n\nselect\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_all_medications"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.431722Z", "completed_at": "2024-10-25T14:34:39.450728Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.451728Z", "completed_at": "2024-10-25T14:34:39.451728Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024031639099121094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_claims_current_cost", "compiled": true, "compiled_code": "\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n) /* All claims, current cost*/\n\nselect \n p.ndc_code\n , p.ndc_description\n , p.data_source\n , p.rxcui\n , r.brand_vs_generic\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end as generic_available\n , sum(paid_amount) as paid_amount\n , count(distinct claim_id) as claim_count\n , sum(paid_amount) / count(distinct claim_id) as cost_per_claim\n , sum(quantity) as total_units\n , case \n when sum(quantity) > 0 \n and sum(paid_amount) > 0 \n then sum(paid_amount) / sum(quantity) \n else null \n end as cost_per_unit\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\nleft join dev_thuxuan.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\nleft join dev_thuxuan.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\nwhere p.ndc_code is not null\ngroup by \n case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else null \n end\n , r.brand_vs_generic\n , p.ndc_code\n , p.rxcui\n , p.ndc_description\n , p.data_source", "relation_name": "dev_thuxuan.pharmacy._int_claims_current_cost"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.445728Z", "completed_at": "2024-10-25T14:34:39.452731Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.460238Z", "completed_at": "2024-10-25T14:34:39.460238Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03151392936706543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_member_months", "compiled": true, "compiled_code": "\n\nwith\n\ndate_int as (\n select distinct\n replace(year_month,'-','') yyyymm\n , first_day_of_month\n from dev_thuxuan.reference_data.calendar as c\n)\n\nselect \n data_source\n , patient_id\n , first_day_of_month\n , d.yyyymm as year_month\n\nfrom \n dev_thuxuan.core.member_months mm\ninner join date_int d on mm.year_month = d.yyyymm", "relation_name": "dev_thuxuan.ahrq_measures._stg_pqi_member_months"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.452731Z", "completed_at": "2024-10-25T14:34:39.462239Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.463239Z", "completed_at": "2024-10-25T14:34:39.463239Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.018509387969970703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.claims_enrollment__flag_claims_with_enrollment", "compiled": true, "compiled_code": "\n\n\nwith claim_dates as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , coalesce(claim_line_start_date, claim_start_date, admission_date) as inferred_claim_start_date\n , coalesce(claim_line_end_date, claim_end_date, discharge_date) as inferred_claim_end_date\n , case\n when claim_line_start_date is not null then 'claim_line_start_date'\n when claim_line_start_date is null and claim_start_date is not null then 'claim_start_date'\n when claim_line_start_date is null and claim_start_date is null and admission_date is not null then 'admission_date'\n end as inferred_claim_start_column_used\n , case\n when claim_line_end_date is not null then 'claim_line_end_date'\n when claim_line_end_date is null and claim_end_date is not null then 'claim_end_date'\n when claim_line_end_date is null and claim_end_date is null and discharge_date is not null then 'discharge_date'\n end as inferred_claim_end_column_used\n from dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\n)\n\n, claim_year_month as(\n select\n claim_id\n , claim_line_number\n , patient_id\n , payer\n , plan\n , inferred_claim_start_date\n , inferred_claim_end_date\n , inferred_claim_start_column_used\n , inferred_claim_end_column_used\n\n , date_part('year', inferred_claim_start_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_start_date),\n 2\n )\n end as inferred_claim_start_year_month\n\n , date_part('year', inferred_claim_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', inferred_claim_end_date),\n 2\n )\n end as inferred_claim_end_year_month\n\nfrom claim_dates\n\n)\n\nselect distinct\n claim.claim_id\n , claim.claim_line_number\n , claim.patient_id\n , claim.payer\n , claim.plan\n , claim.inferred_claim_start_year_month\n , claim.inferred_claim_end_year_month\n , claim.inferred_claim_start_column_used\n , claim.inferred_claim_end_column_used\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom dev_thuxuan.core.member_months mm\ninner join claim_year_month claim\n on mm.patient_id = claim.patient_id\n and mm.payer = claim.payer\n and mm.plan = claim.plan\n and mm.year_month >= claim.inferred_claim_start_year_month\n and mm.year_month <= claim.inferred_claim_end_year_month", "relation_name": "dev_thuxuan.claims_preprocessing.flag_claims_with_enrollment"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.471237Z", "completed_at": "2024-10-25T14:34:39.476239Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.481238Z", "completed_at": "2024-10-25T14:34:39.481238Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017000675201416016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__stg_member_month", "compiled": true, "compiled_code": "\n\nwith cte as\n(\nselect distinct year_month_int\n,full_date\nfrom dev_thuxuan.reference_data.calendar c\nwhere day = 1\n\n)\n\nselect mm.*\n,c.year_month_int\n,c.full_date as year_month_date\nFROM dev_thuxuan.core.member_months mm\nleft join cte c on cast(mm.year_month as int) = c.year_month_int", "relation_name": "dev_thuxuan.data_quality.mart_review__stg_member_month"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.476239Z", "completed_at": "2024-10-25T14:34:39.482237Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.491241Z", "completed_at": "2024-10-25T14:34:39.491241Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02100229263305664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_age", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) /* Exclude patients with missing age */\nselect \n data_source\n , patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere birth_date is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusions_missing_age"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.484237Z", "completed_at": "2024-10-25T14:34:39.494705Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.495727Z", "completed_at": "2024-10-25T14:34:39.495727Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015486955642700195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_gender", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) -- Exclude patients with undefined or missing gender\nselect \n data_source\n , patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte___stg_pqi_patient\nwhere \n sex not in ('male', 'female')", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_gender"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.496725Z", "completed_at": "2024-10-25T14:34:39.594347Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.614348Z", "completed_at": "2024-10-25T14:34:39.614348Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.1231069564819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_members", "compiled": true, "compiled_code": "\n/*\nSteps for transforming eligibility data into member demographics:\n 1) Determine enrollment status using eligibility from the collection year.\n 2) Roll up to latest eligibility record for enrollment statuses.\n 3) Add age groups based on the payment year.\n 4) Determine other statuses.\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - CMS guidance: Age is calculated as of Feb 1 of the payment year.\n - The collection year is one year prior to the payment year.\n*/\n\n\n\n\nwith __dbt__cte___stg_eligibility as (\n\nselect\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.eligibility\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), stg_eligibility as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , row_number() over(\n partition by patient_id\n order by enrollment_end_date desc\n ) as row_num /* used to dedupe eligibility */\n from __dbt__cte___stg_eligibility\n where (\n /* Include members with any overlap in the collection or payment year */\n enrollment_start_date <= '2024-12-31'\n and enrollment_end_date >= '2023-01-01'\n )\n\n)\n\n, stg_patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , floor(datediff(\n hour,\n birth_date,\n '2024-02-01'\n ) / 8766.0) as payment_year_age\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n/* create proxy enrollment dates if outside of the collection year */\n, cap_collection_start_end_dates as (\n\n select\n patient_id\n , enrollment_start_date\n , enrollment_end_date\n , case\n when enrollment_start_date < try_cast( '2023-01-01' as date )\n then try_cast( '2023-01-01' as date )\n else enrollment_start_date\n end as proxy_enrollment_start_date\n , case\n when enrollment_end_date > try_cast( '2024-12-31' as date )\n then try_cast( '2024-12-31' as date )\n else enrollment_end_date\n end as proxy_enrollment_end_date\n from stg_eligibility\n where (\n /* filter to members with eligibility in collection or payment year */\n \n extract(year from enrollment_start_date)\n between 2023\n and 2024\n or extract(year from enrollment_end_date)\n between 2023\n and 2024\n \n )\n\n)\n\n, calculate_prior_coverage as (\n\n select patient_id\n , sum(datediff(\n month,\n proxy_enrollment_start_date,\n proxy_enrollment_end_date\n ) + 1) as coverage_months /* include starting month */\n from cap_collection_start_end_dates\n group by patient_id\n\n)\n\n/*\n CMS guidance: A \u201cNew Enrollee\u201d status is when a beneficiary has less than\n 12 months of coverage prior to the payment year.\n*/\n, add_enrollment as (\n\n select\n patient_id\n , case\n when coverage_months < 12 then 'New'\n else 'Continuing'\n end as enrollment_status\n from calculate_prior_coverage\n\n)\n\n, latest_eligibility as (\n\n select\n stg_eligibility.patient_id\n , stg_patient.sex as gender\n , stg_patient.payment_year_age\n , stg_eligibility.original_reason_entitlement_code\n , stg_eligibility.dual_status_code\n , stg_eligibility.medicare_status_code\n /* Defaulting to \"New\" enrollment status when missing */\n , case\n when add_enrollment.enrollment_status is null then 'New'\n else add_enrollment.enrollment_status\n end as enrollment_status\n \n , case\n when add_enrollment.enrollment_status is null then TRUE\n else FALSE\n end as enrollment_status_default\n \n from stg_eligibility\n left join add_enrollment\n on stg_eligibility.patient_id = add_enrollment.patient_id\n left join stg_patient\n on stg_eligibility.patient_id = stg_patient.patient_id\n where stg_eligibility.row_num = 1\n\n)\n\n, add_age_group as (\n\n select\n patient_id\n , gender\n , payment_year_age\n , original_reason_entitlement_code\n , dual_status_code\n , medicare_status_code\n , enrollment_status\n , enrollment_status_default\n , case\n when enrollment_status = 'Continuing' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'Continuing' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'Continuing' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'Continuing' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'Continuing' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'Continuing' and payment_year_age between 65 and 69 then '65-69'\n when enrollment_status = 'Continuing' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'Continuing' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'Continuing' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'Continuing' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'Continuing' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'Continuing' and payment_year_age >= 95 then '>=95'\n when enrollment_status = 'New' and payment_year_age between 0 and 34 then '0-34'\n when enrollment_status = 'New' and payment_year_age between 35 and 44 then '35-44'\n when enrollment_status = 'New' and payment_year_age between 45 and 54 then '45-54'\n when enrollment_status = 'New' and payment_year_age between 55 and 59 then '55-59'\n when enrollment_status = 'New' and payment_year_age between 60 and 64 then '60-64'\n when enrollment_status = 'New' and payment_year_age = 65 then '65'\n when enrollment_status = 'New' and payment_year_age = 66 then '66'\n when enrollment_status = 'New' and payment_year_age = 67 then '67'\n when enrollment_status = 'New' and payment_year_age = 68 then '68'\n when enrollment_status = 'New' and payment_year_age = 69 then '69'\n when enrollment_status = 'New' and payment_year_age between 70 and 74 then '70-74'\n when enrollment_status = 'New' and payment_year_age between 75 and 79 then '75-79'\n when enrollment_status = 'New' and payment_year_age between 80 and 84 then '80-84'\n when enrollment_status = 'New' and payment_year_age between 85 and 89 then '85-89'\n when enrollment_status = 'New' and payment_year_age between 90 and 94 then '90-94'\n when enrollment_status = 'New' and payment_year_age >= 95 then '>=95'\n end as age_group\n from latest_eligibility\n\n)\n\n, add_status_logic as (\n\n select\n patient_id\n , enrollment_status\n , case\n when gender = 'female' then 'Female'\n when gender = 'male' then 'Male'\n else null\n end as gender\n , age_group\n , case\n when dual_status_code in ('01','02','03','04','05','06','08') then 'Yes'\n else 'No'\n end as medicaid_status\n , case\n when dual_status_code in ('02','04','08') then 'Full'\n when dual_status_code in ('01','03','05','06') then 'Partial'\n else 'Non'\n end as dual_status\n /*\n The CMS-HCC model does not have factors for ESRD for these edge-cases,\n we default to 'Aged'. When OREC is missing, latest Medicare status is\n used, if available.\n */\n , case\n when original_reason_entitlement_code in ('0','2') then 'Aged'\n when original_reason_entitlement_code in ('1','3') then 'Disabled'\n when original_reason_entitlement_code is null and medicare_status_code in ('10','11','31') then 'Aged'\n when original_reason_entitlement_code is null and medicare_status_code in ('20','21') then 'Disabled'\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then 'Aged'\n end as orec\n /* Defaulting everyone to non-institutional until logic is added */\n , cast('No' as TEXT) as institutional_status\n , enrollment_status_default\n , case\n \n when dual_status_code is null then TRUE\n else FALSE\n \n end as medicaid_dual_status_default\n /* Setting default true when OREC or Medicare Status is ESRD, or null */\n , case\n \n when original_reason_entitlement_code in ('2') then TRUE\n when original_reason_entitlement_code is null and medicare_status_code in ('31') then TRUE\n when coalesce(original_reason_entitlement_code,medicare_status_code) is null then TRUE\n else FALSE\n \n end as orec_default\n /* Setting default true until institutional logic is added */\n \n , TRUE as institutional_status_default\n \n from add_age_group\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast('2024' as integer) as payment_year\n from add_status_logic\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_members"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.576348Z", "completed_at": "2024-10-25T14:34:39.626348Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.660857Z", "completed_at": "2024-10-25T14:34:39.660857Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.1651313304901123, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), diabetics_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa diabetes medications'\n )\n\n)\n\n, rx_diabetes as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join diabetics_codes\n on pharmacy_claims.ndc_code = diabetics_codes.code\n and lower(diabetics_codes.code_system) = 'ndc'\n\n)\n\n, rx_diabetes_in_measurement_period as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , performance_period_end -- to use in latter cte for days in treatment period calculation\n from rx_diabetes\n inner join dev_thuxuan.quality_measures._int_adh_diabetes__performance_period pp\n on dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, rx_fill_order as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n , dense_rank() over (\n partition by \n patient_id\n , performance_period_end\n order by dispensing_date\n ) as dr\n from rx_diabetes_in_measurement_period\n\n)\n\n, rx_first_fill as (\n\n select\n patient_id\n , dispensing_date\n , performance_period_end\n from rx_fill_order\n where dr = 1\n \n)\n\n, timely_fill_check as (\n\n select\n patient_id\n , ( 1 + datediff(\n day,\n dispensing_date,\n performance_period_end\n ) )\n as days_in_treatment_period\n /* \n Performance Period end minus dispensing date results in \n second_date non-inclusive difference, so to include both of these days\n 1 day is added\n */\n from rx_first_fill\n\n)\n\n, first_check_passed_patients as (\n\n select\n patient_id\n , days_in_treatment_period\n from timely_fill_check\n where days_in_treatment_period > 90\n\n)\n\n, second_check_passed_patients as (\n\n select\n patient_id\n from rx_fill_order\n where dr = 2\n\n)\n\n, qualifying_patients as (\n\n select\n first_check_passed_patients.patient_id\n , first_check_passed_patients.days_in_treatment_period\n from first_check_passed_patients\n inner join second_check_passed_patients\n on first_check_passed_patients.patient_id = second_check_passed_patients.patient_id \n\n)\n\n, qualifying_patients_with_age as (\n \n select\n patients.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from __dbt__cte___stg_patient patients\n inner join qualifying_patients\n on patients.patient_id = qualifying_patients.patient_id\n cross join dev_thuxuan.quality_measures._int_adh_diabetes__performance_period pp\n where patients.death_date is null\n\n)\n/*\n Extracting related fields like dispensing_date, ndc_code and days_supply of qualified patients\n to avoid redundant computations in numerator model\n*/\n\n, qualifying_patients_all_claim_info as (\n\n select\n qualifying_patients_with_age.patient_id\n , qualifying_patients_with_age.age\n , rx_diabetes_in_measurement_period.dispensing_date\n , rx_diabetes_in_measurement_period.ndc_code\n , rx_diabetes_in_measurement_period.days_supply\n , qualifying_patients_with_age.days_in_treatment_period\n , qualifying_patients_with_age.performance_period_begin\n , qualifying_patients_with_age.performance_period_end\n , qualifying_patients_with_age.measure_id\n , qualifying_patients_with_age.measure_name\n , qualifying_patients_with_age.measure_version\n from qualifying_patients_with_age\n inner join rx_diabetes_in_measurement_period\n on qualifying_patients_with_age.patient_id = rx_diabetes_in_measurement_period.patient_id\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from qualifying_patients_all_claim_info\n where age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(dispensing_date as date) as dispensing_date\n , cast(ndc_code as TEXT) as ndc_code\n , cast(days_supply as integer) as days_supply\n , cast(days_in_treatment_period as integer) as days_in_treatment_period\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from denominator\n\n)\n\nselect\n patient_id\n , age\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.615347Z", "completed_at": "2024-10-25T14:34:39.664859Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.665857Z", "completed_at": "2024-10-25T14:34:39.665857Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.09050846099853516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) = 'pqa rasa medications'\n\n)\n\n, pharmacy_claim as (\n\n select \n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, patient_with_claim as (\n\n select\n pharmacy_claim.patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n from pharmacy_claim \n inner join visit_codes\n on pharmacy_claim.ndc_code = visit_codes.code\n \n)\n\n, patient_within_performance_period as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n from patient_with_claim as claim_patient\n inner join performance_period as pp\n on claim_patient.dispensing_date between pp.performance_period_begin and pp.performance_period_end\n\n)\n\n/* \n These patients need to pass two checks\n - First medication fill date should be at least 91 days before the end of measurement period\n - Should have at least two distinct Date of Service (FillDate) for rx\n*/\n\n, patient_with_rank as (\n\n select\n patient_id\n , dispensing_date\n , days_supply\n , ndc_code\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n from patient_within_performance_period\n\n)\n\n, patient_with_first_dispensing_date as (\n\n select\n patient_id\n , dispensing_date as first_dispensing_date\n from patient_with_rank\n where dense_rank = 1\n\n)\n\n/*\ntreatment period days is abbreviated as tpd\n*/\n\n, patient_with_tpd as (\n\n select\n patients1.patient_id\n , patients1.dispensing_date\n , patients2.first_dispensing_date\n , patients1.days_supply\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as tpd\n from patient_within_performance_period as patients1\n inner join patient_with_first_dispensing_date as patients2\n on patients1.patient_id = patients2.patient_id\n\n)\n\n, first_check_patient as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n from patient_with_tpd\n where tpd > 89\n \n)\n\n, second_check_patient as (\n\n select\n patient_id\n , ndc_code\n from patient_with_rank\n where dense_rank = 2\n\n)\n\n, both_check_patient as (\n\n select\n valid_patients1.patient_id\n , valid_patients1.dispensing_date\n , valid_patients1.first_dispensing_date\n , valid_patients1.days_supply\n , valid_patients2.ndc_code\n from first_check_patient as valid_patients1\n inner join second_check_patient as valid_patients2\n on valid_patients1.patient_id = valid_patients2.patient_id\n \n)\n\n, patient_with_age as (\n\n select\n valid_patients1.patient_id\n , floor(datediff(\n hour,\n birth_date,\n pp.performance_period_begin\n ) / 8760.0) as age\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from __dbt__cte___stg_patient as patient\n inner join both_check_patient as valid_patients1\n on patient.patient_id = valid_patients1.patient_id\n cross join performance_period as pp\n where patient.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as denominator_flag\n from patient_with_age \n where age > 17\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(dispensing_date as date) as dispensing_date\n , cast(first_dispensing_date as date) as first_dispensing_date\n , cast(days_supply as integer) as days_supply\n , cast(ndc_code as TEXT) as ndc_code\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adhras_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.667856Z", "completed_at": "2024-10-25T14:34:39.681295Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.686308Z", "completed_at": "2024-10-25T14:34:39.686308Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022450923919677734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.accepted_values_quality_measures__stg_core__patient_sex__female__male__unknown.e6adc9ce2b", "compiled": true, "compiled_code": "\n \n \n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), all_values as (\n\n select\n sex as value_field,\n count(*) as n_records\n\n from __dbt__cte___stg_patient\n group by sex\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'female','male','unknown'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.681295Z", "completed_at": "2024-10-25T14:34:39.692316Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.693355Z", "completed_at": "2024-10-25T14:34:39.693355Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026495933532714844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_birth_date.4b3a2e74e6", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n) select birth_date\nfrom __dbt__cte___stg_patient\nwhere birth_date is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.687302Z", "completed_at": "2024-10-25T14:34:39.694887Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.695777Z", "completed_at": "2024-10-25T14:34:39.695777Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015827417373657227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_patient_id.5510e1a0fd", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n) select patient_id\nfrom __dbt__cte___stg_patient\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.696826Z", "completed_at": "2024-10-25T14:34:39.710958Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.711959Z", "completed_at": "2024-10-25T14:34:39.711959Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.017557621002197266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__patient_sex.e2f34cab69", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n) select sex\nfrom __dbt__cte___stg_patient\nwhere sex is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.705953Z", "completed_at": "2024-10-25T14:34:39.717814Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.718711Z", "completed_at": "2024-10-25T14:34:39.718711Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021885395050048828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_eligibility", "compiled": true, "compiled_code": "\n\nselect\n e.patient_id\n , e.birth_date\n , e.gender\n , e.race\n , d.patient_data_source_id\n , row_number() over (partition by d.patient_data_source_id order by e.enrollment_start_date desc) patient_row_num\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_eligibility e\ninner join dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id d on e.patient_id = d.patient_id\nand\ne.data_source = d.data_source", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_eligibility"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.713403Z", "completed_at": "2024-10-25T14:34:39.719733Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.721731Z", "completed_at": "2024-10-25T14:34:39.721731Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01693248748779297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when hcpcs_code in ('59400', '59409', '59410', '59610', '59612', '59614') then 'l/d - vaginal delivery'\n when hcpcs_code in ('59510', '59514', '59515', '59618', '59620', '59622') then 'l/d - cesarean delivery'\n else 'acute inpatient - other'\n end as service_category_3\n , '_int_acute_inpatient_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and place_of_service_code = '21'", "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.722732Z", "completed_at": "2024-10-25T14:34:39.735730Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.740747Z", "completed_at": "2024-10-25T14:34:39.740747Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021013498306274414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulance_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere \n claim_type = 'professional'\n and (\n hcpcs_code between 'A0425' and 'A0436'\n or place_of_service_code in ('41', '42')\n )", "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulance_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.730730Z", "completed_at": "2024-10-25T14:34:39.739700Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.746920Z", "completed_at": "2024-10-25T14:34:39.746920Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025188922882080078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__dme_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'ancillary' as service_category_1\n, 'durable medical equipment' as service_category_2\n, 'durable medical equipment' as service_category_3\n, '_int_dme_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and hcpcs_code between 'E0100' and 'E8002'", "relation_name": "dev_thuxuan.claims_preprocessing._int_dme_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.741887Z", "completed_at": "2024-10-25T14:34:39.749943Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.750942Z", "completed_at": "2024-10-25T14:34:39.750942Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01620769500732422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__home_health_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n , 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('31','32','33')", "relation_name": "dev_thuxuan.claims_preprocessing._int_home_health_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.755448Z", "completed_at": "2024-10-25T14:34:39.772715Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.775723Z", "completed_at": "2024-10-25T14:34:39.775723Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02577972412109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_professional", "compiled": true, "compiled_code": "\n\nselect distinct \nclaim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n,'_int_inpatient_psychiatric_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('51','55','56')", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.762604Z", "completed_at": "2024-10-25T14:34:39.773714Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.776714Z", "completed_at": "2024-10-25T14:34:39.776714Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025772809982299805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n,'_int_inpatient_rehab_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('61')", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_rehab_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.777731Z", "completed_at": "2024-10-25T14:34:39.785716Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.786715Z", "completed_at": "2024-10-25T14:34:39.786715Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016221284866333008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in ('21','22')", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.787715Z", "completed_at": "2024-10-25T14:34:39.801737Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.802982Z", "completed_at": "2024-10-25T14:34:39.802982Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018268108367919922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__observation_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1\n, 'observation' as service_category_2\n, 'observation' as service_category_3\n, '_int_observation_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\nwhere claim_type = 'institutional'\nand (revenue_center_code in ('0762')\nor hcpcs_code in ('G0378','G0379')\n)", "relation_name": "dev_thuxuan.claims_preprocessing._int_observation_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.793716Z", "completed_at": "2024-10-25T14:34:39.802982Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.808173Z", "completed_at": "2024-10-25T14:34:39.808173Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02245640754699707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n, '_int_outpatient_psychiatric_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('52','53','57','58')", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.804086Z", "completed_at": "2024-10-25T14:34:39.810999Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.811999Z", "completed_at": "2024-10-25T14:34:39.811999Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011256694793701172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n claim_id\n, claim_line_number\n, claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient rehabilitation' as service_category_2\n, 'outpatient rehabilitation' as service_category_3\n,'_int_outpatient_rehab_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('62')", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_rehab_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.813002Z", "completed_at": "2024-10-25T14:34:39.823998Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.825819Z", "completed_at": "2024-10-25T14:34:39.825819Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.015821456909179688, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_inpatient_institutional", "compiled": true, "compiled_code": "\n\nwith drg_requirement as (\n select distinct\n mc.claim_id\n from dev_thuxuan.test.service_category__stg_medical_claim as mc\n left join dev_thuxuan.terminology.ms_drg as msdrg\n on mc.ms_drg_code = msdrg.ms_drg_code\n left join dev_thuxuan.terminology.apr_drg as aprdrg\n on mc.apr_drg_code = aprdrg.apr_drg_code\n where mc.claim_type = 'institutional'\n and (\n msdrg.ms_drg_code is not null\n or aprdrg.apr_drg_code is not null\n )\n)\n\n, bill_type_requirement as (\n select distinct\n claim_id\n from dev_thuxuan.test.service_category__stg_medical_claim\n where claim_type = 'institutional'\n and substring(bill_type_code, 1, 2) in (\n '11' -- hospital inpatient \n , '12' -- hospital inpatient \n , '21' -- SNF inpatient\n , '82' -- inpatient hospice\n )\n)\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as a\ninner join bill_type_requirement as d\n on a.claim_id = d.claim_id\n\n\nunion distinct\n\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as a\ninner join drg_requirement as c\n on a.claim_id = c.claim_id", "relation_name": "dev_thuxuan.test.service_category__stg_inpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.818999Z", "completed_at": "2024-10-25T14:34:39.825294Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.826577Z", "completed_at": "2024-10-25T14:34:39.826577Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01657843589782715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id as claim_line_id\n , 'professional' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nwhere a.claim_type = 'professional'", "relation_name": "dev_thuxuan.test.service_category__stg_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.828584Z", "completed_at": "2024-10-25T14:34:39.846735Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.849368Z", "completed_at": "2024-10-25T14:34:39.849368Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025369644165039062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__urgent_care_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and revenue_center_code = '0456'\n and substring(bill_type_code, 1, 2) in ('13','71','73')\n \nunion all\n\nselect distinct \n a.claim_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nwhere claim_type = 'institutional'\n and hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing._int_urgent_care_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.852471Z", "completed_at": "2024-10-25T14:34:39.867641Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.869487Z", "completed_at": "2024-10-25T14:34:39.869487Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03187680244445801, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__urgent_care_professional", "compiled": true, "compiled_code": "\n\nwith multiple_source as (\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\n and place_of_service_code in ('20')\n\nunion all\n\nselect distinct\n claim_id\n , claim_line_number\n , claim_line_id\n, 'urgent care' as service_category_2\n, 'urgent care' as service_category_3\n,'_int_urgent_care_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim\nwhere claim_type = 'professional'\nand hcpcs_code in ('S9088','99051','S9083')\n)\n\nselect distinct \nclaim_id\n,claim_line_number\n,claim_line_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_source", "relation_name": "dev_thuxuan.claims_preprocessing._int_urgent_care_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.857190Z", "completed_at": "2024-10-25T14:34:39.868650Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.871030Z", "completed_at": "2024-10-25T14:34:39.871030Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03144383430480957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , max(case when claim_count > 0 then 1 else 0 end) as prescribed_atleast_one_generic_history\n , sum(case when total_units > 0 and paid_amount > 0 then paid_amount else null end)/sum(case when total_units > 0 and paid_amount > 0 then total_units else null end) as generic_average_cost_per_unit\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.pharmacy.rxnorm_generic_available as g\nleft join dev_thuxuan.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'\ngroup by\n g.product_rxcui\n , cl.data_source", "relation_name": "dev_thuxuan.pharmacy._int_generic_cost"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.871898Z", "completed_at": "2024-10-25T14:34:39.878992Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.880903Z", "completed_at": "2024-10-25T14:34:39.880903Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.014343500137329102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__int_generic_cost_by_ndc", "compiled": true, "compiled_code": "\n\n/* for each brand rxcui, what is the average cost/unit of all generics available*/\n\nselect\n g.product_rxcui as brand_rxcui\n , cl.data_source\n , cl.ndc_code as generic_ndc_code\n , cl.paid_amount\n , cl.claim_count\n , cl.total_units\n , cl.cost_per_unit\n , case when claim_count > 0 then 1 else 0 end as prescribed_atleast_one_generic_history\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.pharmacy.rxnorm_generic_available as g\nleft join dev_thuxuan.pharmacy._int_claims_current_cost as cl \n on cl.ndc_code = g.ndc\nwhere cl.brand_vs_generic = 'generic'", "relation_name": "dev_thuxuan.pharmacy._int_generic_cost_by_ndc"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.880903Z", "completed_at": "2024-10-25T14:34:39.907777Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.917785Z", "completed_at": "2024-10-25T14:34:39.917785Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04087018966674805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_01_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.892770Z", "completed_at": "2024-10-25T14:34:39.908779Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.918776Z", "completed_at": "2024-10-25T14:34:39.918776Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03978395462036133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_03_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.908779Z", "completed_at": "2024-10-25T14:34:39.921668Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.922673Z", "completed_at": "2024-10-25T14:34:39.922673Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01589679718017578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 40", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_05_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.925711Z", "completed_at": "2024-10-25T14:34:39.950681Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.953758Z", "completed_at": "2024-10-25T14:34:39.953758Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03161311149597168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_07_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.939012Z", "completed_at": "2024-10-25T14:34:39.952757Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.964464Z", "completed_at": "2024-10-25T14:34:39.964464Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04179096221923828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_08_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.953758Z", "completed_at": "2024-10-25T14:34:39.967428Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.968450Z", "completed_at": "2024-10-25T14:34:39.968450Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020377397537231445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_11_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.969452Z", "completed_at": "2024-10-25T14:34:39.990438Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:39.991449Z", "completed_at": "2024-10-25T14:34:39.991449Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024020671844482422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_12_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.978454Z", "completed_at": "2024-10-25T14:34:39.991449Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.003450Z", "completed_at": "2024-10-25T14:34:40.003450Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.034999847412109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_14_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:39.992466Z", "completed_at": "2024-10-25T14:34:40.006442Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.022129Z", "completed_at": "2024-10-25T14:34:40.022129Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03267621994018555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18\n and\n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) <= 39", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_15_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.007462Z", "completed_at": "2024-10-25T14:34:40.031138Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.033131Z", "completed_at": "2024-10-25T14:34:40.033131Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027674436569213867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_denom", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_patient as (\n\n\nselect \n data_source\n , birth_date\n , patient_id\n , sex\nfrom \n dev_thuxuan.core.patient\n) select distinct\n cast(substring(e.year_month, 1, 4) as int) AS year_number\n , e.patient_id\n , e.data_source\n , datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) as age\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_member_months as e\ninner join __dbt__cte___stg_pqi_patient as p \n on e.patient_id = p.patient_id\n and p.data_source = e.data_source\nwhere \n datediff(\n year,\n p.birth_date,\n e.first_day_of_month\n ) >= 18", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_16_denom"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.023128Z", "completed_at": "2024-10-25T14:34:40.032133Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.034222Z", "completed_at": "2024-10-25T14:34:40.034222Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.028766155242919922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__enrollment_change", "compiled": true, "compiled_code": "\n\nWITH RankedMonths AS (\n SELECT\n patient_id,\n year_month,\n data_source,\n lag(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as prev_year_month,\n lead(year_month_date, 1) over (partition by patient_id, data_source order by year_month_date) as next_year_month,\n year_month_date\n FROM dev_thuxuan.data_quality.mart_review__stg_member_month\n),\nChanges AS (\n SELECT\n patient_id,\n data_source,\n year_month_date as change_month,\n case\n when prev_year_month is null\n or \n\n dateadd(\n month,\n -1,\n year_month_date\n )\n\n != prev_year_month\n then 'added'\n end as change_type\nFROM RankedMonths\nunion all\nSELECT\n patient_id,\n data_source,\n \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n as change_month,\n case\n when next_year_month is null\n or \n\n dateadd(\n month,\n 1,\n year_month_date\n )\n\n != next_year_month\n then 'removed'\n end as change_type\nFROM RankedMonths\n\n),\nFinal AS (\n SELECT\n patient_id || '|' || change_month as membermonthkey,\n data_source,\n patient_id,\n change_month,\n change_type\n FROM Changes\n WHERE change_type IS NOT NULL\n),\nResult AS (\n SELECT\n data_source,\n change_month,\n change_type,\n count(*) as member_count\n FROM Final\n GROUP BY data_source\n , change_month\n , change_type\n)\n\n\nSELECT * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM Result", "relation_name": "dev_thuxuan.data_quality.mart_review__enrollment_change"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.037126Z", "completed_at": "2024-10-25T14:34:40.048135Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.053233Z", "completed_at": "2024-10-25T14:34:40.053233Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022009849548339844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_demographic_factors", "compiled": true, "compiled_code": "\n\nwith members as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , payment_year\n from dev_thuxuan.cms_hcc._int_members\n\n)\n\n, seed_demographic_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_demographic_factors\n where plan_segment is null /* data not available */\n\n)\n\n, v24_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v24_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V24'\n\n)\n\n, v28_new_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.orec = seed_demographic_factors.orec\n where members.enrollment_status = 'New'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, v28_continuining_enrollees as (\n\n select\n members.patient_id\n , members.enrollment_status\n , members.gender\n , members.age_group\n , members.medicaid_status\n , members.dual_status\n , members.orec\n , members.institutional_status\n , members.enrollment_status_default\n , members.medicaid_dual_status_default\n , members.orec_default\n , members.institutional_status_default\n , members.payment_year\n , seed_demographic_factors.model_version\n , seed_demographic_factors.factor_type\n , seed_demographic_factors.coefficient\n from members\n inner join seed_demographic_factors\n on members.enrollment_status = seed_demographic_factors.enrollment_status\n and members.gender = seed_demographic_factors.gender\n and members.age_group = seed_demographic_factors.age_group\n and members.medicaid_status = seed_demographic_factors.medicaid_status\n and members.dual_status = seed_demographic_factors.dual_status\n and members.orec = seed_demographic_factors.orec\n and members.institutional_status = seed_demographic_factors.institutional_status\n where members.enrollment_status = 'Continuing'\n and seed_demographic_factors.model_version = 'CMS-HCC-V28'\n\n)\n\n, unioned as (\n\n select * from v24_new_enrollees\n union all\n select * from v24_continuining_enrollees\n union all\n select * from v28_new_enrollees\n union all\n select * from v28_continuining_enrollees\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(enrollment_status as TEXT) as enrollment_status\n , cast(gender as TEXT) as gender\n , cast(age_group as TEXT) as age_group\n , cast(medicaid_status as TEXT) as medicaid_status\n , cast(dual_status as TEXT) as dual_status\n , cast(orec as TEXT) as orec\n , cast(institutional_status as TEXT) as institutional_status\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_demographic_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.049135Z", "completed_at": "2024-10-25T14:34:40.061220Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.068237Z", "completed_at": "2024-10-25T14:34:40.068237Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02210235595703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_members_patient_id.75e528329b", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.cms_hcc._int_members\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.054143Z", "completed_at": "2024-10-25T14:34:40.067226Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.069230Z", "completed_at": "2024-10-25T14:34:40.069230Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02309584617614746, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_cms_hcc__int_members_patient_id.4d202f2bbb", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.cms_hcc._int_members\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.073697Z", "completed_at": "2024-10-25T14:34:40.086743Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.098339Z", "completed_at": "2024-10-25T14:34:40.098339Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0311129093170166, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_numerator", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , days_in_treatment_period\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n/*\n The below 3 cte identifies periods of continuous medication use for each patient by:\n 1. Assigning a row number and tracking the previous medication per patient.\n 2. Flagging when a medication change occurs.\n 3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dr\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dr\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dr \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\n The ctes below calculates adjusted medication fill dates,\n groups fills by continuous periods of use and ensures accurate start and end dates based \n on previous fills and the performance period.\n*/\n\n, fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n, previous_fill_end_date as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_end_date\n from fills\n\n)\n\n, adjusted_fills as (\n \n /* Adjust start dates based on the previous fill's end date + 1,\n or use the current rx_fill_date */\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_start_date\n from previous_fill_end_date\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_start_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as final_end_date\n from adjusted_fills\n inner join performance_end\n on adjusted_fills.adjusted_start_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , min(adjusted_start_date) over(partition by patient_id, group_id) as first_disp_date\n , max(adjusted_start_date) over(partition by patient_id, group_id) as last_disp_date\n from final_fills\n\n)\n\n, last_med_end_groupwise as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_start_date\n , final_end_date\n , first_disp_date\n , last_disp_date\n , max(\n case\n when adjusted_start_date = last_disp_date\n then days_supply\n else null\n end) over (partition by patient_id, group_id) as last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n 1. Calculates the total covered days per medication group per patient\n 2. Then calculates the overlap between groups of medication per patient\n 3. Finally calculates the actual total covered days for each patient\n*/\n\n, covered_days_per_group as (\n \n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_start_date,\n final_end_date\n ) ) as covered_days\n from last_med_end_groupwise\n group by \n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , last_days_supply\n\n)\n\n, final_with_lag as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag(last_disp_date) over(partition by patient_id order by first_disp_date) as lag_date\n , lag(last_days_supply) over(partition by patient_id order by first_disp_date) as lag_days_supply\n from covered_days_per_group\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , first_disp_date\n , last_disp_date\n , covered_days\n , lag_date\n , case\n when first_disp_date < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n first_disp_date,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from final_with_lag\n\n)\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, relevant_patients_from_deno as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days / days_in_treatment_period as numeric(28,6)), 4) as adherence\n , dispensing_date as evidence_date\n , days_supply as evidence_value\n from final_covered_days\n inner join denominator\n on final_covered_days.patient_id = denominator.patient_id\n \n)\n\n, numerator as (\n\n select\n patient_id\n , adherence * 100 as adherence --percent conversion\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from relevant_patients_from_deno\n where adherence >= 0.8\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.089462Z", "completed_at": "2024-10-25T14:34:40.106346Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.109347Z", "completed_at": "2024-10-25T14:34:40.109347Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025637388229370117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_numerator", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , dispensing_date\n , first_dispensing_date\n , days_supply\n , ndc_code\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_adhras_denominator\n\n)\n\n, performance_end as (\n\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n/*\nThe below 3 cte identifies periods of continuous medication use for each patient by:\n1. Assigning a row number and tracking the previous medication per patient.\n2. Flagging when a medication change occurs.\n3. Grouping consecutive periods of the same medication by assigning a group ID.\n*/\n\n, ranked_patient as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank() over (partition by patient_id order by dispensing_date) as dense_rank\n , lag(ndc_code) over (partition by patient_id order by dispensing_date) as previous_ndc\n from denominator\n\n)\n\n, grouped_meds as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , dense_rank\n , case\n when (ndc_code != previous_ndc) or previous_ndc is null then 1\n else 0\n end as med_change_flag --to increment group when medication changes\n from ranked_patient\n\n)\n\n, final_groups as (\n\n select\n patient_id\n , ndc_code\n , dispensing_date\n , days_supply\n , sum(med_change_flag) over (\n partition by patient_id \n order by dense_rank \n rows between unbounded preceding and current row\n ) as group_id\n from grouped_meds\n\n)\n\n/*\nThis cte theoretical_end_dates to final_fills calculates adjusted medication fill dates, \ngroups fills by continuous periods of use and ensures accurate start and end dates based \non previous fills and the performance period.\n*/\n\n, theoretical_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n dispensing_date\n )\n\n\n )\n\n as theoretical_end_date\n from final_groups\n\n)\n\n/* \nAdjust start dates based on the previous fill's end date + 1,\nor use the current rx_fill_date \n*/\n\n, previous_fill_end_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , lag(theoretical_end_date)\n over (partition by \n patient_id\n , group_id \n order by\n dispensing_date\n ) as previous_fill_end_date\n from theoretical_end_dates\n\n)\n\n, adjusted_fill_dates as (\n \n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , theoretical_end_date\n , coalesce(\n greatest(\n dispensing_date\n , \n\n dateadd(\n day,\n 1,\n previous_fill_end_date\n )\n\n\n )\n , dispensing_date\n ) as adjusted_fill_date\n from previous_fill_end_dates\n\n)\n\n\n, actual_end_dates as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , least(\n \n\n dateadd(\n day,\n -1,\n \n\n dateadd(\n day,\n days_supply,\n adjusted_fill_date\n )\n\n\n )\n\n\n , performance_period_end\n ) as actual_end_date\n from adjusted_fill_dates\n inner join performance_end\n on adjusted_fill_dates.adjusted_fill_date <= performance_end.performance_period_end\n\n)\n\n, grouped_fill_ranges as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , min(adjusted_fill_date) over(partition by patient_id, group_id) as group_first\n , max(adjusted_fill_date) over(partition by patient_id, group_id) as group_last\n from actual_end_dates\n\n)\n\n, final_fills as (\n\n select\n patient_id\n , group_id\n , dispensing_date\n , days_supply\n , adjusted_fill_date\n , actual_end_date\n , group_first\n , group_last\n , max(\n case\n when adjusted_fill_date = group_last\n then days_supply\n else 0\n end) over (partition by patient_id, group_id) as group_last_days_supply\n from grouped_fill_ranges\n\n)\n\n/*\n1. Calculates the total covered days per every medication group per patient\n2. Then, calculates the overlap between groups of medication per patient.\n3. Then, calculates the actual total covered days for each patient.\n*/\n\n, covered_days_per_groups as (\n \n select\n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n , sum( 1 + datediff(\n day,\n adjusted_fill_date,\n actual_end_date\n ) ) as covered_days_per_group\n from final_fills\n group by \n patient_id\n , group_id\n , group_first\n , group_last\n , group_last_days_supply\n\n)\n\n, with_lag as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag(group_last) over(partition by patient_id order by group_first) as lag_date\n , lag(group_last_days_supply) over(partition by patient_id order by group_first) as lag_days_supply\n from covered_days_per_groups\n\n)\n\n, overlap_days as (\n\n select\n patient_id\n , group_id\n , group_first\n , group_last\n , covered_days_per_group\n , lag_date\n , case\n when group_first < \n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n then\n datediff(\n day,\n group_first,\n \n\n dateadd(\n day,\n lag_days_supply,\n lag_date\n )\n\n\n )\n else 0\n end as overlap\n from with_lag\n\n)\n\n\n, final_covered_days as (\n\n select \n patient_id\n , sum(covered_days_per_group) - sum(overlap) as actual_covered_days\n from overlap_days\n group by patient_id\n\n)\n\n, patient_with_treatment_period_days as (\n select\n patient_id\n , datediff(\n day,\n first_dispensing_date,\n performance_period_end\n ) as treatment_period_days\n from denominator\n\n)\n\n, patient_with_pdc as (\n\n select\n final_covered_days.patient_id\n , round(cast(actual_covered_days * 100 / treatment_period_days as numeric(28,6)), 4) as adherence\n from final_covered_days\n inner join patient_with_treatment_period_days \n on final_covered_days.patient_id = patient_with_treatment_period_days.patient_id\n\n)\n\n/*\nSelects only the patient whose pdc is greater than 80%.\n*/\n\n, valid_patients as (\n\n select \n patient_with_pdc.patient_id\n , adherence\n , denominator.dispensing_date as evidence_date\n , denominator.days_supply as evidence_value\n , 1 as numerator_flag\n from patient_with_pdc \n inner join denominator\n on patient_with_pdc.patient_id = denominator.patient_id \n where patient_with_pdc.adherence >= 80.00 \n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(adherence as numeric(28,6)) as adherence\n , cast(numerator_flag as integer) as numerator_flag\n from valid_patients\n\n)\n\nselect\n patient_id\n , evidence_date\n , evidence_value\n , adherence\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adhras_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.099347Z", "completed_at": "2024-10-25T14:34:40.108447Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.110346Z", "completed_at": "2024-10-25T14:34:40.110346Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025640487670898438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_skilled_nursing_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n, a.claim_line_number\n, a.claim_line_id\n, 'inpatient' as service_category_1\n, 'skilled nursing' as service_category_2\n, 'skilled nursing' as service_category_3\n, '_int_inpatient_skilled_nursing_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nleft join dev_thuxuan.claims_preprocessing._int_dme_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\nwhere claim_type = 'professional'\n and place_of_service_code in ('31','32')\n and (b.claim_id is null and b.claim_line_number is null)", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.112374Z", "completed_at": "2024-10-25T14:34:40.119146Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.120156Z", "completed_at": "2024-10-25T14:34:40.120156Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011708259582519531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_inpatient_institutional", "compiled": true, "compiled_code": "\n\nselect \n claim_id\n, service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_inpatient_institutional a", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_inpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.121147Z", "completed_at": "2024-10-25T14:34:40.136225Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.137273Z", "completed_at": "2024-10-25T14:34:40.137273Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019764184951782227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_maternity", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when s.ms_drg_code in ('768', '796', '797', '798', '805', '806', '807') then 'l/d - vaginal delivery'\n when s.ms_drg_code in ('783', '784', '785', '786', '787', '788') then 'l/d - cesarean delivery'\n when s.ms_drg_code = '795' then 'l/d - newborn'\n when s.ms_drg_code in ('789', '790', '791', '792', '793', '794') then 'l/d - newborn nicu'\n when s.revenue_center_code in ('0173', '0174') then 'l/d - newborn nicu'\n else 'l/d - other'\n end as service_category_3\n , '_int_acute_inpatient_institutional_maternity' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join dev_thuxuan.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code\nwhere \n m.mdc_code in ('MDC 14', 'MDC 15')", "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_maternity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.129091Z", "completed_at": "2024-10-25T14:34:40.138224Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.140223Z", "completed_at": "2024-10-25T14:34:40.140223Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022095918655395508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_med_surg", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'acute inpatient' as service_category_2\n , case \n when m.medical_surgical = 'M' then 'medical'\n when m.medical_surgical = 'P' then 'surgical'\n when m.medical_surgical = 'surgical' then 'surgical'\n else 'acute inpatient - other' \n end as service_category_3\n , '_int_acute_inpatient_institutional_med_surg' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\ninner join dev_thuxuan.terminology.ms_drg as m\n on s.ms_drg_code = m.ms_drg_code", "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_med_surg"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.141232Z", "completed_at": "2024-10-25T14:34:40.154434Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.155941Z", "completed_at": "2024-10-25T14:34:40.155941Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01971578598022461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__acute_inpatient_institutional_other", "compiled": true, "compiled_code": "\n\n\n--simplified by setting lowest priority instead of explicitly doing all the joins\nselect distinct \n a.claim_id\n , 'inpatient' as service_category_1\n, 'acute inpatient' as service_category_2\n, 'acute inpatient - other' as service_category_3\n, '_int_acute_inpatient_institutional_other' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id", "relation_name": "dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_other"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.150428Z", "completed_at": "2024-10-25T14:34:40.160889Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.161806Z", "completed_at": "2024-10-25T14:34:40.161806Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014493465423583984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n, '_int_inpatient_hospice_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional a on s.claim_id = a.claim_id\nwhere substring(s.bill_type_code, 1, 2) in ('82')", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_hospice_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.156798Z", "completed_at": "2024-10-25T14:34:40.162840Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.163809Z", "completed_at": "2024-10-25T14:34:40.163809Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014847040176391602, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_psychiatric_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \ns.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient psychiatric' as service_category_2\n, 'inpatient psychiatric' as service_category_3\n, '_int_inpatient_psychiatric_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.166805Z", "completed_at": "2024-10-25T14:34:40.183933Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.186547Z", "completed_at": "2024-10-25T14:34:40.186547Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02370738983154297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_rehab_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n s.claim_id\n, 'inpatient' as service_category_1\n, 'inpatient rehabilitation' as service_category_2\n, 'inpatient rehabilitation' as service_category_3\n, '_int_inpatient_rehab_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional i on s.claim_id = i.claim_id\nwhere s.primary_taxonomy_code in ('283X00000X'\n ,'273Y00000X'\n )", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_rehab_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.178936Z", "completed_at": "2024-10-25T14:34:40.188625Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.195582Z", "completed_at": "2024-10-25T14:34:40.195582Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.029772520065307617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_substance_use_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n a.claim_id\n , 'inpatient' as service_category_1\n , 'inpatient substance use' as service_category_2\n , 'inpatient substance use' as service_category_3\n , '_int_inpatient_substance_use_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as s\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional as a\n on s.claim_id = a.claim_id\nwhere \n s.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )\n or s.default_ccsr_category_description_ip in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_substance_use_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.188625Z", "completed_at": "2024-10-25T14:34:40.197544Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.199606Z", "completed_at": "2024-10-25T14:34:40.199606Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025344133377075195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_outpatient_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n, 'outpatient' as service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\nleft join dev_thuxuan.test.service_category__stg_inpatient_institutional i on a.claim_id = i.claim_id\nwhere i.claim_id is null\nand\na.claim_type = 'institutional'", "relation_name": "dev_thuxuan.test.service_category__stg_outpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.201105Z", "completed_at": "2024-10-25T14:34:40.210566Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.211607Z", "completed_at": "2024-10-25T14:34:40.211607Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01602339744567871, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n claim_id\n, claim_line_number\n, claim_line_id\n, service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_professional a", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.206569Z", "completed_at": "2024-10-25T14:34:40.218567Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.219569Z", "completed_at": "2024-10-25T14:34:40.219569Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018972396850585938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n, 'ambulatory surgery center' as service_category_2\n, 'ambulatory surgery center' as service_category_3\n, '_int_ambulatory_surgery_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('24')", "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.212568Z", "completed_at": "2024-10-25T14:34:40.220657Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.222568Z", "completed_at": "2024-10-25T14:34:40.222568Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.015999555587768555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__dialysis_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1 \n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('65')\n or med.ccs_category in ('91', '58', '57')", "relation_name": "dev_thuxuan.claims_preprocessing._int_dialysis_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.223568Z", "completed_at": "2024-10-25T14:34:40.228568Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.236567Z", "completed_at": "2024-10-25T14:34:40.236567Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016909360885620117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__emergency_department_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'emergency department' as service_category_2\n, 'emergency department' as service_category_3\n, '_int_emergency_department_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '23'\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')", "relation_name": "dev_thuxuan.claims_preprocessing._int_emergency_department_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.228568Z", "completed_at": "2024-10-25T14:34:40.243575Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.246575Z", "completed_at": "2024-10-25T14:34:40.246575Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024007081985473633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__home_health_professional", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1\n, 'home health' as service_category_2\n, 'home health' as service_category_3\n, '_int_home_health_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere med.place_of_service_code in ('12')", "relation_name": "dev_thuxuan.claims_preprocessing._int_home_health_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.238567Z", "completed_at": "2024-10-25T14:34:40.247575Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.249573Z", "completed_at": "2024-10-25T14:34:40.249573Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021005868911743164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__inpatient_hospice_professional", "compiled": true, "compiled_code": "\n\nselect distinct\nmed.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'inpatient' as service_category_1\n, 'inpatient hospice' as service_category_2\n, 'inpatient hospice' as service_category_3\n,'_int_inpatient_hospice_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code in ('34')", "relation_name": "dev_thuxuan.claims_preprocessing._int_inpatient_hospice_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.251573Z", "completed_at": "2024-10-25T14:34:40.264894Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.270539Z", "completed_at": "2024-10-25T14:34:40.270539Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02196478843688965, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__lab_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere place_of_service_code = '81'\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "relation_name": "dev_thuxuan.claims_preprocessing._int_lab_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.265534Z", "completed_at": "2024-10-25T14:34:40.277540Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.281539Z", "completed_at": "2024-10-25T14:34:40.281539Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03096294403076172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__observation_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'observation' as service_category_2\n , 'observation' as service_category_3\n , '_int_observation_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.hcpcs_code in ('G0378', 'G0379')", "relation_name": "dev_thuxuan.claims_preprocessing._int_observation_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.271642Z", "completed_at": "2024-10-25T14:34:40.284037Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.285745Z", "completed_at": "2024-10-25T14:34:40.285745Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.027571916580200195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient hospice' as service_category_2\n, 'outpatient hospice' as service_category_3\n, '_int_outpatient_hospice_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere \nmed.hcpcs_code in ('Q5001','Q5002','Q5003','Q5009')", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospice_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.289759Z", "completed_at": "2024-10-25T14:34:40.300814Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.305925Z", "completed_at": "2024-10-25T14:34:40.305925Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021361351013183594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.place_of_service_code in ('15', '17', '19', '22', '49', '50', '60', '71', '72')", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.296755Z", "completed_at": "2024-10-25T14:34:40.305925Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.307843Z", "completed_at": "2024-10-25T14:34:40.307843Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020087480545043945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient pt/ot/st' as service_category_2\n, 'outpatient pt/ot/st' as service_category_3\n, 'service_category__outpatient_physical_therapy_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (ccs_category in ('213','212','215')\nOR\nmed.primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nAND\nplace_of_service_code <> '11'", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.301839Z", "completed_at": "2024-10-25T14:34:40.308844Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.309852Z", "completed_at": "2024-10-25T14:34:40.309852Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014093637466430664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_professional as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n and med.place_of_service_code <> '11'", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.311855Z", "completed_at": "2024-10-25T14:34:40.324844Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.330928Z", "completed_at": "2024-10-25T14:34:40.330928Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022083282470703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\n(ccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244'))\nand\nplace_of_service_code in ('15','17','19','22','49','50','60','71','72')", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.317858Z", "completed_at": "2024-10-25T14:34:40.332167Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.333494Z", "completed_at": "2024-10-25T14:34:40.333494Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022635698318481445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__pharmacy_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , case when place_of_service_code = '11' then 'office-based' else 'outpatient' end as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n ,'service_category__pharmacy_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_professional prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere\nccs_category = '240' --medications", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.325850Z", "completed_at": "2024-10-25T14:34:40.333494Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.335039Z", "completed_at": "2024-10-25T14:34:40.335039Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.017180919647216797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__stg_office_based", "compiled": true, "compiled_code": "\n\nselect distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_line_id\n , 'office based' as service_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim a\ninner join dev_thuxuan.test.service_category__stg_professional p on a.claim_id = p.claim_id \nand\na.claim_line_number = p.claim_line_number\nwhere a.place_of_service_code in ( '11' -- office\n,'02' --telehealth \n,'10' --telehealth\n)", "relation_name": "dev_thuxuan.test.service_category__stg_office_based"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.337051Z", "completed_at": "2024-10-25T14:34:40.365307Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.375554Z", "completed_at": "2024-10-25T14:34:40.375554Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04101872444152832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__brand_generic_opportunity", "compiled": true, "compiled_code": "\n\n/* claimid/line/source grain. calculates opportunity at line level*/\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n), cpu as (\nselect claim_id\n,claim_line_number\n,data_source\n,case when quantity > 0 then paid_amount/quantity else null end as brand_cost_per_unit\nfrom __dbt__cte__stg_pharmacy_claim\n)\n\n\nselect \n pc.data_source\n , pc.claim_id\n , pc.claim_line_number\n , cc.ndc_code\n , cc.ndc_description\n , cc.rxcui as brand_rxcui\n , cc.brand_vs_generic \n , cc.generic_available\n , pc.paid_amount\n , pc.quantity as total_units\n , cpu.brand_cost_per_unit\n , gc.generic_average_cost_per_unit \n , cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit as brand_less_generic_cost_per_unit\n , case \n when cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit > 0 \n then (cpu.brand_cost_per_unit - gc.generic_average_cost_per_unit) * pc.quantity \n else 0 \n end as generic_available_total_opportunity\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as pc\ninner join cpu on pc.claim_id = cpu.claim_id\n and\n pc.claim_line_number = cpu.claim_line_number\n and\n pc.data_source = cpu.data_source\ninner join dev_thuxuan.pharmacy._int_claims_current_cost cc\n on cc.ndc_code = pc.ndc_code\n and\n cc.data_source = pc.data_source\ninner join dev_thuxuan.pharmacy._int_generic_cost as gc \n on cc.rxcui = gc.brand_rxcui\n and gc.data_source = cc.data_source\nwhere prescribed_atleast_one_generic_history = 1", "relation_name": "dev_thuxuan.pharmacy.brand_generic_opportunity"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.352136Z", "completed_at": "2024-10-25T14:34:40.375554Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.381577Z", "completed_at": "2024-10-25T14:34:40.381577Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04543924331665039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_denom_long", "compiled": true, "compiled_code": "\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '01' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_01_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '03' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_03_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '05' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_05_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '07' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_07_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '08' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_08_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '11' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_11_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '12' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_12_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '14' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_14_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '15' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_15_denom as d\n\nunion all\n\nselect\n d.year_number\n , d.patient_id\n , d.data_source\n , '16' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_16_denom as d", "relation_name": "dev_thuxuan.ahrq_measures.pqi_denom_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.367389Z", "completed_at": "2024-10-25T14:34:40.381577Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.384526Z", "completed_at": "2024-10-25T14:34:40.384526Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03339123725891113, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_enrollment_interaction_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , gender\n , enrollment_status\n , medicaid_status\n , dual_status\n , institutional_status\n , description\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_enrollment_interaction_factors\n\n)\n\n/*\n Originally disabled interactions for non-institutional members >= 65\n*/\n, non_institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.gender = seed_interaction_factors.gender\n and demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.medicaid_status = seed_interaction_factors.medicaid_status\n and demographics.dual_status = seed_interaction_factors.dual_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'No'\n and demographics.orec = 'Disabled'\n and demographics.age_group in (\n '65-69'\n , '70-74'\n , '75-79'\n , '80-84'\n , '85-89'\n , '90-94'\n , '>=95'\n )\n\n)\n\n/*\n Medicaid interactions for institutional members\n*/\n, institutional_interactions as (\n\n select\n demographics.patient_id\n , demographics.model_version\n , demographics.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics\n inner join seed_interaction_factors\n on demographics.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics.institutional_status = seed_interaction_factors.institutional_status\n and demographics.model_version = seed_interaction_factors.model_version\n where demographics.institutional_status = 'Yes'\n and demographics.medicaid_status = 'Yes'\n\n)\n\n, unioned as (\n\n select * from non_institutional_interactions\n union all\n select * from institutional_interactions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_enrollment_interaction_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.391658Z", "completed_at": "2024-10-25T14:34:40.405910Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.407233Z", "completed_at": "2024-10-25T14:34:40.407233Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02123260498046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_cms_hcc__int_demographic_factors_patient_id__model_version.d5ad3bc1ba", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, model_version\n from dev_thuxuan.cms_hcc._int_demographic_factors\n group by patient_id, model_version\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.397628Z", "completed_at": "2024-10-25T14:34:40.405910Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.408404Z", "completed_at": "2024-10-25T14:34:40.408404Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01882338523864746, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_outpatient_institutional", "compiled": true, "compiled_code": "\n\n\nselect distinct \n claim_id\n, service_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_outpatient_institutional a", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_outpatient_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.401591Z", "completed_at": "2024-10-25T14:34:40.407826Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.409413Z", "completed_at": "2024-10-25T14:34:40.409413Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.018759727478027344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulance_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'ancillary' as service_category_1\n , 'ambulance' as service_category_2\n , 'ambulance' as service_category_3\n , '_int_ambulance_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n (med.hcpcs_code between 'A0425' and 'A0436')\n or med.revenue_center_code = '0540'", "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulance_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.413409Z", "completed_at": "2024-10-25T14:34:40.547710Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.556359Z", "completed_at": "2024-10-25T14:34:40.556359Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.1459505558013916, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__ambulatory_surgery_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0490','0499')\n\nunion all\n\nselect distinct \n med.claim_id\n , 'ambulatory surgery center' as service_category_2\n , 'ambulatory surgery center' as service_category_3\n , '_int_ambulatory_surgery_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere med.primary_taxonomy_code = '261QA1903X'\n)\n\nselect distinct claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.536683Z", "completed_at": "2024-10-25T14:34:40.554815Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.559369Z", "completed_at": "2024-10-25T14:34:40.559369Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.14795994758605957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__dialysis_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'dialysis' as service_category_2\n , 'dialysis' as service_category_3\n , '_int_dialysis_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('72')\n or med.primary_taxonomy_code in (\n '2472R0900X'\n , '163WD1100X'\n , '163WH0500X'\n , '261QE0700X'\n )\n or med.ccs_category in ('91', '58', '57')\n or substring(med.revenue_center_code, 1, 3) in ('082', '083', '084', '085', '088')", "relation_name": "dev_thuxuan.claims_preprocessing._int_dialysis_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.549711Z", "completed_at": "2024-10-25T14:34:40.558366Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.562366Z", "completed_at": "2024-10-25T14:34:40.562366Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.14995479583740234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__emergency_department_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\nOR\nhcpcs_code in ('99281','99282','99283','99284','99285','G0380','G0381','G0382','G0383','G0384')\n \nunion all\n\n--Adding in inpatient claims for flagging encounters with ED \nselect distinct \n med.claim_id\n , 'emergency department' as service_category_2\n , 'emergency department' as service_category_3\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , '_int_emergency_department_institutional' as source_model_name\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_inpatient_institutional inp\n on med.claim_id = inp.claim_id\nwhere revenue_center_code in ('0450','0451','0452','0459','0981')\n\n)\n\nselect claim_id\n, 'outpatient' as service_category_1\n,service_category_2\n,service_category_3\n,tuva_last_run\n,source_model_name\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing._int_emergency_department_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.566955Z", "completed_at": "2024-10-25T14:34:40.582955Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.584250Z", "completed_at": "2024-10-25T14:34:40.584250Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020880937576293945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__lab_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'ancillary' as service_category_1 \n, 'lab' as service_category_2\n, 'lab' as service_category_3\n,'_int_lab_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.bill_type_code, 1, 2) in ('14')\nOR\nmed.ccs_category in ('233' -- lab\n,'235' --other lab\n,'234' --pathology\n)", "relation_name": "dev_thuxuan.claims_preprocessing._int_lab_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.571998Z", "completed_at": "2024-10-25T14:34:40.585266Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.585653Z", "completed_at": "2024-10-25T14:34:40.585653Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021688222885131836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospice_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient hospice' as service_category_2\n , 'outpatient hospice' as service_category_3\n , '_int_outpatient_hospice_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\nwhere \n substring(med.bill_type_code, 1, 2) in ('81')\n or (\n med.hcpcs_code in ('Q5001', 'Q5002', 'Q5003', 'Q5009')\n and substring(med.bill_type_code, 1, 2) not in ('31', '32', '33')\n )\n or med.revenue_center_code in ('0651', '0652')", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospice_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.577031Z", "completed_at": "2024-10-25T14:34:40.585653Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.587680Z", "completed_at": "2024-10-25T14:34:40.587680Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021734237670898438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_hospital_or_clinic_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as m\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n substring(m.bill_type_code, 1, 2) in ('13', '71', '73')\n\n union all\n\n select distinct\n m.claim_id\n , 'outpatient hospital or clinic' as service_category_2\n , 'outpatient hospital or clinic' as service_category_3\n , '_int_outpatient_hospital_or_clinic_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as m\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as o\n on m.claim_id = o.claim_id\n where \n m.ccs_category = '227' -- Consultation, evaluation, and preventative care\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.590261Z", "completed_at": "2024-10-25T14:34:40.596259Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.605338Z", "completed_at": "2024-10-25T14:34:40.605338Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018660545349121094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_physical_therapy_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n ,'outpatient' as service_category_1 \n , 'outpatient pt/ot/st' as service_category_2\n , 'outpatient pt/ot/st' as service_category_3\n ,'service_category__outpatient_physical_therapy_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere ccs_category in ('213','212','215')", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.596259Z", "completed_at": "2024-10-25T14:34:40.606646Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.607888Z", "completed_at": "2024-10-25T14:34:40.607888Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01762700080871582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_psychiatric_institutional", "compiled": true, "compiled_code": "\nwith multiple_sources as (\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim m\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere substring(m.bill_type_code, 1, 2) in ('52')\n\nunion all\n\nselect distinct \n m.claim_id\n, 'outpatient psychiatric' as service_category_2\n, 'outpatient psychiatric' as service_category_3\n,'_int_outpatient_psychiatric_institutional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim m\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional i on m.claim_id = i.claim_id\nwhere m.primary_taxonomy_code in ('283Q00000X'\n ,'273R00000X')\n)\n\nselect distinct claim_id\n,'outpatient' as service_category_1 \n,service_category_2\n,service_category_3\n,source_model_name\n,tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.601261Z", "completed_at": "2024-10-25T14:34:40.607888Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.608936Z", "completed_at": "2024-10-25T14:34:40.608936Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014589071273803711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_institutional' as source_model_name \n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.611817Z", "completed_at": "2024-10-25T14:34:40.622969Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.632542Z", "completed_at": "2024-10-25T14:34:40.632542Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023606300354003906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_radiology_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'outpatient' as service_category_1 \n, 'outpatient radiology' as service_category_2\n, case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n, 'service_category__outpatient_radiology_professional' as source_model_name \n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere med.modality is not null\nand\nplace_of_service_code <> '11'", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.622969Z", "completed_at": "2024-10-25T14:34:40.636109Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.639161Z", "completed_at": "2024-10-25T14:34:40.639161Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.029308319091796875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_rehab_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n m.claim_id\n , 'outpatient rehabilitation' as service_category_2\n , 'outpatient rehabilitation' as service_category_3\n , 'service_category__outpatient_rehab_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as m\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as i\n on m.claim_id = i.claim_id\n where \n m.primary_taxonomy_code in (\n '283X00000X'\n , '273Y00000X'\n , '261QR0400X'\n , '315D00000X'\n , '261QR0401X'\n , '208100000X'\n , '225400000X'\n , '324500000X'\n , '2278P1005X'\n , '261QR0405X'\n , '2081S0010X'\n , '261QR0404X'\n )\n)\n\nselect distinct\n claim_id\n , 'outpatient' as service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_rehab_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.628567Z", "completed_at": "2024-10-25T14:34:40.636109Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.640119Z", "completed_at": "2024-10-25T14:34:40.640119Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02326202392578125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_substance_use_institutional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , 'outpatient' as service_category_1\n , 'outpatient substance use' as service_category_2\n , 'outpatient substance use' as service_category_3\n , 'service_category__outpatient_substance_use_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional as o\n on med.claim_id = o.claim_id\nwhere \n med.default_ccsr_category_description_op in (\n 'MBD026'\n , 'SYM008'\n , 'MBD025'\n , 'SYM009'\n , 'MBD034'\n )\n or med.primary_taxonomy_code in (\n '324500000X'\n , '261QR0405X'\n , '101YA0400X'\n )", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.645234Z", "completed_at": "2024-10-25T14:34:40.661545Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.662438Z", "completed_at": "2024-10-25T14:34:40.662438Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021209001541137695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__outpatient_surgery_institutional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id --claim level\n , 'outpatient' as service_category_1 \n , 'outpatient surgery' as service_category_2\n , 'outpatient surgery' as service_category_3\n , 'service_category__outpatient_surgery_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_outpatient_institutional o on med.claim_id = o.claim_id\nwhere\nccs_category between '1' and '176'\nor\nccs_category in ('229','230','231','232','244')", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.651236Z", "completed_at": "2024-10-25T14:34:40.662438Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.664079Z", "completed_at": "2024-10-25T14:34:40.664079Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019842147827148438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__pharmacy_institutional", "compiled": true, "compiled_code": "\n\nwith multiple_sources as (\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'outpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as med\n inner join dev_thuxuan.test.service_category__stg_outpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547'\n or med.ccs_category = '240') -- medications\n\n union all\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , 'inpatient' as service_category_1\n , 'pharmacy' as service_category_2\n , 'pharmacy' as service_category_3\n , 'service_category__pharmacy_institutional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_medical_claim as med\n inner join dev_thuxuan.test.service_category__stg_inpatient_institutional as outpatient\n on med.claim_id = outpatient.claim_id\n where \n (substring(med.revenue_center_code, 1, 3) in ('025', '026', '063', '089') -- pharmacy and iv therapy\n or med.revenue_center_code = '0547')\n)\n\nselect \n claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , source_model_name\n , tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__pharmacy_institutional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.656333Z", "completed_at": "2024-10-25T14:34:40.664079Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.665085Z", "completed_at": "2024-10-25T14:34:40.665085Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.020850658416748047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_physical_therapy_professional", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based pt/ot/st' as service_category_2\n , 'office-based pt/ot/st' as service_category_3\n ,'service_category__office_based_physical_therapy_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_office_based prof on med.claim_id = prof.claim_id \nand\nmed.claim_line_number = prof.claim_line_number\nwhere (\nccs_category in ('213','212','215')\nOR\n med.rend_primary_specialty_description IN (\n 'Occupational Health'\n ,'Occupational Medicine'\n ,'Occupational Therapist in Private Practice'\n ,'Occupational Therapy Assistant'\n ,'Physical Therapist'\n ,'Physical Therapist in Private Practice'\n ,'Physical Therapy Assistant'\n ,'Speech Language Pathologist'\n ,'Speech-Language Assistant'\n ))\nand place_of_service_code = '11'", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.669091Z", "completed_at": "2024-10-25T14:34:40.675127Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.690129Z", "completed_at": "2024-10-25T14:34:40.690129Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025043249130249023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_radiology", "compiled": true, "compiled_code": "\n\nselect distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1 \n , 'office-based radiology' as service_category_2\n , case when med.modality = 'Nuclear medicine' then 'pet'\n when med.modality = 'Magnetic resonance' then 'mri'\n when med.modality = 'Computerized tomography' then 'ct'\n when med.modality in ('Invasive', 'Ultrasound', 'Computer-aided detection', 'Three-dimensional reconstruction', 'Radiography') then 'general'\n else 'general' \n end as service_category_3\n ,'service_category__office_based_radiology' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim med\ninner join dev_thuxuan.test.service_category__stg_office_based o on med.claim_id = o.claim_id\nand\nmed.claim_line_number = o.claim_line_number\nwhere \nmed.modality is not null\nand\nmed.place_of_service_code = '11'", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_radiology"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.675127Z", "completed_at": "2024-10-25T14:34:40.692112Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.694004Z", "completed_at": "2024-10-25T14:34:40.694004Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02592015266418457, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_surgery_professional", "compiled": true, "compiled_code": "\n\n\nwith numeric_hcpcs as (\n select *\n from dev_thuxuan.test.service_category__stg_medical_claim as med\n where \n \n try_cast(hcpcs_code as int)\n is not null\n)\n\n\n select distinct \n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n ,'office-based' as service_category_1 \n , 'office-based surgery' as service_category_2\n , 'office-based surgery' as service_category_3\n , 'service_category__office_based_surgery_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from numeric_hcpcs as med\n inner join dev_thuxuan.test.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\n where \n (hcpcs_code between '10021' and '69999')", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.685209Z", "completed_at": "2024-10-25T14:34:40.693612Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.717922Z", "completed_at": "2024-10-25T14:34:40.717922Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.044342041015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_visit_professional", "compiled": true, "compiled_code": "\n\nselect distinct\n med.claim_id\n , med.claim_line_number\n , med.claim_line_id\n , 'office-based' as service_category_1\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_2\n , case \n when med.place_of_service_code = '11' then 'office-based visit'\n when med.place_of_service_code in ('02', '10') then 'telehealth visit'\n end as service_category_3\n , '_int_office_based_visit_professional' as source_model_name\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.test.service_category__stg_medical_claim as med\ninner join dev_thuxuan.test.service_category__stg_office_based as prof\n on med.claim_id = prof.claim_id\n and med.claim_line_number = prof.claim_line_number\nwhere \n (med.place_of_service_code = '11' and med.ccs_category = '227') -- consultation eval and preventative care\n or med.place_of_service_code in ('02', '10') -- telehealth", "relation_name": "dev_thuxuan.claims_preprocessing._int_office_based_visit_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.695015Z", "completed_at": "2024-10-25T14:34:40.724910Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.728990Z", "completed_at": "2024-10-25T14:34:40.728990Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03687763214111328, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__pharmacy_claim_expanded", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n), all_drugs as (\n select \n p.data_source\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.ndc_code\n , p.ndc_description\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\n , p.paid_amount\n , p.allowed_amount\n , p.rxcui\n , r.product_name\n , r.product_tty\n , r.brand_vs_generic\n , r.brand_name\n , r.clinical_product_rxcui as generic_rxcui\n , r.clinical_product_name as generic_rxcui_description\n , r.clinical_product_tty as generic_tty\n , r.ingredient_name\n , r.dose_form_name\n , case \n when ga.brand_with_generic_available is not null \n then 'brand_with_generic_available' \n else r.brand_vs_generic \n end as generic_available\n , opp.brand_cost_per_unit\n , opp.generic_average_cost_per_unit\n , opp.brand_less_generic_cost_per_unit\n , opp.generic_available_total_opportunity\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from __dbt__cte__stg_pharmacy_claim as p\n left join dev_thuxuan.terminology.rxnorm_brand_generic as r \n on p.rxcui = r.product_rxcui\n left join dev_thuxuan.pharmacy._int_brand_with_generic_available as ga \n on p.rxcui = ga.brand_with_generic_available\n left join dev_thuxuan.pharmacy.brand_generic_opportunity as opp \n on p.claim_id = opp.claim_id\n and p.claim_line_number = opp.claim_line_number\n and p.data_source = opp.data_source\n)\n\n, generic_available as (\n select \n *\n , row_number() over (order by ndc_code, data_source) as generic_available_sk\n from all_drugs\n where generic_available = 'brand_with_generic_available'\n)\n\nselect \n a.data_source\n , a.claim_id\n , a.claim_line_number\n , a.patient_id\n , a.member_id\n , a.prescribing_provider_id\n , a.dispensing_provider_id\n , a.dispensing_date\n , a.ndc_code\n , a.ndc_description\n , a.quantity\n , a.days_supply\n , a.refills\n , a.paid_date\n , a.paid_amount\n , a.allowed_amount\n , a.rxcui\n , a.product_name\n , a.product_tty\n , a.brand_vs_generic\n , a.brand_name\n , a.generic_rxcui\n , a.generic_rxcui_description\n , a.generic_tty\n , a.ingredient_name\n , a.dose_form_name\n , a.generic_available\n , a.brand_cost_per_unit\n , a.generic_average_cost_per_unit\n , a.brand_less_generic_cost_per_unit\n , a.generic_available_total_opportunity\n , g.generic_available_sk\nfrom all_drugs as a\nleft join generic_available as g \n on a.claim_id = g.claim_id\n and a.claim_line_number = g.claim_line_number\n and a.data_source = g.data_source", "relation_name": "dev_thuxuan.pharmacy.pharmacy_claim_expanded"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.733910Z", "completed_at": "2024-10-25T14:34:40.751259Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.758779Z", "completed_at": "2024-10-25T14:34:40.758779Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.032865285873413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__brand_generic_opportunity_data_source__claim_id__claim_line_number.c19d0cecc7", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from dev_thuxuan.pharmacy.brand_generic_opportunity\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.768721Z", "completed_at": "2024-10-25T14:34:40.774721Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.775759Z", "completed_at": "2024-10-25T14:34:40.775759Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.011017560958862305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__office_based_other_professional", "compiled": true, "compiled_code": "\n\n\n select distinct \n med.claim_id\n, med.claim_line_number\n, med.claim_line_id\n, 'office-based' as service_category_1 \n, 'office-based other' as service_category_2\n, 'office-based other' as service_category_3\n, 'service_category__office_based_other_professional' as source_model_name\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from dev_thuxuan.test.service_category__stg_office_based med\n left join dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional pharm on med.claim_line_id = pharm.claim_line_id\n left join dev_thuxuan.claims_preprocessing.service_category__office_based_radiology rad on med.claim_line_id = rad.claim_line_id\n left join dev_thuxuan.claims_preprocessing._int_office_based_visit_professional visit on med.claim_line_id = visit.claim_line_id\n left join dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional surg on med.claim_line_id = surg.claim_line_id\n left join dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional pt on med.claim_line_id = pt.claim_line_id\n where pharm.claim_line_id is null \n and rad.claim_line_id is null \n and visit.claim_line_id is null\n and surg.claim_line_id is null\n and pt.claim_line_id is null", "relation_name": "dev_thuxuan.claims_preprocessing.service_category__office_based_other_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.779189Z", "completed_at": "2024-10-25T14:34:40.805737Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.808724Z", "completed_at": "2024-10-25T14:34:40.808724Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03175520896911621, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.pharmacy__generic_available_list", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__stg_pharmacy_claim as (\n\n\nselect \n p.ndc_code\n , n.fda_description as ndc_description\n , p.data_source\n , n.rxcui\n , p.paid_amount\n , p.allowed_amount\n , p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.member_id\n , p.prescribing_provider_id\n , p.dispensing_provider_id\n , p.dispensing_date\n , p.quantity\n , p.days_supply\n , p.refills\n , p.paid_date\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\n), generic_sk as (\n select \n generic_available_sk\n , claim_id\n , claim_line_number\n , data_source\n from dev_thuxuan.pharmacy.pharmacy_claim_expanded as e\n where generic_available_sk is not null\n)\n\nselect \n sk.generic_available_sk\n , p.data_source\n , p.ndc_code as brand_ndc_code\n , p.ndc_description as brand_ndc_description\n , p.rxcui as brand_rxcui\n , p.paid_amount as brand_paid_amount\n , p.quantity as brand_units\n , case \n when p.quantity = 0 \n then 0 \n else p.paid_amount / p.quantity \n end as brand_paid_per_unit\n , ga.ndc as generic_ndc\n , n.fda_description as generic_ndc_description\n , case \n when gc.ndc_code is not null \n then 1 \n else 0 \n end as generic_prescribed_history\n , gc.cost_per_unit as generic_cost_per_unit\n , gc.cost_per_unit * p.quantity as generic_cost_at_units\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__stg_pharmacy_claim as p\ninner join generic_sk as sk \n on p.claim_id = sk.claim_id\n and p.claim_line_number = sk.claim_line_number\n and p.data_source = sk.data_source\ninner join dev_thuxuan.pharmacy._int_brand_with_generic_available as b \n on p.rxcui = b.brand_with_generic_available\ninner join dev_thuxuan.pharmacy.rxnorm_generic_available as ga \n on p.rxcui = ga.product_rxcui\n and ga.ndc_product_tty in ('SCD','GPCK')\nleft join dev_thuxuan.terminology.ndc as n \n on ga.ndc = n.ndc\nleft join dev_thuxuan.pharmacy._int_claims_current_cost as gc \n on ga.ndc = gc.ndc_code\n and gc.brand_vs_generic = 'generic'\n and gc.data_source = p.data_source\nwhere \n ga.product_startmarketingdate is not null\n \n and cast(ga.product_startmarketingdate as date) <= current_date\n", "relation_name": "dev_thuxuan.pharmacy.generic_available_list"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.813724Z", "completed_at": "2024-10-25T14:34:40.817726Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.818728Z", "completed_at": "2024-10-25T14:34:40.818728Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.007003307342529297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__pharmacy_claim_expanded_data_source__claim_id__claim_line_number.132bf82f59", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n data_source, claim_id, claim_line_number\n from dev_thuxuan.pharmacy.pharmacy_claim_expanded\n group by data_source, claim_id, claim_line_number\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:38.290555Z", "completed_at": "2024-10-25T14:34:40.981927Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:40.982927Z", "completed_at": "2024-10-25T14:34:40.982927Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 2.8127901554107666, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_quality_test_summary", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_claim_line_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_claim_line_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_inst_header_fields' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_inst_header_fields\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.medical_claim_provider_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.medical_claim_provider_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_ndc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_ndc\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_npi' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_npi\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_prescription_details' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_prescription_details\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.pharmacy_claim_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.pharmacy_claim_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.primary_key_check' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.primary_key_check\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_date_checks' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_date_checks\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_demographics' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_demographics\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_missing_patient_id' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_missing_patient_id\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.eligibility_missing_payer' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(64)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(13,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.data_quality.eligibility_missing_payer\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned_data\nwhere data_quality_check <> 'Percent of claims with secondary diagnosis'", "relation_name": "dev_thuxuan.data_quality.data_quality_test_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:41.077436Z", "completed_at": "2024-10-25T14:34:41.081433Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:41.081433Z", "completed_at": "2024-10-25T14:34:41.081433Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.004995822906494141, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__generics", "compiled": true, "compiled_code": "\n\nselect *\nfrom dev_thuxuan.pharmacy.generic_available_list", "relation_name": "dev_thuxuan.data_quality.mart_review__generics"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:41.083433Z", "completed_at": "2024-10-25T14:34:41.088433Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:41.089433Z", "completed_at": "2024-10-25T14:34:41.089433Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.0069997310638427734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_pharmacy__generic_available_list_generic_available_sk__generic_ndc.5460505c42", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n generic_available_sk, generic_ndc\n from dev_thuxuan.pharmacy.generic_available_list\n group by generic_available_sk, generic_ndc\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:41.091433Z", "completed_at": "2024-10-25T14:34:41.095433Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:41.095433Z", "completed_at": "2024-10-25T14:34:41.095433Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.004998207092285156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_data_quality__data_quality_test_summary_data_quality_check.dd0d557084", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom dev_thuxuan.data_quality.data_quality_test_summary\nwhere data_quality_check is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:41.098433Z", "completed_at": "2024-10-25T14:34:41.103433Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:41.104434Z", "completed_at": "2024-10-25T14:34:41.104434Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.008000373840332031, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_data_quality__data_quality_test_summary_data_quality_check.952b80bd98", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.data_quality.data_quality_test_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.752285Z", "completed_at": "2024-10-25T14:34:41.890458Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:41.894473Z", "completed_at": "2024-10-25T14:34:41.894473Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 1.244502305984497, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__combined_institutional_line_level", "compiled": true, "compiled_code": "\n\nWITH combine_line_models AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__pharmacy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing.service_category__pharmacy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_observation_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing._int_observation_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulance_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulance_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_lab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(20)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(11)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(52)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" \n\n from dev_thuxuan.claims_preprocessing._int_lab_institutional\n\n \n )\n\n \n)\n\nSELECT\n l.claim_id,\n l.claim_line_number,\n l.service_category_1,\n l.service_category_2,\n l.service_category_3,\n l.source_model_name\nFROM combine_line_models l", "relation_name": "dev_thuxuan.claims_preprocessing._int_combined_institutional_line_level"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.740249Z", "completed_at": "2024-10-25T14:34:43.206495Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:43.207495Z", "completed_at": "2024-10-25T14:34:43.207495Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 2.5593512058258057, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__combined_institutional_header_level", "compiled": true, "compiled_code": "\n\nWITH combine_header_models AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_other' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_other\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_maternity' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_maternity\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_med_surg' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_institutional_med_surg\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_dialysis_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_dialysis_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_emergency_department_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_emergency_department_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_home_health_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_home_health_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospice_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospice_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_urgent_care_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_urgent_care_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_rehab_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_rehab_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_institutional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_institutional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(10)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(29)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(29)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(59)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_institutional\n\n \n )\n\n \n)\n\nSELECT\n h.claim_id,\n h.service_category_1,\n h.service_category_2,\n h.service_category_3,\n h.source_model_name\nFROM combine_header_models h", "relation_name": "dev_thuxuan.claims_preprocessing._int_combined_institutional_header_level"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:40.819727Z", "completed_at": "2024-10-25T14:34:44.082149Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.083148Z", "completed_at": "2024-10-25T14:34:44.083148Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 3.353381395339966, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__combined_professional", "compiled": true, "compiled_code": "\n\nWITH combined_professional_services AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_acute_inpatient_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_acute_inpatient_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulatory_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_dialysis_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_dialysis_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_emergency_department_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_emergency_department_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_home_health_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_home_health_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_lab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_lab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_other_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_other_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_radiology' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_radiology\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__office_based_surgery_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_office_based_visit_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_office_based_visit_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospital_or_clinic_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_psychiatric_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_rehab_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_rehab_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_inpatient_skilled_nursing_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_urgent_care_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_urgent_care_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_outpatient_hospice_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_outpatient_hospice_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__pharmacy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_substance_use_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_physical_therapy_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_radiology_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_observation_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_observation_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_dme_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_dme_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing._int_ambulance_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(\"CLAIM_LINE_ID\" as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing._int_ambulance_professional\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_professional' as TEXT) as _dbt_source_relation,\n\n \n cast(\"CLAIM_ID\" as character varying(16777216)) as \"CLAIM_ID\" ,\n cast(\"CLAIM_LINE_NUMBER\" as NUMBER(38,0)) as \"CLAIM_LINE_NUMBER\" ,\n cast(null as character varying(16777216)) as \"CLAIM_LINE_ID\" ,\n cast(\"SERVICE_CATEGORY_1\" as character varying(12)) as \"SERVICE_CATEGORY_1\" ,\n cast(\"SERVICE_CATEGORY_2\" as character varying(16777216)) as \"SERVICE_CATEGORY_2\" ,\n cast(\"SERVICE_CATEGORY_3\" as character varying(16777216)) as \"SERVICE_CATEGORY_3\" ,\n cast(\"SOURCE_MODEL_NAME\" as character varying(60)) as \"SOURCE_MODEL_NAME\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.claims_preprocessing.service_category__outpatient_surgery_professional\n\n \n )\n\n \n)\n\nSELECT\n p.claim_id,\n p.claim_line_number,\n p.claim_line_id,\n p.service_category_1,\n p.service_category_2,\n p.service_category_3,\n p.tuva_last_run,\n p.source_model_name\nFROM combined_professional_services p", "relation_name": "dev_thuxuan.claims_preprocessing._int_combined_professional"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.176111Z", "completed_at": "2024-10-25T14:34:44.185216Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.185216Z", "completed_at": "2024-10-25T14:34:44.185216Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.010103702545166016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.service_category__service_category_grouper", "compiled": true, "compiled_code": "\n\nwith service_category_1_mapping as(\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , b.source_model_name\n from dev_thuxuan.test.service_category__stg_medical_claim a\n left join dev_thuxuan.claims_preprocessing._int_combined_professional b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join dev_thuxuan.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'professional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , b.source_model_name\n from dev_thuxuan.test.service_category__stg_medical_claim a\n left join dev_thuxuan.claims_preprocessing._int_combined_institutional_header_level b\n on a.claim_id = b.claim_id\n left join dev_thuxuan.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n\n union all\n\n select distinct \n a.claim_id\n , a.claim_line_number\n , a.claim_type\n , case when s.service_category_1 is null and b.service_category_1 is not null then 'Service cat value not in seed table'\n else b.service_category_1\n end service_category_1\n , case when s.service_category_2 is null and b.service_category_2 is not null then 'Service cat value not in seed table'\n else s.service_category_2\n end service_category_2\n , case\n when s.service_category_3 is null and b.service_category_3 is not null then 'Service cat value not in seed table'\n else s.service_category_3\n end service_category_3\n ,b.service_category_2 as original_service_cat_2\n ,b.service_category_3 as original_service_cat_3\n , s.priority\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n , b.source_model_name\n from dev_thuxuan.test.service_category__stg_medical_claim a\n left join dev_thuxuan.claims_preprocessing._int_combined_institutional_line_level b\n on a.claim_id = b.claim_id\n and a.claim_line_number = b.claim_line_number\n left join dev_thuxuan.claims_preprocessing.service_category__service_categories s on b.service_category_2 = s.service_category_2\n and\n b.service_category_3 = s.service_category_3\n where a.claim_type = 'institutional'\n)\n\n, service_category_2_deduplication as(\n select \n claim_id\n , claim_line_number\n , claim_type\n , service_category_1\n , service_category_2\n , service_category_3\n ,original_service_cat_2\n ,original_service_cat_3\n , source_model_name\n , row_number() over (partition by claim_id, claim_line_number order by priority) as duplicate_row_number\n from service_category_1_mapping\n)\n\nselect\n d.claim_id\n , d.claim_line_number\n , d.claim_type\n , coalesce(service_category_1,'other') as service_category_1\n , coalesce(service_category_2,'other') as service_category_2\n , coalesce(service_category_3,'other') as service_category_3\n , original_service_cat_2\n , original_service_cat_3\n , duplicate_row_number\n , s.ccs_category\n , s.ccs_category_description\n , s.ms_drg_code\n , s.ms_drg_description\n , s.place_of_service_code\n , s.place_of_service_description\n , s.revenue_center_code\n , s.revenue_center_description\n , s.hcpcs_code\n , s.default_ccsr_category_ip\n , s.default_ccsr_category_op\n , s.default_ccsr_category_description_ip\n , s.default_ccsr_category_description_op\n , s.primary_taxonomy_code\n , s.primary_specialty_description\n , s.modality\n , s.bill_type_code\n , s.bill_type_description\n , d.source_model_name\n , s.data_source\nfrom service_category_2_deduplication d\ninner join dev_thuxuan.test.service_category__stg_medical_claim s on d.claim_id = s.claim_id\nand\nd.claim_line_number = s.claim_line_number\n--where duplicate_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.service_category_grouper"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.187219Z", "completed_at": "2024-10-25T14:34:44.195215Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.195215Z", "completed_at": "2024-10-25T14:34:44.195215Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.009002685546875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__stg_medical_claim", "compiled": true, "compiled_code": "\n\n\nselect\n m.apr_drg_code\n , m.patient_id \n , d.patient_data_source_id\n , m.claim_id\n , m.claim_line_number\n , m.claim_id || '|' || cast(m.claim_line_number as TEXT) as claim_line_id\n , m.claim_type\n , coalesce(m.admission_date,m.claim_line_start_date,m.claim_start_date) as start_date\n , coalesce(m.discharge_date,m.claim_line_end_date,m.claim_end_date) as end_date\n , m.admission_date\n , m.discharge_date\n , m.claim_start_date\n , m.claim_end_date\n , m.claim_line_start_date\n , m.claim_line_end_date\n , g.service_category_1\n , g.service_category_2\n , g.service_category_3\n , m.bill_type_code\n , bt.bill_type_description\n , m.hcpcs_code\n , m.hcpcs_modifier_1\n , m.hcpcs_modifier_2\n , m.hcpcs_modifier_3\n , m.hcpcs_modifier_4\n , m.hcpcs_modifier_5\n , c.ccs_category\n , c.ccs_category_description\n , m.ms_drg_code\n , drg.ms_drg_description\n , m.admit_source_code\n , m.admit_type_code\n , m.place_of_service_code\n , pos.place_of_service_description\n , m.revenue_center_code\n , r.revenue_center_description\n , m.diagnosis_code_type\n , m.diagnosis_code_1\n , dx.default_ccsr_category_ip\n , dx.default_ccsr_category_op\n , dx.default_ccsr_category_description_ip\n , dx.default_ccsr_category_description_op\n , p.primary_taxonomy_code\n , p.primary_specialty_description\n , n.modality\n , m.billing_id\n , m.rendering_id\n , rend.primary_specialty_description as rend_primary_specialty_description\n , m.facility_id\n , m.discharge_disposition_code\n , m.paid_amount\n , m.charge_amount\n , m.allowed_amount\n , m.data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.service_category_grouper g on m.claim_id = g.claim_id\nand\nm.claim_line_number = g.claim_line_number\nand g.duplicate_row_number = 1\ninner join dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id d on m.patient_id = d.patient_id\nand\nm.data_source = d.data_source\nleft join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_cleaned_map dx on m.diagnosis_code_1 = dx.icd_10_cm_code\nleft join dev_thuxuan.terminology.provider p on m.facility_id = p.npi\nleft join dev_thuxuan.terminology.ccs_services_procedures c on m.hcpcs_code = c.hcpcs_code\nleft join dev_thuxuan.terminology.nitos n on m.hcpcs_code = n.hcpcs_code\nleft join dev_thuxuan.terminology.ms_drg drg on m.ms_drg_code = drg.ms_drg_code\nleft join dev_thuxuan.terminology.revenue_center r on m.revenue_center_code = r.revenue_center_code\nleft join dev_thuxuan.terminology.place_of_service pos on m.place_of_service_code = pos.place_of_service_code\nleft join dev_thuxuan.terminology.bill_type bt on m.bill_type_code = bt.bill_type_code\nleft join dev_thuxuan.terminology.provider rend on m.rendering_id = rend.npi", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.205213Z", "completed_at": "2024-10-25T14:34:44.217540Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.218539Z", "completed_at": "2024-10-25T14:34:44.218539Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020326614379882812, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulance' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.201215Z", "completed_at": "2024-10-25T14:34:44.217540Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.219542Z", "completed_at": "2024-10-25T14:34:44.219542Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022328615188598633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\nselect claim_id\n,patient_data_source_id\n,min(start_date) as start_date\n,max(end_date) as end_date \n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id\n ,patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id\n , enc.patient_data_source_id\n , c.start_date\n , c.end_date\n , enc.facility_id\n , enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c on enc.claim_id = c.claim_id\n and\n c.patient_data_source_id = enc.patient_data_source_id\n where\n service_category_2 in ('acute inpatient')\n and claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id\n , aa.claim_id as claim_id_a\n , bb.claim_id as claim_id_b\n , aa.row_num as row_num_a\n , bb.row_num as row_num_b\n , case\n -- Claims with same end_date and same facility_id should be merged:\n when aa.end_date = bb.end_date\n and aa.facility_id = bb.facility_id then 1\n\n -- Claims with different end_date and start_date that are\n -- adjacent (i.e. separated by 1 day) should be merged:\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n\n -- Claims with different end_date \n -- should be merged if they overlap:\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n where aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.208217Z", "completed_at": "2024-10-25T14:34:44.218539Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.220542Z", "completed_at": "2024-10-25T14:34:44.220542Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022329092025756836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n , end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'ambulatory surgery center' -- include both professional and institutional claims as anchor events\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.asc__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.212217Z", "completed_at": "2024-10-25T14:34:44.219542Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.221682Z", "completed_at": "2024-10-25T14:34:44.221682Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02246713638305664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'dialysis' --both inst and professional as anchor\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.225689Z", "completed_at": "2024-10-25T14:34:44.243562Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.244568Z", "completed_at": "2024-10-25T14:34:44.244568Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.021878957748413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'durable medical equipment' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.dme__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.231689Z", "completed_at": "2024-10-25T14:34:44.244568Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.246670Z", "completed_at": "2024-10-25T14:34:44.246670Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022980690002441406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'emergency department' --both inst and prof\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.235688Z", "completed_at": "2024-10-25T14:34:44.244568Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.246670Z", "completed_at": "2024-10-25T14:34:44.246670Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022980690002441406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'home health' -- both prof and inst as anchors\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.home_health__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.238690Z", "completed_at": "2024-10-25T14:34:44.245646Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.247656Z", "completed_at": "2024-10-25T14:34:44.247656Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022967100143432617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 in ('inpatient hospice')\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.252650Z", "completed_at": "2024-10-25T14:34:44.271368Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.274375Z", "completed_at": "2024-10-25T14:34:44.274375Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.024804115295410156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient psychiatric'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.256655Z", "completed_at": "2024-10-25T14:34:44.273375Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.275378Z", "completed_at": "2024-10-25T14:34:44.275378Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024713993072509766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient rehabilitation'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.263366Z", "completed_at": "2024-10-25T14:34:44.274375Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.277286Z", "completed_at": "2024-10-25T14:34:44.277286Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026622772216796875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'skilled nursing'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b, \n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.267367Z", "completed_at": "2024-10-25T14:34:44.275378Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.278292Z", "completed_at": "2024-10-25T14:34:44.278292Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026638031005859375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith claim_start_end as (\n select\n claim_id,\n patient_data_source_id,\n min(start_date) as start_date,\n max(end_date) as end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n group by claim_id, patient_data_source_id\n)\n\n, base as (\n select distinct\n enc.claim_id,\n enc.patient_data_source_id,\n c.start_date,\n c.end_date,\n enc.facility_id,\n enc.discharge_disposition_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim enc\n inner join claim_start_end c \n on enc.claim_id = c.claim_id\n and c.patient_data_source_id = enc.patient_data_source_id\n where\n enc.service_category_2 = 'inpatient substance use'\n and enc.claim_type = 'institutional'\n)\n\n, add_row_num as (\n select\n patient_data_source_id,\n claim_id,\n start_date,\n end_date,\n discharge_disposition_code,\n facility_id,\n row_number() over (partition by patient_data_source_id order by end_date, start_date, claim_id) as row_num\n from base\n)\n\n, check_for_merges_with_larger_row_num as (\n select\n aa.patient_data_source_id,\n aa.claim_id as claim_id_a,\n bb.claim_id as claim_id_b,\n aa.row_num as row_num_a,\n bb.row_num as row_num_b,\n case\n when aa.end_date = bb.end_date and aa.facility_id = bb.facility_id then 1\n when \n\n dateadd(\n day,\n 1,\n aa.end_date\n )\n\n = bb.start_date\n and aa.facility_id = bb.facility_id\n and aa.discharge_disposition_code = '30' then 1\n when aa.end_date <> bb.end_date\n and aa.end_date >= bb.start_date\n and aa.facility_id = bb.facility_id then 1\n else 0\n end as merge_flag\n from add_row_num as aa\n inner join add_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num < bb.row_num\n and aa.claim_id <> bb.claim_id\n)\n\n\n, merges_with_larger_row_num as (\n select\n patient_data_source_id\n , claim_id_a\n , claim_id_b\n , row_num_a\n , row_num_b\n , merge_flag\n from check_for_merges_with_larger_row_num\n where merge_flag = 1\n)\n\n, claim_ids_that_merge_with_larger_row_num as (\n select distinct\n claim_id_a as claim_id\n from merges_with_larger_row_num\n)\n\n, claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as (\n select distinct\n aa.claim_id as claim_id\n from add_row_num as aa\n inner join merges_with_larger_row_num as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and bb.row_num_a < aa.row_num\n and bb.row_num_b > aa.row_num\n)\n\n, close_flags as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , case\n when bb.claim_id is null\n and cc.claim_id is null then 1\n else 0\n end as close_flag\n from add_row_num as aa\n left join claim_ids_that_merge_with_larger_row_num as bb\n on aa.claim_id = bb.claim_id\n left join claim_ids_having_a_smaller_row_num_merging_with_a_larger_row_num as cc\n on aa.claim_id = cc.claim_id\n)\n\n, join_every_row_to_later_closes as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.row_num\n , bb.row_num as row_num_b\n from close_flags as aa\n inner join close_flags as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.row_num <= bb.row_num\n where bb.close_flag = 1\n)\n\n, find_min_closing_row_num_for_every_claim as (\n select\n patient_data_source_id\n , claim_id\n , min(row_num_b) as min_closing_row\n from join_every_row_to_later_closes\n group by\n patient_data_source_id\n , claim_id\n)\n\n, add_min_closing_row_to_every_claim as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , bb.min_closing_row\n from close_flags as aa\n left join find_min_closing_row_num_for_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.claim_id = bb.claim_id\n)\n\n, add_encounter_id as (\n select\n aa.patient_data_source_id\n , aa.claim_id\n , aa.start_date\n , aa.end_date\n , aa.discharge_disposition_code\n , aa.facility_id\n , aa.row_num\n , aa.close_flag\n , aa.min_closing_row\n , bb.claim_id as encounter_id\n from add_min_closing_row_to_every_claim as aa\n left join add_min_closing_row_to_every_claim as bb\n on aa.patient_data_source_id = bb.patient_data_source_id\n and aa.min_closing_row = bb.row_num\n)\n\nselect\n patient_data_source_id\n , claim_id\n , start_date\n , end_date\n , discharge_disposition_code\n , facility_id\n , row_number() over (partition by encounter_id order by start_date, end_date, claim_id) as encounter_claim_number\n , row_number() over (partition by encounter_id order by start_date desc, end_date desc, claim_id desc) as encounter_claim_number_desc\n , close_flag\n , min_closing_row\n , dense_rank() over (order by encounter_id) as encounter_id\nfrom add_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.284369Z", "completed_at": "2024-10-25T14:34:44.301374Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.303286Z", "completed_at": "2024-10-25T14:34:44.303286Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02191638946533203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'lab' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.lab__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.289369Z", "completed_at": "2024-10-25T14:34:44.302364Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.304369Z", "completed_at": "2024-10-25T14:34:44.304369Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02198052406311035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits", "compiled": true, "compiled_code": "\n\nwith anchor as (\n select distinct\n mc.patient_data_source_id\n , mc.start_date\n , mc.claim_id\n , mc.claim_line_number\n , mc.service_category_1\n , mc.service_category_2\n , mc.service_category_3\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as mc\n inner join dev_thuxuan.claims_preprocessing._int_combined_professional as p -- joining in all sc regardless of final priority\n on mc.claim_id = p.claim_id\n and mc.claim_line_number = p.claim_line_number\n where p.service_category_1 = 'office-based'\n)\n\nselect\n patient_data_source_id\n , start_date\n , claim_id\n , claim_line_number\n , service_category_1\n , service_category_2\n , service_category_3\n , dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.292371Z", "completed_at": "2024-10-25T14:34:44.302364Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.304369Z", "completed_at": "2024-10-25T14:34:44.304369Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021003007888793945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient hospice' --both inst and prof\n \n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.296369Z", "completed_at": "2024-10-25T14:34:44.303286Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.305378Z", "completed_at": "2024-10-25T14:34:44.306287Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022921085357666016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where \n service_category_2 in (\n 'outpatient hospital or clinic' -- both prof and inst\n , 'observation' -- orphaned obs that didn't roll up to other encounter\n )\n)\n\nselect distinct \n claim_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.311382Z", "completed_at": "2024-10-25T14:34:44.331289Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.333368Z", "completed_at": "2024-10-25T14:34:44.333368Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.026017427444458008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__anchor_events", "compiled": true, "compiled_code": "\n\nwith multiple_sources as \n(\nselect distinct\n med.patient_data_source_id\n ,med.start_date\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_outpatient_institutional outpatient\n on med.claim_id = outpatient.claim_id\nwhere substring(med.hcpcs_code,1,1) = 'J'\n)\n\n\nselect distinct \n patient_data_source_id\n ,start_date\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom multiple_sources", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.315367Z", "completed_at": "2024-10-25T14:34:44.332388Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.334322Z", "completed_at": "2024-10-25T14:34:44.334322Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025958776473999023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient psychiatric' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.318370Z", "completed_at": "2024-10-25T14:34:44.332388Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.335342Z", "completed_at": "2024-10-25T14:34:44.335342Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025968074798583984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient pt/ot/st' --both inst and prof as anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.322369Z", "completed_at": "2024-10-25T14:34:44.334322Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.337288Z", "completed_at": "2024-10-25T14:34:44.337288Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.027914047241210938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n patient_data_source_id\n , start_date\n , hcpcs_code\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient radiology' --both professional and inst\n)\n\nselect distinct \n patient_data_source_id\n , start_date\n , hcpcs_code\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.342286Z", "completed_at": "2024-10-25T14:34:44.360132Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.361209Z", "completed_at": "2024-10-25T14:34:44.361209Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02291250228881836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient rehabilitation'\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.348458Z", "completed_at": "2024-10-25T14:34:44.361209Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.363549Z", "completed_at": "2024-10-25T14:34:44.363549Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02525162696838379, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 = 'outpatient substance use'\n and claim_type = 'institutional'\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.353459Z", "completed_at": "2024-10-25T14:34:44.362735Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.365562Z", "completed_at": "2024-10-25T14:34:44.365562Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.025264263153076172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__anchor_events", "compiled": true, "compiled_code": "\n\nwith service_category as (\n select distinct\n claim_id\n , patient_data_source_id\n , start_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('outpatient surgery') --both inst and prof anchor\n)\n\nselect distinct \nclaim_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_category", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.357379Z", "completed_at": "2024-10-25T14:34:44.362735Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.366569Z", "completed_at": "2024-10-25T14:34:44.366569Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025283098220825195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__anchor_events", "compiled": true, "compiled_code": "\n\n select distinct\n claim_id\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim\n where\n service_category_2 in ('urgent care') --both inst and prof anchor", "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__anchor_events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.375317Z", "completed_at": "2024-10-25T14:34:44.395325Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.397316Z", "completed_at": "2024-10-25T14:34:44.397316Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.028116226196289062, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.ambulance__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.380357Z", "completed_at": "2024-10-25T14:34:44.396338Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.398405Z", "completed_at": "2024-10-25T14:34:44.398405Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02709650993347168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.385319Z", "completed_at": "2024-10-25T14:34:44.397316Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.399401Z", "completed_at": "2024-10-25T14:34:44.399401Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027083635330200195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith base_data as (\n select distinct\n m.patient_data_source_id\n , m.start_date\n , m.end_date\n , m.claim_id\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as m\n inner join dev_thuxuan.claims_preprocessing.asc__anchor_events as u\n on m.claim_id = u.claim_id\n)\n\n-- Determine Previous Maximum End Date\n, grouped_data as (\n select\n bd.*\n , max(end_date) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows between unbounded preceding and 1 preceding\n ) as previous_max_end_date\n from base_data as bd\n)\n\n-- Flag New Encounter Groups\n, flagged_data as (\n select\n gd.*\n , case \n when start_date > coalesce(previous_max_end_date, '1900-01-01') then 1 \n else 0 \n end as new_group_flag\n from grouped_data as gd\n)\n\n-- Assign Encounter Groups per Patient\n, numbered_data as (\n select\n fd.*\n , sum(new_group_flag) over (\n partition by patient_data_source_id \n order by start_date, claim_id \n rows unbounded preceding\n ) as encounter_group\n from flagged_data as fd\n)\n\n-- Identify Unique Encounters\n, unique_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , min(start_date) as encounter_start_date\n from numbered_data\n group by\n patient_data_source_id\n , encounter_group\n)\n\n-- Assign asc encounter_id\n, numbered_encounters as (\n select\n patient_data_source_id\n , encounter_group\n , row_number() over (\n order by patient_data_source_id, encounter_start_date\n ) as encounter_id\n from unique_encounters\n)\n\n-- Merge Encounters with Claims\nselect\n nd.patient_data_source_id\n , nd.start_date\n , nd.end_date\n , nd.claim_id\n , ne.encounter_id as old_encounter_id\nfrom numbered_data as nd\ninner join numbered_encounters as ne\n on nd.patient_data_source_id = ne.patient_data_source_id\n and nd.encounter_group = ne.encounter_group", "relation_name": "dev_thuxuan.claims_preprocessing.asc__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.391315Z", "completed_at": "2024-10-25T14:34:44.398405Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.400317Z", "completed_at": "2024-10-25T14:34:44.400317Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.027999162673950195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dialysis__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.407355Z", "completed_at": "2024-10-25T14:34:44.423773Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.425720Z", "completed_at": "2024-10-25T14:34:44.425720Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022307634353637695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dme__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.dme__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.411220Z", "completed_at": "2024-10-25T14:34:44.424684Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.426684Z", "completed_at": "2024-10-25T14:34:44.426684Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022367238998413086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.416235Z", "completed_at": "2024-10-25T14:34:44.424684Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.427530Z", "completed_at": "2024-10-25T14:34:44.427530Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022214412689208984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.home_health__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.home_health__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.419673Z", "completed_at": "2024-10-25T14:34:44.425720Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.428190Z", "completed_at": "2024-10-25T14:34:44.428190Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02287459373474121, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.434253Z", "completed_at": "2024-10-25T14:34:44.449858Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.450865Z", "completed_at": "2024-10-25T14:34:44.450865Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020624160766601562, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.437343Z", "completed_at": "2024-10-25T14:34:44.449858Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.451863Z", "completed_at": "2024-10-25T14:34:44.451863Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.021619319915771484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.440374Z", "completed_at": "2024-10-25T14:34:44.450865Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.452864Z", "completed_at": "2024-10-25T14:34:44.452864Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021619319915771484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.444518Z", "completed_at": "2024-10-25T14:34:44.451863Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.454284Z", "completed_at": "2024-10-25T14:34:44.454284Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022088289260864258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__start_end_dates", "compiled": true, "compiled_code": "\n\nselect encounter_id \n, min(start_date) as encounter_start_date\n, max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id\ngroup by encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.461564Z", "completed_at": "2024-10-25T14:34:44.479149Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.481922Z", "completed_at": "2024-10-25T14:34:44.481922Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02588963508605957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.lab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.lab__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.465758Z", "completed_at": "2024-10-25T14:34:44.480926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.483571Z", "completed_at": "2024-10-25T14:34:44.483571Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.026517391204833984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_em", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based visit'", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_em"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.471627Z", "completed_at": "2024-10-25T14:34:44.481922Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.483571Z", "completed_at": "2024-10-25T14:34:44.483571Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026517391204833984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_injections", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\nwhere substring(hcpcs_code,1,1) = 'J'", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_injections"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.476050Z", "completed_at": "2024-10-25T14:34:44.482951Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.484643Z", "completed_at": "2024-10-25T14:34:44.484643Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02507925033569336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_ptotst", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based pt/ot/st'", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_ptotst"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.489581Z", "completed_at": "2024-10-25T14:34:44.621414Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.627691Z", "completed_at": "2024-10-25T14:34:44.627691Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.1411116123199463, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_radiology", "compiled": true, "compiled_code": "\n\nwith max_encounter as (\n select max(old_encounter_id) as max_encounter_id\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits\n)\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,mc.hcpcs_code\n ,dense_rank() over (order by ov.patient_data_source_id, ov.start_date, mc.hcpcs_code) + mx.max_encounter_id as old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\ncross join max_encounter mx\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim mc on mc.claim_id = ov.claim_id\n and mc.claim_line_number = ov.claim_line_number\ninner join dev_thuxuan.claims_preprocessing.service_category__office_based_radiology scrad on mc.claim_id = scrad.claim_id\n and mc.claim_line_number = scrad.claim_line_number", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_radiology"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.494581Z", "completed_at": "2024-10-25T14:34:44.624043Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.627691Z", "completed_at": "2024-10-25T14:34:44.627691Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.14011168479919434, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_surgery", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'office-based surgery'", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_surgery"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.502577Z", "completed_at": "2024-10-25T14:34:44.626716Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.628730Z", "completed_at": "2024-10-25T14:34:44.628730Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.14014697074890137, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospice__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.497577Z", "completed_at": "2024-10-25T14:34:44.626716Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.629701Z", "completed_at": "2024-10-25T14:34:44.629701Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.1421215534210205, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_telehealth", "compiled": true, "compiled_code": "\n\nselect distinct\n ov.patient_data_source_id\n ,ov.start_date\n ,ov.claim_id\n ,ov.claim_line_number\n ,ov.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits ov\nwhere service_category_2 = 'telehealth visit'", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_telehealth"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.636707Z", "completed_at": "2024-10-25T14:34:44.649784Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.652049Z", "completed_at": "2024-10-25T14:34:44.652049Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018346548080444336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.640713Z", "completed_at": "2024-10-25T14:34:44.650793Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.653078Z", "completed_at": "2024-10-25T14:34:44.653078Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019374847412109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__generate_encounter_id", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.outpatient_injections__anchor_events", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.643793Z", "completed_at": "2024-10-25T14:34:44.652049Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.654074Z", "completed_at": "2024-10-25T14:34:44.654074Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01935267448425293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_psych__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.646786Z", "completed_at": "2024-10-25T14:34:44.653078Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.655074Z", "completed_at": "2024-10-25T14:34:44.655074Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02035236358642578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_ptotst__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.658578Z", "completed_at": "2024-10-25T14:34:44.671587Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.675424Z", "completed_at": "2024-10-25T14:34:44.675424Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.019348859786987305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__generate_encounter_id", "compiled": true, "compiled_code": "\n\nselect patient_data_source_id\n,start_date\n,hcpcs_code\n,dense_rank() over (order by patient_data_source_id, start_date, hcpcs_code) as old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.outpatient_radiology__anchor_events", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.663584Z", "completed_at": "2024-10-25T14:34:44.675424Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.676496Z", "completed_at": "2024-10-25T14:34:44.676496Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.019422292709350586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_rehab__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.668583Z", "completed_at": "2024-10-25T14:34:44.676496Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.678519Z", "completed_at": "2024-10-25T14:34:44.678519Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021445274353027344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__generate_encounter_id", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_substance_use__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.671587Z", "completed_at": "2024-10-25T14:34:44.677518Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.679552Z", "completed_at": "2024-10-25T14:34:44.679552Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020973920822143555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__generate_encounter_id", "compiled": true, "compiled_code": "\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_surgery__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.683532Z", "completed_at": "2024-10-25T14:34:44.695484Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.699436Z", "completed_at": "2024-10-25T14:34:44.699436Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.019883394241333008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__generate_encounter_id", "compiled": true, "compiled_code": "\n\nwith anchor as \n(\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.urgent_care__anchor_events u on m.claim_id = u.claim_id\n)\n\nselect patient_data_source_id\n,start_date\n,claim_id\n,dense_rank() over (order by patient_data_source_id, start_date) as old_encounter_id\nfrom anchor", "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__generate_encounter_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.686515Z", "completed_at": "2024-10-25T14:34:44.699436Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.701128Z", "completed_at": "2024-10-25T14:34:44.701128Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020610570907592773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.ambulance__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'ambulance'", "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.691525Z", "completed_at": "2024-10-25T14:34:44.700494Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.702151Z", "completed_at": "2024-10-25T14:34:44.702151Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.019635915756225586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.695484Z", "completed_at": "2024-10-25T14:34:44.701128Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.703153Z", "completed_at": "2024-10-25T14:34:44.703153Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019620895385742188, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__start_end_dates", "compiled": true, "compiled_code": "\n\nselect\n patient_data_source_id\n , old_encounter_id\n , min(start_date) as encounter_start_date\n , max(end_date) as encounter_end_date\nfrom dev_thuxuan.claims_preprocessing.asc__generate_encounter_id\ngroup by\n patient_data_source_id\n , old_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.asc__start_end_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.710150Z", "completed_at": "2024-10-25T14:34:44.722153Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.729151Z", "completed_at": "2024-10-25T14:34:44.729151Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02499842643737793, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dialysis__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.714150Z", "completed_at": "2024-10-25T14:34:44.728153Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.730150Z", "completed_at": "2024-10-25T14:34:44.730150Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.026999950408935547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.dme__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'durable medical equipment'", "relation_name": "dev_thuxuan.claims_preprocessing.dme__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.718152Z", "completed_at": "2024-10-25T14:34:44.730150Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.732151Z", "completed_at": "2024-10-25T14:34:44.732151Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.024999141693115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n\n-- ensuring each claim is only attributed to one encounter with claim_attribution_number\n,inst_and_prof as (\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date\n\nunion all \n\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,med.claim_id\n,med.claim_line_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_outpatient_institutional inst on med.claim_id = inst.claim_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date \nwhere dat.claim_id <> med.claim_id\n)\n\nselect distinct encounter_id\n,encounter_start_date\n,encounter_end_date\n,claim_id\n,claim_line_number\n,row_number () over (partition by claim_id ,claim_line_number order by encounter_id) as claim_attribution_number\nfrom inst_and_prof", "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.723152Z", "completed_at": "2024-10-25T14:34:44.731152Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.733151Z", "completed_at": "2024-10-25T14:34:44.733151Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.023998022079467773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.home_health__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.home_health__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.737149Z", "completed_at": "2024-10-25T14:34:44.750155Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.756052Z", "completed_at": "2024-10-25T14:34:44.756052Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.022900819778442383, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n, join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.741150Z", "completed_at": "2024-10-25T14:34:44.751155Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.757064Z", "completed_at": "2024-10-25T14:34:44.757064Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022914409637451172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.746154Z", "completed_at": "2024-10-25T14:34:44.757064Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.759575Z", "completed_at": "2024-10-25T14:34:44.759575Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.024425268173217773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.751155Z", "completed_at": "2024-10-25T14:34:44.758569Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.761615Z", "completed_at": "2024-10-25T14:34:44.761615Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02546525001525879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.765527Z", "completed_at": "2024-10-25T14:34:44.784539Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.789459Z", "completed_at": "2024-10-25T14:34:44.789459Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.028873205184936523, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__prof_claims", "compiled": true, "compiled_code": "\n\nwith first_claim as (\n select *\n from dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id\n where encounter_claim_number = 1\n)\n\n,join_first_claim_dates as (\n select f.*\n ,dat.encounter_end_date\n ,dat.encounter_start_date\n from first_claim f \n inner join dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates dat on f.encounter_id = dat.encounter_id\n)\n\n-- ensuring each prof claim is only attributed to one institutional claim with claim_attribution_number\nselect dat.encounter_id\n,dat.encounter_start_date\n,dat.encounter_end_date\n,prof.claim_id\n,prof.claim_line_number\n-- ,med.start_date\n-- ,med.end_date\n-- ,med.place_of_service_code\n-- ,med.place_of_service_description\n,row_number () over (partition by prof.claim_line_id order by dat.encounter_id) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_professional prof on med.claim_line_id = prof.claim_line_id\ninner join join_first_claim_dates dat on med.patient_data_source_id = dat.patient_data_source_id\nand med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__prof_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.770522Z", "completed_at": "2024-10-25T14:34:44.788706Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.790479Z", "completed_at": "2024-10-25T14:34:44.790479Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02757120132446289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.lab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nwhere m.service_category_2 = 'lab'", "relation_name": "dev_thuxuan.claims_preprocessing.lab__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.776530Z", "completed_at": "2024-10-25T14:34:44.790479Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.792478Z", "completed_at": "2024-10-25T14:34:44.792478Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.027942419052124023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_union", "compiled": true, "compiled_code": "\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit radiology' as encounter_type\n,0 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_radiology\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit surgery' as encounter_type\n,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_surgery\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit injections' as encounter_type\n,2 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_injections\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit pt/ot/st' as encounter_type\n,3 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_ptotst\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit' as encounter_type\n,4 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_em\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'telehealth' as encounter_type\n,5 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n\nunion distinct\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'office visit - other' as encounter_type\n,9999 as priority_number\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_union"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.785597Z", "completed_at": "2024-10-25T14:34:44.791479Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.793661Z", "completed_at": "2024-10-25T14:34:44.793661Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02413773536682129, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospice__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.797674Z", "completed_at": "2024-10-25T14:34:44.811375Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.816909Z", "completed_at": "2024-10-25T14:34:44.816909Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.024164915084838867, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.801674Z", "completed_at": "2024-10-25T14:34:44.814932Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.817826Z", "completed_at": "2024-10-25T14:34:44.817826Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02414846420288086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_injections__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.804691Z", "completed_at": "2024-10-25T14:34:44.816909Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.819397Z", "completed_at": "2024-10-25T14:34:44.819397Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.023700952529907227, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_psych__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.811803Z", "completed_at": "2024-10-25T14:34:44.819397Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.821416Z", "completed_at": "2024-10-25T14:34:44.821416Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024741649627685547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_ptotst__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.827416Z", "completed_at": "2024-10-25T14:34:44.842705Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.843712Z", "completed_at": "2024-10-25T14:34:44.843712Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.020295381546020508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , m.hcpcs_code\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_radiology__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date\nand\nm.hcpcs_code = u.hcpcs_code", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.830419Z", "completed_at": "2024-10-25T14:34:44.842705Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.844718Z", "completed_at": "2024-10-25T14:34:44.844718Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02129840850830078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_rehab__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.834439Z", "completed_at": "2024-10-25T14:34:44.844718Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.846776Z", "completed_at": "2024-10-25T14:34:44.846776Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021358728408813477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_substance_use__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.838416Z", "completed_at": "2024-10-25T14:34:44.844718Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.847520Z", "completed_at": "2024-10-25T14:34:44.847520Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0211026668548584, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.outpatient_surgery__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.851176Z", "completed_at": "2024-10-25T14:34:44.864188Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.865377Z", "completed_at": "2024-10-25T14:34:44.865377Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.01721787452697754, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect distinct m.patient_data_source_id\n , m.start_date\n , m.claim_id\n , m.claim_line_number\n , u.old_encounter_id\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim m\ninner join dev_thuxuan.claims_preprocessing.urgent_care__generate_encounter_id u on m.patient_data_source_id = u.patient_data_source_id\nand\nm.start_date = u.start_date", "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.857184Z", "completed_at": "2024-10-25T14:34:44.864188Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.866046Z", "completed_at": "2024-10-25T14:34:44.866046Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.016868114471435547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__match_claims_to_anchor", "compiled": true, "compiled_code": "\n\nselect\n dat.old_encounter_id\n , dat.encounter_start_date\n , dat.encounter_end_date\n , med.claim_id\n , med.claim_line_number\n , row_number() over (\n partition by med.claim_id, med.claim_line_number\n order by dat.old_encounter_id\n ) as claim_attribution_number\nfrom dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as med\ninner join dev_thuxuan.claims_preprocessing.asc__start_end_dates as dat\n on med.patient_data_source_id = dat.patient_data_source_id\n and med.start_date between dat.encounter_start_date and dat.encounter_end_date", "relation_name": "dev_thuxuan.claims_preprocessing.asc__match_claims_to_anchor"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.859733Z", "completed_at": "2024-10-25T14:34:44.866046Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.867078Z", "completed_at": "2024-10-25T14:34:44.867078Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01690053939819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_encounter_ranking", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,dist_encounter as (\nselect distinct old_encounter_id\n,encounter_type\n,priority_number\nfrom rank_cte\n)\n\nselect \nold_encounter_id\n,encounter_type\n,priority_number\n,row_number() over (partition by old_encounter_id order by priority_number) as relative_rank\nfrom dist_encounter", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_encounter_ranking"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.869057Z", "completed_at": "2024-10-25T14:34:44.873057Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.873057Z", "completed_at": "2024-10-25T14:34:44.873057Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.004998445510864258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visits__int_office_visits_claim_line", "compiled": true, "compiled_code": "\n\nwith rank_cte as (\nselect *\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_union\n)\n\n,crosswalk_cte as (\nselect old_encounter_id\n,encounter_type\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_encounter_ranking\nwhere relative_rank = 1\n)\n\nselect r.claim_id\n, r.claim_line_number\n, r.old_encounter_id\n, x.encounter_type\nfrom rank_cte r\ninner join crosswalk_cte x on r.old_encounter_id = x.old_encounter_id", "relation_name": "dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_claim_line"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.875059Z", "completed_at": "2024-10-25T14:34:44.885058Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.885058Z", "completed_at": "2024-10-25T14:34:44.885058Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.011978626251220703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__combined_claim_line_crosswalk", "compiled": true, "compiled_code": "\n\nwith cte as \n(\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'acute inpatient' as encounter_type\n ,'inpatient' as encounter_group\n ,0 as priority_number\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'acute inpatient' as encounter_type\n,'inpatient' as encounter_group\n,0 as priority_number\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'emergency department' as encounter_type\n,'outpatient' as encounter_group\n,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.emergency_department__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n ,claim_line_number\n ,encounter_id\n ,'emergency department' as encounter_type\n ,'outpatient' as encounter_group\n ,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.emergency_department__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient hospice' as encounter_type\n,'inpatient' as encounter_group\n,1 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_hospice__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__prof_claims\nwhere claim_attribution_number = 1\n\nunion all\n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient psych' as encounter_type\n,'inpatient' as encounter_group\n,2 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient rehabilitation' as encounter_type\n,'inpatient' as encounter_group\n,3 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient skilled nursing' as encounter_type\n,'inpatient' as encounter_group\n,4 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__prof_claims\nwhere claim_attribution_number = 1\n\nunion all \n\nselect enc.claim_id\n,med.claim_line_number\n,enc.encounter_id\n,'inpatient substance use' as encounter_type\n,'inpatient' as encounter_group\n,5 as priority_number\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__generate_encounter_id enc\ninner join dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim med on enc.claim_id = med.claim_id\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,9 as priority_number --priority set in combined office visit encounter ranking model\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type = 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,encounter_type\n,'office based' as encounter_group\n,10 as priority_number --priority set in combined office visit encounter ranking model\nfrom dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_claim_line\nwhere encounter_type <> 'office visit radiology'\n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'urgent care' as encounter_type\n,'outpatient' as encounter_group\n,11 as priority_number --urgent care needs to be lower than ed and inpatient\nfrom dev_thuxuan.claims_preprocessing.urgent_care__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient psych' as encounter_type\n,'outpatient' as encounter_group\n,12 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_psych__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient rehabilitation' as encounter_type\n,'outpatient' as encounter_group\n,13 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_rehab__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulatory surgery center' as encounter_type\n,'outpatient' as encounter_group\n,14 as priority_number \nfrom dev_thuxuan.claims_preprocessing.asc__match_claims_to_anchor\n\nunion all\n\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospital or clinic' as encounter_type\n,'outpatient' as encounter_group\n,999 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__match_claims_to_anchor --lowest outpatient priority, roll up to more specific encounter type when available\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient surgery' as encounter_type\n,'outpatient' as encounter_group\n,18 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_surgery__match_claims_to_anchor \n\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dialysis' as encounter_type\n,'outpatient' as encounter_group\n,15 as priority_number \nfrom dev_thuxuan.claims_preprocessing.dialysis__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient hospice' as encounter_type\n,'outpatient' as encounter_group\n,16 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_hospice__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'home health' as encounter_type\n,'outpatient' as encounter_group\n,17 as priority_number \nfrom dev_thuxuan.claims_preprocessing.home_health__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient injections' as encounter_type\n,'outpatient' as encounter_group\n,19 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_injections__match_claims_to_anchor\n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient pt/ot/st' as encounter_type\n,'outpatient' as encounter_group\n,20 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_ptotst__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient substance use' as encounter_type\n,'outpatient' as encounter_group\n,21 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_substance_use__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'outpatient radiology' as encounter_type\n,'outpatient' as encounter_group\n,22 as priority_number \nfrom dev_thuxuan.claims_preprocessing.outpatient_radiology__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'lab - orphaned' as encounter_type\n,'other' as encounter_group\n,1000000 as priority_number \nfrom dev_thuxuan.claims_preprocessing.lab__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'dme - orphaned' as encounter_type\n,'other' as encounter_group\n,1000001 as priority_number \nfrom dev_thuxuan.claims_preprocessing.dme__match_claims_to_anchor \n\nunion all\n\nselect claim_id\n,claim_line_number\n,old_encounter_id\n,'ambulance - orphaned' as encounter_type\n,'other' as encounter_group\n,1000002 as priority_number \nfrom dev_thuxuan.claims_preprocessing.ambulance__match_claims_to_anchor \n\n)\n\n\nselect \n claim_id\n, claim_line_number\n, encounter_id as old_encounter_id\n, dense_rank() over (order by encounter_type, encounter_id) as encounter_id\n, encounter_type\n, encounter_group\n, priority_number\n, row_number() over (partition by claim_id , claim_line_number order by priority_number) as claim_line_attribution_number\nfrom cte", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.892441Z", "completed_at": "2024-10-25T14:34:44.933599Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.936502Z", "completed_at": "2024-10-25T14:34:44.936502Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.047876596450805664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.acute_inpatient__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'acute inpatient'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when d.service_category_3 in ( 'l/d - cesarean delivery', 'l/d - vaginal delivery') then 1 else 0 end ) as delivery_flag\n ,max(case when d.service_category_3 ='l/d - cesarean delivery' then 1 else 0 end ) as cesarean_delivery\n ,max(case when d.service_category_3 ='l/d - vaginal delivery' then 1 else 0 end ) as vaginal_delivery\n ,max(case when d.service_category_3 in ('l/d - newborn','l/d - newborn nicu') then 1 else 0 end ) as newborn_flag\n ,max(case when d.service_category_3 ='l/d - newborn nicu' then 1 else 0 end ) as nicu_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n,encounter_group\n)\n\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, sc.observation_flag\n, sc.ed_flag\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.delivery_flag\n, case when sc.cesarean_delivery = 1 then 'cesarean'\n when sc.vaginal_delivery = 1 then 'vaginal'\n else null end as delivery_type\n, sc.newborn_flag\n, sc.nicu_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.acute_inpatient__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.acute_inpatient__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.902441Z", "completed_at": "2024-10-25T14:34:44.934500Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.936502Z", "completed_at": "2024-10-25T14:34:44.936502Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.047075748443603516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ambulance__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.ambulance__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulance - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type -- not changing grain, but bringing into final\n, encounter_group\n\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.ambulance__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.908440Z", "completed_at": "2024-10-25T14:34:44.935533Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.937499Z", "completed_at": "2024-10-25T14:34:44.937499Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04807257652282715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.asc__encounter_grain", "compiled": true, "compiled_code": "\n\n\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,ed.encounter_start_date \n ,ed.encounter_end_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'ambulatory surgery center'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.asc__start_end_dates ed on cli.old_encounter_id = ed.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, datediff(\n day,\n d.encounter_start_date,\n d.encounter_end_date\n ) as length_of_stay\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.asc__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.915441Z", "completed_at": "2024-10-25T14:34:44.935533Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.938498Z", "completed_at": "2024-10-25T14:34:44.938498Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.048038482666015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_condition", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the condition table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_1 as source_code\n , 1 as diagnosis_rank\n , diagnosis_poa_1 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere diagnosis_code_1 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n\t , discharge_date\n\t , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_2 as source_code\n , 2 as diagnosis_rank\n , diagnosis_poa_2 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_2 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_3 as source_code\n , 3 as diagnosis_rank\n , diagnosis_poa_3 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_3 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_4 as source_code\n , 4 as diagnosis_rank\n , diagnosis_poa_4 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_4 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_5 as source_code\n , 5 as diagnosis_rank\n , diagnosis_poa_5 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_5 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_6 as source_code\n , 6 as diagnosis_rank\n , diagnosis_poa_6 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_6 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_7 as source_code\n , 7 as diagnosis_rank\n , diagnosis_poa_7 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_7 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_8 as source_code\n , 8 as diagnosis_rank\n , diagnosis_poa_8 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_8 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_9 as source_code\n , 9 as diagnosis_rank\n , diagnosis_poa_9 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_9 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_10 as source_code\n , 10 as diagnosis_rank\n , diagnosis_poa_10 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_10 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_11 as source_code\n , 11 as diagnosis_rank\n , diagnosis_poa_11 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_11 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_12 as source_code\n , 12 as diagnosis_rank\n , diagnosis_poa_12 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_12 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_13 as source_code\n , 13 as diagnosis_rank\n , diagnosis_poa_13 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_13 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_14 as source_code\n , 14 as diagnosis_rank\n , diagnosis_poa_14 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_14 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_15 as source_code\n , 15 as diagnosis_rank\n , diagnosis_poa_15 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_15 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_16 as source_code\n , 16 as diagnosis_rank\n , diagnosis_poa_16 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_16 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_17 as source_code\n , 17 as diagnosis_rank\n , diagnosis_poa_17 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_17 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_18 as source_code\n , 18 as diagnosis_rank\n , diagnosis_poa_18 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_18 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_19 as source_code\n , 19 as diagnosis_rank\n , diagnosis_poa_19 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_19 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_20 as source_code\n , 20 as diagnosis_rank\n , diagnosis_poa_20 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_20 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_21 as source_code\n , 21 as diagnosis_rank\n , diagnosis_poa_21 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_21 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_22 as source_code\n , 22 as diagnosis_rank\n , diagnosis_poa_22 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_22 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_23 as source_code\n , 23 as diagnosis_rank\n , diagnosis_poa_23 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_23 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_24 as source_code\n , 24 as diagnosis_rank\n , diagnosis_poa_24 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_24 is not null\n\nunion all \n\nselect\n claim_id\n , claim_line_number\n , patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as recorded_date\n , 'discharge_diagnosis' as condition_type\n , diagnosis_code_type as source_code_type\n , diagnosis_code_25 as source_code\n , 25 as diagnosis_rank\n , diagnosis_poa_25 as present_on_admit_code\n , data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere diagnosis_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(CAST(unpivot_cte.data_source AS TEXT) || '_' || CAST(unpivot_cte.claim_id AS TEXT) || '_' || CAST(unpivot_cte.diagnosis_rank AS TEXT) || '_' || CAST(unpivot_cte.source_code AS TEXT) as TEXT)\n as condition_id\n\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.recorded_date as date ) as recorded_date\n , try_cast( null as date ) as onset_date\n , try_cast( null as date ) as resolved_date\n , cast('active' as TEXT ) as status\n , cast(unpivot_cte.condition_type as TEXT ) as condition_type\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_cm is not null then 'icd-10-cm'\n end as TEXT\n ) as normalized_code_type\n , cast(icd.icd_10_cm as TEXT ) as normalized_code\n , cast(icd.long_description as TEXT ) as normalized_description\n , cast(unpivot_cte.diagnosis_rank as integer ) as condition_rank\n , cast(unpivot_cte.present_on_admit_code as TEXT ) as present_on_admit_code\n , cast(poa.present_on_admit_description as TEXT ) as present_on_admit_description\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join dev_thuxuan.terminology.icd_10_cm icd\n on unpivot_cte.source_code = icd.icd_10_cm\nleft join dev_thuxuan.terminology.present_on_admission as poa\n on unpivot_cte.present_on_admit_code = poa.present_on_admit_code", "relation_name": "dev_thuxuan.test.core__stg_claims_condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.945503Z", "completed_at": "2024-10-25T14:34:44.986979Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.988303Z", "completed_at": "2024-10-25T14:34:44.988303Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04680442810058594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_procedure", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the procedure table in core.\n-- *************************************************\n\nwith unpivot_cte as (\n\nselect\n claim_id as claim_id\n , claim_line_number as procedure_sequence_id\n , patient_id as patient_id\n , coalesce(admission_date\n , claim_start_date\n , discharge_date\n , claim_end_date\n ) as procedure_date\n , 'hcpcs' as source_code_type\n , hcpcs_code as source_code\n , rendering_id as practitioner_npi\n , hcpcs_modifier_1 as modifier_1\n , hcpcs_modifier_2 as modifier_2\n , hcpcs_modifier_3 as modifier_3\n , hcpcs_modifier_4 as modifier_4\n , hcpcs_modifier_5 as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim\nwhere hcpcs_code is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 1 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_1 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_1 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_1 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 2 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_2 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_2 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_2 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 3 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_3 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_3 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_3 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 4 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_4 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_4 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_4 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 5 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_5 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_5 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_5 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 6 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_6 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_6 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_6 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 7 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_7 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_7 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_7 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 8 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_8 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_8 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_8 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 9 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_9 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_9 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_9 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 10 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_10 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_10 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_10 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 11 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_11 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_11 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_11 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 12 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_12 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_12 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_12 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 13 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_13 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_13 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_13 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 14 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_14 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_14 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_14 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 15 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_15 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_15 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_15 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 16 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_16 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_16 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_16 is not null\n \n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 17 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_17 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_17 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_17 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 18 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_18 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_18 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_18 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 19 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_19 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_19 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_19 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 20 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_20 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_20 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_20 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 21 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_21 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_21 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_21 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 22 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_22 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_22 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_22 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 23 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_23 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_23 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_23 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 24 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_24 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_24 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_24 is not null\n\n\nunion distinct\n\n\nselect\n claim_id as claim_id\n , 25 as procedure_sequence_id\n , patient_id as patient_id\n , procedure_date_25 as procedure_date\n , procedure_code_type as source_code_type\n , procedure_code_25 as source_code\n , rendering_id as practitioner_npi\n , null as modifier_1\n , null as modifier_2\n , null as modifier_3\n , null as modifier_4\n , null as modifier_5\n , data_source as data_source\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim \nwhere procedure_code_25 is not null\n\n)\n\nselect distinct\n\n \n try_cast(unpivot_cte.data_source || '_' || unpivot_cte.claim_id || '_' || unpivot_cte.procedure_sequence_id || '_' || unpivot_cte.source_code || case when unpivot_cte.modifier_1 is not null then CONCAT('_', unpivot_cte.modifier_1) else '' end || case when unpivot_cte.modifier_2 is not null then CONCAT('_', unpivot_cte.modifier_2) else '' end || case when unpivot_cte.modifier_3 is not null then CONCAT('_', unpivot_cte.modifier_3) else '' end || case when unpivot_cte.modifier_4 is not null then CONCAT('_', unpivot_cte.modifier_4) else '' end || case when unpivot_cte.modifier_5 is not null then CONCAT('_', unpivot_cte.modifier_5) else '' end || case when unpivot_cte.practitioner_npi is not null then CONCAT('_', unpivot_cte.practitioner_npi) else '' end as TEXT)\n as procedure_id\n , cast(unpivot_cte.patient_id as TEXT ) as patient_id\n , cast(null as TEXT ) as encounter_id --one claim can be on multiple encounters, so nulling out for now\n , cast(unpivot_cte.claim_id as TEXT ) as claim_id\n , try_cast( unpivot_cte.procedure_date as date ) as procedure_date\n , cast(unpivot_cte.source_code_type as TEXT ) as source_code_type\n , cast(unpivot_cte.source_code as TEXT ) as source_code\n , cast(null as TEXT ) as source_description\n , cast(\n case\n when icd.icd_10_pcs is not null then 'icd-10-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n end\n as TEXT ) as normalized_code_type\n , cast (\n coalesce (\n icd.icd_10_pcs\n , hcpcs.hcpcs\n )\n as TEXT ) as normalized_code\n , cast (\n coalesce (\n icd.description\n , hcpcs.short_description\n )\n as TEXT ) as normalized_description\n , cast(unpivot_cte.modifier_1 as TEXT ) as modifier_1\n , cast(unpivot_cte.modifier_2 as TEXT ) as modifier_2\n , cast(unpivot_cte.modifier_3 as TEXT ) as modifier_3\n , cast(unpivot_cte.modifier_4 as TEXT ) as modifier_4\n , cast(unpivot_cte.modifier_5 as TEXT ) as modifier_5\n , cast(unpivot_cte.practitioner_npi as TEXT ) as practitioner_id\n , cast(unpivot_cte.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom unpivot_cte\n--inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk x on unpivot_cte.claim_id = x.claim_id\n--and\n--unpivot_cte.claim_line_number = x.claim_line_number\n--and\n--x.claim_line_attribution_number = 1\nleft join dev_thuxuan.terminology.icd_10_pcs as icd\n on unpivot_cte.source_code = icd.icd_10_pcs\nleft join dev_thuxuan.terminology.hcpcs_level_2 as hcpcs\n on unpivot_cte.source_code = hcpcs.hcpcs", "relation_name": "dev_thuxuan.test.core__stg_claims_procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.966543Z", "completed_at": "2024-10-25T14:34:44.988303Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.989318Z", "completed_at": "2024-10-25T14:34:44.989318Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04681658744812012, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dialysis__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.dialysis__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dialysis'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.dialysis__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.973724Z", "completed_at": "2024-10-25T14:34:44.989318Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.991315Z", "completed_at": "2024-10-25T14:34:44.991315Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0488133430480957, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.dme__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.dme__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'dme - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.dme__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.979759Z", "completed_at": "2024-10-25T14:34:44.990316Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:44.993318Z", "completed_at": "2024-10-25T14:34:44.993318Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04981851577758789, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.emergency_department__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'emergency department'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n,encounter_header_values as (\n select distinct patient_data_source_id\n ,data_source\n ,encounter_id\n from detail_values\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type -- not changing grain, but bringing into final\n, encounter_group\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, ehv.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n a.encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, sc.observation_flag\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, ehv.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.emergency_department__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\ninner join encounter_header_values ehv on x.encounter_id = ehv.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.emergency_department__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:44.998318Z", "completed_at": "2024-10-25T14:34:45.018318Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.033317Z", "completed_at": "2024-10-25T14:34:45.033317Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.039998769760131836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.encounters__orphaned_claims", "compiled": true, "compiled_code": "\n\nwith cte as (\n select stg.claim_id\n ,stg.claim_line_number\n ,stg.service_category_1\n ,stg.service_category_2\n ,stg.service_category_3\n ,stg.claim_type\n ,stg.claim_start_date\n ,stg.claim_end_date\n ,stg.start_date\n ,stg.end_date\n ,stg.patient_data_source_id\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n left join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk enc on stg.claim_id = enc.claim_id\n and\n stg.claim_line_number = enc.claim_line_number\n where enc.claim_id is null -- missing from encounter mapping table\n)\n\n,max_encounter as (\n select max(encounter_id) max_encounter_id\n from dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk\n)\n\nselect \n claim_id\n, claim_line_number\n, dense_rank() over (order by patient_data_source_id, claim_id) + max_encounter.max_encounter_id as encounter_id\n, 'orphaned claim' as encounter_type\n, 'other' as encounter_group\nfrom cte\ncross join max_encounter", "relation_name": "dev_thuxuan.claims_preprocessing.encounters__orphaned_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.003316Z", "completed_at": "2024-10-25T14:34:45.033317Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.037045Z", "completed_at": "2024-10-25T14:34:45.037045Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04172801971435547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.home_health__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.home_health__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'home health'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.home_health__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.010318Z", "completed_at": "2024-10-25T14:34:45.034316Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.038785Z", "completed_at": "2024-10-25T14:34:45.038785Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04246640205383301, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_hospice__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n ,encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_hospice__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_hospice__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.019316Z", "completed_at": "2024-10-25T14:34:45.037847Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.040790Z", "completed_at": "2024-10-25T14:34:45.040790Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04347419738769531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_psych__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_psych__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_psych__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.046548Z", "completed_at": "2024-10-25T14:34:45.071807Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.078807Z", "completed_at": "2024-10-25T14:34:45.078807Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.037268877029418945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_rehab__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n, encounter_group\n ,encounter_type\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_rehab__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_rehab__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.054550Z", "completed_at": "2024-10-25T14:34:45.077808Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.080807Z", "completed_at": "2024-10-25T14:34:45.080807Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03726339340209961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_snf__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient skilled nursing'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n ,encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_snf__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_snf__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.062798Z", "completed_at": "2024-10-25T14:34:45.079905Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.082804Z", "completed_at": "2024-10-25T14:34:45.082804Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03725409507751465, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.inpatient_substance_use__encounter_grain", "compiled": true, "compiled_code": "\n\nwith detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,ed.encounter_start_date\n ,ed.encounter_end_date\n ,cli.encounter_type\n ,cli.encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id --replace this ref with the deduped version when complete\n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'inpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates ed on cli.old_encounter_id = ed.encounter_id\n)\n\n,encounter_cross_walk as (\n select distinct encounter_id\n ,old_encounter_id\n from detail_values\n)\n\n,first_last_inst_inst_values as (\nselect *\n,row_number() over (partition by encounter_id order by start_date, claim_id) as first_num\n,row_number() over (partition by encounter_id order by end_date desc, claim_id) as last_num\nfrom detail_values\nwhere claim_type = 'institutional'\n)\n\n, institutional_claim_details as (\n select distinct\n d.encounter_id\n , f.diagnosis_code_1\n , f.diagnosis_code_type\n , f.facility_id as facility_id\n , f.ms_drg_code as ms_drg_code\n , f.apr_drg_code as apr_drg_code\n , f.admit_source_code as admit_source_code\n , f.admit_type_code as admit_type_code\n , l.discharge_disposition_code as discharge_disposition_code\n , d.patient_data_source_id\n , d.data_source\n from detail_values d\n inner join first_last_inst_inst_values f on d.encounter_id = f.encounter_id\n and\n f.first_num =1 \n inner join first_last_inst_inst_values l on d.encounter_id = l.encounter_id\n and\n l.last_num = 1 \n\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n, encounter_type\n, encounter_group\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'emergency department' then 1 else 0 end) as ed_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect\n x.encounter_id\n, a.encounter_start_date\n, a.encounter_end_date\n, c.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n encounter_end_date\n )/365 as admit_age\n, e.gender\n, e.race\n, c.diagnosis_code_type as primary_diagnosis_code_type\n, c.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, c.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, sc.ed_flag\n, c.ms_drg_code\n, j.ms_drg_description\n, j.medical_surgical\n, c.apr_drg_code\n, k.apr_drg_description\n, c.admit_source_code\n, h.admit_source_description\n, c.admit_type_code\n, i.admit_type_description\n, c.discharge_disposition_code\n, g.discharge_disposition_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, datediff(\n day,\n a.encounter_start_date,\n a.encounter_end_date\n ) as length_of_stay\n, case\n when c.discharge_disposition_code = '20' then 1\n else 0\n end mortality_flag\n, c.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.inpatient_substance_use__start_end_dates a\ninner join encounter_cross_walk x on a.encounter_id = x.old_encounter_id\ninner join total_amounts tot on x.encounter_id = tot.encounter_id\ninner join service_category_flags sc on x.encounter_id = sc.encounter_id\nleft join institutional_claim_details c\n on x.encounter_id = c.encounter_id\nleft join patient e\n on c.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on c.facility_id = b.npi\nleft join dev_thuxuan.terminology.discharge_disposition g\n on c.discharge_disposition_code = g.discharge_disposition_code\nleft join dev_thuxuan.terminology.admit_source h\n on c.admit_source_code = h.admit_source_code\nleft join dev_thuxuan.terminology.admit_type i\n on c.admit_type_code = i.admit_type_code\nleft join dev_thuxuan.terminology.ms_drg j\n on c.ms_drg_code = j.ms_drg_code\nleft join dev_thuxuan.terminology.apr_drg k\n on c.apr_drg_code = k.apr_drg_code\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on c.diagnosis_code_1 = icd10cm.icd_10_cm\n and c.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on c.diagnosis_code_1 = icd9cm.icd_9_cm\n and c.diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.claims_preprocessing.inpatient_substance_use__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.071807Z", "completed_at": "2024-10-25T14:34:45.081804Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.084810Z", "completed_at": "2024-10-25T14:34:45.084810Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0392603874206543, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.lab__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.lab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'lab - orphaned'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'outpatient pharmacy' then 1 \n when scr.service_category_2 = 'office-based pharmacy' then 1 else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.lab__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.087805Z", "completed_at": "2024-10-25T14:34:45.103928Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.116615Z", "completed_at": "2024-10-25T14:34:45.116615Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03372550010681152, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.office_visit__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit surgery' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_surgery\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit injections' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_injections\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit radiology' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_radiology\n\n union all\n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit - other' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_em\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'telehealth' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits_telehealth\n\n union all \n\nselect distinct old_encounter_id\n ,start_date as encounter_start_date\n ,'office visit pt/ot/st' as encounter_type\n from dev_thuxuan.claims_preprocessing.office_visits__int_office_visits\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_group = 'office based'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n and\n d.encounter_type = cli.encounter_type\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_physician as \n(\n select encounter_id\n , billing_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where billing_id is not null\n group by \n encounter_id\n , billing_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where hcpcs_code is not null\n group by \n encounter_id\n , hcpcs_code\n , ccs_category\n , ccs_category_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, phy.billing_id\n, b2.provider_first_name || ' ' || b2.provider_last_name as provider_name\n, b2.primary_specialty_description as provider_specialty\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, hcpc.hcpcs_code\n, hcpc.ccs_category\n, hcpc.ccs_category_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_physician phy on d.encounter_id = phy.encounter_id\nand\nphy.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.provider b2\n on phy.billing_id = b2.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.office_visit__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.096911Z", "completed_at": "2024-10-25T14:34:45.117532Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.122576Z", "completed_at": "2024-10-25T14:34:45.122576Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03677010536193848, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospice__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_hospice__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospice'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n, tot.encounter_type\n, tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospice__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.104976Z", "completed_at": "2024-10-25T14:34:45.120982Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.123586Z", "completed_at": "2024-10-25T14:34:45.124582Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03773760795593262, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_hospital_or_clinic__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient hospital or clinic'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.111641Z", "completed_at": "2024-10-25T14:34:45.123586Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.125643Z", "completed_at": "2024-10-25T14:34:45.125643Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.0297243595123291, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_injections__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_injections__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient injections'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_hcpc as \n(\n select encounter_id\n , hcpcs_code\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where substring(hcpcs_code,1,1)='J'\n\n group by \n encounter_id\n , hcpcs_code\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_hcpc hcpc on d.encounter_id = hcpc.encounter_id\nand\nhcpc.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_injections__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.130582Z", "completed_at": "2024-10-25T14:34:45.144753Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.157659Z", "completed_at": "2024-10-25T14:34:45.157659Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03307604789733887, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_psych__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_psych__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient psych'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_psych__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.138582Z", "completed_at": "2024-10-25T14:34:45.156748Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.159717Z", "completed_at": "2024-10-25T14:34:45.159717Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.031102657318115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_ptotst__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_ptotst__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient pt/ot/st'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_ptotst__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.146035Z", "completed_at": "2024-10-25T14:34:45.159163Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.161436Z", "completed_at": "2024-10-25T14:34:45.161436Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.031853675842285156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_radiology__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_radiology__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient radiology'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,hcpcs_code as \n(\n select distinct hcpcs_code\n ,encounter_id\n from detail_values\n\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, hcpc.hcpcs_code\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join hcpcs_code hcpc on d.encounter_id = hcpc.encounter_id\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_radiology__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.151650Z", "completed_at": "2024-10-25T14:34:45.160414Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.163424Z", "completed_at": "2024-10-25T14:34:45.163424Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.026839256286621094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_rehab__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_rehab__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient rehabilitation'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_rehab__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.167421Z", "completed_at": "2024-10-25T14:34:45.181420Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.194424Z", "completed_at": "2024-10-25T14:34:45.194424Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03199934959411621, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_substance_use__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_substance_use__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient substance use'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_substance_use__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.175420Z", "completed_at": "2024-10-25T14:34:45.195423Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.197421Z", "completed_at": "2024-10-25T14:34:45.197421Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03399968147277832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.outpatient_surgery__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.outpatient_surgery__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'outpatient surgery'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.outpatient_surgery__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.181420Z", "completed_at": "2024-10-25T14:34:45.196422Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.198422Z", "completed_at": "2024-10-25T14:34:45.198422Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0319974422454834, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.urgent_care__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select distinct old_encounter_id\n ,start_date as encounter_start_date\n from dev_thuxuan.claims_preprocessing.urgent_care__generate_encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.old_encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n and\n cli.encounter_type = 'urgent care'\n and\n cli.claim_line_attribution_number = 1\n inner join encounter_date d on cli.old_encounter_id = d.old_encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.patient_data_source_id\n\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, sc.observation_flag\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.urgent_care__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.188420Z", "completed_at": "2024-10-25T14:34:45.197421Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.199420Z", "completed_at": "2024-10-25T14:34:45.199420Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024999141693115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__condition", "compiled": true, "compiled_code": "\n\n\nwith all_conditions as (\n select *\nfrom dev_thuxuan.test.core__stg_claims_condition\nunion all\nselect *\nfrom dev_thuxuan.test.core__stg_clinical_condition\n\n\n)\n\n\n\n\nselect\n all_conditions.condition_id\n , all_conditions.patient_id\n , all_conditions.encounter_id\n , all_conditions.claim_id\n , all_conditions.recorded_date\n , all_conditions.onset_date\n , all_conditions.resolved_date\n , all_conditions.status\n , all_conditions.condition_type\n , all_conditions.source_code_type\n , all_conditions.source_code\n , all_conditions.source_description\n , case\n when all_conditions.normalized_code_type is not null then all_conditions.normalized_code_type\n when icd10.icd_10_cm is not null then 'icd-10-cm'\n when icd9.icd_9_cm is not null then 'icd-9-cm'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n else null end as normalized_code_type\n , coalesce(\n all_conditions.normalized_code\n , icd10.icd_10_cm\n , icd9.icd_9_cm\n , snomed_ct.snomed_ct) as normalized_code\n , coalesce(\n all_conditions.normalized_description\n , icd10.short_description\n , icd9.short_description\n , snomed_ct.description) as normalized_description\n , case when coalesce(all_conditions.normalized_code, all_conditions.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_cm,icd9.icd_9_cm, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_conditions.condition_rank\n , all_conditions.present_on_admit_code\n , all_conditions.present_on_admit_description\n , all_conditions.data_source\n , all_conditions.tuva_last_run\nfrom\nall_conditions\nleft join dev_thuxuan.terminology.icd_10_cm icd10\n on all_conditions.source_code_type = 'icd-10-cm'\n and replace(all_conditions.source_code,'.','') = icd10.icd_10_cm\nleft join dev_thuxuan.terminology.icd_9_cm icd9\n on all_conditions.source_code_type = 'icd-9-cm'\n and replace(all_conditions.source_code,'.','') = icd9.icd_9_cm\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on all_conditions.source_code_type = 'snomed-ct'\n and all_conditions.source_code = snomed_ct.snomed_ct\n\n\n\n\n", "relation_name": "dev_thuxuan.core.condition"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.202422Z", "completed_at": "2024-10-25T14:34:45.214420Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.240421Z", "completed_at": "2024-10-25T14:34:45.240421Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.041001081466674805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__procedure", "compiled": true, "compiled_code": "\n\n\nwith all_procedures as (\nselect * from dev_thuxuan.test.core__stg_claims_procedure\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_procedure\n\n\n)\n\n\n\nselect\n all_procedures.procedure_id\n , all_procedures.patient_id\n , all_procedures.encounter_id\n , all_procedures.claim_id\n , all_procedures.procedure_date\n , all_procedures.source_code_type\n , all_procedures.source_code\n , all_procedures.source_description\n , case when all_procedures.normalized_code_type is not null then all_procedures.normalized_code_type\n when icd10.icd_10_pcs is not null then 'icd-10-pcs'\n when icd9.icd_9_pcs is not null then 'icd-9-pcs'\n when hcpcs.hcpcs is not null then 'hcpcs'\n when snomed_ct.snomed_ct is not null then 'snomed-ct'\n end as normalized_code_type\n , coalesce(all_procedures.normalized_code\n , icd10.icd_10_pcs\n , icd9.icd_9_pcs\n , hcpcs.hcpcs\n ,snomed_ct.snomed_ct ) as normalized_code\n , coalesce(all_procedures.normalized_description\n , icd10.description\n , icd9.short_description\n , hcpcs.short_description\n , snomed_ct.description) normalized_description\n , case when coalesce(all_procedures.normalized_code, all_procedures.normalized_description) is not null then 'manual'\n when coalesce(icd10.icd_10_pcs,icd9.icd_9_pcs, hcpcs.hcpcs, snomed_ct.snomed_ct) is not null then 'automatic'\n end as mapping_method\n , all_procedures.modifier_1\n , all_procedures.modifier_2\n , all_procedures.modifier_3\n , all_procedures.modifier_4\n , all_procedures.modifier_5\n , all_procedures.practitioner_id\n , all_procedures.data_source\n , all_procedures.tuva_last_run\nfrom all_procedures\nleft join dev_thuxuan.terminology.icd_10_pcs icd10\n on all_procedures.source_code_type = 'icd-10-pcs'\n and all_procedures.source_code = icd10.icd_10_pcs\nleft join dev_thuxuan.terminology.icd_9_pcs icd9\n on all_procedures.source_code_type = 'icd-9-pcs'\n and all_procedures.source_code = icd9.icd_9_pcs\nleft join dev_thuxuan.terminology.hcpcs_level_2 hcpcs\n on all_procedures.source_code_type = 'hcpcs'\n and all_procedures.source_code = hcpcs.hcpcs\nleft join dev_thuxuan.terminology.snomed_ct snomed_ct\n on all_procedures.source_code_type = 'snomed-ct'\n and all_procedures.source_code = snomed_ct.snomed_ct\n\n\n", "relation_name": "dev_thuxuan.core.procedure"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.214420Z", "completed_at": "2024-10-25T14:34:45.242421Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.245221Z", "completed_at": "2024-10-25T14:34:45.245221Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.043801069259643555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_medical_claim", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the medical_claim table\n-- in core. It adds these 4 fields to the input layer\n-- medical claim table:\n-- encounter_id\n-- service_category_1\n-- service_category_2\n-- *************************************************\n\nwith all_encounters as (\n select claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__combined_claim_line_crosswalk\n where claim_line_attribution_number = 1\n \n union all \n\n select \n claim_id\n, claim_line_number\n, encounter_id\n, encounter_type\n, encounter_group\n from dev_thuxuan.claims_preprocessing.encounters__orphaned_claims\n)\n\n\nselect\n med.claim_id || '-' || med.claim_line_number as medical_claim_id\n , cast(med.claim_id as TEXT ) as claim_id\n , cast(med.claim_line_number as integer ) as claim_line_number\n , cast(x.encounter_id as TEXT ) as encounter_id\n , cast(x.encounter_type as TEXT ) as encounter_type\n , cast(x.encounter_group as TEXT ) as encounter_group\n , cast(med.claim_type as TEXT ) as claim_type\n , cast(med.patient_id as TEXT ) as patient_id\n , cast(med.member_id as TEXT ) as member_id\n , cast(med.payer as TEXT ) as payer\n , med.plan\n , try_cast( med.claim_start_date as date ) as claim_start_date\n , try_cast( med.claim_end_date as date ) as claim_end_date\n , try_cast( med.claim_line_start_date as date ) as claim_line_start_date\n , try_cast( med.claim_line_end_date as date ) as claim_line_end_date\n , try_cast( med.admission_date as date ) as admission_date\n , try_cast( med.discharge_date as date ) as discharge_date\n , cast(srv_group.service_category_1 as TEXT ) as service_category_1\n , cast(srv_group.service_category_2 as TEXT ) as service_category_2\n , cast(srv_group.service_category_3 as TEXT ) as service_category_3\n , cast(med.admit_source_code as TEXT ) as admit_source_code\n , cast(med.admit_source_description as TEXT ) as admit_source_description\n , cast(med.admit_type_code as TEXT ) as admit_type_code\n , cast(med.admit_type_description as TEXT ) as admit_type_description\n , cast(med.discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(med.discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(med.place_of_service_code as TEXT ) as place_of_service_code\n , cast(med.place_of_service_description as TEXT ) as place_of_service_description\n , cast(med.bill_type_code as TEXT ) as bill_type_code\n , cast(med.bill_type_description as TEXT ) as bill_type_description\n , cast(med.ms_drg_code as TEXT ) as ms_drg_code\n , cast(med.ms_drg_description as TEXT ) as ms_drg_description\n , cast(med.apr_drg_code as TEXT ) as apr_drg_code\n , cast(med.apr_drg_description as TEXT ) as apr_drg_description\n , cast(med.revenue_center_code as TEXT ) as revenue_center_code\n , cast(med.revenue_center_description as TEXT ) as revenue_center_description\n , cast(med.service_unit_quantity as numeric(28,6) ) as service_unit_quantity\n , cast(med.hcpcs_code as TEXT ) as hcpcs_code\n , cast(med.hcpcs_modifier_1 as TEXT ) as hcpcs_modifier_1\n , cast(med.hcpcs_modifier_2 as TEXT ) as hcpcs_modifier_2\n , cast(med.hcpcs_modifier_3 as TEXT ) as hcpcs_modifier_3\n , cast(med.hcpcs_modifier_4 as TEXT ) as hcpcs_modifier_4\n , cast(med.hcpcs_modifier_5 as TEXT ) as hcpcs_modifier_5\n , cast(med.rendering_id as TEXT ) as rendering_id\n , cast(med.rendering_tin as TEXT ) as rendering_tin\n , cast(med.rendering_name as TEXT ) as rendering_name\n , cast(med.billing_id as TEXT ) as billing_id\n , cast(med.billing_tin as TEXT ) as billing_tin\n , cast(med.billing_name as TEXT ) as billing_name\n , cast(med.facility_id as TEXT ) as facility_id\n , cast(med.facility_name as TEXT ) as facility_name\n , try_cast( med.paid_date as date ) as paid_date\n , cast(med.paid_amount as numeric(28,6) ) as paid_amount\n , cast(med.allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(med.charge_amount as numeric(28,6) ) as charge_amount\n , cast(med.coinsurance_amount as numeric(28,6) ) as coinsurance_amount\n , cast(med.copayment_amount as numeric(28,6) ) as copayment_amount\n , cast(med.deductible_amount as numeric(28,6) ) as deductible_amount\n , cast(med.total_cost_amount as numeric(28,6) ) as total_cost_amount\n , cast(med.in_network_flag as int ) as in_network_flag\n , cast(\n case\n when enroll.claim_id is not null then 1\n else 0\n end as int) as enrollment_flag\n , cast(med.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom dev_thuxuan.claims_preprocessing.normalized_input_medical_claim as med\ninner join dev_thuxuan.claims_preprocessing.service_category_grouper as srv_group\n on med.claim_id = srv_group.claim_id\n and med.claim_line_number = srv_group.claim_line_number\n and srv_group.duplicate_row_number = 1\ninner join all_encounters as x\n on med.claim_id = x.claim_id\n and med.claim_line_number = x.claim_line_number\nleft join dev_thuxuan.claims_preprocessing.flag_claims_with_enrollment as enroll\n on med.claim_id = enroll.claim_id\n and med.claim_line_number = enroll.claim_line_number", "relation_name": "dev_thuxuan.test.core__stg_claims_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.231420Z", "completed_at": "2024-10-25T14:34:45.243623Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.246258Z", "completed_at": "2024-10-25T14:34:45.246258Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.043836355209350586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.orphaned_claim__encounter_grain", "compiled": true, "compiled_code": "\n\nwith encounter_date as (\n select\n cli.encounter_id\n , min(stg.start_date) as encounter_start_date\n , max(stg.start_date) as encounter_end_date\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim as stg\n inner join dev_thuxuan.claims_preprocessing.encounters__orphaned_claims as cli\n on stg.claim_id = cli.claim_id\n and stg.claim_line_number = cli.claim_line_number\n group by\n cli.encounter_id\n)\n\n,detail_values as (\n select stg.*\n ,cli.encounter_id\n ,cli.encounter_type\n ,cli.encounter_group\n ,d.encounter_start_date \n ,d.encounter_end_date\n , row_number() over (partition by cli.encounter_id order by stg.claim_type, stg.start_date) as encounter_row_number --institutional then professional\n from dev_thuxuan.claims_preprocessing.encounters__stg_medical_claim stg\n inner join dev_thuxuan.claims_preprocessing.encounters__orphaned_claims cli on stg.claim_id = cli.claim_id \n and\n stg.claim_line_number = cli.claim_line_number\n inner join encounter_date d on cli.encounter_id = d.encounter_id\n)\n\n, patient as (\n select \n patient_data_source_id\n , birth_date\n , gender\n , race\n from dev_thuxuan.claims_preprocessing.encounters__stg_eligibility\n where patient_row_num = 1\n )\n\n, total_amounts as (\n select \n encounter_id\n , encounter_type\n , encounter_group\n , sum(paid_amount) as total_paid_amount\n , sum(allowed_amount) as total_allowed_amount\n , sum(charge_amount) as total_charge_amount\n , count(distinct claim_id) as claim_count\n , count(distinct(case when claim_type = 'institutional' then claim_id else null end)) as inst_claim_count\n , count(distinct(case when claim_type = 'professional' then claim_id else null end)) as prof_claim_count\nfrom detail_values\ngroup by encounter_id\n,encounter_type \n,encounter_group\n)\n\n\n,highest_paid_diagnosis as \n(\n select encounter_id\n , diagnosis_code_1\n , diagnosis_code_type\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where diagnosis_code_1 is not null\n group by diagnosis_code_1\n , encounter_id\n , diagnosis_code_type\n)\n\n,highest_paid_facility as \n(\n select encounter_id\n , facility_id\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where facility_id is not null\n group by \n encounter_id\n , facility_id\n)\n\n,highest_paid_pos as \n(\n select encounter_id\n , place_of_service_code\n , place_of_service_description\n , row_number() over (partition by encounter_id order by sum(paid_amount) desc ) as paid_order\n , sum(paid_amount) as paid_amount\n from detail_values\n where place_of_service_code is not null\n group by \n encounter_id\n , place_of_service_code\n , place_of_service_description\n)\n\n\n\n, service_category_flags as (\n select distinct\n d.encounter_id\n ,max(case when scr.service_category_2 = 'lab' then 1 else 0 end) as lab_flag\n ,max(case when scr.service_category_2 = 'ambulance' then 1 else 0 end) as ambulance_flag\n ,max(case when scr.service_category_2 = 'durable medical equipment' then 1 else 0 end) as dme_flag\n ,max(case when scr.service_category_2 = 'observation' then 1 else 0 end) as observation_flag\n ,max(case when scr.service_category_2 = 'pharmacy' then 1 \n else 0 end) as pharmacy_flag\n from detail_values d\n left join dev_thuxuan.claims_preprocessing.service_category_grouper scr on d.claim_id = scr.claim_id \n and\n scr.claim_line_number = d.claim_line_number\n group by d.encounter_id\n)\n\nselect d.encounter_id\n, d.encounter_start_date\n, d.encounter_end_date\n, d.patient_data_source_id\n,tot.encounter_type\n,tot.encounter_group\n, datediff(\n day,\n birth_date,\n d.encounter_start_date\n )/365 as admit_age\n, e.gender\n, e.race\n, hp.diagnosis_code_type as primary_diagnosis_code_type\n, hp.diagnosis_code_1 as primary_diagnosis_code\n, coalesce(icd10cm.long_description, icd9cm.long_description) as primary_diagnosis_description\n, hf.facility_id as facility_id\n, b.provider_organization_name as facility_name\n, b.primary_specialty_description as facility_type\n, sc.lab_flag\n, sc.dme_flag\n, sc.ambulance_flag\n, sc.pharmacy_flag\n, pos.place_of_service_code\n, pos.place_of_service_description\n, tot.total_paid_amount\n, tot.total_allowed_amount\n, tot.total_charge_amount\n, tot.claim_count\n, tot.inst_claim_count\n, tot.prof_claim_count\n, d.data_source\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom detail_values d\ninner join total_amounts tot on d.encounter_id = tot.encounter_id\ninner join service_category_flags sc on d.encounter_id = sc.encounter_id\nleft join highest_paid_diagnosis hp on d.encounter_id = hp.encounter_id\nand\nhp.paid_order = 1\nleft join highest_paid_facility hf on d.encounter_id = hf.encounter_id\nand\nhf.paid_order = 1\nleft join highest_paid_pos pos on d.encounter_id = pos.encounter_id\nand\npos.paid_order = 1\nleft join patient e\n on d.patient_data_source_id = e.patient_data_source_id\nleft join dev_thuxuan.terminology.provider b\n on hf.facility_id = b.npi\nleft join dev_thuxuan.terminology.icd_10_cm icd10cm\n on hp.diagnosis_code_1 = icd10cm.icd_10_cm\n and hp.diagnosis_code_type = 'icd-10-cm'\nleft join dev_thuxuan.terminology.icd_9_cm icd9cm\n on hp.diagnosis_code_1 = icd9cm.icd_9_cm\n and hp.diagnosis_code_type = 'icd-9-cm'\nwhere d.encounter_row_number = 1", "relation_name": "dev_thuxuan.claims_preprocessing.orphaned_claim__encounter_grain"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.284475Z", "completed_at": "2024-10-25T14:34:45.293483Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.294480Z", "completed_at": "2024-10-25T14:34:45.294480Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02044844627380371, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__condition_condition_id.ef1067e2f0", "compiled": true, "compiled_code": "\n \n \n\nselect\n condition_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.condition\nwhere condition_id is not null\ngroup by condition_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.326117Z", "completed_at": "2024-10-25T14:34:45.336124Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.356198Z", "completed_at": "2024-10-25T14:34:45.356198Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03709053993225098, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__procedure_procedure_id.feb1b6b4d5", "compiled": true, "compiled_code": "\n \n \n\nselect\n procedure_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.procedure\nwhere procedure_id is not null\ngroup by procedure_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.330116Z", "completed_at": "2024-10-25T14:34:45.344112Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.357233Z", "completed_at": "2024-10-25T14:34:45.357233Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03712129592895508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__medical_claim", "compiled": true, "compiled_code": "\n\n\nselect * from dev_thuxuan.test.core__stg_claims_medical_claim", "relation_name": "dev_thuxuan.core.medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.337110Z", "completed_at": "2024-10-25T14:34:45.358203Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.360694Z", "completed_at": "2024-10-25T14:34:45.360694Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.036585330963134766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_location", "compiled": true, "compiled_code": "\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom dev_thuxuan.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'organization'\n)\n\n\n\nselect \n cast(npi as TEXT ) as location_id\n , cast(npi as TEXT ) as npi\n , cast(provider_organization_name as TEXT ) as name\n , cast(null as TEXT ) as facility_type\n , cast(parent_organization_name as TEXT ) as parent_organization\n , cast(practice_address_line_1 as TEXT ) as address\n , cast(practice_city as TEXT ) as city\n , cast(practice_state as TEXT ) as state\n , cast(practice_zip_code as TEXT ) as zip_code\n , cast(null as float ) as latitude\n , cast(null as float ) as longitude\n , cast(data_source as TEXT ) as data_source\n , cast( '2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom provider", "relation_name": "dev_thuxuan.test.core__stg_claims_location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.345210Z", "completed_at": "2024-10-25T14:34:45.359195Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.362691Z", "completed_at": "2024-10-25T14:34:45.362691Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03257465362548828, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_practitioner", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the provider table \n-- in core. It includes data about all providers\n-- present in the raw claims dataset.\n-- *************************************************\n\n\nwith all_providers_in_claims_dataset as (\nselect distinct facility_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct rendering_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct billing_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_medical_claim\n\n\nunion distinct\n\n\nselect distinct prescribing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n\n\nunion distinct\n\n\nselect distinct dispensing_provider_id as npi, data_source\nfrom dev_thuxuan.test.core__stg_claims_pharmacy_claim\n),\n\n\nprovider as (\nselect aa.*, bb.data_source\nfrom dev_thuxuan.terminology.provider aa\ninner join all_providers_in_claims_dataset bb\non aa.npi = bb.npi\nwhere lower(aa.entity_type_description) = 'individual'\n)\n\n\n\nselect \n cast(npi as TEXT ) as practitioner_id\n , cast(npi as TEXT ) as npi\n , cast(provider_first_name as TEXT ) as provider_first_name\n , cast(provider_last_name as TEXT ) as provider_last_name\n , cast(parent_organization_name as TEXT ) as practice_affiliation\n , cast(primary_specialty_description as TEXT ) as specialty\n , cast(null as TEXT ) as sub_specialty\n , cast(data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nfrom provider", "relation_name": "dev_thuxuan.test.core__stg_claims_practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.385655Z", "completed_at": "2024-10-25T14:34:45.416945Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.438670Z", "completed_at": "2024-10-25T14:34:45.438670Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07696151733398438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__long_condition_category", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__condition as (\n\n\nselect\n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , condition_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere normalized_code_type = 'icd-10-cm'\n), ccsr__dx_vertical_pivot as (\n \n select * from dev_thuxuan.ccsr.dx_vertical_pivot \n\n), condition as (\n \n select * from __dbt__cte__ccsr__stg_core__condition\n\n), dxccsr_body_systems as (\n\n select * from dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems\n\n)\n\nselect \n condition.encounter_id,\n condition.claim_id,\n condition.patient_id,\n condition.normalized_code,\n ccsr__dx_vertical_pivot.code_description,\n condition.condition_rank,\n ccsr__dx_vertical_pivot.ccsr_parent_category,\n dxccsr_body_systems.body_system,\n dxccsr_body_systems.parent_category_description,\n ccsr__dx_vertical_pivot.ccsr_category,\n ccsr__dx_vertical_pivot.ccsr_category_description,\n ccsr__dx_vertical_pivot.ccsr_category_rank,\n ccsr__dx_vertical_pivot.is_ip_default_category,\n ccsr__dx_vertical_pivot.is_op_default_category,\n '2023.1' as dxccsr_version,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom condition\nleft join ccsr__dx_vertical_pivot\n on condition.normalized_code = ccsr__dx_vertical_pivot.code\nleft join dxccsr_body_systems on ccsr__dx_vertical_pivot.ccsr_parent_category = dxccsr_body_systems.ccsr_parent_category", "relation_name": "dev_thuxuan.ccsr.long_condition_category"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.400711Z", "completed_at": "2024-10-25T14:34:45.439754Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.445687Z", "completed_at": "2024-10-25T14:34:45.445687Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.08098053932189941, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_prep_conditions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , lower(normalized_code_type) as code_type\n , normalized_code as code\n , data_source\nfrom dev_thuxuan.core.condition\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_condition\n\n)\n\n/*\n Default mapping guidance: Most map groups terminate with an unconditional\n rule \u2013 a rule whose predicate is \u201cTRUE\u201d or, equivalently, \u201cOTHERWISE TRUE\u201d.\n This rule is considered a \u201cdefault\u201d because it should be applied if\n nothing further is known about the patient\u2019s condition.\n*/\n, seed_snomed_icd_10_map as (\n\n select\n referenced_component_id as snomed_code\n , map_target as icd_10_code\n from dev_thuxuan.terminology.snomed_icd_10_map\n where lower(map_rule) in ('true', 'otherwise true')\n and map_group = '1'\n\n)\n\n, snomed_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , 'icd-10-cm' as code_type\n , icd_10_code as code\n , data_source\n from conditions\n inner join seed_snomed_icd_10_map\n on conditions.code = seed_snomed_icd_10_map.snomed_code\n where conditions.code_type = 'snomed-ct'\n\n)\n\n, other_conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from conditions\n where conditions.code_type <> 'snomed-ct'\n\n)\n\n, union_conditions as (\n\n select * from snomed_conditions\n union all\n select * from other_conditions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code_type as TEXT) as code_type\n , cast(code as TEXT) as code\n , cast(data_source as TEXT) as data_source\n from union_conditions\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_prep_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.416945Z", "completed_at": "2024-10-25T14:34:45.443681Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.448447Z", "completed_at": "2024-10-25T14:34:45.448447Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.05074930191040039, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria3", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), diabetes_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetes_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join diabetes_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetes_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetes_codes.code\n\n)\n\n, patients_with_diabetes as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version \n from diabetes_conditions\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_diabetes\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator_criteria3"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.452455Z", "completed_at": "2024-10-25T14:34:45.459078Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.476171Z", "completed_at": "2024-10-25T14:34:45.476171Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.028316736221313477, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__condition_patient_id.1f1222e348", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n) select patient_id\nfrom __dbt__cte___stg_condition\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.460089Z", "completed_at": "2024-10-25T14:34:45.478142Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.479105Z", "completed_at": "2024-10-25T14:34:45.479105Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0276491641998291, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_long", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__tuva_chronic_conditions__stg_core__condition as (\n\n\nselect \n patient_id\n , normalized_code\n , recorded_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), all_conditions as (\nselect \n patient_id,\n normalized_code,\n recorded_date\n from __dbt__cte__tuva_chronic_conditions__stg_core__condition\n),\n\n\nconditions_with_first_and_last_diagnosis_date as (\nselect \n patient_id,\n normalized_code as icd_10_cm,\n min(recorded_date) as first_diagnosis_date,\n max(recorded_date) as last_diagnosis_date\nfrom all_conditions\ngroup by patient_id, normalized_code\n\n)\n\n\nselect\n aa.patient_id,\n bb.concept_name as condition,\n min(first_diagnosis_date) as first_diagnosis_date,\n max(last_diagnosis_date) as last_diagnosis_date,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom conditions_with_first_and_last_diagnosis_date aa\ninner join dev_thuxuan.clinical_concept_library.value_set_member_relevant_fields bb\non aa.icd_10_cm = bb.code\ngroup by aa.patient_id, bb.concept_name", "relation_name": "dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.469085Z", "completed_at": "2024-10-25T14:34:45.479105Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.480546Z", "completed_at": "2024-10-25T14:34:45.480546Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022975683212280273, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__long_procedure_category", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__ccsr__stg_core__procedure as (\n\n\nselect \n encounter_id\n , claim_id\n , patient_id\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), procedures as (\n\n select * from __dbt__cte__ccsr__stg_core__procedure\n\n)\n\n, ccsr__procedure_category_map as (\n\n select * from dev_thuxuan.ccsr.procedure_category_map\n\n)\n\nselect distinct\n procedures.encounter_id\n , procedures.claim_id\n , procedures.patient_id\n , procedures.normalized_code\n , ccsr__procedure_category_map.code_description\n , ccsr__procedure_category_map.ccsr_parent_category\n , ccsr__procedure_category_map.ccsr_category\n , ccsr__procedure_category_map.ccsr_category_description\n , ccsr__procedure_category_map.clinical_domain\n , '2023.1' as prccsr_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom procedures\nleft join ccsr__procedure_category_map\n on procedures.normalized_code = ccsr__procedure_category_map.code", "relation_name": "dev_thuxuan.ccsr.long_procedure_category"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.481618Z", "completed_at": "2024-10-25T14:34:45.508813Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.559348Z", "completed_at": "2024-10-25T14:34:45.559348Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.08068633079528809, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria1", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), ascvd_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'atherosclerosis and peripheral arterial disease'\n , 'myocardial infarction'\n , 'pci'\n , 'stable and unstable angina'\n , 'cabg or pci procedure'\n , 'cabg surgeries'\n , 'cerebrovascular disease stroke or tia'\n , 'ischemic heart disease or related diagnoses'\n , 'carotid intervention'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, ascvd_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join ascvd_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = ascvd_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = ascvd_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, ascvd_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join ascvd_codes\n on procedures.code = ascvd_codes.code\n and procedures.code_type = ascvd_codes.code_system\n\n)\n\n, historical_ascvd as (\n\n select\n ascvd_conditions.patient_id\n , ascvd_conditions.evidence_date\n from ascvd_conditions\n\n union all\n\n select\n ascvd_procedures.patient_id\n , ascvd_procedures.evidence_date\n from ascvd_procedures\n\n)\n\n, patients_with_ascvd as (\n\n select\n distinct\n historical_ascvd.patient_id\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from historical_ascvd\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_ascvd\n\n)\n\nselect \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator_criteria1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.509888Z", "completed_at": "2024-10-25T14:34:45.567790Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.569791Z", "completed_at": "2024-10-25T14:34:45.569791Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.06298136711120605, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator_criteria2", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), cholesterol_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'ldl cholesterol'\n , 'familial hypercholesterolemia'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, cholesterol_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as evidence_date\n from conditions\n inner join cholesterol_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = cholesterol_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = cholesterol_codes.code\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, cholesterol_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join cholesterol_codes\n on procedures.code = cholesterol_codes.code\n and procedures.code_type = cholesterol_codes.code_system\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, cholesterol_tests_with_result as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date, result_date) as evidence_date\n , cholesterol_codes.concept_name\n , row_number() over(partition by labs.patient_id order by\n labs.result desc\n , result_date desc) as rn\n from labs\n inner join cholesterol_codes\n on coalesce(labs.normalized_code, labs.source_code) = cholesterol_codes.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = cholesterol_codes.code_system\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, cholesterol_labs as (\n\n select\n patient_id\n , evidence_date\n from cholesterol_tests_with_result\n where rn= 1\n and cast(evidence_value as numeric(28,6)) >= 190\n\n)\n\n, all_patients_with_cholesterol as (\n\n select\n cholesterol_conditions.patient_id\n , cholesterol_conditions.evidence_date\n from cholesterol_conditions\n\n union all\n\n select\n cholesterol_procedures.patient_id\n , cholesterol_procedures.evidence_date\n from cholesterol_procedures\n\n union all\n\n select\n cholesterol_labs.patient_id\n , cholesterol_labs.evidence_date\n from cholesterol_labs\n\n)\n\n, patients_with_cholesterol as (\n\n select\n distinct\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from all_patients_with_cholesterol\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period pp\n on evidence_date <= pp.performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from patients_with_cholesterol\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator_criteria2"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.560355Z", "completed_at": "2024-10-25T14:34:45.568791Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.570790Z", "completed_at": "2024-10-25T14:34:45.570790Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.06297802925109863, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__procedure_patient_id.0b52ff75d9", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n) select patient_id\nfrom __dbt__cte___stg_procedure\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.573789Z", "completed_at": "2024-10-25T14:34:45.583789Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.596790Z", "completed_at": "2024-10-25T14:34:45.596790Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027998924255371094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__procedure_ccs", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__procedure as (\n\n\nselect\n encounter_id\n, normalized_code\n, normalized_code_type\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n) -- Here we map every procedure code to its corresponding\n-- CCS procedure category.\n-- This model may list more than one CCS procedure category\n-- per encounter_id because different procedures associated with the\n-- encounter (different rows on the stg_procedure model) may have\n-- different associated CCS procedure categories.\n\n\n\nselect\n aa.encounter_id,\n aa.normalized_code as procedure_code,\n case\n when bb.icd_10_pcs is null then 0\n\telse 1\n end as valid_icd_10_pcs_flag,\n cc.ccs_procedure_category,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n __dbt__cte__readmissions__stg_core__procedure aa\n left join dev_thuxuan.terminology.icd_10_pcs bb\n on aa.normalized_code = bb.icd_10_pcs\n left join dev_thuxuan.readmissions._value_set_icd_10_pcs_to_ccs cc\n on aa.normalized_code = cc.icd_10_pcs\nwhere aa.normalized_code_type = 'icd-10-pcs'", "relation_name": "dev_thuxuan.readmissions._int_procedure_ccs"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.602788Z", "completed_at": "2024-10-25T14:34:45.620791Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.629791Z", "completed_at": "2024-10-25T14:34:45.629791Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.030000925064086914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__data_loss", "compiled": true, "compiled_code": "\n\nwith input_medical as (\n select\n cast('medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.medical_claim\n)\n\n, input_pharmacy as (\n select\n cast('pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from tuva.input_layer.pharmacy_claim\n)\n\n,input_eligibility as (\nselect\n cast('eligibility' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct member_id || '-' || enrollment_start_date || '-' || enrollment_end_date || '-' || payer || '-' || plan) as span_count\nfrom tuva.input_layer.eligibility\n)\n\n , input_member_months as (\n select\n cast('eligibility' as TEXT) as table_name\n , count(*) as member_month_count\n from dev_thuxuan.data_quality.data_quality__eligibility_dq_stage e\n)\n\n-- Core layer CTEs\n, core_medical as (\n select\n cast( 'medical_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from dev_thuxuan.core.medical_claim\n)\n\n, core_pharmacy as (\n select\n cast( 'pharmacy_claim' as TEXT) as table_name\n , count(distinct patient_id) as patient_count\n , count(distinct claim_id) as claim_count\n , count(*) as record_count\n , sum(paid_amount) as paid_amount\n , sum(allowed_amount) as allowed_amount\n from dev_thuxuan.core.pharmacy_claim\n)\n\n, core_eligibility as (\n select\n cast('eligibility' as TEXT)as table_name\n , count(distinct patient_id) as patient_count\n , count(*) as span_count\n from dev_thuxuan.core.eligibility\n)\n\n, core_member_months as (\n select\n cast('member_months' as TEXT) as table_name\n , count(*) as member_month_count\n from dev_thuxuan.core.member_months\n)\n\n,final as (\n-- Combining both input and core layers\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_medical as input\ninner join core_medical as core\n on input.table_name = core.table_name\n\n-- Pharmacy layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Claims' as TEXT) as metric\n , input.claim_count as input_layer_value\n , core.claim_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Records' as TEXT) as metric\n , input.record_count as input_layer_value\n , core.record_count as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Paid Amount' as TEXT) as metric\n , input.paid_amount as input_layer_value\n , core.paid_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Allowed Amount' as TEXT) as metric\n , input.allowed_amount as input_layer_value\n , core.allowed_amount as core_value\nfrom input_pharmacy as input\ninner join core_pharmacy as core\n on input.table_name = core.table_name\n\n-- Eligibility layer\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Patients' as TEXT) as metric\n , input.patient_count as input_layer_value\n , core.patient_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\n\nunion all\n\nselect\n input.table_name\n , cast('Total Unique Eligibility Spans' as TEXT) as metric\n , input.span_count as input_layer_value\n , core.span_count as core_value\nfrom input_eligibility as input\ninner join core_eligibility as core\n on input.table_name = core.table_name\n\nunion all\n\nselect\n input.table_name\n , cast('Total Member Months' as TEXT) as metric\n , input.member_month_count as input_layer_value\n , core.member_month_count as core_value\nfrom input_member_months as input\ninner join core_member_months as core\n on input.table_name = core.table_name\n\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.data_loss"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.615790Z", "completed_at": "2024-10-25T14:34:45.630790Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.631792Z", "completed_at": "2024-10-25T14:34:45.631792Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03099822998046875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__service_categories_pmpm", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n count(1) as member_months\n from dev_thuxuan.core.member_months mm\n)\n\n, pmpm as (\n select\n cast('service categories pmpm' as TEXT ) as analytics_concept\n , mc.service_category_2 as analytics_measure\n , sum(mc.paid_amount) as total_paid\n , avg(mm.member_months) as member_months\n , case when avg(mm.member_months) = 0 then null\n else sum(mc.paid_amount) / avg(mm.member_months)\n end as data_source_value\n from dev_thuxuan.core.medical_claim mc\n cross join member_months mm\n group by\n mc.service_category_2\n)\n\nselect\n pmpm.*\n , ref_data.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pmpm\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data\n on pmpm.analytics_concept = ref_data.analytics_concept\n and pmpm.analytics_measure = ref_data.analytics_measure", "relation_name": "dev_thuxuan.data_quality.service_categories_pmpm"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.621791Z", "completed_at": "2024-10-25T14:34:45.632789Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.633789Z", "completed_at": "2024-10-25T14:34:45.633789Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.020995140075683594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__service_category_pmpm_trend", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from dev_thuxuan.core.member_months\n group by year_month\n)\n\n, service_categories as (\n select\n cast(c.year_month_int as TEXT) as year_month\n , m.service_category_1\n , m.service_category_2\n , sum(m.paid_amount) as total_paid\n from dev_thuxuan.core.medical_claim as m\n left join dev_thuxuan.reference_data.calendar as c\n on m.claim_start_date = c.full_date\n group by\n cast(c.year_month_int as TEXT)\n , m.service_category_1\n , m.service_category_2\n)\n\nselect\n scat.year_month\n , scat.service_category_1\n , scat.service_category_2\n , scat.total_paid\n , scat.total_paid / mm.member_months as pmpm\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_categories as scat\ninner join member_months as mm\n on scat.year_month = mm.year_month", "relation_name": "dev_thuxuan.data_quality.service_category_pmpm_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.645826Z", "completed_at": "2024-10-25T14:34:45.656826Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.672337Z", "completed_at": "2024-10-25T14:34:45.672337Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03653764724731445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__stg_medical_claim", "compiled": true, "compiled_code": "\n\nselect mc.*,\ncast(c.year_month_int as TEXT) as year_month\nFROM dev_thuxuan.core.medical_claim mc\nleft join dev_thuxuan.reference_data.calendar c on coalesce(mc.claim_line_start_date,mc.claim_start_date) = c.full_date", "relation_name": "dev_thuxuan.data_quality.mart_review__stg_medical_claim"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.677335Z", "completed_at": "2024-10-25T14:34:45.683338Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.699335Z", "completed_at": "2024-10-25T14:34:45.699335Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027998685836791992, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__medical_claim_medical_claim_id.74a5d63708", "compiled": true, "compiled_code": "\n \n \n\nselect\n medical_claim_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.medical_claim\nwhere medical_claim_id is not null\ngroup by medical_claim_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.684337Z", "completed_at": "2024-10-25T14:34:45.701336Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.702337Z", "completed_at": "2024-10-25T14:34:45.702337Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.022000551223754883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__location", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_location\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_location\n\n", "relation_name": "dev_thuxuan.core.location"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.689337Z", "completed_at": "2024-10-25T14:34:45.702337Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.703337Z", "completed_at": "2024-10-25T14:34:45.703337Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022000551223754883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__practitioner", "compiled": true, "compiled_code": "\n\nselect * from dev_thuxuan.test.core__stg_claims_practitioner\nunion all\nselect * from dev_thuxuan.test.core__stg_clinical_practitioner\n\n", "relation_name": "dev_thuxuan.core.practitioner"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.705335Z", "completed_at": "2024-10-25T14:34:45.711335Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.712335Z", "completed_at": "2024-10-25T14:34:45.712335Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.010999202728271484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ccsr__singular_condition_category", "compiled": true, "compiled_code": "\n\nselect \n encounter_id,\n claim_id,\n patient_id,\n ccsr_category,\n ccsr_category_description,\n ccsr_parent_category,\n parent_category_description,\n body_system,\n '2023.1' as dxccsr_version,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ccsr.long_condition_category\nwhere\n is_ip_default_category = 1\n and condition_rank = 1", "relation_name": "dev_thuxuan.ccsr.singular_condition_category"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.713335Z", "completed_at": "2024-10-25T14:34:45.739336Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.740335Z", "completed_at": "2024-10-25T14:34:45.740335Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.029999732971191406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_all_conditions", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from dev_thuxuan.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n diagnosis_code\n , cms_hcc_v28 as hcc_code\n from dev_thuxuan.hcc_suspecting._value_set_icd_10_cm_mappings\n where cms_hcc_v28 is not null\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, joined as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code\n , conditions.data_source\n , seed_hcc_mapping.hcc_code\n , seed_hcc_descriptions.hcc_description\n from conditions\n left join seed_hcc_mapping\n on conditions.code = seed_hcc_mapping.diagnosis_code\n left join seed_hcc_descriptions\n on seed_hcc_mapping.hcc_code = seed_hcc_descriptions.hcc_code\n where conditions.code_type = 'icd-10-cm'\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(data_source as TEXT) as data_source\n from joined\n\n)\n\nselect\n patient_id\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_all_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.723338Z", "completed_at": "2024-10-25T14:34:45.740335Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.741338Z", "completed_at": "2024-10-25T14:34:45.741338Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030002593994140625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__tuva_chronic_conditions_wide", "compiled": true, "compiled_code": "\n\nwith patients as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n),\n\nobesity as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Obesity'\n),\n\n\nosteoarthritis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoarthritis'\n),\n\ncopd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Obstructive Pulmonary Disease'\n),\n\nanxiety_disorders as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Anxiety Disorders'\n),\n\nckd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Kidney Disease'\n),\n\nt2d as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 2 Diabetes Mellitus'\n),\n\ncll as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Chronic Lymphocytic Leukemia'\n),\n\ndysplipidemias as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dyslipidemias'\n),\n\nhypertension as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hypertension'\n),\n\natherosclerosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atherosclerosis'\n),\n\ndementia as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Dementia'\n),\n\nrheumatoid_arthritis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rheumatoid Arthritis'\n),\n\nceliac as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Celiac Disease'\n),\n\nhip_fracture as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Hip Fracture'\n),\n\nimmunodeficiencies_and_white_blood_cell_disorders as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Specified Immunodeficiencies and White Blood Cell Disorders (HCC v28 concept #115)'\n),\n\nasthma as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Asthma'\n),\n\nt1d as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Type 1 Diabetes Mellitus'\n),\n\nulcerative_colitis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Ulcerative colitis'\n),\n\nchrohns as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Crohns Disease'\n),\n\nholicobacter as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Helicobacter pylori Infection'\n),\n\nbipolar as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Bipolar Affective Disorder'\n),\n\nheart_failure as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Heart Failure'\n),\n\ntabacco as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Tobacco Use'\n),\n\nlyme as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lyme Disease'\n),\n\nbreast_cancer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Breast Cancer'\n),\n\nosteoporosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Osteoporosis'\n),\n\npulmonary_embolism as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Pulmonary Embolism, Thrombotic or Unspecified'\n),\n\nschizophrenia as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Schizophrenia'\n),\n\natrial_fibrillation as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Atrial Fibrillation'\n),\n\ncolorectal_cancer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Colorectal Cancer'\n),\n\ndepression as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Major Depressive Disorder'\n),\n\ndeep_vein_thrombosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Deep Vein Thrombosis of Extremities or Central Veins'\n),\n\nalzheimer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alzheimer Disease'\n),\n\nstroke as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Stroke'\n),\n\nmyocardial_infraction as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Myocardial Infarction'\n),\n\nopiod_use_disorder as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Opioid Use Disorder'\n),\n\nlung_cancer as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Lung cancer, primary or unspecified'\n),\n\nherpes as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Herpes Simplex Infection'\n),\n\nrickettsiosis as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Rickettsiosis'\n),\n\nms as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Multiple Sclerosis'\n),\n\nalchohol as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Alcohol Use Disorder'\n),\n\nadhd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Attention Deficit-Hyperactivity Disorder'\n),\n\nhiv as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'HIV/AIDS (HCC v28 concept #1)'\n),\n\nptsd as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Post-Traumatic Stress Disorder'\n),\n\nlupus as (\nselect distinct patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\nwhere condition = 'Systemic Lupus Erythematosus'\n)\n\n\n\n\nselect\n patient_id,\n case when patient_id in (select * from obesity) then 1\n else 0\n end as obesity,\n case when patient_id in (select * from osteoarthritis) then 1\n else 0\n end as osteoarthritis,\n case when patient_id in (select * from copd) then 1\n else 0\n end as copd,\n case when patient_id in (select * from anxiety_disorders) then 1\n else 0\n end as anxiety_disorders,\n case when patient_id in (select * from ckd) then 1\n else 0\n end as ckd,\n case when patient_id in (select * from t2d) then 1\n else 0\n end as t2d,\n case when patient_id in (select * from cll) then 1\n else 0\n end as cll,\n case when patient_id in (select * from dysplipidemias) then 1\n else 0\n end as dysplipidemias,\n case when patient_id in (select * from hypertension) then 1\n else 0\n end as hypertension,\n case when patient_id in (select * from atherosclerosis) then 1\n else 0\n end as atherosclerosis,\n case when patient_id in (select * from dementia) then 1\n else 0\n end as dementia,\n case when patient_id in (select * from rheumatoid_arthritis) then 1\n else 0\n end as rheumatoid_arthritis,\n case when patient_id in (select * from celiac) then 1\n else 0\n end as celiac,\n case when patient_id in (select * from hip_fracture) then 1\n else 0\n end as hip_fracture,\n case when patient_id in (select * from immunodeficiencies_and_white_blood_cell_disorders) then 1\n else 0\n end as immunodeficiencies_and_white_blood_cell_disorders,\n case when patient_id in (select * from asthma) then 1\n else 0\n end asthma,\n case when patient_id in (select * from t1d) then 1\n else 0\n end as t1d,\n case when patient_id in (select * from ulcerative_colitis) then 1\n else 0\n end as ulcerative_colitis,\n case when patient_id in (select * from chrohns) then 1\n else 0\n end as chrohns,\n case when patient_id in (select * from holicobacter) then 1\n else 0\n end as holicobacter,\n case when patient_id in (select * from bipolar) then 1\n else 0\n end as bipolar,\n case when patient_id in (select * from heart_failure) then 1\n else 0\n end as heart_failure,\n case when patient_id in (select * from tabacco) then 1\n else 0\n end as tabacco,\n case when patient_id in (select * from lyme) then 1\n else 0\n end as lyme,\n case when patient_id in (select * from breast_cancer) then 1\n else 0\n end as breast_cancer,\n case when patient_id in (select * from osteoporosis) then 1\n else 0\n end as osteoporosis,\n case when patient_id in (select * from pulmonary_embolism) then 1\n else 0\n end as pulmonary_embolism,\n case when patient_id in (select * from schizophrenia) then 1\n else 0\n end as schizophrenia,\n case when patient_id in (select * from atrial_fibrillation) then 1\n else 0\n end as atrial_fibrillation,\n case when patient_id in (select * from colorectal_cancer) then 1\n else 0\n end as colorectal_cancer,\n case when patient_id in (select * from depression) then 1\n else 0\n end as depression,\n case when patient_id in (select * from deep_vein_thrombosis) then 1\n else 0\n end as deep_vein_thrombosis,\n case when patient_id in (select * from alzheimer) then 1\n else 0\n end as alzheimer,\n case when patient_id in (select * from stroke) then 1\n else 0\n end as stroke,\n case when patient_id in (select * from myocardial_infraction) then 1\n else 0\n end as myocardial_infraction,\n case when patient_id in (select * from opiod_use_disorder) then 1\n else 0\n end as opiod_use_disorder,\n case when patient_id in (select * from lung_cancer) then 1\n else 0\n end as lung_cancer,\n case when patient_id in (select * from herpes) then 1\n else 0\n end as herpes,\n case when patient_id in (select * from rickettsiosis) then 1\n else 0\n end as rickettsiosis,\n case when patient_id in (select * from ms) then 1\n else 0\n end as ms,\n case when patient_id in (select * from alchohol) then 1\n else 0\n end as alchohol,\n case when patient_id in (select * from adhd) then 1\n else 0\n end as adhd,\n case when patient_id in (select * from hiv) then 1\n else 0\n end as hiv,\n case when patient_id in (select * from ptsd) then 1\n else 0\n end as ptsd,\n case when patient_id in (select * from lupus) then 1\n else 0\n end as lupus,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n\nfrom patients", "relation_name": "dev_thuxuan.chronic_conditions.tuva_chronic_conditions_wide"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.743335Z", "completed_at": "2024-10-25T14:34:45.755369Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.763391Z", "completed_at": "2024-10-25T14:34:45.763391Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024054765701293945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_prevalence", "compiled": true, "compiled_code": "\n\nwith condition_counts as (\n select\n condition\n , count(distinct patient_id) as patients\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n group by condition\n)\n, total_patients as (\n select \n count(distinct patient_id) as total_distinct_patients\n from dev_thuxuan.core.eligibility\n)\n\n, results_first as (\nselect\n conditions.condition\n , conditions.patients\n , CASE \n WHEN total_patients.total_distinct_patients = 0 THEN NULL\n ELSE (conditions.patients / total_patients.total_distinct_patients) * 100 \n END as percent_of_total\n\nfrom condition_counts as conditions\ncross join total_patients\n)\n\n,results_second as (\n select \n condition\n , patients\n , percent_of_total\n , ROW_NUMBER() OVER (ORDER BY percent_of_total desc) AS condition_rank\n from results_first\n)\n\n\nselect\n ref_data.analytics_concept\n , coalesce(results.condition, ref_data.analytics_measure) as analytics_measure\n , results.patients\n , results.condition_rank as value_rank\n , results.percent_of_total as data_source_value\n , ref_data.analytics_value\n , ref_data.value_rank as medicare_lds_condition_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data\nleft join results_second as results on results.condition = ref_data.analytics_measure\nwhere ref_data.analytics_concept = 'chronic conditions top 10'", "relation_name": "dev_thuxuan.data_quality.chronic_conditions_prevalence"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.757368Z", "completed_at": "2024-10-25T14:34:45.773875Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.774876Z", "completed_at": "2024-10-25T14:34:45.774876Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02150750160217285, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__number_of_conditions", "compiled": true, "compiled_code": "\n\nwith xwalk as (\n select distinct patient_id, data_source\n from dev_thuxuan.core.patient\n),\ncte as (\n select l.patient_id,\n x.data_source,\n count(*) as numofconditions\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long l\n left join xwalk x on l.patient_id = x.patient_id\n group by l.patient_id, x.data_source\n)\nselect p.patient_id,\n p.data_source,\n p.patient_id || '|' || p.data_source as patient_source_key,\n coalesce(cte.numofconditions, 0) as numofconditions\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient p\nleft join cte on p.patient_id = cte.patient_id and p.data_source = cte.data_source", "relation_name": "dev_thuxuan.data_quality.mart_review__number_of_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.764749Z", "completed_at": "2024-10-25T14:34:45.775918Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.777873Z", "completed_at": "2024-10-25T14:34:45.777873Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.023503780364990234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__tuva_chronic_conditions", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n patient_id\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, patientxwalk as (\n select distinct\n patient_id\n , data_source\n from dev_thuxuan.core.patient\n)\n\n, result as (\n select\n l.patient_id\n , p.data_source\n , l.condition\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long as l\n inner join patientxwalk as p\n on l.patient_id = p.patient_id\n\n union all\n\n select\n p.patient_id\n , p.data_source\n , 'No Chronic Conditions' as condition\n from dev_thuxuan.core.patient as p\n left join cte\n on p.patient_id = cte.patient_id\n where cte.patient_id is null\n)\n\nselect *\n , patient_id || '|' || data_source as patient_source_key\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom result", "relation_name": "dev_thuxuan.data_quality.mart_review__tuva_chronic_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.777873Z", "completed_at": "2024-10-25T14:34:45.785578Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.817847Z", "completed_at": "2024-10-25T14:34:45.817847Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04297184944152832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__tuva_chronic_conditions_long_patient_id__condition.9c8c725ff2", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, condition\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n group by patient_id, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.786597Z", "completed_at": "2024-10-25T14:34:45.851973Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.853024Z", "completed_at": "2024-10-25T14:34:45.853024Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0689702033996582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_all", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n and chronic_conditions.additional_logic = 'None'\n\n)\n\n, exclusions_diagnosis as (\n\n select distinct\n patient_conditions.claim_id\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Exclude'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_ms_drg\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_diagnosis\n on inclusions_unioned.claim_id = exclusions_diagnosis.claim_id\n and inclusions_unioned.condition = exclusions_diagnosis.condition\nwhere exclusions_diagnosis.claim_id is null", "relation_name": "dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.824862Z", "completed_at": "2024-10-25T14:34:45.854939Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.886443Z", "completed_at": "2024-10-25T14:34:45.886443Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.10086417198181152, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_hiv_aids", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__medical_claim as (\n\n\nselect\n claim_id\n , patient_id\n , claim_start_date\n , ms_drg_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), chronic_conditions as (\n\n select * from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_ms_drgs as (\n\n select\n patient_id\n , claim_id\n , claim_start_date as start_date\n , 'MS-DRG' as code_type\n , ms_drg_code as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__medical_claim\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE excludes encounters with the exception code. Those encounters\n will be evaluated separately.\n*/\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code <> 'R75'\n\n)\n\n, inclusions_ms_drg as (\n\n select\n patient_ms_drgs.patient_id\n , patient_ms_drgs.claim_id\n , patient_ms_drgs.start_date\n , patient_ms_drgs.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_ms_drgs\n inner join chronic_conditions\n on patient_ms_drgs.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'MS-DRG'\n\n)\n\n/*\n Exception logic: a claim with the diagnosis code R75 requires a second\n qualifying claim that is not R75 (a screening code)\n\n This CTE includes encounters with the exception code only where that\n patient has another encounter that is not R75.\n*/\n, exception_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n inner join inclusions_diagnosis\n on patient_conditions.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n and chronic_conditions.code = 'R75'\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_ms_drg\n union distinct\n select * from exception_diagnosis\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom inclusions_unioned", "relation_name": "dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.855942Z", "completed_at": "2024-10-25T14:34:45.889500Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.891449Z", "completed_at": "2024-10-25T14:34:45.891449Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03947591781616211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_eligible_conditions", "compiled": true, "compiled_code": "\n/*\nSteps for staging condition data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs\n\nClaims filtering logic:\n - Professional:\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n - Inpatient:\n - Bill type code in (11X, 41X)\n - Outpatient:\n - Bill type code in (12X, 13X, 43X, 71X, 73X, 76X, 77X, 85X)\n - CPT/HCPCS in CPT/HCPCS seed file from CMS\n\nJinja is used to set payment year variable.\n - The payment_year var has been set here so it gets compiled.\n - The collection year is one year prior to the payment year.\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\nselect\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), __dbt__cte___stg_condition as (\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , condition_type\n , normalized_code_type as code_type\n , normalized_code as code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), medical_claims as (\n\n select\n claim_id\n , claim_line_number\n , claim_type\n , patient_id\n , claim_start_date\n , claim_end_date\n , bill_type_code\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, conditions as (\n\n select\n claim_id\n , patient_id\n , code\n from __dbt__cte___stg_condition\n where code_type = 'icd-10-cm'\n\n)\n\n, cpt_hcpcs_list as (\n\n select\n payment_year\n , hcpcs_cpt_code\n from dev_thuxuan.cms_hcc._value_set_cpt_hcpcs\n\n)\n\n, professional_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'professional'\n and date_part('year', claim_end_date) = 2023\n and cpt_hcpcs_list.payment_year = 2024\n\n)\n\n\n, inpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and substring(bill_type_code, 1, 2) in ('11','41')\n\n)\n\n, outpatient_claims as (\n\n select\n medical_claims.claim_id\n , medical_claims.claim_line_number\n , medical_claims.claim_type\n , medical_claims.patient_id\n , medical_claims.claim_start_date\n , medical_claims.claim_end_date\n , medical_claims.bill_type_code\n , medical_claims.hcpcs_code\n from medical_claims\n inner join cpt_hcpcs_list\n on medical_claims.hcpcs_code = cpt_hcpcs_list.hcpcs_cpt_code\n where claim_type = 'institutional'\n \n and extract(year from claim_end_date) = 2023\n \n and cpt_hcpcs_list.payment_year = 2024\n and substring(bill_type_code, 1, 2) in ('12','13','43','71','73','76','77','85')\n\n)\n\n, eligible_claims as (\n\n select * from professional_claims\n union all\n select * from inpatient_claims\n union all\n select * from outpatient_claims\n\n)\n\n, eligible_conditions as (\n\n select distinct\n eligible_claims.claim_id\n , eligible_claims.patient_id\n , conditions.code\n from eligible_claims\n inner join conditions\n on eligible_claims.claim_id = conditions.claim_id\n and eligible_claims.patient_id = conditions.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(code as TEXT) as condition_code\n , cast('2024' as integer) as payment_year\n from eligible_conditions\n\n)\n\nselect\n patient_id\n , condition_code\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_eligible_conditions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.892490Z", "completed_at": "2024-10-25T14:34:45.920444Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.926404Z", "completed_at": "2024-10-25T14:34:45.926404Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03996133804321289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__patient_spend_with_service_categories", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__financial_pmpm__stg_medical_claim as (\n\n\n\nSELECT\n patient_id\n , claim_id\n , claim_line_number\n , claim_start_date\n , claim_end_date\n , service_category_1\n , service_category_2\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n), __dbt__cte__financial_pmpm__stg_pharmacy_claim as (\n\n\n\nSELECT\n patient_id\n , dispensing_date\n , paid_date\n , paid_amount\n , allowed_amount\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n), claims_with_service_categories as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , coalesce(claim_start_date,claim_end_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_medical_claim\n)\n\n, medical_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from claims_with_service_categories\n)\n\n, rx_claims as (\n select\n patient_id\n , payer\n , plan\n , 'pharmacy' as service_category_1\n , cast(null as TEXT) as service_category_2\n , coalesce(dispensing_date, paid_date) as claim_date\n , paid_amount\n , allowed_amount\n , data_source\n from __dbt__cte__financial_pmpm__stg_pharmacy_claim\n)\n\n, rx_claims_year_month as (\n select\n patient_id\n , payer\n , plan\n , service_category_1\n , service_category_2\n , date_part('year', claim_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '0' || date_part('month', claim_date),\n 2\n )\n end as year_month\n , paid_amount\n , allowed_amount\n , data_source\n from rx_claims\n)\n\n, combine_medical_and_rx as (\nselect *\nfrom medical_claims_year_month\n\nunion all\n\nselect *\nfrom rx_claims_year_month\n)\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , sum(paid_amount) as total_paid\n , sum(allowed_amount) as total_allowed\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n from combine_medical_and_rx\ngroup by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , service_category_2\n , data_source", "relation_name": "dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.921434Z", "completed_at": "2024-10-25T14:34:45.932487Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.934485Z", "completed_at": "2024-10-25T14:34:45.934485Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.018016338348388672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__claims_with_enrollment", "compiled": true, "compiled_code": "\n\nwith enrollment_stage as(\nSELECT\n mc.data_source,\n mc.year_month,\n SUM(CASE WHEN mm.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS claims_with_enrollment,\n COUNT(*) AS claims\nFROM dev_thuxuan.data_quality.mart_review__stg_medical_claim mc\nLEFT JOIN dev_thuxuan.core.member_months mm\n ON mc.patient_id = mm.patient_id\n AND mc.data_source = mm.data_source\n AND mc.year_month = mm.year_month\nGROUP BY mc.data_source\n, mc.year_month\n)\n\nselect\n data_source\n , year_month\n , claims_with_enrollment\n , claims\n , cast(claims_with_enrollment / claims as numeric(28,6) ) AS percentage_claims_with_enrollment\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom enrollment_stage", "relation_name": "dev_thuxuan.data_quality.mart_review__claims_with_enrollment"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.926404Z", "completed_at": "2024-10-25T14:34:45.934485Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.936497Z", "completed_at": "2024-10-25T14:34:45.936497Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.016052961349487305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__members_with_claims", "compiled": true, "compiled_code": "\n\nWITH medical_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM dev_thuxuan.data_quality.mart_review__stg_medical_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n\n,pharmacy_claim AS (\n SELECT\n data_source,\n patient_id,\n year_month,\n SUM(paid_amount) AS paid_amount\n FROM dev_thuxuan.data_quality.mart_review__stg_pharmacy_claim\n GROUP BY data_source\n , patient_id\n , year_month\n)\n, final as(\nSELECT\n mm.data_source,\n mm.year_month,\n SUM(CASE WHEN mc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_medical_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1 ELSE 0 END) AS members_with_pharmacy_claims,\n SUM(CASE WHEN pc.patient_id IS NOT NULL THEN 1\n WHEN mc.patient_id is not null THEN 1 ELSE 0 END) AS members_with_claims,\n COUNT(*) AS total_member_months\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM dev_thuxuan.core.member_months mm\nLEFT JOIN medical_claim mc\n ON mm.patient_id = mc.patient_id\n AND mm.data_source = mc.data_source\n AND mm.year_month = mc.year_month\nLEFT JOIN pharmacy_claim pc\n ON mm.patient_id = pc.patient_id\n AND mm.data_source = pc.data_source\n AND mm.year_month = pc.year_month\nGROUP BY mm.data_source, mm.year_month\n)\n\nselect\n data_source\n , year_month\n , members_with_medical_claims\n , members_with_pharmacy_claims\n , members_with_claims\n , total_member_months\n , cast(members_with_claims/ total_member_months as numeric(28,6)) as percent_members_with_claims\n , cast(members_with_medical_claims/ total_member_months as numeric(28,6)) as percent_members_with_medical_claims\n , cast(members_with_pharmacy_claims/ total_member_months as numeric(28,6)) as percent_members_with_pharmacy_claims\nfrom final", "relation_name": "dev_thuxuan.data_quality.mart_review__members_with_claims"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.937504Z", "completed_at": "2024-10-25T14:34:45.978668Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:45.982675Z", "completed_at": "2024-10-25T14:34:45.982675Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.05027008056640625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclude_colectomy_cancer", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatients with a diagnosis or past history of total colectomy or colorectal cancer: G9711\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n From dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'malignant neoplasm of colon'\n , 'total colectomy'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for historical record of colectomy cancer' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom patients_with_exclusions", "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_exclude_colectomy_cancer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.985013Z", "completed_at": "2024-10-25T14:34:46.059601Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.062995Z", "completed_at": "2024-10-25T14:34:46.062995Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.08567953109741211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_frailty", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'frailty device'\n , 'frailty diagnosis'\n , 'frailty encounter'\n , 'frailty symptom'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_frailty as (\n\n select\n patients.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from patients\n inner join condition_exclusions\n on patients.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , med_claim_exclusions.concept_name as exclusion_reason\n from patients\n inner join med_claim_exclusions\n on patients.patient_id = med_claim_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from patients\n inner join observation_exclusions\n on patients.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n patients.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from patients\n inner join procedure_exclusions\n on patients.patient_id = procedure_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom patients_with_frailty", "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_frailty"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.020115Z", "completed_at": "2024-10-25T14:34:46.062995Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.083371Z", "completed_at": "2024-10-25T14:34:46.083371Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.10470271110534668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_hospice_palliative", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR EXCLUSIONS:\nPatient was provided hospice services any time during the measurement period: G9687\n*/\n\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n From dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n , 'palliative care encounter'\n , 'palliative care diagnosis'\n , 'palliative care intervention'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition \n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, patients_with_exclusions as(\n \n select patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'hospice_palliative' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom patients_with_exclusions", "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.072388Z", "completed_at": "2024-10-25T14:34:46.091374Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.095374Z", "completed_at": "2024-10-25T14:34:46.095374Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03729748725891113, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_institutional_snp", "compiled": true, "compiled_code": "\n\n/*\n patients in institutional special needs plans (snp)\n or residing in long term care\n\n while referencing this model, patients greater or equal than 66 years of age should be taken\n\n filtering out age from this model has been stripped out as different measures calculate age varingly\n\n future enhancement: group claims into encounters\n*/\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), patients as (\n\n select\n patient_id\n from __dbt__cte___stg_patient\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, exclusions as (\n\n select\n patients.patient_id\n , coalesce(\n medical_claim.claim_start_date\n , medical_claim.claim_end_date\n ) as exclusion_date\n , 'institutional or long term care' as exclusion_reason\n from patients\n inner join medical_claim\n on patients.patient_id = medical_claim.patient_id\n where place_of_service_code in ('32', '33', '34', '54', '56')\n and datediff(\n day,\n medical_claim.claim_start_date,\n medical_claim.claim_end_date\n ) >= 90\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'institutional_snp' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions", "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.098372Z", "completed_at": "2024-10-25T14:34:46.112372Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.114372Z", "completed_at": "2024-10-25T14:34:46.114372Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02200007438659668, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__location_location_id.dc12ec8d3a", "compiled": true, "compiled_code": "\n \n \n\nselect\n location_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.location\nwhere location_id is not null\ngroup by location_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.104389Z", "completed_at": "2024-10-25T14:34:46.113372Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.120373Z", "completed_at": "2024-10-25T14:34:46.120373Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026000261306762695, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__pharmacy", "compiled": true, "compiled_code": "\n\nselect\n p.claim_id\n , p.claim_line_number\n , p.patient_id\n , p.data_source\n , p.patient_id || '|' || p.data_source as patient_source_key\n , p.ndc_code\n , coalesce(n.fda_description, n.rxnorm_description) as ndc_description\n , p.paid_amount\n , p.allowed_amount\n , p.prescribing_provider_id\n , p.prescribing_provider_name\n , prac.specialty as prescribing_specialty\n , p.dispensing_provider_id\n , p.dispensing_provider_name\n , p.paid_date\n , p.dispensing_date\n , p.days_supply\n , p.paid_amount / p.days_supply as cost_per_day\n , (p.paid_amount / p.days_supply) * 30 as thirty_day_equivalent_cost\n , case \n when (p.paid_amount / p.days_supply) * 30 >= 950 then 1 \n else 0 \n end as specialty_tier -- $950 is the threshold set by CMS for CY 2024\n , n.rxcui\n , n.rxnorm_description\n , r.brand_name\n , r.brand_vs_generic\n , r.ingredient_name\n , a.atc_1_name\n , a.atc_2_name\n , a.atc_3_name\n , a.atc_4_name\n , pe.generic_available_total_opportunity\n , pe.generic_average_cost_per_unit * p.quantity as generic_cost_at_units\n , pe.brand_cost_per_unit * p.quantity as brand_paid_amount\n , pe.generic_available\n , pe.generic_available_sk\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim as p\nleft join dev_thuxuan.terminology.ndc as n \n on p.ndc_code = n.ndc\nleft join dev_thuxuan.terminology.rxnorm_brand_generic as r \n on n.rxcui = r.product_rxcui\nleft join dev_thuxuan.terminology.rxnorm_to_atc as a \n on n.rxcui = a.rxcui\nleft join dev_thuxuan.core.practitioner as prac \n on p.prescribing_provider_id = prac.practitioner_id\nleft join dev_thuxuan.pharmacy.pharmacy_claim_expanded as pe \n on p.data_source = pe.data_source\n and p.claim_id = pe.claim_id\n and p.claim_line_number = pe.claim_line_number", "relation_name": "dev_thuxuan.data_quality.mart_review__pharmacy"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.114372Z", "completed_at": "2024-10-25T14:34:46.123380Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.126375Z", "completed_at": "2024-10-25T14:34:46.126375Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.014999151229858398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__practitioner_practitioner_id.24d565a6b6", "compiled": true, "compiled_code": "\n \n \n\nselect\n practitioner_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.practitioner\nwhere practitioner_id is not null\ngroup by practitioner_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.128373Z", "completed_at": "2024-10-25T14:34:46.143211Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.150085Z", "completed_at": "2024-10-25T14:34:46.150085Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.025712966918945312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_patient_hcc_history", "compiled": true, "compiled_code": "\n\nwith all_conditions as (\n\n select\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._int_all_conditions\n where hcc_code is not null\n\n)\n\n, hcc_grouped as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , min(recorded_date) as first_recorded\n , max(recorded_date) as last_recorded\n from all_conditions\n where hcc_code is not null\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, hcc_billed as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , max(recorded_date) as last_billed\n from all_conditions\n where hcc_code is not null\n and lower(condition_type) <> 'problem'\n group by\n patient_id\n , hcc_code\n , hcc_description\n , data_source\n\n)\n\n, add_flag as (\n\n select\n hcc_grouped.patient_id\n , hcc_grouped.data_source\n , hcc_grouped.hcc_code\n , hcc_grouped.hcc_description\n , hcc_grouped.first_recorded\n , hcc_grouped.last_recorded\n , hcc_billed.last_billed\n , case\n when date_part('year', hcc_billed.last_billed) = date_part('year', convert_timezone('UTC', current_timestamp()))\n then 1\n else 0\n end as current_year_billed\n\n from hcc_grouped\n left join hcc_billed\n on hcc_grouped.patient_id = hcc_billed.patient_id\n and hcc_grouped.hcc_code = hcc_billed.hcc_code\n and hcc_grouped.data_source = hcc_billed.data_source\n\n)\n\n, all_conditions_with_flag as (\n\n select distinct\n all_conditions.patient_id\n , all_conditions.data_source\n , all_conditions.recorded_date\n , all_conditions.condition_type\n , all_conditions.icd_10_cm_code\n , all_conditions.hcc_code\n , all_conditions.hcc_description\n , add_flag.first_recorded\n , add_flag.last_recorded\n , add_flag.last_billed\n , add_flag.current_year_billed\n , cast('Prior coding history' as TEXT) as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as condition_date\n from all_conditions\n left join add_flag\n on all_conditions.patient_id = add_flag.patient_id\n and all_conditions.hcc_code = add_flag.hcc_code\n and all_conditions.data_source = add_flag.data_source\n\n)\n\n, add_standard_fields as (\n\n select distinct\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , 'Prior coding history' as reason\n , icd_10_cm_code || case when last_billed is not null then ' last billed on ' || last_billed when last_billed is null and last_recorded is not null then ' last recorded on ' || last_recorded else ' (missing recorded and billing dates) ' end as contributing_factor\n , coalesce(last_billed, last_recorded) as suspect_date\n from all_conditions_with_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(recorded_date as date) as recorded_date\n , cast(condition_type as TEXT) as condition_type\n , cast(icd_10_cm_code as TEXT) as icd_10_cm_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(first_recorded as date) as first_recorded\n , cast(last_recorded as date) as last_recorded\n , cast(last_billed as date) as last_billed\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , recorded_date\n , condition_type\n , icd_10_cm_code\n , hcc_code\n , hcc_description\n , first_recorded\n , last_recorded\n , last_billed\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_patient_hcc_history"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.137373Z", "completed_at": "2024-10-25T14:34:46.149075Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.150085Z", "completed_at": "2024-10-25T14:34:46.150085Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02570796012878418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__tuva_chronic_conditions_wide_patient_id.705b1ca561", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.144216Z", "completed_at": "2024-10-25T14:34:46.152079Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.154079Z", "completed_at": "2024-10-25T14:34:46.154079Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.012352943420410156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_chronic_conditions__tuva_chronic_conditions_wide_patient_id.02386b9158", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.chronic_conditions.tuva_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:33.662732Z", "completed_at": "2024-10-25T14:34:46.062995Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.084376Z", "completed_at": "2024-10-25T14:34:46.084376Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 12.54474425315857, "adapter_response": {}, "message": null, "failures": null, "unique_id": "operation.the_tuva_project.the_tuva_project-on-run-end-0", "compiled": true, "compiled_code": "\n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.156080Z", "completed_at": "2024-10-25T14:34:46.211600Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.218599Z", "completed_at": "2024-10-25T14:34:46.218599Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.06551766395568848, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_oud", "compiled": true, "compiled_code": "with __dbt__cte__cms_chronic_conditions__stg_core__condition as (\n\n\nselect\n claim_id\n , patient_id\n , recorded_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\nwhere claim_id is not null\n), __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim as (\n\n\nselect\n claim_id\n , patient_id\n , paid_date\n , ndc_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n), __dbt__cte__cms_chronic_conditions__stg_core__procedure as (\n\n\nselect\n claim_id\n , patient_id\n , procedure_date\n , normalized_code_type\n , normalized_code\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\nwhere claim_id is not null\n), chronic_conditions as (\n\n select * from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n where condition = 'Opioid Use Disorder (OUD)'\n\n)\n\n, patient_conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__condition\n\n)\n\n, patient_medications as (\n\n select\n patient_id\n , claim_id\n , paid_date as start_date\n , replace(ndc_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__pharmacy_claim\n\n)\n\n, patient_procedures as (\n\n select\n patient_id\n , claim_id\n , procedure_date as start_date\n , normalized_code_type as code_type\n , replace(normalized_code,'.','') as code\n , data_source\n from __dbt__cte__cms_chronic_conditions__stg_core__procedure\n\n)\n\n, inclusions_diagnosis as (\n\n select\n patient_conditions.patient_id\n , patient_conditions.claim_id\n , patient_conditions.start_date\n , patient_conditions.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_conditions\n inner join chronic_conditions\n on patient_conditions.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'ICD-10-CM'\n\n)\n\n, inclusions_procedure as (\n\n select\n patient_procedures.patient_id\n , patient_procedures.claim_id\n , patient_procedures.start_date\n , patient_procedures.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_procedures\n inner join chronic_conditions\n on patient_procedures.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system in ('ICD-10-PCS', 'HCPCS')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE excludes medication encounters with the exception codes for\n Naltrexone. Those encounters will be evaluated separately.\n*/\n, inclusions_medication as (\n\n select\n patient_medications.patient_id\n , patient_medications.claim_id\n , patient_medications.start_date\n , patient_medications.data_source\n , chronic_conditions.chronic_condition_type\n , chronic_conditions.condition_category\n , chronic_conditions.condition\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code not in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE includes patients with evidence of the chronic conditions Alcohol\n Use Disorders or Drug Use Disorders.\n*/\n, exclusions_other_chronic_conditions as (\n\n select distinct patient_id\n from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\n where condition in (\n 'Alcohol Use Disorders'\n , 'Drug Use Disorders'\n )\n\n)\n\n/*\n Exclusion logic: Naltrexone NDCs are excluded if there is evidence of an\n alcohol or other drug use disorder where opioid DX is not present\n\n This CTE creates the exclusion list which consists of patients with\n medication encounters for Naltrexone having Alcohol Use Disorder or Drug\n Use Disorder and missing the Opioid Use Disorder diagnosis codes.\n*/\n, exclusions_medication as (\n select distinct\n patient_medications.patient_id\n from patient_medications\n inner join chronic_conditions\n on patient_medications.code = chronic_conditions.code\n inner join exclusions_other_chronic_conditions\n on patient_medications.patient_id = exclusions_other_chronic_conditions.patient_id\n left join inclusions_diagnosis\n on patient_medications.patient_id = inclusions_diagnosis.patient_id\n where chronic_conditions.inclusion_type = 'Include'\n and chronic_conditions.code_system = 'NDC'\n and chronic_conditions.code in ('00056001122', '00056001130', '00056001170', '00056007950', '00056008050', '00185003901', '00185003930', '00406009201', '00406009203', '00406117001', '00406117003', '00555090201', '00555090202', '00904703604', '16729008101', '16729008110', '42291063230', '43063059115', '47335032683', '47335032688', '50090286600', '50436010501', '51224020630', '51224020650', '51285027501', '51285027502', '52152010502', '52152010504', '52152010530', '54868557400', '63459030042', '63629104601', '63629104701', '65694010003', '65694010010', '65757030001', '65757030202', '68084029111', '68084029121', '68094085362', '68115068030')\n and inclusions_diagnosis.patient_id is null\n\n)\n\n\n, inclusions_unioned as (\n\n select * from inclusions_diagnosis\n union distinct\n select * from inclusions_procedure\n union distinct\n select * from inclusions_medication\n\n)\n\n\nselect distinct\n cast(inclusions_unioned.patient_id as TEXT) as patient_id\n , cast(inclusions_unioned.claim_id as TEXT) as claim_id\n , cast(inclusions_unioned.start_date as date) as start_date\n , cast(inclusions_unioned.chronic_condition_type as TEXT) as chronic_condition_type\n , cast(inclusions_unioned.condition_category as TEXT) as condition_category\n , cast(inclusions_unioned.condition as TEXT) as condition\n , cast(inclusions_unioned.data_source as TEXT) as data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom inclusions_unioned\n left join exclusions_medication\n on inclusions_unioned.patient_id = exclusions_medication.patient_id\nwhere exclusions_medication.patient_id is null", "relation_name": "dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.200601Z", "completed_at": "2024-10-25T14:34:46.217599Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.221597Z", "completed_at": "2024-10-25T14:34:46.221597Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.06751799583435059, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_claim_id.84015aec48", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.213598Z", "completed_at": "2024-10-25T14:34:46.222597Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.225598Z", "completed_at": "2024-10-25T14:34:46.225598Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0269777774810791, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_condition.bb780b4840", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.225598Z", "completed_at": "2024-10-25T14:34:46.240614Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.247641Z", "completed_at": "2024-10-25T14:34:46.247641Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.028043031692504883, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_all_patient_id.95fc066008", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.234600Z", "completed_at": "2024-10-25T14:34:46.248670Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.256648Z", "completed_at": "2024-10-25T14:34:46.256648Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03203916549682617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_hiv_aids_condition__Human_Immunodeficiency_Virus_and_or_Acquired_Immunodeficiency_Syndrome_HIV_AIDS_.c54d45a2c6", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Human Immunodeficiency Virus and/or Acquired Immunodeficiency Syndrome (HIV/AIDS)'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.241600Z", "completed_at": "2024-10-25T14:34:46.255663Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.257678Z", "completed_at": "2024-10-25T14:34:46.257678Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027044296264648438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_claim_id.9baa48027d", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.250646Z", "completed_at": "2024-10-25T14:34:46.258648Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.261159Z", "completed_at": "2024-10-25T14:34:46.261159Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02054452896118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_condition.da32954f00", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.262755Z", "completed_at": "2024-10-25T14:34:46.277778Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.283768Z", "completed_at": "2024-10-25T14:34:46.283768Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.026090383529663086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_hiv_aids_patient_id.b6c58add4b", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.268769Z", "completed_at": "2024-10-25T14:34:46.285766Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.304334Z", "completed_at": "2024-10-25T14:34:46.304334Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04317593574523926, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_mapping", "compiled": true, "compiled_code": "\n/*\nSteps for staging the medical claim data:\n 1) Filter to risk-adjustable claims per claim type for the collection year.\n 2) Gather diagnosis codes from Condition for the eligible claims.\n 3) Map and filter diagnosis codes to HCCs for each CMS model version\n 4) Union results from each CMS model version\n (note: some payment years may not have results for v28)\n*/\n\nwith conditions as (\n\n select\n patient_id\n , condition_code\n , payment_year\n from dev_thuxuan.cms_hcc._int_eligible_conditions\n\n)\n\n, seed_hcc_mapping as (\n\n select\n payment_year\n , diagnosis_code\n , cms_hcc_v24\n , cms_hcc_v24_flag\n , cms_hcc_v28\n , cms_hcc_v28_flag\n from dev_thuxuan.cms_hcc._value_set_icd_10_cm_mappings\n\n)\n\n/* casting hcc_code to avoid formatting changes during union */\n, v24_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V24' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v24 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v24_flag = 'Yes'\n\n)\n\n, v28_mapped as (\n\n select distinct\n conditions.patient_id\n , conditions.condition_code\n , conditions.payment_year\n , 'CMS-HCC-V28' as model_version\n , cast(seed_hcc_mapping.cms_hcc_v28 as TEXT) as hcc_code\n from conditions\n inner join seed_hcc_mapping\n on conditions.condition_code = seed_hcc_mapping.diagnosis_code\n and conditions.payment_year = seed_hcc_mapping.payment_year\n where cms_hcc_v28_flag = 'Yes'\n\n)\n\n, unioned as (\n\n select * from v24_mapped\n union all\n select * from v28_mapped\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(condition_code as TEXT) as condition_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from unioned\n\n)\n\nselect\n patient_id\n , condition_code\n , hcc_code\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_hcc_mapping"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.279762Z", "completed_at": "2024-10-25T14:34:46.286762Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.305530Z", "completed_at": "2024-10-25T14:34:46.305530Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03876519203186035, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_cms_hcc__int_eligible_conditions_condition_code.e811a078bc", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition_code\nfrom dev_thuxuan.cms_hcc._int_eligible_conditions\nwhere condition_code is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.287760Z", "completed_at": "2024-10-25T14:34:46.312570Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.314549Z", "completed_at": "2024-10-25T14:34:46.314549Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03478717803955078, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_allowed_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_allowed) as total_allowed\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_allowed\n else 0\n end\n )\n \n \n as ancillary_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_1_allowed_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.315549Z", "completed_at": "2024-10-25T14:34:46.334845Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.345933Z", "completed_at": "2024-10-25T14:34:46.345933Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.040926218032836914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_1_paid_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_1 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n , sum(total_paid) as total_paid\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_1\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_1 = 'inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'outpatient'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'office-based'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'ancillary'\n then total_paid\n else 0\n end\n )\n \n \n as ancillary_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_1 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_1\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_1_paid_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.324604Z", "completed_at": "2024-10-25T14:34:46.347234Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.399892Z", "completed_at": "2024-10-25T14:34:46.399892Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.08634257316589355, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_allowed_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_allowed) as total_allowed\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_allowed\n else 0\n end\n )\n \n \n as acute_inpatient_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulance_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_allowed\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_allowed\n else 0\n end\n )\n \n \n as dialysis_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_allowed\n else 0\n end\n )\n \n \n as durable_medical_equipment_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_allowed\n else 0\n end\n )\n \n \n as emergency_department_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_allowed\n else 0\n end\n )\n \n \n as home_health_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_allowed\n else 0\n end\n )\n \n \n as lab_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_allowed\n else 0\n end\n )\n \n \n as observation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_allowed\n else 0\n end\n )\n \n \n as office_based_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_allowed\n else 0\n end\n )\n \n \n as other_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospice_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_ptotst_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_psychiatric_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_radiology_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_allowed\n else 0\n end\n )\n \n \n as outpatient_surgery_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_allowed\n else 0\n end\n )\n \n \n as pharmacy_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_allowed\n else 0\n end\n )\n \n \n as skilled_nursing_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_allowed\n else 0\n end\n )\n \n \n as telehealth_visit_allowed\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_allowed\n else 0\n end\n )\n \n \n as urgent_care_allowed\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_2_allowed_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.335835Z", "completed_at": "2024-10-25T14:34:46.348255Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.401889Z", "completed_at": "2024-10-25T14:34:46.401889Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.0803232192993164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__service_category_2_paid_pivot", "compiled": true, "compiled_code": "\n\nwith service_cat_2 as (\n select\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n , sum(total_paid) as total_paid\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories\n group by\n patient_id\n , year_month\n , payer\n , plan\n , service_category_2\n , data_source\n)\n\nselect\n patient_id\n, year_month\n, payer\n, plan\n, data_source\n, \n \n sum(\n \n case\n when service_category_2 = 'acute inpatient'\n then total_paid\n else 0\n end\n )\n \n \n as acute_inpatient_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulance'\n then total_paid\n else 0\n end\n )\n \n \n as ambulance_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'ambulatory surgery center'\n then total_paid\n else 0\n end\n )\n \n \n as ambulatory_surgery_center_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'dialysis'\n then total_paid\n else 0\n end\n )\n \n \n as dialysis_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'durable medical equipment'\n then total_paid\n else 0\n end\n )\n \n \n as durable_medical_equipment_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'emergency department'\n then total_paid\n else 0\n end\n )\n \n \n as emergency_department_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'home health'\n then total_paid\n else 0\n end\n )\n \n \n as home_health_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'inpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as inpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'lab'\n then total_paid\n else 0\n end\n )\n \n \n as lab_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'observation'\n then total_paid\n else 0\n end\n )\n \n \n as observation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based other'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based radiology'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based surgery'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'office-based visit'\n then total_paid\n else 0\n end\n )\n \n \n as office_based_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'other'\n then total_paid\n else 0\n end\n )\n \n \n as other_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospice'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospice_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient hospital or clinic'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_hospital_or_clinic_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient pt/ot/st'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_ptotst_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient psychiatric'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_psychiatric_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient radiology'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_radiology_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient rehabilitation'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_rehabilitation_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'outpatient surgery'\n then total_paid\n else 0\n end\n )\n \n \n as outpatient_surgery_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'pharmacy'\n then total_paid\n else 0\n end\n )\n \n \n as pharmacy_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'skilled nursing'\n then total_paid\n else 0\n end\n )\n \n \n as skilled_nursing_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'telehealth visit'\n then total_paid\n else 0\n end\n )\n \n \n as telehealth_visit_paid\n \n \n ,\n \n sum(\n \n case\n when service_category_2 = 'urgent care'\n then total_paid\n else 0\n end\n )\n \n \n as urgent_care_paid\n \n \n \n \n\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom service_cat_2\ngroup by\n patient_id\n, year_month\n, payer\n, plan\n, data_source", "relation_name": "dev_thuxuan.financial_pmpm._int_service_category_2_paid_pivot"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.348255Z", "completed_at": "2024-10-25T14:34:46.403881Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.429298Z", "completed_at": "2024-10-25T14:34:46.429298Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0944528579711914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_advanced_illness", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'advanced illness'\n , 'acute inpatient'\n , 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n where lower(exclusion_codes.concept_name) = 'advanced illness'\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, acute_inpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) = 'acute inpatient'\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) = 'acute inpatient'\n\n)\n\n, nonacute_outpatient as (\n\n select distinct\n patients_with_frailty.patient_id\n , coalesce(\n med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n ) as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || med_claim_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , med_claim_exclusions.claim_start_date\n , med_claim_exclusions.claim_end_date\n , cast(null as date) as procedure_date\n from patients_with_frailty\n inner join med_claim_exclusions\n on patients_with_frailty.patient_id = med_claim_exclusions.patient_id\n inner join condition_exclusions\n on med_claim_exclusions.claim_id = condition_exclusions.claim_id\n where lower(med_claim_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n union all\n\n select distinct\n patients_with_frailty.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || procedure_exclusions.concept_name || ' and ' || condition_exclusions.concept_name as exclusion_reason\n , cast(null as date) as claim_start_date\n , cast(null as date) as claim_end_date\n , procedure_exclusions.procedure_date\n from patients_with_frailty\n inner join procedure_exclusions\n on patients_with_frailty.patient_id = procedure_exclusions.patient_id\n inner join condition_exclusions\n on procedure_exclusions.patient_id = condition_exclusions.patient_id\n and procedure_exclusions.procedure_date = condition_exclusions.recorded_date\n where lower(procedure_exclusions.concept_name) in (\n 'encounter inpatient'\n , 'outpatient'\n , 'observation'\n , 'emergency department visit'\n , 'nonacute inpatient'\n )\n\n)\n\n, exclusions_unioned as (\n\n select\n acute_inpatient.patient_id\n , acute_inpatient.exclusion_date\n , acute_inpatient.exclusion_reason\n , acute_inpatient.claim_start_date\n , acute_inpatient.claim_end_date\n , acute_inpatient.procedure_date\n , 'acute_inpatient' as patient_type\n from acute_inpatient\n\n union all\n\n select\n nonacute_outpatient.patient_id\n , nonacute_outpatient.exclusion_date\n , nonacute_outpatient.exclusion_reason\n , nonacute_outpatient.claim_start_date\n , nonacute_outpatient.claim_end_date\n , nonacute_outpatient.procedure_date\n , 'nonacute_outpatient' as patient_type\n from nonacute_outpatient\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'advanced_illness' as exclusion_type\n , claim_start_date\n , claim_end_date\n , procedure_date\n , patient_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions_unioned", "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.405876Z", "completed_at": "2024-10-25T14:34:46.438355Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.580821Z", "completed_at": "2024-10-25T14:34:46.580821Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.1799311637878418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_shared_exclusions_dementia", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), patients_with_frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dementia medications'\n )\n\n)\n\n, medications as (\n\n select\n patient_id\n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claim as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n , paid_date\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.rxnorm_code = exclusion_codes.code\n where exclusion_codes.code_system = 'rxnorm'\n\n union all\n\n select\n medications.patient_id\n , medications.dispensing_date\n , exclusion_codes.concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claim_exclusions as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date\n , pharmacy_claim.ndc_code\n , pharmacy_claim.paid_date\n , exclusion_codes.concept_name\n from pharmacy_claim\n inner join exclusion_codes\n on pharmacy_claim.ndc_code = exclusion_codes.code\n where exclusion_codes.code_system = 'ndc'\n\n)\n\n, frailty_with_dementia as (\n\n select\n patients_with_frailty.patient_id\n , patients_with_frailty.exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || pharmacy_claim_exclusions.concept_name as exclusion_reason\n , pharmacy_claim_exclusions.dispensing_date\n , pharmacy_claim_exclusions.paid_date\n from patients_with_frailty\n inner join pharmacy_claim_exclusions\n on patients_with_frailty.patient_id = pharmacy_claim_exclusions.patient_id\n\n union all\n\n select\n patients_with_frailty.patient_id\n , medication_exclusions.dispensing_date as exclusion_date\n , patients_with_frailty.exclusion_reason || ' with ' || medication_exclusions.concept_name as exclusion_reason\n , medication_exclusions.dispensing_date\n , null as paid_date\n from patients_with_frailty\n inner join medication_exclusions\n on patients_with_frailty.patient_id = medication_exclusions.patient_id\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'dementia' as exclusion_type\n , dispensing_date\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom frailty_with_dementia", "relation_name": "dev_thuxuan.quality_measures._int_shared_exclusions_dementia"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.438355Z", "completed_at": "2024-10-25T14:34:46.603885Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.605887Z", "completed_at": "2024-10-25T14:34:46.605887Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.2000114917755127, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pqa esrd'\n , 'pqa insulin medications'\n )\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adh_diabetes__performance_period\n\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date as exclusion_date\n , exclusion_codes.concept_name as exclusion_reason\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_exclusions as (\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and exclusion_codes.code_system = 'ndc'\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from pharmacy_exclusions\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.580821Z", "completed_at": "2024-10-25T14:34:46.606887Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.617886Z", "completed_at": "2024-10-25T14:34:46.617886Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.18789100646972656, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), denominator as (\n\n select\n patient_id\n from dev_thuxuan.quality_measures._int_adhras_denominator\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name in (\n 'PQA ESRD'\n , 'PQA Sacubitril Valsartan Medications'\n )\n\n)\n\n, valid_esrd as (\n\n select\n condition.patient_id\n , condition.recorded_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_condition as condition\n inner join codes \n on coalesce(condition.normalized_code, condition.source_code) = codes.code \n and coalesce(condition.normalized_code_type, condition.source_code_type) = codes.code_system\n where condition.recorded_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, sacubitril_pharmacy_claim as (\n\n select\n pharmacy_claim.patient_id\n , pharmacy_claim.dispensing_date as exclusion_date\n , codes.concept_name as exclusion_reason\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claim\n inner join codes\n on pharmacy_claim.ndc_code = codes.code \n where pharmacy_claim.dispensing_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_adhras__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_esrd\n\n union all\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason \n from sacubitril_pharmacy_claim\n\n)\n\n, measure_exclusions as (\n\n select \n exclusions.patient_id\n , exclusion_date\n , exclusion_reason\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from measure_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run \nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adhras_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.606887Z", "completed_at": "2024-10-25T14:34:46.618886Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.627885Z", "completed_at": "2024-10-25T14:34:46.627885Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.04804086685180664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_comorbidity_suspects", "compiled": true, "compiled_code": "\n\nwith conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from dev_thuxuan.hcc_suspecting._int_prep_conditions\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 37 logic */\n, ckd_stage_1_or_2 as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) in (\n 'chronic kidney disease, stage 1'\n , 'chronic kidney disease, stage 2'\n )\n\n)\n\n, ckd_stage_1_or_2_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from ckd_stage_1_or_2\n where row_num = 1\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n , row_number() over (\n partition by\n conditions.patient_id\n , conditions.data_source\n order by\n conditions.recorded_date desc\n , conditions.code desc\n ) as row_num\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n)\n\n, diabetes_dedupe as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n , concept_name\n from diabetes\n where row_num = 1\n\n)\n\n, hcc_37_suspect as (\n\n select\n diabetes_dedupe.patient_id\n , diabetes_dedupe.data_source\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , diabetes_dedupe.concept_name as condition_1_concept_name\n , diabetes_dedupe.code as condition_1_code\n , diabetes_dedupe.recorded_date as condition_1_recorded_date\n , ckd_stage_1_or_2_dedupe.concept_name as condition_2_concept_name\n , ckd_stage_1_or_2_dedupe.code as condition_2_code\n , ckd_stage_1_or_2_dedupe.recorded_date as condition_2_recorded_date\n from diabetes_dedupe\n inner join ckd_stage_1_or_2_dedupe\n on diabetes_dedupe.patient_id = ckd_stage_1_or_2_dedupe.patient_id\n and diabetes_dedupe.data_source = ckd_stage_1_or_2_dedupe.data_source\n /* ensure conditions overlap in the same year */\n and date_part('year', diabetes_dedupe.recorded_date) = date_part('year', ckd_stage_1_or_2_dedupe.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '37'\n\n)\n/* END HCC 37 logic */\n\n, unioned as (\n\n select * from hcc_37_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.condition_1_concept_name\n , unioned.condition_1_code\n , unioned.condition_1_recorded_date\n , unioned.condition_2_concept_name\n , unioned.condition_2_code\n , unioned.condition_2_recorded_date\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , cast('Comorbidity suspect' as TEXT) as reason\n , condition_1_concept_name || ' (' || condition_1_code || ') on ' || condition_1_recorded_date || ') and ' || condition_2_concept_name || ' (' || condition_2_code || ') on ' || condition_2_recorded_date as contributing_factor\n , condition_1_recorded_date as suspect_date\n from add_billed_flag\n\n)\n\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(condition_1_concept_name as TEXT) as condition_1_concept_name\n , cast(condition_1_code as TEXT) as condition_1_code\n , cast(condition_1_recorded_date as date) as condition_1_recorded_date\n , cast(condition_2_concept_name as TEXT) as condition_2_concept_name\n , cast(condition_2_code as TEXT) as condition_2_code\n , cast(condition_2_recorded_date as date) as condition_2_recorded_date\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , condition_1_concept_name\n , condition_1_code\n , condition_1_recorded_date\n , condition_2_concept_name\n , condition_2_code\n , condition_2_recorded_date\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_comorbidity_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.619886Z", "completed_at": "2024-10-25T14:34:46.629887Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.638885Z", "completed_at": "2024-10-25T14:34:46.638885Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.021998882293701172, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_lab_suspects", "compiled": true, "compiled_code": "\n\nwith egfr_labs as (\n\n select\n patient_id\n , data_source\n , code_type\n , code\n , result_date\n , result\n from dev_thuxuan.hcc_suspecting._int_prep_egfr_labs\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN CKD logic */\n\n/*\n Find a patient\u2019s two most recent eGFR lab results that are spaced by at\n least 90 days.\n*/\n, max_lab_date as (\n\n select\n patient_id\n , data_source\n , max(result_date) as max_result_date\n from egfr_labs\n group by\n patient_id\n , data_source\n\n)\n\n, lab_lookback as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n , max(egfr_labs.result_date) as lookback_result_date\n from egfr_labs\n left join max_lab_date\n on egfr_labs.patient_id = max_lab_date.patient_id\n and egfr_labs.data_source = max_lab_date.data_source\n where egfr_labs.result_date <= \n\n dateadd(\n day,\n -90,\n max_result_date\n )\n\n\n group by\n egfr_labs.patient_id\n , egfr_labs.data_source\n , max_lab_date.max_result_date\n\n)\n\n/*\n Take the highest eGFR result that occurred between the date range.\n*/\n, eligible_labs as (\n\n select\n egfr_labs.patient_id\n , egfr_labs.data_source\n , egfr_labs.code_type\n , egfr_labs.code\n , egfr_labs.result_date\n , egfr_labs.result\n , row_number() over (\n partition by\n egfr_labs.patient_id\n , egfr_labs.data_source\n order by egfr_labs.result desc\n ) as row_num\n from egfr_labs\n inner join lab_lookback\n on egfr_labs.patient_id = lab_lookback.patient_id\n and egfr_labs.data_source = lab_lookback.data_source\n where egfr_labs.result_date >= lab_lookback.lookback_result_date\n\n)\n\n/*\n Assign a patient's kidney disease stage based on the highest eGFR based on\n the following range:\n\n CKD 3a: eGFR in the range (45-59)\n CKD 3b: eGFR in the range (30-44)\n CKD 4: eGFR in the range (15-29)\n CKD 5: eGFR in the range (0-14)\n*/\n, ckd_suspects as (\n\n select\n patient_id\n , data_source\n , code_type\n , code as lab_code\n , result_date\n , result\n , case\n when result between 0 and 14 then '326'\n when result between 15 and 29 then '327'\n when result between 30 and 44 then '328'\n when result between 45 and 59 then '329'\n end as hcc_code\n , 'eGFR (' || code || ') result ' || result || ' on ' || result_date as contributing_factor\n from eligible_labs\n where row_num = 1\n\n)\n/* END CKD logic */\n\n, unioned as (\n\n select * from ckd_suspects\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.result_date\n , unioned.result\n , unioned.lab_code\n , unioned.hcc_code\n , unioned.contributing_factor\n , seed_hcc_descriptions.hcc_description\n , billed_hccs.current_year_billed\n from unioned\n inner join seed_hcc_descriptions\n on unioned.hcc_code = seed_hcc_descriptions.hcc_code\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Lab result suspect' as TEXT) as reason\n , result_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(result_date as date) as result_date\n , cast(result as numeric(28,6)) as result\n , cast(lab_code as TEXT) as lab_code\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , result_date\n , result\n , lab_code\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_lab_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.629887Z", "completed_at": "2024-10-25T14:34:46.669398Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.739659Z", "completed_at": "2024-10-25T14:34:46.739659Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.1207733154296875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_medication_suspects", "compiled": true, "compiled_code": "\n\nwith all_medications as (\n\n select\n patient_id\n , dispensing_date\n , drug_code\n , code_system\n , data_source\n from dev_thuxuan.hcc_suspecting._int_all_medications\n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n antidepressant medication taken within the past five years\n*/\n, hcc_155_suspect as (\n\n select\n all_medications.patient_id\n , all_medications.dispensing_date\n , all_medications.drug_code\n , all_medications.code_system\n , all_medications.data_source\n , seed_clinical_concepts.concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from all_medications\n inner join seed_clinical_concepts\n on all_medications.code_system = seed_clinical_concepts.code_system\n and all_medications.drug_code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where lower(seed_clinical_concepts.concept_name) = 'antidepressant medication'\n and all_medications.dispensing_date >= \n\n dateadd(\n year,\n -5,\n convert_timezone('UTC', current_timestamp())\n )\n\n\n\n)\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.concept_name\n , unioned.dispensing_date\n , unioned.drug_code\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , cast('Medication suspect' as TEXT) as reason\n , concept_name || drug_code || ') dispensed on ' || dispensing_date as contributing_factor\n , dispensing_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(dispensing_date as date) as dispensing_date\n , cast(drug_code as TEXT) as drug_code\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , dispensing_date\n , drug_code\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_medication_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.733657Z", "completed_at": "2024-10-25T14:34:46.747666Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.756665Z", "completed_at": "2024-10-25T14:34:46.756665Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.11877751350402832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_long", "compiled": true, "compiled_code": "\n\n\nwith conditions_unioned as (\n\n select * from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_all\n union distinct\n select * from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_hiv_aids\n union distinct\n select * from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\n\n)\n\n\nselect\n patient_id\n , claim_id\n , start_date\n , chronic_condition_type\n , condition_category\n , condition\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom conditions_unioned", "relation_name": "dev_thuxuan.chronic_conditions.cms_chronic_conditions_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.639884Z", "completed_at": "2024-10-25T14:34:46.748664Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.757665Z", "completed_at": "2024-10-25T14:34:46.757665Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.12878036499023438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__int_observation_suspects", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , observation_date\n , result\n , lower(coalesce(normalized_code_type,source_code_type)) as code_type\n , coalesce(normalized_code,source_code) as code\n , data_source\nfrom dev_thuxuan.core.observation\n\n\n), conditions as (\n\n select\n patient_id\n , recorded_date\n , condition_type\n , code_type\n , code\n , data_source\n from dev_thuxuan.hcc_suspecting._int_prep_conditions\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , result\n , code_type\n , code\n , data_source\n from __dbt__cte___stg_observation\n\n)\n\n, numeric_observations as (\n\n select\n patient_id\n , observation_date\n \n , CAST(result AS numeric(28,6)) AS result\n \n , code_type\n , code\n , data_source\n from observations\n \n where regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, seed_clinical_concepts as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.hcc_suspecting._value_set_clinical_concepts\n\n)\n\n, seed_hcc_descriptions as (\n\n select distinct\n hcc_code\n , hcc_description\n from dev_thuxuan.hcc_suspecting._value_set_hcc_descriptions\n\n)\n\n, billed_hccs as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , current_year_billed\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n\n)\n\n, depression_assessment as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.observation_date\n , numeric_observations.result\n , numeric_observations.code_type\n , numeric_observations.code\n , numeric_observations.data_source\n , seed_clinical_concepts.concept_name\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'depression assessment (phq-9)'\n\n)\n\n, diabetes as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'diabetes'\n\n)\n\n, hypertension as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'essential hypertension'\n\n)\n\n, obstructive_sleep_apnea as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , conditions.condition_type\n , conditions.code_type\n , conditions.code\n , conditions.data_source\n , seed_clinical_concepts.concept_name\n from conditions\n inner join seed_clinical_concepts\n on conditions.code_type = seed_clinical_concepts.code_system\n and conditions.code = seed_clinical_concepts.code\n where lower(seed_clinical_concepts.concept_name) = 'obstructive sleep apnea'\n\n)\n\n/* BEGIN HCC 48 logic (Morbid Obesity) */\n, bmi_over_30_with_osa as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , obstructive_sleep_apnea.code as condition_code\n , obstructive_sleep_apnea.recorded_date as condition_date\n , obstructive_sleep_apnea.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join obstructive_sleep_apnea\n on numeric_observations.patient_id = obstructive_sleep_apnea.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', obstructive_sleep_apnea.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 30\n\n)\n\n, bmi_over_35_with_diabetes as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , diabetes.code as condition_code\n , diabetes.recorded_date as condition_date\n , diabetes.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join diabetes\n on numeric_observations.patient_id = diabetes.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', diabetes.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_35_with_hypertension as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , hypertension.code as condition_code\n , hypertension.recorded_date as condition_date\n , hypertension.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join hypertension\n on numeric_observations.patient_id = hypertension.patient_id\n /* ensure bmi and condition overlaps in the same year */\n and date_part('year', numeric_observations.observation_date) = date_part('year', hypertension.recorded_date)\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 35\n\n)\n\n, bmi_over_40 as (\n\n select\n numeric_observations.patient_id\n , numeric_observations.data_source\n , numeric_observations.observation_date\n , numeric_observations.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , cast(null as TEXT) as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n from numeric_observations\n inner join seed_clinical_concepts\n on numeric_observations.code_type = seed_clinical_concepts.code_system\n and numeric_observations.code = seed_clinical_concepts.code\n inner join seed_hcc_descriptions\n on hcc_code = '48'\n where lower(seed_clinical_concepts.concept_name) = 'bmi'\n and result >= 40\n\n)\n\n, hcc_48_unioned as (\n\n select * from bmi_over_30_with_osa\n union all\n select * from bmi_over_35_with_diabetes\n union all\n select * from bmi_over_35_with_hypertension\n union all\n select * from bmi_over_40\n\n)\n\n, hcc_48_suspect as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , 'BMI result ' || observation_result || case when condition_code is null then '' else ' with ' || condition_concept_name || '(' || condition_code || ' on ' || condition_date || ')' end as contributing_factor\n from hcc_48_unioned\n\n)\n/* END HCC 48 logic */\n\n/* BEGIN HCC 155 logic (Major Depression, Moderate or Severe, without Psychosis)\n\n to determine a positive PHQ-9 assessment, we look at the past 3 screenings\n for a patient and take the highest result\n*/\n, eligible_depression_assessments as (\n\n select\n depression_assessment.patient_id\n , depression_assessment.observation_date\n , depression_assessment.result\n , depression_assessment.code_type\n , depression_assessment.code\n , depression_assessment.data_source\n , depression_assessment.concept_name\n , row_number() over (\n partition by\n depression_assessment.patient_id\n , depression_assessment.data_source\n order by\n case when depression_assessment.observation_date is null then 1 else 0 end,\n depression_assessment.observation_date desc\n ) assessment_order\n from depression_assessment\n\n)\n\n, depression_assessments_ordered as (\n\n select\n patient_id\n , observation_date\n , code_type\n , code\n , data_source\n , concept_name\n , result\n , row_number() over (\n partition by\n patient_id\n , data_source\n --order by result desc nulls last\n order by\n case when result is null then 1 else 0 end,\n result desc\n ) as result_order --order the last three assessments by result value\n from eligible_depression_assessments\n where assessment_order <= 3\n\n)\n\n, hcc_155_suspect as (\n\n select\n depression_assessments_ordered.patient_id\n , depression_assessments_ordered.data_source\n , depression_assessments_ordered.observation_date\n , depression_assessments_ordered.result as observation_result\n , cast(null as TEXT) as condition_code\n , cast(null as date) as condition_date\n , depression_assessments_ordered.concept_name as condition_concept_name\n , seed_hcc_descriptions.hcc_code\n , seed_hcc_descriptions.hcc_description\n , 'PHQ-9 result ' || depression_assessments_ordered.result || ' on ' || depression_assessments_ordered.observation_date as contributing_factor\n from depression_assessments_ordered\n inner join seed_hcc_descriptions\n on hcc_code = '155'\n where result_order = 1\n and result >= 15\n\n)\n\n/* END HCC 155 logic */\n\n, unioned as (\n\n select * from hcc_48_suspect\n union all\n select * from hcc_155_suspect\n\n)\n\n, add_billed_flag as (\n\n select\n unioned.patient_id\n , unioned.data_source\n , unioned.observation_date\n , unioned.observation_result\n , unioned.condition_code\n , unioned.condition_date\n , unioned.condition_concept_name\n , unioned.hcc_code\n , unioned.hcc_description\n , unioned.contributing_factor\n , billed_hccs.current_year_billed\n from unioned\n left join billed_hccs\n on unioned.patient_id = billed_hccs.patient_id\n and unioned.data_source = billed_hccs.data_source\n and unioned.hcc_code = billed_hccs.hcc_code\n\n)\n\n, add_standard_fields as (\n\n select\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , contributing_factor\n , current_year_billed\n , cast('Observation suspect' as TEXT) as reason\n , observation_date as suspect_date\n from add_billed_flag\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(observation_date as date) as observation_date\n , cast(observation_result as TEXT) as observation_result\n , cast(condition_code as TEXT) as condition_code\n , cast(condition_date as date) as condition_date\n , cast(condition_concept_name as TEXT) as condition_concept_name\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n \n , cast(current_year_billed as boolean) as current_year_billed\n \n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from add_standard_fields\n\n)\n\nselect\n patient_id\n , data_source\n , observation_date\n , observation_result\n , condition_code\n , condition_date\n , condition_concept_name\n , hcc_code\n , hcc_description\n , current_year_billed\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting._int_observation_suspects"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.750664Z", "completed_at": "2024-10-25T14:34:46.760664Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.767078Z", "completed_at": "2024-10-25T14:34:46.767078Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.027419090270996094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.accepted_values_chronic_conditions__cms_chronic_conditions_oud_condition__Opioid_Use_Disorder_OUD_.f44489eec5", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n condition as value_field,\n count(*) as n_records\n\n from dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\n group by condition\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'Opioid Use Disorder (OUD)'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.762077Z", "completed_at": "2024-10-25T14:34:46.770678Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.778139Z", "completed_at": "2024-10-25T14:34:46.778139Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.028474092483520508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_claim_id.7ee5fe28fe", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.771685Z", "completed_at": "2024-10-25T14:34:46.785373Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.793077Z", "completed_at": "2024-10-25T14:34:46.793077Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02700066566467285, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_condition.6800b245ea", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.779164Z", "completed_at": "2024-10-25T14:34:46.793077Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.795102Z", "completed_at": "2024-10-25T14:34:46.795102Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.02702498435974121, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_oud_patient_id.382354e0d0", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions._int_cms_chronic_condition_oud\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.786344Z", "completed_at": "2024-10-25T14:34:46.796103Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.798102Z", "completed_at": "2024-10-25T14:34:46.798102Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.019963502883911133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_hierarchy", "compiled": true, "compiled_code": "\n/*\n Staging HCCs that will be used in disease factor calculations.\n Final output for each CMS model version includes:\n - hccs without a hierarchy\n - lower-level hccs with hierarchy where top-level hcc is missing\n - top-level hccs from hierarchy\n*/\n\nwith hcc_mapping as (\n\n select distinct\n patient_id\n , hcc_code\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_hcc_mapping\n\n)\n\n, seed_hcc_hierarchy as (\n\n select\n model_version\n , hcc_code\n , description\n , hccs_to_exclude\n from dev_thuxuan.cms_hcc._value_set_disease_hierarchy\n\n)\n\n/*\n selecting hccs that do not have a hierarchy\n all codes in this cte are included in final output\n*/\n, hccs_without_hierarchy as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n left join seed_hcc_hierarchy as hcc_top_level\n on hcc_mapping.hcc_code = hcc_top_level.hcc_code\n and hcc_mapping.model_version = hcc_top_level.model_version\n left join seed_hcc_hierarchy as hcc_exclusions\n on hcc_mapping.hcc_code = hcc_exclusions.hccs_to_exclude\n and hcc_mapping.model_version = hcc_exclusions.model_version\n where hcc_top_level.hcc_code is null\n and hcc_exclusions.hccs_to_exclude is null\n\n)\n\n/*\n selecting hccs that have a hierarchy to be evaluated in the next cte\n*/\n, hccs_with_hierarchy as (\n\n select\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n , seed_hcc_hierarchy.hcc_code as top_level_hcc\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hccs_to_exclude\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n\n)\n\n/*\n applying hcc hierarchy and grouping by patient and hcc\n to account for multiple hcc combinations\n minimum HCC is included following CMS's severity logic\n*/\n, hierarchy_applied as (\n\n select\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n , min(hcc_mapping.hcc_code) as top_level_hcc\n from hccs_with_hierarchy\n left join hcc_mapping\n on hcc_mapping.patient_id = hccs_with_hierarchy.patient_id\n and hcc_mapping.hcc_code = hccs_with_hierarchy.top_level_hcc\n and hcc_mapping.model_version = hccs_with_hierarchy.model_version\n group by\n hccs_with_hierarchy.patient_id\n , hccs_with_hierarchy.model_version\n , hccs_with_hierarchy.payment_year\n , hccs_with_hierarchy.hcc_code\n\n)\n\n/*\n selecting lower-level hccs in hierarchy\n all codes in this cte are included in final output\n*/\n, lower_level_inclusions as (\n\n select distinct\n patient_id\n , model_version\n , payment_year\n , case\n when top_level_hcc is not null then top_level_hcc\n else hcc_code\n end as hcc_code\n from hierarchy_applied\n\n)\n\n/*\n selecting top-level hccs not in previous steps\n all codes in this cte are included in final output\n*/\n, top_level_inclusions as (\n\n select distinct\n hcc_mapping.patient_id\n , hcc_mapping.model_version\n , hcc_mapping.payment_year\n , hcc_mapping.hcc_code\n from hcc_mapping\n inner join seed_hcc_hierarchy\n on hcc_mapping.hcc_code = seed_hcc_hierarchy.hcc_code\n and hcc_mapping.model_version = seed_hcc_hierarchy.model_version\n left join lower_level_inclusions\n on hcc_mapping.patient_id = lower_level_inclusions.patient_id\n and hcc_mapping.hcc_code = lower_level_inclusions.hcc_code\n and hcc_mapping.model_version = lower_level_inclusions.model_version\n left join hierarchy_applied\n on hcc_mapping.patient_id = hierarchy_applied.patient_id\n and hcc_mapping.hcc_code = hierarchy_applied.hcc_code\n and hcc_mapping.model_version = hierarchy_applied.model_version\n where lower_level_inclusions.hcc_code is null\n and hierarchy_applied.top_level_hcc is null\n\n)\n\n, unioned as (\n\n select * from hccs_without_hierarchy\n union all\n select * from lower_level_inclusions\n union all\n select * from top_level_inclusions\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n , cast(hcc_code as TEXT) as hcc_code\n from unioned\n\n)\n\nselect\n patient_id\n , model_version\n , payment_year\n , hcc_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_hcc_hierarchy"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.799102Z", "completed_at": "2024-10-25T14:34:46.813687Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.819646Z", "completed_at": "2024-10-25T14:34:46.819646Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02652907371520996, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_prep", "compiled": true, "compiled_code": "\n\nwith combine as (\n select\n a.patient_id\n , a.year_month\n , a.payer\n , a.plan\n , a.data_source\n , a.payer_attributed_provider\n , a.payer_attributed_provider_practice\n , a.payer_attributed_provider_organization\n , a.payer_attributed_provider_lob\n , a.custom_attributed_provider\n , a.custom_attributed_provider_practice\n , a.custom_attributed_provider_organization\n , a.custom_attributed_provider_lob\n\n -- service cat 1 paid\n , coalesce(b.inpatient_paid, 0) as inpatient_paid\n , coalesce(b.outpatient_paid, 0) as outpatient_paid\n , coalesce(b.office_based_paid, 0) as office_based_paid\n , coalesce(b.ancillary_paid, 0) as ancillary_paid\n , coalesce(b.other_paid, 0) as other_paid\n , coalesce(b.pharmacy_paid, 0) as pharmacy_paid\n\n -- service cat 2 paid\n , coalesce(c.acute_inpatient_paid, 0) as acute_inpatient_paid\n , coalesce(c.ambulance_paid, 0) as ambulance_paid\n , coalesce(c.ambulatory_surgery_center_paid, 0) as ambulatory_surgery_center_paid\n , coalesce(c.dialysis_paid, 0) as dialysis_paid\n , coalesce(c.durable_medical_equipment_paid, 0) as durable_medical_equipment_paid\n , coalesce(c.emergency_department_paid, 0) as emergency_department_paid\n , coalesce(c.home_health_paid, 0) as home_health_paid\n , coalesce(c.inpatient_hospice_paid, 0) as inpatient_hospice_paid\n , coalesce(c.inpatient_psychiatric_paid, 0) as inpatient_psychiatric_paid\n , coalesce(c.inpatient_rehabilitation_paid, 0) as inpatient_rehabilitation_paid\n , coalesce(c.lab_paid, 0) as lab_paid\n , coalesce(c.observation_paid, 0) as observation_paid\n , coalesce(c.office_based_other_paid, 0) as office_based_other_paid\n , coalesce(c.office_based_ptotst_paid, 0) as office_based_pt_ot_st_paid\n , coalesce(c.office_based_radiology_paid, 0) as office_based_radiology_paid\n , coalesce(c.office_based_surgery_paid, 0) as office_based_surgery_paid\n , coalesce(c.office_based_visit_paid, 0) as office_based_visit_paid\n , coalesce(c.other_paid, 0) as other_paid_2\n , coalesce(c.outpatient_hospice_paid, 0) as outpatient_hospice_paid\n , coalesce(c.outpatient_hospital_or_clinic_paid, 0) as outpatient_hospital_or_clinic_paid\n , coalesce(c.outpatient_ptotst_paid, 0) as outpatient_pt_ot_st_paid\n , coalesce(c.outpatient_psychiatric_paid, 0) as outpatient_psychiatric_paid\n , coalesce(c.outpatient_radiology_paid, 0) as outpatient_radiology_paid\n , coalesce(c.outpatient_rehabilitation_paid, 0) as outpatient_rehabilitation_paid\n , coalesce(c.outpatient_surgery_paid, 0) as outpatient_surgery_paid\n , coalesce(c.pharmacy_paid, 0) as pharmacy_paid_2\n , coalesce(c.skilled_nursing_paid, 0) as skilled_nursing_paid\n , coalesce(c.telehealth_visit_paid, 0) as telehealth_visit_paid\n , coalesce(c.urgent_care_paid, 0) as urgent_care_paid\n\n -- service cat 1 allowed\n , coalesce(d.inpatient_allowed, 0) as inpatient_allowed\n , coalesce(d.outpatient_allowed, 0) as outpatient_allowed\n , coalesce(d.office_based_allowed, 0) as office_based_allowed\n , coalesce(d.ancillary_allowed, 0) as ancillary_allowed\n , coalesce(d.other_allowed, 0) as other_allowed\n , coalesce(d.pharmacy_allowed, 0) as pharmacy_allowed\n\n -- service cat 2 allowed\n , coalesce(e.acute_inpatient_allowed, 0) as acute_inpatient_allowed\n , coalesce(e.ambulance_allowed, 0) as ambulance_allowed\n , coalesce(e.ambulatory_surgery_center_allowed, 0) as ambulatory_surgery_center_allowed\n , coalesce(e.dialysis_allowed, 0) as dialysis_allowed\n , coalesce(e.durable_medical_equipment_allowed, 0) as durable_medical_equipment_allowed\n , coalesce(e.emergency_department_allowed, 0) as emergency_department_allowed\n , coalesce(e.home_health_allowed, 0) as home_health_allowed\n , coalesce(e.inpatient_hospice_allowed, 0) as inpatient_hospice_allowed\n , coalesce(e.inpatient_psychiatric_allowed, 0) as inpatient_psychiatric_allowed\n , coalesce(e.inpatient_rehabilitation_allowed, 0) as inpatient_rehabilitation_allowed\n , coalesce(e.lab_allowed, 0) as lab_allowed\n , coalesce(e.observation_allowed, 0) as observation_allowed\n , coalesce(e.office_based_other_allowed, 0) as office_based_other_allowed\n , coalesce(e.office_based_ptotst_allowed, 0) as office_based_pt_ot_st_allowed\n , coalesce(e.office_based_radiology_allowed, 0) as office_based_radiology_allowed\n , coalesce(e.office_based_surgery_allowed, 0) as office_based_surgery_allowed\n , coalesce(e.office_based_visit_allowed, 0) as office_based_visit_allowed\n , coalesce(e.other_allowed, 0) as other_allowed_2\n , coalesce(e.outpatient_hospice_allowed, 0) as outpatient_hospice_allowed\n , coalesce(e.outpatient_hospital_or_clinic_allowed, 0) as outpatient_hospital_or_clinic_allowed\n , coalesce(e.outpatient_ptotst_allowed, 0) as outpatient_pt_ot_st_allowed\n , coalesce(e.outpatient_psychiatric_allowed, 0) as outpatient_psychiatric_allowed\n , coalesce(e.outpatient_radiology_allowed, 0) as outpatient_radiology_allowed\n , coalesce(e.outpatient_rehabilitation_allowed, 0) as outpatient_rehabilitation_allowed\n , coalesce(e.outpatient_surgery_allowed, 0) as outpatient_surgery_allowed\n , coalesce(e.pharmacy_allowed, 0) as pharmacy_allowed_2\n , coalesce(e.skilled_nursing_allowed, 0) as skilled_nursing_allowed\n , coalesce(e.telehealth_visit_allowed, 0) as telehealth_visit_allowed\n , coalesce(e.urgent_care_allowed, 0) as urgent_care_allowed\n\n from dev_thuxuan.core.member_months as a\n left join dev_thuxuan.financial_pmpm._int_service_category_1_paid_pivot as b\n on a.patient_id = b.patient_id\n and a.year_month = b.year_month\n and a.payer = b.payer\n and a.plan = b.plan\n left join dev_thuxuan.financial_pmpm._int_service_category_2_paid_pivot as c\n on a.patient_id = c.patient_id\n and a.year_month = c.year_month\n and a.payer = c.payer\n and a.plan = c.plan\n left join dev_thuxuan.financial_pmpm._int_service_category_1_allowed_pivot as d\n on a.patient_id = d.patient_id\n and a.year_month = d.year_month\n and a.payer = d.payer\n and a.plan = d.plan\n left join dev_thuxuan.financial_pmpm._int_service_category_2_allowed_pivot as e\n on a.patient_id = e.patient_id\n and a.year_month = e.year_month\n and a.payer = e.payer\n and a.plan = e.plan\n)\n\nselect\n *\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid + pharmacy_paid as total_paid\n , inpatient_paid + outpatient_paid + office_based_paid + ancillary_paid + other_paid as medical_paid\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed + pharmacy_allowed as total_allowed\n , inpatient_allowed + outpatient_allowed + office_based_allowed + ancillary_allowed + other_allowed as medical_allowed\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom combine", "relation_name": "dev_thuxuan.financial_pmpm.pmpm_prep"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.806103Z", "completed_at": "2024-10-25T14:34:46.820632Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.823630Z", "completed_at": "2024-10-25T14:34:46.823630Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026526689529418945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adh_diabetes_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_adh_diabetes_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_adh_diabetes_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_adh_diabetes_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adh_diabetes_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.814611Z", "completed_at": "2024-10-25T14:34:46.822631Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.842239Z", "completed_at": "2024-10-25T14:34:46.842239Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03711986541748047, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_adhras_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_adhras_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_adhras_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_adhras_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_adhras_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.851786Z", "completed_at": "2024-10-25T14:34:46.865912Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.870913Z", "completed_at": "2024-10-25T14:34:46.870913Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.029575586318969727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__chronic_conditions_none", "compiled": true, "compiled_code": "\n\nwith chronic_conditions as \n(\n select distinct patient_id \n from dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\n)\n\n,results as (\n select \n cast('Percent of patients without chronic conditions' as TEXT) as data_quality_check\n , sum(case when cccw.patient_id is null then 1 else 0 end) / count(distinct e.patient_id) * 100 as result_count\n from dev_thuxuan.core.patient e\n left join chronic_conditions cccw \n on e.patient_id = cccw.patient_id\n)\n\nselect\n results.data_quality_check\n , results.result_count\n , ref_data.analytics_value as medicare_lds_reference\n , 0 as normally_zero \n , cast('2024-10-25 14:34:26.237057+00:00' as TEXT) as tuva_last_run\n \nfrom results\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics as ref_data \n on results.data_quality_check = ref_data.analytics_measure", "relation_name": "dev_thuxuan.data_quality.chronic_conditions_none"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.861912Z", "completed_at": "2024-10-25T14:34:46.869914Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.871912Z", "completed_at": "2024-10-25T14:34:46.871912Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.021177053451538086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_chronic_conditions__cms_chronic_conditions_long_patient_id__claim_id__start_date__condition.8088fbf90d", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, claim_id, start_date, condition\n from dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\n group by patient_id, claim_id, start_date, condition\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.865912Z", "completed_at": "2024-10-25T14:34:46.872912Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.874912Z", "completed_at": "2024-10-25T14:34:46.874912Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019153118133544922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_claim_id.74242d2abc", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect claim_id\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\nwhere claim_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.877912Z", "completed_at": "2024-10-25T14:34:46.888596Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.898599Z", "completed_at": "2024-10-25T14:34:46.898599Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024688243865966797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_condition.e794460ae3", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect condition\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\nwhere condition is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.884488Z", "completed_at": "2024-10-25T14:34:46.899600Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.901600Z", "completed_at": "2024-10-25T14:34:46.901600Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.025689363479614258, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_long_patient_id.551c145c85", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_long\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.889600Z", "completed_at": "2024-10-25T14:34:46.901600Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.903601Z", "completed_at": "2024-10-25T14:34:46.903601Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01978015899658203, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__list", "compiled": true, "compiled_code": "\n\nwith hcc_history_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_patient_hcc_history\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, comorbidity_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_comorbidity_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, observation_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_observation_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, lab_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_lab_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, medication_suspects as (\n\n select distinct\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n from dev_thuxuan.hcc_suspecting._int_medication_suspects\n \n where (current_year_billed = false\n or current_year_billed is null)\n \n\n)\n\n, unioned as (\n\n select * from hcc_history_suspects\n union all\n select * from comorbidity_suspects\n union all\n select * from observation_suspects\n union all\n select * from lab_suspects\n union all\n select * from medication_suspects\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(data_source as TEXT) as data_source\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(suspect_date as date) as suspect_date\n from unioned\n\n)\n\nselect\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting.list"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.905749Z", "completed_at": "2024-10-25T14:34:46.921748Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.922750Z", "completed_at": "2024-10-25T14:34:46.922750Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02014923095703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_disabled_interaction_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , institutional_status\n , short_name\n , description\n , hcc_code\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_disabled_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_interaction_factors.factor_type\n , seed_interaction_factors.description\n , seed_interaction_factors.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors\n on demographics_with_hccs.enrollment_status = seed_interaction_factors.enrollment_status\n and demographics_with_hccs.institutional_status = seed_interaction_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_interaction_factors.hcc_code\n and demographics_with_hccs.model_version = seed_interaction_factors.model_version\n\n)\n\n, add_data_types as (\n\nselect\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\nfrom interactions\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_disabled_interaction_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.912752Z", "completed_at": "2024-10-25T14:34:46.923749Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.931753Z", "completed_at": "2024-10-25T14:34:46.931753Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0270082950592041, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_disease_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , hcc_code\n , description\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_disease_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.gender\n , demographics.age_group\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, disease_factors as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.hcc_code\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , seed_disease_factors.factor_type\n , seed_disease_factors.description\n , seed_disease_factors.coefficient\n from demographics_with_hccs\n inner join seed_disease_factors\n on demographics_with_hccs.enrollment_status = seed_disease_factors.enrollment_status\n and demographics_with_hccs.medicaid_status = seed_disease_factors.medicaid_status\n and demographics_with_hccs.dual_status = seed_disease_factors.dual_status\n and demographics_with_hccs.orec = seed_disease_factors.orec\n and demographics_with_hccs.institutional_status = seed_disease_factors.institutional_status\n and demographics_with_hccs.hcc_code = seed_disease_factors.hcc_code\n and demographics_with_hccs.model_version = seed_disease_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(description as TEXT) as hcc_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_factors\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_disease_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.923749Z", "completed_at": "2024-10-25T14:34:46.934750Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.945752Z", "completed_at": "2024-10-25T14:34:46.945752Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.035005807876586914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_disease_interaction_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , gender\n , age_group\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, seed_interaction_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , short_name\n , description\n , hcc_code_1\n , hcc_code_2\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_disease_interaction_factors\n\n)\n\n, demographics_with_hccs as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , hcc_hierarchy.hcc_code\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n\n)\n\n, demographics_with_interactions as (\n\n select\n demographics_with_hccs.patient_id\n , demographics_with_hccs.model_version\n , demographics_with_hccs.payment_year\n , interactions_code_1.factor_type\n , interactions_code_1.description\n , interactions_code_1.hcc_code_1\n , interactions_code_1.hcc_code_2\n , interactions_code_1.coefficient\n from demographics_with_hccs\n inner join seed_interaction_factors as interactions_code_1\n on demographics_with_hccs.enrollment_status = interactions_code_1.enrollment_status\n and demographics_with_hccs.medicaid_status = interactions_code_1.medicaid_status\n and demographics_with_hccs.dual_status = interactions_code_1.dual_status\n and demographics_with_hccs.orec = interactions_code_1.orec\n and demographics_with_hccs.institutional_status = interactions_code_1.institutional_status\n and demographics_with_hccs.hcc_code = interactions_code_1.hcc_code_1\n and demographics_with_hccs.model_version = interactions_code_1.model_version\n\n)\n\n, disease_interactions as (\n\n select\n demographics_with_interactions.patient_id\n , demographics_with_interactions.factor_type\n , demographics_with_interactions.hcc_code_1\n , demographics_with_interactions.hcc_code_2\n , demographics_with_interactions.description\n , demographics_with_interactions.coefficient\n , demographics_with_interactions.model_version\n , demographics_with_interactions.payment_year\n from demographics_with_interactions\n inner join demographics_with_hccs as interactions_code_2\n on demographics_with_interactions.patient_id = interactions_code_2.patient_id\n and demographics_with_interactions.hcc_code_2 = interactions_code_2.hcc_code\n and demographics_with_interactions.model_version = interactions_code_2.model_version\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code_1 as TEXT) as hcc_code_1\n , cast(hcc_code_2 as TEXT) as hcc_code_2\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from disease_interactions\n\n)\n\nselect\n patient_id\n , hcc_code_1\n , hcc_code_2\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_disease_interaction_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.947782Z", "completed_at": "2024-10-25T14:34:46.961790Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.963785Z", "completed_at": "2024-10-25T14:34:46.963785Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030005693435668945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__int_hcc_count_factors", "compiled": true, "compiled_code": "\n\nwith demographics as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, seed_payment_hcc_count_factors as (\n\n select\n model_version\n , factor_type\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , payment_hcc_count\n , description\n , coefficient\n from dev_thuxuan.cms_hcc._value_set_payment_hcc_count_factors\n\n)\n\n, hcc_hierarchy as (\n\n select\n patient_id\n , hcc_code\n , model_version\n from dev_thuxuan.cms_hcc._int_hcc_hierarchy\n\n)\n\n, demographics_with_hcc_counts as (\n\n select\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n , count(hcc_hierarchy.hcc_code) as hcc_count\n from demographics\n inner join hcc_hierarchy\n on demographics.patient_id = hcc_hierarchy.patient_id\n and demographics.model_version = hcc_hierarchy.model_version\n group by\n demographics.patient_id\n , demographics.enrollment_status\n , demographics.medicaid_status\n , demographics.dual_status\n , demographics.orec\n , demographics.institutional_status\n , demographics.model_version\n , demographics.payment_year\n\n)\n\n, hcc_counts_normalized as (\n\n select\n patient_id\n , enrollment_status\n , medicaid_status\n , dual_status\n , orec\n , institutional_status\n , model_version\n , payment_year\n , case\n when hcc_count >= 10 then '>=10'\n else cast(hcc_count as TEXT)\n end as hcc_count_string\n from demographics_with_hcc_counts\n\n)\n\n, hcc_counts as (\n\n select\n hcc_counts_normalized.patient_id\n , hcc_counts_normalized.model_version\n , hcc_counts_normalized.payment_year\n , seed_payment_hcc_count_factors.factor_type\n , seed_payment_hcc_count_factors.description\n , seed_payment_hcc_count_factors.coefficient\n from hcc_counts_normalized\n inner join seed_payment_hcc_count_factors\n on hcc_counts_normalized.enrollment_status = seed_payment_hcc_count_factors.enrollment_status\n and hcc_counts_normalized.medicaid_status = seed_payment_hcc_count_factors.medicaid_status\n and hcc_counts_normalized.dual_status = seed_payment_hcc_count_factors.dual_status\n and hcc_counts_normalized.orec = seed_payment_hcc_count_factors.orec\n and hcc_counts_normalized.institutional_status = seed_payment_hcc_count_factors.institutional_status\n and hcc_counts_normalized.hcc_count_string = seed_payment_hcc_count_factors.payment_hcc_count\n and hcc_counts_normalized.model_version = seed_payment_hcc_count_factors.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(description as TEXT) as description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(factor_type as TEXT) as factor_type\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from hcc_counts\n\n)\n\nselect\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc._int_hcc_count_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.956756Z", "completed_at": "2024-10-25T14:34:46.964818Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.970837Z", "completed_at": "2024-10-25T14:34:46.970837Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026082515716552734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__financial_pmpm", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect distinct cast(year_month_int as TEXT ) as year_month\n,year as year_number\nfrom dev_thuxuan.reference_data.calendar\n)\n\nselect count(*) as member_months\n,sum(total_paid) / cast(count(*) as numeric(28,6)) as total_pmpm\n,c.year_number as year_number\nfrom dev_thuxuan.financial_pmpm.pmpm_prep p \nleft join cte c on p.year_month = c.year_month \ngroup by c.year_number", "relation_name": "dev_thuxuan.data_quality.data_quality_financial_pmpm"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.965784Z", "completed_at": "2024-10-25T14:34:46.973836Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.983835Z", "completed_at": "2024-10-25T14:34:46.983835Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.021047115325927734, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n, payer\n, data_source", "relation_name": "dev_thuxuan.financial_pmpm.pmpm_payer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.974839Z", "completed_at": "2024-10-25T14:34:46.991835Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:46.993835Z", "completed_at": "2024-10-25T14:34:46.993835Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.022000789642333984, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.financial_pmpm__pmpm_payer_plan", "compiled": true, "compiled_code": "\n\nselect\n year_month\n , payer\n , plan\n , data_source\n , count(1) as member_months\n , sum(total_paid) / count(1) as total_paid\n , sum(medical_paid) / count(1) as medical_paid\n , sum(inpatient_paid) / count(1) as inpatient_paid\n , sum(outpatient_paid) / count(1) as outpatient_paid\n , sum(office_based_paid) / count(1) as office_based_paid\n , sum(ancillary_paid) / count(1) as ancillary_paid\n , sum(other_paid) / count(1) as other_paid\n , sum(pharmacy_paid) / count(1) as pharmacy_paid\n , sum(acute_inpatient_paid) / count(1) as acute_inpatient_paid\n , sum(ambulance_paid) / count(1) as ambulance_paid\n , sum(ambulatory_surgery_center_paid) / count(1) as ambulatory_surgery_center_paid\n , sum(dialysis_paid) / count(1) as dialysis_paid\n , sum(durable_medical_equipment_paid) / count(1) as durable_medical_equipment_paid\n , sum(emergency_department_paid) / count(1) as emergency_department_paid\n , sum(home_health_paid) / count(1) as home_health_paid\n , sum(inpatient_hospice_paid) / count(1) as inpatient_hospice_paid\n , sum(inpatient_psychiatric_paid) / count(1) as inpatient_psychiatric_paid\n , sum(inpatient_rehabilitation_paid) / count(1) as inpatient_rehabilitation_paid\n , sum(lab_paid) / count(1) as lab_paid\n , sum(observation_paid) / count(1) as observation_paid\n , sum(office_based_other_paid) / count(1) as office_based_other_paid\n , sum(office_based_pt_ot_st_paid) / count(1) as office_based_pt_ot_st_paid\n , sum(office_based_radiology_paid) / count(1) as office_based_radiology_paid\n , sum(office_based_surgery_paid) / count(1) as office_based_surgery_paid\n , sum(office_based_visit_paid) / count(1) as office_based_visit_paid\n , sum(outpatient_hospital_or_clinic_paid) / count(1) as outpatient_hospital_or_clinic_paid\n , sum(outpatient_pt_ot_st_paid) / count(1) as outpatient_pt_ot_st_paid\n , sum(outpatient_psychiatric_paid) / count(1) as outpatient_psychiatric_paid\n , sum(outpatient_radiology_paid) / count(1) as outpatient_radiology_paid\n , sum(outpatient_rehabilitation_paid) / count(1) as outpatient_rehabilitation_paid\n , sum(outpatient_surgery_paid) / count(1) as outpatient_surgery_paid\n , sum(skilled_nursing_paid) / count(1) as skilled_nursing_paid\n , sum(telehealth_visit_paid) / count(1) as telehealth_visit_paid\n , sum(urgent_care_paid) / count(1) as urgent_care_paid\n , sum(total_allowed) / count(1) as total_allowed\n , sum(medical_allowed) / count(1) as medical_allowed\n , sum(inpatient_allowed) / count(1) as inpatient_allowed\n , sum(outpatient_allowed) / count(1) as outpatient_allowed\n , sum(office_based_allowed) / count(1) as office_based_allowed\n , sum(ancillary_allowed) / count(1) as ancillary_allowed\n , sum(other_allowed) / count(1) as other_allowed\n , sum(pharmacy_allowed) / count(1) as pharmacy_allowed\n , sum(acute_inpatient_allowed) / count(1) as acute_inpatient_allowed\n , sum(ambulance_allowed) / count(1) as ambulance_allowed\n , sum(ambulatory_surgery_center_allowed) / count(1) as ambulatory_surgery_center_allowed\n , sum(dialysis_allowed) / count(1) as dialysis_allowed\n , sum(durable_medical_equipment_allowed) / count(1) as durable_medical_equipment_allowed\n , sum(emergency_department_allowed) / count(1) as emergency_department_allowed\n , sum(home_health_allowed) / count(1) as home_health_allowed\n , sum(inpatient_hospice_allowed) / count(1) as inpatient_hospice_allowed\n , sum(inpatient_psychiatric_allowed) / count(1) as inpatient_psychiatric_allowed\n , sum(inpatient_rehabilitation_allowed) / count(1) as inpatient_rehabilitation_allowed\n , sum(lab_allowed) / count(1) as lab_allowed\n , sum(observation_allowed) / count(1) as observation_allowed\n , sum(office_based_other_allowed) / count(1) as office_based_other_allowed\n , sum(office_based_pt_ot_st_allowed) / count(1) as office_based_pt_ot_st_allowed\n , sum(office_based_radiology_allowed) / count(1) as office_based_radiology_allowed\n , sum(office_based_surgery_allowed) / count(1) as office_based_surgery_allowed\n , sum(office_based_visit_allowed) / count(1) as office_based_visit_allowed\n , sum(outpatient_hospital_or_clinic_allowed) / count(1) as outpatient_hospital_or_clinic_allowed\n , sum(outpatient_pt_ot_st_allowed) / count(1) as outpatient_pt_ot_st_allowed\n , sum(outpatient_psychiatric_allowed) / count(1) as outpatient_psychiatric_allowed\n , sum(outpatient_radiology_allowed) / count(1) as outpatient_radiology_allowed\n , sum(outpatient_rehabilitation_allowed) / count(1) as outpatient_rehabilitation_allowed\n , sum(outpatient_surgery_allowed) / count(1) as outpatient_surgery_allowed\n , sum(skilled_nursing_allowed) / count(1) as skilled_nursing_allowed\n , sum(telehealth_visit_allowed) / count(1) as telehealth_visit_allowed\n , sum(urgent_care_allowed) / count(1) as urgent_care_allowed\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.financial_pmpm.pmpm_prep a\ngroup by\n year_month\n , payer\n , plan\n , data_source", "relation_name": "dev_thuxuan.financial_pmpm.pmpm_payer_plan"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.985834Z", "completed_at": "2024-10-25T14:34:46.994834Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.001835Z", "completed_at": "2024-10-25T14:34:47.001835Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.026996612548828125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__member_months", "compiled": true, "compiled_code": "\n\nSELECT m.*,\n COALESCE(p.total_paid, 0) AS total_paid,\n COALESCE(p.medical_paid, 0) AS medical_paid,\n COALESCE(p.pharmacy_paid, 0) AS pharmacy_paid,\n m.patient_id || '|' || m.data_source AS patient_data_source_key,\n m.patient_id || '|' || m.data_source || '|' || m.year_month AS member_month_key\nFROM dev_thuxuan.core.member_months m\nLEFT JOIN dev_thuxuan.financial_pmpm.pmpm_prep p ON m.patient_id = p.patient_id\n AND m.data_source = p.data_source\n AND m.year_month = p.year_month", "relation_name": "dev_thuxuan.data_quality.mart_review__member_months"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.995834Z", "completed_at": "2024-10-25T14:34:47.004835Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.013835Z", "completed_at": "2024-10-25T14:34:47.013835Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020996809005737305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.dbt_utils_unique_combination_of_columns_financial_pmpm__pmpm_prep_patient_id__year_month___quote_column_plan_.be60091e23", "compiled": true, "compiled_code": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n patient_id, year_month, plan\n from dev_thuxuan.financial_pmpm.pmpm_prep\n group by patient_id, year_month, plan\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.005837Z", "completed_at": "2024-10-25T14:34:47.031851Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.033834Z", "completed_at": "2024-10-25T14:34:47.033834Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030998945236206055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__list_rollup", "compiled": true, "compiled_code": "\n\nwith list as (\n\n select\n patient_id\n , data_source\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date\n , row_number() over (\n partition by\n patient_id\n , hcc_code\n order by suspect_date desc\n ) as row_num\n from dev_thuxuan.hcc_suspecting.list\n\n)\n\n, list_dedupe as (\n\n select\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , suspect_date as latest_suspect_date\n from list\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(hcc_code as TEXT) as hcc_code\n , cast(hcc_description as TEXT) as hcc_description\n , cast(reason as TEXT) as reason\n , cast(contributing_factor as TEXT) as contributing_factor\n , cast(latest_suspect_date as date) as latest_suspect_date\n from list_dedupe\n\n)\n\nselect\n patient_id\n , hcc_code\n , hcc_description\n , reason\n , contributing_factor\n , latest_suspect_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting.list_rollup"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.015834Z", "completed_at": "2024-10-25T14:34:47.034834Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.048837Z", "completed_at": "2024-10-25T14:34:47.048837Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.044002532958984375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.hcc_suspecting__summary", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\nfrom dev_thuxuan.core.patient\n), patients as (\n\n select\n patient_id\n , sex\n , birth_date\n \n , floor(datediff(\n hour,\n birth_date,\n current_date\n ) / 8766.0) as age\n \n from __dbt__cte___stg_patient\n where death_date is null\n\n)\n\n, suspecting_list as (\n\n select\n patient_id\n , count(*) as gaps\n from dev_thuxuan.hcc_suspecting.list\n group by patient_id\n\n)\n\n, joined as (\n\n select\n patients.patient_id\n , patients.sex\n , patients.birth_date\n , patients.age\n , suspecting_list.gaps\n from patients\n inner join suspecting_list\n on patients.patient_id = suspecting_list.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(sex as TEXT) as patient_sex\n , cast(birth_date as date) as patient_birth_date\n , cast(age as integer) as patient_age\n , cast(gaps as integer) as suspecting_gaps\n from joined\n\n)\n\nselect\n patient_id\n , patient_sex\n , patient_birth_date\n , patient_age\n , suspecting_gaps\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.hcc_suspecting.summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.036834Z", "completed_at": "2024-10-25T14:34:47.055839Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.057837Z", "completed_at": "2024-10-25T14:34:47.057837Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.026003599166870117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_factors", "compiled": true, "compiled_code": "\nwith demographic_factors as (\n\n select\n patient_id\n /* concatenate demographic risk factors */\n\n , gender || ', ' || age_group || ' Years' || ', ' || enrollment_status || ' Enrollee' || ', ' || CASE WHEN medicaid_status = 'Yes' THEN 'Medicaid' ELSE 'Non-Medicaid' END || ', ' || dual_status || ' Dual' || ', ' || orec || ', ' || CASE WHEN institutional_status = 'Yes' THEN 'Institutional' ELSE 'Non-Institutional' END as description\n\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, demographic_defaults as (\n\n select\n patient_id\n , model_version\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n from dev_thuxuan.cms_hcc._int_demographic_factors\n\n)\n\n, disease_factors as (\n\n select\n patient_id\n , hcc_description || ' (HCC ' || hcc_code || ')' as description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_disease_factors\n\n)\n\n, enrollment_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_enrollment_interaction_factors\n\n)\n\n, disabled_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_disabled_interaction_factors\n\n)\n\n, disease_interactions as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_disease_interaction_factors\n\n)\n\n, hcc_counts as (\n\n select\n patient_id\n , description\n , coefficient\n , factor_type\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc._int_hcc_count_factors\n\n)\n\n, unioned as (\n\n select * from demographic_factors\n union all\n select * from disease_factors\n union all\n select * from enrollment_interactions\n union all\n select * from disabled_interactions\n union all\n select * from disease_interactions\n union all\n select * from hcc_counts\n\n)\n\n, add_defaults as (\n\n select\n unioned.patient_id\n , demographic_defaults.enrollment_status_default\n , demographic_defaults.medicaid_dual_status_default\n , demographic_defaults.orec_default\n , demographic_defaults.institutional_status_default\n , unioned.description as risk_factor_description\n , unioned.coefficient\n , unioned.factor_type\n , unioned.model_version\n , unioned.payment_year\n from unioned\n left join demographic_defaults\n on unioned.patient_id = demographic_defaults.patient_id\n and unioned.model_version = demographic_defaults.model_version\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n \n , cast(enrollment_status_default as boolean) as enrollment_status_default\n , cast(medicaid_dual_status_default as boolean) as medicaid_dual_status_default\n , cast(orec_default as boolean) as orec_default\n , cast(institutional_status_default as boolean) as institutional_status_default\n \n , cast(factor_type as TEXT) as factor_type\n , cast(risk_factor_description as TEXT) as risk_factor_description\n , round(cast(coefficient as numeric(28,6)),3) as coefficient\n , cast(model_version as TEXT) as model_version\n , cast(payment_year as integer) as payment_year\n from add_defaults\n\n)\n\nselect\n patient_id\n , enrollment_status_default\n , medicaid_dual_status_default\n , orec_default\n , institutional_status_default\n , factor_type\n , risk_factor_description\n , coefficient\n , model_version\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc.patient_risk_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.059837Z", "completed_at": "2024-10-25T14:34:47.065347Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.066377Z", "completed_at": "2024-10-25T14:34:47.066377Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01251077651977539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__pmpm", "compiled": true, "compiled_code": "\n\n\nSELECT *,\n total_paid * member_months AS total_paid_absolute,\n medical_paid * member_months AS medical_paid_absolute,\n pharmacy_paid * member_months AS pharmacy_paid_absolute,\n inpatient_paid * member_months AS inpatient_paid_absolute,\n outpatient_paid * member_months AS outpatient_paid_absolute,\n office_based_paid * member_months AS office_based_paid_absolute,\n ancillary_paid * member_months AS ancillary_paid_absolute,\n other_paid * member_months AS other_paid_absolute,\n data_source || '|' || year_month as data_source_month_key\nFROM dev_thuxuan.financial_pmpm.pmpm_payer", "relation_name": "dev_thuxuan.data_quality.mart_review__pmpm"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.067348Z", "completed_at": "2024-10-25T14:34:47.135365Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.137129Z", "completed_at": "2024-10-25T14:34:47.137129Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.07278275489807129, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.cms_hcc__patient_risk_scores", "compiled": true, "compiled_code": "\nwith __dbt__cte___stg_member_months as (\n\nselect\n patient_id\n , year_month\n , payer\n , plan\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.member_months\n), seed_adjustment_rates as (\n\n select\n model_version\n , payment_year\n , normalization_factor\n , ma_coding_pattern_adjustment\n from dev_thuxuan.cms_hcc._value_set_adjustment_rates\n\n)\n\n, risk_factors as (\n\n select\n patient_id\n , coefficient\n , model_version\n , payment_year\n from dev_thuxuan.cms_hcc.patient_risk_factors\n\n)\n\n, member_months as (\n\n select\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer) as eligible_year\n , COUNT(1) as member_months\n from __dbt__cte___stg_member_months\n group by\n patient_id\n , cast(\n substr(year_month, 1, 4)\n as integer)\n)\n\n, raw_score as (\n\n select\n patient_id\n , sum(coefficient) as risk_score\n , model_version\n , payment_year\n from risk_factors\n group by\n patient_id\n , model_version\n , payment_year\n\n)\n\n/*\n CMS Guidance for the transition from v24 to v28:\n\n PY2024 risk scores will be blended using 67% of the risk score calculated\n from v24 and 33% from v28.\n\n PY2025 risk scores will be blended using 33% of the risk score calculated\n from v24 and 67% from v28.\n\n PY2026 risk scores will be 100% from v28.\n\n Prior payment years will still be calculated from v24 only.\n*/\n, transition_scores as (\n\n select\n patient_id\n , risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V24' then risk_score\n when payment_year = 2024 and model_version = 'CMS-HCC-V24' then risk_score * 0.67\n when payment_year = 2025 and model_version = 'CMS-HCC-V24' then risk_score * 0.33\n when payment_year >= 2026 and model_version = 'CMS-HCC-V24' then 0\n end as v24_risk_score\n , case\n when payment_year <= 2023 and model_version = 'CMS-HCC-V28' then 0\n when payment_year = 2024 and model_version = 'CMS-HCC-V28' then risk_score * 0.33\n when payment_year = 2025 and model_version = 'CMS-HCC-V28' then risk_score * 0.67\n when payment_year >= 2026 and model_version = 'CMS-HCC-V28' then risk_score\n end as v28_risk_score\n , model_version\n , payment_year\n from raw_score\n\n)\n\n/*\n Grouping by patient to create a single row per patient.\n*/\n, transition_scores_grouped as (\n\n select\n patient_id\n , max(v24_risk_score) as v24_risk_score\n , max(v28_risk_score) as v28_risk_score\n , payment_year\n from transition_scores\n group by\n patient_id\n , payment_year\n\n)\n\n, blended as (\n\n select\n patient_id\n , v24_risk_score\n , v28_risk_score\n , v24_risk_score + v28_risk_score as blended_risk_score\n , payment_year\n from transition_scores_grouped\n\n)\n\n, normalized as (\n\n select\n blended.patient_id\n , blended.v24_risk_score\n , blended.v28_risk_score\n , blended.blended_risk_score\n , blended.blended_risk_score / seed_adjustment_rates.normalization_factor as normalized_risk_score\n , blended.payment_year\n from blended\n left join seed_adjustment_rates\n on blended.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, payment as (\n\n select\n normalized.patient_id\n , normalized.v24_risk_score\n , normalized.v28_risk_score\n , normalized.blended_risk_score\n , normalized.normalized_risk_score\n , normalized.normalized_risk_score * (1 - seed_adjustment_rates.ma_coding_pattern_adjustment) as payment_risk_score\n , normalized.payment_year\n from normalized\n left join seed_adjustment_rates\n on normalized.payment_year = seed_adjustment_rates.payment_year\n\n)\n\n, weighted_score as (\n\n select\n payment.patient_id\n , payment.v24_risk_score\n , payment.v28_risk_score\n , payment.blended_risk_score\n , payment.normalized_risk_score\n , payment.payment_risk_score\n , member_months.member_months\n , payment.payment_risk_score * member_months.member_months as payment_risk_score_weighted_by_months\n , payment.payment_year\n from payment\n left join member_months\n on payment.patient_id = member_months.patient_id\n and payment.payment_year = member_months.eligible_year\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(v24_risk_score as numeric(28,6)),3) as v24_risk_score\n , round(cast(v28_risk_score as numeric(28,6)),3) as v28_risk_score\n , round(cast(blended_risk_score as numeric(28,6)),3) as blended_risk_score\n , round(cast(normalized_risk_score as numeric(28,6)),3) as normalized_risk_score\n , round(cast(payment_risk_score as numeric(28,6)),3) as payment_risk_score\n , round(cast(payment_risk_score_weighted_by_months as numeric(28,6)),3) as payment_risk_score_weighted_by_months\n , cast(member_months as integer) as member_months\n , cast(payment_year as integer) as payment_year\n from weighted_score\n\n)\n\nselect\n patient_id\n , v24_risk_score\n , v28_risk_score\n , blended_risk_score\n , normalized_risk_score\n , payment_risk_score\n , payment_risk_score_weighted_by_months\n , member_months\n , payment_year\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.cms_hcc.patient_risk_scores"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.119347Z", "completed_at": "2024-10-25T14:34:47.136453Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.138151Z", "completed_at": "2024-10-25T14:34:47.138151Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07280325889587402, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__cms_hcc", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect max(case when factor_type = 'Demographic' then 1 else 0 end) demographic_factor\n,max(case when factor_type = 'Disease' then 1 else 0 end) as disease_factor\nfrom dev_thuxuan.cms_hcc.patient_risk_factors\n)\n\nselect 'missing cms-hcc demographic factor' as data_quality_check\n,case when demographic_factor = 0 then 1 else 0 end as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte \n\nunion all\n\nselect 'missing cms-hcc disease factor' as data_quality_check\n,case when disease_factor = 0 then 1 else 0 end as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte", "relation_name": "dev_thuxuan.data_quality.data_quality_cms_hcc"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.140500Z", "completed_at": "2024-10-25T14:34:47.145630Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.151650Z", "completed_at": "2024-10-25T14:34:47.151650Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.01628589630126953, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient_risk_factors", "compiled": true, "compiled_code": "\n\nselect *\n,dense_rank() over (order by patient_id, model_version, payment_year ) as patient_risk_sk\nfrom dev_thuxuan.cms_hcc.patient_risk_factors p", "relation_name": "dev_thuxuan.data_quality.mart_review__patient_risk_factors"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.145630Z", "completed_at": "2024-10-25T14:34:47.156634Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.157633Z", "completed_at": "2024-10-25T14:34:47.157633Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01402425765991211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__cms_hcc_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(normalized_risk_score) data_source_value\n,cast('normalized risk score' as TEXT) as analytics_measure\n,cast('cms-hcc' as TEXT) as analytics_concept\nfrom dev_thuxuan.cms_hcc.patient_risk_scores\n)\n\nselect \n m.analytics_concept as analytics_concept\n,m.analytics_measure as analytics_measure\n,cte.data_source_value\n,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = 'cms-hcc'\nand\nm.analytics_measure = 'normalized risk score'", "relation_name": "dev_thuxuan.data_quality.data_quality_cms_hcc_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.152635Z", "completed_at": "2024-10-25T14:34:47.156634Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.162170Z", "completed_at": "2024-10-25T14:34:47.162170Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01754021644592285, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient_risk_scores", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom dev_thuxuan.cms_hcc.patient_risk_scores p", "relation_name": "dev_thuxuan.data_quality.mart_review__patient_risk_scores"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.163170Z", "completed_at": "2024-10-25T14:34:47.168171Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.172187Z", "completed_at": "2024-10-25T14:34:47.172187Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.015553474426269531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_cms_hcc__patient_risk_scores_patient_id.05b154e126", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.cms_hcc.patient_risk_scores\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.168171Z", "completed_at": "2024-10-25T14:34:47.173391Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.173391Z", "completed_at": "2024-10-25T14:34:47.173391Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.006217241287231445, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__patient_risk", "compiled": true, "compiled_code": "\n\n\nWITH cte AS (\n SELECT \n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n SUM(coefficient) AS risk_score\n FROM dev_thuxuan.data_quality.mart_review__patient_risk_factors\n GROUP BY payment_year,\n patient_id,\n model_version,\n patient_risk_sk\n)\n\nSELECT \n CASE \n WHEN risk_score <= 0.5 THEN '.5'\n WHEN risk_score BETWEEN 0.5 AND 1.0 THEN '1'\n WHEN risk_score BETWEEN 1.0 AND 1.5 THEN '1.5'\n WHEN risk_score BETWEEN 1.5 AND 2.0 THEN '2'\n WHEN risk_score BETWEEN 2.0 AND 2.5 THEN '2.5'\n WHEN risk_score BETWEEN 2.5 AND 3.0 THEN '3'\n WHEN risk_score BETWEEN 3.0 AND 3.5 THEN '3.5'\n WHEN risk_score BETWEEN 3.5 AND 4.0 THEN '4'\n WHEN risk_score BETWEEN 4.0 AND 4.5 THEN '4.5'\n WHEN risk_score BETWEEN 4.5 AND 5.0 THEN '5'\n WHEN risk_score > 5.0 THEN '5+'\n ELSE null \n END AS risk_score_bucket,\n payment_year,\n patient_id,\n model_version,\n patient_risk_sk,\n risk_score\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nFROM cte", "relation_name": "dev_thuxuan.data_quality.mart_review__patient_risk"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:46.824632Z", "completed_at": "2024-10-25T14:34:47.541766Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.542765Z", "completed_at": "2024-10-25T14:34:47.542765Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.9727466106414795, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.chronic_conditions__cms_chronic_conditions_wide", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__cms_chronic_conditions__stg_core__patient as (\n\n\nselect \n patient_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), chronic_conditions as (\n\n select distinct\n condition\n , condition_column_name\n from dev_thuxuan.chronic_conditions._value_set_cms_chronic_conditions_hierarchy\n\n)\n\n, conditions as (\n\n select\n chronic_conditions_unioned.patient_id\n , chronic_conditions.condition_column_name\n , 1 as condition_count\n from dev_thuxuan.chronic_conditions.cms_chronic_conditions_long as chronic_conditions_unioned\n inner join chronic_conditions as chronic_conditions\n on chronic_conditions_unioned.condition = chronic_conditions.condition\n\n)\n\nselect\n p.patient_id\n , \n \n max(\n \n case\n when condition_column_name = 'acute_myocardial_infarction'\n then 1\n else 0\n end\n )\n \n \n as acute_myocardial_infarction\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'adhd_conduct_disorders_and_hyperkinetic_syndrome'\n then 1\n else 0\n end\n )\n \n \n as adhd_conduct_disorders_and_hyperkinetic_syndrome\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alcohol_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as alcohol_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'alzheimers_disease'\n then 1\n else 0\n end\n )\n \n \n as alzheimers_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anemia'\n then 1\n else 0\n end\n )\n \n \n as anemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'anxiety_disorders'\n then 1\n else 0\n end\n )\n \n \n as anxiety_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'asthma'\n then 1\n else 0\n end\n )\n \n \n as asthma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'atrial_fibrillation_and_flutter'\n then 1\n else 0\n end\n )\n \n \n as atrial_fibrillation_and_flutter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'autism_spectrum_disorders'\n then 1\n else 0\n end\n )\n \n \n as autism_spectrum_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'benign_prostatic_hyperplasia'\n then 1\n else 0\n end\n )\n \n \n as benign_prostatic_hyperplasia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'bipolar_disorder'\n then 1\n else 0\n end\n )\n \n \n as bipolar_disorder\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_breast'\n then 1\n else 0\n end\n )\n \n \n as cancer_breast\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_colorectal'\n then 1\n else 0\n end\n )\n \n \n as cancer_colorectal\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_endometrial'\n then 1\n else 0\n end\n )\n \n \n as cancer_endometrial\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_lung'\n then 1\n else 0\n end\n )\n \n \n as cancer_lung\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_prostate'\n then 1\n else 0\n end\n )\n \n \n as cancer_prostate\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cancer_urologic_kidney_renal_pelvis_and_ureter'\n then 1\n else 0\n end\n )\n \n \n as cancer_urologic_kidney_renal_pelvis_and_ureter\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cataract'\n then 1\n else 0\n end\n )\n \n \n as cataract\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cerebral_palsy'\n then 1\n else 0\n end\n )\n \n \n as cerebral_palsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_kidney_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_kidney_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'chronic_obstructive_pulmonary_disease'\n then 1\n else 0\n end\n )\n \n \n as chronic_obstructive_pulmonary_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'cystic_fibrosis_and_other_metabolic_developmental_disorders'\n then 1\n else 0\n end\n )\n \n \n as cystic_fibrosis_and_other_metabolic_developmental_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depression_bipolar_or_other_depressive_mood_disorders'\n then 1\n else 0\n end\n )\n \n \n as depression_bipolar_or_other_depressive_mood_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'depressive_disorders'\n then 1\n else 0\n end\n )\n \n \n as depressive_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'diabetes'\n then 1\n else 0\n end\n )\n \n \n as diabetes\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'drug_use_disorders'\n then 1\n else 0\n end\n )\n \n \n as drug_use_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'epilepsy'\n then 1\n else 0\n end\n )\n \n \n as epilepsy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'fibromyalgia_and_chronic_pain_and_fatigue'\n then 1\n else 0\n end\n )\n \n \n as fibromyalgia_and_chronic_pain_and_fatigue\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'glaucoma'\n then 1\n else 0\n end\n )\n \n \n as glaucoma\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'heart_failure_and_non_ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as heart_failure_and_non_ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_a'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_a\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_acute_or_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_acute_or_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_b_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_b_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_acute'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_acute\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_chronic'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_chronic\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_c_unspecified'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_c_unspecified\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_d'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_d\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hepatitis_e'\n then 1\n else 0\n end\n )\n \n \n as hepatitis_e\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hip_pelvic_fracture'\n then 1\n else 0\n end\n )\n \n \n as hip_pelvic_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids'\n then 1\n else 0\n end\n )\n \n \n as human_immunodeficiency_virus_and_or_acquired_immunodeficiency_syndrome_hiv_aids\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hyperlipidemia'\n then 1\n else 0\n end\n )\n \n \n as hyperlipidemia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypertension'\n then 1\n else 0\n end\n )\n \n \n as hypertension\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'hypothyroidism'\n then 1\n else 0\n end\n )\n \n \n as hypothyroidism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'intellectual_disabilities_and_related_conditions'\n then 1\n else 0\n end\n )\n \n \n as intellectual_disabilities_and_related_conditions\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'ischemic_heart_disease'\n then 1\n else 0\n end\n )\n \n \n as ischemic_heart_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'learning_disabilities'\n then 1\n else 0\n end\n )\n \n \n as learning_disabilities\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'leukemias_and_lymphomas'\n then 1\n else 0\n end\n )\n \n \n as leukemias_and_lymphomas\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis'\n then 1\n else 0\n end\n )\n \n \n as liver_disease_cirrhosis_and_other_liver_conditions_except_viral_hepatitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'migraine_and_chronic_headache'\n then 1\n else 0\n end\n )\n \n \n as migraine_and_chronic_headache\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'mobility_impairments'\n then 1\n else 0\n end\n )\n \n \n as mobility_impairments\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'multiple_sclerosis_and_transverse_myelitis'\n then 1\n else 0\n end\n )\n \n \n as multiple_sclerosis_and_transverse_myelitis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'muscular_dystrophy'\n then 1\n else 0\n end\n )\n \n \n as muscular_dystrophy\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'non_alzheimers_dementia'\n then 1\n else 0\n end\n )\n \n \n as non_alzheimers_dementia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'obesity'\n then 1\n else 0\n end\n )\n \n \n as obesity\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'opioid_use_disorder_oud'\n then 1\n else 0\n end\n )\n \n \n as opioid_use_disorder_oud\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'osteoporosis_with_or_without_pathological_fracture'\n then 1\n else 0\n end\n )\n \n \n as osteoporosis_with_or_without_pathological_fracture\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'other_developmental_delays'\n then 1\n else 0\n end\n )\n \n \n as other_developmental_delays\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'parkinsons_disease_and_secondary_parkinsonism'\n then 1\n else 0\n end\n )\n \n \n as parkinsons_disease_and_secondary_parkinsonism\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'peripheral_vascular_disease_pvd'\n then 1\n else 0\n end\n )\n \n \n as peripheral_vascular_disease_pvd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'personality_disorders'\n then 1\n else 0\n end\n )\n \n \n as personality_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pneumonia_all_cause'\n then 1\n else 0\n end\n )\n \n \n as pneumonia_all_cause\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'post_traumatic_stress_disorder_ptsd'\n then 1\n else 0\n end\n )\n \n \n as post_traumatic_stress_disorder_ptsd\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'pressure_and_chronic_ulcers'\n then 1\n else 0\n end\n )\n \n \n as pressure_and_chronic_ulcers\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'rheumatoid_arthritis_osteoarthritis'\n then 1\n else 0\n end\n )\n \n \n as rheumatoid_arthritis_osteoarthritis\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'schizophrenia_and_other_psychotic_disorders'\n then 1\n else 0\n end\n )\n \n \n as schizophrenia_and_other_psychotic_disorders\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_blindness_and_visual_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_blindness_and_visual_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sensory_deafness_and_hearing_impairment'\n then 1\n else 0\n end\n )\n \n \n as sensory_deafness_and_hearing_impairment\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'sickle_cell_disease'\n then 1\n else 0\n end\n )\n \n \n as sickle_cell_disease\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spina_bifida_and_other_congenital_anomalies_of_the_nervous_system'\n then 1\n else 0\n end\n )\n \n \n as spina_bifida_and_other_congenital_anomalies_of_the_nervous_system\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'spinal_cord_injury'\n then 1\n else 0\n end\n )\n \n \n as spinal_cord_injury\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'stroke_transient_ischemic_attack'\n then 1\n else 0\n end\n )\n \n \n as stroke_transient_ischemic_attack\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'tobacco_use'\n then 1\n else 0\n end\n )\n \n \n as tobacco_use\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage'\n then 1\n else 0\n end\n )\n \n \n as traumatic_brain_injury_and_nonpsychotic_mental_disorders_due_to_brain_damage\n \n \n ,\n \n max(\n \n case\n when condition_column_name = 'viral_hepatitis_general'\n then 1\n else 0\n end\n )\n \n \n as viral_hepatitis_general\n \n \n \n \n\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__cms_chronic_conditions__stg_core__patient p\n left join conditions\n on p.patient_id = conditions.patient_id\ngroup by\n p.patient_id", "relation_name": "dev_thuxuan.chronic_conditions.cms_chronic_conditions_wide"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.799676Z", "completed_at": "2024-10-25T14:34:47.820651Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.822566Z", "completed_at": "2024-10-25T14:34:47.822566Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.029851436614990234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_chronic_conditions__cms_chronic_conditions_wide_patient_id.5c2c8ae105", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect patient_id\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:47.807681Z", "completed_at": "2024-10-25T14:34:47.822566Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:47.825626Z", "completed_at": "2024-10-25T14:34:47.825626Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.031870126724243164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_chronic_conditions__cms_chronic_conditions_wide_patient_id.60c2d9a586", "compiled": true, "compiled_code": "\n \n \n\nselect\n patient_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.chronic_conditions.cms_chronic_conditions_wide\nwhere patient_id is not null\ngroup by patient_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:45.364706Z", "completed_at": "2024-10-25T14:34:48.795922Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.796921Z", "completed_at": "2024-10-25T14:34:48.796921Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 3.5168426036834717, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__stg_claims_encounter", "compiled": true, "compiled_code": "\n\n-- *************************************************\n-- This dbt model creates the encounter table in core using dbt_utils.union_relations.\n-- *************************************************\n\n\n\nWITH base AS (\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.acute_inpatient__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(\"DELIVERY_FLAG\" as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(\"DELIVERY_TYPE\" as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(\"NEWBORN_FLAG\" as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(\"NICU_FLAG\" as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.acute_inpatient__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.emergency_department__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.emergency_department__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_snf__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_snf__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.inpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(\"ED_FLAG\" as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(\"MS_DRG_CODE\" as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(\"MS_DRG_DESCRIPTION\" as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(\"MEDICAL_SURGICAL\" as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(\"APR_DRG_CODE\" as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(\"APR_DRG_DESCRIPTION\" as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(\"ADMIT_SOURCE_CODE\" as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(\"ADMIT_SOURCE_DESCRIPTION\" as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(\"ADMIT_TYPE_CODE\" as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(\"ADMIT_TYPE_DESCRIPTION\" as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(\"DISCHARGE_DISPOSITION_CODE\" as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(\"DISCHARGE_DISPOSITION_DESCRIPTION\" as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(\"MORTALITY_FLAG\" as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.inpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.urgent_care__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.urgent_care__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.office_visit__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(null as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(\"BILLING_ID\" as character varying(16777216)) as \"BILLING_ID\" ,\n cast(\"PROVIDER_NAME\" as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(\"PROVIDER_SPECIALTY\" as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(\"CCS_CATEGORY\" as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(\"CCS_CATEGORY_DESCRIPTION\" as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.office_visit__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_hospice__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_hospice__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_hospital_or_clinic__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_injections__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_injections__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_psych__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_psych__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_ptotst__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_ptotst__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_surgery__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_surgery__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_radiology__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_radiology__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_rehab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_rehab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.outpatient_substance_use__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(\"OBSERVATION_FLAG\" as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.outpatient_substance_use__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.home_health__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.home_health__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.dialysis__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.dialysis__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.asc__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(\"LENGTH_OF_STAY\" as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(\"HCPCS_CODE\" as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(null as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.asc__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.ambulance__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.ambulance__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.dme__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.dme__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.lab__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(null as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.lab__encounter_grain\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.claims_preprocessing.orphaned_claim__encounter_grain' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ENCOUNTER_ID\" as NUMBER(18,0)) as \"ENCOUNTER_ID\" ,\n cast(\"ENCOUNTER_START_DATE\" as DATE) as \"ENCOUNTER_START_DATE\" ,\n cast(\"ENCOUNTER_END_DATE\" as DATE) as \"ENCOUNTER_END_DATE\" ,\n cast(\"PATIENT_DATA_SOURCE_ID\" as NUMBER(18,0)) as \"PATIENT_DATA_SOURCE_ID\" ,\n cast(\"ENCOUNTER_TYPE\" as character varying(29)) as \"ENCOUNTER_TYPE\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(12)) as \"ENCOUNTER_GROUP\" ,\n cast(\"ADMIT_AGE\" as NUMBER(15,6)) as \"ADMIT_AGE\" ,\n cast(\"GENDER\" as character varying(16777216)) as \"GENDER\" ,\n cast(\"RACE\" as character varying(16777216)) as \"RACE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE_TYPE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE_TYPE\" ,\n cast(\"PRIMARY_DIAGNOSIS_CODE\" as character varying(16777216)) as \"PRIMARY_DIAGNOSIS_CODE\" ,\n cast(\"PRIMARY_DIAGNOSIS_DESCRIPTION\" as character varying(256)) as \"PRIMARY_DIAGNOSIS_DESCRIPTION\" ,\n cast(\"FACILITY_ID\" as character varying(16777216)) as \"FACILITY_ID\" ,\n cast(null as NUMBER(1,0)) as \"OBSERVATION_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"ED_FLAG\" ,\n cast(\"LAB_FLAG\" as NUMBER(1,0)) as \"LAB_FLAG\" ,\n cast(\"DME_FLAG\" as NUMBER(1,0)) as \"DME_FLAG\" ,\n cast(\"AMBULANCE_FLAG\" as NUMBER(1,0)) as \"AMBULANCE_FLAG\" ,\n cast(\"PHARMACY_FLAG\" as NUMBER(1,0)) as \"PHARMACY_FLAG\" ,\n cast(\"FACILITY_NAME\" as character varying(95)) as \"FACILITY_NAME\" ,\n cast(\"FACILITY_TYPE\" as character varying(173)) as \"FACILITY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"DELIVERY_FLAG\" ,\n cast(null as character varying(16777216)) as \"DELIVERY_TYPE\" ,\n cast(null as NUMBER(1,0)) as \"NEWBORN_FLAG\" ,\n cast(null as NUMBER(1,0)) as \"NICU_FLAG\" ,\n cast(null as character varying(16777216)) as \"MS_DRG_CODE\" ,\n cast(null as character varying(256)) as \"MS_DRG_DESCRIPTION\" ,\n cast(null as character varying(256)) as \"MEDICAL_SURGICAL\" ,\n cast(null as character varying(16777216)) as \"APR_DRG_CODE\" ,\n cast(null as character varying(256)) as \"APR_DRG_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_SOURCE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_SOURCE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"ADMIT_TYPE_CODE\" ,\n cast(null as character varying(256)) as \"ADMIT_TYPE_DESCRIPTION\" ,\n cast(null as character varying(16777216)) as \"DISCHARGE_DISPOSITION_CODE\" ,\n cast(null as character varying(256)) as \"DISCHARGE_DISPOSITION_DESCRIPTION\" ,\n cast(\"TOTAL_PAID_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_PAID_AMOUNT\" ,\n cast(\"TOTAL_ALLOWED_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_ALLOWED_AMOUNT\" ,\n cast(\"TOTAL_CHARGE_AMOUNT\" as NUMBER(38,6)) as \"TOTAL_CHARGE_AMOUNT\" ,\n cast(\"CLAIM_COUNT\" as NUMBER(18,0)) as \"CLAIM_COUNT\" ,\n cast(\"INST_CLAIM_COUNT\" as NUMBER(18,0)) as \"INST_CLAIM_COUNT\" ,\n cast(\"PROF_CLAIM_COUNT\" as NUMBER(18,0)) as \"PROF_CLAIM_COUNT\" ,\n cast(null as NUMBER(9,0)) as \"LENGTH_OF_STAY\" ,\n cast(null as NUMBER(1,0)) as \"MORTALITY_FLAG\" ,\n cast(\"DATA_SOURCE\" as character varying(16777216)) as \"DATA_SOURCE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(16777216)) as \"BILLING_ID\" ,\n cast(null as character varying(191)) as \"PROVIDER_NAME\" ,\n cast(null as character varying(173)) as \"PROVIDER_SPECIALTY\" ,\n cast(null as character varying(16777216)) as \"HCPCS_CODE\" ,\n cast(null as character varying(3)) as \"CCS_CATEGORY\" ,\n cast(null as character varying(256)) as \"CCS_CATEGORY_DESCRIPTION\" ,\n cast(\"PLACE_OF_SERVICE_CODE\" as character varying(16777216)) as \"PLACE_OF_SERVICE_CODE\" ,\n cast(\"PLACE_OF_SERVICE_DESCRIPTION\" as character varying(256)) as \"PLACE_OF_SERVICE_DESCRIPTION\" \n\n from dev_thuxuan.claims_preprocessing.orphaned_claim__encounter_grain\n\n \n )\n\n \n)\n\nSELECT\n cast(encounter_id as TEXT ) as encounter_id\n , cast(p.patient_id as TEXT ) as patient_id\n , cast(encounter_type as TEXT ) as encounter_type\n , cast(encounter_group as TEXT ) as encounter_group\n , try_cast( encounter_start_date as date ) as encounter_start_date\n , try_cast( encounter_end_date as date ) as encounter_end_date\n , cast(length_of_stay as integer ) as length_of_stay\n , cast(admit_source_code as TEXT ) as admit_source_code\n , cast(admit_source_description as TEXT ) as admit_source_description\n , cast(admit_type_code as TEXT ) as admit_type_code\n , cast(admit_type_description as TEXT ) as admit_type_description\n , cast(discharge_disposition_code as TEXT ) as discharge_disposition_code\n , cast(discharge_disposition_description as TEXT ) as discharge_disposition_description\n , cast(null as TEXT ) as attending_provider_id\n , cast(null as TEXT ) as attending_provider_name\n , cast(facility_id as TEXT ) as facility_id\n , cast(facility_name as TEXT ) as facility_name\n , cast(facility_type as TEXT ) as facility_type\n , cast(observation_flag as integer ) as observation_flag\n , cast(lab_flag as integer ) as lab_flag\n , cast(dme_flag as integer ) as dme_flag\n , cast(ambulance_flag as integer ) as ambulance_flag\n , cast(pharmacy_flag as integer ) as pharmacy_flag\n , cast(ed_flag as integer ) as ed_flag\n , cast(delivery_flag as integer ) as delivery_flag\n , cast(delivery_type as TEXT ) as delivery_type\n , cast(newborn_flag as integer ) as newborn_flag\n , cast(nicu_flag as integer ) as nicu_flag\n , cast(primary_diagnosis_code_type as TEXT ) as primary_diagnosis_code_type\n , cast(primary_diagnosis_code as TEXT ) as primary_diagnosis_code\n , cast(primary_diagnosis_description as TEXT ) as primary_diagnosis_description\n , cast(ms_drg_code as TEXT ) as ms_drg_code\n , cast(ms_drg_description as TEXT ) as ms_drg_description\n , cast(apr_drg_code as TEXT ) as apr_drg_code\n , cast(apr_drg_description as TEXT ) as apr_drg_description\n , cast(total_paid_amount as numeric(28,6) ) as paid_amount\n , cast(total_allowed_amount as numeric(28,6) ) as allowed_amount\n , cast(total_charge_amount as numeric(28,6) ) as charge_amount\n , cast(claim_count as integer) as claim_count\n , cast(inst_claim_count as integer) as inst_claim_count\n , cast(prof_claim_count as integer) as prof_claim_count\n , cast(_dbt_source_relation as TEXT) as source_model\n , cast(base.data_source as TEXT ) as data_source\n , cast('2024-10-25 14:34:26.237057+00:00' as timestamp ) as tuva_last_run\nFROM base\ninner join dev_thuxuan.claims_preprocessing.encounters__patient_data_source_id p on base.patient_data_source_id = p.patient_data_source_id", "relation_name": "dev_thuxuan.test.core__stg_claims_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.882619Z", "completed_at": "2024-10-25T14:34:48.888625Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.888625Z", "completed_at": "2024-10-25T14:34:48.888625Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0070819854736328125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.core__encounter", "compiled": true, "compiled_code": "\n\nselect *\n,'claim' as encounter_source_type\n from dev_thuxuan.test.core__stg_claims_encounter\nunion all\n\nselect *\n,'clinical' as encounter_source_type\n from dev_thuxuan.test.core__stg_clinical_encounter\n\n", "relation_name": "dev_thuxuan.core.encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.895626Z", "completed_at": "2024-10-25T14:34:48.918809Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.921811Z", "completed_at": "2024-10-25T14:34:48.921811Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.030182838439941406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__stg_pqi_inpatient_encounter", "compiled": true, "compiled_code": "\n\nselect \n encounter_id\n , data_source\n , ms_drg_code\n , ms_drg_description\n , admit_source_code\n , encounter_start_date\n , encounter_end_date\n , length_of_stay\n , primary_diagnosis_code\n , patient_id\n , facility_id\n , paid_amount\n , date_part('year', encounter_start_date) as year_number\nfrom\n dev_thuxuan.core.encounter\nwhere \n encounter_type = 'acute inpatient'", "relation_name": "dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.899627Z", "completed_at": "2024-10-25T14:34:48.919848Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.921811Z", "completed_at": "2024-10-25T14:34:48.921811Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.030182838439941406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient", "compiled": true, "compiled_code": "\n\nwith cte as (\n select count(*) as result_count\n ,'inpatient encounter missing professional claim' as data_quality_check\n from dev_thuxuan.core.encounter\n where encounter_type = 'acute inpatient'\n and prof_claim_count = 0 \n)\n\n\nselect data_quality_check\n,result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom cte", "relation_name": "dev_thuxuan.data_quality.data_quality_acute_inpatient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.902625Z", "completed_at": "2024-10-25T14:34:48.919848Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.922808Z", "completed_at": "2024-10-25T14:34:48.922808Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.030182838439941406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_prevelence", "compiled": true, "compiled_code": "\n\nwith total_cte as (\nselect cast(count(*) as numeric(28,6) ) as total_encounters\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n) \n\n,cte as (\nselect \n ms_drg_code || ' - ' || ms_drg_description as ms_drg_code_and_description\n ,cast('acute inpatient drg distribution' as TEXT ) as analytics_concept\n ,cast(count(*) as numeric(28,6) )/total_encounters as encounter_percent\n ,total_encounters\n ,row_number() over (order by count(*) desc) as rank_nbr\nfrom dev_thuxuan.core.encounter\ncross join total_cte \nwhere encounter_type = 'acute inpatient'\nand\nms_drg_code is not null\ngroup by \n ms_drg_code || ' - ' || ms_drg_description,\n total_encounters\n)\n\nselect \n cte.analytics_concept\n ,ms_drg_code_and_description as analytics_measure\n ,encounter_percent as data_source_value\n ,m.analytics_value\n ,rank_nbr as value_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on\nm.analytics_concept = cte.analytics_concept\nand\ncte.rank_nbr = m.value_rank\nwhere m.analytics_concept = 'acute inpatient drg distribution'\nand rank_nbr < 11", "relation_name": "dev_thuxuan.data_quality.data_quality_acute_inpatient_prevelence"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.908629Z", "completed_at": "2024-10-25T14:34:48.920808Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.922808Z", "completed_at": "2024-10-25T14:34:48.922808Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03118443489074707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__acute_inpatient_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect avg(length_of_stay) los\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end) deceased_encounters\n,sum(case when discharge_disposition_code in ('20','40','41','42') then 1 else 0 end)/count(*) as mortality_rate\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n)\n\n\n,long_cte as (\n select 'acute inpatient' as analytics_concept\n,'length of stay' as analytics_measure\n,los as data_source_value\nfrom cte\n\nunion all \n\n select 'acute inpatient' as analytics_concept\n,'mortality rate' as analytics_measure\n,mortality_rate as data_source_value\nfrom cte\n)\n\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'length of stay'\n\nunion all \n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join long_cte on long_cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = long_cte.analytics_concept\nwhere m.analytics_concept = 'acute inpatient'\nand\nm.analytics_measure = 'mortality rate'", "relation_name": "dev_thuxuan.data_quality.data_quality_acute_inpatient_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.913629Z", "completed_at": "2024-10-25T14:34:48.920808Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.923809Z", "completed_at": "2024-10-25T14:34:48.923809Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.030180931091308594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__core_populated", "compiled": true, "compiled_code": "\n\nwith medical as (\n select\n 'medical_claim' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.medical_claim\n)\n\n, pharmacy as (\n select\n 'pharmacy_claim' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.pharmacy_claim\n)\n\n, eligibility as (\n select\n 'eligibility' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.eligibility\n)\n\n, member_months as (\n select\n 'member_months' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.member_months\n)\n\n, patient as (\n select\n 'patient' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.patient\n)\n\n, encounter as (\n select\n 'encounter' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.encounter\n)\n\n, condition as (\n select\n 'condition' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.condition\n)\n\n, procedure_cte as (\n select\n 'procedure' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.procedure\n)\n\n,final as (\nselect * from medical\nunion all\nselect * from pharmacy\nunion all\nselect * from eligibility\nunion all\nselect * from member_months\nunion all\nselect * from patient\nunion all\nselect * from encounter\nunion all\nselect * from condition\nunion all\nselect * from procedure_cte\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.core_populated"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.932808Z", "completed_at": "2024-10-25T14:34:48.952857Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.960854Z", "completed_at": "2024-10-25T14:34:48.960854Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03304624557495117, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups", "compiled": true, "compiled_code": "\n\nwith expected_groups as (\n select 'inpatient' as encounter_group\n union all\n select 'outpatient'\n union all\n select 'office based'\n union all\n select 'other'\n)\n\n, actual_groups as (\n select distinct\n encounter_group\n from dev_thuxuan.core.encounter\n)\n\nselect\n e.encounter_group as missing_encounter_group\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom expected_groups e\n left join actual_groups a\n on e.encounter_group = a.encounter_group\nwhere a.encounter_group is null", "relation_name": "dev_thuxuan.data_quality.encounters_missing_groups"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.941811Z", "completed_at": "2024-10-25T14:34:48.959853Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.963412Z", "completed_at": "2024-10-25T14:34:48.963412Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03660464286804199, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization_trend", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select\n year_month\n , count(1) as member_months\n from dev_thuxuan.core.member_months\n group by year_month\n)\n\n, encounters as (\n select\n cast(cal.year_month_int as TEXT) as year_month\n , e.encounter_group\n , e.encounter_type\n , e.encounter_id\n , e.paid_amount\n from dev_thuxuan.core.encounter as e\n left join dev_thuxuan.reference_data.calendar as cal\n on e.encounter_start_date = cal.full_date\n)\n\n, pkpy_trend as (\n select\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , count(enc.encounter_id) / mm.member_months * 12000 as pkpy\n , sum(enc.paid_amount) / nullif(count(enc.encounter_id), 0) as paid_per\n from encounters as enc\n inner join member_months as mm\n on enc.year_month = mm.year_month\n group by\n enc.year_month\n , enc.encounter_group\n , enc.encounter_type\n , mm.member_months\n)\n\nselect\n pkpy_trend.year_month\n , pkpy_trend.encounter_group\n , pkpy_trend.encounter_type\n , pkpy_trend.pkpy\n , pkpy_trend.paid_per\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom pkpy_trend", "relation_name": "dev_thuxuan.data_quality.encounters_cost_and_utilization_trend"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.936812Z", "completed_at": "2024-10-25T14:34:48.960854Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.963412Z", "completed_at": "2024-10-25T14:34:48.964491Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.034682273864746094, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__data_source", "compiled": true, "compiled_code": "\n\nwith data_sources as (\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.condition\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.eligibility\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.encounter\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.location\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.medical_claim\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.member_months\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.patient\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.pharmacy_claim\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.practitioner\n\nUNION ALL\n\nSELECT DISTINCT data_source\nFROM dev_thuxuan.core.procedure\n)\n\nSELECT DISTINCT\n data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom data_sources", "relation_name": "dev_thuxuan.data_quality.mart_review__data_source"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.953856Z", "completed_at": "2024-10-25T14:34:48.963412Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:48.965499Z", "completed_at": "2024-10-25T14:34:48.965499Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.039685964584350586, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_cost_and_utilization", "compiled": true, "compiled_code": "\n\nwith member_months as (\n select \n count(1) as member_months \n from dev_thuxuan.core.member_months\n)\n,pkpy as (\nselect\n cast('encounters cost and utilization PKPY' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , count(enc.encounter_id) / avg(mm.member_months) * 12000 as data_source_value\nfrom dev_thuxuan.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\n,paid_per as (\nselect\n cast('encounters cost and utilization paid per' as TEXT) as analytics_concept\n , enc.encounter_group\n , cast(enc.encounter_type as TEXT) as analytics_measure\n , sum(enc.paid_amount) / count(enc.encounter_id) as data_source_value\nfrom dev_thuxuan.core.encounter as enc\ncross join member_months as mm\ngroup by\n enc.encounter_group\n , enc.encounter_type\n)\nselect\n pkpy.*\n ,ref_data.analytics_value\n ,cast('2024-10-25 14:34:26.237057+00:00' as TEXT) as tuva_last_run\nfrom pkpy\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data on pkpy.analytics_concept = ref_data.analytics_concept and pkpy.analytics_measure = ref_data.analytics_measure\nunion all\nselect\n paid_per.*\n ,ref_data.analytics_value\n ,cast('2024-10-25 14:34:26.237057+00:00' as TEXT) as tuva_last_run\nfrom paid_per\nleft join dev_thuxuan.data_quality._value_set_reference_mart_analytics ref_data on paid_per.analytics_concept = paid_per.analytics_concept and paid_per.analytics_measure = paid_per.analytics_measure", "relation_name": "dev_thuxuan.data_quality.encounters_cost_and_utilization"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.970498Z", "completed_at": "2024-10-25T14:34:48.994528Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.000499Z", "completed_at": "2024-10-25T14:34:49.000499Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03400540351867676, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__inpatient", "compiled": true, "compiled_code": "\n\nwith cte as (\n select distinct\n location_id\n , npi\n , name\n from dev_thuxuan.core.location\n)\n\n, final as (\n select\n e.*\n , e.patient_id || '|' || e.data_source as patient_source_key\n , e.encounter_id || '|' || e.data_source as encounter_source_key\n , e.ms_drg_code || '|' || e.ms_drg_description as drgwithdescription\n , e.primary_diagnosis_code || '|' || e.primary_diagnosis_description as primary_diagnosis_and_description\n , e.admit_source_code || '|' || e.admit_source_description as admit_source_code_and_description\n , e.admit_type_code || '|' || e.admit_type_description as admit_type_code_and_description\n , e.discharge_disposition_code || '|' || e.discharge_disposition_description as discharge_code_and_description\n , p.ccsr_parent_category\n , p.ccsr_category\n , p.ccsr_category_description\n , p.ccsr_category || '|' || p.ccsr_category_description as ccsr_category_and_description\n , b.body_system\n , case \n when e.length_of_stay <= 1 then '1. 0-1 day'\n when e.length_of_stay <= 3 then '2. 2-3 days'\n when e.length_of_stay <= 5 then '3. 4-5 days'\n when e.length_of_stay <= 7 then '4. 6-7 days'\n when e.length_of_stay <= 14 then '5. 8-14 days'\n when e.length_of_stay <= 30 then '6. 15-30 days'\n else '7. 31+ Days'\n end as los_groups\n , weights.drg_weight\n from dev_thuxuan.core.encounter as e\n left join cte as l\n on e.facility_id = l.location_id\n left join dev_thuxuan.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\n left join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems as b\n on p.ccsr_parent_category = b.ccsr_parent_category\n left join dev_thuxuan.terminology.ms_drg_weights_los as weights\n on e.ms_drg_code = weights.ms_drg\n where e.encounter_type = 'acute inpatient'\n)\n\nselect * from final", "relation_name": "dev_thuxuan.data_quality.mart_review__inpatient"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.988511Z", "completed_at": "2024-10-25T14:34:49.000499Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.003497Z", "completed_at": "2024-10-25T14:34:49.003497Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03499603271484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_core__encounter_encounter_id.d6227f8792", "compiled": true, "compiled_code": "\n \n \n\nselect\n encounter_id as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.core.encounter\nwhere encounter_id is not null\ngroup by encounter_id\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:48.995496Z", "completed_at": "2024-10-25T14:34:49.002436Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.005523Z", "completed_at": "2024-10-25T14:34:49.005523Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03502535820007324, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__service_categories_long", "compiled": true, "compiled_code": "\n\nwith encounters as (\n select\n cast(c.year_month_int as TEXT) as year_month\n , mc.patient_id\n , service_category_1\n , service_category_2\n , count(distinct mc.encounter_id) as visits\n from dev_thuxuan.data_quality.mart_review__stg_medical_claim as mc\n left join dev_thuxuan.reference_data.calendar c on mc.claim_start_date = c.full_date\n inner join dev_thuxuan.core.encounter as e\n on mc.encounter_id = e.encounter_id\n group by\n cast(c.year_month_int as TEXT)\n , mc.patient_id\n , service_category_1\n , service_category_2\n)\n\n\n select \n pmpm.year_month\n , pmpm.data_source\n , pmpm.service_category_1\n , pmpm.service_category_2\n , sum(total_paid) as paid_amt\n , sum(visits) as visits\n from dev_thuxuan.financial_pmpm._int_patient_spend_with_service_categories as pmpm\n left join encounters\n on pmpm.year_month = encounters.year_month\n and pmpm.patient_id = encounters.patient_id\n and pmpm.service_category_1 = encounters.service_category_1\n and pmpm.service_category_2 = encounters.service_category_2\n group by\n pmpm.year_month\n , pmpm.data_source\n , pmpm.service_category_1\n , pmpm.service_category_2", "relation_name": "dev_thuxuan.data_quality.mart_review__service_categories_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.008499Z", "completed_at": "2024-10-25T14:34:49.020489Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.027532Z", "completed_at": "2024-10-25T14:34:49.027532Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.02403545379638672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_dates", "compiled": true, "compiled_code": "\n-- Exclude encounters with missing start dates\nselect\n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n encounter_start_date is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_dates"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.012516Z", "completed_at": "2024-10-25T14:34:49.021412Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.027532Z", "completed_at": "2024-10-25T14:34:49.027532Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.024010419845581055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_missing_primary_dx", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with missing primary diagnosis code\nselect \n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n primary_diagnosis_code is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.015506Z", "completed_at": "2024-10-25T14:34:49.022517Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.031493Z", "completed_at": "2024-10-25T14:34:49.031493Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02700209617614746, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_transfer", "compiled": true, "compiled_code": "\n\n-- Exclude transfers from hospital, SNF, or other healthcare facility\nselect \n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n admit_source_code in ('4', '5', '6')", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_transfer"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.022517Z", "completed_at": "2024-10-25T14:34:49.033412Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.035524Z", "completed_at": "2024-10-25T14:34:49.035524Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.027025222778320312, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_ungroupable_drg", "compiled": true, "compiled_code": "\n\n-- Exclude encounters with ungroupable DRG\nselect \n encounter_id\n , data_source\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter\nwhere \n ms_drg_code = '999'", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.028501Z", "completed_at": "2024-10-25T14:34:49.035524Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.037527Z", "completed_at": "2024-10-25T14:34:49.037527Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.018001556396484375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__encounters_missing_groups_union", "compiled": true, "compiled_code": "\n\nselect\n 'number of missing encounter groups' as data_quality_check\n , count(*) as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality.encounters_missing_groups", "relation_name": "dev_thuxuan.data_quality.encounters_missing_groups_union"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.040504Z", "completed_at": "2024-10-25T14:34:49.168354Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.170353Z", "completed_at": "2024-10-25T14:34:49.170353Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.13709759712219238, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ed_classification__int_map_primary_dx", "compiled": true, "compiled_code": "/*\nAll condition discharge diagnosis left join with probabilistic\nindicators of ED classification terminology\n*/\n\n\n\n\nwith __dbt__cte__ed_classification__stg_encounter as (\n\n\nselect\n encounter_id\n , encounter_type\n , patient_id\n , encounter_end_date\n , facility_id\n , primary_diagnosis_code_type\n , primary_diagnosis_code\n , primary_diagnosis_description\n , paid_amount\n , allowed_amount\n , charge_amount\nfrom dev_thuxuan.core.encounter\n), condition as (\n select * \n from __dbt__cte__ed_classification__stg_encounter\n where encounter_type = 'emergency department'\n)\n, icd9 as (\n select\n icd9 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from dev_thuxuan.ed_classification._value_set_johnston_icd9\n)\n, icd10 as (\n select\n icd10 as code\n \n , edcnnpa\n \n , edcnpa\n \n , epct\n \n , noner\n \n , injury\n \n , psych\n \n , alcohol\n \n , drug\n \n , 1 as ed_classification_capture\n from dev_thuxuan.ed_classification._value_set_johnston_icd10\n)\n\nselect\n a.*\n \n , icd10.edcnnpa\n \n , icd10.edcnpa\n \n , icd10.epct\n \n , icd10.noner\n \n , icd10.injury\n \n , icd10.psych\n \n , icd10.alcohol\n \n , icd10.drug\n \n , coalesce(icd10.ed_classification_capture, 0) as ed_classification_capture\nfrom condition a\nleft join icd10\n on a.primary_diagnosis_code = icd10.code \n and a.primary_diagnosis_code_type = 'icd-10-cm'\n\nunion all\n\nselect\n a.*\n \n , icd9.edcnnpa\n \n , icd9.edcnpa\n \n , icd9.epct\n \n , icd9.noner\n \n , icd9.injury\n \n , icd9.psych\n \n , icd9.alcohol\n \n , icd9.drug\n \n , coalesce(icd9.ed_classification_capture, 0) ed_classification_capture\nfrom condition a\ninner join icd9\n on a.primary_diagnosis_code = icd9.code \n and a.primary_diagnosis_code_type = 'icd-9-cm'", "relation_name": "dev_thuxuan.ed_classification._int_by_provider_parent_organization"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.107499Z", "completed_at": "2024-10-25T14:34:49.170353Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.264662Z", "completed_at": "2024-10-25T14:34:49.264662Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.22817277908325195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'audiology visit'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'occupational therapy evaluation'\n , 'office visit'\n , 'physical therapy evaluation'\n , 'online assessments'\n , 'telephone visits' \n , 'care services in long term residential facility'\n , 'discharge services nursing facility'\n , 'encounter inpatient'\n , 'ophthalmological services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, falls_screening_code as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where code = '1100F'\n /* \n Patient screened for future fall risk; documentation of two or more falls in the past year \n or any fall with injury in the past year\n */\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join falls_screening_code\n on procedures.code = falls_screening_code.code\n and procedures.code_type = falls_screening_code.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from medical_claim\n inner join falls_screening_code\n on medical_claim.hcpcs_code = falls_screening_code.code\n and lower(falls_screening_code.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, qualifying_cares_past_year as (\n\n select\n patient_id\n , evidence_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n from qualifying_cares\n inner join dev_thuxuan.quality_measures._int_cbe0101__performance_period pp\n on evidence_date between pp.performance_period_begin and pp.performance_period_end \n /* \n code 1100F is reported if there are two or more falls in the last year itself,\n so if it's reported in performance year, it indicates the falls in the last year\n */\n\n)\n\n, qualifying_patients as (\n\n select\n qualifying_cares_past_year.patient_id\n , patients_with_age.age\n , max_date as encounter_date\n , qualifying_cares_past_year.performance_period_begin\n , qualifying_cares_past_year.performance_period_end\n , qualifying_cares_past_year.measure_id\n , qualifying_cares_past_year.measure_name\n , qualifying_cares_past_year.measure_version\n , 1 as denominator_flag\n from qualifying_cares_past_year\n left join patients_with_age\n on qualifying_cares_past_year.patient_id = patients_with_age.patient_id\n where age >= 65\n\n)\n\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.058604Z", "completed_at": "2024-10-25T14:34:49.170353Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.265732Z", "completed_at": "2024-10-25T14:34:49.265732Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.22924256324768066, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up' \n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'outpatient'\n , 'observation'\n , 'diabetes visit'\n , 'ophthalmological services'\n , 'diabetic retinopathy'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_cbe0055__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.171592Z", "completed_at": "2024-10-25T14:34:49.267545Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.269552Z", "completed_at": "2024-10-25T14:34:49.269552Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.2119464874267578, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'encounter to document medications'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as procedure_encounter_date -- alias only to enable union later\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as claims_encounter_date -- alias only to enable union later\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm130__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as procedure_encounter_date\n , try_cast( null as date ) as claims_encounter_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_cqm130__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , try_cast( null as date ) as procedure_encounter_date\n , coalesce(claim_end_date,claim_start_date) as claims_encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm130__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, multiple_encounters_by_patient as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , case when procedure_encounter_date >= claims_encounter_date\n then procedure_encounter_date\n else claims_encounter_date\n end as max_encounter_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id, procedure_encounter_date, claims_encounter_date\n\n)\n\n, max_encounter_dates_by_patient as (\n\n\tselect\n\t\t patient_id\n\t\t, max(max_encounter_date) as max_encounter_date\n\tfrom multiple_encounters_by_patient\n\tgroup by patient_id\n\n)\n\n, latest_patient_encounters as (\n\t\n\tselect\n\t\t max_encounter_dates_by_patient.patient_id\n\t\t, max_encounter_dates_by_patient.max_encounter_date\n\t\t, procedure_encounter_date\n\t\t, claims_encounter_date\n\tfrom max_encounter_dates_by_patient\n\tinner join multiple_encounters_by_patient\n\t\ton max_encounter_dates_by_patient.patient_id = multiple_encounters_by_patient.patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_encounter_date\n ) / 8760.0) as max_age\n from __dbt__cte___stg_patient p\n inner join latest_patient_encounters e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , patients_with_age.procedure_encounter_date\n , patients_with_age.claims_encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_cqm130__performance_period pp\n where max_age >= 18\n \n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(procedure_encounter_date as date) as procedure_encounter_date\n , cast(claims_encounter_date as date) as claims_encounter_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm130_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.178597Z", "completed_at": "2024-10-25T14:34:49.268549Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.270550Z", "completed_at": "2024-10-25T14:34:49.270550Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.1031959056854248, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'emergency department evaluation and management visit'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm236__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'outpatient'\n , 'nonacute inpatient'\n , 'encounter inpatient'\n , 'acute_inpatient'\n , 'emergency_department'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_cqm236__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm236__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, hypertension_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'essential hypertension'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, hypertension_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join hypertension_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = hypertension_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = hypertension_codes.code\n\n)\n\n, patients_with_age as (\n \n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n-- Patients 18-85 years of age who had a visit and diagnosis of essential hypertension starting before and continuing into, or starting during the first six months of the measurement period.\n, qualifying_patients as (\n\n select\n distinct\n hypertension_conditions.patient_id\n , hypertension_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from hypertension_conditions\n left join patients_with_age\n on hypertension_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_cqm236__performance_period pp\n where max_age >= 18 and min_age <= 85\n and hypertension_conditions.recorded_date between\n \n\n dateadd(\n month,\n -12,\n performance_period_begin\n )\n\n\n and \n \n\n dateadd(\n month,\n 6,\n performance_period_begin\n )\n\n\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm236_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.273552Z", "completed_at": "2024-10-25T14:34:49.401993Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.445993Z", "completed_at": "2024-10-25T14:34:49.445993Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.1774437427520752, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), patients_with_ascvd as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as criteria\n from dev_thuxuan.quality_measures._int_cqm438_denominator_criteria1\n\n)\n\n, patients_with_cholesterol as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 2 as criteria\n from dev_thuxuan.quality_measures._int_cqm438_denominator_criteria2\n\n)\n\n, patients_with_diabetes as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 3 as criteria\n from dev_thuxuan.quality_measures._int_cqm438_denominator_criteria3\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes \n where lower(concept_name) in (\n 'annual wellness visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'outpatient encounters for preventive care'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm438__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n performance_period_begin\n ) / 8760.0) as age\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n and p.death_date is null\n cross join dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n, qualifying_patients_from_criteria1 as (\n\n select\n distinct\n patients_with_ascvd.patient_id\n , patients_with_age.age as age\n , patients_with_ascvd.performance_period_begin\n , patients_with_ascvd.performance_period_end\n , patients_with_ascvd.measure_id\n , patients_with_ascvd.measure_name\n , patients_with_ascvd.measure_version\n , 1 as denominator_flag\n from patients_with_ascvd\n left join patients_with_age\n on patients_with_ascvd.patient_id = patients_with_age.patient_id\n where age is not null\n\n)\n\n, qualifying_patients_from_criteria2 as (\n\n select\n distinct\n patients_with_cholesterol.patient_id\n , patients_with_age.age as age\n , patients_with_cholesterol.performance_period_begin\n , patients_with_cholesterol.performance_period_end\n , patients_with_cholesterol.measure_id\n , patients_with_cholesterol.measure_name\n , patients_with_cholesterol.measure_version\n , 1 as denominator_flag\n from patients_with_cholesterol\n left join patients_with_age\n on patients_with_cholesterol.patient_id = patients_with_age.patient_id\n where age between 20 and 75\n\n)\n\n, qualifying_patients_from_criteria3 as (\n\n select\n distinct\n patients_with_diabetes.patient_id\n , patients_with_age.age as age\n , patients_with_diabetes.performance_period_begin\n , patients_with_diabetes.performance_period_end\n , patients_with_diabetes.measure_id\n , patients_with_diabetes.measure_name\n , patients_with_diabetes.measure_version\n , 1 as denominator_flag\n from patients_with_diabetes\n left join patients_with_age\n on patients_with_diabetes.patient_id = patients_with_age.patient_id\n where age between 40 and 75\n\n)\n\n, final_denominator as (\n \n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria1\n\n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria2\n \n union all\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from qualifying_patients_from_criteria3\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from final_denominator\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.326550Z", "completed_at": "2024-10-25T14:34:49.401993Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.446993Z", "completed_at": "2024-10-25T14:34:49.446993Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.17744135856628418, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'occupational therapy evaluation'\n , 'office visit'\n , 'outpatient'\n , 'physical therapy evaluation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, medical_claim as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_cqm48__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_cqm48__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from medical_claim\n inner join dev_thuxuan.quality_measures._int_cqm48__performance_period as pp \n on coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.sex = 'female'\n and p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age\n , patients_with_age.max_date as encounter_date\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_cqm48__performance_period pp\n where age >= 65\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(encounter_date as date) as encounter_date\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm48_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.371911Z", "completed_at": "2024-10-25T14:34:49.431993Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.514345Z", "completed_at": "2024-10-25T14:34:49.514345Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.24279522895812988, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_denominator", "compiled": true, "compiled_code": "\n\n/*\nDENOMINATOR:\nPatients 45-75 years of age with a visit during the measurement period\nDENOMINATOR NOTE: To assess the age for exclusions, the patient\u2019s age on the date of the encounter\nshould be used\n*Signifies that this CPT Category I code is a non-covered service under the Medicare Part B Physician Fee\nSchedule (PFS). These non-covered services should be counted in the denominator population for MIPS\nCQMs.\nDenominator Criteria (Eligible Cases):\nPatients 45 to 75 years of age on date of encounter\nAND\nPatient encounter during the performance period (CPT or HCPCS): 99202, 99203, 99204, 99205,\n99212, 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350, 99386*, 99387*,\n99396*, 99397*, G0438, G0439\n*/\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'online assessments'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where encounter_type in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8766.0) as min_age\n , max_date\n ,floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8766.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null -- ensures deceased patients are not included\n\n)\n\nselect \n patient_id\n , min_age\n , max_age\n , qualifying_types\nfrom patients_with_age\nwhere max_age >= 45 and min_age <= 75", "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.402993Z", "completed_at": "2024-10-25T14:34:49.516136Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.518937Z", "completed_at": "2024-10-25T14:34:49.518937Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.14801263809204102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'annual wellness visit'\n , 'discharge services nursing facility'\n , 'hemodialysis'\n , 'home healthcare services'\n , 'nursing facility visit'\n , 'office visit'\n , 'outpatient consultation'\n , 'peritoneal dialysis'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services group counseling'\n , 'preventive care services individual counseling'\n , 'preventive care services initial office visit, 18 and up'\n , 'preventive care services, initial office visit, 0 to 17'\n , 'preventive care, established office visit, 0 to 17'\n , 'online assessments'\n , 'patient provider interaction'\n , 'telephone visits'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procedures\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procedures.normalized_code,procedures.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id, min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n , coalesce(min(proc_enc),''))\n , coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , (datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as age_in_decimal_point\n , max_date\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.age_in_decimal_point as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_nqf0041__performance_period pp\n where age_in_decimal_point >= 0.5 --filters patients aged 6 months or older\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , round(cast(age as numeric(28,6)), 1) as age -- ensures age is seen in one decimal point\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.446993Z", "completed_at": "2024-10-25T14:34:49.517917Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.520938Z", "completed_at": "2024-10-25T14:34:49.520938Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.14902639389038086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes as value_sets\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n , encounter_type\n from __dbt__cte___stg_encounter as encounter\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , place_of_service_code\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select\n patient_id\n , min(min_date) min_date\n , max(max_date) max_date\n , concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, bone_fracture_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) = 'fracture diagnoses'\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, bone_fracture_conditions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.encounter_id\n , conditions.recorded_date\n , conditions.source_code\n , conditions.source_code_type\n from conditions\n inner join bone_fracture_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = bone_fracture_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = bone_fracture_codes.code\n\n)\n\n, patients_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient patient\n inner join encounters_by_patient e\n on patient.patient_id = e.patient_id\n where patient.death_date is null\n\n)\n\n, qualifying_patients_w_fractures as (\n\n select\n distinct\n bone_fracture_conditions.patient_id\n , bone_fracture_conditions.recorded_date\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from bone_fracture_conditions\n left join patients_with_age\n on bone_fracture_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_nqf0053__performance_period pp\n where max_age >= 50 and min_age <= 85\n and bone_fracture_conditions.recorded_date between\n \n\n dateadd(\n month,\n -6,\n performance_period_begin\n )\n\n\n and\n pp.lookback_period_june\n and lower(patients_with_age.sex) = 'female'\n\n)\n\n, fracture_procedures as (\n\n select\n procedures.*\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n inner join dev_thuxuan.quality_measures._int_nqf0053__performance_period as pp\n on procedures.procedure_date \n between pp.performance_period_begin and pp.performance_period_end\n where lower(visit_codes.concept_name) = 'fracture procedures'\n\n)\n\n, qualifying_patients_w_encounter as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join visits_encounters\n on qualifying_patients_w_fractures.patient_id = visits_encounters.patient_id\n where \n lower(visits_encounters.encounter_type) in (\n 'acute inpatient'\n , 'annual wellness visit'\n , 'emergency department visit'\n , 'emergency department'\n , 'home healthcare services'\n , 'office visit'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'emergency department evaluation and management visit'\n , 'outpatient'\n )\n)\n\n, qualifying_patients_w_procedure as (\n\n select\n qualifying_patients_w_fractures.*\n from qualifying_patients_w_fractures\n inner join fracture_procedures\n on qualifying_patients_w_fractures.patient_id = fracture_procedures.patient_id\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n qualifying_patients_w_encounter.*\n from qualifying_patients_w_encounter\n left join qualifying_patients_w_procedure\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n left join claims_encounters\n on qualifying_patients_w_encounter.patient_id = claims_encounters.patient_id\n where (cast(claims_encounters.place_of_service_code as TEXT) not in ('21')\n or claims_encounters.patient_id is null)\n\n union all\n\n select\n distinct\n qualifying_patients_w_procedure.*\n from qualifying_patients_w_procedure\n left join qualifying_patients_w_encounter\n on qualifying_patients_w_encounter.patient_id = qualifying_patients_w_procedure.patient_id\n where qualifying_patients_w_encounter.patient_id is null\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(recorded_date as date) as recorded_date\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , recorded_date \n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.522937Z", "completed_at": "2024-10-25T14:34:49.787694Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.789728Z", "completed_at": "2024-10-25T14:34:49.789728Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.27181124687194824, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'office visit'\n , 'home healthcare services'\n , 'preventive care services established office visit, 18 and up'\n , 'preventive care services initial office visit, 18 and up'\n , 'annual wellness visit'\n , 'telephone visits'\n , 'nutrition services'\n )\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0059__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n inner join dev_thuxuan.quality_measures._int_nqf0059__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = visit_codes.code\n\n)\n\n, claims_encounters as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0059__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join visit_codes\n on medical_claim.hcpcs_code= visit_codes.code\n\n)\n\n, all_encounters as (\n select *, 'v' as visit_enc,cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n union all\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n union all\n select *, cast(null as TEXT) as visit_enc,cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n)\n\n, encounters_by_patient as (\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n)\n\n, diabetics_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetes'\n , 'hba1c laboratory test'\n )\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , source_code\n , source_code_type\n , normalized_code\n , normalized_code_type\n from __dbt__cte___stg_condition\n\n)\n\n, diabetic_conditions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n from conditions\n inner join diabetics_codes\n on coalesce(conditions.normalized_code_type, conditions.source_code_type) = diabetics_codes.code_system\n and coalesce(conditions.normalized_code, conditions.source_code) = diabetics_codes.code\n\n)\n\n, patients_with_age as (\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n diabetic_conditions.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from diabetic_conditions\n left join patients_with_age\n on diabetic_conditions.patient_id = patients_with_age.patient_id\n cross join dev_thuxuan.quality_measures._int_nqf0059__performance_period pp\n where max_age >= 18 and min_age <= 75\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.571455Z", "completed_at": "2024-10-25T14:34:49.789728Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.840728Z", "completed_at": "2024-10-25T14:34:49.840728Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.3217911720275879, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n\n)\n\n, valid_concepts as (\n\n select\n concept_name\n from dev_thuxuan.quality_measures._value_set_concepts\n where concept_name in (\n 'annual wellness visit'\n , 'care services in long term residential facility'\n , 'encounter to document medications'\n , 'home healthcare services'\n , 'office visit'\n , 'outpatient'\n , 'psychoanalysis'\n )\n\n)\n\n, valid_visit_codes as (\n\n select\n visit_codes.concept_name\n , visit_codes.code\n , visit_codes.code_system\n from visit_codes\n inner join valid_concepts\n on visit_codes.concept_name = valid_concepts.concept_name\n\n)\n\n, visits_encounters as (\n\n select patient_id\n , length_of_stay\n , encounter.encounter_end_date\n , coalesce(encounter.encounter_start_date,encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date,encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0097__performance_period as pp\n on coalesce(encounter.encounter_end_date,encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date,encounter.encounter_end_date) <= pp.performance_period_end\n -- all encounter types considered; inpatient encounters are filtered by length of stay being more than 0 days\n\n)\n\n, procedure_encounters as (\n\n select \n patient_id\n , procedure_date as min_date\n , procedure_date as max_date\n from __dbt__cte___stg_procedure procs\n\n inner join dev_thuxuan.quality_measures._int_nqf0097__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join valid_visit_codes\n on coalesce(procs.normalized_code,procs.source_code) = valid_visit_codes.code\n\n)\n\n, claims_encounters as (\n \n select patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join dev_thuxuan.quality_measures._int_nqf0097__performance_period as pp on\n coalesce(claim_end_date,claim_start_date) >= pp.performance_period_begin\n and coalesce(claim_start_date,claim_end_date) <= pp.performance_period_end\n inner join valid_visit_codes\n on medical_claim.hcpcs_code= valid_visit_codes.code\n\n)\n\n, all_encounters as (\n\n select\n patient_id\n , min_date\n , max_date\n , 'v' as visit_enc\n , cast(null as TEXT) as proc_enc\n , cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , 'p' as proc_enc\n , cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select\n patient_id\n , min_date\n , max_date\n , cast(null as TEXT) as visit_enc\n , cast(null as TEXT) as proc_enc\n , 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select patient_id,min(min_date) min_date, max(max_date) max_date,\n concat(concat(\n coalesce(min(visit_enc),'')\n ,coalesce(min(proc_enc),''))\n ,coalesce(min(claim_enc),'')\n ) as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , min_date\n , floor(datediff(\n hour,\n birth_date,\n e.min_date\n ) / 8760.0) as min_age\n , max_date\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patients_with_age.patient_id\n , patients_with_age.max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , visits_encounters.encounter_end_date as discharge_date\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_nqf0097__performance_period pp\n inner join visits_encounters\n on patients_with_age.patient_id = visits_encounters.patient_id\n where max_age >= 18\n and visits_encounters.length_of_stay > 0 --ensures inpatient\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(discharge_date as date) as discharge_date\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.732523Z", "completed_at": "2024-10-25T14:34:49.790692Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.841715Z", "completed_at": "2024-10-25T14:34:49.841715Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.3217780590057373, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'home healthcare services'\n , 'office visit'\n , 'encounter to document medications'\n , 'psychological and/or neuropsychological test administration'\n )\n\n)\n\n, visits_encounters as (\n\n select \n patient_id\n , coalesce(encounter.encounter_start_date, encounter.encounter_end_date) as min_date\n , coalesce(encounter.encounter_end_date, encounter.encounter_start_date) as max_date\n from __dbt__cte___stg_encounter encounter\n inner join dev_thuxuan.quality_measures._int_nqf0420__performance_period as pp\n on coalesce(encounter.encounter_end_date, encounter.encounter_start_date) >= pp.performance_period_begin\n and coalesce(encounter.encounter_start_date, encounter.encounter_end_date) <= pp.performance_period_end\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where coalesce(modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(modifier_5, '') not in ('GQ', 'GT', '95')\n\n)\n\n, claims as (\n\n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(hcpcs_modifier_1, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_2, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_3, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_4, '') not in ('GQ', 'GT', '95')\n and coalesce(hcpcs_modifier_5, '') not in ('GQ', 'GT', '95')\n and coalesce(place_of_service_code, '') not in ('02')\n \n)\n\n, procedure_encounters as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as min_date\n , procedures.procedure_date as max_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_nqf0420__performance_period as pp\n on procedure_date between pp.performance_period_begin and pp.performance_period_end\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n, claims_encounters as (\n \n select \n claims.patient_id\n , claims.min_date\n , claims.max_date\n from claims\n inner join dev_thuxuan.quality_measures._int_nqf0420__performance_period as pp \n on claims.max_date >= pp.performance_period_begin\n and claims.min_date <= pp.performance_period_end\n inner join visit_codes\n on claims.hcpcs_code = visit_codes.code\n and visit_codes.code_system = 'hcpcs'\n\n)\n\n, all_encounters as (\n\n select *, 'v' as visit_enc, cast(null as TEXT) as proc_enc, cast(null as TEXT) as claim_enc\n from visits_encounters\n\n union all\n\n select *, cast(null as TEXT) as visit_enc, 'p' as proc_enc, cast(null as TEXT) as claim_enc\n from procedure_encounters\n\n union all\n \n select *, cast(null as TEXT) as visit_enc, cast(null as TEXT) as proc_enc, 'c' as claim_enc\n from claims_encounters\n\n)\n\n, encounters_by_patient as (\n\n select \n patient_id\n , max(max_date) max_date\n , coalesce(min(visit_enc), '') || coalesce(min(proc_enc), '') || coalesce(min(claim_enc), '') as qualifying_types\n from all_encounters\n group by patient_id\n\n)\n\n, patients_with_age as (\n\n select\n p.patient_id\n , floor(datediff(\n hour,\n birth_date,\n e.max_date\n ) / 8760.0) as max_age\n , qualifying_types\n from __dbt__cte___stg_patient p\n inner join encounters_by_patient e\n on p.patient_id = e.patient_id\n where p.death_date is null\n\n)\n\n, qualifying_patients as (\n\n select\n distinct\n patient_id\n , max_age as age\n , pp.performance_period_begin\n , pp.performance_period_end\n , pp.measure_id\n , pp.measure_name\n , pp.measure_version\n , 1 as denominator_flag\n from patients_with_age\n cross join dev_thuxuan.quality_measures._int_nqf0420__performance_period pp\n where max_age >= 18\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from qualifying_patients\n\n)\n\nselect \n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.790692Z", "completed_at": "2024-10-25T14:34:49.843992Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.845568Z", "completed_at": "2024-10-25T14:34:49.845568Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.2741124629974365, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_denominator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), performance_period as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_end\n , performance_period_begin\n , performance_period_lookback\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n, patient as (\n\n select\n patient_id\n , sex\n , birth_date\n , death_date\n from __dbt__cte___stg_patient\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n from __dbt__cte___stg_encounter\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, visit_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name in (\n 'Office Visit'\n , 'Home Healthcare Services'\n , 'Preventive Care Services Established Office Visit, 18 and Up'\n , 'Preventive Care Services Initial Office Visit, 18 and Up'\n , 'Annual Wellness Visit'\n , 'Telephone Visits'\n , 'Online Assessments'\n )\n\n)\n\n, patient_with_age as (\n\n select\n patient.patient_id\n , patient.sex\n , patient.birth_date\n , patient.death_date\n , performance_period.measure_id\n , performance_period.measure_name\n , performance_period.measure_version\n , performance_period.performance_period_begin\n , performance_period.performance_period_end\n , performance_period.performance_period_lookback\n , floor(datediff(\n hour,\n patient.birth_date,\n performance_period.performance_period_begin\n ) / 8760.0) as age -- 365*24 hours in a year\n from patient\n cross join performance_period\n\n)\n\n/*\n Filter patient to living women 51 - 74 years of age\n at the beginning of the measurement period\n*/\n, patient_filtered as (\n\n select\n patient_id\n , age\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , 1 as denominator_flag\n from patient_with_age\n where lower(sex) = 'female'\n and age between 51 and 74\n and death_date is null\n\n)\n\n/*\n Filter to qualifying visit types by claim procedures\n*/\n, visit_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n from medical_claim\n inner join visit_codes\n on medical_claim.hcpcs_code = visit_codes.code\n where visit_codes.code_system = 'hcpcs'\n\n)\n\n/*\n Filter encounters to qualifying visit type\n*/\n, visit_encounters as (\n\n select\n patient_id\n , encounter_start_date\n from encounters\n where lower(encounter_type) in (\n 'home health'\n , 'office visit'\n , 'outpatient'\n , 'outpatient rehabilitation'\n , 'telehealth'\n )\n\n)\n\n/*\n Filter to qualifying visit types by procedure\n*/\n, visit_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join visit_codes\n on procedures.code = visit_codes.code\n and procedures.code_type = visit_codes.code_system\n\n)\n\n/*\n Filter to final eligible population/denominator before exclusions\n with a qualifying visit during the measurement period\n*/\n, eligible_population as (\n\n select\n patient_filtered.patient_id\n , patient_filtered.age\n , patient_filtered.measure_id\n , patient_filtered.measure_name\n , patient_filtered.measure_version\n , patient_filtered.performance_period_begin\n , patient_filtered.performance_period_end\n , performance_period_lookback\n , patient_filtered.denominator_flag\n from patient_filtered\n left join visit_claims\n on patient_filtered.patient_id = visit_claims.patient_id\n left join visit_procedures\n on patient_filtered.patient_id = visit_procedures.patient_id\n left join visit_encounters\n on patient_filtered.patient_id = visit_encounters.patient_id\n where (\n visit_claims.claim_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_claims.claim_end_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_procedures.procedure_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n or visit_encounters.encounter_start_date\n between patient_filtered.performance_period_begin\n and patient_filtered.performance_period_end\n )\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(age as integer) as age\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(performance_period_lookback as date) as performance_period_lookback\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(denominator_flag as integer) as denominator_flag\n from eligible_population\n\n)\n\n select distinct\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_denominator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.835201Z", "completed_at": "2024-10-25T14:34:49.844768Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.846609Z", "completed_at": "2024-10-25T14:34:49.846609Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.05991792678833008, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_quality_measures__stg_core__encounter_patient_id.a0d82e2159", "compiled": true, "compiled_code": "\n \n \n\n\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n) select patient_id\nfrom __dbt__cte___stg_encounter\nwhere patient_id is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.848620Z", "completed_at": "2024-10-25T14:34:49.874134Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.879133Z", "completed_at": "2024-10-25T14:34:49.879133Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.035140275955200195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter", "compiled": true, "compiled_code": "\n\nwith __dbt__cte__readmissions__stg_core__encounter as (\n\n\nselect\n encounter_id,\n patient_id,\n encounter_start_date,\n encounter_end_date,\n discharge_disposition_code,\n facility_id,\n ms_drg_code,\n paid_amount,\n primary_diagnosis_code,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = 'acute inpatient'\n) -- Staging model for the input layer:\n-- stg_encounter input layer model.\n-- This contains one row for every unique encounter in the dataset.\n\nselect\n cast(encounter_id as TEXT) as encounter_id,\n cast(patient_id as TEXT) as patient_id,\n cast(encounter_start_date as date) as admit_date,\n cast(encounter_end_date as date) as discharge_date,\n cast(discharge_disposition_code as TEXT) as discharge_disposition_code,\n cast(facility_id as TEXT) as facility_id,\n cast(ms_drg_code as TEXT) as ms_drg_code,\n cast(paid_amount as numeric(28,6)) as paid_amount,\n cast(primary_diagnosis_code as TEXT) as primary_diagnosis_code,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom __dbt__cte__readmissions__stg_core__encounter", "relation_name": "dev_thuxuan.readmissions._int_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.861620Z", "completed_at": "2024-10-25T14:34:49.879133Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.933950Z", "completed_at": "2024-10-25T14:34:49.933950Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.08927536010742188, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_shared_exclusion_union", "compiled": true, "compiled_code": "\n\n-- Missing Age Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing age' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusions_missing_age as age\n on denom.patient_id = age.patient_id\n and denom.data_source = age.data_source\n\nunion all\n\n-- Missing Gender Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing gender' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_gender as gender\n on denom.patient_id = gender.patient_id\n and denom.data_source = gender.data_source\n\nunion all\n\n-- Missing Dates Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing dates' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_dates as dates\n on denom.encounter_id = dates.encounter_id\n and denom.data_source = dates.data_source\n\nunion all\n\n-- Missing Primary Diagnosis Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'missing primary diagnosis' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_missing_primary_dx as dx\n on denom.encounter_id = dx.encounter_id\n and denom.data_source = dx.data_source\n\nunion all\n\n-- Transfer Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'transfer' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_transfer as tx\n on denom.encounter_id = tx.encounter_id\n and denom.data_source = tx.data_source\n\nunion all\n\n-- Ungroupable DRG Exclusion\nselect \n denom.encounter_id\n , denom.data_source\n , 'ungroupable DRG' as exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as denom\ninner join dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_ungroupable_drg as drg\n on denom.encounter_id = drg.encounter_id\n and denom.data_source = drg.data_source", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.875134Z", "completed_at": "2024-10-25T14:34:49.919926Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.936843Z", "completed_at": "2024-10-25T14:34:49.936843Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.08922839164733887, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ed_classification__int_filter_encounter_with_classification", "compiled": true, "compiled_code": "/*\nFilter conditions to those that were classified and pick the classification\nwith the greatest probability (that's the greatest logic). This logic removes\nany rows that were not classified.\n*/\n\n\nselect\n a.*\n , case greatest(edcnnpa, edcnpa, epct, noner, injury, psych, alcohol, drug)\n when edcnnpa then 'edcnnpa'\n when edcnpa then 'edcnpa'\n when epct then 'epct'\n when noner then 'noner'\n when injury then 'injury'\n when psych then 'psych'\n when alcohol then 'alcohol'\n when drug then 'drug'\n else 'unclassified'\n end as classification\nfrom dev_thuxuan.ed_classification._int_by_provider_parent_organization a\nwhere ed_classification_capture = 1", "relation_name": "dev_thuxuan.ed_classification._int_filter_encounter_with_classification"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.880134Z", "completed_at": "2024-10-25T14:34:49.937844Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.942066Z", "completed_at": "2024-10-25T14:34:49.942066Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.06992363929748535, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_cbe0101_denominator\n\n)\n\n, exclusion_code as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where code = '0518F'\n -- further 1P modifier are only excluded\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0101__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0101__performance_period\n\n)\n\n)\n\n, valid_hospice as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from hospice_palliative\n where lower(exclusion_reason) in (\n 'hospice encounter'\n , 'hospice care ambulatory'\n , 'hospice diagnosis'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_procedures as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , 'Limited Mobility' as exclusion_reason\n from procedures\n inner join exclusion_code\n on procedures.code = exclusion_code.code\n and procedures.code_type = exclusion_code.code_system\n where '1P' in (modifier_1, modifier_2, modifier_3, modifier_4, modifier_5)\n \n)\n\n, exclusion_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , 'Limited mobility' as exclusion_reason\n from __dbt__cte___stg_medical_claim medical_claim\n inner join exclusion_code\n on medical_claim.hcpcs_code = exclusion_code.code\n and lower(exclusion_code.code_system) = 'hcpcs'\n where '1P' in (hcpcs_modifier_1, hcpcs_modifier_2, hcpcs_modifier_3, hcpcs_modifier_4, hcpcs_modifier_5)\n\n)\n\n, exclusion_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_procedures\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from exclusion_claims\n\n)\n\n, combined_exclusions as (\n\n select\n exclusion_patients.patient_id\n , exclusion_patients.exclusion_date\n , exclusion_patients.exclusion_reason\n from exclusion_patients\n inner join denominator\n on exclusion_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.906826Z", "completed_at": "2024-10-25T14:34:49.941173Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:49.943844Z", "completed_at": "2024-10-25T14:34:49.943844Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.06971025466918945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cbe0101_denominator\n\n)\n\n, fallcare_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where code = '0518F' -- Falls plan of care documented\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join fallcare_codes\n on procedures.code = fallcare_codes.code\n and procedures.code_type = fallcare_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join fallcare_codes\n on medical_claim.hcpcs_code = fallcare_codes.code\n and lower(fallcare_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of falls screening visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.944844Z", "completed_at": "2024-10-25T14:34:49.983639Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.012650Z", "completed_at": "2024-10-25T14:34:50.012650Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.07280826568603516, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cbe0055__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join dev_thuxuan.quality_measures._int_cbe0055_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.954851Z", "completed_at": "2024-10-25T14:34:50.012650Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.079333Z", "completed_at": "2024-10-25T14:34:50.079333Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.13649749755859375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cbe0055_denominator\n\n)\n\n, retina_test_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'diabetic retinal eye exam met'\n , 'retinal or dilated eye exam'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_patients as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join dev_thuxuan.quality_measures._int_cbe0055__performance_period pp\n on procedure_date between\n performance_period_begin and performance_period_end\n inner join retina_test_code\n on procedures.code = retina_test_code.code\n and procedures.code_type = retina_test_code.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast('1' as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:49.977662Z", "completed_at": "2024-10-25T14:34:50.045658Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.081767Z", "completed_at": "2024-10-25T14:34:50.081767Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.137923002243042, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medical reason'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , claim_id\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm130__performance_period\n)\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as (\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join dev_thuxuan.quality_measures._int_cqm130_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm130_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.013632Z", "completed_at": "2024-10-25T14:34:50.082789Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.085794Z", "completed_at": "2024-10-25T14:34:50.085794Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.13094282150268555, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select\n patient_id\n , procedure_encounter_date\n , claims_encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cqm130_denominator\n\n)\n\n, medication_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'eligible clinician attests to documenting current medications'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, documenting_meds_procedures as (\n\n select\n patient_id\n , procedure_date\n from procedures\n inner join medication_code\n on procedures.code = medication_code.code\n and procedures.code_type = medication_code.code_system\n\n)\n\n, documenting_meds_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date,claim_start_date) as encounter_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join medication_code\n on medical_claim.hcpcs_code = medication_code.code\n and medication_code.code_system = 'hcpcs'\n\n)\n\n, qualifying_procedure as (\n\n select \n documenting_meds_procedures.patient_id\n , documenting_meds_procedures.procedure_date as encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_procedures\n inner join denominator\n on documenting_meds_procedures.patient_id = denominator.patient_id\n and documenting_meds_procedures.procedure_date = denominator.procedure_encounter_date\n\n)\n\n, qualifying_claims as (\n \n select \n documenting_meds_claims.patient_id\n , documenting_meds_claims.encounter_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from documenting_meds_claims\n inner join denominator\n on documenting_meds_claims.patient_id = denominator.patient_id\n and documenting_meds_claims.encounter_date = denominator.claims_encounter_date\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_procedure\n\n union all\n\n select\n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(encounter_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_cares\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm130_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.045658Z", "completed_at": "2024-10-25T14:34:50.084788Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.087609Z", "completed_at": "2024-10-25T14:34:50.087609Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.11096715927124023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclude_procedures_observations", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , age\n , performance_period_begin\n , performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'dialysis services'\n , 'end stage renal disease'\n , 'esrd monthly outpatient services'\n , 'kidney transplant'\n , 'kidney transplant recipient'\n , 'pregnancy'\n )\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, exclusions_unioned as (\n\n select\n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, excluded_patients as (\n\n select\n exclusions_unioned.patient_id\n , exclusions_unioned.exclusion_date\n , exclusions_unioned.exclusion_reason\n , case\n when exclusion_reason = 'pregnancy' then 1\n else 0\n end as is_pregnant\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.age\n from exclusions_unioned\n inner join denominator\n on exclusions_unioned.patient_id = denominator.patient_id\n\n)\n\n, exclusions_filtered as (\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 1\n and exclusion_date between performance_period_begin and performance_period_end\n \n union all\n\n select\n patient_id\n , age\n , exclusion_date\n , exclusion_reason\n from excluded_patients\n where is_pregnant = 0\n and exclusion_date between performance_period_begin and performance_period_end\n or (exclusion_date between \n\n dateadd(\n year,\n -1,\n performance_period_begin\n )\n\n\n and performance_period_end)\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , age\n , 'measure specific exclusion for observation procedure' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n exclusions_filtered", "relation_name": "dev_thuxuan.quality_measures._int_cqm236_exclude_procedures_observations"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.090614Z", "completed_at": "2024-10-25T14:34:50.287536Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.299032Z", "completed_at": "2024-10-25T14:34:50.299032Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.21424460411071777, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_encounter as (\n\n\nselect\n patient_id\n , encounter_id\n , encounter_type\n , length_of_stay\n , encounter_start_date\n , encounter_end_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), controlled_bp_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'most recent systolic blood pressure < 140 mmhg' --G8752 hcpcs\n , 'most recent diastolic blood pressure < 90 mmhg' --G8754 hcpcs\n )\n \n)\n\n, denominator as (\n\n select\n patient_id\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n\n, encounters as (\n\n select\n patient_id\n , encounter_type\n , encounter_start_date\n , encounter_end_date\n from __dbt__cte___stg_encounter\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , normalized_code\n , normalized_description\n , result\n from __dbt__cte___stg_observation\n where lower(normalized_description) in \n (\n 'systolic blood pressure'\n , 'diastolic blood pressure'\n )\n and normalized_code not in (\n '99473' -- Self-measured blood pressure using a device validated for clinical accuracy; patient education/training and device calibration\n , '99474' -- Separate self-measurements of two readings one minute apart, twice daily over a 30-day period (minimum of 12 readings), collection of data reported by the patient and/or caregiver to the physician or other qualified health care professional, with report of average systolic and diastolic pressures and subsequent communication of a treatment plan to the patient\n )\n and \n \n try_cast(result as numeric)\n is not null\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , result\n , normalized_code\n from __dbt__cte___stg_lab_result\n where normalized_code in \n ('8480-6' --systolic\n ,'8462-4') --diastolic\n and\n normalized_code_type = 'loinc'\n and \n \n try_cast(result as numeric)\n is not null\n\n)\n\n, all_procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, all_medical_claims as (\n \n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, controlled_bp_procedures as (\n\n select\n all_procedures.patient_id\n , all_procedures.procedure_date as evidence_date\n , controlled_bp_codes.code\n from all_procedures\n inner join controlled_bp_codes\n on all_procedures.code_type = controlled_bp_codes.code_system\n and all_procedures.code = controlled_bp_codes.code\n\n)\n\n, controlled_bp_medical_claims as (\n\n select\n all_medical_claims.patient_id\n , coalesce(all_medical_claims.claim_end_date, all_medical_claims.claim_start_date) as evidence_date\n , controlled_bp_codes.code\n from all_medical_claims\n inner join controlled_bp_codes\n on all_medical_claims.hcpcs_code = controlled_bp_codes.code\n and controlled_bp_codes.code_system = 'hcpcs'\n\n)\n\n, controlled_bp_patients_proc_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_procedures\n\n union all\n \n select\n patient_id\n , evidence_date\n , code\n from controlled_bp_medical_claims\n\n)\n\n, controlled_bp_within_range_proc_claims as (\n\n select\n controlled_bp_patients_proc_claims.patient_id\n , controlled_bp_patients_proc_claims.evidence_date\n , controlled_bp_patients_proc_claims.code\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from controlled_bp_patients_proc_claims\n inner join denominator\n on controlled_bp_patients_proc_claims.patient_id = denominator.patient_id\n and controlled_bp_patients_proc_claims.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, procedure_claims_w_encounters as (\n\n select\n controlled_bp_within_range_proc_claims.patient_id\n , controlled_bp_within_range_proc_claims.evidence_date\n , controlled_bp_within_range_proc_claims.code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_procedure_claims\n , controlled_bp_within_range_proc_claims.measure_id\n , controlled_bp_within_range_proc_claims.measure_name\n , controlled_bp_within_range_proc_claims.measure_version\n , controlled_bp_within_range_proc_claims.performance_period_begin\n , controlled_bp_within_range_proc_claims.performance_period_end\n from controlled_bp_within_range_proc_claims\n left join encounters\n on controlled_bp_within_range_proc_claims.patient_id = encounters.patient_id\n and controlled_bp_within_range_proc_claims.evidence_date between \n encounters.encounter_start_date and encounters.encounter_end_date \n \n)\n\n, valid_procedures_and_claims as (\n\n select\n patient_id\n , evidence_date\n , code\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from procedure_claims_w_encounters\n where is_valid_procedure_claims = 1\n\n)\n\n, systolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from valid_procedures_and_claims\n where code = 'G8752' --systolic\n\n)\n\n, diastolic_bp_from_procedure_claims as (\n\n select\n patient_id\n , evidence_date\n from valid_procedures_and_claims\n where code = 'G8754' --diastolic\n\n)\n\n, qualifying_controlled_bp_proc_claims as (\n\n select\n systolic_bp_from_procedure_claims.patient_id\n , systolic_bp_from_procedure_claims.evidence_date\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp_from_procedure_claims\n inner join diastolic_bp_from_procedure_claims\n on systolic_bp_from_procedure_claims.patient_id = diastolic_bp_from_procedure_claims.patient_id\n and systolic_bp_from_procedure_claims.evidence_date = diastolic_bp_from_procedure_claims.evidence_date\n\n)\n\n, observations_within_range as (\n\n select\n observations.patient_id\n , observations.observation_date\n , observations.normalized_code\n , observations.normalized_description\n , observations.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from observations\n inner join denominator\n on observations.patient_id = denominator.patient_id\n and observations.observation_date between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, labs_within_range as (\n\n select\n labs.patient_id\n , labs.normalized_code\n , coalesce(labs.result_date, labs.collection_date) as observation_date\n , labs.result\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from labs\n inner join denominator\n on labs.patient_id = denominator.patient_id\n and coalesce(labs.result_date,labs.collection_date) between \n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, observations_with_encounters as (\n\n select\n observations_within_range.patient_id\n , observations_within_range.observation_date\n , observations_within_range.normalized_description\n , observations_within_range.result\n , observations_within_range.normalized_code\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_observation\n , observations_within_range.measure_id\n , observations_within_range.measure_name\n , observations_within_range.measure_version\n , observations_within_range.performance_period_begin\n , observations_within_range.performance_period_end\n from observations_within_range\n left join encounters\n on observations_within_range.patient_id = encounters.patient_id\n and observations_within_range.observation_date between \n encounters.encounter_start_date and encounters.encounter_end_date\n\n)\n\n, labs_with_encounters as (\n\n select\n labs_within_range.patient_id\n , labs_within_range.normalized_code\n , labs_within_range.observation_date\n , labs_within_range.result\n , case\n when lower(encounters.encounter_type) in (\n 'emergency department'\n , 'acute inpatient'\n )\n then 0\n else 1\n end as is_valid_encounter_labs\n , labs_within_range.measure_id\n , labs_within_range.measure_name\n , labs_within_range.measure_version\n , labs_within_range.performance_period_begin\n , labs_within_range.performance_period_end\n from labs_within_range\n left join encounters\n on labs_within_range.patient_id = encounters.patient_id\n and labs_within_range.observation_date between\n encounters.encounter_start_date and encounters.encounter_end_date\n \n)\n\n, obs_and_labs as (\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from observations_with_encounters\n where is_valid_encounter_observation = 1\n\n union all\n\n select\n patient_id\n , observation_date\n \n , cast(result as float) as bp_reading\n \n , cast(null as TEXT) as normalized_description\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , normalized_code\n from labs_with_encounters labs\n where is_valid_encounter_labs = 1\n\n)\n\n, systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'systolic blood pressure'\n or\n normalized_code = '8480-6'\n\n)\n\n, diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading\n , row_number() over(partition by patient_id order by observation_date desc, bp_reading asc) as rn\n from obs_and_labs\n where lower(normalized_description) = 'diastolic blood pressure'\n or\n normalized_code = '8462-4'\n\n)\n\n, least_recent_systolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as systolic_bp\n , measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n from systolic_bp\n where rn = 1\n\n)\n\n, least_recent_diastolic_bp as (\n\n select\n patient_id\n , observation_date\n , bp_reading as diastolic_bp\n from diastolic_bp\n where rn = 1\n\n)\n\n, patients_with_bp_readings as (\n\n select\n least_recent_systolic_bp.patient_id\n , least_recent_systolic_bp.systolic_bp\n , least_recent_diastolic_bp.diastolic_bp\n , least_recent_systolic_bp.observation_date\n , least_recent_systolic_bp.measure_id\n , least_recent_systolic_bp.measure_name\n , least_recent_systolic_bp.measure_version\n , least_recent_systolic_bp.performance_period_begin\n , least_recent_systolic_bp.performance_period_end\n from least_recent_systolic_bp\n inner join least_recent_diastolic_bp\n on least_recent_systolic_bp.patient_id = least_recent_diastolic_bp.patient_id\n and least_recent_systolic_bp.observation_date = least_recent_diastolic_bp.observation_date\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , case\n when systolic_bp < 140.0 and diastolic_bp < 90.0\n then 1\n else 0\n end as numerator_flag\n from patients_with_bp_readings\n\n union all\n\n select\n patient_id\n , evidence_date as observation_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , 1 as numerator_flag\n from qualifying_controlled_bp_proc_claims\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(observation_date as date) as observation_date\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , observation_date\n , numerator_flag\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm236_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.185742Z", "completed_at": "2024-10-25T14:34:50.287536Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.301398Z", "completed_at": "2024-10-25T14:34:50.301398Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.21428966522216797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), exclusion_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) end as code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'rhabdomyolysis'\n , 'breastfeeding'\n , 'liver disease'\n , 'hepatitis a'\n , 'hepatitis b'\n , 'documentation of medical reason for no statin therapy'\n , 'statin allergen'\n , 'end stage renal disease'\n , 'statin associated muscle symptoms'\n , 'medical reason'\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, conditions as (\n\n select\n patient_id\n , claim_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n where recorded_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n , place_of_service_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n where observation_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm438__performance_period\n\n)\n\n)\n\n, medications as (\n \n select\n patient_id\n , coalesce(prescribing_date, dispensing_date) as exclusion_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim \n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.claim_id\n , conditions.recorded_date\n , exclusion_codes.concept_name as concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n where exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name as concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, medication_exclusions as (\n\n select\n medications.patient_id\n , medications.exclusion_date\n , exclusion_codes.concept_name as concept_name\n from medications\n inner join exclusion_codes\n on medications.source_code = exclusion_codes.code\n and medications.source_code_type = exclusion_codes.code_system\n\n)\n\n, pharmacy_claims_exclusions as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , exclusion_codes.concept_name as concept_name\n from pharmacy_claims\n inner join exclusion_codes\n on pharmacy_claims.ndc_code = exclusion_codes.code\n and lower(exclusion_codes.code_system) = 'ndc'\n\n)\n\n, patients_with_exclusions as(\n \n select \n patient_id\n , recorded_date as exclusion_date\n , concept_name as exclusion_reason\n from condition_exclusions\n\n union all\n\n select \n patient_id\n , coalesce(claim_end_date, claim_start_date) as exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , observation_date as exclusion_date\n , concept_name as exclusion_reason\n from observation_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select \n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from medication_exclusions\n\n union all\n\n select\n patient_id\n , dispensing_date as exclusion_date\n , concept_name as exclusion_reason\n from pharmacy_claims_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join dev_thuxuan.quality_measures._int_cqm438_denominator as denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.247782Z", "completed_at": "2024-10-25T14:34:50.300390Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.334606Z", "completed_at": "2024-10-25T14:34:50.335605Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.24695801734924316, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cqm438_denominator\n\n)\n\n, statin_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'high intensity statin therapy'\n , 'low intensity statin therapy'\n , 'moderate intensity statin therapy'\n , 'statin therapy'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, procedure_statin_related as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join statin_codes\n on procedures.code = statin_codes.code\n and procedures.code_type = statin_codes.code_system\n\n)\n\n, pharmacy_claims_statin_related as (\n\n select\n patient_id\n , dispensing_date as evidence_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join statin_codes\n on pharmacy_claims.ndc_code = statin_codes.code\n and lower(statin_codes.code_system) = 'ndc'\n\n)\n\n, medication_statin_related as (\n\n select\n patient_id\n , coalesce(dispensing_date, prescribing_date) as evidence_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication as medications\n inner join statin_codes\n on medications.source_code = statin_codes.code\n and medications.source_code_type = statin_codes.code_system\n \n)\n\n, qualifying_patients as (\n\n select\n procedure_statin_related.patient_id\n , procedure_statin_related.evidence_date\n from procedure_statin_related\n\n union all\n\n select\n pharmacy_claims_statin_related.patient_id\n , pharmacy_claims_statin_related.evidence_date\n from pharmacy_claims_statin_related\n\n union all\n\n select\n medication_statin_related.patient_id\n , medication_statin_related.evidence_date\n from medication_statin_related\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n qualifying_patients.patient_id\n , qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , cast(1 as integer) as numerator_flag\n from qualifying_patients\n inner join denominator\n on qualifying_patients.patient_id = denominator.patient_id\n and evidence_date between \n denominator.performance_period_begin and \n denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.289025Z", "completed_at": "2024-10-25T14:34:50.335605Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.338604Z", "completed_at": "2024-10-25T14:34:50.338604Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.1528618335723877, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_exclusions", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm48__performance_period\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm48__performance_period\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select\n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n from valid_hospice_exclusions\n inner join dev_thuxuan.quality_measures._int_cqm48_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm48_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.302405Z", "completed_at": "2024-10-25T14:34:50.338604Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.341610Z", "completed_at": "2024-10-25T14:34:50.341610Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.09482765197753906, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , encounter_date\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_cqm48_denominator\n\n)\n\n, involuntary_urination_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'presence or absence of urinary incontinence assessed'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_procedures as (\n\n select\n patient_id\n , procedure_date as evidence_date\n from procedures\n inner join involuntary_urination_codes\n on procedures.code = involuntary_urination_codes.code\n and procedures.code_type = involuntary_urination_codes.code_system\n \n)\n\n, qualifying_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join involuntary_urination_codes\n on medical_claim.hcpcs_code = involuntary_urination_codes.code\n and lower(involuntary_urination_codes.code_system) = 'hcpcs'\n\n)\n\n, qualifying_cares as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualifying_cares.patient_id\n , qualifying_cares.evidence_date\n , cast(null as TEXT) as evidence_value\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from qualifying_cares\n inner join denominator\n on qualifying_cares.patient_id = denominator.patient_id\n where evidence_date between\n \n\n dateadd(\n year,\n -1,\n denominator.encounter_date\n )\n\n\n and \n denominator.encounter_date -- within last 12 months of visit\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm48_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.342611Z", "completed_at": "2024-10-25T14:34:50.460626Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.463713Z", "completed_at": "2024-10-25T14:34:50.463713Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.12611031532287598, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , max_age as age\n from dev_thuxuan.quality_measures._int_nqf0034_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n and lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0034__performance_period\n\n)\n\n)\n\n, measure_specific_colectomy_colorectal_cancer_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_nqf0034_exclude_colectomy_cancer\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from measure_specific_colectomy_colorectal_cancer_exclusion\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type not in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n and age >= 66\n\n union all\n\n select * from combined_exclusions --age irrelvant exclusions\n where exclusion_type in (\n 'measure specific exclusion for historical record of colectomy cancer'\n , 'hospice_palliative'\n ) \n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.354610Z", "completed_at": "2024-10-25T14:34:50.463713Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.529343Z", "completed_at": "2024-10-25T14:34:50.529343Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.1907339096069336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_numerator", "compiled": true, "compiled_code": "\n\n\n/*\nPatients with one or more screenings for colorectal cancer. Appropriate screenings are defined by any one of the\nfollowing criteria:\n- Fecal occult blood test (FOBT) during the measurement period\n- Flexible sigmoidoscopy during the measurement period or the four years prior to the measurement period\n- Colonoscopy during the measurement period or the nine years prior to the measurement period\n- Computed tomography (CT) colonography during the measurement period or the four years prior to the\nmeasurement period.\n- Fecal immunochemical DNA test (FIT-DNA) during the measurement period or the two years prior to the\nmeasurement period.\n\n*/\n\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0034_denominator\n\n)\n\n, screening_codes as (\n\n select\n code\n , case code_system\n when 'SNOMEDCT' then 'snomed-ct'\n when 'ICD9CM' then 'icd-9-cm'\n when 'ICD10CM' then 'icd-10-cm'\n when 'CPT' then 'hcpcs'\n when 'ICD10PCS' then 'icd-10-pcs'\n else lower(code_system) \n end as code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'fecal occult blood test (fobt)' -- mp\n , 'flexible sigmoidoscopy' --mp+4\n , 'colonoscopy' -- mp+9\n , 'ct colonography' -- mp+4\n , 'sdna fit test' -- mp+2\n )\n\n)\n\n, screening_periods as (\n\n select \n code\n , code_system\n , concept_name\n , case concept_name\n when 'Fecal Occult Blood Test (FOBT)' then pp.performance_period_begin --mp\n when 'Flexible Sigmoidoscopy' then pp.performance_period_begin_4yp --mp+4\n when 'Colonoscopy' then pp.performance_period_begin_9yp -- mp+9\n when 'CT Colonography' then pp.performance_period_begin_4yp -- mp+4\n when 'sDNA FIT Test' then pp.performance_period_begin_2yp -- mp+2\n else pp.performance_period_begin \n end as effective_performance_period_begin\n , performance_period_end\n from screening_codes\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n \n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, labs as (\n\n select \n patient_id\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , coalesce( medical_claim.claim_start_date, medical_claim.claim_end_date) as claim_date\n , screening_codes.concept_name\n from medical_claim\n inner join screening_periods\n on medical_claim.claim_start_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n or medical_claim.claim_end_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on medical_claim.hcpcs_code = screening_codes.code\n where screening_codes.code_system in ('hcpcs', 'cpt' )\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n , screening_codes.concept_name\n from observations\n inner join screening_periods\n on observations.observation_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on observations.code = screening_codes.code\n and observations.code_type = screening_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , screening_codes.concept_name\n from procedures\n inner join screening_periods\n on procedures.procedure_date between screening_periods.effective_performance_period_begin and screening_periods.performance_period_end\n inner join screening_codes\n on procedures.code = screening_codes.code\n and procedures.code_type = screening_codes.code_system\n\n)\n\n, normalized_code_labs as (\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.normalized_code = screening_codes.code\n and labs.normalized_code_type = screening_codes.code_system\n)\n\n, source_code_labs as (\n\n select\n patient_id\n , coalesce(collection_date, result_date) as lab_date\n , screening_codes.concept_name\n from labs\n inner join screening_periods\n on coalesce(labs.collection_date, labs.result_date) >= screening_periods.effective_performance_period_begin\n and coalesce(labs.collection_date, labs.result_date) <= screening_periods.performance_period_end\n inner join screening_codes\n on labs.source_code = screening_codes.code\n and labs.source_code_type = screening_codes.code_system\n\n)\n\n, qualifying_labs_union as (\n\n select \n patient_id\n , lab_date\n , concept_name\n from normalized_code_labs\n\n union all\n\n select \n patient_id\n , lab_date\n , concept_name\n from source_code_labs\n\n)\n\n, qualifying_labs as (\n\n select distinct\n patient_id\n , lab_date\n , concept_name\n from qualifying_labs_union\n\n)\n\n, qualifying_events as (\n\n select\n patient_id\n , claim_date as evidence_date\n , concept_name as evidence\n from qualifying_claims\n\n union all\n\n select\n patient_id\n , observation_date as evidence_date\n , concept_name as evidence\n from qualifying_observations\n\n union all\n\n select\n patient_id\n , procedure_date as evidence_date\n , concept_name as evidence\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , lab_date as evidence_date\n , concept_name as evidence\n from qualifying_labs\n\n)\n\nselect\n cast( qualifying_events.patient_id as TEXT) as patient_id\n , cast( evidence_date as date) as evidence_date\n , cast( evidence as TEXT) as evidence\nfrom qualifying_events\ninner join denominator\n on qualifying_events.patient_id = denominator.patient_id", "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.417601Z", "completed_at": "2024-10-25T14:34:50.463713Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.531338Z", "completed_at": "2024-10-25T14:34:50.531338Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.1907343864440918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0041_denominator\n\n)\n\n, exclusion_codes as (\n\n select \n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza immunization not ordered or administered reason documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n) and (\n\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0041__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from hospice_palliative\n where exclusion_reason in (\n 'hospice care ambulatory'\n , 'hospice encounter'\n )\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select\n valid_exclusions.patient_id\n , valid_exclusions.exclusion_date\n , valid_exclusions.exclusion_reason\n from valid_exclusions\n inner join denominator\n on valid_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.464825Z", "completed_at": "2024-10-25T14:34:50.533337Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.536367Z", "completed_at": "2024-10-25T14:34:50.536367Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.18273305892944336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0041_denominator\n\n)\n\n, influenza_vaccination_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'influenza vaccination'\n , 'influenza vaccine'\n , 'influenza virus laiv immunization'\n , 'influenza virus laiv procedure'\n )\n\n)\n\n, procedure_vaccination as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procedures\n inner join influenza_vaccination_code\n on coalesce(procedures.normalized_code, procedures.source_code) = influenza_vaccination_code.code\n and coalesce(procedures.normalized_code_type, procedures.source_code_type) = influenza_vaccination_code.code_system\n\n)\n\n, claims_vaccination as (\n \n select \n patient_id\n , coalesce(claim_start_date,claim_end_date) as min_date\n , coalesce(claim_end_date,claim_start_date) as max_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join influenza_vaccination_code\n on medical_claim.hcpcs_code = influenza_vaccination_code.code\n\n)\n\n, qualifying_procedures as (\n\n select\n procedure_vaccination.patient_id\n , procedure_vaccination.procedure_date as evidence_date\n from procedure_vaccination\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period pp\n on procedure_date between \n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualifying_claims as (\n\n select \n claims_vaccination.patient_id\n , claims_vaccination.max_date as evidence_date\n from claims_vaccination\n inner join dev_thuxuan.quality_measures._int_nqf0041__performance_period pp\n on max_date between\n pp.lookback_period_august and\n pp.performance_period_end\n\n)\n\n, qualified_patients as (\n\n select\n patient_id\n , evidence_date\n from qualifying_procedures\n\n union all\n\n select\n patient_id\n , evidence_date\n from qualifying_claims\n\n)\n\n, combined_qualifying_patients as (\n\n select\n qualified_patients.patient_id\n , qualified_patients.evidence_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , 1 as numerator_flag\n from qualified_patients\n inner join denominator\n on qualified_patients.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from combined_qualifying_patients\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.494422Z", "completed_at": "2024-10-25T14:34:50.534340Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.537338Z", "completed_at": "2024-10-25T14:34:50.537338Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.07771611213684082, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclude_procedures_medications", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pharmacy_claims as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code\n from __dbt__cte___stg_pharmacy_claim\n\n)\n\n, medications as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n from __dbt__cte___stg_medication\n\n)\n\n, bone_density_test_codes as (\n\n select\n concept_name\n , code\n , code_system\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests hcpcs'\n , 'bone mineral density tests icd10pcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n )\n\n)\n\n, osteoporosis_medication_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, bone_density_test_procedures as (\n\n select\n procedures.*\n , bone_density_test_codes.concept_name\n from procedures\n inner join bone_density_test_codes\n on procedures.code = bone_density_test_codes.code\n and procedures.code_type = bone_density_test_codes.code_system\n\n)\n\n, osteoporosis_pharmacy_claims as (\n\n select\n pharmacy_claims.patient_id\n , pharmacy_claims.dispensing_date\n , pharmacy_claims.ndc_code\n , osteoporosis_medication_codes.concept_name\n from pharmacy_claims\n inner join osteoporosis_medication_codes\n on pharmacy_claims.ndc_code = osteoporosis_medication_codes.code\n and lower(osteoporosis_medication_codes.code_system) = 'ndc'\n \n)\n\n, osteoporosis_medications as (\n\n select\n medications.patient_id\n , medications.encounter_id\n , medications.prescribing_date\n , medications.dispensing_date\n , medications.source_code\n , medications.source_code_type\n , osteoporosis_medication_codes.concept_name\n from medications\n inner join osteoporosis_medication_codes\n on medications.source_code = osteoporosis_medication_codes.code\n and medications.source_code_type = osteoporosis_medication_codes.code_system\n\n)\n\n, valid_osteoporosis_medications_procedures as (\n\n select\n denominator.patient_id\n , osteoporosis_pharmacy_claims.concept_name as exclusion_reason\n , osteoporosis_pharmacy_claims.dispensing_date as exclusion_date\n from denominator\n inner join osteoporosis_pharmacy_claims\n on denominator.patient_id = osteoporosis_pharmacy_claims.patient_id\n where osteoporosis_pharmacy_claims.dispensing_date\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n \n union all\n\n select\n denominator.patient_id\n , osteoporosis_medications.concept_name as exclusion_reason\n , coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date) as exclusion_date\n from denominator\n inner join osteoporosis_medications\n on denominator.patient_id = osteoporosis_medications.patient_id\n and coalesce(osteoporosis_medications.prescribing_date, osteoporosis_medications.dispensing_date)\n between\n \n\n dateadd(\n month,\n -12,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_tests_performed as (\n\n select\n denominator.patient_id\n , bone_density_test_procedures.concept_name as exclusion_reason\n , procedure_date as exclusion_date\n from denominator\n inner join bone_density_test_procedures\n on denominator.patient_id = bone_density_test_procedures.patient_id\n where bone_density_test_procedures.procedure_date\n between \n \n\n dateadd(\n year,\n -2,\n denominator.performance_period_begin\n )\n\n\n and denominator.performance_period_begin\n\n)\n\n, valid_exclusions as (\n\n select * from valid_tests_performed\n\n union all\n\n select * from valid_osteoporosis_medications_procedures\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'measure specific exclusion for procedure medication' as exclusion_type\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n valid_exclusions", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_exclude_procedures_medications"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.540361Z", "completed_at": "2024-10-25T14:34:50.637781Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.644742Z", "completed_at": "2024-10-25T14:34:50.644742Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.1094059944152832, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_pharmacy_claim as (\n\n\nselect\n patient_id\n , dispensing_date\n , ndc_code\n , days_supply\n , paid_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.pharmacy_claim\n\n\n), __dbt__cte___stg_medication as (\n\n\nselect\n patient_id\n , encounter_id\n , prescribing_date \n , dispensing_date\n , source_code_type\n , source_code\n , ndc_code\n , rxnorm_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medication\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , recorded_date\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0053_denominator\n\n)\n\n, value_sets as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n \n)\n\n, osteo_procedure_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) in (\n 'bone mineral density test'\n , 'bone mineral density tests cpt'\n , 'bone mineral density tests icd10pcs'\n , 'bone mineral density tests hcpcs'\n , 'dexa dual energy xray absorptiometry, bone density'\n , 'central dual energy x-ray absorptiometry (dxa)'\n , 'spinal densitometry x-ray' \n , 'ultrasonography for densitometry' \n , 'ct bone density axial'\n , 'peripheral dual-energy x-ray absorptiometry (dxa)'\n , 'osteoporosis medication'\n )\n\n)\n\n, procedures_osteo_related as (\n\n select\n patient_id\n , procedure_date\n from __dbt__cte___stg_procedure as procs\n inner join osteo_procedure_codes\n on coalesce(procs.normalized_code, procs.source_code) = osteo_procedure_codes.code\n and coalesce(procs.normalized_code_type, procs.source_code_type) = osteo_procedure_codes.code_system\n\n)\n\n, qualifying_procedures as (\n\n select\n procedures_osteo_related.patient_id\n , procedures_osteo_related.procedure_date\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n from procedures_osteo_related\n inner join denominator\n on procedures_osteo_related.patient_id = denominator.patient_id\n and \n procedures_osteo_related.procedure_date between\n denominator.recorded_date \n and\n \n\n dateadd(\n month,\n 6,\n denominator.recorded_date\n )\n\n \n\n)\n\n, denominator_patients_disqualified_from_procedure as (\n \n select \n denominator.patient_id\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , denominator.recorded_date\n , denominator.performance_period_begin\n , denominator.performance_period_end \n from denominator\n left join qualifying_procedures \n on denominator.patient_id = qualifying_procedures.patient_id\n where qualifying_procedures.patient_id is null\n\n)\n\n-- pharmacy_claim begin\n\n, osteo_rx_codes as (\n\n select\n code\n , code_system\n , concept_name\n from value_sets\n where lower(concept_name) \n in \n ( \n 'osteoporosis medications for urology care'\n , 'osteoporosis medication'\n , 'bisphosphonates'\n )\n\n)\n\n, pharmacy_claims_osteo_related as (\n\n select\n patient_id\n , dispensing_date\n , ndc_code \n from __dbt__cte___stg_pharmacy_claim as pharmacy_claims\n inner join osteo_rx_codes\n on pharmacy_claims.ndc_code = osteo_rx_codes.code\n and lower(osteo_rx_codes.code_system) = 'ndc'\n\n)\n\n, qualifying_pharmacy_claims as (\n\n select \n pharmacy_claims_osteo_related.patient_id\n , pharmacy_claims_osteo_related.dispensing_date\n , pharmacy_claims_osteo_related.ndc_code\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from pharmacy_claims_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on pharmacy_claims_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and pharmacy_claims_osteo_related.dispensing_date \n between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n)\n\n-- medication begin\n\n, medication_osteo_related as (\n\n select\n patient_id\n , encounter_id\n , prescribing_date\n , dispensing_date\n , source_code\n , source_code_type\n , ndc_code\n , rxnorm_code\n from __dbt__cte___stg_medication as medications\n inner join osteo_rx_codes\n on medications.source_code = osteo_rx_codes.code\n and medications.source_code_type = osteo_rx_codes.code_system\n\n)\n\n, qualifying_medications as (\n\n select\n medication_osteo_related.patient_id\n , medication_osteo_related.encounter_id\n , denominator_patients_disqualified_from_procedure.measure_id\n , denominator_patients_disqualified_from_procedure.measure_name\n , denominator_patients_disqualified_from_procedure.measure_version\n , denominator_patients_disqualified_from_procedure.recorded_date\n , denominator_patients_disqualified_from_procedure.performance_period_begin\n , denominator_patients_disqualified_from_procedure.performance_period_end\n from medication_osteo_related\n inner join denominator_patients_disqualified_from_procedure\n on medication_osteo_related.patient_id = denominator_patients_disqualified_from_procedure.patient_id\n and coalesce(medication_osteo_related.prescribing_date, medication_osteo_related.dispensing_date) between \n denominator_patients_disqualified_from_procedure.recorded_date \n and \n \n\n dateadd(\n month,\n 6,\n denominator_patients_disqualified_from_procedure.recorded_date\n )\n\n\n\n)\n\n, numerator as (\n\n select\n qualifying_procedures.patient_id\n , qualifying_procedures.performance_period_begin\n , qualifying_procedures.performance_period_end\n , qualifying_procedures.measure_id\n , qualifying_procedures.measure_name\n , qualifying_procedures.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_procedures\n\n union all\n\n select \n qualifying_pharmacy_claims.patient_id\n , qualifying_pharmacy_claims.performance_period_begin\n , qualifying_pharmacy_claims.performance_period_end\n , qualifying_pharmacy_claims.measure_id\n , qualifying_pharmacy_claims.measure_name\n , qualifying_pharmacy_claims.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_pharmacy_claims\n\n union all\n\n select \n qualifying_medications.patient_id\n , qualifying_medications.performance_period_begin\n , qualifying_medications.performance_period_end\n , qualifying_medications.measure_id\n , qualifying_medications.measure_name\n , qualifying_medications.measure_version\n , recorded_date as evidence_date\n , 1 as numerator_flag\n from qualifying_medications\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.597627Z", "completed_at": "2024-10-25T14:34:50.637781Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.645740Z", "completed_at": "2024-10-25T14:34:50.645740Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.11040377616882324, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0059__performance_period\n\n)\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n union all\n select * from valid_dementia_exclusions\n union all\n select * from valid_hospice_palliative\n union all\n select * from valid_institutional_snp\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join dev_thuxuan.quality_measures._int_nqf0059_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.606739Z", "completed_at": "2024-10-25T14:34:50.644742Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.669535Z", "completed_at": "2024-10-25T14:34:50.669535Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.1331930160522461, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_lab_result as (\n\n\nselect\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.lab_result\n\n\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0059_denominator\n\n)\n\n, hba1c_test_code as (\n\n select\n code\n , code_system\n , concept_name\n From dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'hba1c laboratory test'\n )\n\n)\n\n, labs as (\n\n select\n patient_id\n , result\n , result_date\n , collection_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n from __dbt__cte___stg_lab_result\n\n)\n\n, qualifying_labs as (\n\n select\n labs.patient_id\n , labs.result as evidence_value\n , coalesce(collection_date,result_date) as evidence_date\n , hba1c_test_code.concept_name\n , row_number() over(partition by labs.patient_id order by coalesce(collection_date,result_date) desc) as rn\n from labs\n inner join hba1c_test_code\n on coalesce(labs.normalized_code, labs.source_code) = hba1c_test_code.code\n and coalesce(labs.normalized_code_type, labs.source_code_type) = hba1c_test_code.code_system\n left join denominator\n on labs.patient_id = denominator.patient_id\n where coalesce(collection_date,result_date) <= denominator.performance_period_end\n \n and regexp_like(result, '^[+-]?([0-9]*[.])?[0-9]+$')\n \n\n)\n\n, recent_readings as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from qualifying_labs\n where rn = 1\n\n)\n\n, qualifying_patients as (\n\n select\n denominator.*\n , recent_readings.evidence_date\n , recent_readings.evidence_value\n from denominator\n left join recent_readings\n on denominator.patient_id = recent_readings.patient_id\n\n)\n\n, test_not_performed as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , 1 as numerator_flag\n from qualifying_patients\n where\n (evidence_date not between performance_period_begin and performance_period_end)\n or evidence_date is null\n\n)\n\n, valid_patients as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , case\n when cast(evidence_value as numeric(28,6)) > 9.0 then 1\n else 0\n end as numerator_flag\n from qualifying_patients\n where evidence_date between performance_period_begin and performance_period_end\n\n)\n\n, numerator as (\n\n select * from valid_patients\n\n union all\n\n select * from test_not_performed\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from numerator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.638749Z", "completed_at": "2024-10-25T14:34:50.670531Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.673534Z", "completed_at": "2024-10-25T14:34:50.673534Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.06679534912109375, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_exclusions", "compiled": true, "compiled_code": "with valid_hospice_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0097__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0097__performance_period\n\n)\n and lower(exclusion_reason) in (\n 'hospice encounter'\n )\n\n)\n\n, combined_exclusions as (\n\n select \n valid_hospice_exclusions.patient_id\n , valid_hospice_exclusions.exclusion_date\n , valid_hospice_exclusions.exclusion_reason\n , valid_hospice_exclusions.exclusion_type\n from valid_hospice_exclusions\n inner join dev_thuxuan.quality_measures._int_nqf0097_denominator as denominator\n on valid_hospice_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from combined_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.645740Z", "completed_at": "2024-10-25T14:34:50.673534Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.675521Z", "completed_at": "2024-10-25T14:34:50.675521Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.039754629135131836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , discharge_date\n from dev_thuxuan.quality_measures._int_nqf0097_denominator\n\n)\n\n, reconciliation_codes as (\n\n select\n concept_name\n , code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'medication reconciliation post discharge'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, reconciliation_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join reconciliation_codes\n on procedures.code = reconciliation_codes.code\n and procedures.code_type = reconciliation_codes.code_system\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , reconciliation_procedures.procedure_date as evidence_date\n , 1 as numerator_flag\n from denominator\n inner join reconciliation_procedures\n on denominator.patient_id = reconciliation_procedures.patient_id\n where datediff(\n day,\n denominator.discharge_date,\n reconciliation_procedures.procedure_date\n ) between 0 and 30\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.678529Z", "completed_at": "2024-10-25T14:34:50.774212Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.817143Z", "completed_at": "2024-10-25T14:34:50.817143Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.14360952377319336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_exclusions", "compiled": true, "compiled_code": "with __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n \n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0420_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'patient is not eligible for a pain assessment'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n where procedure_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n where coalesce(claim_end_date, claim_start_date) between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0420__performance_period\n\n)\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name as concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, med_claim_exclusions as (\n\n select\n medical_claim.patient_id\n , coalesce(medical_claim.claim_end_date, medical_claim.claim_start_date) as exclusion_date\n , medical_claim.hcpcs_code\n , exclusion_codes.concept_name as concept_name\n from medical_claim\n inner join exclusion_codes\n on medical_claim.hcpcs_code = exclusion_codes.code\n and exclusion_codes.code_system = 'hcpcs'\n\n)\n\n, patients_with_exclusions as(\n \n select\n patient_id\n , exclusion_date\n , concept_name as exclusion_reason\n from med_claim_exclusions\n\n union all\n\n select \n patient_id\n , procedure_date as exclusion_date\n , concept_name as exclusion_reason\n from procedure_exclusions\n\n)\n\n, valid_exclusions as (\n\n select \n patients_with_exclusions.patient_id\n , patients_with_exclusions.exclusion_date\n , patients_with_exclusions.exclusion_reason \n from patients_with_exclusions\n inner join denominator\n on patients_with_exclusions.patient_id = denominator.patient_id\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(1 as integer) as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.730526Z", "completed_at": "2024-10-25T14:34:50.775143Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.818141Z", "completed_at": "2024-10-25T14:34:50.818141Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.14361906051635742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclude_mastectomy", "compiled": true, "compiled_code": "\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy or for whom there is evidence of a right and a left\n unilateral mastectomy\n*/\n\nwith __dbt__cte___stg_condition as (\n\nselect\n patient_id\n , claim_id\n , encounter_id\n , recorded_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.condition\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372_denominator\n\n)\n\n, exclusion_codes as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n , 'Status Post Left Mastectomy'\n , 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Left'\n , 'Unilateral Mastectomy Right'\n , 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n, conditions as (\n\n select\n patient_id\n , recorded_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_condition\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, condition_exclusions as (\n\n select\n conditions.patient_id\n , conditions.recorded_date\n , exclusion_codes.concept_name\n from conditions\n inner join exclusion_codes\n on conditions.code = exclusion_codes.code\n and conditions.code_type = exclusion_codes.code_system\n\n)\n\n, observation_exclusions as (\n\n select\n observations.patient_id\n , observations.observation_date\n , exclusion_codes.concept_name\n from observations\n inner join exclusion_codes\n on observations.code = exclusion_codes.code\n and observations.code_type = exclusion_codes.code_system\n\n)\n\n, procedure_exclusions as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n , exclusion_codes.concept_name\n from procedures\n inner join exclusion_codes\n on procedures.code = exclusion_codes.code\n and procedures.code_type = exclusion_codes.code_system\n\n)\n\n, all_mastectomy as (\n\n select\n denominator.patient_id\n , condition_exclusions.recorded_date as exclusion_date\n , condition_exclusions.concept_name as exclusion_reason\n from denominator\n inner join condition_exclusions\n on denominator.patient_id = condition_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , observation_exclusions.observation_date as exclusion_date\n , observation_exclusions.concept_name as exclusion_reason\n from denominator\n inner join observation_exclusions\n on denominator.patient_id = observation_exclusions.patient_id\n\n union all\n\n select\n denominator.patient_id\n , procedure_exclusions.procedure_date as exclusion_date\n , procedure_exclusions.concept_name as exclusion_reason\n from denominator\n inner join procedure_exclusions\n on denominator.patient_id = procedure_exclusions.patient_id\n\n)\n\n/*\n Women who had a bilateral mastectomy or who have a history of a bilateral\n mastectomy\n*/\n, bilateral_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Bilateral Mastectomy'\n , 'History of bilateral mastectomy'\n )\n\n)\n\n, right_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Right Mastectomy'\n , 'Unilateral Mastectomy Right'\n )\n\n)\n\n, left_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Status Post Left Mastectomy'\n , 'Unilateral Mastectomy Left'\n )\n\n)\n\n, unspecified_mastectomy as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from all_mastectomy\n where exclusion_reason in (\n 'Unilateral Mastectomy, Unspecified Laterality'\n )\n\n)\n\n/*\n Women for whom there is evidence of a right AND a left unilateral mastectomy\n or unspecific mastectomies on different dates\n*/\n, unilateral_mastectomy as (\n\n select\n right_mastectomy.patient_id\n , right_mastectomy.exclusion_date\n , right_mastectomy.exclusion_reason\n from right_mastectomy\n inner join left_mastectomy\n on right_mastectomy.patient_id = left_mastectomy.patient_id\n\n union all\n\n select\n unspecified_mastectomy.patient_id\n , unspecified_mastectomy.exclusion_date\n , unspecified_mastectomy.exclusion_reason\n from unspecified_mastectomy\n inner join unspecified_mastectomy as self_join\n on unspecified_mastectomy.patient_id = self_join.patient_id\n and unspecified_mastectomy.exclusion_date <> self_join.exclusion_date\n\n)\n\n, unioned as (\n\n select * from bilateral_mastectomy\n union all\n select * from unilateral_mastectomy\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned", "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_exclude_mastectomy"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.703530Z", "completed_at": "2024-10-25T14:34:50.775143Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.818141Z", "completed_at": "2024-10-25T14:34:50.818141Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.14462018013000488, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_numerator", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), denominator as (\n\n select \n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf0420_denominator\n\n)\n\n, pain_assessment_code as (\n\n select\n code\n , code_system\n , concept_name\n from dev_thuxuan.quality_measures._value_set_codes\n where lower(concept_name) in (\n 'pain assessment documented'\n )\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, pain_assessment_procedures as (\n\n select \n procedures.patient_id\n , procedures.procedure_date as evidence_date\n from procedures\n inner join pain_assessment_code\n on procedures.code = pain_assessment_code.code\n and procedures.code_type = pain_assessment_code.code_system\n\n)\n\n, pain_assessment_claims as (\n\n select\n patient_id\n , coalesce(claim_end_date, claim_start_date) as evidence_date\n from __dbt__cte___stg_medical_claim medical_claim\n inner join pain_assessment_code\n on medical_claim.hcpcs_code = pain_assessment_code.code\n and lower(pain_assessment_code.code_system) = 'hcpcs'\n\n)\n\n, time_unbounded_qualifying_patients as (\n\n select\n patient_id\n , evidence_date\n from pain_assessment_procedures\n \n union all\n\n select\n patient_id\n , evidence_date\n from pain_assessment_claims\n\n)\n\n, qualifying_patients_with_denominator as (\n\n select \n time_unbounded_qualifying_patients.patient_id\n , time_unbounded_qualifying_patients.evidence_date\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , 1 as numerator_flag\n from time_unbounded_qualifying_patients\n inner join denominator\n on time_unbounded_qualifying_patients.patient_id = denominator.patient_id\n and time_unbounded_qualifying_patients.evidence_date between\n denominator.performance_period_begin and denominator.performance_period_end\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(null as TEXT) as evidence_value\n , cast(numerator_flag as integer) as numerator_flag\n from qualifying_patients_with_denominator\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , evidence_value\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.776163Z", "completed_at": "2024-10-25T14:34:50.824143Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.826141Z", "completed_at": "2024-10-25T14:34:50.826141Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.14961481094360352, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_numerator", "compiled": true, "compiled_code": "\n\n/*\n Eligible population from the denominator model before exclusions\n*/\nwith __dbt__cte___stg_medical_claim as (\n\n\nselect\n patient_id\n , claim_id\n , claim_start_date\n , claim_end_date\n , place_of_service_code\n , hcpcs_code\n , hcpcs_modifier_1\n , hcpcs_modifier_2\n , hcpcs_modifier_3\n , hcpcs_modifier_4\n , hcpcs_modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.medical_claim\n\n\n), __dbt__cte___stg_observation as (\n\n\nselect\n patient_id\n , encounter_id\n , observation_date\n , result\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , normalized_description\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.observation\n\n\n), __dbt__cte___stg_procedure as (\n\nselect\n patient_id\n , encounter_id\n , procedure_date\n , source_code_type\n , source_code\n , normalized_code_type\n , normalized_code\n , modifier_1\n , modifier_2\n , modifier_3\n , modifier_4\n , modifier_5\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.procedure\n), denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , performance_period_lookback\n , measure_id\n , measure_name\n , measure_version\n from dev_thuxuan.quality_measures._int_nqf2372_denominator\n\n)\n\n, mammography_codes as (\n\n select\n code\n , code_system\n from dev_thuxuan.quality_measures._value_set_codes\n where concept_name = 'Mammography'\n\n)\n\n, medical_claim as (\n\n select\n patient_id\n , claim_start_date\n , claim_end_date\n , hcpcs_code\n from __dbt__cte___stg_medical_claim\n\n)\n\n, observations as (\n\n select\n patient_id\n , observation_date\n , coalesce (\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce (\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_observation\n\n)\n\n, procedures as (\n\n select\n patient_id\n , procedure_date\n , coalesce(\n normalized_code_type\n , case\n when lower(source_code_type) = 'cpt' then 'hcpcs'\n when lower(source_code_type) = 'snomed' then 'snomed-ct'\n else lower(source_code_type)\n end\n ) as code_type\n , coalesce(\n normalized_code\n , source_code\n ) as code\n from __dbt__cte___stg_procedure\n\n)\n\n, qualifying_claims as (\n\n select\n medical_claim.patient_id\n , medical_claim.claim_start_date\n , medical_claim.claim_end_date\n from medical_claim\n inner join mammography_codes\n on medical_claim.hcpcs_code = mammography_codes.code\n where mammography_codes.code_system = 'hcpcs'\n\n)\n\n, qualifying_observations as (\n\n select\n observations.patient_id\n , observations.observation_date\n from observations\n inner join mammography_codes\n on observations.code = mammography_codes.code\n and observations.code_type = mammography_codes.code_system\n)\n\n, qualifying_procedures as (\n\n select\n procedures.patient_id\n , procedures.procedure_date\n from procedures\n inner join mammography_codes\n on procedures.code = mammography_codes.code\n and procedures.code_type = mammography_codes.code_system\n\n)\n\n/*\n Check if patients in the eligible population have had a screening,\n diagnostic, film, digital or digital breast tomosynthesis (3D)\n mammography results documented and reviewed.\n*/\n\n, patients_with_mammograms as (\n\n select\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.performance_period_lookback\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_start_date\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_claims.claim_end_date\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_observations.observation_date\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then qualifying_procedures.procedure_date\n else null\n end as evidence_date\n , case\n when qualifying_claims.claim_start_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_claims.claim_end_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_observations.observation_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n when qualifying_procedures.procedure_date\n between denominator.performance_period_lookback\n and denominator.performance_period_end\n then 1\n else 0\n end as numerator_flag\n from denominator\n left join qualifying_claims\n on denominator.patient_id = qualifying_claims.patient_id\n left join qualifying_observations\n on denominator.patient_id = qualifying_observations.patient_id\n left join qualifying_procedures\n on denominator.patient_id = qualifying_procedures.patient_id\n\n)\n\n, add_data_types as (\n\n select distinct\n cast(patient_id as TEXT) as patient_id\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(evidence_date as date) as evidence_date\n , cast(numerator_flag as integer) as numerator_flag\n from patients_with_mammograms\n\n)\n\nselect\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , evidence_date\n , numerator_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_numerator"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.819142Z", "completed_at": "2024-10-25T14:34:50.828143Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.830142Z", "completed_at": "2024-10-25T14:34:50.830142Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.057890892028808594, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_overlap", "compiled": true, "compiled_code": "\n\n-- Here we give a list of all pairs of encounters\n-- that have some date overlap.\n\n\nwith encounters_with_row_num as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over (\n partition by patient_id order by encounter_id\n\t) as row_num\nfrom dev_thuxuan.readmissions._int_encounter\n),\n\n\ncartesian as (\nselect\n aa.encounter_id as encounter_id_A,\n bb.encounter_id as encounter_id_B,\n aa.patient_id,\n aa.admit_date as Ai,\n aa.discharge_date as Af,\n bb.admit_date as Bi,\n bb.discharge_date as Bf,\n case\n when (aa.admit_date between bb.admit_date and bb.discharge_date) or (aa.discharge_date between bb.admit_date and bb.discharge_date) or\n (bb.admit_date between aa.admit_date and aa.discharge_date) or (bb.discharge_date between aa.admit_date and aa.discharge_date)\n then 1\n else 0\n end as overlap\n from encounters_with_row_num aa\n left join encounters_with_row_num bb\n on aa.patient_id = bb.patient_id and aa.row_num < bb.row_num\n),\n\n\noverlapping_pairs\nas\n(\n select\n patient_id,\n encounter_id_A,\n\tencounter_id_B\n from cartesian\n where overlap = 1\n)\n\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom overlapping_pairs", "relation_name": "dev_thuxuan.readmissions._int_encounter_overlap"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.832361Z", "completed_at": "2024-10-25T14:34:50.849327Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.854796Z", "completed_at": "2024-10-25T14:34:50.854796Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.027654647827148438, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_with_ccs", "compiled": true, "compiled_code": "\n\n-- Here we add a CCS diagnosis category to\n-- every encounter that we can add a CCS diagnosis category to.\n-- The CCS diagnosis category is found using\n-- the encounter's primary diagnosis code.\n\n\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.primary_diagnosis_code,\n\n case\n when bb.icd_10_cm is not null then 1\n else 0\n end as valid_primary_diagnosis_code_flag,\n\n cc.ccs_diagnosis_category,\n\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\n\nfrom\n dev_thuxuan.readmissions._int_encounter aa\n left join dev_thuxuan.terminology.icd_10_cm bb\n on aa.primary_diagnosis_code = bb.icd_10_cm\n left join dev_thuxuan.readmissions._value_set_icd_10_cm_to_ccs cc\n on aa.primary_diagnosis_code = cc.icd_10_cm", "relation_name": "dev_thuxuan.readmissions._int_encounter_with_ccs"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.838354Z", "completed_at": "2024-10-25T14:34:50.853331Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.855882Z", "completed_at": "2024-10-25T14:34:50.855882Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.027740001678466797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__index_discharge_requirement", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the discharge_disposition_code requirements to be an\n-- index admission:\n-- *** Must NOT be discharged to another acute care hospital\n-- *** Must NOT have left against medical advice\n-- *** Patient must be alive at discharge\n\n\n\nwith all_invalid_discharges as (\nselect encounter_id\nfrom dev_thuxuan.readmissions._int_encounter\nwhere discharge_disposition_code in (\n '02' -- Patient discharged/transferred to other short term general hospital for inpatient care.\n ,'07' -- Patient left against medical advice\n ,'20' -- Patient died\n )\n)\n\n-- All discharges that meet the discharge_disposition_code\n-- requirements to be an index admission\nselect a.encounter_id, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter a\nleft join all_invalid_discharges b\n on a.encounter_id = b.encounter_id\nwhere b.encounter_id is null", "relation_name": "dev_thuxuan.readmissions._int_index_discharge_requirement"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.842482Z", "completed_at": "2024-10-25T14:34:50.854346Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.856894Z", "completed_at": "2024-10-25T14:34:50.856894Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02775263786315918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__index_time_requirement", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that meet\n-- the time requirement to be an index admission:\n-- The discharge date must be at least 30 days\n-- earlier than the last discharge date available\n-- in the dataset.\n\n\nwith cte as (\n select max(discharge_date) max_discharge\n from dev_thuxuan.readmissions._int_encounter\n)\n\nselect encounter_id\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter\ncross join cte\nwhere discharge_date <= \n\n dateadd(\n day,\n -30,\n cte.max_discharge\n )\n\n", "relation_name": "dev_thuxuan.readmissions._int_index_time_requirement"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.849327Z", "completed_at": "2024-10-25T14:34:50.856894Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.862816Z", "completed_at": "2024-10-25T14:34:50.862816Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.030455350875854492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_exclusions", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_01_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.857900Z", "completed_at": "2024-10-25T14:34:50.865325Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.867329Z", "completed_at": "2024-10-25T14:34:50.867329Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.019006967544555664, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_exclusions", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_03_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.869391Z", "completed_at": "2024-10-25T14:34:50.908929Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.926366Z", "completed_at": "2024-10-25T14:34:50.926366Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.062044620513916016, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system'\n and pqi_number = '05'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_05_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.879894Z", "completed_at": "2024-10-25T14:34:50.910383Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.927392Z", "completed_at": "2024-10-25T14:34:50.927392Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.06408977508544922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nckd as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'exclusion_kidney_disease_diagnosis_codes'\n and pqi_number = '07'\n where c.encounter_id is not null\n),\n\naccess as (\n select distinct\n encounter_id\n , data_source\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'exclusion_dialysis_access_procedure_codes'\n and pqi.pqi_number = '07'\n where c.encounter_id is not null\n),\n\ncombine as (\n select\n c.encounter_id\n , c.data_source\n , 'ckd' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join ckd \n on c.encounter_id = ckd.encounter_id\n and c.data_source = ckd.data_source\n inner join access as a \n on c.encounter_id = a.encounter_id\n and c.data_source = a.data_source\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n \n union all\n \n select\n encounter_id\n , data_source\n , exclusion_reason\n from combine\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_07_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.898938Z", "completed_at": "2024-10-25T14:34:50.927392Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.945378Z", "completed_at": "2024-10-25T14:34:50.945378Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.07902121543884277, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), cardiac as (\n select distinct\n encounter_id\n , data_source\n , 'cardiac procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'cardiac_procedure_codes'\n and pqi.pqi_number = 'appendix_b'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from cardiac\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_08_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.910820Z", "completed_at": "2024-10-25T14:34:50.929377Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.947378Z", "completed_at": "2024-10-25T14:34:50.947378Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.07904863357543945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), sickle_cell as (\n select distinct\n encounter_id\n , data_source\n , 'sickle cell' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'sickle_cell_anemia_or_hb-s_disease_diagnosis_codes'\n and pqi.pqi_number = '11'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from sickle_cell\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_11_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.930377Z", "completed_at": "2024-10-25T14:34:50.949413Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.952880Z", "completed_at": "2024-10-25T14:34:50.952880Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04294395446777344, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), kidney as (\n select distinct\n encounter_id\n , data_source\n , 'kidney' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'kidney_or_urinary_tract_disorder_diagnosis_codes'\n and pqi.pqi_number = '12'\n where c.encounter_id is not null\n),\n\nimmune_dx as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised diagnosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'immunocompromised_state_diagnosis_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nimmune_px as (\n select distinct\n encounter_id\n , data_source\n , 'immunocompromised procedure' as exclusion_reason\n from __dbt__cte___stg_pqi_procedure as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'immunocompromised_state_procedure_codes'\n and pqi.pqi_number = 'appendix_c'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from kidney\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_dx\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from immune_px\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_12_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.952880Z", "completed_at": "2024-10-25T14:34:50.971979Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:50.999479Z", "completed_at": "2024-10-25T14:34:50.999479Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.05309891700744629, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_exclusions", "compiled": true, "compiled_code": "\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_14_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.958906Z", "completed_at": "2024-10-25T14:34:50.998972Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.000993Z", "completed_at": "2024-10-25T14:34:51.000993Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.05157923698425293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), resp_an as (\n select distinct\n encounter_id\n , data_source\n , 'cystic fibrosis' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'cystic_fibrosis_and_anomalies_of_the_respiratory_system_diagnosis_codes'\n and pqi.pqi_number = '15'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from resp_an\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_15_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.971979Z", "completed_at": "2024-10-25T14:34:51.000993Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.009989Z", "completed_at": "2024-10-25T14:34:51.009989Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.05819225311279297, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_exclusions", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), amputation as (\n select distinct\n encounter_id\n , data_source\n , 'amputation' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'traumatic_amputation_of_the_lower_extremity_diagnosis_codes'\n and pqi.pqi_number = '16'\n where c.encounter_id is not null\n),\n\npregnancy as (\n select distinct\n encounter_id\n , data_source\n , 'pregnancy' as exclusion_reason\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi \n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'mdc_14_principal_diagnosis_codes'\n and pqi.pqi_number = 'appendix_f'\n where c.encounter_id is not null\n),\n\nunion_cte as (\n select\n encounter_id\n , data_source\n , exclusion_reason\n from dev_thuxuan.ahrq_measures._int_pqi_shared_exclusion_union\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from amputation\n\n union all\n\n select\n encounter_id\n , data_source\n , exclusion_reason\n from pregnancy\n)\n\nselect\n encounter_id\n , data_source\n , exclusion_reason\n , row_number() over (\n partition by encounter_id, data_source \n order by exclusion_reason\n ) as exclusion_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom union_cte", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_16_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:50.985376Z", "completed_at": "2024-10-25T14:34:51.002063Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.010990Z", "completed_at": "2024-10-25T14:34:51.010990Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.05297708511352539, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ed_classification__summary", "compiled": true, "compiled_code": "\n\n\nwith __dbt__cte__ed_classification__stg_patient as (\n\n\nselect\n patient_id\n , sex\n , birth_date\n , race\n , state\n , zip_code\n , latitude\n , longitude\nfrom dev_thuxuan.core.patient\n) select\n class.encounter_id\n , cat.classification_name as ed_classification_description\n , cat.classification_order as ed_classification_order\n , class.patient_id\n , class.encounter_end_date\n , date_part('year', class.encounter_end_date) || \n\n case when 2 = 0\n then ''\n else\n right(\n '00' || date_part('month', class.encounter_end_date),\n 2\n )\n end as year_month\n , class.primary_diagnosis_code\n , class.primary_diagnosis_description\n , class.paid_amount\n , class.allowed_amount\n , class.charge_amount\n , class.facility_id\n , fac_prov.provider_organization_name as facility_name\n , practice_state as facility_state\n , practice_city as facility_city\n , practice_zip_code as facility_zip_code\n , pat.sex as patient_sex\n , floor(datediff(\n hour,\n pat.birth_date,\n class.encounter_end_date\n ) / 8766.0) as patient_age\n , zip_code as patient_zip_code\n , latitude as patient_latitude\n , longitude as patient_longitude\n , race as patient_race\nfrom dev_thuxuan.ed_classification._int_filter_encounter_with_classification class\ninner join dev_thuxuan.ed_classification._value_set_categories cat\n on class.classification = cat.classification\nleft join dev_thuxuan.terminology.provider fac_prov \n on class.facility_id = fac_prov.npi\nleft join __dbt__cte__ed_classification__stg_patient pat\n on class.patient_id = pat.patient_id", "relation_name": "dev_thuxuan.ed_classification.summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.002989Z", "completed_at": "2024-10-25T14:34:51.013992Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.016671Z", "completed_at": "2024-10-25T14:34:51.016671Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03180122375488281, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0101_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cbe0101_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cbe0101_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cbe0101_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0101_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.017947Z", "completed_at": "2024-10-25T14:34:51.039573Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.047786Z", "completed_at": "2024-10-25T14:34:51.047786Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0357968807220459, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cbe0055_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cbe0055_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cbe0055_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cbe0055_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cbe0055_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.023989Z", "completed_at": "2024-10-25T14:34:51.040585Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.049815Z", "completed_at": "2024-10-25T14:34:51.049815Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03682541847229004, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm130_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm130_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cqm130_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm130_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm130_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.031952Z", "completed_at": "2024-10-25T14:34:51.049278Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.058824Z", "completed_at": "2024-10-25T14:34:51.058824Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.043828725814819336, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, denominator as (\n\n select\n patient_id\n , age\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n )\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_cqm236__performance_period\n\n)\n\n)\n\n, measure_specific_procedure_observation_exclusion as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n , age\n from dev_thuxuan.quality_measures._int_cqm236_exclude_procedures_observations\n\n)\n\n, exclusions as (\n\n select *\n from valid_advanced_illness_exclusions\n \n union all\n\n select *\n from valid_dementia_exclusions\n\n union all\n\n select *\n from valid_hospice_palliative\n\n union all\n\n select *\n from valid_institutional_snp\n\n union all\n\n select *\n from valid_dementia_exclusions\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, frailty_exclusion_older_than_80 as (\n\n select\n frailty.patient_id\n , frailty.exclusion_date\n , frailty.exclusion_reason\n , 'measure specific exclusion for patients older than 80' as exclusion_type\n , denominator.age\n from frailty\n inner join denominator\n on frailty.patient_id = denominator.patient_id\n where denominator.age >= 81\n\n)\n\n, valid_exclusions as (\n\n select * from combined_exclusions\n where exclusion_type != 'hospice_palliative'\n and age >= 66\n\n union all\n\n select * from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n union all\n\n select * from frailty_exclusion_older_than_80\n\n union all\n\n select * from measure_specific_procedure_observation_exclusion\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm236_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.041588Z", "completed_at": "2024-10-25T14:34:51.050821Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.060822Z", "completed_at": "2024-10-25T14:34:51.060822Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.043366432189941406, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm438_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm438_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cqm438_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm438_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm438_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.050821Z", "completed_at": "2024-10-25T14:34:51.062822Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.064822Z", "completed_at": "2024-10-25T14:34:51.064822Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.024236202239990234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm48_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm48_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_cqm48_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm48_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm48_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.066249Z", "completed_at": "2024-10-25T14:34:51.087359Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.098447Z", "completed_at": "2024-10-25T14:34:51.098447Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03862309455871582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0034_long", "compiled": true, "compiled_code": "with denominator as (\n\n select\n patient_id\n from dev_thuxuan.quality_measures._int_nqf0034_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n from dev_thuxuan.quality_measures._int_nqf0034_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0034_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , pp.performance_period_begin\n , pp.performance_period_end\n , (\n select id\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n ) as measure_id\n , (\n\n select name\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_name\n , (\n select version\nfrom dev_thuxuan.quality_measures._value_set_measures\nwhere id = 'NQF0034'\n\n ) as measure_version\n from denominator\n inner join dev_thuxuan.quality_measures._int_nqf0034__performance_period pp\n on 1 = 1\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0034_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.075263Z", "completed_at": "2024-10-25T14:34:51.099357Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.102229Z", "completed_at": "2024-10-25T14:34:51.102229Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03940749168395996, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0041_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0041_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0041_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0041_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0041_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.082270Z", "completed_at": "2024-10-25T14:34:51.100222Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.108936Z", "completed_at": "2024-10-25T14:34:51.108936Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04411482810974121, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions_stage_1", "compiled": true, "compiled_code": "with frailty as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, frailty_within_defined_window as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n lookback_period_december\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where exclusion_date between (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n) and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, exclusion_procedure_and_medication as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_nqf0053_exclude_procedures_medications\n\n)\n\n, valid_institutional_snp as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between\n \n\n dateadd(\n month,\n -6,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n\n and (\n select\n lookback_period_december\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select\n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n )\n\n\n and (\n select\n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf0053__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n\n)\n-- advanced illness end\n\n, frailty_patients_within_defined_window as (\n\n select\n frailty_within_defined_window.patient_id\n , frailty_within_defined_window.exclusion_date\n , frailty_within_defined_window.exclusion_reason\n , 'measure specific exclusion for defined window' as exclusion_type\n from frailty_within_defined_window\n\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n union all\n\n select * from exclusion_procedure_and_medication\n\n union all\n\n select * from frailty_patients_within_defined_window\n\n)\n\nselect\n *\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_exclusions_stage_1"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.092350Z", "completed_at": "2024-10-25T14:34:51.101228Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.109943Z", "completed_at": "2024-10-25T14:34:51.109943Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.036127567291259766, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0059_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0059_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0059_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0059_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0059_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.103186Z", "completed_at": "2024-10-25T14:34:51.111942Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.113945Z", "completed_at": "2024-10-25T14:34:51.113945Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.022584199905395508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0097_long", "compiled": true, "compiled_code": "\n\n/* selecting the full patient population as the grain of this table */\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0097_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0097_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0097_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0097_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.114942Z", "completed_at": "2024-10-25T14:34:51.125397Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.142615Z", "completed_at": "2024-10-25T14:34:51.142615Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.033678293228149414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_exclusions", "compiled": true, "compiled_code": "with frailty as (\n\n select\n *\n from dev_thuxuan.quality_measures._int_shared_exclusions_frailty\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_mastectomy_patients as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf2372_exclude_mastectomy\n)\n\n, valid_hospice_palliative as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_hospice_palliative\n where lower(exclusion_reason) in \n (\n 'palliative care encounter'\n , 'palliative care intervention'\n , 'hospice care ambulatory'\n , 'hospice encounter'\n )\n and\n exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_institutional_snp as (\n\n select \n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_institutional_snp\n where exclusion_date between (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n) and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, valid_dementia_exclusions as (\n\n select\n source.patient_id\n , source.exclusion_date\n , source.exclusion_reason\n , source.exclusion_type\n from dev_thuxuan.quality_measures._int_shared_exclusions_dementia source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where (\n source.dispensing_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n or source.paid_date\n between \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n)\n\n-- advanced illness start\n, advanced_illness_exclusion as (\n\n select\n source.*\n from dev_thuxuan.quality_measures._int_shared_exclusions_advanced_illness as source\n inner join frailty\n on source.patient_id = frailty.patient_id\n where source.exclusion_date\n between\n \n\n dateadd(\n year,\n -1,\n (\n select \n performance_period_begin\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n )\n\n\n and (\n select \n performance_period_end\n from dev_thuxuan.quality_measures._int_nqf2372__performance_period\n\n)\n\n)\n\n, acute_inpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'acute_inpatient'\n\n)\n\n, nonacute_outpatient_advanced_illness as (\n\n select\n *\n from advanced_illness_exclusion\n where patient_type = 'nonacute_outpatient'\n\n)\n\n, acute_inpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from acute_inpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, nonacute_outpatient_counts as (\n\n select\n patient_id\n , exclusion_type\n , count(distinct exclusion_date) as encounter_count\n from nonacute_outpatient_advanced_illness\n group by patient_id, exclusion_type\n\n)\n\n, valid_advanced_illness_exclusions as (\n\n select\n acute_inpatient_advanced_illness.patient_id\n , acute_inpatient_advanced_illness.exclusion_date\n , acute_inpatient_advanced_illness.exclusion_reason\n , acute_inpatient_advanced_illness.exclusion_type\n from acute_inpatient_advanced_illness\n left join acute_inpatient_counts\n on acute_inpatient_advanced_illness.patient_id = acute_inpatient_counts.patient_id\n where acute_inpatient_counts.encounter_count >= 1\n\n union all\n\n select\n nonacute_outpatient_advanced_illness.patient_id\n , nonacute_outpatient_advanced_illness.exclusion_date\n , nonacute_outpatient_advanced_illness.exclusion_reason\n , nonacute_outpatient_advanced_illness.exclusion_type\n from nonacute_outpatient_advanced_illness\n left join nonacute_outpatient_counts\n on nonacute_outpatient_advanced_illness.patient_id = nonacute_outpatient_counts.patient_id\n where nonacute_outpatient_counts.encounter_count >= 2\n\n)\n-- advanced illness end\n\n, valid_mastectomy_patients_with_exclusion_type as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , 'mastectomy_performed' as exclusion_type\n from valid_mastectomy_patients\n)\n\n, exclusions as (\n\n select * from valid_advanced_illness_exclusions\n\n union all\n\n select * from valid_dementia_exclusions\n\n union all\n\n select * from valid_institutional_snp\n\n union all\n\n select * from valid_hospice_palliative\n\n)\n\n, combined_exclusions as (\n\n select \n exclusions.*\n , denominator.age\n from exclusions\n inner join dev_thuxuan.quality_measures._int_nqf2372_denominator denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type != 'hospice_palliative' \n and age >= 66\n\n union all\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_type\n from combined_exclusions\n where exclusion_type = 'hospice_palliative'\n\n)\n\n, valid_exclusions_with_mastectomy as (\n\n select *\n from valid_exclusions\n\n union all\n\n select *\n from valid_mastectomy_patients_with_exclusion_type\n\n)\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions_with_mastectomy\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.126434Z", "completed_at": "2024-10-25T14:34:51.144614Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.151625Z", "completed_at": "2024-10-25T14:34:51.151625Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03868246078491211, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0420_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0420_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0420_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0420_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0420_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.131525Z", "completed_at": "2024-10-25T14:34:51.145613Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.152620Z", "completed_at": "2024-10-25T14:34:51.152620Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.038675546646118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__readmission_crude", "compiled": true, "compiled_code": "\n\n-- Here we calculate readmissions using all encounters\n-- that have valid admit and discharge dates and no overlap.\n-- This is meant to give a crude sense of the readmission\n-- rate without taking into account all the CMS HWR logic.\n\n\nwith encounter_info as (\nselect\n enc.encounter_id,\n enc.patient_id,\n enc.admit_date,\n enc.discharge_date\nfrom dev_thuxuan.readmissions._int_encounter enc\nleft join dev_thuxuan.readmissions._int_encounter_overlap over_a\n on enc.encounter_id = over_a.encounter_id_A\nleft join dev_thuxuan.readmissions._int_encounter_overlap over_b\n on enc.encounter_id = over_b.encounter_id_B\nwhere\n admit_date is not null\n and\n discharge_date is not null\n and\n admit_date <= discharge_date\nand over_a.encounter_id_A is null and over_b.encounter_id_B is null\n ),\n\n\nencounter_sequence as (\nselect\n encounter_id,\n patient_id,\n admit_date,\n discharge_date,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom encounter_info\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n case\n when bb.encounter_id is not null then 1\n\telse 0\n end as had_readmission_flag,\n datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n bb.admit_date,\n aa.discharge_date\n )) <= 30 then 1\n\telse 0\n end as readmit_30_flag\nfrom encounter_sequence aa left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom readmission_calc", "relation_name": "dev_thuxuan.readmissions._int_readmission_crude"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.137444Z", "completed_at": "2024-10-25T14:34:51.145613Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.153624Z", "completed_at": "2024-10-25T14:34:51.153624Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.030681848526000977, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_data_quality", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter table\n-- with data quality flags that may disqualify them from\n-- being used for readmission measures \n\n\n-- Flag several potential data quality issues\n-- with all encounters.\n-- Every encounter_id from the stg_encounter model\n-- will be here. This CTE should have the same\n-- number of rows as the stg_encounter model, i.e.,\n-- there is a one to one correspondence between the\n-- rows in stg_encounter and this CTE.\nwith encounter_data_quality_issues as (\nselect\n aa.encounter_id,\n case\n when aa.admit_date is null then 1\n\telse 0\n end as missing_admit_date_flag,\n case\n when aa.discharge_date is null then 1\n\telse 0\n end as missing_discharge_date_flag,\n case\n when aa.admit_date > aa.discharge_date then 1\n\telse 0\n end as admit_after_discharge_flag,\n case\n when aa.discharge_disposition_code is null then 1\n\telse 0\n end as missing_discharge_disposition_code_flag,\n case\n when\n\t (aa.discharge_disposition_code is not null)\n\t and\n\t (bb.discharge_disposition_code is null) then 1\n\telse 0\n end as invalid_discharge_disposition_code_flag,\n case\n when aa.primary_diagnosis_code is null then 1\n else 0\n end as missing_primary_diagnosis_flag,\n case\n when aa.valid_primary_diagnosis_code_flag = 0 then 1\n\telse 0\n end as invalid_primary_diagnosis_code_flag,\n case\n when aa.ccs_diagnosis_category is null then 1\n\telse 0\n end as no_diagnosis_ccs_flag,\n aa.ccs_diagnosis_category as diagnosis_ccs,\n case\n when aa.encounter_id in (select distinct encounter_id_A\n\t from dev_thuxuan.readmissions._int_encounter_overlap )\n\t or\n\t aa.encounter_id in (select distinct encounter_id_B\n\t from dev_thuxuan.readmissions._int_encounter_overlap )\n\tthen 1\n\telse 0\n end as overlaps_with_another_encounter_flag,\n case\n when aa.ms_drg_code is null then 1\n\telse 0\n end as missing_ms_drg_flag,\n case\n when cc.ms_drg_code is null then 1\n\telse 0\n end as invalid_ms_drg_flag\n\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs aa\n left join dev_thuxuan.terminology.discharge_disposition bb\n on aa.discharge_disposition_code = bb.discharge_disposition_code\n left join dev_thuxuan.terminology.ms_drg cc\n on aa.ms_drg_code = cc.ms_drg_code\n),\n\n\n-- Here we add a disqualified_encounter_flag.\n-- This disqualified_encounter_flag = 1\n-- when any of the critical data quality flags\n-- from the above CTE are equal to 1.\nall_data_quality_flags as (\nselect\n encounter_id,\n diagnosis_ccs,\n case\n when\n\t (missing_admit_date_flag = 1)\n\t or\n\t (missing_discharge_date_flag = 1)\n\t or\n\t (admit_after_discharge_flag = 1)\n\t or\n\t (missing_discharge_disposition_code_flag = 1)\n\t or\n\t (invalid_discharge_disposition_code_flag = 1)\n\t or\n\t (missing_primary_diagnosis_flag = 1)\n\t or\n\t (invalid_primary_diagnosis_code_flag = 1)\n\t or\n\t (no_diagnosis_ccs_flag = 1)\n\t or\n\t (overlaps_with_another_encounter_flag = 1)\n\t or\n\t (missing_ms_drg_flag = 1)\n\t or\n\t (invalid_ms_drg_flag = 1)\n\t then 1\n\telse 0\n end as disqualified_encounter_flag,\n missing_admit_date_flag,\n missing_discharge_date_flag,\n admit_after_discharge_flag,\n missing_discharge_disposition_code_flag,\n invalid_discharge_disposition_code_flag,\n missing_primary_diagnosis_flag,\n invalid_primary_diagnosis_code_flag,\n no_diagnosis_ccs_flag,\n overlaps_with_another_encounter_flag,\n missing_ms_drg_flag,\n invalid_ms_drg_flag\nfrom encounter_data_quality_issues\n) \n\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom all_data_quality_flags", "relation_name": "dev_thuxuan.readmissions._int_encounter_data_quality"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.146615Z", "completed_at": "2024-10-25T14:34:51.154621Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.156620Z", "completed_at": "2024-10-25T14:34:51.156620Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.020098447799682617, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_specialty_cohort", "compiled": true, "compiled_code": "\n\n-- Here we list the specialty cohort for each encounter that has\n-- an associated specialty cohort.\n-- There are 5 possible specialty cohorts:\n-- [1] Medicine\n-- [2] Surgery/Gynecology\n-- [3] Cardiology\n-- [4] Cardiovascular\n-- [5] Neurology\n-- An encounter that has an ICD-10-PCS procedure code or a\n-- CCS procedure category that corresponds to the\n-- 'Surgery/Gynecology' cohort will always be in that cohort.\n-- For encounters that are not in the 'Surgery/Gynecology' cohort,\n-- we then check to see if they are in one of the other 4 cohorts.\n\n--ranking to eventually assign a cohort to encounters in multiple cohorts\nwith cohort_ranks as (\n select 'Surgery/Gynecology' as cohort, 1 as c_rank\n union all\n select 'Cardiorespiratory' as cohort, 2 as c_rank\n union all\n select 'Cardiovascular' as cohort, 3 as c_rank\n union all\n select 'Neurology' as cohort, 4 as c_rank\n union all\n select 'Medicine' as cohort, 5 as c_rank\n)\n\n\n--get all encounter ids in any procedure or diagnosis based cohorts\n, all_encounter_cohorts as (\n\n --encounter ids in procedure based cohorts\n select procs.encounter_id, 1 as c_rank\n from dev_thuxuan.readmissions._int_procedure_ccs procs\n left join dev_thuxuan.readmissions._value_set_surgery_gynecology_cohort sgc\n on procs.procedure_code = sgc.icd_10_pcs\n left join dev_thuxuan.readmissions._value_set_specialty_cohort sgsc\n on procs.ccs_procedure_category = sgsc.ccs and sgsc.specialty_cohort = 'Surgery/Gynecology'\n where sgc.icd_10_pcs is not null or sgsc.ccs is not null\n\n union all\n\n --encounter ids in diagnosis based cohorts\n select diag.encounter_id, cohort_ranks.c_rank\n from dev_thuxuan.readmissions._int_encounter_with_ccs diag\n inner join dev_thuxuan.readmissions._value_set_specialty_cohort sc\n on diag.ccs_diagnosis_category = sc.ccs and sc.procedure_or_diagnosis = 'Diagnosis'\n inner join cohort_ranks\n on sc.specialty_cohort = cohort_ranks.cohort\n)\n\n\n-- getting one cohort per encounter\n, main_encounter_cohort as (\n select encounter_id, min(c_rank) as main_c_rank\n from all_encounter_cohorts\n group by encounter_id\n\n)\n\n\n--getting all encounters, with labeled cohorts, if no cohort cohort is \"medicine\"\nselect enc.encounter_id, coalesce(cohort_ranks.cohort, 'Medicine') as specialty_cohort, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter enc\nleft join main_encounter_cohort mec\n on enc.encounter_id = mec.encounter_id\nleft join cohort_ranks\n on mec.main_c_rank = cohort_ranks.c_rank", "relation_name": "dev_thuxuan.readmissions._int_encounter_specialty_cohort"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.157620Z", "completed_at": "2024-10-25T14:34:51.163623Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.186135Z", "completed_at": "2024-10-25T14:34:51.186135Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.034520626068115234, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__exclusion", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids that are excluded\n-- from being index admissions because they\n-- belong to one of these categories:\n-- [1] Medical Treatment of Cancer\n-- [2] Rehabilitation\n-- [3] Psychiatric\n\n\n-- encounter_ids for encounters that should be\n-- excluded because they belong to one of the\n-- exclusion categories\nwith exclusions as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs\nwhere\n(ccs_diagnosis_category is not null)\nand\n(\nccs_diagnosis_category in\n (select distinct ccs_diagnosis_category\n from dev_thuxuan.readmissions._value_set_exclusion_ccs_diagnosis_category )\n)\n)\n\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom exclusions", "relation_name": "dev_thuxuan.readmissions._int_exclusion"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.163623Z", "completed_at": "2024-10-25T14:34:51.189143Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.200149Z", "completed_at": "2024-10-25T14:34:51.200149Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.04452848434448242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__planned_encounter", "compiled": true, "compiled_code": "\n\n-- Here we list encounter_ids for all encounters\n-- that are planned.\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a procedure category\n-- that is only present for planned encounters \nwith always_planned_px as (\nselect distinct pccs.encounter_id\nfrom dev_thuxuan.readmissions._int_procedure_ccs pccs\ninner join dev_thuxuan.readmissions._value_set_always_planned_ccs_procedure_category apc\n on pccs.ccs_procedure_category = apc.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that we know\n-- are planned because they had a diagnosis category\n-- that is only present for planned encounters\nalways_planned_dx as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs dccs\ninner join dev_thuxuan.readmissions._value_set_always_planned_ccs_diagnosis_category apd\n on dccs.ccs_diagnosis_category = apd.ccs_diagnosis_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on one of their CCS procedure categories.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_ccs as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_procedure_ccs pccs\ninner join dev_thuxuan.readmissions._value_set_potentially_planned_ccs_procedure_category pcs\n on pccs.ccs_procedure_category = pcs.ccs_procedure_category\n),\n\n\n-- encounter_ids for encounters that are potentially planned\n-- based on their ICD-10-PCS procedure codes.\n-- For these encounters to actually be planned, we must further\n-- require that they are NOT acute encounters\npotentially_planned_px_icd_10_pcs as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_procedure_ccs pcs\ninner join dev_thuxuan.readmissions._value_set_potentially_planned_icd_10_pcs pps\n on pcs.procedure_code = pps.icd_10_pcs\n),\n\n\n-- encounter_ids for encounters that are acute based\n-- on their primary diagnosis code or their CCS diagnosis category\nacute_encounters as (\nselect distinct encounter_id\nfrom dev_thuxuan.readmissions._int_encounter_with_ccs dccs\nleft join dev_thuxuan.readmissions._value_set_acute_diagnosis_icd_10_cm adi\n on dccs.primary_diagnosis_code = adi.icd_10_cm\nleft join dev_thuxuan.readmissions._value_set_acute_diagnosis_ccs adc\n on dccs.ccs_diagnosis_category = adc.ccs_diagnosis_category\nwhere adi.icd_10_cm is not null or adc.ccs_diagnosis_category is not null\n),\n\n\n-- encounter_ids for encounters that are:\n-- [1] potentially planned, based on one of\n-- their CCS procedure categories or\n-- their ICD-10-PCS procedure codes\n-- [2] not acute, based on their primary diagnosis code\n-- or their CCS diagnosis category\n-- These encounters are therefore confirmed to be planned\npotentially_planned_that_are_actually_planned as (\nselect distinct ppp.encounter_id\nfrom (\n select * from potentially_planned_px_ccs\n union all\n select * from potentially_planned_px_icd_10_pcs) ppp\nleft join acute_encounters\n on ppp.encounter_id = acute_encounters.encounter_id\nwhere acute_encounters.encounter_id is null\n\n)\n\n\n-- Aggregate of all encounter_ids for planned encounters\n\nselect * , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from always_planned_px\n\nunion distinct\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from always_planned_dx\n\nunion distinct\n\nselect *, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run from potentially_planned_that_are_actually_planned", "relation_name": "dev_thuxuan.readmissions._int_planned_encounter"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.175137Z", "completed_at": "2024-10-25T14:34:51.190136Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.201150Z", "completed_at": "2024-10-25T14:34:51.201150Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04452991485595703, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_01_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_short-term_complications_diagnosis_codes'\n and pqi.pqi_number = '01'\ninner join dev_thuxuan.ahrq_measures._int_pqi_01_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_01_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_01_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.179139Z", "completed_at": "2024-10-25T14:34:51.191143Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.202150Z", "completed_at": "2024-10-25T14:34:51.202150Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0405278205871582, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_03_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on e.primary_diagnosis_code = pqi.code\n and pqi.value_set_name = 'diabetes_with_long-term_complications_diagnosis_codes'\n and pqi.pqi_number = '03'\ninner join dev_thuxuan.ahrq_measures._int_pqi_03_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_03_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_03_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.192161Z", "completed_at": "2024-10-25T14:34:51.205201Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.208305Z", "completed_at": "2024-10-25T14:34:51.208305Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.03416705131530762, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_05_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._int_pqi_05_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._value_set_pqi as copd\n on e.primary_diagnosis_code = copd.code\n and copd.value_set_name = 'chronic_obstructive_pulmonary_disorder'\n and copd.pqi_number = '05'\nleft join dev_thuxuan.ahrq_measures._value_set_pqi asthma\n on e.primary_diagnosis_code = asthma.code\n and asthma.value_set_name = 'asthma'\n and asthma.pqi_number = '05'\nleft join dev_thuxuan.ahrq_measures._int_pqi_05_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null\n and (\n asthma.code is not null \n or copd.code is not null\n )", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_05_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.209639Z", "completed_at": "2024-10-25T14:34:51.225882Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.232592Z", "completed_at": "2024-10-25T14:34:51.232592Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.029442548751831055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_07_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'hypertension_diagnosis_codes'\n and hyp.pqi_number = '07'\ninner join dev_thuxuan.ahrq_measures._int_pqi_07_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_07_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_07_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.216790Z", "completed_at": "2024-10-25T14:34:51.231788Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.239287Z", "completed_at": "2024-10-25T14:34:51.239287Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.03213787078857422, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_08_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'heart_failure_diagnosis_codes'\n and hyp.pqi_number = '08'\ninner join dev_thuxuan.ahrq_measures._int_pqi_08_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_08_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_08_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.221788Z", "completed_at": "2024-10-25T14:34:51.233329Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.240295Z", "completed_at": "2024-10-25T14:34:51.240295Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.03314542770385742, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_11_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'community_acquired_bacterial_pneumonia_diagnosis_codes'\n and hyp.pqi_number = '11'\ninner join dev_thuxuan.ahrq_measures._int_pqi_11_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_11_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_11_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.226839Z", "completed_at": "2024-10-25T14:34:51.239287Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.241348Z", "completed_at": "2024-10-25T14:34:51.241348Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.03219270706176758, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_12_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'urinary_tract_infection_diagnosis_codes'\n and hyp.pqi_number = '12'\ninner join dev_thuxuan.ahrq_measures._int_pqi_12_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_12_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_12_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.233682Z", "completed_at": "2024-10-25T14:34:51.242371Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.245177Z", "completed_at": "2024-10-25T14:34:51.245177Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.01929473876953125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_14_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'uncontrolled_diabetes_diagnosis_codes'\n and hyp.pqi_number = '14'\ninner join dev_thuxuan.ahrq_measures._int_pqi_14_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_14_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_14_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.248465Z", "completed_at": "2024-10-25T14:34:51.281946Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.286925Z", "completed_at": "2024-10-25T14:34:51.286925Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.043355703353881836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_15_num", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._value_set_pqi as hyp\n on e.primary_diagnosis_code = hyp.code\n and hyp.value_set_name = 'asthma_diagnosis_codes'\n and hyp.pqi_number = '15'\ninner join dev_thuxuan.ahrq_measures._int_pqi_15_denom as denom\n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\nleft join dev_thuxuan.ahrq_measures._int_pqi_15_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_15_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.254888Z", "completed_at": "2024-10-25T14:34:51.287934Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.299940Z", "completed_at": "2024-10-25T14:34:51.299940Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.05414271354675293, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__int_pqi_16_num", "compiled": true, "compiled_code": "\n\nwith __dbt__cte___stg_pqi_condition as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.condition\n), __dbt__cte___stg_pqi_procedure as (\n\n\nselect \n normalized_code_type\n , normalized_code\n , encounter_id\n , data_source\nfrom \n dev_thuxuan.core.procedure\n), diagnosis as (\n select distinct\n c.encounter_id\n , c.data_source\n from __dbt__cte___stg_pqi_condition as c\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on c.normalized_code = pqi.code\n and c.normalized_code_type = 'icd-10-cm'\n and pqi.value_set_name = 'diabetes_diagnosis_codes'\n and pqi_number = '16'\n where c.encounter_id is not null\n),\n\n\nprocedures as (\n select distinct\n p.encounter_id\n , p.data_source\n from __dbt__cte___stg_pqi_procedure as p\n inner join diagnosis as d \n on p.encounter_id = d.encounter_id\n and d.data_source = p.data_source\n inner join dev_thuxuan.ahrq_measures._value_set_pqi as pqi\n on p.normalized_code = pqi.code\n and p.normalized_code_type = 'icd-10-pcs'\n and pqi.value_set_name = 'lower-extremity_amputation_procedure_codes'\n and pqi_number = '16'\n)\n\nselect\n e.data_source\n , e.patient_id\n , e.year_number\n , e.encounter_id\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter as e\ninner join dev_thuxuan.ahrq_measures._int_pqi_16_denom as denom \n on e.patient_id = denom.patient_id\n and e.data_source = denom.data_source\n and e.year_number = denom.year_number\n inner join procedures as p\n on e.encounter_id = p.encounter_id\n and e.data_source = p.data_source\nleft join dev_thuxuan.ahrq_measures._int_pqi_16_exclusions as shared\n on e.encounter_id = shared.encounter_id\n and e.data_source = shared.data_source\nwhere shared.encounter_id is null", "relation_name": "dev_thuxuan.ahrq_measures._int_pqi_16_num"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.269085Z", "completed_at": "2024-10-25T14:34:51.287934Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.299940Z", "completed_at": "2024-10-25T14:34:51.299940Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.05402374267578125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_exclusion_long", "compiled": true, "compiled_code": "\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 1 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_01_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 3 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_03_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 5 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_05_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 7 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_07_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 8 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_08_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 11 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_11_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 12 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_12_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 14 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_14_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 15 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_15_exclusions as e\n\nunion all\n\nselect\n e.data_source\n , e.encounter_id\n , e.exclusion_reason\n , e.exclusion_number\n , 16 as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_16_exclusions as e", "relation_name": "dev_thuxuan.ahrq_measures.pqi_exclusion_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.281946Z", "completed_at": "2024-10-25T14:34:51.298933Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.301931Z", "completed_at": "2024-10-25T14:34:51.301931Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.05450439453125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__ed_classification", "compiled": true, "compiled_code": "\n\nwith cte as (\n select \n max(case when ed_classification_description = 'Emergent, ED Care Needed, Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_preventable,\n max(case when ed_classification_description = 'Emergent, Primary Care Treatable' then 1 else 0 end) as pc_treatable,\n max(case when ed_classification_description = 'Emergent, ED Care Needed, Not Preventable/Avoidable' then 1 else 0 end) as ed_care_needed_not_preventable,\n max(case when ed_classification_description = 'Non-Emergent' then 1 else 0 end) as non_emergent\n from dev_thuxuan.ed_classification.summary\n)\n\n,final as (\nselect 'ed classification missing ed_care_needed_preventable' as data_quality_check,\n case when ed_care_needed_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing pc_treatable' as data_quality_check,\n case when pc_treatable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing ed_care_needed_not_preventable' as data_quality_check,\n case when ed_care_needed_not_preventable = 0 then 1 else 0 end as result_count\nfrom cte\n\nunion all\n\nselect 'ed classification missing non_emergent' as data_quality_check,\n case when non_emergent = 0 then 1 else 0 end as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.data_quality_ed_classification"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.288931Z", "completed_at": "2024-10-25T14:34:51.302937Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.304930Z", "completed_at": "2024-10-25T14:34:51.304930Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.05058693885803223, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__ed_classification_reference", "compiled": true, "compiled_code": "\n\nwith total_cte as \n(\nselect count(*) as total_encounters\nfrom dev_thuxuan.core.encounter\nwhere encounter_type = cast('emergency department' as TEXT)\n) \n\n,final as (\nselect coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT)) as ed_classification_description\n,count(*) as encounters\n,total_cte.total_encounters\n,count(*)/total_cte.total_encounters as percent_of_total\n,row_number() over (order by count(*) desc) as value_rank\nfrom dev_thuxuan.core.encounter e\ncross join total_cte\nleft join dev_thuxuan.ed_classification.summary s on e.encounter_id = s.encounter_id \nwhere encounter_type = cast('emergency department' as TEXT)\ngroup by coalesce(cast(ed_classification_description as TEXT), cast('Not Classified' as TEXT))\n,total_cte.total_encounters\n)\n\n,actually_final as (\nselect cast('ed classification' as TEXT) as analytics_concept\n,ed_classification_description as analytics_measure\n,percent_of_total as data_source_value\n,value_rank as value_rank\nfrom final\n)\n\nselect m.analytics_concept\n,m.analytics_measure\n,data_source_value\n,m.analytics_value\n,m.value_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join actually_final on actually_final.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = actually_final.analytics_concept\nwhere m.analytics_concept = cast('ed classification' as TEXT)", "relation_name": "dev_thuxuan.data_quality.data_quality_ed_classification_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.306942Z", "completed_at": "2024-10-25T14:34:51.318944Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.346036Z", "completed_at": "2024-10-25T14:34:51.346036Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.0451045036315918, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__ed_classification", "compiled": true, "compiled_code": "\n\nWITH cte AS\n(\n SELECT DISTINCT location_id, npi, name\n FROM dev_thuxuan.core.location\n)\n\nSELECT\n e.encounter_id,\n case when s.encounter_id is null then 'Not Classified' else s.ed_classification_description end as ed_classification_description,\n CASE\n when s.encounter_id is null then 'Non-Avoidable'\n when cast(s.ed_classification_order as int) <= 3 then s.ed_classification_description\n ELSE 'Non-Avoidable' END AS avoidable_category,\n e.paid_amount,\n e.primary_diagnosis_code,\n e.primary_diagnosis_description,\n e.primary_diagnosis_code || '|' || e.primary_diagnosis_description as primary_diagnosis_and_description,\n p.ccsr_parent_category,\n p.ccsr_category,\n p.ccsr_category_description,\n p.ccsr_category || '|' || p.ccsr_category_description as ccsr_parent_category_and_description,\n b.body_system,\n e.facility_id,\n e.allowed_amount,\n e.charge_amount,\n e.data_source,\n e.length_of_stay,\n e.discharge_disposition_code || '|' || e.discharge_disposition_description as discharge_code_and_description,\n e.patient_id || '|' || e.data_source as patient_source_key,\n e.facility_name,\n e.encounter_start_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.encounter e\nleft join dev_thuxuan.ed_classification.summary s on e.encounter_id = s.encounter_id\nleft join cte on e.facility_id = cte.location_id\nleft join dev_thuxuan.ccsr.dx_vertical_pivot as p\n on e.primary_diagnosis_code = p.code\n and p.ccsr_category_rank = 1\nleft join dev_thuxuan.ccsr._value_set_dxccsr_v2023_1_body_systems b on p.ccsr_parent_category = b.ccsr_parent_category\nwhere e.encounter_type = 'emergency department'", "relation_name": "dev_thuxuan.data_quality.mart_review__ed_classification"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.318944Z", "completed_at": "2024-10-25T14:34:51.347020Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.354049Z", "completed_at": "2024-10-25T14:34:51.354049Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.049118757247924805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_cqm236_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_cqm236_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , observation_date\n from dev_thuxuan.quality_measures._int_cqm236_numerator\n where numerator_flag = 1\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_cqm236_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.observation_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.observation_date is null then 1 else 0 end,\n numerator.observation_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , observation_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(observation_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_cqm236_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.334216Z", "completed_at": "2024-10-25T14:34:51.353039Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.355050Z", "completed_at": "2024-10-25T14:34:51.355050Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0411076545715332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf2372_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf2372_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , numerator_flag\n from dev_thuxuan.quality_measures._int_nqf2372_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n from dev_thuxuan.quality_measures._int_nqf2372_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then denominator.denominator_flag\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null\n then numerator.numerator_flag\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null\n then exclusions.exclusion_flag\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, add_rownum as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , row_number() over(\n partition by\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n order by\n case when evidence_date is null then 1 else 0 end,\n evidence_date desc\n , case when exclusion_date is null then 1 else 0 end,\n exclusion_date desc\n ) as row_num\n from measure_flags\n\n)\n\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from add_rownum\n where row_num = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , cast(null as TEXT) as evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf2372_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.327931Z", "completed_at": "2024-10-25T14:34:51.353039Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.356039Z", "completed_at": "2024-10-25T14:34:51.356039Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.05110669136047363, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_exclusions", "compiled": true, "compiled_code": "\n\nwith\n\ncombined_exclusions as (\n\n select\n exclusions.*\n , denominator.age\n from dev_thuxuan.quality_measures._int_nqf0053_exclusions_stage_1 as exclusions\n inner join dev_thuxuan.quality_measures._int_nqf0053_denominator as denominator\n on exclusions.patient_id = denominator.patient_id\n\n)\n\n, valid_exclusions as (\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'institutional_snp'\n and age >= 66\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'advanced_illness'\n , 'dementia'\n )\n and age between 66 and 80\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type = 'measure specific exclusion for defined window'\n and age >= 81\n\n union all\n\n select\n *\n from combined_exclusions\n where exclusion_type in\n (\n 'measure specific exclusion for procedure medication'\n , 'hospice_palliative'\n )\n\n)\n\n\n, add_data_types as (\n\n select\n distinct\n cast(patient_id as TEXT) as patient_id\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , 1 as exclusion_flag\n from valid_exclusions\n\n)\n\nselect\n patient_id\n , exclusion_date\n , exclusion_reason\n , exclusion_flag\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_exclusions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.348021Z", "completed_at": "2024-10-25T14:34:51.356039Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.359037Z", "completed_at": "2024-10-25T14:34:51.359037Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04110550880432129, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__index_admission", "compiled": true, "compiled_code": "\n\n-- Here we list all index admissions for the hospital wide readmissions\n-- measure.\n-- These represent encounter_ids that meet the requirements to be an\n-- index admission for the HWR measure.\n-- These are the requirements for a hospitalization to be an index admission\n-- for the HWR measure:\n--\n-- Time Requirement: The discharge data must be at least 30 days\n-- earlier than the last dischareg date available\n-- in the dataset.\n-- \n-- Discharge Requirements: The patient must not be discharged to another\n-- acute care hospital; the patient must not have\n-- left against medical advice; and the patient\n-- must be alive at discharge.\n--\n-- Diagnosis Requirements: Exclude encounters where based on the CCS\n-- (exclusions) diagnosis category we know the encounter was\n-- for medical treatment of cancer, rehabilitation,\n-- or psychiatric reasons.\n\n\n\nselect distinct a.encounter_id, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.readmissions._int_encounter a\ninner join dev_thuxuan.readmissions._int_index_time_requirement b\n on a.encounter_id = b.encounter_id\ninner join dev_thuxuan.readmissions._int_index_discharge_requirement c\n on a.encounter_id = c.encounter_id\nleft join dev_thuxuan.readmissions._int_exclusion d\n on a.encounter_id = d.encounter_id\nwhere d.encounter_id is null", "relation_name": "dev_thuxuan.readmissions._int_index_admission"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.362039Z", "completed_at": "2024-10-25T14:34:51.382477Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.390403Z", "completed_at": "2024-10-25T14:34:51.390403Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.03336477279663086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_num_long", "compiled": true, "compiled_code": "\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '01' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_01_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '03' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_03_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '05' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_05_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '07' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_07_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '08' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_08_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '11' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_11_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '12' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_12_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '14' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_14_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '15' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_15_num as n\n\nunion all\n\nselect\n n.data_source\n , n.patient_id\n , n.year_number\n , n.encounter_id\n , '16' as pqi_number\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures._int_pqi_16_num as n", "relation_name": "dev_thuxuan.ahrq_measures.pqi_num_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.376581Z", "completed_at": "2024-10-25T14:34:51.391403Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.392403Z", "completed_at": "2024-10-25T14:34:51.392403Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.031360626220703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__int_nqf0053_long", "compiled": true, "compiled_code": "\n\nwith denominator as (\n\n select\n patient_id\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , denominator_flag\n from dev_thuxuan.quality_measures._int_nqf0053_denominator\n\n)\n\n, numerator as (\n\n select\n patient_id\n , evidence_date\n , evidence_value\n from dev_thuxuan.quality_measures._int_nqf0053_numerator\n\n)\n\n, exclusions as (\n\n select\n patient_id\n , exclusion_date\n , exclusion_reason\n from dev_thuxuan.quality_measures._int_nqf0053_exclusions\n\n)\n\n, measure_flags as (\n\n select\n denominator.patient_id\n , case\n when denominator.patient_id is not null\n then 1\n else null\n end as denominator_flag\n , case\n when numerator.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as numerator_flag\n , case\n when exclusions.patient_id is not null and denominator.patient_id is not null\n then 1\n when denominator.patient_id is not null\n then 0\n else null\n end as exclusion_flag\n , numerator.evidence_date\n , numerator.evidence_value\n , exclusions.exclusion_date\n , exclusions.exclusion_reason\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n , denominator.measure_version\n , (row_number() over(\n partition by\n denominator.patient_id\n , denominator.performance_period_begin\n , denominator.performance_period_end\n , denominator.measure_id\n , denominator.measure_name\n order by\n case when numerator.evidence_date is null then 1 else 0 end,\n numerator.evidence_date desc\n , case when exclusions.exclusion_date is null then 1 else 0 end,\n exclusions.exclusion_date desc\n )) as rn\n from denominator\n left join numerator\n on denominator.patient_id = numerator.patient_id\n left join exclusions\n on denominator.patient_id = exclusions.patient_id\n\n)\n\n/*\n Deduplicate measure rows by latest evidence date or exclusion date\n*/\n, deduped as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n from measure_flags\n where rn = 1\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from deduped\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures._int_nqf0053_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.382477Z", "completed_at": "2024-10-25T14:34:51.393402Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.394408Z", "completed_at": "2024-10-25T14:34:51.394408Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.018828868865966797, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__encounter_augmented", "compiled": true, "compiled_code": "\n\n-- Here we list all encounters from the stg_encounter model\n-- and we augment them with extra fields\n-- that are relevant for readmission measures\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n datediff(\n day,\n aa.admit_date,\n aa.discharge_date\n ) as length_of_stay,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as index_admission_flag,\n case\n when cc.encounter_id is not null then 1\n\t else 0\n end as planned_flag,\n dd.specialty_cohort,\n case\n when aa.discharge_disposition_code = '20' then 1\n\t else 0\n end as died_flag,\n ee.diagnosis_ccs,\n ee.disqualified_encounter_flag,\n ee.missing_admit_date_flag,\n ee.missing_discharge_date_flag,\n ee.admit_after_discharge_flag,\n ee.missing_discharge_disposition_code_flag,\n ee.invalid_discharge_disposition_code_flag,\n ee.missing_primary_diagnosis_flag,\n ee.invalid_primary_diagnosis_code_flag,\n ee.no_diagnosis_ccs_flag,\n ee.overlaps_with_another_encounter_flag,\n ee.missing_ms_drg_flag,\n ee.invalid_ms_drg_flag,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n dev_thuxuan.readmissions._int_encounter aa\n left join dev_thuxuan.readmissions._int_index_admission bb\n on aa.encounter_id = bb.encounter_id\n left join dev_thuxuan.readmissions._int_planned_encounter cc\n on aa.encounter_id = cc.encounter_id \n left join dev_thuxuan.readmissions._int_encounter_specialty_cohort dd\n on aa.encounter_id = dd.encounter_id\n left join dev_thuxuan.readmissions._int_encounter_data_quality ee\n on aa.encounter_id = ee.encounter_id", "relation_name": "dev_thuxuan.readmissions.encounter_augmented"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.400403Z", "completed_at": "2024-10-25T14:34:51.437487Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.440485Z", "completed_at": "2024-10-25T14:34:51.440485Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.04507589340209961, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_rate", "compiled": true, "compiled_code": "\n\nwith num as (\n select\n data_source\n , year_number\n , pqi_number\n , count(encounter_id) as num_count\n from dev_thuxuan.ahrq_measures.pqi_num_long\n group by\n data_source\n , year_number\n , pqi_number\n)\n\n, denom as (\n select\n data_source\n , year_number\n , pqi_number\n , count(patient_id) as denom_count\n from dev_thuxuan.ahrq_measures.pqi_denom_long as d\n group by\n data_source\n , year_number\n , pqi_number\n)\n\nselect\n d.data_source\n , d.year_number\n , d.pqi_number\n , d.denom_count\n , coalesce(num.num_count, 0) as num_count\n , coalesce(num.num_count, 0) / d.denom_count * 100000 as rate_per_100_thousand\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom denom as d\nleft join num\n on d.pqi_number = num.pqi_number\n and d.year_number = num.year_number\n and d.data_source = num.data_source", "relation_name": "dev_thuxuan.ahrq_measures.pqi_rate"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.406402Z", "completed_at": "2024-10-25T14:34:51.438574Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.441486Z", "completed_at": "2024-10-25T14:34:51.441486Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.04508185386657715, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.ahrq_measures__pqi_summary", "compiled": true, "compiled_code": "\n\nselect p.pqi_number\n , m.pqi_name\n , e.year_number\n , e.encounter_id\n , e.data_source\n , e.patient_id\n , e.facility_id\n , e.ms_drg_code\n , e.ms_drg_description\n , e.encounter_start_date\n , e.encounter_end_date\n , e.length_of_stay\n , e.paid_amount\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.ahrq_measures.pqi_num_long p \ninner join dev_thuxuan.ahrq_measures._stg_pqi_inpatient_encounter e\n on p.encounter_id = e.encounter_id\n and p.data_source = e.data_source\ninner join dev_thuxuan.ahrq_measures._value_set_pqi_measures m on cast(p.pqi_number as TEXT) = m.pqi_number", "relation_name": "dev_thuxuan.ahrq_measures.pqi_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.432480Z", "completed_at": "2024-10-25T14:34:51.441486Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.443487Z", "completed_at": "2024-10-25T14:34:51.443487Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.04408431053161621, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.readmissions__readmission_summary", "compiled": true, "compiled_code": "\n\n-- Here calculate days to readmission for encounters\n-- that had a readmission and create readmission flags\n\n\n-- We create the encounter_sequence integer count\n-- which keeps track of what number of encounter each\n-- encounter is for a given patient\nwith encounter_sequence as (\nselect\n *,\n row_number() over(\n partition by patient_id order by admit_date, discharge_date\n ) as encounter_seq\nfrom dev_thuxuan.readmissions.encounter_augmented\nwhere disqualified_encounter_flag = 0\n),\n\n\nreadmission_calc as (\nselect\n aa.encounter_id,\n aa.patient_id,\n aa.admit_date,\n aa.discharge_date,\n aa.discharge_disposition_code,\n aa.facility_id,\n aa.ms_drg_code,\n aa.paid_amount,\n aa.length_of_stay,\n aa.index_admission_flag,\n aa.planned_flag,\n aa.specialty_cohort,\n aa.died_flag,\n aa.diagnosis_ccs,\n case\n when bb.encounter_id is not null then 1\n\t else 0\n end as had_readmission_flag,\n datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n ) as days_to_readmit,\n case\n when (datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30 then 1\n\t else 0\n end as readmit_30_flag,\n case\n when\n\t ((datediff(\n day,\n aa.discharge_date,\n bb.admit_date\n )) <= 30) and (bb.planned_flag = 0) then 1\n\t else 0\n end as unplanned_readmit_30_flag,\n bb.encounter_id as readmission_encounter_id,\n bb.admit_date as readmission_admit_date,\n bb.discharge_date as readmission_discharge_date,\n bb.discharge_disposition_code as readmission_discharge_disposition_code,\n bb.facility_id as readmission_facility,\n bb.ms_drg_code as readmission_ms_drg,\n bb.length_of_stay as readmission_length_of_stay,\n bb.index_admission_flag as readmission_index_admission_flag,\n bb.planned_flag as readmission_planned_flag,\n bb.specialty_cohort as readmission_specialty_cohort,\n bb.died_flag as readmission_died_flag,\n bb.diagnosis_ccs as readmission_diagnosis_ccs,\n '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom\n encounter_sequence aa\n left join encounter_sequence bb\n on aa.patient_id = bb.patient_id\n and aa.encounter_seq + 1 = bb.encounter_seq\n)\n\nselect *\nfrom readmission_calc", "relation_name": "dev_thuxuan.readmissions.readmission_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.454115Z", "completed_at": "2024-10-25T14:34:51.463111Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.464111Z", "completed_at": "2024-10-25T14:34:51.464111Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.014477968215942383, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__readmissions_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('readmission rate' as TEXT) as analytics_measure\n ,cast('readmissions' as TEXT) as analytics_concept\n ,sum(unplanned_readmit_30_flag)/cast(count(*) as numeric(28,6) ) as data_source_value\nfrom dev_thuxuan.readmissions.readmission_summary r \nwhere index_admission_flag = 1\n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('readmissions' as TEXT)", "relation_name": "dev_thuxuan.data_quality.data_quality_readmissions_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.459112Z", "completed_at": "2024-10-25T14:34:51.464111Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:51.466272Z", "completed_at": "2024-10-25T14:34:51.466272Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.014169931411743164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__readmissions", "compiled": true, "compiled_code": "\n\nSELECT *\nFROM dev_thuxuan.readmissions.readmission_summary\nWHERE index_admission_flag = 1", "relation_name": "dev_thuxuan.data_quality.mart_review__readmissions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.424405Z", "completed_at": "2024-10-25T14:34:52.088493Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:52.088493Z", "completed_at": "2024-10-25T14:34:52.088493Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 1.2405431270599365, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__readmissions", "compiled": true, "compiled_code": "\n\n\nwith disqualified_unpivot as (\n select\n encounter_id,\n\n cast('MISSING_ADMIT_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_ADMIT_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DATE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DATE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('ADMIT_AFTER_DISCHARGE_FLAG' as TEXT) as disqualified_reason,\n cast( \n ADMIT_AFTER_DISCHARGE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_DISCHARGE_DISPOSITION_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_DISCHARGE_DISPOSITION_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_PRIMARY_DIAGNOSIS_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_PRIMARY_DIAGNOSIS_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_PRIMARY_DIAGNOSIS_CODE_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('NO_DIAGNOSIS_CCS_FLAG' as TEXT) as disqualified_reason,\n cast( \n NO_DIAGNOSIS_CCS_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG' as TEXT) as disqualified_reason,\n cast( \n OVERLAPS_WITH_ANOTHER_ENCOUNTER_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('MISSING_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n MISSING_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n union all\n select\n encounter_id,\n\n cast('INVALID_MS_DRG_FLAG' as TEXT) as disqualified_reason,\n cast( \n INVALID_MS_DRG_FLAG\n \n as TEXT) as flagvalue\n\n from dev_thuxuan.readmissions.encounter_augmented\n\n \n)\n\n-- Using the transformed data to perform aggregation\nselect \n 'inpatient encounter ' || d.disqualified_reason as data_quality_check\n , count(distinct encounter_id) as result_count\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom disqualified_unpivot d\nwhere cast(flagvalue as integer ) = 1 \ngroup by disqualified_reason", "relation_name": "dev_thuxuan.data_quality.data_quality_readmissions"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:51.414402Z", "completed_at": "2024-10-25T14:34:53.928099Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:53.929098Z", "completed_at": "2024-10-25T14:34:53.929098Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 2.615280866622925, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__summary_long", "compiled": true, "compiled_code": "\n\n/* measures should already be at the full eligibility population grain */\nwith __dbt__cte___stg_patient as (\n\nselect\n patient_id\n , sex\n , birth_date\n , death_date\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.core.patient\n), union_measures as (\n\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf2372_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf2372_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0034_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0034_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0059_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0059_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm236_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm236_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0053_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0053_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cbe0055_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cbe0055_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0097_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0097_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm438_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm438_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0041_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0041_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cbe0101_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cbe0101_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm48_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm48_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_cqm130_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_cqm130_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_nqf0420_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_nqf0420_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_adh_diabetes_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_adh_diabetes_long\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.quality_measures._int_adhras_long' as TEXT) as _dbt_source_relation,\n\n \n cast(\"PATIENT_ID\" as character varying(16777216)) as \"PATIENT_ID\" ,\n cast(\"DENOMINATOR_FLAG\" as NUMBER(38,0)) as \"DENOMINATOR_FLAG\" ,\n cast(\"NUMERATOR_FLAG\" as NUMBER(38,0)) as \"NUMERATOR_FLAG\" ,\n cast(\"EXCLUSION_FLAG\" as NUMBER(38,0)) as \"EXCLUSION_FLAG\" ,\n cast(\"EVIDENCE_DATE\" as DATE) as \"EVIDENCE_DATE\" ,\n cast(\"EVIDENCE_VALUE\" as character varying(16777216)) as \"EVIDENCE_VALUE\" ,\n cast(\"EXCLUSION_DATE\" as DATE) as \"EXCLUSION_DATE\" ,\n cast(\"EXCLUSION_REASON\" as character varying(16777216)) as \"EXCLUSION_REASON\" ,\n cast(\"PERFORMANCE_PERIOD_BEGIN\" as DATE) as \"PERFORMANCE_PERIOD_BEGIN\" ,\n cast(\"PERFORMANCE_PERIOD_END\" as DATE) as \"PERFORMANCE_PERIOD_END\" ,\n cast(\"MEASURE_ID\" as character varying(16777216)) as \"MEASURE_ID\" ,\n cast(\"MEASURE_NAME\" as character varying(16777216)) as \"MEASURE_NAME\" ,\n cast(\"MEASURE_VERSION\" as character varying(16777216)) as \"MEASURE_VERSION\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(32)) as \"TUVA_LAST_RUN\" \n\n from dev_thuxuan.quality_measures._int_adhras_long\n\n \n )\n\n \n\n)\n\n, patient as (\n\n select distinct patient_id\n from __dbt__cte___stg_patient\n\n)\n\n/* selecting the full patient population as the grain of this table */\n, joined as (\n\n select distinct\n patient.patient_id\n , union_measures.denominator_flag\n , union_measures.numerator_flag\n , union_measures.exclusion_flag\n , case\n when union_measures.exclusion_flag = 1 then null\n when union_measures.numerator_flag = 1 then 1\n when union_measures.denominator_flag = 1 then 0\n else null\n end as performance_flag\n , union_measures.evidence_date\n , union_measures.evidence_value\n , union_measures.exclusion_date\n , union_measures.exclusion_reason\n , union_measures.performance_period_begin\n , union_measures.performance_period_end\n , union_measures.measure_id\n , union_measures.measure_name\n , union_measures.measure_version\n from patient\n left join union_measures\n on patient.patient_id = union_measures.patient_id\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(denominator_flag as integer) as denominator_flag\n , cast(numerator_flag as integer) as numerator_flag\n , cast(exclusion_flag as integer) as exclusion_flag\n , cast(performance_flag as integer) as performance_flag\n , cast(evidence_date as date) as evidence_date\n , cast(evidence_value as TEXT) as evidence_value\n , cast(exclusion_date as date) as exclusion_date\n , cast(exclusion_reason as TEXT) as exclusion_reason\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n from joined\n\n)\n\nselect\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , evidence_date\n , evidence_value\n , exclusion_date\n , exclusion_reason\n , performance_period_begin\n , performance_period_end\n , measure_id\n , measure_name\n , measure_version\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures.summary_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.018683Z", "completed_at": "2024-10-25T14:34:54.039683Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:54.041106Z", "completed_at": "2024-10-25T14:34:54.041106Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.02542424201965332, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__analytics_populated", "compiled": true, "compiled_code": "\n\nwith tuva_chronic_condition_long as (\n select\n 'tuva_chronic_condition_long' as table_name\n , count(*) as record_count\n from dev_thuxuan.chronic_conditions.tuva_chronic_conditions_long\n)\n\n, cms_hcc_patient_risk_factors as (\n select\n 'cms_hcc__patient_risk_factors' as table_name\n , count(*) as record_count\n from dev_thuxuan.cms_hcc.patient_risk_factors\n)\n\n, service_category_grouper as (\n select\n 'service_category__service_category_grouper' as table_name\n , count(*) as record_count\n from dev_thuxuan.claims_preprocessing.service_category_grouper\n)\n\n, financial_pmpm_payer as (\n select\n 'financial_pmpm__pmpm_payer' as table_name\n , count(*) as record_count\n from dev_thuxuan.financial_pmpm.pmpm_payer\n)\n\n, readmission_summary as (\n select\n 'readmissions__readmission_summary' as table_name\n , count(*) as record_count\n from dev_thuxuan.readmissions.readmission_summary\n)\n\n, quality_measures_summary_long as (\n select\n 'quality_measures__summary_long' as table_name\n , count(*) as record_count\n from dev_thuxuan.quality_measures.summary_long\n)\n\n, acute_inpatient_visits as (\n select\n 'acute_inpatient_visits' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.encounter\n where encounter_type = 'acute inpatient'\n)\n\n, ed_visits as (\n select\n 'ed_visits' as table_name\n , count(*) as record_count\n from dev_thuxuan.core.encounter\n where encounter_type = 'emergency department'\n)\n\n,final as (\nselect * from tuva_chronic_condition_long\nunion all\nselect * from cms_hcc_patient_risk_factors\nunion all\nselect * from service_category_grouper\nunion all\nselect * from financial_pmpm_payer\nunion all\nselect * from readmission_summary\nunion all\nselect * from quality_measures_summary_long\nunion all\nselect * from acute_inpatient_visits\nunion all\nselect * from ed_visits\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.analytics_populated"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.027686Z", "completed_at": "2024-10-25T14:34:54.039683Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:54.041106Z", "completed_at": "2024-10-25T14:34:54.041106Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.0255277156829834, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__summary_counts", "compiled": true, "compiled_code": "\n\nwith summary_long as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n from dev_thuxuan.quality_measures.summary_long\n where measure_id is not null\n\n)\n\n, calculate_performance_rate as (\n\n select\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , sum(denominator_flag) as denominator_sum\n , sum(numerator_flag) as numerator_sum\n , sum(exclusion_flag) as exclusion_sum\n , (\n cast(sum(performance_flag) as numeric(28,6)) /\n (cast(count(performance_flag) as numeric(28,6)) )\n )*100 as performance_rate\n from summary_long\n group by\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n\n)\n\n, add_data_types as (\n\n select\n cast(measure_id as TEXT) as measure_id\n , cast(measure_name as TEXT) as measure_name\n , cast(measure_version as TEXT) as measure_version\n , cast(performance_period_begin as date) as performance_period_begin\n , cast(performance_period_end as date) as performance_period_end\n , cast(denominator_sum as integer) as denominator_sum\n , cast(numerator_sum as integer) as numerator_sum\n , cast(exclusion_sum as integer) as exclusion_sum\n , round(cast(performance_rate as numeric(28,6)),3) as performance_rate\n from calculate_performance_rate\n\n)\n\nselect\n measure_id\n , measure_name\n , measure_version\n , performance_period_begin\n , performance_period_end\n , denominator_sum\n , numerator_sum\n , exclusion_sum\n , performance_rate\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures.summary_counts"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.024687Z", "completed_at": "2024-10-25T14:34:54.042211Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:54.043216Z", "completed_at": "2024-10-25T14:34:54.043216Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.027533531188964844, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.mart_review__quality_measures_summary_long", "compiled": true, "compiled_code": "\n\n\nselect *\nfrom dev_thuxuan.quality_measures.summary_long s", "relation_name": "dev_thuxuan.data_quality.mart_review__quality_measures_summary_long"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.033686Z", "completed_at": "2024-10-25T14:34:54.042211Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:54.044216Z", "completed_at": "2024-10-25T14:34:54.044216Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 0.02853226661682129, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.quality_measures__summary_wide", "compiled": true, "compiled_code": "\n\n/*\n Each measure is pivoted into a boolean column by evaluating the\n denominator, numerator, and exclusion flags.\n*/\nwith measures_long as (\n\n select\n patient_id\n , denominator_flag\n , numerator_flag\n , exclusion_flag\n , performance_flag\n , measure_id\n from dev_thuxuan.quality_measures.summary_long\n\n)\n\n, nqf_2372 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF2372'\n\n)\n\n, nqf_0034 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0034'\n\n)\n\n, nqf_0059 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0059'\n\n)\n\n, cqm_236 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM236'\n\n)\n\n, nqf_0053 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0053'\n\n)\n\n, cbe_0055 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0055'\n\n)\n\n, nqf_0097 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0097'\n\n)\n\n, cqm_438 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM438'\n\n)\n\n, nqf_0041 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0041'\n\n)\n\n, cbe_0101 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CBE0101'\n\n)\n\n, cqm_48 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM48'\n\n)\n\n, cqm_130 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'CQM130'\n\n)\n\n, nqf_0420 as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'NQF0420'\n\n)\n\n, adh_diabetes as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-Diabetes'\n\n)\n\n, adh_ras as (\n\n select\n patient_id\n , performance_flag\n from measures_long\n where measure_id = 'ADH-RAS'\n \n)\n\n, joined as (\n\n select\n measures_long.patient_id\n , max(nqf_2372.performance_flag) as nqf_2372\n , max(nqf_0034.performance_flag) as nqf_0034\n , max(nqf_0059.performance_flag) as nqf_0059\n , max(cqm_236.performance_flag) as cqm_236\n , max(nqf_0053.performance_flag) as nqf_0053\n , max(cbe_0055.performance_flag) as cbe_0055\n , max(nqf_0097.performance_flag) as nqf_0097\n , max(cqm_438.performance_flag) as cqm_438\n , max(nqf_0041.performance_flag) as nqf_0041\n , max(cbe_0101.performance_flag) as cbe_0101\n , max(cqm_48.performance_flag) as cqm_48\n , max(cqm_130.performance_flag) as cqm_130\n , max(nqf_0420.performance_flag) as nqf_0420\n , max(adh_diabetes.performance_flag) as adh_diabetes\n , max(adh_ras.performance_flag) as adh_ras\n from measures_long\n left join nqf_2372\n on measures_long.patient_id = nqf_2372.patient_id\n left join nqf_0034\n on measures_long.patient_id = nqf_0034.patient_id\n left join nqf_0059\n on measures_long.patient_id = nqf_0059.patient_id\n left join cqm_236\n on measures_long.patient_id = cqm_236.patient_id\n left join nqf_0053\n on measures_long.patient_id = nqf_0053.patient_id\n left join cbe_0055\n on measures_long.patient_id = cbe_0055.patient_id\n left join nqf_0097\n on measures_long.patient_id = nqf_0097.patient_id\n left join cqm_438\n on measures_long.patient_id = cqm_438.patient_id\n left join nqf_0041\n on measures_long.patient_id = nqf_0041.patient_id\n left join cbe_0101\n on measures_long.patient_id = cbe_0101.patient_id\n left join cqm_48\n on measures_long.patient_id = cqm_48.patient_id\n left join cqm_130\n on measures_long.patient_id = cqm_130.patient_id\n left join nqf_0420\n on measures_long.patient_id = nqf_0420.patient_id\n left join adh_diabetes\n on measures_long.patient_id = adh_diabetes.patient_id\n left join adh_ras\n on measures_long.patient_id = adh_ras.patient_id\n group by measures_long.patient_id\n\n)\n\n, add_data_types as (\n\n select\n cast(patient_id as TEXT) as patient_id\n , cast(nqf_2372 as integer) as nqf_2372\n , cast(nqf_0034 as integer) as nqf_0034\n , cast(nqf_0059 as integer) as nqf_0059\n , cast(cqm_236 as integer) as cqm_236\n , cast(nqf_0053 as integer) as nqf_0053\n , cast(cbe_0055 as integer) as cbe_0055\n , cast(nqf_0097 as integer) as nqf_0097\n , cast(cqm_438 as integer) as cqm_438 \n , cast(nqf_0041 as integer) as nqf_0041\n , cast(cbe_0101 as integer) as cbe_0101\n , cast(cqm_48 as integer) as cqm_48\n , cast(cqm_130 as integer) as cqm_130\n , cast(nqf_0420 as integer) as nqf_0420\n , cast(adh_diabetes as integer) as adh_diabetes\n , cast(adh_ras as integer) as adh_ras\n from joined\n\n)\n\nselect\n patient_id\n , nqf_2372\n , nqf_0034\n , nqf_0059\n , cqm_236\n , nqf_0053\n , cbe_0055\n , nqf_0097\n , cqm_438\n , nqf_0041\n , cbe_0101\n , cqm_48\n , cqm_130\n , nqf_0420\n , adh_diabetes\n , adh_ras\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom add_data_types", "relation_name": "dev_thuxuan.quality_measures.summary_wide"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.047218Z", "completed_at": "2024-10-25T14:34:54.056729Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:54.056729Z", "completed_at": "2024-10-25T14:34:54.056729Z"}], "thread_id": "Thread-5 (worker)", "execution_time": 0.01151418685913086, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__quality_measures", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect sum(case when numerator_sum = 0 then 1 else 0 end) as numerator_zero_count\n,sum(case when denominator_sum = 0 then 1 else 0 end) as denominator_zero_count\nfrom dev_thuxuan.quality_measures.summary_counts \n)\n\n,final as (\nselect 'quality measure numerator zero' as data_quality_check\n,numerator_zero_count as result_count\nfrom cte \n\nunion all \n\nselect 'quality measure denominator zero' as data_quality_check\n,denominator_zero_count as result_count\nfrom cte\n)\n\nselect *\n, '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom final", "relation_name": "dev_thuxuan.data_quality.data_quality_quality_measures"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.051726Z", "completed_at": "2024-10-25T14:34:54.057733Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:54.057733Z", "completed_at": "2024-10-25T14:34:54.057733Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.012512922286987305, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__quality_measures_reference", "compiled": true, "compiled_code": "\n\nwith cte as (\nselect \n cast('quality measures' as TEXT) as analytics_concept\n ,measure_name as analytics_measure\n ,performance_rate as data_source_value\nfrom dev_thuxuan.quality_measures.summary_counts r \n)\n\nselect \n m.analytics_concept as analytics_concept\n ,m.analytics_measure as analytics_measure\n ,cte.data_source_value\n ,m.analytics_value\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom dev_thuxuan.data_quality._value_set_reference_mart_analytics m \nleft join cte on cte.analytics_measure = m.analytics_measure\nand\nm.analytics_concept = cte.analytics_concept\nwhere m.analytics_concept = cast('quality measures' as TEXT)", "relation_name": "dev_thuxuan.data_quality.data_quality_quality_measures_reference"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.060738Z", "completed_at": "2024-10-25T14:34:55.099261Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:55.100224Z", "completed_at": "2024-10-25T14:34:55.100224Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 1.1294686794281006, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__analytics_checks_summary", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_readmissions' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_readmissions\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.chronic_conditions_none' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"MEDICARE_LDS_REFERENCE\" as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(\"NORMALLY_ZERO\" as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.chronic_conditions_none\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_cms_hcc' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_cms_hcc\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_quality_measures' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_quality_measures\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.encounters_missing_groups_union' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.encounters_missing_groups_union\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_acute_inpatient' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_acute_inpatient\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_ed_classification' as TEXT) as _dbt_source_relation,\n\n \n cast(\"DATA_QUALITY_CHECK\" as character varying(16777216)) as \"DATA_QUALITY_CHECK\" ,\n cast(\"RESULT_COUNT\" as NUMBER(18,0)) as \"RESULT_COUNT\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as character varying(256)) as \"MEDICARE_LDS_REFERENCE\" ,\n cast(null as NUMBER(1,0)) as \"NORMALLY_ZERO\" \n\n from dev_thuxuan.data_quality.data_quality_ed_classification\n\n \n )\n\n \n\n)\n\nselect\n data_quality_check\n , result_count\n , coalesce(normally_zero ,1) as normally_zero\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned_data", "relation_name": "dev_thuxuan.data_quality.analytics_checks_summary"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:55.193191Z", "completed_at": "2024-10-25T14:34:55.201189Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:55.201189Z", "completed_at": "2024-10-25T14:34:55.201189Z"}], "thread_id": "Thread-4 (worker)", "execution_time": 0.009999513626098633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.not_null_data_quality__analytics_checks_summary_data_quality_check.91ca1cc43a", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect data_quality_check\nfrom dev_thuxuan.data_quality.analytics_checks_summary\nwhere data_quality_check is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:55.197190Z", "completed_at": "2024-10-25T14:34:55.201189Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:55.202192Z", "completed_at": "2024-10-25T14:34:55.202192Z"}], "thread_id": "Thread-3 (worker)", "execution_time": 0.010002851486206055, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.the_tuva_project.unique_data_quality__analytics_checks_summary_data_quality_check.1150c178a0", "compiled": true, "compiled_code": "\n \n \n\nselect\n data_quality_check as unique_field,\n count(*) as n_records\n\nfrom dev_thuxuan.data_quality.analytics_checks_summary\nwhere data_quality_check is not null\ngroup by data_quality_check\nhaving count(*) > 1\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-10-25T14:34:54.066739Z", "completed_at": "2024-10-25T14:34:55.273981Z"}, {"name": "execute", "started_at": "2024-10-25T14:34:55.274981Z", "completed_at": "2024-10-25T14:34:55.274981Z"}], "thread_id": "Thread-2 (worker)", "execution_time": 1.3009426593780518, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.the_tuva_project.data_quality__analytics_reference_summary", "compiled": true, "compiled_code": "\n\nwith unioned_data as (\n\n -- Unioning multiple data quality checks, excluding the _loaded_at field\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_readmissions_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_readmissions_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_cms_hcc_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_cms_hcc_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.chronic_conditions_prevalence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(\"PATIENTS\" as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(\"MEDICARE_LDS_CONDITION_RANK\" as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.chronic_conditions_prevalence\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_quality_measures_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_quality_measures_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_acute_inpatient_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_acute_inpatient_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_acute_inpatient_prevelence' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_acute_inpatient_prevelence\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.encounters_cost_and_utilization' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(\"ENCOUNTER_GROUP\" as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.encounters_cost_and_utilization\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.data_quality_ed_classification_reference' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(\"VALUE_RANK\" as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(null as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(null as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.data_quality_ed_classification_reference\n\n \n )\n\n union all\n \n\n (\n select\n cast('dev_thuxuan.data_quality.service_categories_pmpm' as TEXT) as _dbt_source_relation,\n\n \n cast(\"ANALYTICS_CONCEPT\" as character varying(16777216)) as \"ANALYTICS_CONCEPT\" ,\n cast(\"ANALYTICS_MEASURE\" as character varying(16777216)) as \"ANALYTICS_MEASURE\" ,\n cast(\"DATA_SOURCE_VALUE\" as NUMBER(25,6)) as \"DATA_SOURCE_VALUE\" ,\n cast(\"ANALYTICS_VALUE\" as character varying(256)) as \"ANALYTICS_VALUE\" ,\n cast(\"TUVA_LAST_RUN\" as character varying(16777216)) as \"TUVA_LAST_RUN\" ,\n cast(null as NUMBER(18,0)) as \"PATIENTS\" ,\n cast(null as NUMBER(18,0)) as \"VALUE_RANK\" ,\n cast(null as NUMBER(38,0)) as \"MEDICARE_LDS_CONDITION_RANK\" ,\n cast(null as character varying(16777216)) as \"ENCOUNTER_GROUP\" ,\n cast(\"TOTAL_PAID\" as NUMBER(38,6)) as \"TOTAL_PAID\" ,\n cast(\"MEMBER_MONTHS\" as NUMBER(36,6)) as \"MEMBER_MONTHS\" \n\n from dev_thuxuan.data_quality.service_categories_pmpm\n\n \n )\n\n \n\n)\n\nselect\n analytics_concept \n , analytics_measure\n , data_source_value\n , analytics_value\n , value_rank\n , '2024-10-25 14:34:26.237057+00:00' as tuva_last_run\nfrom unioned_data", "relation_name": "dev_thuxuan.data_quality.analytics_reference_summary"}], "elapsed_time": 26.151333808898926, "args": {"cache_selected_only": false, "use_colors": true, "require_resource_names_without_spaces": false, "exclude": [], "which": "generate", "empty_catalog": false, "warn_error_options": {"include": [], "exclude": []}, "require_explicit_package_overrides_for_builtin_materializations": true, "use_colors_file": true, "enable_legacy_logger": false, "favor_state": false, "printer_width": 80, "version_check": true, "write_json": true, "compile": true, "quiet": false, "source_freshness_run_project_hooks": false, "static": false, "introspect": true, "log_level_file": "debug", "strict_mode": false, "log_path": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate\\logs", "log_level": "info", "populate_cache": true, "log_file_max_bytes": 10485760, "show_resource_report": false, "send_anonymous_usage_stats": true, "macro_debugging": false, "profiles_dir": "C:\\Users\\thuxuan\\PycharmProjects", "partial_parse": true, "defer": false, "indirect_selection": "eager", "log_format_file": "debug", "print": true, "select": [], "vars": {}, "partial_parse_file_diff": true, "log_format": "default", "project_dir": "C:\\Users\\thuxuan\\tuva\\integration_tests\\docs_generate", "invocation_command": "dbt docs generate", "static_parser": true}} \ No newline at end of file